github.com/niluplatform/go-nilu@v1.7.4-0.20200912082737-a0cb0776d52c/tests/gen_tttransaction.go (about)

     1  // Code generated by github.com/fjl/gencodec. DO NOT EDIT.
     2  
     3  package tests
     4  
     5  import (
     6  	"encoding/json"
     7  	"errors"
     8  	"math/big"
     9  
    10  	"github.com/NiluPlatform/go-nilu/common"
    11  	"github.com/NiluPlatform/go-nilu/common/hexutil"
    12  	"github.com/NiluPlatform/go-nilu/common/math"
    13  )
    14  
    15  var _ = (*ttTransactionMarshaling)(nil)
    16  
    17  func (t ttTransaction) MarshalJSON() ([]byte, error) {
    18  	type ttTransaction struct {
    19  		Data     hexutil.Bytes         `gencodec:"required"`
    20  		GasLimit math.HexOrDecimal64   `gencodec:"required"`
    21  		GasPrice *math.HexOrDecimal256 `gencodec:"required"`
    22  		Nonce    math.HexOrDecimal64   `gencodec:"required"`
    23  		Value    *math.HexOrDecimal256 `gencodec:"required"`
    24  		R        *math.HexOrDecimal256 `gencodec:"required"`
    25  		S        *math.HexOrDecimal256 `gencodec:"required"`
    26  		V        *math.HexOrDecimal256 `gencodec:"required"`
    27  		To       common.Address        `gencodec:"required"`
    28  	}
    29  	var enc ttTransaction
    30  	enc.Data = t.Data
    31  	enc.GasLimit = math.HexOrDecimal64(t.GasLimit)
    32  	enc.GasPrice = (*math.HexOrDecimal256)(t.GasPrice)
    33  	enc.Nonce = math.HexOrDecimal64(t.Nonce)
    34  	enc.Value = (*math.HexOrDecimal256)(t.Value)
    35  	enc.R = (*math.HexOrDecimal256)(t.R)
    36  	enc.S = (*math.HexOrDecimal256)(t.S)
    37  	enc.V = (*math.HexOrDecimal256)(t.V)
    38  	enc.To = t.To
    39  	return json.Marshal(&enc)
    40  }
    41  
    42  func (t *ttTransaction) UnmarshalJSON(input []byte) error {
    43  	type ttTransaction struct {
    44  		Data     *hexutil.Bytes        `gencodec:"required"`
    45  		GasLimit *math.HexOrDecimal64  `gencodec:"required"`
    46  		GasPrice *math.HexOrDecimal256 `gencodec:"required"`
    47  		Nonce    *math.HexOrDecimal64  `gencodec:"required"`
    48  		Value    *math.HexOrDecimal256 `gencodec:"required"`
    49  		R        *math.HexOrDecimal256 `gencodec:"required"`
    50  		S        *math.HexOrDecimal256 `gencodec:"required"`
    51  		V        *math.HexOrDecimal256 `gencodec:"required"`
    52  		To       *common.Address       `gencodec:"required"`
    53  	}
    54  	var dec ttTransaction
    55  	if err := json.Unmarshal(input, &dec); err != nil {
    56  		return err
    57  	}
    58  	if dec.Data == nil {
    59  		return errors.New("missing required field 'data' for ttTransaction")
    60  	}
    61  	t.Data = *dec.Data
    62  	if dec.GasLimit == nil {
    63  		return errors.New("missing required field 'gasLimit' for ttTransaction")
    64  	}
    65  	t.GasLimit = uint64(*dec.GasLimit)
    66  	if dec.GasPrice == nil {
    67  		return errors.New("missing required field 'gasPrice' for ttTransaction")
    68  	}
    69  	t.GasPrice = (*big.Int)(dec.GasPrice)
    70  	if dec.Nonce == nil {
    71  		return errors.New("missing required field 'nonce' for ttTransaction")
    72  	}
    73  	t.Nonce = uint64(*dec.Nonce)
    74  	if dec.Value == nil {
    75  		return errors.New("missing required field 'value' for ttTransaction")
    76  	}
    77  	t.Value = (*big.Int)(dec.Value)
    78  	if dec.R == nil {
    79  		return errors.New("missing required field 'r' for ttTransaction")
    80  	}
    81  	t.R = (*big.Int)(dec.R)
    82  	if dec.S == nil {
    83  		return errors.New("missing required field 's' for ttTransaction")
    84  	}
    85  	t.S = (*big.Int)(dec.S)
    86  	if dec.V == nil {
    87  		return errors.New("missing required field 'v' for ttTransaction")
    88  	}
    89  	t.V = (*big.Int)(dec.V)
    90  	if dec.To == nil {
    91  		return errors.New("missing required field 'to' for ttTransaction")
    92  	}
    93  	t.To = *dec.To
    94  	return nil
    95  }