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>
@@ -768,6 +769,14 @@ h256 const& CompilerStack::Source::swarmHash() const
768
769
return swarmHashCached;
769
770
}
770
771
772
+ string const & CompilerStack::Source::ipfsUrl () const
773
+ {
774
+ if (ipfsUrlCached.empty ())
775
+ if (scanner->source ().size () < 1025 * 256 )
776
+ ipfsUrlCached = " ipfs://" + dev::ipfsHashBase58 (scanner->source ());
777
+ return ipfsUrlCached;
778
+ }
779
+
771
780
StringMap CompilerStack::loadMissingSources (SourceUnit const & _ast, std::string const & _sourcePath)
772
781
{
773
782
solAssert (m_stackState < ParsingSuccessful, " " );
@@ -1028,6 +1037,7 @@ string CompilerStack::createMetadata(Contract const& _contract) const
1028
1037
{
1029
1038
meta[" sources" ][s.first ][" urls" ] = Json::arrayValue;
1030
1039
meta[" sources" ][s.first ][" urls" ].append (" bzzr://" + toHex (s.second .swarmHash ().asBytes ()));
1040
+ meta[" sources" ][s.first ][" urls" ].append (s.second .ipfsUrl ());
1031
1041
}
1032
1042
}
1033
1043
Original file line number Diff line number Diff line change @@ -269,9 +269,11 @@ class CompilerStack: boost::noncopyable
269
269
std::shared_ptr<SourceUnit> ast;
270
270
h256 mutable keccak256HashCached;
271
271
h256 mutable swarmHashCached;
272
+ std::string mutable ipfsUrlCached;
272
273
void reset () { *this = Source (); }
273
274
h256 const & keccak256 () const ;
274
275
h256 const & swarmHash () const ;
276
+ std::string const & ipfsUrl () const ;
275
277
};
276
278
277
279
// / The state per contract. Filled gradually during compilation.
You can’t perform that action at this time.
0 commit comments