Add errors to the ABI.

This commit is contained in:
chriseth
2021-03-30 21:16:58 +02:00
parent d80059fb98
commit 517cd17a6f
3 changed files with 204 additions and 0 deletions
+17
View File
@@ -121,6 +121,23 @@ Json::Value ABI::generate(ContractDefinition const& _contractDef)
abi.emplace(std::move(event));
}
for (ErrorDefinition const* error: _contractDef.interfaceErrors())
{
Json::Value errorJson;
errorJson["type"] = "error";
errorJson["name"] = error->name();
errorJson["inputs"] = Json::arrayValue;
for (auto const& p: error->parameters())
{
Type const* type = p->annotation().type->interfaceType(false);
solAssert(type, "");
errorJson["inputs"].append(
formatType(p->name(), *type, *p->annotation().type, false)
);
}
abi.emplace(move(errorJson));
}
Json::Value abiJson{Json::arrayValue};
for (auto& f: abi)
abiJson.append(std::move(f));