Add option to store literal sources in metadata

This commit is contained in:
Alex Beregszaszi
2017-01-26 13:16:26 +00:00
parent 2122d2d728
commit fcf483ee6b
2 changed files with 11 additions and 4 deletions
+9 -4
View File
@@ -726,10 +726,15 @@ string CompilerStack::createOnChainMetadata(Contract const& _contract) const
solAssert(s.second.scanner, "Scanner not available");
meta["sources"][s.first]["keccak256"] =
"0x" + toHex(dev::keccak256(s.second.scanner->source()).asBytes());
meta["sources"][s.first]["urls"] = Json::arrayValue;
meta["sources"][s.first]["urls"].append(
"bzzr://" + toHex(dev::swarmHash(s.second.scanner->source()).asBytes())
);
if (m_metadataLiteralSources)
meta["sources"][s.first]["content"] = s.second.scanner->source();
else
{
meta["sources"][s.first]["urls"] = Json::arrayValue;
meta["sources"][s.first]["urls"].append(
"bzzr://" + toHex(dev::swarmHash(s.second.scanner->source()).asBytes())
);
}
}
meta["settings"]["optimizer"]["enabled"] = m_optimize;
meta["settings"]["optimizer"]["runs"] = m_optimizeRuns;