github.com/carter-ya/go-ethereum@v0.0.0-20230628080049-d2309be3983b/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/ethereum/go-ethereum/common"
    10  	"github.com/ethereum/go-ethereum/common/hexutil"
    11  	"github.com/ethereum/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  		Type       vm.OpCode      `json:"-"`
    20  		From       common.Address `json:"from"`
    21  		Gas        hexutil.Uint64 `json:"gas"`
    22  		GasUsed    hexutil.Uint64 `json:"gasUsed"`
    23  		To         common.Address `json:"to,omitempty" rlp:"optional"`
    24  		Input      hexutil.Bytes  `json:"input" rlp:"optional"`
    25  		Output     hexutil.Bytes  `json:"output,omitempty" rlp:"optional"`
    26  		Error      string         `json:"error,omitempty" rlp:"optional"`
    27  		Revertal   string         `json:"revertReason,omitempty"`
    28  		Calls      []callFrame    `json:"calls,omitempty" rlp:"optional"`
    29  		Value      *hexutil.Big   `json:"value,omitempty" rlp:"optional"`
    30  		TypeString string         `json:"type"`
    31  	}
    32  	var enc callFrame0
    33  	enc.Type = c.Type
    34  	enc.From = c.From
    35  	enc.Gas = hexutil.Uint64(c.Gas)
    36  	enc.GasUsed = hexutil.Uint64(c.GasUsed)
    37  	enc.To = c.To
    38  	enc.Input = c.Input
    39  	enc.Output = c.Output
    40  	enc.Error = c.Error
    41  	enc.Revertal = c.Revertal
    42  	enc.Calls = c.Calls
    43  	enc.Value = (*hexutil.Big)(c.Value)
    44  	enc.TypeString = c.TypeString()
    45  	return json.Marshal(&enc)
    46  }
    47  
    48  // UnmarshalJSON unmarshals from JSON.
    49  func (c *callFrame) UnmarshalJSON(input []byte) error {
    50  	type callFrame0 struct {
    51  		Type     *vm.OpCode      `json:"-"`
    52  		From     *common.Address `json:"from"`
    53  		Gas      *hexutil.Uint64 `json:"gas"`
    54  		GasUsed  *hexutil.Uint64 `json:"gasUsed"`
    55  		To       *common.Address `json:"to,omitempty" rlp:"optional"`
    56  		Input    *hexutil.Bytes  `json:"input" rlp:"optional"`
    57  		Output   *hexutil.Bytes  `json:"output,omitempty" rlp:"optional"`
    58  		Error    *string         `json:"error,omitempty" rlp:"optional"`
    59  		Revertal *string         `json:"revertReason,omitempty"`
    60  		Calls    []callFrame     `json:"calls,omitempty" rlp:"optional"`
    61  		Value    *hexutil.Big    `json:"value,omitempty" rlp:"optional"`
    62  	}
    63  	var dec callFrame0
    64  	if err := json.Unmarshal(input, &dec); err != nil {
    65  		return err
    66  	}
    67  	if dec.Type != nil {
    68  		c.Type = *dec.Type
    69  	}
    70  	if dec.From != nil {
    71  		c.From = *dec.From
    72  	}
    73  	if dec.Gas != nil {
    74  		c.Gas = uint64(*dec.Gas)
    75  	}
    76  	if dec.GasUsed != nil {
    77  		c.GasUsed = uint64(*dec.GasUsed)
    78  	}
    79  	if dec.To != nil {
    80  		c.To = *dec.To
    81  	}
    82  	if dec.Input != nil {
    83  		c.Input = *dec.Input
    84  	}
    85  	if dec.Output != nil {
    86  		c.Output = *dec.Output
    87  	}
    88  	if dec.Error != nil {
    89  		c.Error = *dec.Error
    90  	}
    91  	if dec.Revertal != nil {
    92  		c.Revertal = *dec.Revertal
    93  	}
    94  	if dec.Calls != nil {
    95  		c.Calls = dec.Calls
    96  	}
    97  	if dec.Value != nil {
    98  		c.Value = (*big.Int)(dec.Value)
    99  	}
   100  	return nil
   101  }