diff options
author | chriseth <c@ethdev.com> | 2015-05-04 22:21:44 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2015-05-04 22:21:44 +0800 |
commit | e78be5f4be99c0ecef4d8984dba329dc01da03b6 (patch) | |
tree | 4d29948e39c81082d953532703eb3fd454abe7da /CommandLineInterface.cpp | |
parent | 0e00f51167ae33a8688f26006a5d82d20a31ee8b (diff) | |
download | dexon-solidity-e78be5f4be99c0ecef4d8984dba329dc01da03b6.tar dexon-solidity-e78be5f4be99c0ecef4d8984dba329dc01da03b6.tar.gz dexon-solidity-e78be5f4be99c0ecef4d8984dba329dc01da03b6.tar.bz2 dexon-solidity-e78be5f4be99c0ecef4d8984dba329dc01da03b6.tar.lz dexon-solidity-e78be5f4be99c0ecef4d8984dba329dc01da03b6.tar.xz dexon-solidity-e78be5f4be99c0ecef4d8984dba329dc01da03b6.tar.zst dexon-solidity-e78be5f4be99c0ecef4d8984dba329dc01da03b6.zip |
Feature for commandline compiler to output the function signature hashes.
Diffstat (limited to 'CommandLineInterface.cpp')
-rw-r--r-- | CommandLineInterface.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/CommandLineInterface.cpp b/CommandLineInterface.cpp index d5ff7b29..0b5e046d 100644 --- a/CommandLineInterface.cpp +++ b/CommandLineInterface.cpp @@ -55,6 +55,7 @@ namespace solidity // extensions and other attributes would be a better choice here? static string const g_argAbiStr = "json-abi"; static string const g_argSolAbiStr = "sol-abi"; +static string const g_argSignatureHashes = "hashes"; static string const g_argAsmStr = "asm"; static string const g_argAsmJsonStr = "asm-json"; static string const g_argAstStr = "ast"; @@ -96,6 +97,7 @@ static bool needsHumanTargetedStdout(po::variables_map const& _args) return humanTargetedStdout(_args, g_argAbiStr) || humanTargetedStdout(_args, g_argSolAbiStr) || + humanTargetedStdout(_args, g_argSignatureHashes) || humanTargetedStdout(_args, g_argNatspecUserStr) || humanTargetedStdout(_args, g_argAstJson) || humanTargetedStdout(_args, g_argNatspecDevStr) || @@ -173,6 +175,24 @@ void CommandLineInterface::handleBytecode(string const& _contract) handleBinary(_contract); } +void CommandLineInterface::handleSignatureHashes(string const& _contract) +{ + string out; + for (auto const& it: m_compiler->getContractDefinition(_contract).getInterfaceFunctions()) + out += toHex(it.first.ref()) + ": " + it.second->externalSignature() + "\n"; + + auto choice = m_args[g_argSignatureHashes].as<OutputType>(); + if (outputToStdout(choice)) + cout << "Function signatures: " << endl << out; + + if (outputToFile(choice)) + { + ofstream outFile(_contract + ".signatures"); + outFile << out; + outFile.close(); + } +} + void CommandLineInterface::handleMeta(DocumentationType _type, string const& _contract) { std::string argName; @@ -254,6 +274,8 @@ bool CommandLineInterface::parseArguments(int argc, char** argv) "Request to output the contract's JSON ABI interface.") (g_argSolAbiStr.c_str(), po::value<OutputType>()->value_name("stdout|file|both"), "Request to output the contract's Solidity ABI interface.") + (g_argSignatureHashes.c_str(), po::value<OutputType>()->value_name("stdout|file|both"), + "Request to output the contract's functions' signature hashes.") (g_argNatspecUserStr.c_str(), po::value<OutputType>()->value_name("stdout|file|both"), "Request to output the contract's Natspec user documentation.") (g_argNatspecDevStr.c_str(), po::value<OutputType>()->value_name("stdout|file|both"), @@ -516,6 +538,7 @@ void CommandLineInterface::actOnInput() } handleBytecode(contract); + handleSignatureHashes(contract); handleMeta(DocumentationType::ABIInterface, contract); handleMeta(DocumentationType::ABISolidityInterface, contract); handleMeta(DocumentationType::NatspecDev, contract); |