github.com/Ethersocial/go-esn@v0.3.7/core/types/gen_log_json.go (about) 1 // Code generated by github.com/fjl/gencodec. DO NOT EDIT. 2 3 package types 4 5 import ( 6 "encoding/json" 7 "errors" 8 9 "github.com/ethersocial/go-esn/common" 10 "github.com/ethersocial/go-esn/common/hexutil" 11 ) 12 13 var _ = (*logMarshaling)(nil) 14 15 func (l Log) MarshalJSON() ([]byte, error) { 16 type Log struct { 17 Address common.Address `json:"address" gencodec:"required"` 18 Topics []common.Hash `json:"topics" gencodec:"required"` 19 Data hexutil.Bytes `json:"data" gencodec:"required"` 20 BlockNumber hexutil.Uint64 `json:"blockNumber"` 21 TxHash common.Hash `json:"transactionHash" gencodec:"required"` 22 TxIndex hexutil.Uint `json:"transactionIndex" gencodec:"required"` 23 BlockHash common.Hash `json:"blockHash"` 24 Index hexutil.Uint `json:"logIndex" gencodec:"required"` 25 Removed bool `json:"removed"` 26 } 27 var enc Log 28 enc.Address = l.Address 29 enc.Topics = l.Topics 30 enc.Data = l.Data 31 enc.BlockNumber = hexutil.Uint64(l.BlockNumber) 32 enc.TxHash = l.TxHash 33 enc.TxIndex = hexutil.Uint(l.TxIndex) 34 enc.BlockHash = l.BlockHash 35 enc.Index = hexutil.Uint(l.Index) 36 enc.Removed = l.Removed 37 return json.Marshal(&enc) 38 } 39 40 func (l *Log) UnmarshalJSON(input []byte) error { 41 type Log struct { 42 Address *common.Address `json:"address" gencodec:"required"` 43 Topics []common.Hash `json:"topics" gencodec:"required"` 44 Data *hexutil.Bytes `json:"data" gencodec:"required"` 45 BlockNumber *hexutil.Uint64 `json:"blockNumber"` 46 TxHash *common.Hash `json:"transactionHash" gencodec:"required"` 47 TxIndex *hexutil.Uint `json:"transactionIndex" gencodec:"required"` 48 BlockHash *common.Hash `json:"blockHash"` 49 Index *hexutil.Uint `json:"logIndex" gencodec:"required"` 50 Removed *bool `json:"removed"` 51 } 52 var dec Log 53 if err := json.Unmarshal(input, &dec); err != nil { 54 return err 55 } 56 if dec.Address == nil { 57 return errors.New("missing required field 'address' for Log") 58 } 59 l.Address = *dec.Address 60 if dec.Topics == nil { 61 return errors.New("missing required field 'topics' for Log") 62 } 63 l.Topics = dec.Topics 64 if dec.Data == nil { 65 return errors.New("missing required field 'data' for Log") 66 } 67 l.Data = *dec.Data 68 if dec.BlockNumber != nil { 69 l.BlockNumber = uint64(*dec.BlockNumber) 70 } 71 if dec.TxHash == nil { 72 return errors.New("missing required field 'transactionHash' for Log") 73 } 74 l.TxHash = *dec.TxHash 75 if dec.TxIndex == nil { 76 return errors.New("missing required field 'transactionIndex' for Log") 77 } 78 l.TxIndex = uint(*dec.TxIndex) 79 if dec.BlockHash != nil { 80 l.BlockHash = *dec.BlockHash 81 } 82 if dec.Index == nil { 83 return errors.New("missing required field 'logIndex' for Log") 84 } 85 l.Index = uint(*dec.Index) 86 if dec.Removed != nil { 87 l.Removed = *dec.Removed 88 } 89 return nil 90 }