Commit 9739c817 authored by Wyatt Barnes's avatar Wyatt Barnes

Remove options.blockNumber from estimateFees

parent 9a924605
......@@ -59,20 +59,14 @@ You will now have access to the following functions under the `op` namespace, i.
Computes the total (L1 + L2) fee estimate to execute a transaction
```typescript
async estimateFees(transaction: Transaction, options?: { blockNumber?: BlockNumberOrTag, returnFormat?: ReturnFormat })
async estimateFees(transaction: Transaction, returnFormat?: ReturnFormat)
```
#### Parameters
- `transaction: Transaction` - An unsigned web3.js [transaction](https://docs.web3js.org/api/web3-types/interface/Transaction) object
- `options?: { blockNumber?: BlockNumberOrTag, returnFormat?: ReturnFormat }` - An optional object with properties:
- `blockNumber?: BlockNumberOrTag` - Specifies what block to use for gas estimation. Can be either:
- **Note** Specifying a block to estimate L2 gas for is currently not working
- A web3.js [Numbers](https://docs.web3js.org/api/web3-types#Numbers)
- A web3.js [BlockTags](https://docs.web3js.org/api/web3-types/enum/BlockTags)
- If not provided, `BlockTags.LATEST` is used
- `returnFormat?: ReturnFormat` - A web3.js [DataFormat](https://docs.web3js.org/api/web3-types#DataFormat) object that specifies how to format number and bytes values
- If `returnFormat` is not provided, [DEFAULT_RETURN_FORMAT](https://docs.web3js.org/api/web3-types#DEFAULT_RETURN_FORMAT) is used which will format numbers to `BigInt`s
- `returnFormat?: ReturnFormat` - A web3.js [DataFormat](https://docs.web3js.org/api/web3-types#DataFormat) object that specifies how to format number and bytes values
- If `returnFormat` is not provided, [DEFAULT_RETURN_FORMAT](https://docs.web3js.org/api/web3-types#DEFAULT_RETURN_FORMAT) is used which will format numbers to `BigInt`s
#### Returns
......@@ -597,4 +591,4 @@ console.log(version) // 1.0.0
## Known Issues
- As of version `4.0.3` of web3.js, both `input` and `data` parameters are automatically added to a transaction objects causing the gas estimations to be inflated. This was corrected in [this](https://github.com/web3/web3.js/pull/6294) PR, but has yet to be released
- For the plugin functions, `getL2Fee` and `estimateFees`, you should be able to get the fee estimates using the state of the blockchain at a specified block, however, this doesn't seem to be working with web3.js and requires further investigation
- For the plugin function `getL2Fee`, you should be able to get the fee estimates using the state of the blockchain at a specified block, however, this doesn't seem to be working with web3.js and requires further investigation
......@@ -247,8 +247,7 @@ export class OptimismFeeEstimationPlugin extends Web3PluginBase {
/**
* Computes the total (L1 + L2) fee estimate to execute {transaction}
* @param transaction - An unsigned web3.js {Transaction} object
* @param {{ blockNumber: BlockNumberOrTag, returnFormat: DataFormat }} [options={blockNumber: BlockTags.LATEST, returnFormat: DEFAULT_RETURN_FORMAT}] -
* An options object specifying what block to use for gas estimates and the web3.js format object that specifies how to format number and bytes values
* @param {DataFormat} [returnFormat=DEFAULT_RETURN_FORMAT] - The web3.js format object that specifies how to format number and bytes values
* @returns {Promise<Numbers>} - The estimated total fee as a BigInt by default, but {returnFormat} determines type
* @example
* const estimatedFees: bigint = await estimateFees(transaction);
......@@ -260,22 +259,17 @@ export class OptimismFeeEstimationPlugin extends Web3PluginBase {
ReturnFormat extends DataFormat = typeof DEFAULT_RETURN_FORMAT
>(
transaction: Transaction,
options?: {
blockNumber?: BlockNumberOrTag
returnFormat?: ReturnFormat
}
returnFormat?: ReturnFormat
) {
const [l1Fee, l2Fee] = await Promise.all([
this.getL1Fee(transaction),
this.getL2Fee(transaction, {
blockNumber: options?.blockNumber,
}),
this.getL2Fee(transaction),
])
return Web3.utils.format(
{ format: 'uint' },
l1Fee + l2Fee,
options?.returnFormat ?? DEFAULT_RETURN_FORMAT
returnFormat ?? DEFAULT_RETURN_FORMAT
)
}
......
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