mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add event and error identifiers to cli hashes cmd
This commit is contained in:
@@ -75,6 +75,7 @@
|
||||
#include <libsolutil/IpfsHash.h>
|
||||
#include <libsolutil/JSON.h>
|
||||
#include <libsolutil/Algorithms.h>
|
||||
#include <libsolutil/FunctionSelector.h>
|
||||
|
||||
#include <json/json.h>
|
||||
|
||||
@@ -1024,6 +1025,37 @@ Json::Value CompilerStack::methodIdentifiers(string const& _contractName) const
|
||||
return methodIdentifiers;
|
||||
}
|
||||
|
||||
Json::Value CompilerStack::errorIdentifiers(string const& _contractName) const
|
||||
{
|
||||
if (m_stackState < AnalysisPerformed)
|
||||
solThrow(CompilerError, "Analysis was not successful.");
|
||||
|
||||
Json::Value errorIdentifiers(Json::objectValue);
|
||||
for (ErrorDefinition const* error: contractDefinition(_contractName).interfaceErrors())
|
||||
{
|
||||
string signature = error->functionType(true)->externalSignature();
|
||||
errorIdentifiers[signature] = toHex(toCompactBigEndian(selectorFromSignature32(signature), 4));
|
||||
}
|
||||
|
||||
return errorIdentifiers;
|
||||
}
|
||||
|
||||
Json::Value CompilerStack::eventIdentifiers(string const& _contractName) const
|
||||
{
|
||||
if (m_stackState < AnalysisPerformed)
|
||||
solThrow(CompilerError, "Analysis was not successful.");
|
||||
|
||||
Json::Value eventIdentifiers(Json::objectValue);
|
||||
for (EventDefinition const* event: contractDefinition(_contractName).interfaceEvents())
|
||||
if (!event->isAnonymous())
|
||||
{
|
||||
string signature = event->functionType(true)->externalSignature();
|
||||
eventIdentifiers[signature] = toHex(u256(h256::Arith(keccak256(signature))));
|
||||
}
|
||||
|
||||
return eventIdentifiers;
|
||||
}
|
||||
|
||||
bytes CompilerStack::cborMetadata(string const& _contractName, bool _forIR) const
|
||||
{
|
||||
if (m_stackState < AnalysisPerformed)
|
||||
|
||||
@@ -330,6 +330,12 @@ public:
|
||||
/// @returns a JSON representing a map of method identifiers (hashes) to function names.
|
||||
Json::Value methodIdentifiers(std::string const& _contractName) const;
|
||||
|
||||
/// @returns a JSON representing a map of error identifiers (hashes) to error names.
|
||||
Json::Value errorIdentifiers(std::string const& _contractName) const;
|
||||
|
||||
/// @returns a JSON representing a map of event identifiers (hashes) to event names.
|
||||
Json::Value eventIdentifiers(std::string const& _contractName) const;
|
||||
|
||||
/// @returns the Contract Metadata matching the pipeline selected using the viaIR setting.
|
||||
std::string const& metadata(std::string const& _contractName) const { return metadata(contract(_contractName)); }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user