// Code generated by github.com/fjl/gencodec. DO NOT EDIT.

package ethclient

import (
	"encoding/json"
	"math/big"

	"github.com/ethereum/go-ethereum/common"
	"github.com/ethereum/go-ethereum/common/hexutil"
)

var _ = (*simulateBlockResultMarshaling)(nil)

// MarshalJSON marshals as JSON.
func (s SimulateBlockResult) MarshalJSON() ([]byte, error) {
	type SimulateBlockResult struct {
		Number        *hexutil.Big         `json:"number"`
		Hash          common.Hash          `json:"hash"`
		Timestamp     hexutil.Uint64       `json:"timestamp"`
		GasLimit      hexutil.Uint64       `json:"gasLimit"`
		GasUsed       hexutil.Uint64       `json:"gasUsed"`
		FeeRecipient  common.Address       `json:"miner"`
		BaseFeePerGas *hexutil.Big         `json:"baseFeePerGas,omitempty"`
		Calls         []SimulateCallResult `json:"calls"`
	}
	var enc SimulateBlockResult
	enc.Number = (*hexutil.Big)(s.Number)
	enc.Hash = s.Hash
	enc.Timestamp = hexutil.Uint64(s.Timestamp)
	enc.GasLimit = hexutil.Uint64(s.GasLimit)
	enc.GasUsed = hexutil.Uint64(s.GasUsed)
	enc.FeeRecipient = s.FeeRecipient
	enc.BaseFeePerGas = (*hexutil.Big)(s.BaseFeePerGas)
	enc.Calls = s.Calls
	return json.Marshal(&enc)
}

// UnmarshalJSON unmarshals from JSON.
func (s *SimulateBlockResult) UnmarshalJSON(input []byte) error {
	type SimulateBlockResult struct {
		Number        *hexutil.Big         `json:"number"`
		Hash          *common.Hash         `json:"hash"`
		Timestamp     *hexutil.Uint64      `json:"timestamp"`
		GasLimit      *hexutil.Uint64      `json:"gasLimit"`
		GasUsed       *hexutil.Uint64      `json:"gasUsed"`
		FeeRecipient  *common.Address      `json:"miner"`
		BaseFeePerGas *hexutil.Big         `json:"baseFeePerGas,omitempty"`
		Calls         []SimulateCallResult `json:"calls"`
	}
	var dec SimulateBlockResult
	if err := json.Unmarshal(input, &dec); err != nil {
		return err
	}
	if dec.Number != nil {
		s.Number = (*big.Int)(dec.Number)
	}
	if dec.Hash != nil {
		s.Hash = *dec.Hash
	}
	if dec.Timestamp != nil {
		s.Timestamp = uint64(*dec.Timestamp)
	}
	if dec.GasLimit != nil {
		s.GasLimit = uint64(*dec.GasLimit)
	}
	if dec.GasUsed != nil {
		s.GasUsed = uint64(*dec.GasUsed)
	}
	if dec.FeeRecipient != nil {
		s.FeeRecipient = *dec.FeeRecipient
	}
	if dec.BaseFeePerGas != nil {
		s.BaseFeePerGas = (*big.Int)(dec.BaseFeePerGas)
	}
	if dec.Calls != nil {
		s.Calls = dec.Calls
	}
	return nil
}
