github.com/ethereum/go-ethereum@v1.16.1/eth/tracers/native/gen_callframewithopcodes_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 _ = (*callFrameWithOpcodesMarshaling)(nil)
    15  
    16  // MarshalJSON marshals as JSON.
    17  func (c callFrameWithOpcodes) MarshalJSON() ([]byte, error) {
    18  	type callFrameWithOpcodes0 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  		RevertReason      string                                     `json:"revertReason,omitempty"`
    28  		Logs              []callLog                                  `json:"logs,omitempty" rlp:"optional"`
    29  		Value             *hexutil.Big                               `json:"value,omitempty" rlp:"optional"`
    30  		AccessedSlots     accessedSlots                              `json:"accessedSlots"`
    31  		ExtCodeAccessInfo []common.Address                           `json:"extCodeAccessInfo"`
    32  		UsedOpcodes       map[hexutil.Uint64]uint64                  `json:"usedOpcodes"`
    33  		ContractSize      map[common.Address]*contractSizeWithOpcode `json:"contractSize"`
    34  		OutOfGas          bool                                       `json:"outOfGas"`
    35  		KeccakPreimages   []hexutil.Bytes                            `json:"keccak,omitempty"`
    36  		Calls             []callFrameWithOpcodes                     `json:"calls,omitempty" rlp:"optional"`
    37  		TypeString        string                                     `json:"type"`
    38  	}
    39  	var enc callFrameWithOpcodes0
    40  	enc.Type = c.Type
    41  	enc.From = c.From
    42  	enc.Gas = hexutil.Uint64(c.Gas)
    43  	enc.GasUsed = hexutil.Uint64(c.GasUsed)
    44  	enc.To = c.To
    45  	enc.Input = c.Input
    46  	enc.Output = c.Output
    47  	enc.Error = c.Error
    48  	enc.RevertReason = c.RevertReason
    49  	enc.Logs = c.Logs
    50  	enc.Value = (*hexutil.Big)(c.Value)
    51  	enc.AccessedSlots = c.AccessedSlots
    52  	enc.ExtCodeAccessInfo = c.ExtCodeAccessInfo
    53  	if c.UsedOpcodes != nil {
    54  		enc.UsedOpcodes = make(map[hexutil.Uint64]uint64, len(c.UsedOpcodes))
    55  		for k, v := range c.UsedOpcodes {
    56  			enc.UsedOpcodes[hexutil.Uint64(k)] = v
    57  		}
    58  	}
    59  	enc.ContractSize = c.ContractSize
    60  	enc.OutOfGas = c.OutOfGas
    61  	if c.KeccakPreimages != nil {
    62  		enc.KeccakPreimages = make([]hexutil.Bytes, len(c.KeccakPreimages))
    63  		for k, v := range c.KeccakPreimages {
    64  			enc.KeccakPreimages[k] = v
    65  		}
    66  	}
    67  	enc.Calls = c.Calls
    68  	enc.TypeString = c.TypeString()
    69  	return json.Marshal(&enc)
    70  }
    71  
    72  // UnmarshalJSON unmarshals from JSON.
    73  func (c *callFrameWithOpcodes) UnmarshalJSON(input []byte) error {
    74  	type callFrameWithOpcodes0 struct {
    75  		Type              *vm.OpCode                                 `json:"-"`
    76  		From              *common.Address                            `json:"from"`
    77  		Gas               *hexutil.Uint64                            `json:"gas"`
    78  		GasUsed           *hexutil.Uint64                            `json:"gasUsed"`
    79  		To                *common.Address                            `json:"to,omitempty" rlp:"optional"`
    80  		Input             *hexutil.Bytes                             `json:"input" rlp:"optional"`
    81  		Output            *hexutil.Bytes                             `json:"output,omitempty" rlp:"optional"`
    82  		Error             *string                                    `json:"error,omitempty" rlp:"optional"`
    83  		RevertReason      *string                                    `json:"revertReason,omitempty"`
    84  		Logs              []callLog                                  `json:"logs,omitempty" rlp:"optional"`
    85  		Value             *hexutil.Big                               `json:"value,omitempty" rlp:"optional"`
    86  		AccessedSlots     *accessedSlots                             `json:"accessedSlots"`
    87  		ExtCodeAccessInfo []common.Address                           `json:"extCodeAccessInfo"`
    88  		UsedOpcodes       map[hexutil.Uint64]uint64                  `json:"usedOpcodes"`
    89  		ContractSize      map[common.Address]*contractSizeWithOpcode `json:"contractSize"`
    90  		OutOfGas          *bool                                      `json:"outOfGas"`
    91  		KeccakPreimages   []hexutil.Bytes                            `json:"keccak,omitempty"`
    92  		Calls             []callFrameWithOpcodes                     `json:"calls,omitempty" rlp:"optional"`
    93  	}
    94  	var dec callFrameWithOpcodes0
    95  	if err := json.Unmarshal(input, &dec); err != nil {
    96  		return err
    97  	}
    98  	if dec.Type != nil {
    99  		c.Type = *dec.Type
   100  	}
   101  	if dec.From != nil {
   102  		c.From = *dec.From
   103  	}
   104  	if dec.Gas != nil {
   105  		c.Gas = uint64(*dec.Gas)
   106  	}
   107  	if dec.GasUsed != nil {
   108  		c.GasUsed = uint64(*dec.GasUsed)
   109  	}
   110  	if dec.To != nil {
   111  		c.To = dec.To
   112  	}
   113  	if dec.Input != nil {
   114  		c.Input = *dec.Input
   115  	}
   116  	if dec.Output != nil {
   117  		c.Output = *dec.Output
   118  	}
   119  	if dec.Error != nil {
   120  		c.Error = *dec.Error
   121  	}
   122  	if dec.RevertReason != nil {
   123  		c.RevertReason = *dec.RevertReason
   124  	}
   125  	if dec.Logs != nil {
   126  		c.Logs = dec.Logs
   127  	}
   128  	if dec.Value != nil {
   129  		c.Value = (*big.Int)(dec.Value)
   130  	}
   131  	if dec.AccessedSlots != nil {
   132  		c.AccessedSlots = *dec.AccessedSlots
   133  	}
   134  	if dec.ExtCodeAccessInfo != nil {
   135  		c.ExtCodeAccessInfo = dec.ExtCodeAccessInfo
   136  	}
   137  	if dec.UsedOpcodes != nil {
   138  		c.UsedOpcodes = make(map[vm.OpCode]uint64, len(dec.UsedOpcodes))
   139  		for k, v := range dec.UsedOpcodes {
   140  			c.UsedOpcodes[vm.OpCode(k)] = v
   141  		}
   142  	}
   143  	if dec.ContractSize != nil {
   144  		c.ContractSize = dec.ContractSize
   145  	}
   146  	if dec.OutOfGas != nil {
   147  		c.OutOfGas = *dec.OutOfGas
   148  	}
   149  	if dec.KeccakPreimages != nil {
   150  		c.KeccakPreimages = make([][]byte, len(dec.KeccakPreimages))
   151  		for k, v := range dec.KeccakPreimages {
   152  			c.KeccakPreimages[k] = v
   153  		}
   154  	}
   155  	if dec.Calls != nil {
   156  		c.Calls = dec.Calls
   157  	}
   158  	return nil
   159  }