github.com/insight-chain/inb-go@v1.1.3-0.20191221022159-da049980ae38/core/types/gen_receipt_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 "github.com/insight-chain/inb-go/common" 9 "github.com/insight-chain/inb-go/common/hexutil" 10 "math/big" 11 ) 12 13 var _ = (*receiptMarshaling)(nil) 14 15 // MarshalJSON marshals as JSON. 16 func (r Receipt) MarshalJSON() ([]byte, error) { 17 type Receipt struct { 18 PostState hexutil.Bytes `json:"root"` 19 Status hexutil.Uint64 `json:"status"` 20 CumulativeResUsed hexutil.Uint64 `json:"cumulativeResUsed" gencodec:"required"` 21 Bloom Bloom `json:"logsBloom" gencodec:"required"` 22 Logs []*Log `json:"logs" gencodec:"required"` 23 TxHash common.Hash `json:"transactionHash" gencodec:"required"` 24 ContractAddress common.Address `json:"contractAddress"` 25 Value *big.Int `json:"value" gencodec:"required"` //2019.8.1 inb by ghy 26 ResUsed hexutil.Uint64 `json:"resUsed" gencodec:"required"` 27 } 28 var enc Receipt 29 enc.PostState = r.PostState 30 enc.Status = hexutil.Uint64(r.Status) 31 enc.CumulativeResUsed = hexutil.Uint64(r.CumulativeResUsed) 32 enc.Bloom = r.Bloom 33 enc.Logs = r.Logs 34 enc.TxHash = r.TxHash 35 enc.ContractAddress = r.ContractAddress 36 enc.Value = r.Value //2019.8.1 inb by ghy 37 enc.ResUsed = hexutil.Uint64(r.ResUsed) 38 39 return json.Marshal(&enc) 40 } 41 42 // UnmarshalJSON unmarshals from JSON. 43 func (r *Receipt) UnmarshalJSON(input []byte) error { 44 type Receipt struct { 45 PostState *hexutil.Bytes `json:"root"` 46 Status *hexutil.Uint64 `json:"status"` 47 CumulativeResUsed *hexutil.Uint64 `json:"cumulativeResUsed" gencodec:"required"` 48 Bloom *Bloom `json:"logsBloom" gencodec:"required"` 49 Logs []*Log `json:"logs" gencodec:"required"` 50 TxHash *common.Hash `json:"transactionHash" gencodec:"required"` 51 ContractAddress *common.Address `json:"contractAddress"` 52 Value *big.Int `json:"value" gencodec:"required"` //2019.8.1 inb by ghy 53 ResUsed *hexutil.Uint64 `json:"resUsed" gencodec:"required"` 54 } 55 var dec Receipt 56 if err := json.Unmarshal(input, &dec); err != nil { 57 return err 58 } 59 if dec.PostState != nil { 60 r.PostState = *dec.PostState 61 } 62 if dec.Status != nil { 63 r.Status = uint64(*dec.Status) 64 } 65 if dec.CumulativeResUsed == nil { 66 return errors.New("missing required field 'cumulativeResUsed' for Receipt") 67 } 68 r.CumulativeResUsed = uint64(*dec.CumulativeResUsed) 69 if dec.Bloom == nil { 70 return errors.New("missing required field 'logsBloom' for Receipt") 71 } 72 r.Bloom = *dec.Bloom 73 if dec.Logs == nil { 74 return errors.New("missing required field 'logs' for Receipt") 75 } 76 r.Logs = dec.Logs 77 if dec.TxHash == nil { 78 return errors.New("missing required field 'transactionHash' for Receipt") 79 } 80 r.TxHash = *dec.TxHash 81 if dec.ContractAddress != nil { 82 r.ContractAddress = *dec.ContractAddress 83 } 84 if dec.ResUsed == nil { 85 return errors.New("missing required field 'resUsed' for Receipt") 86 } 87 r.ResUsed = uint64(*dec.ResUsed) 88 if dec.Value == nil { 89 return errors.New("missing required field 'value' for Receipt") 90 } 91 r.Value = dec.Value //2019.8.1 inb by ghy 92 93 return nil 94 }