diff --git a/mix/ClientModel.cpp b/mix/ClientModel.cpp index 7bc25fd3f..de55bebfa 100644 --- a/mix/ClientModel.cpp +++ b/mix/ClientModel.cpp @@ -402,10 +402,29 @@ void ClientModel::executeSequence(vector const& _sequence) { QSolidityType const* type = p->type(); QVariant value = transaction.parameterValues.value(p->name()); - if (type->type().type == SolidityType::Type::Address && value.toString().startsWith("<")) + if (type->type().type == SolidityType::Type::Address) { - std::pair ctrParamInstance = resolvePair(value.toString()); - value = QVariant(resolveToken(ctrParamInstance)); + if (type->array()) + { + QJsonArray jsonDoc = QJsonDocument::fromJson(value.toString().toUtf8()).array(); + int k = 0; + for (QJsonValue const& item: jsonDoc) + { + if (item.toString().startsWith("<")) + { + std::pair ctrParamInstance = resolvePair(item.toString()); + jsonDoc.replace(k, resolveToken(ctrParamInstance)); + } + k++; + } + QJsonDocument doc(jsonDoc); + value = QVariant(doc.toJson(QJsonDocument::Compact)); + } + else if (value.toString().startsWith("<")) + { + std::pair ctrParamInstance = resolvePair(value.toString()); + value = QVariant(resolveToken(ctrParamInstance)); + } } encoder.encode(value, type->type()); } diff --git a/mix/QVariableDeclaration.h b/mix/QVariableDeclaration.h index 583847b44..0b6ab3bf2 100644 --- a/mix/QVariableDeclaration.h +++ b/mix/QVariableDeclaration.h @@ -47,6 +47,7 @@ class QSolidityType: public QObject Q_PROPERTY(int size READ size CONSTANT) Q_PROPERTY(QString name READ name CONSTANT) Q_PROPERTY(QVariantList members READ members CONSTANT) + Q_PROPERTY(bool array READ array CONSTANT) public: QSolidityType() {} @@ -71,6 +72,7 @@ public: int size() const { return m_type.size; } QString name() const { return m_type.name; } QVariantList members() const; + bool array() const { return m_type.array; } private: SolidityType m_type; diff --git a/mix/qml/BlockChain.qml b/mix/qml/BlockChain.qml index 2c247d282..69d42799c 100644 --- a/mix/qml/BlockChain.qml +++ b/mix/qml/BlockChain.qml @@ -376,7 +376,6 @@ ColumnLayout { block.status = "mined" retBlocks.push(block) } - } if (retBlocks.length === 0) retBlocks.push(projectModel.stateListModel.createEmptyBlock()) @@ -587,7 +586,7 @@ ColumnLayout { itemTr.parameters = _r.parameters itemTr.isContractCreation = itemTr.functionId === itemTr.contractId itemTr.label = _r.label - itemTr.isFunctionCall = itemTr.functionId !== "" + itemTr.isFunctionCall = itemTr.functionId !== "" && itemTr.functionId !== "" itemTr.returned = _r.returned itemTr.value = QEtherHelper.createEther(_r.value, QEther.Wei) itemTr.sender = _r.sender @@ -617,7 +616,7 @@ ColumnLayout { clientModel.addAccount(ac.secret); for (var k in Object.keys(blockChainPanel.states)) blockChainPanel.states[k].accounts["0x" + ac.address] = "0 wei" // add the account in all the previous state (balance at O) - accountAdded(ac.address, "0") + accountAdded("0x" + ac.address, "0") } Layout.preferredWidth: 100 Layout.preferredHeight: 30 diff --git a/mix/qml/Debugger.qml b/mix/qml/Debugger.qml index 0129f864d..0b833c4de 100644 --- a/mix/qml/Debugger.qml +++ b/mix/qml/Debugger.qml @@ -112,7 +112,6 @@ Rectangle { ColumnLayout { id: debugScrollArea anchors.fill: parent - //orientation: Qt.Vertical spacing: 0 RowLayout { diff --git a/mix/qml/DeployContractStep.qml b/mix/qml/DeployContractStep.qml index 9bdcd765c..3bf5c217e 100644 --- a/mix/qml/DeployContractStep.qml +++ b/mix/qml/DeployContractStep.qml @@ -19,7 +19,7 @@ Rectangle { id: root property int labelWidth: 150 - + property bool verifyDeploy: true function show() { @@ -37,12 +37,12 @@ Rectangle { } verifyDeployedContract() - deployedAddresses.refresh() - worker.renewCtx() + worker.renewCtx() + verifyDeploy = true worker.pooler.onTriggered.connect(function() { - if (root.visible) + if (root.visible && verifyDeploy) verifyDeployedContract(); }) } @@ -73,10 +73,13 @@ Rectangle { verificationLabel.text = nb if (trLost.length > 0) { + verifyDeploy = false verificationTextArea.visible = true verificationLabel.visible = false + verificationTextArea.text = "" deploymentStepChanged("following transactions are invalidated:") verificationTextArea.text += "\n" + qsTr("Transactions lost") + "\n" + verificationTextArea.textColor = "red" for (var k in trLost) { deploymentStepChanged(trLost[k]) @@ -143,9 +146,11 @@ Rectangle { ScrollView { anchors.fill: parent + horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff ColumnLayout { spacing: 0 + ListModel { id: trListModel @@ -218,6 +223,13 @@ Rectangle { font.italic: true } } + + Rectangle + { + Layout.preferredWidth: scenarioList.width + Layout.preferredHeight: 1 + color: "#cccccc" + } } } } @@ -524,6 +536,5 @@ Rectangle { } } } - } diff --git a/mix/qml/DeploymentWorker.qml b/mix/qml/DeploymentWorker.qml index 76e981d8c..cf29e3d25 100644 --- a/mix/qml/DeploymentWorker.qml +++ b/mix/qml/DeploymentWorker.qml @@ -128,7 +128,7 @@ Item params: [], id: req }); - var label = {} + var label = [] for (var k in trHashes) { req++ @@ -142,15 +142,13 @@ Item } TransactionHelper.rpcCall(requests, function (httpRequest, response){ - console.log(response) - var ret = JSON.parse(response) var b = ret[0].result; var trLost = [] for (var k in ret) { - if (ret[k].result === null) - trLost.push(label[ret[k]]) + if (!ret[k].result) + trLost.push(label[ret[k].id]) } callback(parseInt(b, 16), trLost) }); diff --git a/mix/qml/PackagingStep.qml b/mix/qml/PackagingStep.qml index 6f7ed3f11..26b5c8540 100644 --- a/mix/qml/PackagingStep.qml +++ b/mix/qml/PackagingStep.qml @@ -51,13 +51,14 @@ Rectangle { id: col spacing: 20 + anchors.left: parent.left + anchors.leftMargin: 10 Label { anchors.top: parent.top Layout.fillWidth: true - anchors.left: parent.left - anchors.leftMargin: 10 + text: qsTr("Upload and update your Dapp assets") } @@ -67,11 +68,11 @@ Rectangle { Layout.preferredHeight: 20 Rectangle { - Layout.preferredWidth: col.width / 2 + Layout.preferredWidth: col.width / 5 Label { text: qsTr("Save Package to") - anchors.right: parent.right + anchors.left: parent.left anchors.verticalCenter: parent.verticalCenter } } @@ -80,7 +81,7 @@ Rectangle { { id: packageFolder visible: true - Layout.preferredWidth: 150 + Layout.preferredWidth: 360 text: projectPath + "package/" } @@ -102,7 +103,8 @@ Rectangle { Button { id: generatePackageBtn - anchors.horizontalCenter: parent.horizontalCenter + anchors.left: parent.left + anchors.leftMargin: 10 text: qsTr("Generate Package") onClicked: { @@ -117,7 +119,6 @@ Rectangle { anchors.top: generatePackageBtn.bottom anchors.topMargin: 10 visible: root.lastDeployDate !== "" - anchors.horizontalCenter: parent.horizontalCenter Label { id: lastPackage @@ -137,11 +138,11 @@ Rectangle { Layout.preferredHeight: 20 Rectangle { - Layout.preferredWidth: col.width / 2 + Layout.preferredWidth: col.width / 5 Label { text: qsTr("Local package URL") - anchors.right: parent.right + anchors.left: parent.left anchors.verticalCenter: parent.verticalCenter } } @@ -149,7 +150,7 @@ Rectangle { DefaultTextField { id: localPackageUrl - Layout.preferredWidth: 235 + Layout.preferredWidth: 450 readOnly: true } } @@ -157,7 +158,6 @@ Rectangle { Label { Layout.preferredWidth: 300 - anchors.horizontalCenter: parent.horizontalCenter text: qsTr("You have to upload the package to a remote folder, or use a service like pastebin") wrapMode: Text.WordWrap clip: true @@ -171,8 +171,9 @@ Rectangle { Button { Layout.preferredWidth: 200 - anchors.horizontalCenter: parent.horizontalCenter text: qsTr("Copy Base64") + anchors.left: parent.left + anchors.leftMargin: 10 onClicked: { clipboard.text = deploymentDialog.packageStep.packageBase64; @@ -188,8 +189,9 @@ Rectangle { Button { Layout.preferredWidth: 200 - anchors.horizontalCenter: parent.horizontalCenter text: qsTr("Open pastebin") + anchors.left: parent.left + anchors.leftMargin: 10 onClicked: { Qt.openUrlExternally("http://pastebin.com/"); diff --git a/mix/qml/QAddressView.qml b/mix/qml/QAddressView.qml index 56aefcf3e..0a8d09056 100644 --- a/mix/qml/QAddressView.qml +++ b/mix/qml/QAddressView.qml @@ -1,8 +1,10 @@ import QtQuick 2.0 import QtQuick.Controls 1.3 import QtQuick.Controls.Styles 1.3 +import QtQuick.Layouts 1.1 +import "js/InputValidator.js" as InputValidator -Row +ColumnLayout { property alias value: textinput.text property alias accountRef: ctrModel @@ -12,8 +14,16 @@ Row property alias displayInput: textInputRect.visible property variant accounts signal indexChanged() + spacing: 0 id: editRoot - height: 20 + height: + { + if (isArray() && !readOnly) + return 60 + else + return 30 + } + width: 320 SourceSansProBold @@ -21,6 +31,12 @@ Row id: boldFont } + function isArray() + { + InputValidator.init() + return InputValidator.isArray(subType) + } + function currentValue() { return value; } @@ -38,7 +54,7 @@ Row function load() { accountRef.clear(); - if (subType === "contract" || subType === "address") + if (subType.indexOf("contract") !== -1 || subType.indexOf("address") !== -1) { var trCr = 0; if (blockChainPanel) @@ -59,7 +75,7 @@ Row } } } - if (subType === "address") + if (subType.indexOf("address") !== -1) { for (k = 0; k < accounts.length; k++) { @@ -72,21 +88,42 @@ Row function init() { - trCombobox.visible = !readOnly + btnAdd.visible = isArray() textinput.readOnly = readOnly + if (isArray() || readOnly) + displayInput = true + else + displayInput = false + + if (isArray() || !readOnly) + trCombobox.visible = true + else + trCombobox.visible = false + + if (!trCombobox.visible) + { + rowCombobox.visible = false + rowCombobox.height = 0 + trCombobox.height = 0 + textinput.anchors.top = textinput.parent.top + } + if (!readOnly) { + trCombobox.currentIndex = 0 for (var k = 0; k < ctrModel.count; k++) { if (ctrModel.get(k).value === value) { - trCombobox.currentIndex = k; - return; + trCombobox.currentIndex = k + break } } - trCombobox.currentIndex = 0; } - trCombobox.update() + if (!isArray()) + trCombobox.update() + else if (value === "") + textinput.text = "[]" } function select(address) @@ -101,17 +138,73 @@ Row } } + ListModel + { + id: ctrModel + } + + Row + { + anchors.top: parent.top + height: 30 + id: rowCombobox + ComboBox + { + property bool selected: false + id: trCombobox + model: ctrModel + width: 265 + textRole: "itemid" + function update() + { + trCombobox.selected = false; + if (currentText === "") + return; + else if (currentText !== " - ") + { + if (model.get(currentIndex).type === "contract") + textinput.text = "<" + currentText + ">"; + else + textinput.text = model.get(currentIndex).value; //address + trCombobox.selected = true; + } + else if (textinput.text.indexOf("<") === 0) + { + textinput.text = ""; + } + indexChanged(); + } + + onCurrentIndexChanged: { + if (!isArray()) + update() + } + } + + Button + { + id: btnAdd + text: qsTr("Add") + visible: false + onClicked: + { + var ar = JSON.parse(textinput.text) + ar.push(trCombobox.model.get(currentIndex).value) + textinput.text = JSON.stringify(ar) + } + } + } + + Rectangle { radius: 4 - anchors.verticalCenter: parent.verticalCenter - height: 20 + width: 350 + height: 30 id: textInputRect - TextInput { + TextField { id: textinput text: value - width: parent.width - height: parent.width - wrapMode: Text.WordWrap + anchors.fill: parent clip: true font.family: boldFont.name MouseArea { @@ -130,43 +223,4 @@ Row } } } - - ListModel - { - id: ctrModel - } - - ComboBox - { - property bool selected: false - id: trCombobox - model: ctrModel - width: 350 - textRole: "itemid" - anchors.verticalCenter: parent.verticalCenter - - function update() - { - trCombobox.selected = false; - if (currentText === "") - return; - else if (currentText !== " - ") - { - if (model.get(currentIndex).type === "contract") - textinput.text = "<" + currentText + ">"; - else - textinput.text = model.get(currentIndex).value; //address - trCombobox.selected = true; - } - else if (textinput.text.indexOf("<") === 0) - { - textinput.text = ""; - } - indexChanged(); - } - - onCurrentIndexChanged: { - update() - } - } } diff --git a/mix/qml/QBoolTypeView.qml b/mix/qml/QBoolTypeView.qml index 12c932762..25577b1ea 100644 --- a/mix/qml/QBoolTypeView.qml +++ b/mix/qml/QBoolTypeView.qml @@ -1,5 +1,6 @@ import QtQuick 2.0 import QtQuick.Controls 1.3 +import "js/InputValidator.js" as InputValidator Item { @@ -7,6 +8,7 @@ Item property string value property string defaultValue property bool readOnly: !boolCombo.enabled + property string subType height: 20 width: 150 @@ -14,20 +16,59 @@ Item boolCombo.enabled = !readOnly; } + function isArray() + { + InputValidator.init() + return InputValidator.isArray(subType) + } + function init() + { + if (!isArray()) + { + boolArray.visible = false + boolCombo.visible = true + + value = format(value) + + var setValue = "1" + if (value === "") + setValue = parseInt(defaultValue); + else + setValue = parseInt(value); + boolCombo.checked = setValue === "1" ? true: false + boolCombo.enabled = !readOnly; + } + else + { + boolArray.visible = true + boolCombo.visible = false + if (value === "") + boolArray.text = "[]" + else + boolArray.text = value + + var formattedparam = [] + var param = JSON.parse(boolArray.text) + for (var k in JSON.parse(boolArray.text)) + formattedparam.push(parseInt(format(param[k]))) + boolArray.text = JSON.stringify(formattedparam) + } + } + + function finalize() + { + if (isArray()) + value = boolArray.text + } + + function format(value) { value = value === true ? "1" : value value = value === false ? "0" : value; value = value === "true" ? "1" : value value = value === "false" ? "0" : value; - - var setValue = "1" - if (value === "") - setValue = parseInt(defaultValue); - else - setValue = parseInt(value); - boolCombo.checked = setValue === "1" ? true: false - boolCombo.enabled = !readOnly; + return value } Rectangle { @@ -52,6 +93,15 @@ Item } text: qsTr("True") } + + TextField + { + id: boolArray + onTextChanged: + { + value = text + } + } } } diff --git a/mix/qml/QIntTypeView.qml b/mix/qml/QIntTypeView.qml index 6bee54a1f..65e029ad5 100644 --- a/mix/qml/QIntTypeView.qml +++ b/mix/qml/QIntTypeView.qml @@ -5,7 +5,7 @@ Item property alias value: textinput.text property alias readOnly: textinput.readOnly id: editRoot - width: 200 + width: 350 DebuggerPaneStyle { id: dbgStyle } @@ -15,7 +15,7 @@ Item id: textinput selectByMouse: true text: value - implicitWidth: 200 + implicitWidth: 350 MouseArea { id: mouseArea anchors.fill: parent diff --git a/mix/qml/QStringTypeView.qml b/mix/qml/QStringTypeView.qml index 25831cb00..e8b798784 100644 --- a/mix/qml/QStringTypeView.qml +++ b/mix/qml/QStringTypeView.qml @@ -6,7 +6,7 @@ Item property alias value: textinput.text property alias readOnly: textinput.readOnly id: editRoot - width: readOnly ? textinput.implicitWidth : 150 + width: 350 DebuggerPaneStyle { id: dbgStyle @@ -17,6 +17,7 @@ Item id: textinput selectByMouse: true text: value + width: 350 MouseArea { id: mouseArea anchors.fill: parent diff --git a/mix/qml/RegisteringStep.qml b/mix/qml/RegisteringStep.qml index 3201b9827..5ea83efd8 100644 --- a/mix/qml/RegisteringStep.qml +++ b/mix/qml/RegisteringStep.qml @@ -90,11 +90,11 @@ Rectangle { anchors.topMargin: 10 id: col spacing: 20 + anchors.left: parent.left + anchors.leftMargin: 10 Label { anchors.top: parent.top - anchors.left: parent.left - anchors.leftMargin: 10 Layout.fillWidth: true text: qsTr("Register your Dapp on the Name registrar Contract") } @@ -105,11 +105,11 @@ Rectangle { Layout.preferredHeight: 20 Rectangle { - Layout.preferredWidth: col.width / 2 + Layout.preferredWidth: col.width / 5 Label { text: qsTr("Root Registrar address") - anchors.right: parent.right + anchors.left: parent.left anchors.verticalCenter: parent.verticalCenter } } @@ -119,7 +119,7 @@ Rectangle { id: registrarAddr text: "c6d9d2cd449a754c494264e1809c50e34d64562b" visible: true - Layout.preferredWidth: 235 + Layout.preferredWidth: 450 } } @@ -129,11 +129,11 @@ Rectangle { Layout.preferredHeight: 20 Rectangle { - Layout.preferredWidth: col.width / 2 + Layout.preferredWidth: col.width / 5 Label { text: qsTr("Http URL") - anchors.right: parent.right + anchors.left: parent.left anchors.verticalCenter: parent.verticalCenter } } @@ -141,7 +141,7 @@ Rectangle { DefaultTextField { id: applicationUrlHttpCtrl - Layout.preferredWidth: 235 + Layout.preferredWidth: 450 } Label @@ -158,11 +158,11 @@ Rectangle { Layout.preferredHeight: 20 Rectangle { - Layout.preferredWidth: col.width / 2 + Layout.preferredWidth: col.width / 5 Label { text: qsTr("Registration Cost") - anchors.right: parent.right + anchors.left: parent.left anchors.verticalCenter: parent.verticalCenter id: ctrRegisterLabel function calculateRegisterGas() @@ -200,23 +200,23 @@ Rectangle { Layout.preferredHeight: 20 Rectangle { - Layout.preferredWidth: col.width / 2 + Layout.preferredWidth: col.width / 5 Label { text: qsTr("Ethereum URL") - anchors.right: parent.right + anchors.left: parent.left anchors.verticalCenter: parent.verticalCenter - } + } } Rectangle { height: 25 color: "transparent" - Layout.preferredWidth: 235 + Layout.preferredWidth: 450 DefaultTextField { - width: 235 + width: 450 id: applicationUrlEthCtrl onTextChanged: { ctrRegisterLabel.calculateRegisterGas(); @@ -231,11 +231,11 @@ Rectangle { Layout.preferredHeight: 20 Rectangle { - Layout.preferredWidth: col.width / 2 + Layout.preferredWidth: col.width / 4 Label { text: qsTr("Formatted Ethereum URL") - anchors.right: parent.right + anchors.left: parent.left anchors.verticalCenter: parent.verticalCenter } } @@ -252,7 +252,7 @@ Rectangle { Label { id: verificationEthUrl - anchors.verticalCenter: parent.verticalCenter; + anchors.verticalCenter: parent.verticalCenter; anchors.topMargin: 10 font.italic: true font.pointSize: appStyle.absoluteSize(-1) @@ -264,7 +264,7 @@ Rectangle { { anchors.bottom: parent.bottom anchors.bottomMargin: 10 - width: parent.width + width: parent.width function registerHash(gasPrice, callback) { @@ -276,7 +276,7 @@ Rectangle { inError.push(qsTr("Member too long: " + ethUrl[k]) + "\n"); } if (!worker.stopForInputError(inError)) - { + { NetworkDeploymentCode.registerDapp(ethUrl, gasPrice, function(){ projectModel.applicationUrlEth = applicationUrlEthCtrl.text projectModel.saveProject() @@ -309,7 +309,9 @@ Rectangle { inError.push(qsTr(applicationUrlHttpCtrl.text)); if (!worker.stopForInputError(inError)) { - registerToUrlHint(applicationUrlHttpCtrl.text, gasPrice, function(){ + var url = applicationUrlHttpCtrl.text + url = url.replace("http://", "").replace("https://", "") + registerToUrlHint(url, gasPrice, function(){ projectModel.applicationUrlHttp = applicationUrlHttpCtrl.text projectModel.saveProject() verificationUrl.text = qsTr("waiting verifications") diff --git a/mix/qml/ScenarioLoader.qml b/mix/qml/ScenarioLoader.qml index 24b5962c1..c4ce19af0 100644 --- a/mix/qml/ScenarioLoader.qml +++ b/mix/qml/ScenarioLoader.qml @@ -29,7 +29,6 @@ ColumnLayout function needSaveOrReload() { - editStatus.visible = true } RowLayout diff --git a/mix/qml/StateDialog.qml b/mix/qml/StateDialog.qml index 56be75a09..cd19751b6 100644 --- a/mix/qml/StateDialog.qml +++ b/mix/qml/StateDialog.qml @@ -15,7 +15,7 @@ Dialog { width: 630 height: 660 - title: qsTr("Edit State") + title: qsTr("Edit Genesis Parameters") visible: false property alias isDefault: defaultCheckBox.checked diff --git a/mix/qml/StateList.qml b/mix/qml/StateList.qml index e081947e2..b12aa2fb2 100644 --- a/mix/qml/StateList.qml +++ b/mix/qml/StateList.qml @@ -17,6 +17,7 @@ Dialog { ColumnLayout { anchors.fill: parent + anchors.margins: 10 TableView { id: list Layout.fillHeight: true @@ -57,7 +58,7 @@ Dialog { verticalAlignment: Text.AlignBottom } ToolButton { - text: qsTr("Edit"); + text: qsTr("Edit Genesis"); Layout.fillHeight: true onClicked: list.model.editState(styleData.row); } diff --git a/mix/qml/StateListModel.qml b/mix/qml/StateListModel.qml index f144560cf..51521ac86 100644 --- a/mix/qml/StateListModel.qml +++ b/mix/qml/StateListModel.qml @@ -301,7 +301,7 @@ Item { var ctorTr = defaultTransactionItem(); ctorTr.functionId = c; ctorTr.contractId = c; - ctorTr.label = qsTr("Deploy") + " " + ctorTr.contractId; + ctorTr.label = ctorTr.contractId + "." + ctorTr.contractId + "()" ctorTr.sender = item.accounts[0].secret; item.transactions.push(ctorTr); item.blocks[0].transactions.push(ctorTr) @@ -343,7 +343,7 @@ Item { var ctorTr = defaultTransactionItem(); ctorTr.functionId = c; ctorTr.contractId = c; - ctorTr.label = qsTr("Deploy") + " " + ctorTr.contractId; + ctorTr.label = ctorTr.contractId + "." + ctorTr.contractId + "()"; ctorTr.sender = state.accounts[0].secret; state.transactions.push(ctorTr); changed = true; diff --git a/mix/qml/StructView.qml b/mix/qml/StructView.qml index 96a828eba..bc3f9499e 100644 --- a/mix/qml/StructView.qml +++ b/mix/qml/StructView.qml @@ -13,7 +13,16 @@ Column property int transactionIndex property string context Layout.fillWidth: true - spacing: 5 + spacing: 0 + property int colHeight + + function clear() + { + value = {} + members = [] + colHeight = 0 + } + Repeater { id: repeater @@ -21,8 +30,17 @@ Column RowLayout { id: row - height: 30 + (members[index].type.category === QSolidityType.Struct ? (30 * members[index].type.members.length) : 0) Layout.fillWidth: true + + Component.onCompleted: + { + if (QSolidityType.Address === members[index].type.category && members[index].type.array && context === "parameter") + height = 60 + else + height = 30 + (members[index].type.category === QSolidityType.Struct ? (30 * members[index].type.members.length) : 0) + root.colHeight += height + } + Rectangle { Layout.preferredWidth: 150 @@ -30,12 +48,14 @@ Column { anchors.right: parent.right anchors.verticalCenter: parent.verticalCenter - Label { + Label + { id: nameLabel text: modelData.name } - Label { + Label + { id: typeLabel text: " (" + modelData.type.name + ")" font.italic: true @@ -72,6 +92,7 @@ Column var ptype = members[index].type; var pname = members[index].name; var vals = value; + item.readOnly = context === "variable"; if (ptype.category === QSolidityType.Address) { @@ -94,18 +115,29 @@ Column item.value = getValue(); if (ptype.category === QSolidityType.Bool) + { + item.subType = modelData.type.name item.init(); + } item.onValueChanged.connect(function() { - vals[pname] = item.value; - valueChanged(); + syncValue(vals, pname) }); var newWidth = nameLabel.width + typeLabel.width + item.width + 108; if (root.width < newWidth) root.width = newWidth; + + syncValue(vals, pname) } + function syncValue(vals, pname) + { + vals[pname] = item.value; + valueChanged(); + } + + function getValue() { var r = ""; diff --git a/mix/qml/TransactionDialog.qml b/mix/qml/TransactionDialog.qml index cc2ca2e79..f0440101b 100644 --- a/mix/qml/TransactionDialog.qml +++ b/mix/qml/TransactionDialog.qml @@ -8,6 +8,7 @@ import org.ethereum.qml.QEther 1.0 import "js/TransactionHelper.js" as TransactionHelper import "js/InputValidator.js" as InputValidator import "js/NetworkDeployment.js" as NetworkDeployment +import "js/QEtherHelper.js" as QEtherHelper import "." Dialog { @@ -54,7 +55,6 @@ Dialog { if (item.sender) senderComboBox.select(item.sender); - trTypeCreate.checked = item.isContractCreation trTypeSend.checked = !item.isFunctionCall trTypeExecute.checked = item.isFunctionCall && !item.isContractCreation @@ -152,8 +152,7 @@ Dialog { function initTypeLoader() { - paramScroll.value = {} - paramScroll.members = [] + paramScroll.clear() paramScroll.value = paramValues; paramScroll.members = paramsModel; paramScroll.updateView() @@ -237,6 +236,8 @@ Dialog { recipientsAccount.select(contractId); if (functionId) selectFunction(functionId); + else + functionComboBox.currentIndex = 0 if (isFunctionCall) { labelRecipient.text = qsTr("Recipient Contract") @@ -489,14 +490,14 @@ Dialog { StructView { id: paramScroll - members: paramsModel; + members: paramsModel accounts: senderComboBox.model context: "parameter" Layout.fillWidth: true function updateView() { paramScroll.visible = paramsModel.length > 0 - paramScroll.Layout.preferredHeight = paramsModel.length < 6 ? paramsModel.length * 30 : 205 + paramScroll.Layout.preferredHeight = paramScroll.colHeight if (paramsModel.length === 0) paramScroll.height = 0 } @@ -519,7 +520,7 @@ Dialog { Layout.preferredWidth: 350 id: valueField edit: true - displayFormattedValue: false + displayFormattedValue: true displayUnitSelection: true } } @@ -655,11 +656,12 @@ Dialog { Label { id: gasPriceMarket anchors.top: gasPriceLabel.bottom + anchors.topMargin: 10 Component.onCompleted: { NetworkDeployment.gasPrice(function(result) { - gasPriceMarket.text = qsTr("Current market: ") + " " + result + " Wei"; + gasPriceMarket.text = qsTr("Current market: ") + " " + QEtherHelper.createEther(result, QEther.Wei).format() }, function (){}); } } @@ -667,7 +669,7 @@ Dialog { } Ether { - Layout.preferredWidth: 350 + Layout.preferredWidth: 400 id: gasPriceField edit: true displayFormattedValue: false diff --git a/mix/qml/VariablesView.qml b/mix/qml/VariablesView.qml index aec629853..517204877 100644 --- a/mix/qml/VariablesView.qml +++ b/mix/qml/VariablesView.qml @@ -25,7 +25,7 @@ DebugInfoList members: [] value: {} context: "variable" - width:parent.width + width: parent.width } } } diff --git a/mix/qml/Watchers.qml b/mix/qml/Watchers.qml index 654670d6c..c7c6e8335 100644 --- a/mix/qml/Watchers.qml +++ b/mix/qml/Watchers.qml @@ -13,7 +13,6 @@ import "." Rectangle { color: "#4F4F4F" - radius: 4 property variant tx property variant currentState property variant bc diff --git a/mix/qml/html/codeeditor.js b/mix/qml/html/codeeditor.js index 108df5952..68172200f 100644 --- a/mix/qml/html/codeeditor.js +++ b/mix/qml/html/codeeditor.js @@ -246,7 +246,7 @@ displayGasEstimation = function(show) { var color; var colorIndex = Math.round(step * gasCosts[i].gas); - if (gasCosts[i].isInfinite || colorIndex > colorGradient.length) + if (gasCosts[i].isInfinite || colorIndex >= colorGradient.length) color = colorGradient[colorGradient.length - 1]; else color = colorGradient[colorIndex]; diff --git a/mix/qml/js/InputValidator.js b/mix/qml/js/InputValidator.js index c0626e0f1..ea8d6dad5 100644 --- a/mix/qml/js/InputValidator.js +++ b/mix/qml/js/InputValidator.js @@ -32,10 +32,11 @@ function init() function check(type, value) { var res = { valid: true, message : "" } - if (isContractType(type)) - res = validateAddress(type, value); - else if (isArray(type)) + + if (isArray(type)) res = validateArray(type, value); + else if (isContractType(type)) + res = validateAddress(type, value); else if (type.indexOf("int") !== -1) res = validateInt(type, value); else if (type.indexOf("enum") !== -1) @@ -196,7 +197,7 @@ function validateBytes(_type, _value) function validateBool(_type, _value) { var ret = { valid: true, message: "" } - if (_value !== "1" && _value !== "0") + if (!(_value === "1" || _value === "0" || _value === 1 || _value === 0)) { ret.valid = false; ret.message = _value + " is not in the correct bool format";