fix return type in tx receipt for l1fee type (#254)

* edit marshalling override

* goimports

* not required

* encode l1fee

---------

Co-authored-by: Péter Garamvölgyi <th307q@gmail.com>
This commit is contained in:
Max Wolff 2023-04-18 20:12:57 -07:00 committed by GitHub
parent 49e755e334
commit 028acecb02
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 8 deletions

View file

@ -29,7 +29,7 @@ func (r Receipt) MarshalJSON() ([]byte, error) {
BlockNumber *hexutil.Big `json:"blockNumber,omitempty"`
TransactionIndex hexutil.Uint `json:"transactionIndex"`
ReturnValue []byte `json:"returnValue,omitempty"`
L1Fee *big.Int `json:"l1Fee" gencodec:"required"`
L1Fee *hexutil.Big `json:"l1Fee,omitempty"`
}
var enc Receipt
enc.Type = hexutil.Uint64(r.Type)
@ -45,7 +45,7 @@ func (r Receipt) MarshalJSON() ([]byte, error) {
enc.BlockNumber = (*hexutil.Big)(r.BlockNumber)
enc.TransactionIndex = hexutil.Uint(r.TransactionIndex)
enc.ReturnValue = r.ReturnValue
enc.L1Fee = r.L1Fee
enc.L1Fee = (*hexutil.Big)(r.L1Fee)
return json.Marshal(&enc)
}
@ -65,7 +65,7 @@ func (r *Receipt) UnmarshalJSON(input []byte) error {
BlockNumber *hexutil.Big `json:"blockNumber,omitempty"`
TransactionIndex *hexutil.Uint `json:"transactionIndex"`
ReturnValue []byte `json:"returnValue,omitempty"`
L1Fee *big.Int `json:"l1Fee" gencodec:"required"`
L1Fee *hexutil.Big `json:"l1Fee,omitempty"`
}
var dec Receipt
if err := json.Unmarshal(input, &dec); err != nil {
@ -115,9 +115,8 @@ func (r *Receipt) UnmarshalJSON(input []byte) error {
if dec.ReturnValue != nil {
r.ReturnValue = dec.ReturnValue
}
if dec.L1Fee == nil {
return errors.New("missing required field 'l1Fee' for Receipt")
if dec.L1Fee != nil {
r.L1Fee = (*big.Int)(dec.L1Fee)
}
r.L1Fee = dec.L1Fee
return nil
}

View file

@ -75,7 +75,7 @@ type Receipt struct {
ReturnValue []byte `json:"returnValue,omitempty"`
// Scroll rollup
L1Fee *big.Int `json:"l1Fee,omitempty" gencodec:"required"`
L1Fee *big.Int `json:"l1Fee,omitempty"`
}
type receiptMarshaling struct {
@ -86,6 +86,7 @@ type receiptMarshaling struct {
GasUsed hexutil.Uint64
BlockNumber *hexutil.Big
TransactionIndex hexutil.Uint
L1Fee *hexutil.Big
}
// receiptRLP is the consensus encoding of a receipt.

View file

@ -1669,7 +1669,7 @@ func (s *PublicTransactionPoolAPI) GetTransactionReceipt(ctx context.Context, ha
"logs": receipt.Logs,
"logsBloom": receipt.Bloom,
"type": hexutil.Uint(tx.Type()),
"l1Fee": receipt.L1Fee,
"l1Fee": hexutil.Uint64(receipt.L1Fee.Uint64()),
}
// Assign the effective gas price paid
if !s.b.ChainConfig().IsLondon(bigblock) {