From c617336587b976afc3dbe388ebaa8605c3d6fe54 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Thu, 13 Jul 2017 00:47:15 +0100 Subject: Only include files usde in metadata --- libsolidity/interface/CompilerStack.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'libsolidity') diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index 7a87875c..9b630c31 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -780,9 +780,18 @@ string CompilerStack::createMetadata(Contract const& _contract) const meta["language"] = "Solidity"; meta["compiler"]["version"] = VersionStringStrict; + /// All the source files (including self), which should be included in the metadata. + set referencedSources; + referencedSources.insert(_contract.contract->sourceUnit().annotation().path); + for (auto const sourceUnit: _contract.contract->sourceUnit().referencedSourceUnits(true)) + referencedSources.insert(sourceUnit->annotation().path); + meta["sources"] = Json::objectValue; for (auto const& s: m_sources) { + if (!referencedSources.count(s.first)) + continue; + solAssert(s.second.scanner, "Scanner not available"); meta["sources"][s.first]["keccak256"] = "0x" + toHex(dev::keccak256(s.second.scanner->source()).asBytes()); -- cgit