github.com/theQRL/go-zond@v0.2.1/tests/gen_sttransaction.go (about) 1 // Code generated by github.com/fjl/gencodec. DO NOT EDIT. 2 3 package tests 4 5 import ( 6 "encoding/json" 7 "math/big" 8 9 "github.com/theQRL/go-zond/common" 10 "github.com/theQRL/go-zond/common/math" 11 "github.com/theQRL/go-zond/core/types" 12 ) 13 14 var _ = (*stTransactionMarshaling)(nil) 15 16 // MarshalJSON marshals as JSON. 17 func (s stTransaction) MarshalJSON() ([]byte, error) { 18 type stTransaction struct { 19 GasPrice *math.HexOrDecimal256 `json:"gasPrice"` 20 MaxFeePerGas *math.HexOrDecimal256 `json:"maxFeePerGas"` 21 MaxPriorityFeePerGas *math.HexOrDecimal256 `json:"maxPriorityFeePerGas"` 22 Nonce math.HexOrDecimal64 `json:"nonce"` 23 To string `json:"to"` 24 Data []string `json:"data"` 25 AccessLists []*types.AccessList `json:"accessLists,omitempty"` 26 GasLimit []math.HexOrDecimal64 `json:"gasLimit"` 27 Value []string `json:"value"` 28 Seed string `json:"seed"` 29 Sender *common.Address `json:"sender"` 30 } 31 var enc stTransaction 32 enc.GasPrice = (*math.HexOrDecimal256)(s.GasPrice) 33 enc.MaxFeePerGas = (*math.HexOrDecimal256)(s.MaxFeePerGas) 34 enc.MaxPriorityFeePerGas = (*math.HexOrDecimal256)(s.MaxPriorityFeePerGas) 35 enc.Nonce = math.HexOrDecimal64(s.Nonce) 36 enc.To = s.To 37 enc.Data = s.Data 38 enc.AccessLists = s.AccessLists 39 if s.GasLimit != nil { 40 enc.GasLimit = make([]math.HexOrDecimal64, len(s.GasLimit)) 41 for k, v := range s.GasLimit { 42 enc.GasLimit[k] = math.HexOrDecimal64(v) 43 } 44 } 45 enc.Value = s.Value 46 enc.Seed = s.Seed 47 enc.Sender = s.Sender 48 return json.Marshal(&enc) 49 } 50 51 // UnmarshalJSON unmarshals from JSON. 52 func (s *stTransaction) UnmarshalJSON(input []byte) error { 53 type stTransaction struct { 54 GasPrice *math.HexOrDecimal256 `json:"gasPrice"` 55 MaxFeePerGas *math.HexOrDecimal256 `json:"maxFeePerGas"` 56 MaxPriorityFeePerGas *math.HexOrDecimal256 `json:"maxPriorityFeePerGas"` 57 Nonce *math.HexOrDecimal64 `json:"nonce"` 58 To *string `json:"to"` 59 Data []string `json:"data"` 60 AccessLists []*types.AccessList `json:"accessLists,omitempty"` 61 GasLimit []math.HexOrDecimal64 `json:"gasLimit"` 62 Value []string `json:"value"` 63 Seed *string `json:"seed"` 64 Sender *common.Address `json:"sender"` 65 } 66 var dec stTransaction 67 if err := json.Unmarshal(input, &dec); err != nil { 68 return err 69 } 70 if dec.GasPrice != nil { 71 s.GasPrice = (*big.Int)(dec.GasPrice) 72 } 73 if dec.MaxFeePerGas != nil { 74 s.MaxFeePerGas = (*big.Int)(dec.MaxFeePerGas) 75 } 76 if dec.MaxPriorityFeePerGas != nil { 77 s.MaxPriorityFeePerGas = (*big.Int)(dec.MaxPriorityFeePerGas) 78 } 79 if dec.Nonce != nil { 80 s.Nonce = uint64(*dec.Nonce) 81 } 82 if dec.To != nil { 83 s.To = *dec.To 84 } 85 if dec.Data != nil { 86 s.Data = dec.Data 87 } 88 if dec.AccessLists != nil { 89 s.AccessLists = dec.AccessLists 90 } 91 if dec.GasLimit != nil { 92 s.GasLimit = make([]uint64, len(dec.GasLimit)) 93 for k, v := range dec.GasLimit { 94 s.GasLimit[k] = uint64(v) 95 } 96 } 97 if dec.Value != nil { 98 s.Value = dec.Value 99 } 100 if dec.Seed != nil { 101 s.Seed = *dec.Seed 102 } 103 if dec.Sender != nil { 104 s.Sender = dec.Sender 105 } 106 return nil 107 }