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

package native

import (
	"encoding/json"

	"github.com/erigontech/erigon/common"
)

// MarshalJSON marshals as JSON.
func (f flatCallFrame) MarshalJSON() ([]byte, error) {
	type flatCallFrame struct {
		Action              flatCallAction  `json:"action"`
		BlockHash           *common.Hash    `json:"blockHash"`
		BlockNumber         uint64          `json:"blockNumber"`
		Error               string          `json:"error,omitempty"`
		Result              *flatCallResult `json:"result,omitempty"`
		Subtraces           int             `json:"subtraces"`
		TraceAddress        []int           `json:"traceAddress"`
		TransactionHash     *common.Hash    `json:"transactionHash"`
		TransactionPosition uint64          `json:"transactionPosition"`
		Type                string          `json:"type"`
	}
	var enc flatCallFrame
	enc.Action = f.Action
	enc.BlockHash = f.BlockHash
	enc.BlockNumber = f.BlockNumber
	enc.Error = f.Error
	enc.Result = f.Result
	enc.Subtraces = f.Subtraces
	enc.TraceAddress = f.TraceAddress
	enc.TransactionHash = f.TransactionHash
	enc.TransactionPosition = f.TransactionPosition
	enc.Type = f.Type
	return json.Marshal(&enc)
}

// UnmarshalJSON unmarshals from JSON.
func (f *flatCallFrame) UnmarshalJSON(input []byte) error {
	type flatCallFrame struct {
		Action              *flatCallAction `json:"action"`
		BlockHash           *common.Hash    `json:"blockHash"`
		BlockNumber         *uint64         `json:"blockNumber"`
		Error               *string         `json:"error,omitempty"`
		Result              *flatCallResult `json:"result,omitempty"`
		Subtraces           *int            `json:"subtraces"`
		TraceAddress        []int           `json:"traceAddress"`
		TransactionHash     *common.Hash    `json:"transactionHash"`
		TransactionPosition *uint64         `json:"transactionPosition"`
		Type                *string         `json:"type"`
	}
	var dec flatCallFrame
	if err := json.Unmarshal(input, &dec); err != nil {
		return err
	}
	if dec.Action != nil {
		f.Action = *dec.Action
	}
	if dec.BlockHash != nil {
		f.BlockHash = dec.BlockHash
	}
	if dec.BlockNumber != nil {
		f.BlockNumber = *dec.BlockNumber
	}
	if dec.Error != nil {
		f.Error = *dec.Error
	}
	if dec.Result != nil {
		f.Result = dec.Result
	}
	if dec.Subtraces != nil {
		f.Subtraces = *dec.Subtraces
	}
	if dec.TraceAddress != nil {
		f.TraceAddress = dec.TraceAddress
	}
	if dec.TransactionHash != nil {
		f.TransactionHash = dec.TransactionHash
	}
	if dec.TransactionPosition != nil {
		f.TransactionPosition = *dec.TransactionPosition
	}
	if dec.Type != nil {
		f.Type = *dec.Type
	}
	return nil
}
