github.com/jimmyx0x/go-ethereum@v1.10.28/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  	"github.com/ethereum/go-ethereum/common"
    11  	"github.com/ethereum/go-ethereum/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"`
    21  		Random           *math.HexOrDecimal256               `json:"currentRandom"`
    22  		ParentDifficulty *math.HexOrDecimal256               `json:"parentDifficulty"`
    23  		ParentBaseFee    *math.HexOrDecimal256               `json:"parentBaseFee,omitempty"`
    24  		ParentGasUsed    math.HexOrDecimal64                 `json:"parentGasUsed,omitempty"`
    25  		ParentGasLimit   math.HexOrDecimal64                 `json:"parentGasLimit,omitempty"`
    26  		GasLimit         math.HexOrDecimal64                 `json:"currentGasLimit"   gencodec:"required"`
    27  		Number           math.HexOrDecimal64                 `json:"currentNumber"     gencodec:"required"`
    28  		Timestamp        math.HexOrDecimal64                 `json:"currentTimestamp"  gencodec:"required"`
    29  		ParentTimestamp  math.HexOrDecimal64                 `json:"parentTimestamp,omitempty"`
    30  		BlockHashes      map[math.HexOrDecimal64]common.Hash `json:"blockHashes,omitempty"`
    31  		Ommers           []ommer                             `json:"ommers,omitempty"`
    32  		BaseFee          *math.HexOrDecimal256               `json:"currentBaseFee,omitempty"`
    33  		ParentUncleHash  common.Hash                         `json:"parentUncleHash"`
    34  	}
    35  	var enc stEnv
    36  	enc.Coinbase = common.UnprefixedAddress(s.Coinbase)
    37  	enc.Difficulty = (*math.HexOrDecimal256)(s.Difficulty)
    38  	enc.Random = (*math.HexOrDecimal256)(s.Random)
    39  	enc.ParentDifficulty = (*math.HexOrDecimal256)(s.ParentDifficulty)
    40  	enc.ParentBaseFee = (*math.HexOrDecimal256)(s.ParentBaseFee)
    41  	enc.ParentGasUsed = math.HexOrDecimal64(s.ParentGasUsed)
    42  	enc.ParentGasLimit = math.HexOrDecimal64(s.ParentGasLimit)
    43  	enc.GasLimit = math.HexOrDecimal64(s.GasLimit)
    44  	enc.Number = math.HexOrDecimal64(s.Number)
    45  	enc.Timestamp = math.HexOrDecimal64(s.Timestamp)
    46  	enc.ParentTimestamp = math.HexOrDecimal64(s.ParentTimestamp)
    47  	enc.BlockHashes = s.BlockHashes
    48  	enc.Ommers = s.Ommers
    49  	enc.BaseFee = (*math.HexOrDecimal256)(s.BaseFee)
    50  	enc.ParentUncleHash = s.ParentUncleHash
    51  	return json.Marshal(&enc)
    52  }
    53  
    54  // UnmarshalJSON unmarshals from JSON.
    55  func (s *stEnv) UnmarshalJSON(input []byte) error {
    56  	type stEnv struct {
    57  		Coinbase         *common.UnprefixedAddress           `json:"currentCoinbase"   gencodec:"required"`
    58  		Difficulty       *math.HexOrDecimal256               `json:"currentDifficulty"`
    59  		Random           *math.HexOrDecimal256               `json:"currentRandom"`
    60  		ParentDifficulty *math.HexOrDecimal256               `json:"parentDifficulty"`
    61  		ParentBaseFee    *math.HexOrDecimal256               `json:"parentBaseFee,omitempty"`
    62  		ParentGasUsed    *math.HexOrDecimal64                `json:"parentGasUsed,omitempty"`
    63  		ParentGasLimit   *math.HexOrDecimal64                `json:"parentGasLimit,omitempty"`
    64  		GasLimit         *math.HexOrDecimal64                `json:"currentGasLimit"   gencodec:"required"`
    65  		Number           *math.HexOrDecimal64                `json:"currentNumber"     gencodec:"required"`
    66  		Timestamp        *math.HexOrDecimal64                `json:"currentTimestamp"  gencodec:"required"`
    67  		ParentTimestamp  *math.HexOrDecimal64                `json:"parentTimestamp,omitempty"`
    68  		BlockHashes      map[math.HexOrDecimal64]common.Hash `json:"blockHashes,omitempty"`
    69  		Ommers           []ommer                             `json:"ommers,omitempty"`
    70  		BaseFee          *math.HexOrDecimal256               `json:"currentBaseFee,omitempty"`
    71  		ParentUncleHash  *common.Hash                        `json:"parentUncleHash"`
    72  	}
    73  	var dec stEnv
    74  	if err := json.Unmarshal(input, &dec); err != nil {
    75  		return err
    76  	}
    77  	if dec.Coinbase == nil {
    78  		return errors.New("missing required field 'currentCoinbase' for stEnv")
    79  	}
    80  	s.Coinbase = common.Address(*dec.Coinbase)
    81  	if dec.Difficulty != nil {
    82  		s.Difficulty = (*big.Int)(dec.Difficulty)
    83  	}
    84  	if dec.Random != nil {
    85  		s.Random = (*big.Int)(dec.Random)
    86  	}
    87  	if dec.ParentDifficulty != nil {
    88  		s.ParentDifficulty = (*big.Int)(dec.ParentDifficulty)
    89  	}
    90  	if dec.ParentBaseFee != nil {
    91  		s.ParentBaseFee = (*big.Int)(dec.ParentBaseFee)
    92  	}
    93  	if dec.ParentGasUsed != nil {
    94  		s.ParentGasUsed = uint64(*dec.ParentGasUsed)
    95  	}
    96  	if dec.ParentGasLimit != nil {
    97  		s.ParentGasLimit = uint64(*dec.ParentGasLimit)
    98  	}
    99  	if dec.GasLimit == nil {
   100  		return errors.New("missing required field 'currentGasLimit' for stEnv")
   101  	}
   102  	s.GasLimit = uint64(*dec.GasLimit)
   103  	if dec.Number == nil {
   104  		return errors.New("missing required field 'currentNumber' for stEnv")
   105  	}
   106  	s.Number = uint64(*dec.Number)
   107  	if dec.Timestamp == nil {
   108  		return errors.New("missing required field 'currentTimestamp' for stEnv")
   109  	}
   110  	s.Timestamp = uint64(*dec.Timestamp)
   111  	if dec.ParentTimestamp != nil {
   112  		s.ParentTimestamp = uint64(*dec.ParentTimestamp)
   113  	}
   114  	if dec.BlockHashes != nil {
   115  		s.BlockHashes = dec.BlockHashes
   116  	}
   117  	if dec.Ommers != nil {
   118  		s.Ommers = dec.Ommers
   119  	}
   120  	if dec.BaseFee != nil {
   121  		s.BaseFee = (*big.Int)(dec.BaseFee)
   122  	}
   123  	if dec.ParentUncleHash != nil {
   124  		s.ParentUncleHash = *dec.ParentUncleHash
   125  	}
   126  	return nil
   127  }