Browse Source

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

cl-refactor
Gav Wood 10 years ago
parent
commit
600e40a31c
  1. 2
      eth/main.cpp
  2. 2
      libsolidity/InterfaceHandler.cpp
  3. 4
      mix/ContractCallDataEncoder.cpp
  4. 23
      mix/qml/QAddressView.qml
  5. 2
      mix/qml/StateListModel.qml
  6. 43
      mix/qml/StructView.qml
  7. 4
      mix/qml/TransactionDialog.qml
  8. 2
      mix/qml/VariablesView.qml
  9. 11
      solc/CommandLineInterface.cpp
  10. 12
      test/libsolidity/SolidityInterface.cpp

2
eth/main.cpp

@ -1317,9 +1317,9 @@ int main(int argc, char** argv)
{ {
string hexAddr; string hexAddr;
u256 amount; u256 amount;
int size = hexAddr.length();
iss >> hexAddr >> amount; iss >> hexAddr >> amount;
int size = hexAddr.length();
if (size < 40) if (size < 40)
{ {
if (size > 0) if (size > 0)

2
libsolidity/InterfaceHandler.cpp

@ -107,7 +107,7 @@ unique_ptr<string> InterfaceHandler::getABISolidityInterface(ContractDefinition
ret += "returns" + populateParameters(it.second->getReturnParameterNames(), it.second->getReturnParameterTypeNames()); ret += "returns" + populateParameters(it.second->getReturnParameterNames(), it.second->getReturnParameterTypeNames());
else if (ret.back() == ' ') else if (ret.back() == ' ')
ret.pop_back(); ret.pop_back();
ret += "{}"; ret += ";";
} }
return unique_ptr<string>(new string(ret + "}")); return unique_ptr<string>(new string(ret + "}"));

4
mix/ContractCallDataEncoder.cpp

@ -195,7 +195,7 @@ QVariant ContractCallDataEncoder::decode(SolidityType const& _type, bytes const&
bytes rawParam(32); bytes rawParam(32);
value.populate(&rawParam); value.populate(&rawParam);
QSolidityType::Type type = _type.type; 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))); return QVariant::fromValue(toString(decodeInt(rawParam)));
else if (type == QSolidityType::Type::Bool) else if (type == QSolidityType::Type::Bool)
return QVariant::fromValue(toString(decodeBool(rawParam))); return QVariant::fromValue(toString(decodeBool(rawParam)));
@ -203,6 +203,8 @@ QVariant ContractCallDataEncoder::decode(SolidityType const& _type, bytes const&
return QVariant::fromValue(toString(decodeBytes(rawParam))); return QVariant::fromValue(toString(decodeBytes(rawParam)));
else if (type == QSolidityType::Type::Struct) else if (type == QSolidityType::Type::Struct)
return QVariant::fromValue(QString("struct")); //TODO return QVariant::fromValue(QString("struct")); //TODO
else if (type == QSolidityType::Type::Address)
return QVariant::fromValue(toString(decodeBytes(unpadLeft(rawParam))));
else else
BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("Parameter declaration not found")); BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("Parameter declaration not found"));
} }

23
mix/qml/QAddressView.qml

@ -5,10 +5,12 @@ import QtQuick.Controls.Styles 1.3
Item Item
{ {
property alias value: textinput.text property alias value: textinput.text
property alias contractCreationTr: ctrModel property alias accountRef: ctrModel
property string subType
property bool readOnly
id: editRoot id: editRoot
height: 20 height: 20
width: 200 width: 320
SourceSansProBold SourceSansProBold
{ {
@ -17,19 +19,19 @@ Item
function init() function init()
{ {
trCombobox.visible = ctrModel.count > 1; //index 0 is a blank value. trCombobox.visible = !readOnly
if (value.indexOf("<") === 0) textinput.readOnly = readOnly
if (!readOnly)
{ {
for (var k = 0; k < ctrModel.count; k++) for (var k = 0; k < ctrModel.count; k++)
{ {
if ("<" + ctrModel.get(k).functionId + ">" === value) if (ctrModel.get(k).value === value)
{ {
trCombobox.currentIndex = k; trCombobox.currentIndex = k;
return; return;
} }
} }
trCombobox.currentIndex = 0; trCombobox.currentIndex = 0;
value = "";
} }
} }
@ -43,7 +45,7 @@ Item
text: value text: value
width: parent.width width: parent.width
height: parent.width height: parent.width
wrapMode: Text.WrapAnywhere wrapMode: Text.WordWrap
clip: true clip: true
font.family: boldFont.name font.family: boldFont.name
MouseArea { MouseArea {
@ -73,7 +75,7 @@ Item
property bool selected: false property bool selected: false
id: trCombobox id: trCombobox
model: ctrModel model: ctrModel
textRole: "functionId" textRole: "itemid"
height: 20 height: 20
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.left: textinput.parent.right anchors.left: textinput.parent.right
@ -84,7 +86,10 @@ Item
return; return;
else if (currentText !== " - ") 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; trCombobox.selected = true;
} }
else if (textinput.text.indexOf("<") === 0) else if (textinput.text.indexOf("<") === 0)

2
mix/qml/StateListModel.qml

@ -183,7 +183,7 @@ Item {
_secret = clientModel.newSecret(); _secret = clientModel.newSecret();
var address = clientModel.address(_secret); var address = clientModel.address(_secret);
var name = qsTr("Account") + "-" + address.substring(0, 4); 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() { function createDefaultState() {

43
mix/qml/StructView.qml

@ -7,8 +7,10 @@ Column
{ {
id: root id: root
property alias members: repeater.model //js array property alias members: repeater.model //js array
property variant accounts
property var value: ({}) property var value: ({})
property int transactionIndex property int transactionIndex
property string context
Layout.fillWidth: true Layout.fillWidth: true
spacing: 10 spacing: 10
Repeater Repeater
@ -69,21 +71,40 @@ Column
var vals = value; var vals = value;
if (ptype.category === QSolidityType.Address) if (ptype.category === QSolidityType.Address)
{ {
item.contractCreationTr.append({"functionId": " - "}); item.value = getValue();
var trCr = -1; item.readOnly = context === "variable";
for (var k = 0; k < transactionsModel.count; k++) if (context === "parameter")
{ {
if (k >= transactionIndex) var dec = modelData.type.name.split(" ");
break; item.subType = dec[0];
var tr = transactionsModel.get(k); item.accountRef.append({"itemid": " - "});
if (tr.functionId === tr.contractId)
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++; for (k = 0; k < accounts.length; k++)
if (modelData.type.name === qsTr("contract") + " " + tr.contractId) {
item.contractCreationTr.append({ "functionId": tr.contractId + " - " + trCr }); 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(); item.init();
} }
else if (ptype.category === QSolidityType.Struct && !item.members) else if (ptype.category === QSolidityType.Struct && !item.members)

4
mix/qml/TransactionDialog.qml

@ -11,7 +11,7 @@ import "."
Dialog { Dialog {
id: modalTransactionDialog id: modalTransactionDialog
modality: Qt.ApplicationModal modality: Qt.ApplicationModal
width: 520 width: 570
height: 500 height: 500
visible: false visible: false
title: qsTr("Edit Transaction") title: qsTr("Edit Transaction")
@ -387,6 +387,8 @@ Dialog {
id: typeLoader id: typeLoader
Layout.preferredWidth: 150 Layout.preferredWidth: 150
members: paramsModel; members: paramsModel;
accounts: senderComboBox.model
context: "parameter"
} }
} }

2
mix/qml/VariablesView.qml

@ -24,6 +24,8 @@ DebugInfoList
members: [] members: []
value: {} value: {}
Layout.preferredWidth: parent.width Layout.preferredWidth: parent.width
context: "variable"
width: parent.width
} }
} }
} }

11
solc/CommandLineInterface.cpp

@ -270,7 +270,7 @@ bool CommandLineInterface::parseArguments(int argc, char** argv)
} }
catch (po::error const& _exception) catch (po::error const& _exception)
{ {
cout << _exception.what() << endl; cerr << _exception.what() << endl;
return false; return false;
} }
if (m_args.count("combined-json")) 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<string>(), boost::is_any_of(","))) for (string const& item: boost::split(requests, m_args["combined-json"].as<string>(), boost::is_any_of(",")))
if (!g_combinedJsonArgs.count(item)) if (!g_combinedJsonArgs.count(item))
{ {
cout << "Invalid option to --combined-json: " << item << endl; cerr << "Invalid option to --combined-json: " << item << endl;
return false; return false;
} }
} }
@ -317,13 +317,13 @@ bool CommandLineInterface::processInput()
auto path = boost::filesystem::path(infile); auto path = boost::filesystem::path(infile);
if (!boost::filesystem::exists(path)) if (!boost::filesystem::exists(path))
{ {
cout << "Skipping non existant input file \"" << infile << "\"" << endl; cerr << "Skipping non existant input file \"" << infile << "\"" << endl;
continue; continue;
} }
if (!boost::filesystem::is_regular_file(path)) 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; continue;
} }
@ -380,6 +380,9 @@ bool CommandLineInterface::processInput()
void CommandLineInterface::handleCombinedJSON() void CommandLineInterface::handleCombinedJSON()
{ {
if (!m_args.count("combined-json"))
return;
Json::Value output(Json::objectValue); Json::Value output(Json::objectValue);
set<string> requests; set<string> requests;

12
test/libsolidity/SolidityInterface.cpp

@ -78,7 +78,7 @@ BOOST_AUTO_TEST_CASE(single_function)
"}\n"); "}\n");
BOOST_REQUIRE_EQUAL(1, contract.getDefinedFunctions().size()); BOOST_REQUIRE_EQUAL(1, contract.getDefinedFunctions().size());
BOOST_CHECK_EQUAL(getSourcePart(*contract.getDefinedFunctions().front()), 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) 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; } }"); "contract test { function f(uint a) constant returns(bytes1 x) { 1==2; } }");
BOOST_REQUIRE_EQUAL(1, contract.getDefinedFunctions().size()); BOOST_REQUIRE_EQUAL(1, contract.getDefinedFunctions().size());
BOOST_CHECK_EQUAL(getSourcePart(*contract.getDefinedFunctions().front()), 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) 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" " function g(uint b) returns(uint e) { return b * 8; }\n"
"}\n"; "}\n";
ContractDefinition const& contract = checkInterface(sourceCode); ContractDefinition const& contract = checkInterface(sourceCode);
set<string> expectation({"function f(uint256 a)returns(uint256 d){}", set<string> expectation({"function f(uint256 a)returns(uint256 d);",
"function g(uint256 b)returns(uint256 e){}"}); "function g(uint256 b)returns(uint256 e);"});
BOOST_REQUIRE_EQUAL(2, contract.getDefinedFunctions().size()); BOOST_REQUIRE_EQUAL(2, contract.getDefinedFunctions().size());
BOOST_CHECK(expectation == set<string>({getSourcePart(*contract.getDefinedFunctions().at(0)), BOOST_CHECK(expectation == set<string>({getSourcePart(*contract.getDefinedFunctions().at(0)),
getSourcePart(*contract.getDefinedFunctions().at(1))})); getSourcePart(*contract.getDefinedFunctions().at(1))}));
@ -135,8 +135,8 @@ BOOST_AUTO_TEST_CASE(inheritance)
" event derivedEvent(uint indexed evtArgDerived); \n" " event derivedEvent(uint indexed evtArgDerived); \n"
" }"; " }";
ContractDefinition const& contract = checkInterface(sourceCode); ContractDefinition const& contract = checkInterface(sourceCode);
set<string> expectedFunctions({"function baseFunction(uint256 p)returns(uint256 i){}", set<string> expectedFunctions({"function baseFunction(uint256 p)returns(uint256 i);",
"function derivedFunction(bytes32 p)returns(bytes32 i){}"}); "function derivedFunction(bytes32 p)returns(bytes32 i);"});
BOOST_REQUIRE_EQUAL(2, contract.getDefinedFunctions().size()); BOOST_REQUIRE_EQUAL(2, contract.getDefinedFunctions().size());
BOOST_CHECK(expectedFunctions == set<string>({getSourcePart(*contract.getDefinedFunctions().at(0)), BOOST_CHECK(expectedFunctions == set<string>({getSourcePart(*contract.getDefinedFunctions().at(0)),
getSourcePart(*contract.getDefinedFunctions().at(1))})); getSourcePart(*contract.getDefinedFunctions().at(1))}));

Loading…
Cancel
Save