gen_rpc_tx_meta_json.go 2.35 KB
// Code generated by github.com/fjl/gencodec. DO NOT EDIT.

package ethclient

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

	"github.com/ethereum-optimism/optimism/l2geth/common"
	"github.com/ethereum-optimism/optimism/l2geth/common/hexutil"
	"github.com/ethereum-optimism/optimism/l2geth/core/types"
)

var _ = (*rpcTransactionMetaMarshaling)(nil)

// MarshalJSON marshals as JSON.
func (r rpcTransactionMeta) MarshalJSON() ([]byte, error) {
	type rpcTransactionMeta struct {
		L1BlockNumber   *hexutil.Big      `json:"l1BlockNumber"`
		L1Timestamp     hexutil.Uint64    `json:"l1Timestamp"`
		L1MessageSender *common.Address   `json:"l1MessageSender"`
		QueueOrigin     types.QueueOrigin `json:"queueOrigin"`
		Index           *hexutil.Uint64   `json:"index"`
		QueueIndex      *hexutil.Uint64   `json:"queueIndex"`
		RawTransaction  hexutil.Bytes     `json:"rawTransaction"`
	}
	var enc rpcTransactionMeta
	enc.L1BlockNumber = (*hexutil.Big)(r.L1BlockNumber)
	enc.L1Timestamp = hexutil.Uint64(r.L1Timestamp)
	enc.L1MessageSender = r.L1MessageSender
	enc.QueueOrigin = r.QueueOrigin
	enc.Index = (*hexutil.Uint64)(r.Index)
	enc.QueueIndex = (*hexutil.Uint64)(r.QueueIndex)
	enc.RawTransaction = r.RawTransaction
	return json.Marshal(&enc)
}

// UnmarshalJSON unmarshals from JSON.
func (r *rpcTransactionMeta) UnmarshalJSON(input []byte) error {
	type rpcTransactionMeta struct {
		L1BlockNumber   *hexutil.Big       `json:"l1BlockNumber"`
		L1Timestamp     *hexutil.Uint64    `json:"l1Timestamp"`
		L1MessageSender *common.Address    `json:"l1MessageSender"`
		QueueOrigin     *types.QueueOrigin `json:"queueOrigin"`
		Index           *hexutil.Uint64    `json:"index"`
		QueueIndex      *hexutil.Uint64    `json:"queueIndex"`
		RawTransaction  *hexutil.Bytes     `json:"rawTransaction"`
	}
	var dec rpcTransactionMeta
	if err := json.Unmarshal(input, &dec); err != nil {
		return err
	}
	if dec.L1BlockNumber != nil {
		r.L1BlockNumber = (*big.Int)(dec.L1BlockNumber)
	}
	if dec.L1Timestamp != nil {
		r.L1Timestamp = uint64(*dec.L1Timestamp)
	}
	if dec.L1MessageSender != nil {
		r.L1MessageSender = dec.L1MessageSender
	}
	if dec.QueueOrigin != nil {
		r.QueueOrigin = *dec.QueueOrigin
	}
	if dec.Index != nil {
		r.Index = (*uint64)(dec.Index)
	}
	if dec.QueueIndex != nil {
		r.QueueIndex = (*uint64)(dec.QueueIndex)
	}
	if dec.RawTransaction != nil {
		r.RawTransaction = *dec.RawTransaction
	}
	return nil
}