File tree 2 files changed +12
-0
lines changed
2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change 56
56
#include < libevmasm/Exceptions.h>
57
57
58
58
#include < libdevcore/SwarmHash.h>
59
+ #include < libdevcore/IpfsHash.h>
59
60
#include < libdevcore/JSON.h>
60
61
61
62
#include < json/json.h>
@@ -769,6 +770,14 @@ h256 const& CompilerStack::Source::swarmHash() const
769
770
return swarmHashCached;
770
771
}
771
772
773
+ string const & CompilerStack::Source::ipfsUrl () const
774
+ {
775
+ if (ipfsUrlCached.empty ())
776
+ if (scanner->source ().size () < 1025 * 256 )
777
+ ipfsUrlCached = " dweb:/ipfs/" + dev::ipfsHashBase58 (scanner->source ());
778
+ return ipfsUrlCached;
779
+ }
780
+
772
781
StringMap CompilerStack::loadMissingSources (SourceUnit const & _ast, std::string const & _sourcePath)
773
782
{
774
783
solAssert (m_stackState < ParsingSuccessful, " " );
@@ -1029,6 +1038,7 @@ string CompilerStack::createMetadata(Contract const& _contract) const
1029
1038
{
1030
1039
meta[" sources" ][s.first ][" urls" ] = Json::arrayValue;
1031
1040
meta[" sources" ][s.first ][" urls" ].append (" bzzr://" + toHex (s.second .swarmHash ().asBytes ()));
1041
+ meta[" sources" ][s.first ][" urls" ].append (s.second .ipfsUrl ());
1032
1042
}
1033
1043
}
1034
1044
Original file line number Diff line number Diff line change @@ -272,9 +272,11 @@ class CompilerStack: boost::noncopyable
272
272
std::shared_ptr<SourceUnit> ast;
273
273
h256 mutable keccak256HashCached;
274
274
h256 mutable swarmHashCached;
275
+ std::string mutable ipfsUrlCached;
275
276
void reset () { *this = Source (); }
276
277
h256 const & keccak256 () const ;
277
278
h256 const & swarmHash () const ;
279
+ std::string const & ipfsUrl () const ;
278
280
};
279
281
280
282
// / The state per contract. Filled gradually during compilation.
You can’t perform that action at this time.
0 commit comments