github.com/insight-chain/inb-go@v1.1.3-0.20191221022159-da049980ae38/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 "math/big" 9 10 "github.com/insight-chain/inb-go/common" 11 "github.com/insight-chain/inb-go/common/hexutil" 12 ) 13 14 var _ = (*logMarshaling)(nil) 15 16 // MarshalJSON marshals as JSON. 17 func (l Log) MarshalJSON() ([]byte, error) { 18 type Log struct { 19 Address common.Address `json:"address" gencodec:"required"` 20 Topics []common.Hash `json:"topics" gencodec:"required"` 21 Data hexutil.Bytes `json:"data" gencodec:"required"` 22 BlockNumber hexutil.Uint64 `json:"blockNumber"` 23 TxHash common.Hash `json:"transactionHash" gencodec:"required"` 24 TxIndex hexutil.Uint `json:"transactionIndex" gencodec:"required"` 25 BlockHash common.Hash `json:"blockHash"` 26 Index hexutil.Uint `json:"logIndex" gencodec:"required"` 27 Removed bool `json:"removed"` 28 From common.Address `json:"from" gencodec:"required"` 29 To common.Address `json:"to" gencodec:"required"` 30 Amount *big.Int `json:"value" gencodec:"required"` 31 Types TxType `json:"txType" gencodec:"required"` 32 } 33 var enc Log 34 enc.Address = l.Address 35 enc.Topics = l.Topics 36 enc.Data = l.Data 37 enc.BlockNumber = hexutil.Uint64(l.BlockNumber) 38 enc.TxHash = l.TxHash 39 enc.TxIndex = hexutil.Uint(l.TxIndex) 40 enc.BlockHash = l.BlockHash 41 enc.Index = hexutil.Uint(l.Index) 42 enc.Removed = l.Removed 43 enc.From = l.From 44 enc.To = l.To 45 enc.Amount = l.Amount 46 enc.Types = l.TxType 47 return json.Marshal(&enc) 48 } 49 50 // UnmarshalJSON unmarshals from JSON. 51 func (l *Log) UnmarshalJSON(input []byte) error { 52 type Log struct { 53 Address *common.Address `json:"address" gencodec:"required"` 54 Topics []common.Hash `json:"topics" gencodec:"required"` 55 Data *hexutil.Bytes `json:"data" gencodec:"required"` 56 BlockNumber *hexutil.Uint64 `json:"blockNumber"` 57 TxHash *common.Hash `json:"transactionHash" gencodec:"required"` 58 TxIndex *hexutil.Uint `json:"transactionIndex" gencodec:"required"` 59 BlockHash *common.Hash `json:"blockHash"` 60 Index *hexutil.Uint `json:"logIndex" gencodec:"required"` 61 Removed *bool `json:"removed"` 62 From *common.Address `json:"from" gencodec:"required"` 63 To *common.Address `json:"to" gencodec:"required"` 64 Amount *big.Int `json:"value" gencodec:"required"` 65 Types *TxType `json:"txType" gencodec:"required"` 66 } 67 var dec Log 68 if err := json.Unmarshal(input, &dec); err != nil { 69 return err 70 } 71 if dec.Address == nil { 72 return errors.New("missing required field 'address' for Log") 73 } 74 l.Address = *dec.Address 75 if dec.Topics == nil { 76 return errors.New("missing required field 'topics' for Log") 77 } 78 l.Topics = dec.Topics 79 if dec.Data == nil { 80 return errors.New("missing required field 'data' for Log") 81 } 82 l.Data = *dec.Data 83 if dec.BlockNumber != nil { 84 l.BlockNumber = uint64(*dec.BlockNumber) 85 } 86 if dec.TxHash == nil { 87 return errors.New("missing required field 'transactionHash' for Log") 88 } 89 l.TxHash = *dec.TxHash 90 if dec.TxIndex == nil { 91 return errors.New("missing required field 'transactionIndex' for Log") 92 } 93 l.TxIndex = uint(*dec.TxIndex) 94 if dec.BlockHash != nil { 95 l.BlockHash = *dec.BlockHash 96 } 97 if dec.Index == nil { 98 return errors.New("missing required field 'logIndex' for Log") 99 } 100 l.Index = uint(*dec.Index) 101 if dec.Removed != nil { 102 l.Removed = *dec.Removed 103 } 104 if dec.From == nil { 105 return errors.New("missing required field 'from' for Log") 106 } 107 l.From = *dec.From 108 if dec.To == nil { 109 return errors.New("missing required field 'to' for Log") 110 } 111 l.To = *dec.To 112 if dec.Amount == nil { 113 return errors.New("missing required field 'value' for Log") 114 } 115 l.Amount = dec.Amount 116 if dec.Types == nil { 117 return errors.New("missing required field 'txType' for Log") 118 } 119 l.TxType = *dec.Types 120 return nil 121 }