gitee.com/liu-zhao234568/cntest@v1.0.0/cmd/evm/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 "gitee.com/liu-zhao234568/cntest/common" 11 "gitee.com/liu-zhao234568/cntest/common/math" 12 ) 13 14 var _ = (*stEnvMarshaling)(nil) 15 16 // MarshalJSON marshals as JSON. 17 func (s stEnv) MarshalJSON() ([]byte, error) { 18 type stEnv struct { 19 Coinbase common.UnprefixedAddress `json:"currentCoinbase" gencodec:"required"` 20 Difficulty *math.HexOrDecimal256 `json:"currentDifficulty" gencodec:"required"` 21 GasLimit math.HexOrDecimal64 `json:"currentGasLimit" gencodec:"required"` 22 Number math.HexOrDecimal64 `json:"currentNumber" gencodec:"required"` 23 Timestamp math.HexOrDecimal64 `json:"currentTimestamp" gencodec:"required"` 24 BlockHashes map[math.HexOrDecimal64]common.Hash `json:"blockHashes,omitempty"` 25 Ommers []ommer `json:"ommers,omitempty"` 26 BaseFee *math.HexOrDecimal256 `json:"currentBaseFee,omitempty"` 27 } 28 var enc stEnv 29 enc.Coinbase = common.UnprefixedAddress(s.Coinbase) 30 enc.Difficulty = (*math.HexOrDecimal256)(s.Difficulty) 31 enc.GasLimit = math.HexOrDecimal64(s.GasLimit) 32 enc.Number = math.HexOrDecimal64(s.Number) 33 enc.Timestamp = math.HexOrDecimal64(s.Timestamp) 34 enc.BlockHashes = s.BlockHashes 35 enc.Ommers = s.Ommers 36 enc.BaseFee = (*math.HexOrDecimal256)(s.BaseFee) 37 return json.Marshal(&enc) 38 } 39 40 // UnmarshalJSON unmarshals from JSON. 41 func (s *stEnv) UnmarshalJSON(input []byte) error { 42 type stEnv struct { 43 Coinbase *common.UnprefixedAddress `json:"currentCoinbase" gencodec:"required"` 44 Difficulty *math.HexOrDecimal256 `json:"currentDifficulty" gencodec:"required"` 45 GasLimit *math.HexOrDecimal64 `json:"currentGasLimit" gencodec:"required"` 46 Number *math.HexOrDecimal64 `json:"currentNumber" gencodec:"required"` 47 Timestamp *math.HexOrDecimal64 `json:"currentTimestamp" gencodec:"required"` 48 BlockHashes map[math.HexOrDecimal64]common.Hash `json:"blockHashes,omitempty"` 49 Ommers []ommer `json:"ommers,omitempty"` 50 BaseFee *math.HexOrDecimal256 `json:"currentBaseFee,omitempty"` 51 } 52 var dec stEnv 53 if err := json.Unmarshal(input, &dec); err != nil { 54 return err 55 } 56 if dec.Coinbase == nil { 57 return errors.New("missing required field 'currentCoinbase' for stEnv") 58 } 59 s.Coinbase = common.Address(*dec.Coinbase) 60 if dec.Difficulty == nil { 61 return errors.New("missing required field 'currentDifficulty' for stEnv") 62 } 63 s.Difficulty = (*big.Int)(dec.Difficulty) 64 if dec.GasLimit == nil { 65 return errors.New("missing required field 'currentGasLimit' for stEnv") 66 } 67 s.GasLimit = uint64(*dec.GasLimit) 68 if dec.Number == nil { 69 return errors.New("missing required field 'currentNumber' for stEnv") 70 } 71 s.Number = uint64(*dec.Number) 72 if dec.Timestamp == nil { 73 return errors.New("missing required field 'currentTimestamp' for stEnv") 74 } 75 s.Timestamp = uint64(*dec.Timestamp) 76 if dec.BlockHashes != nil { 77 s.BlockHashes = dec.BlockHashes 78 } 79 if dec.Ommers != nil { 80 s.Ommers = dec.Ommers 81 } 82 if dec.BaseFee != nil { 83 s.BaseFee = (*big.Int)(dec.BaseFee) 84 } 85 return nil 86 }