diff options
author | Liana Husikyan <liana@ethdev.com> | 2015-04-17 21:26:12 +0800 |
---|---|---|
committer | Liana Husikyan <liana@ethdev.com> | 2015-04-27 19:08:32 +0800 |
commit | 2d62c482fd50a69bb19d2c3e3adca3a66260417f (patch) | |
tree | e3a3903b584289a066263872f00abbf44ff530c5 | |
parent | fcd3f44fd9b76c659fa0a41beeb00680e8337a5e (diff) | |
download | dexon-solidity-2d62c482fd50a69bb19d2c3e3adca3a66260417f.tar dexon-solidity-2d62c482fd50a69bb19d2c3e3adca3a66260417f.tar.gz dexon-solidity-2d62c482fd50a69bb19d2c3e3adca3a66260417f.tar.bz2 dexon-solidity-2d62c482fd50a69bb19d2c3e3adca3a66260417f.tar.lz dexon-solidity-2d62c482fd50a69bb19d2c3e3adca3a66260417f.tar.xz dexon-solidity-2d62c482fd50a69bb19d2c3e3adca3a66260417f.tar.zst dexon-solidity-2d62c482fd50a69bb19d2c3e3adca3a66260417f.zip |
fixed the output of the test
-rw-r--r-- | AST.cpp | 6 | ||||
-rw-r--r-- | AST.h | 3 | ||||
-rw-r--r-- | InterfaceHandler.cpp | 14 |
3 files changed, 21 insertions, 2 deletions
@@ -124,6 +124,12 @@ FunctionDefinition const* ContractDefinition::getConstructor() const return nullptr; } +FixedHash<4> ContractDefinition::getConstructorsInterface() const +{ + return FixedHash<4>(dev::sha3(getConstructor()->externalSignature())); + //return hash; +} + FunctionDefinition const* ContractDefinition::getFallbackFunction() const { for (ContractDefinition const* contract: getLinearizedBaseContracts()) @@ -281,6 +281,9 @@ public: /// Returns the fallback function or nullptr if no fallback function was specified. FunctionDefinition const* getFallbackFunction() const; + ///@returns hash of the constructor + FixedHash<4> getConstructorsInterface() const; + private: /// Checks that two functions defined in this contract with the same name have different /// arguments and that there is at most one constructor. diff --git a/InterfaceHandler.cpp b/InterfaceHandler.cpp index ea787c28..d68f9dbe 100644 --- a/InterfaceHandler.cpp +++ b/InterfaceHandler.cpp @@ -38,7 +38,17 @@ std::unique_ptr<std::string> InterfaceHandler::getDocumentation(ContractDefiniti std::unique_ptr<std::string> InterfaceHandler::getABIInterface(ContractDefinition const& _contractDef) { Json::Value abi(Json::arrayValue); - for (auto const& it: _contractDef.getInterfaceFunctions()) + auto allFunctions = _contractDef.getInterfaceFunctions(); + + FunctionTypePointer functionTypePointer = nullptr; + if (_contractDef.getConstructor()) + { + functionTypePointer = make_shared<FunctionType>(*_contractDef.getConstructor(), false); + allFunctions.insert(make_pair(_contractDef.getConstructorsInterface(), functionTypePointer)); + } + + //allFunctions.insert(_contractDef.getConstructor()); + for (auto it: allFunctions) { auto populateParameters = [](vector<string> const& _paramNames, vector<string> const& _paramTypes) { @@ -55,7 +65,7 @@ std::unique_ptr<std::string> InterfaceHandler::getABIInterface(ContractDefinitio }; Json::Value method; - method["type"] = "function"; + method["type"] = (functionTypePointer == it.second ? "constructor" : "function"); method["name"] = it.second->getDeclaration().getName(); method["constant"] = it.second->isConstant(); method["inputs"] = populateParameters(it.second->getParameterNames(), |