github.com/edxfund/masterchain@v1.8.16-0.20190112084457-6ad8bdd0f74a/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/EDXFund/MasterChain/common" 10 ) 11 12 // MarshalJSON marshals as JSON. 13 func (l Log) MarshalJSON() ([]byte, error) { 14 type Log struct { 15 Address common.Address `json:"address" gencodec:"required"` 16 Topics []common.Hash `json:"topics" gencodec:"required"` 17 Data []byte `json:"data" gencodec:"required"` 18 TxHash common.Hash `json:"transactionHash" gencodec:"required"` 19 ShardId uint64 20 BlockNumberOfShard uint64 `json:"blockNumber"` 21 TxIndexInShard uint `json:"transactionIndex" gencodec:"required"` 22 BlockHashOfShard common.Hash `json:"blockHash"` 23 LogIndexInMaster uint `json:"logIndex" gencodec:"required"` 24 MasterBlockNumber uint64 `json:"blockNumber"` 25 ShardIndexInMaster uint `json:"shardIndex" gencodec:"required"` 26 BlockHashOfMaster common.Hash `json:"blockHash"` 27 Removed bool `json:"removed"` 28 } 29 var enc Log 30 enc.Address = l.Address 31 enc.Topics = l.Topics 32 enc.Data = l.Data 33 enc.TxHash = l.TxHash 34 enc.ShardId = l.ShardId 35 enc.BlockNumberOfShard = l.BlockNumberOfShard 36 enc.TxIndexInShard = l.TxIndexInShard 37 enc.BlockHashOfShard = l.BlockHashOfShard 38 enc.LogIndexInMaster = l.LogIndexInMaster 39 enc.MasterBlockNumber = l.MasterBlockNumber 40 enc.ShardIndexInMaster = l.ShardIndexInMaster 41 enc.BlockHashOfMaster = l.BlockHashOfMaster 42 enc.Removed = l.Removed 43 return json.Marshal(&enc) 44 } 45 46 // UnmarshalJSON unmarshals from JSON. 47 func (l *Log) UnmarshalJSON(input []byte) error { 48 type Log struct { 49 Address *common.Address `json:"address" gencodec:"required"` 50 Topics []common.Hash `json:"topics" gencodec:"required"` 51 Data []byte `json:"data" gencodec:"required"` 52 TxHash *common.Hash `json:"transactionHash" gencodec:"required"` 53 ShardId *uint64 54 BlockNumberOfShard *uint64 `json:"blockNumber"` 55 TxIndexInShard *uint `json:"transactionIndex" gencodec:"required"` 56 BlockHashOfShard *common.Hash `json:"blockHash"` 57 LogIndexInMaster *uint `json:"logIndex" gencodec:"required"` 58 MasterBlockNumber *uint64 `json:"blockNumber"` 59 ShardIndexInMaster *uint `json:"shardIndex" gencodec:"required"` 60 BlockHashOfMaster *common.Hash `json:"blockHash"` 61 Removed *bool `json:"removed"` 62 } 63 var dec Log 64 if err := json.Unmarshal(input, &dec); err != nil { 65 return err 66 } 67 if dec.Address == nil { 68 return errors.New("missing required field 'address' for Log") 69 } 70 l.Address = *dec.Address 71 if dec.Topics == nil { 72 return errors.New("missing required field 'topics' for Log") 73 } 74 l.Topics = dec.Topics 75 if dec.Data == nil { 76 return errors.New("missing required field 'data' for Log") 77 } 78 l.Data = dec.Data 79 if dec.TxHash == nil { 80 return errors.New("missing required field 'transactionHash' for Log") 81 } 82 l.TxHash = *dec.TxHash 83 if dec.ShardId != nil { 84 l.ShardId = *dec.ShardId 85 } 86 if dec.BlockNumberOfShard != nil { 87 l.BlockNumberOfShard = *dec.BlockNumberOfShard 88 } 89 if dec.TxIndexInShard == nil { 90 return errors.New("missing required field 'transactionIndex' for Log") 91 } 92 l.TxIndexInShard = *dec.TxIndexInShard 93 if dec.BlockHashOfShard != nil { 94 l.BlockHashOfShard = *dec.BlockHashOfShard 95 } 96 if dec.LogIndexInMaster == nil { 97 return errors.New("missing required field 'logIndex' for Log") 98 } 99 l.LogIndexInMaster = *dec.LogIndexInMaster 100 if dec.MasterBlockNumber != nil { 101 l.MasterBlockNumber = *dec.MasterBlockNumber 102 } 103 if dec.ShardIndexInMaster == nil { 104 return errors.New("missing required field 'shardIndex' for Log") 105 } 106 l.ShardIndexInMaster = *dec.ShardIndexInMaster 107 if dec.BlockHashOfMaster != nil { 108 l.BlockHashOfMaster = *dec.BlockHashOfMaster 109 } 110 if dec.Removed != nil { 111 l.Removed = *dec.Removed 112 } 113 return nil 114 }