@@ -31,14 +31,15 @@ import (
3131
3232var versionRegexp = regexp .MustCompile (`([0-9]+)\.([0-9]+)\.([0-9]+)` )
3333
34- // Contract contains information about a compiled contract, alongside its code.
34+ // Contract contains information about a compiled contract, alongside its code and runtime code .
3535type Contract struct {
36- Code string `json:"code"`
37- Info ContractInfo `json:"info"`
36+ Code string `json:"code"`
37+ RuntimeCode string `json:"runtime-code"`
38+ Info ContractInfo `json:"info"`
3839}
3940
4041// ContractInfo contains information about a compiled contract, including access
41- // to the ABI definition, user and developer docs, and metadata.
42+ // to the ABI definition, source mapping, user and developer docs, and metadata.
4243//
4344// Depending on the source, language version, compiler version, and compiler
4445// options will provide information about how the contract was compiled.
@@ -48,6 +49,8 @@ type ContractInfo struct {
4849 LanguageVersion string `json:"languageVersion"`
4950 CompilerVersion string `json:"compilerVersion"`
5051 CompilerOptions string `json:"compilerOptions"`
52+ SrcMap string `json:"srcMap"`
53+ SrcMapRuntime string `json:"srcMapRuntime"`
5154 AbiDefinition interface {} `json:"abiDefinition"`
5255 UserDoc interface {} `json:"userDoc"`
5356 DeveloperDoc interface {} `json:"developerDoc"`
@@ -63,14 +66,16 @@ type Solidity struct {
6366// --combined-output format
6467type solcOutput struct {
6568 Contracts map [string ]struct {
66- Bin , Abi , Devdoc , Userdoc , Metadata string
69+ BinRuntime string `json:"bin-runtime"`
70+ SrcMapRuntime string `json:"srcmap-runtime"`
71+ Bin , SrcMap , Abi , Devdoc , Userdoc , Metadata string
6772 }
6873 Version string
6974}
7075
7176func (s * Solidity ) makeArgs () []string {
7277 p := []string {
73- "--combined-json" , "bin,abi,userdoc,devdoc" ,
78+ "--combined-json" , "bin,bin-runtime,srcmap,srcmap-runtime, abi,userdoc,devdoc" ,
7479 "--optimize" , // code optimizer switched on
7580 }
7681 if s .Major > 0 || s .Minor > 4 || s .Patch > 6 {
@@ -157,7 +162,7 @@ func (s *Solidity) run(cmd *exec.Cmd, source string) (map[string]*Contract, erro
157162// provided source, language and compiler version, and compiler options are all
158163// passed through into the Contract structs.
159164//
160- // The solc output is expected to contain ABI, user docs, and dev docs.
165+ // The solc output is expected to contain ABI, source mapping, user docs, and dev docs.
161166//
162167// Returns an error if the JSON is malformed or missing data, or if the JSON
163168// embedded within the JSON is malformed.
@@ -184,13 +189,16 @@ func ParseCombinedJSON(combinedJSON []byte, source string, languageVersion strin
184189 return nil , fmt .Errorf ("solc: error reading dev doc: %v" , err )
185190 }
186191 contracts [name ] = & Contract {
187- Code : "0x" + info .Bin ,
192+ Code : "0x" + info .Bin ,
193+ RuntimeCode : "0x" + info .BinRuntime ,
188194 Info : ContractInfo {
189195 Source : source ,
190196 Language : "Solidity" ,
191197 LanguageVersion : languageVersion ,
192198 CompilerVersion : compilerVersion ,
193199 CompilerOptions : compilerOptions ,
200+ SrcMap : info .SrcMap ,
201+ SrcMapRuntime : info .SrcMapRuntime ,
194202 AbiDefinition : abi ,
195203 UserDoc : userdoc ,
196204 DeveloperDoc : devdoc ,
0 commit comments