github.com/theQRL/go-zond@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/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.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  		ExcessBlobGas         *math.HexOrDecimal64                `json:"excessBlobGas,omitempty"`
    37  		ParentExcessBlobGas   *math.HexOrDecimal64                `json:"parentExcessBlobGas,omitempty"`
    38  		ParentBlobGasUsed     *math.HexOrDecimal64                `json:"parentBlobGasUsed,omitempty"`
    39  		ParentBeaconBlockRoot *common.Hash                        `json:"parentBeaconBlockRoot"`
    40  	}
    41  	var enc stEnv
    42  	enc.Coinbase = common.UnprefixedAddress(s.Coinbase)
    43  	enc.Difficulty = (*math.HexOrDecimal256)(s.Difficulty)
    44  	enc.Random = (*math.HexOrDecimal256)(s.Random)
    45  	enc.ParentDifficulty = (*math.HexOrDecimal256)(s.ParentDifficulty)
    46  	enc.ParentBaseFee = (*math.HexOrDecimal256)(s.ParentBaseFee)
    47  	enc.ParentGasUsed = math.HexOrDecimal64(s.ParentGasUsed)
    48  	enc.ParentGasLimit = math.HexOrDecimal64(s.ParentGasLimit)
    49  	enc.GasLimit = math.HexOrDecimal64(s.GasLimit)
    50  	enc.Number = math.HexOrDecimal64(s.Number)
    51  	enc.Timestamp = math.HexOrDecimal64(s.Timestamp)
    52  	enc.ParentTimestamp = math.HexOrDecimal64(s.ParentTimestamp)
    53  	enc.BlockHashes = s.BlockHashes
    54  	enc.Ommers = s.Ommers
    55  	enc.Withdrawals = s.Withdrawals
    56  	enc.BaseFee = (*math.HexOrDecimal256)(s.BaseFee)
    57  	enc.ParentUncleHash = s.ParentUncleHash
    58  	enc.ExcessBlobGas = (*math.HexOrDecimal64)(s.ExcessBlobGas)
    59  	enc.ParentExcessBlobGas = (*math.HexOrDecimal64)(s.ParentExcessBlobGas)
    60  	enc.ParentBlobGasUsed = (*math.HexOrDecimal64)(s.ParentBlobGasUsed)
    61  	enc.ParentBeaconBlockRoot = s.ParentBeaconBlockRoot
    62  	return json.Marshal(&enc)
    63  }
    64  
    65  // UnmarshalJSON unmarshals from JSON.
    66  func (s *stEnv) UnmarshalJSON(input []byte) error {
    67  	type stEnv struct {
    68  		Coinbase              *common.UnprefixedAddress           `json:"currentCoinbase"   gencodec:"required"`
    69  		Difficulty            *math.HexOrDecimal256               `json:"currentDifficulty"`
    70  		Random                *math.HexOrDecimal256               `json:"currentRandom"`
    71  		ParentDifficulty      *math.HexOrDecimal256               `json:"parentDifficulty"`
    72  		ParentBaseFee         *math.HexOrDecimal256               `json:"parentBaseFee,omitempty"`
    73  		ParentGasUsed         *math.HexOrDecimal64                `json:"parentGasUsed,omitempty"`
    74  		ParentGasLimit        *math.HexOrDecimal64                `json:"parentGasLimit,omitempty"`
    75  		GasLimit              *math.HexOrDecimal64                `json:"currentGasLimit"   gencodec:"required"`
    76  		Number                *math.HexOrDecimal64                `json:"currentNumber"     gencodec:"required"`
    77  		Timestamp             *math.HexOrDecimal64                `json:"currentTimestamp"  gencodec:"required"`
    78  		ParentTimestamp       *math.HexOrDecimal64                `json:"parentTimestamp,omitempty"`
    79  		BlockHashes           map[math.HexOrDecimal64]common.Hash `json:"blockHashes,omitempty"`
    80  		Ommers                []ommer                             `json:"ommers,omitempty"`
    81  		Withdrawals           []*types.Withdrawal                 `json:"withdrawals,omitempty"`
    82  		BaseFee               *math.HexOrDecimal256               `json:"currentBaseFee,omitempty"`
    83  		ParentUncleHash       *common.Hash                        `json:"parentUncleHash"`
    84  		ExcessBlobGas         *math.HexOrDecimal64                `json:"excessBlobGas,omitempty"`
    85  		ParentExcessBlobGas   *math.HexOrDecimal64                `json:"parentExcessBlobGas,omitempty"`
    86  		ParentBlobGasUsed     *math.HexOrDecimal64                `json:"parentBlobGasUsed,omitempty"`
    87  		ParentBeaconBlockRoot *common.Hash                        `json:"parentBeaconBlockRoot"`
    88  	}
    89  	var dec stEnv
    90  	if err := json.Unmarshal(input, &dec); err != nil {
    91  		return err
    92  	}
    93  	if dec.Coinbase == nil {
    94  		return errors.New("missing required field 'currentCoinbase' for stEnv")
    95  	}
    96  	s.Coinbase = common.Address(*dec.Coinbase)
    97  	if dec.Difficulty != nil {
    98  		s.Difficulty = (*big.Int)(dec.Difficulty)
    99  	}
   100  	if dec.Random != nil {
   101  		s.Random = (*big.Int)(dec.Random)
   102  	}
   103  	if dec.ParentDifficulty != nil {
   104  		s.ParentDifficulty = (*big.Int)(dec.ParentDifficulty)
   105  	}
   106  	if dec.ParentBaseFee != nil {
   107  		s.ParentBaseFee = (*big.Int)(dec.ParentBaseFee)
   108  	}
   109  	if dec.ParentGasUsed != nil {
   110  		s.ParentGasUsed = uint64(*dec.ParentGasUsed)
   111  	}
   112  	if dec.ParentGasLimit != nil {
   113  		s.ParentGasLimit = uint64(*dec.ParentGasLimit)
   114  	}
   115  	if dec.GasLimit == nil {
   116  		return errors.New("missing required field 'currentGasLimit' for stEnv")
   117  	}
   118  	s.GasLimit = uint64(*dec.GasLimit)
   119  	if dec.Number == nil {
   120  		return errors.New("missing required field 'currentNumber' for stEnv")
   121  	}
   122  	s.Number = uint64(*dec.Number)
   123  	if dec.Timestamp == nil {
   124  		return errors.New("missing required field 'currentTimestamp' for stEnv")
   125  	}
   126  	s.Timestamp = uint64(*dec.Timestamp)
   127  	if dec.ParentTimestamp != nil {
   128  		s.ParentTimestamp = uint64(*dec.ParentTimestamp)
   129  	}
   130  	if dec.BlockHashes != nil {
   131  		s.BlockHashes = dec.BlockHashes
   132  	}
   133  	if dec.Ommers != nil {
   134  		s.Ommers = dec.Ommers
   135  	}
   136  	if dec.Withdrawals != nil {
   137  		s.Withdrawals = dec.Withdrawals
   138  	}
   139  	if dec.BaseFee != nil {
   140  		s.BaseFee = (*big.Int)(dec.BaseFee)
   141  	}
   142  	if dec.ParentUncleHash != nil {
   143  		s.ParentUncleHash = *dec.ParentUncleHash
   144  	}
   145  	if dec.ExcessBlobGas != nil {
   146  		s.ExcessBlobGas = (*uint64)(dec.ExcessBlobGas)
   147  	}
   148  	if dec.ParentExcessBlobGas != nil {
   149  		s.ParentExcessBlobGas = (*uint64)(dec.ParentExcessBlobGas)
   150  	}
   151  	if dec.ParentBlobGasUsed != nil {
   152  		s.ParentBlobGasUsed = (*uint64)(dec.ParentBlobGasUsed)
   153  	}
   154  	if dec.ParentBeaconBlockRoot != nil {
   155  		s.ParentBeaconBlockRoot = dec.ParentBeaconBlockRoot
   156  	}
   157  	return nil
   158  }