github.com/amazechain/amc@v0.1.3/internal/tracers/native/gen_flatcallresult_json.go (about) 1 // Code generated by github.com/fjl/gencodec. DO NOT EDIT. 2 3 package native 4 5 import ( 6 "encoding/json" 7 8 "github.com/amazechain/amc/common/hexutil" 9 "github.com/amazechain/amc/common/types" 10 ) 11 12 var _ = (*flatCallResultMarshaling)(nil) 13 14 // MarshalJSON marshals as JSON. 15 func (f flatCallResult) MarshalJSON() ([]byte, error) { 16 type flatCallResult struct { 17 Address *types.Address `json:"address,omitempty"` 18 Code *hexutil.Bytes `json:"code,omitempty"` 19 GasUsed *hexutil.Uint64 `json:"gasUsed,omitempty"` 20 Output *hexutil.Bytes `json:"output,omitempty"` 21 } 22 var enc flatCallResult 23 enc.Address = f.Address 24 enc.Code = (*hexutil.Bytes)(f.Code) 25 enc.GasUsed = (*hexutil.Uint64)(f.GasUsed) 26 enc.Output = (*hexutil.Bytes)(f.Output) 27 return json.Marshal(&enc) 28 } 29 30 // UnmarshalJSON unmarshals from JSON. 31 func (f *flatCallResult) UnmarshalJSON(input []byte) error { 32 type flatCallResult struct { 33 Address *types.Address `json:"address,omitempty"` 34 Code *hexutil.Bytes `json:"code,omitempty"` 35 GasUsed *hexutil.Uint64 `json:"gasUsed,omitempty"` 36 Output *hexutil.Bytes `json:"output,omitempty"` 37 } 38 var dec flatCallResult 39 if err := json.Unmarshal(input, &dec); err != nil { 40 return err 41 } 42 if dec.Address != nil { 43 f.Address = dec.Address 44 } 45 if dec.Code != nil { 46 f.Code = (*[]byte)(dec.Code) 47 } 48 if dec.GasUsed != nil { 49 f.GasUsed = (*uint64)(dec.GasUsed) 50 } 51 if dec.Output != nil { 52 f.Output = (*[]byte)(dec.Output) 53 } 54 return nil 55 }