Fix gas limit function in V4 oracle: if transaction type not specified, but transaction data provided, need to bump estimated limit

This commit is contained in:
Theo 2023-08-28 09:05:53 -07:00
parent c3bfb381b7
commit 90471e0073
2 changed files with 3 additions and 3 deletions

@ -1,6 +1,6 @@
{
"name": "@tornado/tornado-oracles",
"version": "1.4.1",
"version": "1.4.2",
"description": "Gas oracle for Tornado-specific transactions",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",

@ -26,8 +26,8 @@ export class TornadoFeeOracleV4 extends TornadoFeeOracle implements ITornadoFeeO
// For compatibility reasons, when wee check user-provided fee for V4 withdrawal transaction, we need dump gas limit
// for about 20 percent,so that the transaction will be sent, even if it results in some loss for the relayer
if (type === 'relayer_withdrawal_check_v4') return bump(defaultWithdrawalGasLimit[this.chainId], -25).toNumber();
if (!tx) return bump(21_000, bumpPercent).toNumber();
if (!tx || Object.keys(tx).length === 0) return bump(21_000, bumpPercent).toNumber();
return (await this.provider.estimateGas(tx)).toNumber();
return bump(await this.provider.estimateGas(tx), bumpPercent).toNumber();
}
}