From cdc38ab28a3ea6ad11d16f94072e2abec665c11d Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 23 Apr 2015 14:45:50 +0200 Subject: [PATCH 1/5] Use non-implemented functions for solidity interface output. --- libsolidity/InterfaceHandler.cpp | 2 +- test/libsolidity/SolidityInterface.cpp | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libsolidity/InterfaceHandler.cpp b/libsolidity/InterfaceHandler.cpp index aacbbfd72..ea787c282 100644 --- a/libsolidity/InterfaceHandler.cpp +++ b/libsolidity/InterfaceHandler.cpp @@ -107,7 +107,7 @@ unique_ptr InterfaceHandler::getABISolidityInterface(ContractDefinition ret += "returns" + populateParameters(it.second->getReturnParameterNames(), it.second->getReturnParameterTypeNames()); else if (ret.back() == ' ') ret.pop_back(); - ret += "{}"; + ret += ";"; } return unique_ptr(new string(ret + "}")); diff --git a/test/libsolidity/SolidityInterface.cpp b/test/libsolidity/SolidityInterface.cpp index c8f74e3aa..9c9373f04 100644 --- a/test/libsolidity/SolidityInterface.cpp +++ b/test/libsolidity/SolidityInterface.cpp @@ -78,7 +78,7 @@ BOOST_AUTO_TEST_CASE(single_function) "}\n"); BOOST_REQUIRE_EQUAL(1, contract.getDefinedFunctions().size()); BOOST_CHECK_EQUAL(getSourcePart(*contract.getDefinedFunctions().front()), - "function f(uint256 a)returns(uint256 d){}"); + "function f(uint256 a)returns(uint256 d);"); } BOOST_AUTO_TEST_CASE(single_constant_function) @@ -87,7 +87,7 @@ BOOST_AUTO_TEST_CASE(single_constant_function) "contract test { function f(uint a) constant returns(bytes1 x) { 1==2; } }"); BOOST_REQUIRE_EQUAL(1, contract.getDefinedFunctions().size()); BOOST_CHECK_EQUAL(getSourcePart(*contract.getDefinedFunctions().front()), - "function f(uint256 a)constant returns(bytes1 x){}"); + "function f(uint256 a)constant returns(bytes1 x);"); } BOOST_AUTO_TEST_CASE(multiple_functions) @@ -97,8 +97,8 @@ BOOST_AUTO_TEST_CASE(multiple_functions) " function g(uint b) returns(uint e) { return b * 8; }\n" "}\n"; ContractDefinition const& contract = checkInterface(sourceCode); - set expectation({"function f(uint256 a)returns(uint256 d){}", - "function g(uint256 b)returns(uint256 e){}"}); + set expectation({"function f(uint256 a)returns(uint256 d);", + "function g(uint256 b)returns(uint256 e);"}); BOOST_REQUIRE_EQUAL(2, contract.getDefinedFunctions().size()); BOOST_CHECK(expectation == set({getSourcePart(*contract.getDefinedFunctions().at(0)), getSourcePart(*contract.getDefinedFunctions().at(1))})); @@ -135,8 +135,8 @@ BOOST_AUTO_TEST_CASE(inheritance) " event derivedEvent(uint indexed evtArgDerived); \n" " }"; ContractDefinition const& contract = checkInterface(sourceCode); - set expectedFunctions({"function baseFunction(uint256 p)returns(uint256 i){}", - "function derivedFunction(bytes32 p)returns(bytes32 i){}"}); + set expectedFunctions({"function baseFunction(uint256 p)returns(uint256 i);", + "function derivedFunction(bytes32 p)returns(bytes32 i);"}); BOOST_REQUIRE_EQUAL(2, contract.getDefinedFunctions().size()); BOOST_CHECK(expectedFunctions == set({getSourcePart(*contract.getDefinedFunctions().at(0)), getSourcePart(*contract.getDefinedFunctions().at(1))})); From 792b878315bddc15a925613d047e195926c740b4 Mon Sep 17 00:00:00 2001 From: Ryan Casey Date: Thu, 23 Apr 2015 09:42:01 -0700 Subject: [PATCH 2/5] Direct more mundane failures to cerr as well. --- solc/CommandLineInterface.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index 5e4c901f3..0cc1ab259 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -270,7 +270,7 @@ bool CommandLineInterface::parseArguments(int argc, char** argv) } catch (po::error const& _exception) { - cout << _exception.what() << endl; + cerr << _exception.what() << endl; return false; } if (m_args.count("combined-json")) @@ -279,7 +279,7 @@ bool CommandLineInterface::parseArguments(int argc, char** argv) for (string const& item: boost::split(requests, m_args["combined-json"].as(), boost::is_any_of(","))) if (!g_combinedJsonArgs.count(item)) { - cout << "Invalid option to --combined-json: " << item << endl; + cerr << "Invalid option to --combined-json: " << item << endl; return false; } } @@ -317,13 +317,13 @@ bool CommandLineInterface::processInput() auto path = boost::filesystem::path(infile); if (!boost::filesystem::exists(path)) { - cout << "Skipping non existant input file \"" << infile << "\"" << endl; + cerr << "Skipping non existant input file \"" << infile << "\"" << endl; continue; } if (!boost::filesystem::is_regular_file(path)) { - cout << "\"" << infile << "\" is not a valid file. Skipping" << endl; + cerr << "\"" << infile << "\" is not a valid file. Skipping" << endl; continue; } From 739f6b4731fd6d8887c2022dcc8dfe7c0840dfa4 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 24 Apr 2015 10:03:36 +0200 Subject: [PATCH 3/5] fix send via CLI --- eth/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eth/main.cpp b/eth/main.cpp index f7f6fe372..9c49396f0 100644 --- a/eth/main.cpp +++ b/eth/main.cpp @@ -1317,9 +1317,9 @@ int main(int argc, char** argv) { string hexAddr; u256 amount; - int size = hexAddr.length(); iss >> hexAddr >> amount; + int size = hexAddr.length(); if (size < 40) { if (size > 0) From 962d0eaaf2f8647e7449919b2b3a949952c7c47b Mon Sep 17 00:00:00 2001 From: yann300 Date: Fri, 24 Apr 2015 10:18:08 +0200 Subject: [PATCH 4/5] - If param is address type, allow to easily fill in param width used accounts --- mix/ContractCallDataEncoder.cpp | 4 ++- mix/qml/QAddressView.qml | 23 +++++++++++------- mix/qml/StateListModel.qml | 2 +- mix/qml/StructView.qml | 43 ++++++++++++++++++++++++--------- mix/qml/TransactionDialog.qml | 4 ++- mix/qml/VariablesView.qml | 2 ++ 6 files changed, 55 insertions(+), 23 deletions(-) diff --git a/mix/ContractCallDataEncoder.cpp b/mix/ContractCallDataEncoder.cpp index c561c0017..854623a6a 100644 --- a/mix/ContractCallDataEncoder.cpp +++ b/mix/ContractCallDataEncoder.cpp @@ -195,7 +195,7 @@ QVariant ContractCallDataEncoder::decode(SolidityType const& _type, bytes const& bytes rawParam(32); value.populate(&rawParam); QSolidityType::Type type = _type.type; - if (type == QSolidityType::Type::SignedInteger || type == QSolidityType::Type::UnsignedInteger || type == QSolidityType::Type::Address) + if (type == QSolidityType::Type::SignedInteger || type == QSolidityType::Type::UnsignedInteger) return QVariant::fromValue(toString(decodeInt(rawParam))); else if (type == QSolidityType::Type::Bool) return QVariant::fromValue(toString(decodeBool(rawParam))); @@ -203,6 +203,8 @@ QVariant ContractCallDataEncoder::decode(SolidityType const& _type, bytes const& return QVariant::fromValue(toString(decodeBytes(rawParam))); else if (type == QSolidityType::Type::Struct) return QVariant::fromValue(QString("struct")); //TODO + else if (type == QSolidityType::Type::Address) + return QVariant::fromValue(toString(decodeBytes(unpadLeft(rawParam)))); else BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("Parameter declaration not found")); } diff --git a/mix/qml/QAddressView.qml b/mix/qml/QAddressView.qml index 2c1d43276..204e92508 100644 --- a/mix/qml/QAddressView.qml +++ b/mix/qml/QAddressView.qml @@ -5,10 +5,12 @@ import QtQuick.Controls.Styles 1.3 Item { property alias value: textinput.text - property alias contractCreationTr: ctrModel + property alias accountRef: ctrModel + property string subType + property bool readOnly id: editRoot height: 20 - width: 200 + width: 320 SourceSansProBold { @@ -17,19 +19,19 @@ Item function init() { - trCombobox.visible = ctrModel.count > 1; //index 0 is a blank value. - if (value.indexOf("<") === 0) + trCombobox.visible = !readOnly + textinput.readOnly = readOnly + if (!readOnly) { for (var k = 0; k < ctrModel.count; k++) { - if ("<" + ctrModel.get(k).functionId + ">" === value) + if (ctrModel.get(k).value === value) { trCombobox.currentIndex = k; return; } } trCombobox.currentIndex = 0; - value = ""; } } @@ -43,7 +45,7 @@ Item text: value width: parent.width height: parent.width - wrapMode: Text.WrapAnywhere + wrapMode: Text.WordWrap clip: true font.family: boldFont.name MouseArea { @@ -73,7 +75,7 @@ Item property bool selected: false id: trCombobox model: ctrModel - textRole: "functionId" + textRole: "itemid" height: 20 anchors.verticalCenter: parent.verticalCenter anchors.left: textinput.parent.right @@ -84,7 +86,10 @@ Item return; else if (currentText !== " - ") { - textinput.text = "<" + 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) diff --git a/mix/qml/StateListModel.qml b/mix/qml/StateListModel.qml index 35d106b5f..075a049b6 100644 --- a/mix/qml/StateListModel.qml +++ b/mix/qml/StateListModel.qml @@ -183,7 +183,7 @@ Item { _secret = clientModel.newSecret(); var address = clientModel.address(_secret); var name = qsTr("Account") + "-" + address.substring(0, 4); - return { name: name, secret: _secret, balance: QEtherHelper.createEther(_balance, _unit) }; + return { name: name, secret: _secret, balance: QEtherHelper.createEther(_balance, _unit), address: address }; } function createDefaultState() { diff --git a/mix/qml/StructView.qml b/mix/qml/StructView.qml index 32ce3d618..798a634fa 100644 --- a/mix/qml/StructView.qml +++ b/mix/qml/StructView.qml @@ -7,8 +7,10 @@ Column { id: root property alias members: repeater.model //js array + property variant accounts property var value: ({}) property int transactionIndex + property string context Layout.fillWidth: true spacing: 10 Repeater @@ -69,21 +71,40 @@ Column var vals = value; if (ptype.category === QSolidityType.Address) { - item.contractCreationTr.append({"functionId": " - "}); - var trCr = -1; - for (var k = 0; k < transactionsModel.count; k++) + item.value = getValue(); + item.readOnly = context === "variable"; + if (context === "parameter") { - if (k >= transactionIndex) - break; - var tr = transactionsModel.get(k); - if (tr.functionId === tr.contractId) + var dec = modelData.type.name.split(" "); + item.subType = dec[0]; + item.accountRef.append({"itemid": " - "}); + + if (item.subType === "contract" || item.subType === "address") + { + var trCr = 0; + for (var k = 0; k < transactionsModel.count; k++) + { + if (k >= transactionIndex) + break; + var tr = transactionsModel.get(k); + if (tr.functionId === tr.contractId && (dec[1] === tr.contractId || item.subType === "address")) + { + item.accountRef.append({ "itemid": tr.contractId + " - " + trCr, "value": "<" + tr.contractId + " - " + trCr + ">", "type": "contract" }); + trCr++; + } + } + } + if (item.subType === "address") { - trCr++; - if (modelData.type.name === qsTr("contract") + " " + tr.contractId) - item.contractCreationTr.append({ "functionId": tr.contractId + " - " + trCr }); + for (k = 0; k < accounts.length; k++) + { + if (accounts[k].address === undefined) + accounts[k].address = clientModel.address(accounts[k].secret); + item.accountRef.append({ "itemid": accounts[k].name, "value": "0x" + accounts[k].address, "type": "address" }); + } + } } - item.value = getValue(); item.init(); } else if (ptype.category === QSolidityType.Struct && !item.members) diff --git a/mix/qml/TransactionDialog.qml b/mix/qml/TransactionDialog.qml index 0668bfca2..66a98d19e 100644 --- a/mix/qml/TransactionDialog.qml +++ b/mix/qml/TransactionDialog.qml @@ -11,7 +11,7 @@ import "." Dialog { id: modalTransactionDialog modality: Qt.ApplicationModal - width: 520 + width: 570 height: 500 visible: false title: qsTr("Edit Transaction") @@ -387,6 +387,8 @@ Dialog { id: typeLoader Layout.preferredWidth: 150 members: paramsModel; + accounts: senderComboBox.model + context: "parameter" } } diff --git a/mix/qml/VariablesView.qml b/mix/qml/VariablesView.qml index 2670a5cb0..b04739274 100644 --- a/mix/qml/VariablesView.qml +++ b/mix/qml/VariablesView.qml @@ -24,6 +24,8 @@ DebugInfoList members: [] value: {} Layout.preferredWidth: parent.width + context: "variable" + width: parent.width } } } From bd5698b0705c3223d8176690ce4d81738c73c5fd Mon Sep 17 00:00:00 2001 From: chriseth Date: Fri, 24 Apr 2015 11:48:23 +0200 Subject: [PATCH 5/5] Do not handle combined JSON if option not given. --- solc/CommandLineInterface.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index 5e4c901f3..eadc6c56f 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -380,6 +380,9 @@ bool CommandLineInterface::processInput() void CommandLineInterface::handleCombinedJSON() { + if (!m_args.count("combined-json")) + return; + Json::Value output(Json::objectValue); set requests;