github.com/tacshi/go-ethereum@v0.0.0-20230616113857-84a434e20921/eth/tracers/native/gen_callframe_json.go (about)

     1  // Code generated by github.com/fjl/gencodec. DO NOT EDIT.
     2  
     3  package native
     4  
     5  import (
     6  	"encoding/json"
     7  	"math/big"
     8  
     9  	"github.com/tacshi/go-ethereum/common"
    10  	"github.com/tacshi/go-ethereum/common/hexutil"
    11  	"github.com/tacshi/go-ethereum/core/vm"
    12  )
    13  
    14  var _ = (*callFrameMarshaling)(nil)
    15  
    16  // MarshalJSON marshals as JSON.
    17  func (c callFrame) MarshalJSON() ([]byte, error) {
    18  	type callFrame0 struct {
    19  		BeforeEVMTransfers *[]arbitrumTransfer `json:"beforeEVMTransfers,omitempty"`
    20  		AfterEVMTransfers  *[]arbitrumTransfer `json:"afterEVMTransfers,omitempty"`
    21  		Type               vm.OpCode           `json:"-"`
    22  		From               common.Address      `json:"from"`
    23  		Gas                hexutil.Uint64      `json:"gas"`
    24  		GasUsed            hexutil.Uint64      `json:"gasUsed"`
    25  		To                 *common.Address     `json:"to,omitempty" rlp:"optional"`
    26  		Input              hexutil.Bytes       `json:"input" rlp:"optional"`
    27  		Output             hexutil.Bytes       `json:"output,omitempty" rlp:"optional"`
    28  		Error              string              `json:"error,omitempty" rlp:"optional"`
    29  		RevertReason       string              `json:"revertReason,omitempty"`
    30  		Calls              []callFrame         `json:"calls,omitempty" rlp:"optional"`
    31  		Logs               []callLog           `json:"logs,omitempty" rlp:"optional"`
    32  		Value              *hexutil.Big        `json:"value,omitempty" rlp:"optional"`
    33  		TypeString         string              `json:"type"`
    34  	}
    35  	var enc callFrame0
    36  	enc.BeforeEVMTransfers = c.BeforeEVMTransfers
    37  	enc.AfterEVMTransfers = c.AfterEVMTransfers
    38  	enc.Type = c.Type
    39  	enc.From = c.From
    40  	enc.Gas = hexutil.Uint64(c.Gas)
    41  	enc.GasUsed = hexutil.Uint64(c.GasUsed)
    42  	enc.To = c.To
    43  	enc.Input = c.Input
    44  	enc.Output = c.Output
    45  	enc.Error = c.Error
    46  	enc.RevertReason = c.RevertReason
    47  	enc.Calls = c.Calls
    48  	enc.Logs = c.Logs
    49  	enc.Value = (*hexutil.Big)(c.Value)
    50  	enc.TypeString = c.TypeString()
    51  	return json.Marshal(&enc)
    52  }
    53  
    54  // UnmarshalJSON unmarshals from JSON.
    55  func (c *callFrame) UnmarshalJSON(input []byte) error {
    56  	type callFrame0 struct {
    57  		BeforeEVMTransfers *[]arbitrumTransfer `json:"beforeEVMTransfers,omitempty"`
    58  		AfterEVMTransfers  *[]arbitrumTransfer `json:"afterEVMTransfers,omitempty"`
    59  		Type               *vm.OpCode          `json:"-"`
    60  		From               *common.Address     `json:"from"`
    61  		Gas                *hexutil.Uint64     `json:"gas"`
    62  		GasUsed            *hexutil.Uint64     `json:"gasUsed"`
    63  		To                 *common.Address     `json:"to,omitempty" rlp:"optional"`
    64  		Input              *hexutil.Bytes      `json:"input" rlp:"optional"`
    65  		Output             *hexutil.Bytes      `json:"output,omitempty" rlp:"optional"`
    66  		Error              *string             `json:"error,omitempty" rlp:"optional"`
    67  		RevertReason       *string             `json:"revertReason,omitempty"`
    68  		Calls              []callFrame         `json:"calls,omitempty" rlp:"optional"`
    69  		Logs               []callLog           `json:"logs,omitempty" rlp:"optional"`
    70  		Value              *hexutil.Big        `json:"value,omitempty" rlp:"optional"`
    71  	}
    72  	var dec callFrame0
    73  	if err := json.Unmarshal(input, &dec); err != nil {
    74  		return err
    75  	}
    76  	if dec.BeforeEVMTransfers != nil {
    77  		c.BeforeEVMTransfers = dec.BeforeEVMTransfers
    78  	}
    79  	if dec.AfterEVMTransfers != nil {
    80  		c.AfterEVMTransfers = dec.AfterEVMTransfers
    81  	}
    82  	if dec.Type != nil {
    83  		c.Type = *dec.Type
    84  	}
    85  	if dec.From != nil {
    86  		c.From = *dec.From
    87  	}
    88  	if dec.Gas != nil {
    89  		c.Gas = uint64(*dec.Gas)
    90  	}
    91  	if dec.GasUsed != nil {
    92  		c.GasUsed = uint64(*dec.GasUsed)
    93  	}
    94  	if dec.To != nil {
    95  		c.To = dec.To
    96  	}
    97  	if dec.Input != nil {
    98  		c.Input = *dec.Input
    99  	}
   100  	if dec.Output != nil {
   101  		c.Output = *dec.Output
   102  	}
   103  	if dec.Error != nil {
   104  		c.Error = *dec.Error
   105  	}
   106  	if dec.RevertReason != nil {
   107  		c.RevertReason = *dec.RevertReason
   108  	}
   109  	if dec.Calls != nil {
   110  		c.Calls = dec.Calls
   111  	}
   112  	if dec.Logs != nil {
   113  		c.Logs = dec.Logs
   114  	}
   115  	if dec.Value != nil {
   116  		c.Value = (*big.Int)(dec.Value)
   117  	}
   118  	return nil
   119  }