Commit ae97440f authored by Mark Tyneway's avatar Mark Tyneway Committed by GitHub

Merge pull request #2223 from ethereum-optimism/op/sdk-fixes-gas-estimate

Fix and usability improvements for L1 gas and cost estimates in L2Provider
parents 18c94970 44420939
---
'@eth-optimism/sdk': patch
---
1. Fix a bug in `L2Provider.getL1GasPrice()`
2. Make it easier to get correct estimates from `L2Provider.estimateL1Gas()` and `L2.estimateL2GasCost`.
......@@ -31,7 +31,7 @@ export const getL1GasPrice = async (
l2Provider: ProviderLike
): Promise<BigNumber> => {
const gpo = connectGasPriceOracle(l2Provider)
return gpo.gasPrice()
return gpo.l1BaseFee()
}
/**
......@@ -48,7 +48,11 @@ export const estimateL1Gas = async (
const gpo = connectGasPriceOracle(l2Provider)
return gpo.getL1GasUsed(
serialize({
...tx,
data: tx.data,
to: tx.to,
gasPrice: tx.gasPrice,
type: tx.type,
gasLimit: tx.gasLimit,
nonce: toNumber(tx.nonce as NumberLike),
})
)
......@@ -68,7 +72,11 @@ export const estimateL1GasCost = async (
const gpo = connectGasPriceOracle(l2Provider)
return gpo.getL1Fee(
serialize({
...tx,
data: tx.data,
to: tx.to,
gasPrice: tx.gasPrice,
type: tx.type,
gasLimit: tx.gasLimit,
nonce: toNumber(tx.nonce as NumberLike),
})
)
......
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