github.com/Cleverse/go-ethereum@v0.0.0-20220927095127-45113064e7f2/tests/gen_sttransaction.go (about)

     1  // Code generated by github.com/fjl/gencodec. DO NOT EDIT.
     2  
     3  package tests
     4  
     5  import (
     6  	"encoding/json"
     7  	"math/big"
     8  
     9  	"github.com/ethereum/go-ethereum/common/hexutil"
    10  	"github.com/ethereum/go-ethereum/common/math"
    11  	"github.com/ethereum/go-ethereum/core/types"
    12  )
    13  
    14  var _ = (*stTransactionMarshaling)(nil)
    15  
    16  // MarshalJSON marshals as JSON.
    17  func (s stTransaction) MarshalJSON() ([]byte, error) {
    18  	type stTransaction struct {
    19  		GasPrice             *math.HexOrDecimal256 `json:"gasPrice"`
    20  		MaxFeePerGas         *math.HexOrDecimal256 `json:"maxFeePerGas"`
    21  		MaxPriorityFeePerGas *math.HexOrDecimal256 `json:"maxPriorityFeePerGas"`
    22  		Nonce                math.HexOrDecimal64   `json:"nonce"`
    23  		To                   string                `json:"to"`
    24  		Data                 []string              `json:"data"`
    25  		AccessLists          []*types.AccessList   `json:"accessLists,omitempty"`
    26  		GasLimit             []math.HexOrDecimal64 `json:"gasLimit"`
    27  		Value                []string              `json:"value"`
    28  		PrivateKey           hexutil.Bytes         `json:"secretKey"`
    29  	}
    30  	var enc stTransaction
    31  	enc.GasPrice = (*math.HexOrDecimal256)(s.GasPrice)
    32  	enc.MaxFeePerGas = (*math.HexOrDecimal256)(s.MaxFeePerGas)
    33  	enc.MaxPriorityFeePerGas = (*math.HexOrDecimal256)(s.MaxPriorityFeePerGas)
    34  	enc.Nonce = math.HexOrDecimal64(s.Nonce)
    35  	enc.To = s.To
    36  	enc.Data = s.Data
    37  	enc.AccessLists = s.AccessLists
    38  	if s.GasLimit != nil {
    39  		enc.GasLimit = make([]math.HexOrDecimal64, len(s.GasLimit))
    40  		for k, v := range s.GasLimit {
    41  			enc.GasLimit[k] = math.HexOrDecimal64(v)
    42  		}
    43  	}
    44  	enc.Value = s.Value
    45  	enc.PrivateKey = s.PrivateKey
    46  	return json.Marshal(&enc)
    47  }
    48  
    49  // UnmarshalJSON unmarshals from JSON.
    50  func (s *stTransaction) UnmarshalJSON(input []byte) error {
    51  	type stTransaction struct {
    52  		GasPrice             *math.HexOrDecimal256 `json:"gasPrice"`
    53  		MaxFeePerGas         *math.HexOrDecimal256 `json:"maxFeePerGas"`
    54  		MaxPriorityFeePerGas *math.HexOrDecimal256 `json:"maxPriorityFeePerGas"`
    55  		Nonce                *math.HexOrDecimal64  `json:"nonce"`
    56  		To                   *string               `json:"to"`
    57  		Data                 []string              `json:"data"`
    58  		AccessLists          []*types.AccessList   `json:"accessLists,omitempty"`
    59  		GasLimit             []math.HexOrDecimal64 `json:"gasLimit"`
    60  		Value                []string              `json:"value"`
    61  		PrivateKey           *hexutil.Bytes        `json:"secretKey"`
    62  	}
    63  	var dec stTransaction
    64  	if err := json.Unmarshal(input, &dec); err != nil {
    65  		return err
    66  	}
    67  	if dec.GasPrice != nil {
    68  		s.GasPrice = (*big.Int)(dec.GasPrice)
    69  	}
    70  	if dec.MaxFeePerGas != nil {
    71  		s.MaxFeePerGas = (*big.Int)(dec.MaxFeePerGas)
    72  	}
    73  	if dec.MaxPriorityFeePerGas != nil {
    74  		s.MaxPriorityFeePerGas = (*big.Int)(dec.MaxPriorityFeePerGas)
    75  	}
    76  	if dec.Nonce != nil {
    77  		s.Nonce = uint64(*dec.Nonce)
    78  	}
    79  	if dec.To != nil {
    80  		s.To = *dec.To
    81  	}
    82  	if dec.Data != nil {
    83  		s.Data = dec.Data
    84  	}
    85  	if dec.AccessLists != nil {
    86  		s.AccessLists = dec.AccessLists
    87  	}
    88  	if dec.GasLimit != nil {
    89  		s.GasLimit = make([]uint64, len(dec.GasLimit))
    90  		for k, v := range dec.GasLimit {
    91  			s.GasLimit[k] = uint64(v)
    92  		}
    93  	}
    94  	if dec.Value != nil {
    95  		s.Value = dec.Value
    96  	}
    97  	if dec.PrivateKey != nil {
    98  		s.PrivateKey = *dec.PrivateKey
    99  	}
   100  	return nil
   101  }