gen_vmexec.go 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 _ = (*vmExecMarshaling)(nil)
  12. func (v vmExec) MarshalJSON() ([]byte, error) {
  13. type vmExec struct {
  14. Address common.UnprefixedAddress `json:"address" gencodec:"required"`
  15. Caller common.UnprefixedAddress `json:"caller" gencodec:"required"`
  16. Origin common.UnprefixedAddress `json:"origin" gencodec:"required"`
  17. Code hexutil.Bytes `json:"code" gencodec:"required"`
  18. Data hexutil.Bytes `json:"data" gencodec:"required"`
  19. Value *math.HexOrDecimal256 `json:"value" gencodec:"required"`
  20. GasLimit math.HexOrDecimal64 `json:"gas" gencodec:"required"`
  21. GasPrice *math.HexOrDecimal256 `json:"gasPrice" gencodec:"required"`
  22. }
  23. var enc vmExec
  24. enc.Address = common.UnprefixedAddress(v.Address)
  25. enc.Caller = common.UnprefixedAddress(v.Caller)
  26. enc.Origin = common.UnprefixedAddress(v.Origin)
  27. enc.Code = v.Code
  28. enc.Data = v.Data
  29. enc.Value = (*math.HexOrDecimal256)(v.Value)
  30. enc.GasLimit = math.HexOrDecimal64(v.GasLimit)
  31. enc.GasPrice = (*math.HexOrDecimal256)(v.GasPrice)
  32. return json.Marshal(&enc)
  33. }
  34. func (v *vmExec) UnmarshalJSON(input []byte) error {
  35. type vmExec struct {
  36. Address *common.UnprefixedAddress `json:"address" gencodec:"required"`
  37. Caller *common.UnprefixedAddress `json:"caller" gencodec:"required"`
  38. Origin *common.UnprefixedAddress `json:"origin" gencodec:"required"`
  39. Code *hexutil.Bytes `json:"code" gencodec:"required"`
  40. Data *hexutil.Bytes `json:"data" gencodec:"required"`
  41. Value *math.HexOrDecimal256 `json:"value" gencodec:"required"`
  42. GasLimit *math.HexOrDecimal64 `json:"gas" gencodec:"required"`
  43. GasPrice *math.HexOrDecimal256 `json:"gasPrice" gencodec:"required"`
  44. }
  45. var dec vmExec
  46. if err := json.Unmarshal(input, &dec); err != nil {
  47. return err
  48. }
  49. if dec.Address == nil {
  50. return errors.New("missing required field 'address' for vmExec")
  51. }
  52. v.Address = common.Address(*dec.Address)
  53. if dec.Caller == nil {
  54. return errors.New("missing required field 'caller' for vmExec")
  55. }
  56. v.Caller = common.Address(*dec.Caller)
  57. if dec.Origin == nil {
  58. return errors.New("missing required field 'origin' for vmExec")
  59. }
  60. v.Origin = common.Address(*dec.Origin)
  61. if dec.Code == nil {
  62. return errors.New("missing required field 'code' for vmExec")
  63. }
  64. v.Code = *dec.Code
  65. if dec.Data == nil {
  66. return errors.New("missing required field 'data' for vmExec")
  67. }
  68. v.Data = *dec.Data
  69. if dec.Value == nil {
  70. return errors.New("missing required field 'value' for vmExec")
  71. }
  72. v.Value = (*big.Int)(dec.Value)
  73. if dec.GasLimit == nil {
  74. return errors.New("missing required field 'gas' for vmExec")
  75. }
  76. v.GasLimit = uint64(*dec.GasLimit)
  77. if dec.GasPrice == nil {
  78. return errors.New("missing required field 'gasPrice' for vmExec")
  79. }
  80. v.GasPrice = (*big.Int)(dec.GasPrice)
  81. return nil
  82. }