aboutsummaryrefslogtreecommitdiffstats
path: root/InterfaceHandler.cpp
diff options
context:
space:
mode:
authorLiana Husikyan <liana@ethdev.com>2015-04-22 23:00:22 +0800
committerLiana Husikyan <liana@ethdev.com>2015-04-27 19:08:32 +0800
commitf0cac2f6a928c1a6765052e0fd07cab0b936b23f (patch)
tree299f5e0cde9f10075fc02ce1da6b442e47eed9c4 /InterfaceHandler.cpp
parent4cbff655ff6726944bfe7444f61446d82c1411c2 (diff)
downloaddexon-solidity-f0cac2f6a928c1a6765052e0fd07cab0b936b23f.tar
dexon-solidity-f0cac2f6a928c1a6765052e0fd07cab0b936b23f.tar.gz
dexon-solidity-f0cac2f6a928c1a6765052e0fd07cab0b936b23f.tar.bz2
dexon-solidity-f0cac2f6a928c1a6765052e0fd07cab0b936b23f.tar.lz
dexon-solidity-f0cac2f6a928c1a6765052e0fd07cab0b936b23f.tar.xz
dexon-solidity-f0cac2f6a928c1a6765052e0fd07cab0b936b23f.tar.zst
dexon-solidity-f0cac2f6a928c1a6765052e0fd07cab0b936b23f.zip
changed the implementation
Diffstat (limited to 'InterfaceHandler.cpp')
-rw-r--r--InterfaceHandler.cpp47
1 files changed, 26 insertions, 21 deletions
diff --git a/InterfaceHandler.cpp b/InterfaceHandler.cpp
index 42656d37..d4958475 100644
--- a/InterfaceHandler.cpp
+++ b/InterfaceHandler.cpp
@@ -38,33 +38,26 @@ std::unique_ptr<std::string> InterfaceHandler::getDocumentation(ContractDefiniti
std::unique_ptr<std::string> InterfaceHandler::getABIInterface(ContractDefinition const& _contractDef)
{
Json::Value abi(Json::arrayValue);
- auto allFunctions = _contractDef.getInterfaceFunctions();
- FunctionTypePointer functionTypePointer = nullptr;
- if (_contractDef.getConstructor())
+ auto populateParameters = [](vector<string> const& _paramNames, vector<string> const& _paramTypes)
{
- functionTypePointer = make_shared<FunctionType>(*_contractDef.getConstructor(), false);
- allFunctions.insert(make_pair(_contractDef.getConstructorsInterface(), functionTypePointer));
- }
+ Json::Value params(Json::arrayValue);
+ solAssert(_paramNames.size() == _paramTypes.size(), "Names and types vector size does not match");
+ for (unsigned i = 0; i < _paramNames.size(); ++i)
+ {
+ Json::Value param;
+ param["name"] = _paramNames[i];
+ param["type"] = _paramTypes[i];
+ params.append(param);
+ }
+ return params;
+ };
- for (auto it: allFunctions)
+ for (auto it: _contractDef.getInterfaceFunctions())
{
- auto populateParameters = [](vector<string> const& _paramNames, vector<string> const& _paramTypes)
- {
- Json::Value params(Json::arrayValue);
- solAssert(_paramNames.size() == _paramTypes.size(), "Names and types vector size does not match");
- for (unsigned i = 0; i < _paramNames.size(); ++i)
- {
- Json::Value param;
- param["name"] = _paramNames[i];
- param["type"] = _paramTypes[i];
- params.append(param);
- }
- return params;
- };
Json::Value method;
- method["type"] = (functionTypePointer == it.second ? "constructor" : "function");
+ method["type"] = "function";
method["name"] = it.second->getDeclaration().getName();
method["constant"] = it.second->isConstant();
method["inputs"] = populateParameters(it.second->getParameterNames(),
@@ -73,6 +66,18 @@ std::unique_ptr<std::string> InterfaceHandler::getABIInterface(ContractDefinitio
it.second->getReturnParameterTypeNames());
abi.append(method);
}
+ if (_contractDef.getConstructor())
+ {
+ Json::Value method;
+ method["type"] = "constructor";
+ auto externalFunction = FunctionType(*_contractDef.getConstructor()).externalFunctionType();
+ solAssert(!!externalFunction, "");
+ method["inputs"] = populateParameters(
+ externalFunction->getParameterNames(),
+ externalFunction->getParameterTypeNames()
+ );
+ abi.append(method);
+ }
for (auto const& it: _contractDef.getInterfaceEvents())
{