Browse Source

Merge branch 'develop' of github.com:ethereum/cpp-ethereum into develop

Conflicts:
	mix/AppContext.cpp
	mix/qml/StateList.qml
cl-refactor
Gav Wood 10 years ago
parent
commit
ad92d3ba03
  1. 10
      mix/AppContext.cpp
  2. 27
      mix/ClientModel.cpp
  3. 20
      mix/DebuggingStateWrapper.cpp
  4. 15
      mix/DebuggingStateWrapper.h
  5. 59
      mix/QBigInt.cpp
  6. 102
      mix/QBigInt.h
  7. 55
      mix/QEther.cpp
  8. 92
      mix/QEther.h
  9. 3
      mix/qml.qrc
  10. 13
      mix/qml/BigIntValue.qml
  11. 115
      mix/qml/Ether.qml
  12. 15
      mix/qml/EtherValue.qml
  13. 25
      mix/qml/StateDialog.qml
  14. 8
      mix/qml/StateList.qml
  15. 48
      mix/qml/TransactionDialog.qml
  16. 6
      mix/qml/js/Debugger.js

10
mix/AppContext.cpp

@ -32,7 +32,8 @@
#include "CodeEditorExtensionManager.h"
#include "Exceptions.h"
#include "AppContext.h"
#include <libwebthree/WebThree.h> //this needs to be last because it pulls windows.h through libp2p/boost_asio
#include "QEther.h"
#include <libwebthree/WebThree.h>
using namespace dev;
using namespace dev::eth;
@ -47,6 +48,13 @@ AppContext::AppContext(QQmlApplicationEngine* _engine)
m_codeModel.reset(new CodeModel(this));
m_clientModel.reset(new ClientModel(this));
m_fileIo.reset(new FileIo());
m_applicationEngine->rootContext()->setContextProperty("appContext", this);
qmlRegisterType<FileIo>("org.ethereum.qml", 1, 0, "FileIo");
qmlRegisterSingletonType(QUrl("qrc:/qml/ProjectModel.qml"), "org.ethereum.qml.ProjectModel", 1, 0, "ProjectModel");
qmlRegisterType<QEther>("org.ethereum.qml.QEther", 1, 0, "QEther");
qmlRegisterType<QBigInt>("org.ethereum.qml.QBigInt", 1, 0, "QBigInt");
m_applicationEngine->rootContext()->setContextProperty("codeModel", m_codeModel.get());
m_applicationEngine->rootContext()->setContextProperty("fileIo", m_fileIo.get());
}
AppContext::~AppContext()

27
mix/ClientModel.cpp

@ -32,28 +32,17 @@
#include "ContractCallDataEncoder.h"
#include "CodeModel.h"
#include "ClientModel.h"
#include "QEther.h"
using namespace dev;
using namespace dev::eth;
using namespace dev::mix;
/// @todo Move this to QML
dev::u256 fromQString(QString const& _s)
{
return dev::jsToU256(_s.toStdString());
}
/// @todo Move this to QML
QString toQString(dev::u256 _value)
{
std::ostringstream s;
s << _value;
return QString::fromStdString(s.str());
}
ClientModel::ClientModel(AppContext* _context):
m_context(_context), m_running(false)
{
qRegisterMetaType<QBigInt*>("QBigInt*");
qRegisterMetaType<QEther*>("QEther*");
qRegisterMetaType<QVariableDefinition*>("QVariableDefinition*");
qRegisterMetaType<QVariableDefinitionList*>("QVariableDefinitionList*");
qRegisterMetaType<QList<QVariableDefinition*>>("QList<QVariableDefinition*>");
@ -74,7 +63,7 @@ void ClientModel::debugDeployment()
void ClientModel::debugState(QVariantMap _state)
{
u256 balance = fromQString(_state.value("balance").toString());
u256 balance = (qvariant_cast<QEther*>(_state.value("balance")))->toU256Wei();
QVariantList transactions = _state.value("transactions").toList();
std::vector<TransactionSettings> transactionSequence;
@ -84,14 +73,14 @@ void ClientModel::debugState(QVariantMap _state)
QVariantMap transaction = t.toMap();
QString functionId = transaction.value("functionId").toString();
u256 value = fromQString(transaction.value("value").toString());
u256 gas = fromQString(transaction.value("gas").toString());
u256 gasPrice = fromQString(transaction.value("gasPrice").toString());
u256 gas = (qvariant_cast<QEther*>(transaction.value("gas")))->toU256Wei();
u256 value = (qvariant_cast<QEther*>(transaction.value("value")))->toU256Wei();
u256 gasPrice = (qvariant_cast<QEther*>(transaction.value("gasPrice")))->toU256Wei();
QVariantMap params = transaction.value("parameters").toMap();
TransactionSettings transactionSettings(functionId, value, gas, gasPrice);
for (auto p = params.cbegin(); p != params.cend(); ++p)
transactionSettings.parameterValues.insert(std::make_pair(p.key(), fromQString(p.value().toString())));
transactionSettings.parameterValues.insert(std::make_pair(p.key(), (qvariant_cast<QEther*>(p.value()))->toU256Wei()));
transactionSequence.push_back(transactionSettings);
}

20
mix/DebuggingStateWrapper.cpp

@ -23,12 +23,14 @@
#include <QApplication>
#include <QDebug>
#include <QPointer>
#include <QQmlEngine>
#include <libevmcore/Instruction.h>
#include <libdevcore/CommonJS.h>
#include <libdevcrypto/Common.h>
#include <libevmcore/Instruction.h>
#include <libdevcore/Common.h>
#include "DebuggingStateWrapper.h"
#include "QBigInt.h"
using namespace dev;
using namespace dev::eth;
using namespace dev::mix;
@ -66,25 +68,19 @@ std::tuple<QList<QObject*>, QQMLMap*> DebuggingStateWrapper::getHumanReadableCod
return std::make_tuple(codeStr, QPointer<QQMLMap>(new QQMLMap(codeMapping)));
}
QString DebuggingStateWrapper::gasCost()
QBigInt* DebuggingStateWrapper::gasCost()
{
std::ostringstream ss;
ss << std::dec << m_state.gasCost;
return QString::fromStdString(ss.str());
return new QBigInt(m_state.gasCost);
}
QString DebuggingStateWrapper::gas()
QBigInt* DebuggingStateWrapper::gas()
{
std::ostringstream ss;
ss << std::dec << m_state.gas;
return QString::fromStdString(ss.str());
return new QBigInt(m_state.gas);
}
QString DebuggingStateWrapper::newMemSize()
QBigInt* DebuggingStateWrapper::newMemSize()
{
std::ostringstream ss;
ss << std::dec << m_state.newMemSize;
return QString::fromStdString(ss.str());
return new QBigInt(m_state.newMemSize);
}
QStringList DebuggingStateWrapper::debugStack()

15
mix/DebuggingStateWrapper.h

@ -29,6 +29,7 @@
#include <libethereum/Executive.h>
#include "QVariableDefinition.h"
#include "MixClient.h"
#include "QBigInt.h"
namespace dev
{
@ -81,8 +82,8 @@ class DebuggingStateWrapper: public QObject
Q_OBJECT
Q_PROPERTY(int step READ step CONSTANT)
Q_PROPERTY(int curPC READ curPC CONSTANT)
Q_PROPERTY(QString gasCost READ gasCost CONSTANT)
Q_PROPERTY(QString gas READ gas CONSTANT)
Q_PROPERTY(QBigInt* gasCost READ gasCost CONSTANT)
Q_PROPERTY(QBigInt* gas READ gas CONSTANT)
Q_PROPERTY(QString instruction READ instruction CONSTANT)
Q_PROPERTY(QStringList debugStack READ debugStack CONSTANT)
Q_PROPERTY(QStringList debugStorage READ debugStorage CONSTANT)
@ -90,7 +91,7 @@ class DebuggingStateWrapper: public QObject
Q_PROPERTY(QVariantList debugCallData READ debugCallData CONSTANT)
Q_PROPERTY(QString headerInfo READ headerInfo CONSTANT)
Q_PROPERTY(QString endOfDebug READ endOfDebug CONSTANT)
Q_PROPERTY(QString newMemSize READ newMemSize CONSTANT)
Q_PROPERTY(QBigInt* newMemSize READ newMemSize CONSTANT)
Q_PROPERTY(QStringList levels READ levels CONSTANT)
public:
@ -99,12 +100,10 @@ public:
int step() { return (int)m_state.steps; }
/// Get the proccessed code index.
int curPC() { return (int)m_state.curPC; }
/// Get gas left.
QString gasLeft();
/// Get gas cost.
QString gasCost();
QBigInt* gasCost();
/// Get gas used.
QString gas();
QBigInt* gas();
/// Get stack.
QStringList debugStack();
/// Get storage.
@ -118,7 +117,7 @@ public:
/// get end of debug information.
QString endOfDebug();
/// Get the new memory size.
QString newMemSize();
QBigInt* newMemSize();
/// Get current instruction
QString instruction();
/// Get all previous steps.

59
mix/QBigInt.cpp

@ -0,0 +1,59 @@
/*
This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file QBigInt.cpp
* @author Yann yann@ethdev.com
* @date 2015
*/
#include <boost/variant/multivisitors.hpp>
#include <boost/variant.hpp>
#include <libdevcore/CommonJS.h>
#include "QBigInt.h"
using namespace dev;
using namespace dev::mix;
QString QBigInt::value() const
{
std::ostringstream s;
s << m_internalValue;
return QString::fromStdString(s.str());
}
QBigInt* QBigInt::subtract(QBigInt* const& _value) const
{
BigIntVariant toSubtract = _value->internalValue();
return new QBigInt(boost::apply_visitor(mix::subtract(), m_internalValue, toSubtract));
}
QBigInt* QBigInt::add(QBigInt* const& _value) const
{
BigIntVariant toAdd = _value->internalValue();
return new QBigInt(boost::apply_visitor(mix::add(), m_internalValue, toAdd));
}
QBigInt* QBigInt::multiply(QBigInt* const& _value) const
{
BigIntVariant toMultiply = _value->internalValue();
return new QBigInt(boost::apply_visitor(mix::multiply(), m_internalValue, toMultiply));
}
QBigInt* QBigInt::divide(QBigInt* const& _value) const
{
BigIntVariant toDivide = _value->internalValue();
return new QBigInt(boost::apply_visitor(mix::divide(), m_internalValue, toDivide));
}

102
mix/QBigInt.h

@ -0,0 +1,102 @@
/*
This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file QBigInt.h
* @author Yann yann@ethdev.com
* @date 2015
* Represent a big integer (u256, bigint) to be used in QML.
*/
#pragma once
#include "boost/variant.hpp"
#include "boost/variant/multivisitors.hpp"
#include <QObject>
#include <QQmlEngine>
#include <libdevcore/CommonJS.h>
#include <libdevcore/Common.h>
using namespace dev;
namespace dev
{
namespace mix
{
using BigIntVariant = boost::variant<dev::u256, dev::bigint>;
struct add: public boost::static_visitor<BigIntVariant>
{
template<class T1, class T2>
BigIntVariant operator()(T1 const& _value, T2 const& _otherValue) const { return _value + _otherValue; }
};
struct subtract: public boost::static_visitor<BigIntVariant>
{
template<class T1, class T2>
BigIntVariant operator()(T1 const& _value, T2 const& _otherValue) const { return _value - _otherValue; }
};
struct multiply: public boost::static_visitor<BigIntVariant>
{
template<class T1, class T2>
BigIntVariant operator()(T1 const& _value, T2 const& _otherValue) const { return _value * _otherValue; }
};
struct divide: public boost::static_visitor<BigIntVariant>
{
template<class T1, class T2>
BigIntVariant operator()(T1 const& _value, T2 const& _otherValue) const { return _value / _otherValue; }
};
/*
* Represent big integer like big int and u256 in QML.
* The ownership is set by default to Javascript.
*/
class QBigInt: public QObject
{
Q_OBJECT
public:
QBigInt(QObject* _parent = 0): QObject(_parent), m_internalValue(dev::u256(0)) { QQmlEngine::setObjectOwnership(this, QQmlEngine::JavaScriptOwnership); }
QBigInt(dev::u256 const& _value, QObject* _parent = 0): QObject(_parent), m_internalValue(_value) { QQmlEngine::setObjectOwnership(this, QQmlEngine::JavaScriptOwnership); }
QBigInt(dev::bigint const& _value, QObject* _parent = 0): QObject(_parent), m_internalValue(_value) { QQmlEngine::setObjectOwnership(this, QQmlEngine::JavaScriptOwnership); }
QBigInt(BigIntVariant const& _value, QObject* _parent = 0): QObject(_parent), m_internalValue(_value){ QQmlEngine::setObjectOwnership(this, QQmlEngine::JavaScriptOwnership); }
~QBigInt() {}
/// @returns the current used big integer.
BigIntVariant internalValue() { return m_internalValue; }
/// @returns a string representation of the big integer used. Invokable from QML.
Q_INVOKABLE QString value() const;
/// Set the value of the BigInteger used. Will use u256 type. Invokable from QML.
Q_INVOKABLE void setValue(QString const& _value) { m_internalValue = dev::jsToU256(_value.toStdString()); }
/// Subtract by @a _value. Invokable from QML.
Q_INVOKABLE QBigInt* subtract(QBigInt* const& _value) const;
/// Add @a _value to the current big integer. Invokable from QML.
Q_INVOKABLE QBigInt* add(QBigInt* const& _value) const;
/// Multiply by @a _value. Invokable from QML.
Q_INVOKABLE QBigInt* multiply(QBigInt* const& _value) const;
/// divide by @a _value. Invokable from QML.
Q_INVOKABLE QBigInt* divide(QBigInt* const& _value) const;
protected:
BigIntVariant m_internalValue;
};
}
}

55
mix/QEther.cpp

@ -0,0 +1,55 @@
/*
This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file QEther.cpp
* @author Yann yann@ethdev.com
* @date 2014
*/
#include <QMetaEnum>
#include "QEther.h"
using namespace dev::mix;
QString QEther::format() const
{
return QString::fromStdString(dev::eth::formatBalance(boost::get<dev::u256>(toWei()->internalValue())));
}
QBigInt* QEther::toWei() const
{
QMetaEnum units = staticMetaObject.enumerator(staticMetaObject.indexOfEnumerator("EtherUnit"));
const char* key = units.valueToKey(m_currentUnit);
for (std::pair<dev::u256, std::string> rawUnit: dev::eth::units())
{
if (rawUnit.second == QString(key).toLower().toStdString())
return multiply(new QBigInt(rawUnit.first));
}
return new QBigInt(dev::u256(0));
}
void QEther::setUnit(QString const& _unit)
{
QMetaEnum units = staticMetaObject.enumerator(staticMetaObject.indexOfEnumerator("EtherUnit"));
for (int k = 0; k < units.keyCount(); k++)
{
if (QString(units.key(k)).toLower() == _unit)
{
m_currentUnit = static_cast<EtherUnit>(units.keysToValue(units.key(k)));
return;
}
}
}

92
mix/QEther.h

@ -0,0 +1,92 @@
/*
This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file QEther.h
* @author Yann yann@ethdev.com
* @date 2014
* Represent an amount of Ether in QML (mapped to u256 in c++).
*/
#pragma once
#include <QObject>
#include <libethcore/CommonEth.h>
#include "QBigInt.h"
namespace dev
{
namespace mix
{
class QEther: public QBigInt
{
Q_OBJECT
Q_ENUMS(EtherUnit)
Q_PROPERTY(QString value READ value WRITE setValue NOTIFY valueChanged)
Q_PROPERTY(EtherUnit unit READ unit WRITE setUnit NOTIFY unitChanged)
public:
enum EtherUnit
{
Uether,
Vether,
Dether,
Nether,
Yether,
Zether,
Eether,
Pether,
Tether,
Gether,
Mether,
Grand,
Ether,
Finney,
Szabo,
Gwei,
Mwei,
Kwei,
Wei
};
QEther(QObject* _parent = 0): QBigInt(dev::u256(0), _parent), m_currentUnit(EtherUnit::Wei) {}
QEther(dev::u256 _value, EtherUnit _unit, QObject* _parent = 0): QBigInt(_value, _parent), m_currentUnit(_unit) {}
~QEther() {}
/// @returns user-friendly string representation of the amount of ether. Invokable from QML.
Q_INVOKABLE QString format() const;
/// @returns the current amount of Ether in Wei. Invokable from QML.
Q_INVOKABLE QBigInt* toWei() const;
/// @returns the current unit used. Invokable from QML.
Q_INVOKABLE EtherUnit unit() const { return m_currentUnit; }
/// Set the unit to be used. Invokable from QML.
Q_INVOKABLE void setUnit(EtherUnit const& _unit) { m_currentUnit = _unit; }
/// Set the unit to be used. Invokable from QML.
Q_INVOKABLE void setUnit(QString const& _unit);
/// @returns the u256 value of the current amount of Ether in Wei.
dev::u256 toU256Wei() { return boost::get<dev::u256>(toWei()->internalValue()); }
private:
EtherUnit m_currentUnit;
signals:
void valueChanged();
void unitChanged();
};
}
}

3
mix/qml.qrc

@ -40,5 +40,8 @@
<file>qml/CodeEditorView.qml</file>
<file>qml/js/ProjectModel.js</file>
<file>qml/WebPreview.qml</file>
<file>qml/Ether.qml</file>
<file>qml/EtherValue.qml</file>
<file>qml/BigIntValue.qml</file>
</qresource>
</RCC>

13
mix/qml/BigIntValue.qml

@ -0,0 +1,13 @@
/*
* Used to instanciate a QEther obj using Qt.createComponent function.
*/
import QtQuick 2.2
import QtQuick.Controls 1.1
import QtQuick.Layouts 1.1
import QtQuick.Controls.Styles 1.1
import org.ethereum.qml.QBigInt 1.0
QBigInt
{
id: bigInt
}

115
mix/qml/Ether.qml

@ -0,0 +1,115 @@
/*
* Display a row containing :
* - The amount of Ether.
* - The unit used.
* - User-friendly string representation of the amout of Ether (if displayFormattedValue == true).
* 'value' has to be a QEther obj.
*/
import QtQuick 2.2
import QtQuick.Controls 1.1
import QtQuick.Layouts 1.1
import QtQuick.Controls.Styles 1.1
Rectangle {
id: etherEdition
property bool displayFormattedValue;
property bool edit;
property variant value;
onValueChanged: update()
Component.onCompleted: update()
function update()
{
if (value !== undefined)
{
etherValueEdit.text = value.value;
selectUnit(value.unit);
}
}
function selectUnit(unit)
{
units.currentIndex = unit;
}
RowLayout
{
anchors.fill: parent;
id: row
width: 200
height: parent.height
Rectangle
{
width : 200
color: edit ? "blue" : "white"
TextField
{
onTextChanged:
{
if (value !== undefined)
{
value.setValue(text)
formattedValue.text = value.format();
}
}
width: parent.width
readOnly: !edit
visible: edit
id: etherValueEdit;
}
}
Rectangle
{
Layout.fillWidth: true
id: unitContainer
width: 20
anchors.verticalCenter: parent.verticalCenter
ComboBox
{
id: units
onCurrentTextChanged:
{
if (value !== undefined)
{
value.setUnit(currentText);
formattedValue.text = value.format();
}
}
model: ListModel {
id: unitsModel
ListElement { text: "Uether"; }
ListElement { text: "Vether"; }
ListElement { text: "Dether"; }
ListElement { text: "Nether"; }
ListElement { text: "Yether"; }
ListElement { text: "Zether"; }
ListElement { text: "Eether"; }
ListElement { text: "Pether"; }
ListElement { text: "Tether"; }
ListElement { text: "Gether"; }
ListElement { text: "Mether"; }
ListElement { text: "grand"; }
ListElement { text: "ether"; }
ListElement { text: "finney"; }
ListElement { text: "szabo"; }
ListElement { text: "Gwei"; }
ListElement { text: "Mwei"; }
ListElement { text: "Kwei"; }
ListElement { text: "wei"; }
}
}
Rectangle
{
anchors.verticalCenter: parent.verticalCenter
anchors.left: units.right
visible: displayFormattedValue
width: 20
Text
{
id: formattedValue
}
}
}
}
}

15
mix/qml/EtherValue.qml

@ -0,0 +1,15 @@
/*
* Used to instanciate a QEther obj using Qt.createComponent function.
*/
import QtQuick 2.2
import QtQuick.Controls 1.1
import QtQuick.Layouts 1.1
import QtQuick.Controls.Styles 1.1
import org.ethereum.qml.QEther 1.0
QEther
{
id: basicEther
value: "100000000000"
unit: QEther.Wei
}

25
mix/qml/StateDialog.qml

@ -2,8 +2,10 @@ import QtQuick 2.2
import QtQuick.Controls 1.1
import QtQuick.Layouts 1.1
import QtQuick.Window 2.0
import org.ethereum.qml.QEther 1.0
Window {
id: modalStateDialog
modality: Qt.WindowModal
width:640
@ -12,7 +14,7 @@ Window {
visible: false
property alias stateTitle: titleField.text
property alias stateBalance: balanceField.text
property alias stateBalance: balanceField.value
property int stateIndex
property var stateTransactions: []
signal accepted
@ -20,7 +22,7 @@ Window {
function open(index, item) {
stateIndex = index;
stateTitle = item.title;
stateBalance = item.balance;
balanceField.value = item.balance;
transactionsModel.clear();
stateTransactions = [];
var transactions = item.transactions;
@ -66,8 +68,10 @@ Window {
Label {
text: qsTr("Balance")
}
TextField {
Ether {
id: balanceField
edit: true
displayFormattedValue: true
Layout.fillWidth: true
}
@ -114,16 +118,25 @@ Window {
transactionDialog.open(index, transactionsModel.get(index));
}
function ether(_value, _unit)
{
var etherComponent = Qt.createComponent("qrc:/qml/EtherValue.qml");
var ether = etherComponent.createObject(modalStateDialog);
ether.setValue(_value);
ether.setUnit(_unit);
return ether;
}
function addTransaction() {
// Set next id here to work around Qt bug
// https://bugreports.qt-project.org/browse/QTBUG-41327
// Second call to signal handler would just edit the item that was just created, no harm done
var item = {
value: "0",
value: ether("0", QEther.Wei),
functionId: "",
gas: "125000",
gasPrice: "100000"
gas: ether("125000", QEther.Wei),
gasPrice: ether("100000", QEther.Wei)
};
transactionDialog.open(transactionsModel.count, item);

8
mix/qml/StateList.qml

@ -3,6 +3,8 @@ import QtQuick.Controls.Styles 1.1
import QtQuick.Controls 1.1
import QtQuick.Dialogs 1.1
import QtQuick.Layouts 1.1
import org.ethereum.qml.ProjectModel 1.0
import org.ethereum.qml.QEther 1.0
Rectangle {
color: "#ededed"
@ -66,9 +68,13 @@ Rectangle {
id: stateListModel
function addState() {
var etherComponent = Qt.createComponent("qrc:/qml/EtherValue.qml");
var ether = etherComponent.createObject(stateListContainer);
ether.setValue("100000000000000000000000000");
ether.setUnit(QEther.Wei);
var item = {
title: "",
balance: "100000000000000000000000000",
balance: ether,
transactions: []
};
stateDialog.open(stateListModel.count, item);

48
mix/qml/TransactionDialog.qml

@ -2,8 +2,10 @@ import QtQuick 2.2
import QtQuick.Controls 1.1
import QtQuick.Layouts 1.1
import QtQuick.Window 2.0
import org.ethereum.qml.QEther 1.0
Window {
id: modalTransactionDialog
modality: Qt.WindowModal
width:640
height:480
@ -11,9 +13,9 @@ Window {
property int transactionIndex
property alias transactionParams: paramsModel;
property alias gas: gasField.text;
property alias gasPrice: gasPriceField.text;
property alias transactionValue: valueField.text;
property alias gas: gasField.value;
property alias gasPrice: gasPriceField.value;
property alias transactionValue: valueField.value;
property alias functionId: functionComboBox.currentText;
property var itemParams;
@ -21,9 +23,9 @@ Window {
function open(index, item) {
transactionIndex = index;
gas = item.gas;
gasPrice = item.gasPrice;
transactionValue = item.value;
gasField.value = item.gas;
gasPriceField.value = item.gasPrice;
valueField.value = item.value;
var functionId = item.functionId;
itemParams = item.parameters !== undefined ? item.parameters : {};
functionsModel.clear();
@ -53,7 +55,7 @@ Window {
var parameters = func.parameters;
for (var p = 0; p < parameters.length; p++) {
var pname = parameters[p].name;
paramsModel.append({ name: pname, type: parameters[p].type, value: itemParams[pname] !== undefined ? itemParams[pname] : "" });
paramsModel.append({ name: pname, type: parameters[p].type, value: itemParams[pname] !== undefined ? itemParams[pname].value() : "" });
}
}
}
@ -74,7 +76,10 @@ Window {
}
for (var p = 0; p < transactionDialog.transactionParams.count; p++) {
var parameter = transactionDialog.transactionParams.get(p);
item.parameters[parameter.name] = parameter.value;
var intComponent = Qt.createComponent("qrc:/qml/BigIntValue.qml");
var param = intComponent.createObject(modalTransactionDialog);
param.setValue(parameter.value);
item.parameters[parameter.name] = param;
}
return item;
}
@ -107,25 +112,40 @@ Window {
Label {
text: qsTr("Value")
}
TextField {
id: valueField
Rectangle
{
Layout.fillWidth: true
Ether {
id: valueField
edit: true
displayFormattedValue: true
}
}
Label {
text: qsTr("Gas")
}
TextField {
id: gasField
Rectangle
{
Layout.fillWidth: true
Ether {
id: gasField
edit: true
displayFormattedValue: true
}
}
Label {
text: qsTr("Gas price")
}
TextField {
id: gasPriceField
Rectangle
{
Layout.fillWidth: true
Ether {
id: gasPriceField
edit: true
displayFormattedValue: true
}
}
Label {

6
mix/qml/js/Debugger.js

@ -65,9 +65,9 @@ function highlightSelection(index)
function completeCtxInformation(state)
{
currentStep.update(state.step);
mem.update(state.newMemSize + " " + qsTr("words"));
stepCost.update(state.gasCost);
gasSpent.update(debugStates[0].gas - state.gas);
mem.update(state.newMemSize.value() + " " + qsTr("words"));
stepCost.update(state.gasCost.value());
gasSpent.update(debugStates[0].gas.subtract(state.gas).value());
stack.listModel = state.debugStack;
storage.listModel = state.debugStorage;

Loading…
Cancel
Save