Use CompilerStack.contractABI directly

This commit is contained in:
Alex Beregszaszi
2017-05-19 15:57:36 +01:00
parent 8169e149c9
commit 4bf3cbb09a
5 changed files with 24 additions and 15 deletions
+15 -12
View File
@@ -266,12 +266,24 @@ void CommandLineInterface::handleOnChainMetadata(string const& _contract)
return;
string data = m_compiler->onChainMetadata(_contract);
if (m_args.count("output-dir"))
if (m_args.count(g_argOutputDir))
createFile(m_compiler->filesystemFriendlyName(_contract) + "_meta.json", data);
else
cout << "Metadata: " << endl << data << endl;
}
void CommandLineInterface::handleABI(string const& _contract)
{
if (!m_args.count(g_argAbi))
return;
string data = dev::jsonCompactPrint(m_compiler->contractABI(_contract));
if (m_args.count(g_argOutputDir))
createFile(m_compiler->filesystemFriendlyName(_contract) + ".abi", data);
else
cout << "Contract JSON ABI " << endl << data << endl;
}
void CommandLineInterface::handleMeta(DocumentationType _type, string const& _contract)
{
std::string argName;
@@ -279,11 +291,6 @@ void CommandLineInterface::handleMeta(DocumentationType _type, string const& _co
std::string title;
switch(_type)
{
case DocumentationType::ABIInterface:
argName = g_argAbi;
suffix = ".abi";
title = "Contract JSON ABI";
break;
case DocumentationType::NatspecUser:
argName = g_argNatspecUser;
suffix = ".docuser";
@@ -301,11 +308,7 @@ void CommandLineInterface::handleMeta(DocumentationType _type, string const& _co
if (m_args.count(argName))
{
std::string output;
if (_type == DocumentationType::ABIInterface)
output = dev::jsonCompactPrint(m_compiler->metadata(_contract, _type));
else
output = dev::jsonPrettyPrint(m_compiler->metadata(_contract, _type));
std::string output = dev::jsonPrettyPrint(m_compiler->metadata(_contract, _type));
if (m_args.count(g_argOutputDir))
createFile(m_compiler->filesystemFriendlyName(_contract) + suffix, output);
@@ -1069,7 +1072,7 @@ void CommandLineInterface::outputCompilationResults()
handleBytecode(contract);
handleSignatureHashes(contract);
handleOnChainMetadata(contract);
handleMeta(DocumentationType::ABIInterface, contract);
handleABI(contract);
handleMeta(DocumentationType::NatspecDev, contract);
handleMeta(DocumentationType::NatspecUser, contract);
} // end of contracts iteration