mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Use IPFS url in metadata for source links.
This commit is contained in:
parent
d753fcdb36
commit
b01a8c544c
@ -56,6 +56,7 @@
|
|||||||
#include <libevmasm/Exceptions.h>
|
#include <libevmasm/Exceptions.h>
|
||||||
|
|
||||||
#include <libdevcore/SwarmHash.h>
|
#include <libdevcore/SwarmHash.h>
|
||||||
|
#include <libdevcore/IpfsHash.h>
|
||||||
#include <libdevcore/JSON.h>
|
#include <libdevcore/JSON.h>
|
||||||
|
|
||||||
#include <json/json.h>
|
#include <json/json.h>
|
||||||
@ -769,6 +770,14 @@ h256 const& CompilerStack::Source::swarmHash() const
|
|||||||
return swarmHashCached;
|
return swarmHashCached;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string const& CompilerStack::Source::ipfsUrl() const
|
||||||
|
{
|
||||||
|
if (ipfsUrlCached.empty())
|
||||||
|
if (scanner->source().size() < 1024 * 256)
|
||||||
|
ipfsUrlCached = "dweb:/ipfs/" + dev::ipfsHashBase58(scanner->source());
|
||||||
|
return ipfsUrlCached;
|
||||||
|
}
|
||||||
|
|
||||||
StringMap CompilerStack::loadMissingSources(SourceUnit const& _ast, std::string const& _sourcePath)
|
StringMap CompilerStack::loadMissingSources(SourceUnit const& _ast, std::string const& _sourcePath)
|
||||||
{
|
{
|
||||||
solAssert(m_stackState < ParsingSuccessful, "");
|
solAssert(m_stackState < ParsingSuccessful, "");
|
||||||
@ -1029,6 +1038,7 @@ string CompilerStack::createMetadata(Contract const& _contract) const
|
|||||||
{
|
{
|
||||||
meta["sources"][s.first]["urls"] = Json::arrayValue;
|
meta["sources"][s.first]["urls"] = Json::arrayValue;
|
||||||
meta["sources"][s.first]["urls"].append("bzzr://" + toHex(s.second.swarmHash().asBytes()));
|
meta["sources"][s.first]["urls"].append("bzzr://" + toHex(s.second.swarmHash().asBytes()));
|
||||||
|
meta["sources"][s.first]["urls"].append(s.second.ipfsUrl());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,9 +272,11 @@ private:
|
|||||||
std::shared_ptr<SourceUnit> ast;
|
std::shared_ptr<SourceUnit> ast;
|
||||||
h256 mutable keccak256HashCached;
|
h256 mutable keccak256HashCached;
|
||||||
h256 mutable swarmHashCached;
|
h256 mutable swarmHashCached;
|
||||||
|
std::string mutable ipfsUrlCached;
|
||||||
void reset() { *this = Source(); }
|
void reset() { *this = Source(); }
|
||||||
h256 const& keccak256() const;
|
h256 const& keccak256() const;
|
||||||
h256 const& swarmHash() const;
|
h256 const& swarmHash() const;
|
||||||
|
std::string const& ipfsUrl() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// The state per contract. Filled gradually during compilation.
|
/// The state per contract. Filled gradually during compilation.
|
||||||
|
Loading…
Reference in New Issue
Block a user