github.com/EgonCoin/EgonChain@v1.10.16/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 "math/big" 9 10 "github.com/EgonCoin/EgonChain/common" 11 "github.com/EgonCoin/EgonChain/common/hexutil" 12 ) 13 14 var _ = (*receiptMarshaling)(nil) 15 16 // MarshalJSON marshals as JSON. 17 func (r Receipt) MarshalJSON() ([]byte, error) { 18 type Receipt struct { 19 Type hexutil.Uint64 `json:"type,omitempty"` 20 PostState hexutil.Bytes `json:"root"` 21 Status hexutil.Uint64 `json:"status"` 22 CumulativeGasUsed hexutil.Uint64 `json:"cumulativeGasUsed" gencodec:"required"` 23 Bloom Bloom `json:"logsBloom" gencodec:"required"` 24 Logs []*Log `json:"logs" gencodec:"required"` 25 TxHash common.Hash `json:"transactionHash" gencodec:"required"` 26 ContractAddress common.Address `json:"contractAddress"` 27 GasUsed hexutil.Uint64 `json:"gasUsed" gencodec:"required"` 28 BlockHash common.Hash `json:"blockHash,omitempty"` 29 BlockNumber *hexutil.Big `json:"blockNumber,omitempty"` 30 TransactionIndex hexutil.Uint `json:"transactionIndex"` 31 } 32 var enc Receipt 33 enc.Type = hexutil.Uint64(r.Type) 34 enc.PostState = r.PostState 35 enc.Status = hexutil.Uint64(r.Status) 36 enc.CumulativeGasUsed = hexutil.Uint64(r.CumulativeGasUsed) 37 enc.Bloom = r.Bloom 38 enc.Logs = r.Logs 39 enc.TxHash = r.TxHash 40 enc.ContractAddress = r.ContractAddress 41 enc.GasUsed = hexutil.Uint64(r.GasUsed) 42 enc.BlockHash = r.BlockHash 43 enc.BlockNumber = (*hexutil.Big)(r.BlockNumber) 44 enc.TransactionIndex = hexutil.Uint(r.TransactionIndex) 45 return json.Marshal(&enc) 46 } 47 48 // UnmarshalJSON unmarshals from JSON. 49 func (r *Receipt) UnmarshalJSON(input []byte) error { 50 type Receipt struct { 51 Type *hexutil.Uint64 `json:"type,omitempty"` 52 PostState *hexutil.Bytes `json:"root"` 53 Status *hexutil.Uint64 `json:"status"` 54 CumulativeGasUsed *hexutil.Uint64 `json:"cumulativeGasUsed" gencodec:"required"` 55 Bloom *Bloom `json:"logsBloom" gencodec:"required"` 56 Logs []*Log `json:"logs" gencodec:"required"` 57 TxHash *common.Hash `json:"transactionHash" gencodec:"required"` 58 ContractAddress *common.Address `json:"contractAddress"` 59 GasUsed *hexutil.Uint64 `json:"gasUsed" gencodec:"required"` 60 BlockHash *common.Hash `json:"blockHash,omitempty"` 61 BlockNumber *hexutil.Big `json:"blockNumber,omitempty"` 62 TransactionIndex *hexutil.Uint `json:"transactionIndex"` 63 } 64 var dec Receipt 65 if err := json.Unmarshal(input, &dec); err != nil { 66 return err 67 } 68 if dec.Type != nil { 69 r.Type = uint8(*dec.Type) 70 } 71 if dec.PostState != nil { 72 r.PostState = *dec.PostState 73 } 74 if dec.Status != nil { 75 r.Status = uint64(*dec.Status) 76 } 77 if dec.CumulativeGasUsed == nil { 78 return errors.New("missing required field 'cumulativeGasUsed' for Receipt") 79 } 80 r.CumulativeGasUsed = uint64(*dec.CumulativeGasUsed) 81 if dec.Bloom == nil { 82 return errors.New("missing required field 'logsBloom' for Receipt") 83 } 84 r.Bloom = *dec.Bloom 85 if dec.Logs == nil { 86 return errors.New("missing required field 'logs' for Receipt") 87 } 88 r.Logs = dec.Logs 89 if dec.TxHash == nil { 90 return errors.New("missing required field 'transactionHash' for Receipt") 91 } 92 r.TxHash = *dec.TxHash 93 if dec.ContractAddress != nil { 94 r.ContractAddress = *dec.ContractAddress 95 } 96 if dec.GasUsed == nil { 97 return errors.New("missing required field 'gasUsed' for Receipt") 98 } 99 r.GasUsed = uint64(*dec.GasUsed) 100 if dec.BlockHash != nil { 101 r.BlockHash = *dec.BlockHash 102 } 103 if dec.BlockNumber != nil { 104 r.BlockNumber = (*big.Int)(dec.BlockNumber) 105 } 106 if dec.TransactionIndex != nil { 107 r.TransactionIndex = uint(*dec.TransactionIndex) 108 } 109 return nil 110 }