mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add option to store literal sources in metadata
This commit is contained in:
parent
2122d2d728
commit
fcf483ee6b
@ -726,10 +726,15 @@ string CompilerStack::createOnChainMetadata(Contract const& _contract) const
|
|||||||
solAssert(s.second.scanner, "Scanner not available");
|
solAssert(s.second.scanner, "Scanner not available");
|
||||||
meta["sources"][s.first]["keccak256"] =
|
meta["sources"][s.first]["keccak256"] =
|
||||||
"0x" + toHex(dev::keccak256(s.second.scanner->source()).asBytes());
|
"0x" + toHex(dev::keccak256(s.second.scanner->source()).asBytes());
|
||||||
meta["sources"][s.first]["urls"] = Json::arrayValue;
|
if (m_metadataLiteralSources)
|
||||||
meta["sources"][s.first]["urls"].append(
|
meta["sources"][s.first]["content"] = s.second.scanner->source();
|
||||||
"bzzr://" + toHex(dev::swarmHash(s.second.scanner->source()).asBytes())
|
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"]["enabled"] = m_optimize;
|
||||||
meta["settings"]["optimizer"]["runs"] = m_optimizeRuns;
|
meta["settings"]["optimizer"]["runs"] = m_optimizeRuns;
|
||||||
|
@ -177,6 +177,7 @@ public:
|
|||||||
/// Can be one of 4 types defined at @c DocumentationType
|
/// Can be one of 4 types defined at @c DocumentationType
|
||||||
Json::Value const& metadata(std::string const& _contractName, DocumentationType _type) const;
|
Json::Value const& metadata(std::string const& _contractName, DocumentationType _type) const;
|
||||||
std::string const& onChainMetadata(std::string const& _contractName) const;
|
std::string const& onChainMetadata(std::string const& _contractName) const;
|
||||||
|
void useMetadataLiteralSources(bool _metadataLiteralSources) { m_metadataLiteralSources = _metadataLiteralSources; }
|
||||||
|
|
||||||
/// @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& scanner(std::string const& _sourceName = "") const;
|
Scanner const& scanner(std::string const& _sourceName = "") const;
|
||||||
@ -274,6 +275,7 @@ private:
|
|||||||
std::map<std::string const, Contract> m_contracts;
|
std::map<std::string const, Contract> m_contracts;
|
||||||
std::string m_formalTranslation;
|
std::string m_formalTranslation;
|
||||||
ErrorList m_errors;
|
ErrorList m_errors;
|
||||||
|
bool m_metadataLiteralSources = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user