aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libsolidity/interface/ABI.cpp16
-rw-r--r--test/libsolidity/SolidityABIJSON.cpp249
2 files changed, 151 insertions, 114 deletions
diff --git a/libsolidity/interface/ABI.cpp b/libsolidity/interface/ABI.cpp
index 0e28d010..9af7cdc3 100644
--- a/libsolidity/interface/ABI.cpp
+++ b/libsolidity/interface/ABI.cpp
@@ -136,25 +136,25 @@ Json::Value ABI::formatType(string const& _name, Type const& _type, bool _forLib
suffix = string("[") + arrayType->length().str() + "]";
solAssert(arrayType->baseType(), "");
Json::Value subtype = formatType("", *arrayType->baseType(), _forLibrary);
- if (subtype["type"].isString() && !subtype.isMember("subtype"))
- ret["type"] = subtype["type"].asString() + suffix;
- else
+ if (subtype.isMember("components"))
{
- ret["type"] = suffix;
- solAssert(!subtype.isMember("subtype"), "");
- ret["subtype"] = subtype["type"];
+ ret["type"] = subtype["type"].asString() + suffix;
+ ret["components"] = subtype["components"];
}
+ else
+ ret["type"] = subtype["type"].asString() + suffix;
}
}
else if (StructType const* structType = dynamic_cast<StructType const*>(&_type))
{
- ret["type"] = Json::arrayValue;
+ ret["type"] = string();
+ ret["components"] = Json::arrayValue;
for (auto const& member: structType->members(nullptr))
{
solAssert(member.type, "");
auto t = member.type->interfaceType(_forLibrary);
solAssert(t, "");
- ret["type"].append(formatType(member.name, *t, _forLibrary));
+ ret["components"].append(formatType(member.name, *t, _forLibrary));
}
}
else
diff --git a/test/libsolidity/SolidityABIJSON.cpp b/test/libsolidity/SolidityABIJSON.cpp
index 3de8b732..5ddd28ad 100644
--- a/test/libsolidity/SolidityABIJSON.cpp
+++ b/test/libsolidity/SolidityABIJSON.cpp
@@ -950,32 +950,39 @@ BOOST_AUTO_TEST_CASE(return_structs)
}
)";
char const* interface = R"(
- [
- {
+ [{
"constant" : false,
- "payable": false,
- "inputs": [],
- "name": "f",
- "outputs": [{
- "name": "x",
- "type": "uint256"
- }, {
- "name": "s",
- "type": [{
- "name": "a",
- "type": "uint256"
- }, {
- "name": "sub",
- "subtype": [{
- "name": "x",
- "type": "uint256[2]"
- }],
- "type": "[]"
- }]
- }],
+ "inputs" : [],
+ "name" : "f",
+ "outputs" : [
+ {
+ "name" : "x",
+ "type" : "uint256"
+ },
+ {
+ "components" : [
+ {
+ "name" : "a",
+ "type" : "uint256"
+ },
+ {
+ "components" : [
+ {
+ "name" : "x",
+ "type" : "uint256[2]"
+ }
+ ],
+ "name" : "sub",
+ "type" : "[]"
+ }
+ ],
+ "name" : "s",
+ "type" : ""
+ }
+ ],
+ "payable" : false,
"type" : "function"
- }
- ]
+ }]
)";
checkInterface(text, interface);
}
@@ -990,28 +997,33 @@ BOOST_AUTO_TEST_CASE(return_structs_with_contracts)
}
)";
char const* interface = R"(
- [
- {
- "constant" : false,
- "payable": false,
+ [{
+ "constant": false,
"inputs": [],
"name": "f",
- "outputs" : [{
- "name" : "s",
- "type" : [{
- "name" : "x",
- "type" : "address[]"
- }, {
- "name" : "y",
- "type" : "address"
- }]
- }, {
- "name" : "c",
- "type" : "address"
- }],
- "type" : "function"
- }
- ]
+ "outputs": [
+ {
+ "components": [
+ {
+ "name": "x",
+ "type": "address[]"
+ },
+ {
+ "name": "y",
+ "type": "address"
+ }
+ ],
+ "name": "s",
+ "type": ""
+ },
+ {
+ "name": "c",
+ "type": "address"
+ }
+ ],
+ "payable": false,
+ "type": "function"
+ }]
)";
checkInterface(text, interface);
}
@@ -1025,36 +1037,49 @@ BOOST_AUTO_TEST_CASE(event_structs)
event E(T t, S s);
}
)";
- char const* interface = R"(
- [{
- "anonymous" : false,
- "inputs" : [{
- "indexed" : false,
- "name" : "t",
- "type" : [{
- "name" : "x",
- "type" : "uint256[2]"
- }]
- }, {
- "indexed" : false,
- "name" : "s",
- "type" : [{
- "name" : "a",
- "type" : "uint256"
- }, {
- "name" : "sub",
- "subtype" : [{
- "name" : "x",
- "type" : "uint256[2]"
- }],
- "type" : "[]"
- }, {
- "name" : "b",
- "type" : "bytes"
- }]
- }],
- "name" : "E",
- "type" : "event"
+ char const *interface = R"(
+ [{
+ "anonymous": false,
+ "inputs": [
+ {
+ "components": [
+ {
+ "name": "x",
+ "type": "uint256[2]"
+ }
+ ],
+ "indexed": false,
+ "name": "t",
+ "type": ""
+ },
+ {
+ "components": [
+ {
+ "name": "a",
+ "type": "uint256"
+ },
+ {
+ "components": [
+ {
+ "name": "x",
+ "type": "uint256[2]"
+ }
+ ],
+ "name": "sub",
+ "type": "[]"
+ },
+ {
+ "name": "b",
+ "type": "bytes"
+ }
+ ],
+ "indexed": false,
+ "name": "s",
+ "type": ""
+ }
+ ],
+ "name": "E",
+ "type": "event"
}]
)";
checkInterface(text, interface);
@@ -1072,38 +1097,50 @@ BOOST_AUTO_TEST_CASE(structs_in_libraries)
)";
char const* interface = R"(
[{
- "constant" : false,
- "inputs" : [{
- "name" : "s",
- "type" : [{
- "name" : "a",
- "type" : "uint256"
- }, {
- "name" : "sub",
- "subtype" : [{
- "name" : "x",
- "type" : "uint256[2]"
- }],
- "type" : "[]"
- }, {
- "name" : "b",
- "type" : "bytes"
- }]
- }],
- "name" : "g",
- "outputs" : [],
- "payable" : false,
- "type" : "function"
- }, {
- "constant" : false,
- "inputs" : [{
- "name" : "s",
- "type" : "L.S storage"
- }],
- "name" : "f",
- "outputs" : [],
- "payable" : false,
- "type" : "function"
+ "constant": false,
+ "inputs": [
+ {
+ "components": [
+ {
+ "name": "a",
+ "type": "uint256"
+ },
+ {
+ "components": [
+ {
+ "name": "x",
+ "type": "uint256[2]"
+ }
+ ],
+ "name": "sub",
+ "type": "[]"
+ },
+ {
+ "name": "b",
+ "type": "bytes"
+ }
+ ],
+ "name": "s",
+ "type": ""
+ }
+ ],
+ "name": "g",
+ "outputs": [],
+ "payable": false,
+ "type": "function"
+ },
+ {
+ "constant": false,
+ "inputs": [
+ {
+ "name": "s",
+ "type": "L.S storage"
+ }
+ ],
+ "name": "f",
+ "outputs": [],
+ "payable": false,
+ "type": "function"
}]
)";
checkInterface(text, interface);