github.com/reapchain/go-reapchain@v0.2.15-0.20210609012950-9735c110c705/core/types/gen_tx_json.go (about)

     1  // Code generated by github.com/fjl/gencodec. DO NOT EDIT.
     2  
     3  package types
     4  
     5  import (
     6  	"encoding/json"
     7  	"errors"
     8  	"math/big"
     9  
    10  	"github.com/ethereum/go-ethereum/common"
    11  	"github.com/ethereum/go-ethereum/common/hexutil"
    12  )
    13  
    14  var _ = (*txdataMarshaling)(nil)
    15  
    16  // MarshalJSON marshals as JSON.
    17  func (t txdata) MarshalJSON() ([]byte, error) {
    18  	type txdata struct {
    19  		AccountNonce hexutil.Uint64  `json:"nonce"      gencodec:"required"`
    20  		Price        *hexutil.Big    `json:"gasPrice"   gencodec:"required"`
    21  		GasLimit     *hexutil.Big    `json:"gas"        gencodec:"required"`
    22  		Recipient    *common.Address `json:"to"         rlp:"nil"`
    23  		Amount       *hexutil.Big    `json:"value"      gencodec:"required"`
    24  		Payload      hexutil.Bytes   `json:"input"      gencodec:"required"`
    25  		Governance   bool            `json:"governance" gencodec:"required"`
    26  		V            *hexutil.Big    `json:"v" gencodec:"required"`
    27  		R            *hexutil.Big    `json:"r" gencodec:"required"`
    28  		S            *hexutil.Big    `json:"s" gencodec:"required"`
    29  		Hash         *common.Hash    `json:"hash" rlp:"-"`
    30  	}
    31  	var enc txdata
    32  	enc.AccountNonce = hexutil.Uint64(t.AccountNonce)
    33  	enc.Price = (*hexutil.Big)(t.Price)
    34  	enc.GasLimit = (*hexutil.Big)(t.GasLimit)
    35  	enc.Recipient = t.Recipient
    36  	enc.Amount = (*hexutil.Big)(t.Amount)
    37  	enc.Payload = t.Payload
    38  	enc.Governance = t.Governance
    39  	enc.V = (*hexutil.Big)(t.V)
    40  	enc.R = (*hexutil.Big)(t.R)
    41  	enc.S = (*hexutil.Big)(t.S)
    42  	enc.Hash = t.Hash
    43  	return json.Marshal(&enc)
    44  }
    45  
    46  // UnmarshalJSON unmarshals from JSON.
    47  func (t *txdata) UnmarshalJSON(input []byte) error {
    48  	type txdata struct {
    49  		AccountNonce *hexutil.Uint64 `json:"nonce"      gencodec:"required"`
    50  		Price        *hexutil.Big    `json:"gasPrice"   gencodec:"required"`
    51  		GasLimit     *hexutil.Big    `json:"gas"        gencodec:"required"`
    52  		Recipient    *common.Address `json:"to"         rlp:"nil"`
    53  		Amount       *hexutil.Big    `json:"value"      gencodec:"required"`
    54  		Payload      *hexutil.Bytes  `json:"input"      gencodec:"required"`
    55  		Governance   *bool           `json:"governance" gencodec:"required"`
    56  		V            *hexutil.Big    `json:"v" gencodec:"required"`
    57  		R            *hexutil.Big    `json:"r" gencodec:"required"`
    58  		S            *hexutil.Big    `json:"s" gencodec:"required"`
    59  		Hash         *common.Hash    `json:"hash" rlp:"-"`
    60  	}
    61  	var dec txdata
    62  	if err := json.Unmarshal(input, &dec); err != nil {
    63  		return err
    64  	}
    65  	if dec.AccountNonce == nil {
    66  		return errors.New("missing required field 'nonce' for txdata")
    67  	}
    68  	t.AccountNonce = uint64(*dec.AccountNonce)
    69  	if dec.Price == nil {
    70  		return errors.New("missing required field 'gasPrice' for txdata")
    71  	}
    72  	t.Price = (*big.Int)(dec.Price)
    73  	if dec.GasLimit == nil {
    74  		return errors.New("missing required field 'gas' for txdata")
    75  	}
    76  	t.GasLimit = (*big.Int)(dec.GasLimit)
    77  	if dec.Recipient != nil {
    78  		t.Recipient = dec.Recipient
    79  	}
    80  	if dec.Amount == nil {
    81  		return errors.New("missing required field 'value' for txdata")
    82  	}
    83  	t.Amount = (*big.Int)(dec.Amount)
    84  	if dec.Payload == nil {
    85  		return errors.New("missing required field 'input' for txdata")
    86  	}
    87  	t.Payload = *dec.Payload
    88  	if dec.Governance == nil {
    89  		return errors.New("missing required field 'governance' for txdata")
    90  	}
    91  	t.Governance = *dec.Governance
    92  	if dec.V == nil {
    93  		return errors.New("missing required field 'v' for txdata")
    94  	}
    95  	t.V = (*big.Int)(dec.V)
    96  	if dec.R == nil {
    97  		return errors.New("missing required field 'r' for txdata")
    98  	}
    99  	t.R = (*big.Int)(dec.R)
   100  	if dec.S == nil {
   101  		return errors.New("missing required field 's' for txdata")
   102  	}
   103  	t.S = (*big.Int)(dec.S)
   104  	if dec.Hash != nil {
   105  		t.Hash = dec.Hash
   106  	}
   107  	return nil
   108  }