github.com/theQRL/go-zond@v0.2.1/cmd/zvm/internal/t8ntool/gen_stenv.go (about) 1 // Code generated by github.com/fjl/gencodec. DO NOT EDIT. 2 3 package t8ntool 4 5 import ( 6 "encoding/json" 7 "errors" 8 "math/big" 9 10 "github.com/theQRL/go-zond/common" 11 "github.com/theQRL/go-zond/common/math" 12 "github.com/theQRL/go-zond/core/types" 13 ) 14 15 var _ = (*stEnvMarshaling)(nil) 16 17 // MarshalJSON marshals as JSON. 18 func (s stEnv) MarshalJSON() ([]byte, error) { 19 type stEnv struct { 20 Coinbase common.Address `json:"currentCoinbase" gencodec:"required"` 21 Random *math.HexOrDecimal256 `json:"currentRandom"` 22 ParentBaseFee *math.HexOrDecimal256 `json:"parentBaseFee,omitempty"` 23 ParentGasUsed math.HexOrDecimal64 `json:"parentGasUsed,omitempty"` 24 ParentGasLimit math.HexOrDecimal64 `json:"parentGasLimit,omitempty"` 25 GasLimit math.HexOrDecimal64 `json:"currentGasLimit" gencodec:"required"` 26 Number math.HexOrDecimal64 `json:"currentNumber" gencodec:"required"` 27 Timestamp math.HexOrDecimal64 `json:"currentTimestamp" gencodec:"required"` 28 ParentTimestamp math.HexOrDecimal64 `json:"parentTimestamp,omitempty"` 29 BlockHashes map[math.HexOrDecimal64]common.Hash `json:"blockHashes,omitempty"` 30 Withdrawals []*types.Withdrawal `json:"withdrawals,omitempty"` 31 BaseFee *math.HexOrDecimal256 `json:"currentBaseFee,omitempty"` 32 } 33 var enc stEnv 34 enc.Coinbase = s.Coinbase 35 enc.Random = (*math.HexOrDecimal256)(s.Random) 36 enc.ParentBaseFee = (*math.HexOrDecimal256)(s.ParentBaseFee) 37 enc.ParentGasUsed = math.HexOrDecimal64(s.ParentGasUsed) 38 enc.ParentGasLimit = math.HexOrDecimal64(s.ParentGasLimit) 39 enc.GasLimit = math.HexOrDecimal64(s.GasLimit) 40 enc.Number = math.HexOrDecimal64(s.Number) 41 enc.Timestamp = math.HexOrDecimal64(s.Timestamp) 42 enc.ParentTimestamp = math.HexOrDecimal64(s.ParentTimestamp) 43 enc.BlockHashes = s.BlockHashes 44 enc.Withdrawals = s.Withdrawals 45 enc.BaseFee = (*math.HexOrDecimal256)(s.BaseFee) 46 return json.Marshal(&enc) 47 } 48 49 // UnmarshalJSON unmarshals from JSON. 50 func (s *stEnv) UnmarshalJSON(input []byte) error { 51 type stEnv struct { 52 Coinbase *common.Address `json:"currentCoinbase" gencodec:"required"` 53 Random *math.HexOrDecimal256 `json:"currentRandom"` 54 ParentBaseFee *math.HexOrDecimal256 `json:"parentBaseFee,omitempty"` 55 ParentGasUsed *math.HexOrDecimal64 `json:"parentGasUsed,omitempty"` 56 ParentGasLimit *math.HexOrDecimal64 `json:"parentGasLimit,omitempty"` 57 GasLimit *math.HexOrDecimal64 `json:"currentGasLimit" gencodec:"required"` 58 Number *math.HexOrDecimal64 `json:"currentNumber" gencodec:"required"` 59 Timestamp *math.HexOrDecimal64 `json:"currentTimestamp" gencodec:"required"` 60 ParentTimestamp *math.HexOrDecimal64 `json:"parentTimestamp,omitempty"` 61 BlockHashes map[math.HexOrDecimal64]common.Hash `json:"blockHashes,omitempty"` 62 Withdrawals []*types.Withdrawal `json:"withdrawals,omitempty"` 63 BaseFee *math.HexOrDecimal256 `json:"currentBaseFee,omitempty"` 64 } 65 var dec stEnv 66 if err := json.Unmarshal(input, &dec); err != nil { 67 return err 68 } 69 if dec.Coinbase == nil { 70 return errors.New("missing required field 'currentCoinbase' for stEnv") 71 } 72 s.Coinbase = common.Address(*dec.Coinbase) 73 if dec.Random != nil { 74 s.Random = (*big.Int)(dec.Random) 75 } 76 if dec.ParentBaseFee != nil { 77 s.ParentBaseFee = (*big.Int)(dec.ParentBaseFee) 78 } 79 if dec.ParentGasUsed != nil { 80 s.ParentGasUsed = uint64(*dec.ParentGasUsed) 81 } 82 if dec.ParentGasLimit != nil { 83 s.ParentGasLimit = uint64(*dec.ParentGasLimit) 84 } 85 if dec.GasLimit == nil { 86 return errors.New("missing required field 'currentGasLimit' for stEnv") 87 } 88 s.GasLimit = uint64(*dec.GasLimit) 89 if dec.Number == nil { 90 return errors.New("missing required field 'currentNumber' for stEnv") 91 } 92 s.Number = uint64(*dec.Number) 93 if dec.Timestamp == nil { 94 return errors.New("missing required field 'currentTimestamp' for stEnv") 95 } 96 s.Timestamp = uint64(*dec.Timestamp) 97 if dec.ParentTimestamp != nil { 98 s.ParentTimestamp = uint64(*dec.ParentTimestamp) 99 } 100 if dec.BlockHashes != nil { 101 s.BlockHashes = dec.BlockHashes 102 } 103 if dec.Withdrawals != nil { 104 s.Withdrawals = dec.Withdrawals 105 } 106 if dec.BaseFee != nil { 107 s.BaseFee = (*big.Int)(dec.BaseFee) 108 } 109 return nil 110 }