mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
changed the implementation
This commit is contained in:
parent
4cbff655ff
commit
f0cac2f6a9
@ -38,33 +38,26 @@ std::unique_ptr<std::string> InterfaceHandler::getDocumentation(ContractDefiniti
|
|||||||
std::unique_ptr<std::string> InterfaceHandler::getABIInterface(ContractDefinition const& _contractDef)
|
std::unique_ptr<std::string> InterfaceHandler::getABIInterface(ContractDefinition const& _contractDef)
|
||||||
{
|
{
|
||||||
Json::Value abi(Json::arrayValue);
|
Json::Value abi(Json::arrayValue);
|
||||||
auto allFunctions = _contractDef.getInterfaceFunctions();
|
|
||||||
|
|
||||||
FunctionTypePointer functionTypePointer = nullptr;
|
auto populateParameters = [](vector<string> const& _paramNames, vector<string> const& _paramTypes)
|
||||||
if (_contractDef.getConstructor())
|
|
||||||
{
|
{
|
||||||
functionTypePointer = make_shared<FunctionType>(*_contractDef.getConstructor(), false);
|
Json::Value params(Json::arrayValue);
|
||||||
allFunctions.insert(make_pair(_contractDef.getConstructorsInterface(), functionTypePointer));
|
solAssert(_paramNames.size() == _paramTypes.size(), "Names and types vector size does not match");
|
||||||
}
|
for (unsigned i = 0; i < _paramNames.size(); ++i)
|
||||||
|
|
||||||
for (auto it: allFunctions)
|
|
||||||
{
|
|
||||||
auto populateParameters = [](vector<string> const& _paramNames, vector<string> const& _paramTypes)
|
|
||||||
{
|
{
|
||||||
Json::Value params(Json::arrayValue);
|
Json::Value param;
|
||||||
solAssert(_paramNames.size() == _paramTypes.size(), "Names and types vector size does not match");
|
param["name"] = _paramNames[i];
|
||||||
for (unsigned i = 0; i < _paramNames.size(); ++i)
|
param["type"] = _paramTypes[i];
|
||||||
{
|
params.append(param);
|
||||||
Json::Value param;
|
}
|
||||||
param["name"] = _paramNames[i];
|
return params;
|
||||||
param["type"] = _paramTypes[i];
|
};
|
||||||
params.append(param);
|
|
||||||
}
|
for (auto it: _contractDef.getInterfaceFunctions())
|
||||||
return params;
|
{
|
||||||
};
|
|
||||||
|
|
||||||
Json::Value method;
|
Json::Value method;
|
||||||
method["type"] = (functionTypePointer == it.second ? "constructor" : "function");
|
method["type"] = "function";
|
||||||
method["name"] = it.second->getDeclaration().getName();
|
method["name"] = it.second->getDeclaration().getName();
|
||||||
method["constant"] = it.second->isConstant();
|
method["constant"] = it.second->isConstant();
|
||||||
method["inputs"] = populateParameters(it.second->getParameterNames(),
|
method["inputs"] = populateParameters(it.second->getParameterNames(),
|
||||||
@ -73,6 +66,18 @@ std::unique_ptr<std::string> InterfaceHandler::getABIInterface(ContractDefinitio
|
|||||||
it.second->getReturnParameterTypeNames());
|
it.second->getReturnParameterTypeNames());
|
||||||
abi.append(method);
|
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())
|
for (auto const& it: _contractDef.getInterfaceEvents())
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user