gen_sttransaction.go 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. Nonce math.HexOrDecimal64 `json:"nonce"`
  16. To string `json:"to"`
  17. Data []string `json:"data"`
  18. AccessLists []*types.AccessList `json:"accessLists,omitempty"`
  19. GasLimit []math.HexOrDecimal64 `json:"gasLimit"`
  20. Value []string `json:"value"`
  21. PrivateKey hexutil.Bytes `json:"secretKey"`
  22. }
  23. var enc stTransaction
  24. enc.GasPrice = (*math.HexOrDecimal256)(s.GasPrice)
  25. enc.Nonce = math.HexOrDecimal64(s.Nonce)
  26. enc.To = s.To
  27. enc.Data = s.Data
  28. enc.AccessLists = s.AccessLists
  29. if s.GasLimit != nil {
  30. enc.GasLimit = make([]math.HexOrDecimal64, len(s.GasLimit))
  31. for k, v := range s.GasLimit {
  32. enc.GasLimit[k] = math.HexOrDecimal64(v)
  33. }
  34. }
  35. enc.Value = s.Value
  36. enc.PrivateKey = s.PrivateKey
  37. return json.Marshal(&enc)
  38. }
  39. // UnmarshalJSON unmarshals from JSON.
  40. func (s *stTransaction) UnmarshalJSON(input []byte) error {
  41. type stTransaction struct {
  42. GasPrice *math.HexOrDecimal256 `json:"gasPrice"`
  43. Nonce *math.HexOrDecimal64 `json:"nonce"`
  44. To *string `json:"to"`
  45. Data []string `json:"data"`
  46. AccessLists []*types.AccessList `json:"accessLists,omitempty"`
  47. GasLimit []math.HexOrDecimal64 `json:"gasLimit"`
  48. Value []string `json:"value"`
  49. PrivateKey *hexutil.Bytes `json:"secretKey"`
  50. }
  51. var dec stTransaction
  52. if err := json.Unmarshal(input, &dec); err != nil {
  53. return err
  54. }
  55. if dec.GasPrice != nil {
  56. s.GasPrice = (*big.Int)(dec.GasPrice)
  57. }
  58. if dec.Nonce != nil {
  59. s.Nonce = uint64(*dec.Nonce)
  60. }
  61. if dec.To != nil {
  62. s.To = *dec.To
  63. }
  64. if dec.Data != nil {
  65. s.Data = dec.Data
  66. }
  67. if dec.AccessLists != nil {
  68. s.AccessLists = dec.AccessLists
  69. }
  70. if dec.GasLimit != nil {
  71. s.GasLimit = make([]uint64, len(dec.GasLimit))
  72. for k, v := range dec.GasLimit {
  73. s.GasLimit[k] = uint64(v)
  74. }
  75. }
  76. if dec.Value != nil {
  77. s.Value = dec.Value
  78. }
  79. if dec.PrivateKey != nil {
  80. s.PrivateKey = *dec.PrivateKey
  81. }
  82. return nil
  83. }