2020-06-30 08:12:51 +00:00
|
|
|
// Code generated by github.com/fjl/gencodec. DO NOT EDIT.
|
|
|
|
|
|
|
|
package t8ntool
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"errors"
|
|
|
|
"math/big"
|
|
|
|
|
2023-01-13 18:12:18 +00:00
|
|
|
libcommon "github.com/ledgerwatch/erigon-lib/common"
|
|
|
|
|
2021-05-20 18:25:53 +00:00
|
|
|
"github.com/ledgerwatch/erigon/common"
|
|
|
|
"github.com/ledgerwatch/erigon/common/math"
|
2020-06-30 08:12:51 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var _ = (*stEnvMarshaling)(nil)
|
|
|
|
|
|
|
|
// MarshalJSON marshals as JSON.
|
|
|
|
func (s stEnv) MarshalJSON() ([]byte, error) {
|
|
|
|
type stEnv struct {
|
2023-02-03 15:39:09 +00:00
|
|
|
Coinbase common.UnprefixedAddress `json:"currentCoinbase" gencodec:"required"`
|
|
|
|
Difficulty *math.HexOrDecimal256 `json:"currentDifficulty"`
|
|
|
|
Random *math.HexOrDecimal256 `json:"currentRandom"`
|
|
|
|
ParentDifficulty *math.HexOrDecimal256 `json:"parentDifficulty"`
|
|
|
|
GasLimit math.HexOrDecimal64 `json:"currentGasLimit" gencodec:"required"`
|
|
|
|
Number math.HexOrDecimal64 `json:"currentNumber" gencodec:"required"`
|
|
|
|
Timestamp math.HexOrDecimal64 `json:"currentTimestamp" gencodec:"required"`
|
|
|
|
ParentTimestamp math.HexOrDecimal64 `json:"parentTimestamp,omitempty"`
|
2023-01-13 18:12:18 +00:00
|
|
|
BlockHashes map[math.HexOrDecimal64]libcommon.Hash `json:"blockHashes,omitempty"`
|
2023-02-03 15:39:09 +00:00
|
|
|
Ommers []ommer `json:"ommers,omitempty"`
|
|
|
|
BaseFee *math.HexOrDecimal256 `json:"currentBaseFee,omitempty"`
|
2023-01-13 18:12:18 +00:00
|
|
|
ParentUncleHash libcommon.Hash `json:"parentUncleHash"`
|
2020-06-30 08:12:51 +00:00
|
|
|
}
|
|
|
|
var enc stEnv
|
|
|
|
enc.Coinbase = common.UnprefixedAddress(s.Coinbase)
|
|
|
|
enc.Difficulty = (*math.HexOrDecimal256)(s.Difficulty)
|
2022-07-07 11:47:00 +00:00
|
|
|
enc.Random = (*math.HexOrDecimal256)(s.Random)
|
|
|
|
enc.ParentDifficulty = (*math.HexOrDecimal256)(s.ParentDifficulty)
|
2020-06-30 08:12:51 +00:00
|
|
|
enc.GasLimit = math.HexOrDecimal64(s.GasLimit)
|
|
|
|
enc.Number = math.HexOrDecimal64(s.Number)
|
|
|
|
enc.Timestamp = math.HexOrDecimal64(s.Timestamp)
|
2022-07-07 11:47:00 +00:00
|
|
|
enc.ParentTimestamp = math.HexOrDecimal64(s.ParentTimestamp)
|
2020-06-30 08:12:51 +00:00
|
|
|
enc.BlockHashes = s.BlockHashes
|
|
|
|
enc.Ommers = s.Ommers
|
2021-05-11 09:54:20 +00:00
|
|
|
enc.BaseFee = (*math.HexOrDecimal256)(s.BaseFee)
|
2022-07-07 11:47:00 +00:00
|
|
|
enc.ParentUncleHash = s.ParentUncleHash
|
2020-06-30 08:12:51 +00:00
|
|
|
return json.Marshal(&enc)
|
|
|
|
}
|
|
|
|
|
|
|
|
// UnmarshalJSON unmarshals from JSON.
|
|
|
|
func (s *stEnv) UnmarshalJSON(input []byte) error {
|
|
|
|
type stEnv struct {
|
2023-02-03 15:39:09 +00:00
|
|
|
Coinbase *common.UnprefixedAddress `json:"currentCoinbase" gencodec:"required"`
|
|
|
|
Difficulty *math.HexOrDecimal256 `json:"currentDifficulty"`
|
|
|
|
Random *math.HexOrDecimal256 `json:"currentRandom"`
|
|
|
|
ParentDifficulty *math.HexOrDecimal256 `json:"parentDifficulty"`
|
|
|
|
GasLimit *math.HexOrDecimal64 `json:"currentGasLimit" gencodec:"required"`
|
|
|
|
Number *math.HexOrDecimal64 `json:"currentNumber" gencodec:"required"`
|
|
|
|
Timestamp *math.HexOrDecimal64 `json:"currentTimestamp" gencodec:"required"`
|
|
|
|
ParentTimestamp *math.HexOrDecimal64 `json:"parentTimestamp,omitempty"`
|
2023-01-13 18:12:18 +00:00
|
|
|
BlockHashes map[math.HexOrDecimal64]libcommon.Hash `json:"blockHashes,omitempty"`
|
2023-02-03 15:39:09 +00:00
|
|
|
Ommers []ommer `json:"ommers,omitempty"`
|
|
|
|
BaseFee *math.HexOrDecimal256 `json:"currentBaseFee,omitempty"`
|
2023-01-13 18:12:18 +00:00
|
|
|
ParentUncleHash *libcommon.Hash `json:"parentUncleHash"`
|
2020-06-30 08:12:51 +00:00
|
|
|
}
|
|
|
|
var dec stEnv
|
|
|
|
if err := json.Unmarshal(input, &dec); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if dec.Coinbase == nil {
|
|
|
|
return errors.New("missing required field 'currentCoinbase' for stEnv")
|
|
|
|
}
|
2023-01-13 18:12:18 +00:00
|
|
|
s.Coinbase = libcommon.Address(*dec.Coinbase)
|
2022-07-07 11:47:00 +00:00
|
|
|
if dec.Difficulty != nil {
|
|
|
|
s.Difficulty = (*big.Int)(dec.Difficulty)
|
|
|
|
}
|
|
|
|
if dec.Random != nil {
|
|
|
|
s.Random = (*big.Int)(dec.Random)
|
|
|
|
}
|
|
|
|
if dec.ParentDifficulty != nil {
|
|
|
|
s.ParentDifficulty = (*big.Int)(dec.ParentDifficulty)
|
2020-06-30 08:12:51 +00:00
|
|
|
}
|
|
|
|
if dec.GasLimit == nil {
|
|
|
|
return errors.New("missing required field 'currentGasLimit' for stEnv")
|
|
|
|
}
|
|
|
|
s.GasLimit = uint64(*dec.GasLimit)
|
|
|
|
if dec.Number == nil {
|
|
|
|
return errors.New("missing required field 'currentNumber' for stEnv")
|
|
|
|
}
|
|
|
|
s.Number = uint64(*dec.Number)
|
|
|
|
if dec.Timestamp == nil {
|
|
|
|
return errors.New("missing required field 'currentTimestamp' for stEnv")
|
|
|
|
}
|
|
|
|
s.Timestamp = uint64(*dec.Timestamp)
|
2022-07-07 11:47:00 +00:00
|
|
|
if dec.ParentTimestamp != nil {
|
|
|
|
s.ParentTimestamp = uint64(*dec.ParentTimestamp)
|
|
|
|
}
|
2020-06-30 08:12:51 +00:00
|
|
|
if dec.BlockHashes != nil {
|
|
|
|
s.BlockHashes = dec.BlockHashes
|
|
|
|
}
|
|
|
|
if dec.Ommers != nil {
|
|
|
|
s.Ommers = dec.Ommers
|
|
|
|
}
|
2021-05-11 09:54:20 +00:00
|
|
|
if dec.BaseFee != nil {
|
|
|
|
s.BaseFee = (*big.Int)(dec.BaseFee)
|
|
|
|
}
|
2022-07-07 11:47:00 +00:00
|
|
|
if dec.ParentUncleHash != nil {
|
|
|
|
s.ParentUncleHash = *dec.ParentUncleHash
|
2022-01-10 13:17:26 +00:00
|
|
|
}
|
2020-06-30 08:12:51 +00:00
|
|
|
return nil
|
|
|
|
}
|