diff options
Diffstat (limited to 'solc')
-rw-r--r-- | solc/CommandLineInterface.cpp | 23 | ||||
-rw-r--r-- | solc/CommandLineInterface.h | 1 | ||||
-rw-r--r-- | solc/jsonCompiler.cpp | 1 |
3 files changed, 22 insertions, 3 deletions
diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index 49fac51c..6e59099a 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -78,6 +78,7 @@ static string const g_argCloneBinaryStr = "clone-bin"; static string const g_argOpcodesStr = "opcodes"; static string const g_argNatspecDevStr = "devdoc"; static string const g_argNatspecUserStr = "userdoc"; +static string const g_argMetadata = "metadata"; static string const g_argAddStandard = "add-std"; static string const g_stdinFileName = "<stdin>"; @@ -91,6 +92,7 @@ static set<string> const g_combinedJsonArgs{ "opcodes", "abi", "interface", + "metadata", "asm", "ast", "userdoc", @@ -117,6 +119,7 @@ static bool needsHumanTargetedStdout(po::variables_map const& _args) for (string const& arg: { g_argAbiStr, g_argSignatureHashes, + g_argMetadata, g_argNatspecUserStr, g_argAstJson, g_argNatspecDevStr, @@ -202,6 +205,18 @@ void CommandLineInterface::handleSignatureHashes(string const& _contract) cout << "Function signatures: " << endl << out; } +void CommandLineInterface::handleOnChainMetadata(string const& _contract) +{ + if (!m_args.count(g_argMetadata)) + return; + + string data = m_compiler->onChainMetadata(_contract); + if (m_args.count("output-dir")) + createFile(_contract + "_meta.json", data); + else + cout << "Metadata: " << endl << data << endl; +} + void CommandLineInterface::handleMeta(DocumentationType _type, string const& _contract) { std::string argName; @@ -467,6 +482,7 @@ Allowed options)", (g_argSignatureHashes.c_str(), "Function signature hashes of the contracts.") (g_argNatspecUserStr.c_str(), "Natspec user documentation of all contracts.") (g_argNatspecDevStr.c_str(), "Natspec developer documentation of all contracts.") + (g_argMetadata.c_str(), "Combined Metadata JSON whose Swarm hash is stored on-chain.") ("formal", "Translated source suitable for formal analysis."); desc.add(outputComponents); @@ -581,9 +597,7 @@ bool CommandLineInterface::processInput() // TODO: Perhaps we should not compile unless requested bool optimize = m_args.count("optimize") > 0; unsigned runs = m_args["optimize-runs"].as<unsigned>(); - bool successful = m_compiler->compile(optimize, runs); - if (successful) - m_compiler->link(m_libraries); + bool successful = m_compiler->compile(optimize, runs, m_libraries); if (successful && m_args.count("formal")) if (!m_compiler->prepareFormalAnalysis()) @@ -659,6 +673,8 @@ void CommandLineInterface::handleCombinedJSON() Json::Value contractData(Json::objectValue); if (requests.count("abi")) contractData["abi"] = dev::jsonCompactPrint(m_compiler->interface(contractName)); + if (requests.count("metadata")) + contractData["metadata"] = m_compiler->onChainMetadata(contractName); if (requests.count("bin")) contractData["bin"] = m_compiler->object(contractName).toHex(); if (requests.count("bin-runtime")) @@ -918,6 +934,7 @@ void CommandLineInterface::outputCompilationResults() handleBytecode(contract); handleSignatureHashes(contract); + handleOnChainMetadata(contract); handleMeta(DocumentationType::ABIInterface, contract); handleMeta(DocumentationType::NatspecDev, contract); handleMeta(DocumentationType::NatspecUser, contract); diff --git a/solc/CommandLineInterface.h b/solc/CommandLineInterface.h index 33ae6ee6..b8fc1823 100644 --- a/solc/CommandLineInterface.h +++ b/solc/CommandLineInterface.h @@ -63,6 +63,7 @@ private: void handleOpcode(std::string const& _contract); void handleBytecode(std::string const& _contract); void handleSignatureHashes(std::string const& _contract); + void handleOnChainMetadata(std::string const& _contract); void handleMeta(DocumentationType _type, std::string const& _contract); void handleGasEstimation(std::string const& _contract); void handleFormal(); diff --git a/solc/jsonCompiler.cpp b/solc/jsonCompiler.cpp index 0f95ebe5..d761b541 100644 --- a/solc/jsonCompiler.cpp +++ b/solc/jsonCompiler.cpp @@ -218,6 +218,7 @@ string compile(StringMap const& _sources, bool _optimize, CStyleReadFileCallback contractData["bytecode"] = compiler.object(contractName).toHex(); contractData["runtimeBytecode"] = compiler.runtimeObject(contractName).toHex(); contractData["opcodes"] = solidity::disassemble(compiler.object(contractName).bytecode); + contractData["metadata"] = compiler.onChainMetadata(contractName); contractData["functionHashes"] = functionHashes(compiler.contractDefinition(contractName)); contractData["gasEstimates"] = estimateGas(compiler, contractName); auto sourceMap = compiler.sourceMapping(contractName); |