Commit 896168e2 authored by Mark Tyneway's avatar Mark Tyneway Committed by Kelvin Fichter

core-utils: ethers l2 context receipt

Have the ethers L2 context helper pass through the
new optimistic ethereum related fields
parent 343da72a
---
'@eth-optimism/core-utils': minor
---
Parse optimistic ethereum specific fields on transaction receipts
...@@ -9,7 +9,6 @@ import ( ...@@ -9,7 +9,6 @@ import (
"math/big" "math/big"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rollup/rcfg" "github.com/ethereum/go-ethereum/rollup/rcfg"
...@@ -159,7 +158,6 @@ func CalculateL1GasUsed(data []byte, overhead *big.Int) *big.Int { ...@@ -159,7 +158,6 @@ func CalculateL1GasUsed(data []byte, overhead *big.Int) *big.Int {
func DeriveL1GasInfo(msg Message, state StateDB) (*big.Int, *big.Int, *big.Int, *big.Float, error) { func DeriveL1GasInfo(msg Message, state StateDB) (*big.Int, *big.Int, *big.Int, *big.Float, error) {
tx := asTransaction(msg) tx := asTransaction(msg)
raw, err := rlpEncode(tx) raw, err := rlpEncode(tx)
fmt.Println(hexutil.Encode(raw))
if err != nil { if err != nil {
return nil, nil, nil, nil, err return nil, nil, nil, nil, err
} }
......
import cloneDeep from 'lodash/cloneDeep' import cloneDeep from 'lodash/cloneDeep'
import { providers } from 'ethers' import { providers, BigNumber } from 'ethers'
const parseNumber = (n: string | number): number => { const parseNumber = (n: string | number): number => {
if (typeof n === 'string' && n.startsWith('0x')) { if (typeof n === 'string' && n.startsWith('0x')) {
...@@ -69,5 +69,17 @@ export const injectL2Context = (l1Provider: providers.JsonRpcProvider) => { ...@@ -69,5 +69,17 @@ export const injectL2Context = (l1Provider: providers.JsonRpcProvider) => {
return tx return tx
} }
const formatReceiptResponse = provider.formatter.receipt.bind(
provider.formatter
)
provider.formatter.receipt = (receipt) => {
const r = formatReceiptResponse(receipt)
r.l1GasPrice = BigNumber.from(receipt.l1GasPrice)
r.l1GasUsed = BigNumber.from(receipt.l1GasUsed)
r.l1Fee = BigNumber.from(receipt.l1Fee)
r.l1FeeScalar = parseFloat(receipt.l1FeeScalar)
return r
}
return provider return provider
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment