Alethzero: Showing a contract's function's hashes at creation

This commit is contained in:
Lefteris Karapetsas 2015-01-12 17:13:27 +01:00
parent c5d14ce933
commit a253abf062
2 changed files with 21 additions and 0 deletions

View File

@ -179,6 +179,24 @@ string const& CompilerStack::getMetadata(string const& _contractName, Documentat
return *(*doc); return *(*doc);
} }
std::string const CompilerStack::getFunctionHashes(std::string const& _contractName)
{
if (!m_parseSuccessful)
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Parsing was not successful."));
std::string ret = "";
Contract const& contract = getContract(_contractName);
auto interfaceFunctions = contract.contract->getInterfaceFunctions();
for (auto const& it: interfaceFunctions)
{
ret += it.first.abridged();
ret += " :";
ret += it.second->getName() + "\n";
}
return ret;
}
Scanner const& CompilerStack::getScanner(string const& _sourceName) const Scanner const& CompilerStack::getScanner(string const& _sourceName) const
{ {
return *getSource(_sourceName).scanner; return *getSource(_sourceName).scanner;

View File

@ -93,6 +93,9 @@ public:
/// Can be one of 4 types defined at @c DocumentationType /// Can be one of 4 types defined at @c DocumentationType
std::string const& getMetadata(std::string const& _contractName, DocumentationType _type) const; std::string const& getMetadata(std::string const& _contractName, DocumentationType _type) const;
/// Convenience function to return all contract method hashes in a string
std::string const getFunctionHashes(std::string const& _contractName = "");
/// @returns the previously used scanner, useful for counting lines during error reporting. /// @returns the previously used scanner, useful for counting lines during error reporting.
Scanner const& getScanner(std::string const& _sourceName = "") const; Scanner const& getScanner(std::string const& _sourceName = "") const;
/// @returns the parsed source unit with the supplied name. /// @returns the parsed source unit with the supplied name.