This commit is contained in:
mayakalpana1 2024-07-15 20:33:32 +08:00
parent 5c8f66ebb4
commit ce4bf5618e
2 changed files with 26 additions and 19 deletions

View file

@ -31,6 +31,7 @@ func (r Receipt) MarshalJSON() ([]byte, error) {
BlockHash common.Hash `json:"blockHash,omitempty"`
BlockNumber *hexutil.Big `json:"blockNumber,omitempty"`
TransactionIndex hexutil.Uint `json:"transactionIndex"`
To *common.Address `json:"to"`
}
var enc Receipt
enc.Type = hexutil.Uint64(r.Type)
@ -48,6 +49,7 @@ func (r Receipt) MarshalJSON() ([]byte, error) {
enc.BlockHash = r.BlockHash
enc.BlockNumber = (*hexutil.Big)(r.BlockNumber)
enc.TransactionIndex = hexutil.Uint(r.TransactionIndex)
enc.To = r.To
return json.Marshal(&enc)
}
@ -69,6 +71,7 @@ func (r *Receipt) UnmarshalJSON(input []byte) error {
BlockHash *common.Hash `json:"blockHash,omitempty"`
BlockNumber *hexutil.Big `json:"blockNumber,omitempty"`
TransactionIndex *hexutil.Uint `json:"transactionIndex"`
To *common.Address `json:"to"`
}
var dec Receipt
if err := json.Unmarshal(input, &dec); err != nil {
@ -124,5 +127,8 @@ func (r *Receipt) UnmarshalJSON(input []byte) error {
if dec.TransactionIndex != nil {
r.TransactionIndex = uint(*dec.TransactionIndex)
}
if dec.To != nil {
r.To = dec.To
}
return nil
}

View file

@ -71,7 +71,7 @@ type Receipt struct {
BlockHash common.Hash `json:"blockHash,omitempty"`
BlockNumber *big.Int `json:"blockNumber,omitempty"`
TransactionIndex uint `json:"transactionIndex"`
To common.Address `json:"to,omitempty"`
To *common.Address `json:"to"`
}
type receiptMarshaling struct {
@ -85,6 +85,7 @@ type receiptMarshaling struct {
BlobGasPrice *hexutil.Big
BlockNumber *hexutil.Big
TransactionIndex hexutil.Uint
To *common.Address
}
// receiptRLP is the consensus encoding of a receipt.