github.com/aquanetwork/aquachain@v1.7.8/opt/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 "gitlab.com/aquachain/aquachain/common" 11 "gitlab.com/aquachain/aquachain/common/hexutil" 12 "gitlab.com/aquachain/aquachain/common/math" 13 ) 14 15 var _ = (*vmExecMarshaling)(nil) 16 17 func (v vmExec) MarshalJSON() ([]byte, error) { 18 type vmExec struct { 19 Address common.UnprefixedAddress `json:"address" gencodec:"required"` 20 Caller common.UnprefixedAddress `json:"caller" gencodec:"required"` 21 Origin common.UnprefixedAddress `json:"origin" gencodec:"required"` 22 Code hexutil.Bytes `json:"code" gencodec:"required"` 23 Data hexutil.Bytes `json:"data" gencodec:"required"` 24 Value *math.HexOrDecimal256 `json:"value" gencodec:"required"` 25 GasLimit math.HexOrDecimal64 `json:"gas" gencodec:"required"` 26 GasPrice *math.HexOrDecimal256 `json:"gasPrice" gencodec:"required"` 27 } 28 var enc vmExec 29 enc.Address = common.UnprefixedAddress(v.Address) 30 enc.Caller = common.UnprefixedAddress(v.Caller) 31 enc.Origin = common.UnprefixedAddress(v.Origin) 32 enc.Code = v.Code 33 enc.Data = v.Data 34 enc.Value = (*math.HexOrDecimal256)(v.Value) 35 enc.GasLimit = math.HexOrDecimal64(v.GasLimit) 36 enc.GasPrice = (*math.HexOrDecimal256)(v.GasPrice) 37 return json.Marshal(&enc) 38 } 39 40 func (v *vmExec) UnmarshalJSON(input []byte) error { 41 type vmExec struct { 42 Address *common.UnprefixedAddress `json:"address" gencodec:"required"` 43 Caller *common.UnprefixedAddress `json:"caller" gencodec:"required"` 44 Origin *common.UnprefixedAddress `json:"origin" gencodec:"required"` 45 Code *hexutil.Bytes `json:"code" gencodec:"required"` 46 Data *hexutil.Bytes `json:"data" gencodec:"required"` 47 Value *math.HexOrDecimal256 `json:"value" gencodec:"required"` 48 GasLimit *math.HexOrDecimal64 `json:"gas" gencodec:"required"` 49 GasPrice *math.HexOrDecimal256 `json:"gasPrice" gencodec:"required"` 50 } 51 var dec vmExec 52 if err := json.Unmarshal(input, &dec); err != nil { 53 return err 54 } 55 if dec.Address == nil { 56 return errors.New("missing required field 'address' for vmExec") 57 } 58 v.Address = common.Address(*dec.Address) 59 if dec.Caller == nil { 60 return errors.New("missing required field 'caller' for vmExec") 61 } 62 v.Caller = common.Address(*dec.Caller) 63 if dec.Origin == nil { 64 return errors.New("missing required field 'origin' for vmExec") 65 } 66 v.Origin = common.Address(*dec.Origin) 67 if dec.Code == nil { 68 return errors.New("missing required field 'code' for vmExec") 69 } 70 v.Code = *dec.Code 71 if dec.Data == nil { 72 return errors.New("missing required field 'data' for vmExec") 73 } 74 v.Data = *dec.Data 75 if dec.Value == nil { 76 return errors.New("missing required field 'value' for vmExec") 77 } 78 v.Value = (*big.Int)(dec.Value) 79 if dec.GasLimit == nil { 80 return errors.New("missing required field 'gas' for vmExec") 81 } 82 v.GasLimit = uint64(*dec.GasLimit) 83 if dec.GasPrice == nil { 84 return errors.New("missing required field 'gasPrice' for vmExec") 85 } 86 v.GasPrice = (*big.Int)(dec.GasPrice) 87 return nil 88 }