diff --git a/.gitignore b/.gitignore index b7bfa02..8f8d464 100644 --- a/.gitignore +++ b/.gitignore @@ -90,4 +90,5 @@ sw.* # Vim swap files *.swp -test \ No newline at end of file +test +TODO \ No newline at end of file diff --git a/package.json b/package.json index fafec3c..c175870 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@tornado/tornado-oracles", - "version": "1.0.0", + "version": "1.1.0", "description": "Gas oracle for Tornado-specific transactions", "main": "./lib/index.js", "types": "./lib/index.d.ts", diff --git a/src/feeOracle.ts b/src/feeOracle.ts index 8dde27b..33ee0b7 100644 --- a/src/feeOracle.ts +++ b/src/feeOracle.ts @@ -23,14 +23,15 @@ export abstract class TornadoFeeOracle implements ITornadoFeeOracle { * Because Optimism transaction published on Mainnet, for each OP transaction we need to calculate L1 security fee: * https://community.optimism.io/docs/developers/build/transaction-fees/#priority-fee * @param {TransactionData} tx Transaction data to estimate L1 additional fee - * @returns Fee in WEI (MATIC) + * @returns {Promise} Fee in WEI (MATIC) */ - private async fetchL1OptimismFee(tx?: TransactionData): Promise { - if (this.chainId != ChainId.OPTIMISM) return BigNumber.from(0); + async fetchL1OptimismFee(tx?: TransactionData): Promise { + if (this.chainId != ChainId.OPTIMISM) return BigNumber.from(0).toHexString(); const optimismL1FeeOracle = getOptimismL1FeeOracle(this.provider); + const l1Fee = await optimismL1FeeOracle.getL1Fee(serializeTx(tx)); - return await optimismL1FeeOracle.getL1Fee(serializeTx(tx)); + return l1Fee.toHexString(); } /** @@ -40,11 +41,7 @@ export abstract class TornadoFeeOracle implements ITornadoFeeOracle { * @param {LegacyGasPriceKey} speed Preferred transaction speed, if uses legacy gas (before EIP-1559) * @returns {Promise} Gas value in WEI (hex-format) */ - public async getGas( - tx?: TransactionData, - txType: TxType = 'other', - speed: LegacyGasPriceKey = 'fast', - ): Promise { + async getGas(tx?: TransactionData, txType: TxType = 'other', speed: LegacyGasPriceKey = 'fast'): Promise { const gasPrice = await this.getGasPrice(txType, speed); let gas = BigNumber.from(0); gas = gas.add(gasPrice); diff --git a/src/types.ts b/src/types.ts index 1935f02..b6531e4 100644 --- a/src/types.ts +++ b/src/types.ts @@ -35,6 +35,7 @@ export interface ITornadoFeeOracle { getGasPriceParams: (type?: TxType, speed?: LegacyGasPriceKey, bumpPercent?: number) => Promise; getGasPrice: (type?: TxType, speed?: LegacyGasPriceKey, bumpPercent?: number) => Promise; getGasLimit: (tx?: TransactionData, type?: TxType, bumpPercent?: number) => Promise; + fetchL1OptimismFee: (tx?: TransactionData) => Promise; calculateRefundInETH: (tx?: TransactionData) => Promise; calculateRefundInToken: ( tokenPriceInEth: BigNumberish,