gen_sttransaction.go 3.2 KB

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