github.com/authcall/reference-optimistic-geth@v0.0.0-20220816224302-06313bfeb8d2/core/beacon/gen_ed.go (about)

     1  // Code generated by github.com/fjl/gencodec. DO NOT EDIT.
     2  
     3  package beacon
     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/hexutil"
    12  )
    13  
    14  var _ = (*executableDataMarshaling)(nil)
    15  
    16  // MarshalJSON marshals as JSON.
    17  func (e ExecutableDataV1) MarshalJSON() ([]byte, error) {
    18  	type ExecutableDataV1 struct {
    19  		ParentHash    common.Hash     `json:"parentHash"    gencodec:"required"`
    20  		FeeRecipient  common.Address  `json:"feeRecipient"  gencodec:"required"`
    21  		StateRoot     common.Hash     `json:"stateRoot"     gencodec:"required"`
    22  		ReceiptsRoot  common.Hash     `json:"receiptsRoot"  gencodec:"required"`
    23  		LogsBloom     hexutil.Bytes   `json:"logsBloom"     gencodec:"required"`
    24  		Random        common.Hash     `json:"prevRandao"    gencodec:"required"`
    25  		Number        hexutil.Uint64  `json:"blockNumber"   gencodec:"required"`
    26  		GasLimit      hexutil.Uint64  `json:"gasLimit"      gencodec:"required"`
    27  		GasUsed       hexutil.Uint64  `json:"gasUsed"       gencodec:"required"`
    28  		Timestamp     hexutil.Uint64  `json:"timestamp"     gencodec:"required"`
    29  		ExtraData     hexutil.Bytes   `json:"extraData"     gencodec:"required"`
    30  		BaseFeePerGas *hexutil.Big    `json:"baseFeePerGas" gencodec:"required"`
    31  		BlockHash     common.Hash     `json:"blockHash"     gencodec:"required"`
    32  		Transactions  []hexutil.Bytes `json:"transactions"  gencodec:"required"`
    33  	}
    34  	var enc ExecutableDataV1
    35  	enc.ParentHash = e.ParentHash
    36  	enc.FeeRecipient = e.FeeRecipient
    37  	enc.StateRoot = e.StateRoot
    38  	enc.ReceiptsRoot = e.ReceiptsRoot
    39  	enc.LogsBloom = e.LogsBloom
    40  	enc.Random = e.Random
    41  	enc.Number = hexutil.Uint64(e.Number)
    42  	enc.GasLimit = hexutil.Uint64(e.GasLimit)
    43  	enc.GasUsed = hexutil.Uint64(e.GasUsed)
    44  	enc.Timestamp = hexutil.Uint64(e.Timestamp)
    45  	enc.ExtraData = e.ExtraData
    46  	enc.BaseFeePerGas = (*hexutil.Big)(e.BaseFeePerGas)
    47  	enc.BlockHash = e.BlockHash
    48  	if e.Transactions != nil {
    49  		enc.Transactions = make([]hexutil.Bytes, len(e.Transactions))
    50  		for k, v := range e.Transactions {
    51  			enc.Transactions[k] = v
    52  		}
    53  	}
    54  	return json.Marshal(&enc)
    55  }
    56  
    57  // UnmarshalJSON unmarshals from JSON.
    58  func (e *ExecutableDataV1) UnmarshalJSON(input []byte) error {
    59  	type ExecutableDataV1 struct {
    60  		ParentHash    *common.Hash    `json:"parentHash"    gencodec:"required"`
    61  		FeeRecipient  *common.Address `json:"feeRecipient"  gencodec:"required"`
    62  		StateRoot     *common.Hash    `json:"stateRoot"     gencodec:"required"`
    63  		ReceiptsRoot  *common.Hash    `json:"receiptsRoot"  gencodec:"required"`
    64  		LogsBloom     *hexutil.Bytes  `json:"logsBloom"     gencodec:"required"`
    65  		Random        *common.Hash    `json:"prevRandao"    gencodec:"required"`
    66  		Number        *hexutil.Uint64 `json:"blockNumber"   gencodec:"required"`
    67  		GasLimit      *hexutil.Uint64 `json:"gasLimit"      gencodec:"required"`
    68  		GasUsed       *hexutil.Uint64 `json:"gasUsed"       gencodec:"required"`
    69  		Timestamp     *hexutil.Uint64 `json:"timestamp"     gencodec:"required"`
    70  		ExtraData     *hexutil.Bytes  `json:"extraData"     gencodec:"required"`
    71  		BaseFeePerGas *hexutil.Big    `json:"baseFeePerGas" gencodec:"required"`
    72  		BlockHash     *common.Hash    `json:"blockHash"     gencodec:"required"`
    73  		Transactions  []hexutil.Bytes `json:"transactions"  gencodec:"required"`
    74  	}
    75  	var dec ExecutableDataV1
    76  	if err := json.Unmarshal(input, &dec); err != nil {
    77  		return err
    78  	}
    79  	if dec.ParentHash == nil {
    80  		return errors.New("missing required field 'parentHash' for ExecutableDataV1")
    81  	}
    82  	e.ParentHash = *dec.ParentHash
    83  	if dec.FeeRecipient == nil {
    84  		return errors.New("missing required field 'feeRecipient' for ExecutableDataV1")
    85  	}
    86  	e.FeeRecipient = *dec.FeeRecipient
    87  	if dec.StateRoot == nil {
    88  		return errors.New("missing required field 'stateRoot' for ExecutableDataV1")
    89  	}
    90  	e.StateRoot = *dec.StateRoot
    91  	if dec.ReceiptsRoot == nil {
    92  		return errors.New("missing required field 'receiptsRoot' for ExecutableDataV1")
    93  	}
    94  	e.ReceiptsRoot = *dec.ReceiptsRoot
    95  	if dec.LogsBloom == nil {
    96  		return errors.New("missing required field 'logsBloom' for ExecutableDataV1")
    97  	}
    98  	e.LogsBloom = *dec.LogsBloom
    99  	if dec.Random == nil {
   100  		return errors.New("missing required field 'prevRandao' for ExecutableDataV1")
   101  	}
   102  	e.Random = *dec.Random
   103  	if dec.Number == nil {
   104  		return errors.New("missing required field 'blockNumber' for ExecutableDataV1")
   105  	}
   106  	e.Number = uint64(*dec.Number)
   107  	if dec.GasLimit == nil {
   108  		return errors.New("missing required field 'gasLimit' for ExecutableDataV1")
   109  	}
   110  	e.GasLimit = uint64(*dec.GasLimit)
   111  	if dec.GasUsed == nil {
   112  		return errors.New("missing required field 'gasUsed' for ExecutableDataV1")
   113  	}
   114  	e.GasUsed = uint64(*dec.GasUsed)
   115  	if dec.Timestamp == nil {
   116  		return errors.New("missing required field 'timestamp' for ExecutableDataV1")
   117  	}
   118  	e.Timestamp = uint64(*dec.Timestamp)
   119  	if dec.ExtraData == nil {
   120  		return errors.New("missing required field 'extraData' for ExecutableDataV1")
   121  	}
   122  	e.ExtraData = *dec.ExtraData
   123  	if dec.BaseFeePerGas == nil {
   124  		return errors.New("missing required field 'baseFeePerGas' for ExecutableDataV1")
   125  	}
   126  	e.BaseFeePerGas = (*big.Int)(dec.BaseFeePerGas)
   127  	if dec.BlockHash == nil {
   128  		return errors.New("missing required field 'blockHash' for ExecutableDataV1")
   129  	}
   130  	e.BlockHash = *dec.BlockHash
   131  	if dec.Transactions == nil {
   132  		return errors.New("missing required field 'transactions' for ExecutableDataV1")
   133  	}
   134  	e.Transactions = make([][]byte, len(dec.Transactions))
   135  	for k, v := range dec.Transactions {
   136  		e.Transactions[k] = v
   137  	}
   138  	return nil
   139  }