github.com/phillinzzz/newBsc@v1.1.6/tests/gen_vmexec.go (about) 1 // Code generated by github.com/fjl/gencodec. DO NOT EDIT. 2 3 package tests 4 5 import ( 6 "encoding/json" 7 "errors" 8 "math/big" 9 10 "github.com/phillinzzz/newBsc/common" 11 "github.com/phillinzzz/newBsc/common/hexutil" 12 "github.com/phillinzzz/newBsc/common/math" 13 ) 14 15 var _ = (*vmExecMarshaling)(nil) 16 17 // MarshalJSON marshals as JSON. 18 func (v vmExec) MarshalJSON() ([]byte, error) { 19 type vmExec struct { 20 Address common.UnprefixedAddress `json:"address" gencodec:"required"` 21 Caller common.UnprefixedAddress `json:"caller" gencodec:"required"` 22 Origin common.UnprefixedAddress `json:"origin" gencodec:"required"` 23 Code hexutil.Bytes `json:"code" gencodec:"required"` 24 Data hexutil.Bytes `json:"data" gencodec:"required"` 25 Value *math.HexOrDecimal256 `json:"value" gencodec:"required"` 26 GasLimit math.HexOrDecimal64 `json:"gas" gencodec:"required"` 27 GasPrice *math.HexOrDecimal256 `json:"gasPrice" gencodec:"required"` 28 } 29 var enc vmExec 30 enc.Address = common.UnprefixedAddress(v.Address) 31 enc.Caller = common.UnprefixedAddress(v.Caller) 32 enc.Origin = common.UnprefixedAddress(v.Origin) 33 enc.Code = v.Code 34 enc.Data = v.Data 35 enc.Value = (*math.HexOrDecimal256)(v.Value) 36 enc.GasLimit = math.HexOrDecimal64(v.GasLimit) 37 enc.GasPrice = (*math.HexOrDecimal256)(v.GasPrice) 38 return json.Marshal(&enc) 39 } 40 41 // UnmarshalJSON unmarshals from JSON. 42 func (v *vmExec) UnmarshalJSON(input []byte) error { 43 type vmExec struct { 44 Address *common.UnprefixedAddress `json:"address" gencodec:"required"` 45 Caller *common.UnprefixedAddress `json:"caller" gencodec:"required"` 46 Origin *common.UnprefixedAddress `json:"origin" gencodec:"required"` 47 Code *hexutil.Bytes `json:"code" gencodec:"required"` 48 Data *hexutil.Bytes `json:"data" gencodec:"required"` 49 Value *math.HexOrDecimal256 `json:"value" gencodec:"required"` 50 GasLimit *math.HexOrDecimal64 `json:"gas" gencodec:"required"` 51 GasPrice *math.HexOrDecimal256 `json:"gasPrice" gencodec:"required"` 52 } 53 var dec vmExec 54 if err := json.Unmarshal(input, &dec); err != nil { 55 return err 56 } 57 if dec.Address == nil { 58 return errors.New("missing required field 'address' for vmExec") 59 } 60 v.Address = common.Address(*dec.Address) 61 if dec.Caller == nil { 62 return errors.New("missing required field 'caller' for vmExec") 63 } 64 v.Caller = common.Address(*dec.Caller) 65 if dec.Origin == nil { 66 return errors.New("missing required field 'origin' for vmExec") 67 } 68 v.Origin = common.Address(*dec.Origin) 69 if dec.Code == nil { 70 return errors.New("missing required field 'code' for vmExec") 71 } 72 v.Code = *dec.Code 73 if dec.Data == nil { 74 return errors.New("missing required field 'data' for vmExec") 75 } 76 v.Data = *dec.Data 77 if dec.Value == nil { 78 return errors.New("missing required field 'value' for vmExec") 79 } 80 v.Value = (*big.Int)(dec.Value) 81 if dec.GasLimit == nil { 82 return errors.New("missing required field 'gas' for vmExec") 83 } 84 v.GasLimit = uint64(*dec.GasLimit) 85 if dec.GasPrice == nil { 86 return errors.New("missing required field 'gasPrice' for vmExec") 87 } 88 v.GasPrice = (*big.Int)(dec.GasPrice) 89 return nil 90 }