Skip to content

Commit

Permalink
core-utils: ethers l2 context receipt
Browse files Browse the repository at this point in the history
Have the ethers L2 context helper pass through the
new optimistic ethereum related fields
  • Loading branch information
tynes authored and smartcontracts committed Oct 1, 2021
1 parent b604fc2 commit 71d6adb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/four-chairs-press.md
@@ -0,0 +1,5 @@
---
'@eth-optimism/core-utils': minor
---

Parse optimistic ethereum specific fields on transaction receipts
2 changes: 0 additions & 2 deletions l2geth/rollup/fees/rollup_fee.go
Expand Up @@ -9,7 +9,6 @@ import (
"math/big"

"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/params"
"github.com/ethereum/go-ethereum/rollup/rcfg"
Expand Down Expand Up @@ -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) {
tx := asTransaction(msg)
raw, err := rlpEncode(tx)
fmt.Println(hexutil.Encode(raw))
if err != nil {
return nil, nil, nil, nil, err
}
Expand Down
14 changes: 13 additions & 1 deletion packages/core-utils/src/l2context.ts
@@ -1,5 +1,5 @@
import cloneDeep from 'lodash/cloneDeep'
import { providers } from 'ethers'
import { providers, BigNumber } from 'ethers'

/**
* Helper for adding additional L2 context to transactions
Expand Down Expand Up @@ -54,5 +54,17 @@ export const injectL2Context = (l1Provider: providers.JsonRpcProvider) => {
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
}

0 comments on commit 71d6adb

Please sign in to comment.