gen_tttransaction.go 3.0 KB

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