github.1485827954.workers.dev/ethereum/go-ethereum@v1.14.3/eth/tracers/logger/gen_callframe.go (about) 1 // Code generated by github.com/fjl/gencodec. DO NOT EDIT. 2 3 package logger 4 5 import ( 6 "encoding/json" 7 "math/big" 8 9 "github.com/ethereum/go-ethereum/common" 10 "github.com/ethereum/go-ethereum/common/hexutil" 11 "github.com/ethereum/go-ethereum/common/math" 12 ) 13 14 var _ = (*callFrameMarshaling)(nil) 15 16 // MarshalJSON marshals as JSON. 17 func (c callFrame) MarshalJSON() ([]byte, error) { 18 type callFrame struct { 19 From common.Address `json:"from"` 20 To common.Address `json:"to"` 21 Input hexutil.Bytes `json:"input,omitempty"` 22 Gas math.HexOrDecimal64 `json:"gas"` 23 Value *hexutil.Big `json:"value"` 24 Type string `json:"type"` 25 } 26 var enc callFrame 27 enc.From = c.From 28 enc.To = c.To 29 enc.Input = c.Input 30 enc.Gas = math.HexOrDecimal64(c.Gas) 31 enc.Value = (*hexutil.Big)(c.Value) 32 enc.Type = c.Type() 33 return json.Marshal(&enc) 34 } 35 36 // UnmarshalJSON unmarshals from JSON. 37 func (c *callFrame) UnmarshalJSON(input []byte) error { 38 type callFrame struct { 39 From *common.Address `json:"from"` 40 To *common.Address `json:"to"` 41 Input *hexutil.Bytes `json:"input,omitempty"` 42 Gas *math.HexOrDecimal64 `json:"gas"` 43 Value *hexutil.Big `json:"value"` 44 } 45 var dec callFrame 46 if err := json.Unmarshal(input, &dec); err != nil { 47 return err 48 } 49 if dec.From != nil { 50 c.From = *dec.From 51 } 52 if dec.To != nil { 53 c.To = *dec.To 54 } 55 if dec.Input != nil { 56 c.Input = *dec.Input 57 } 58 if dec.Gas != nil { 59 c.Gas = uint64(*dec.Gas) 60 } 61 if dec.Value != nil { 62 c.Value = (*big.Int)(dec.Value) 63 } 64 return nil 65 }