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