gen_stlog.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // Code generated by github.com/fjl/gencodec. DO NOT EDIT.
  2. package tests
  3. import (
  4. "encoding/json"
  5. "github.com/ethereum/go-ethereum/common"
  6. "github.com/ethereum/go-ethereum/common/hexutil"
  7. )
  8. var _ = (*stLogMarshaling)(nil)
  9. func (s stLog) MarshalJSON() ([]byte, error) {
  10. type stLog struct {
  11. Address common.UnprefixedAddress `json:"address"`
  12. Data hexutil.Bytes `json:"data"`
  13. Topics []common.UnprefixedHash `json:"topics"`
  14. Bloom string `json:"bloom"`
  15. }
  16. var enc stLog
  17. enc.Address = common.UnprefixedAddress(s.Address)
  18. enc.Data = s.Data
  19. if s.Topics != nil {
  20. enc.Topics = make([]common.UnprefixedHash, len(s.Topics))
  21. for k, v := range s.Topics {
  22. enc.Topics[k] = common.UnprefixedHash(v)
  23. }
  24. }
  25. enc.Bloom = s.Bloom
  26. return json.Marshal(&enc)
  27. }
  28. func (s *stLog) UnmarshalJSON(input []byte) error {
  29. type stLog struct {
  30. Address *common.UnprefixedAddress `json:"address"`
  31. Data hexutil.Bytes `json:"data"`
  32. Topics []common.UnprefixedHash `json:"topics"`
  33. Bloom *string `json:"bloom"`
  34. }
  35. var dec stLog
  36. if err := json.Unmarshal(input, &dec); err != nil {
  37. return err
  38. }
  39. if dec.Address != nil {
  40. s.Address = common.Address(*dec.Address)
  41. }
  42. if dec.Data != nil {
  43. s.Data = dec.Data
  44. }
  45. if dec.Topics != nil {
  46. s.Topics = make([]common.Hash, len(dec.Topics))
  47. for k, v := range dec.Topics {
  48. s.Topics[k] = common.Hash(v)
  49. }
  50. }
  51. if dec.Bloom != nil {
  52. s.Bloom = *dec.Bloom
  53. }
  54. return nil
  55. }