mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Make sure some keys are present.
This commit is contained in:
parent
e666f8cda7
commit
659b635b2d
@ -670,6 +670,7 @@ string CompilerStack::createOnChainMetadata(Contract const& _contract) const
|
|||||||
meta["language"] = "Solidity";
|
meta["language"] = "Solidity";
|
||||||
meta["compiler"]["version"] = VersionString;
|
meta["compiler"]["version"] = VersionString;
|
||||||
|
|
||||||
|
meta["sources"] = Json::objectValue;
|
||||||
for (auto const& s: m_sources)
|
for (auto const& s: m_sources)
|
||||||
{
|
{
|
||||||
solAssert(s.second.scanner, "Scanner not available");
|
solAssert(s.second.scanner, "Scanner not available");
|
||||||
@ -683,12 +684,14 @@ string CompilerStack::createOnChainMetadata(Contract const& _contract) const
|
|||||||
meta["settings"]["compilationTarget"][_contract.contract->sourceUnitName()] =
|
meta["settings"]["compilationTarget"][_contract.contract->sourceUnitName()] =
|
||||||
_contract.contract->annotation().canonicalName;
|
_contract.contract->annotation().canonicalName;
|
||||||
|
|
||||||
|
meta["settings"]["remappings"] = Json::arrayValue;
|
||||||
set<string> remappings;
|
set<string> remappings;
|
||||||
for (auto const& r: m_remappings)
|
for (auto const& r: m_remappings)
|
||||||
remappings.insert(r.context + ":" + r.prefix + "=" + r.target);
|
remappings.insert(r.context + ":" + r.prefix + "=" + r.target);
|
||||||
for (auto const& r: remappings)
|
for (auto const& r: remappings)
|
||||||
meta["settings"]["remappings"].append(r);
|
meta["settings"]["remappings"].append(r);
|
||||||
|
|
||||||
|
meta["settings"]["libraries"] = Json::objectValue;
|
||||||
for (auto const& library: m_libraries)
|
for (auto const& library: m_libraries)
|
||||||
meta["settings"]["libraries"][library.first] = "0x" + toHex(library.second.asBytes());
|
meta["settings"]["libraries"][library.first] = "0x" + toHex(library.second.asBytes());
|
||||||
|
|
||||||
|
@ -212,7 +212,7 @@ void CommandLineInterface::handleOnChainMetadata(string const& _contract)
|
|||||||
|
|
||||||
string data = m_compiler->onChainMetadata(_contract);
|
string data = m_compiler->onChainMetadata(_contract);
|
||||||
if (m_args.count("output-dir"))
|
if (m_args.count("output-dir"))
|
||||||
createFile(_contract + ".meta", data);
|
createFile(_contract + "_meta.json", data);
|
||||||
else
|
else
|
||||||
cout << "Metadata: " << endl << data << endl;
|
cout << "Metadata: " << endl << data << endl;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user