github.com/klaytn/klaytn@v1.12.1/tests/gen_tttransaction.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/klaytn/klaytn/common" 11 "github.com/klaytn/klaytn/common/hexutil" 12 "github.com/klaytn/klaytn/common/math" 13 ) 14 15 var _ = (*ttTransactionMarshaling)(nil) 16 17 // MarshalJSON marshals as JSON. 18 func (t ttTransaction) MarshalJSON() ([]byte, error) { 19 type ttTransaction struct { 20 Data hexutil.Bytes `gencodec:"required"` 21 GasLimit math.HexOrDecimal64 `gencodec:"required"` 22 GasPrice *math.HexOrDecimal256 `gencodec:"required"` 23 Nonce math.HexOrDecimal64 `gencodec:"required"` 24 Value *math.HexOrDecimal256 `gencodec:"required"` 25 R *math.HexOrDecimal256 `gencodec:"required"` 26 S *math.HexOrDecimal256 `gencodec:"required"` 27 V *math.HexOrDecimal256 `gencodec:"required"` 28 To common.Address `gencodec:"required"` 29 } 30 var enc ttTransaction 31 enc.Data = t.Data 32 enc.GasLimit = math.HexOrDecimal64(t.GasLimit) 33 enc.GasPrice = (*math.HexOrDecimal256)(t.GasPrice) 34 enc.Nonce = math.HexOrDecimal64(t.Nonce) 35 enc.Value = (*math.HexOrDecimal256)(t.Value) 36 enc.R = (*math.HexOrDecimal256)(t.R) 37 enc.S = (*math.HexOrDecimal256)(t.S) 38 enc.V = (*math.HexOrDecimal256)(t.V) 39 enc.To = t.To 40 return json.Marshal(&enc) 41 } 42 43 // UnmarshalJSON unmarshals from JSON. 44 func (t *ttTransaction) UnmarshalJSON(input []byte) error { 45 type ttTransaction struct { 46 Data *hexutil.Bytes `gencodec:"required"` 47 GasLimit *math.HexOrDecimal64 `gencodec:"required"` 48 GasPrice *math.HexOrDecimal256 `gencodec:"required"` 49 Nonce *math.HexOrDecimal64 `gencodec:"required"` 50 Value *math.HexOrDecimal256 `gencodec:"required"` 51 R *math.HexOrDecimal256 `gencodec:"required"` 52 S *math.HexOrDecimal256 `gencodec:"required"` 53 V *math.HexOrDecimal256 `gencodec:"required"` 54 To *common.Address `gencodec:"required"` 55 } 56 var dec ttTransaction 57 if err := json.Unmarshal(input, &dec); err != nil { 58 return err 59 } 60 if dec.Data == nil { 61 return errors.New("missing required field 'data' for ttTransaction") 62 } 63 t.Data = *dec.Data 64 if dec.GasLimit == nil { 65 return errors.New("missing required field 'gasLimit' for ttTransaction") 66 } 67 t.GasLimit = uint64(*dec.GasLimit) 68 if dec.GasPrice == nil { 69 return errors.New("missing required field 'gasPrice' for ttTransaction") 70 } 71 t.GasPrice = (*big.Int)(dec.GasPrice) 72 if dec.Nonce == nil { 73 return errors.New("missing required field 'nonce' for ttTransaction") 74 } 75 t.Nonce = uint64(*dec.Nonce) 76 if dec.Value == nil { 77 return errors.New("missing required field 'value' for ttTransaction") 78 } 79 t.Value = (*big.Int)(dec.Value) 80 if dec.R == nil { 81 return errors.New("missing required field 'r' for ttTransaction") 82 } 83 t.R = (*big.Int)(dec.R) 84 if dec.S == nil { 85 return errors.New("missing required field 's' for ttTransaction") 86 } 87 t.S = (*big.Int)(dec.S) 88 if dec.V == nil { 89 return errors.New("missing required field 'v' for ttTransaction") 90 } 91 t.V = (*big.Int)(dec.V) 92 if dec.To == nil { 93 return errors.New("missing required field 'to' for ttTransaction") 94 } 95 t.To = *dec.To 96 return nil 97 }