diff --git a/src/ui/utils/sendTransaction.ts b/src/ui/utils/sendTransaction.ts index 5def2816394..adc55b8a96c 100644 --- a/src/ui/utils/sendTransaction.ts +++ b/src/ui/utils/sendTransaction.ts @@ -55,11 +55,13 @@ export const sendTransaction = async ({ isGasLess, waitCompleted = true, pushType = 'default', + ignoreGasNotEnoughCheck, }: { tx: Tx; chainServerId: string; wallet: WalletControllerType; ignoreGasCheck?: boolean; + ignoreGasNotEnoughCheck?: boolean; onProgress?: (status: ProgressStatus) => void; gasLevel?: GasLevel; lowGasDeadline?: number; @@ -155,19 +157,21 @@ export const sendTransaction = async ({ }); // check gas errors - const checkErrors = checkGasAndNonce({ - recommendGasLimit: `0x${gas.toString(16)}`, - recommendNonce, - gasLimit: Number(gasLimit), - nonce: Number(recommendNonce || tx.nonce), - gasExplainResponse: gasCost, - isSpeedUp: false, - isCancel: false, - tx, - isGnosisAccount: false, - nativeTokenBalance: balance, - recommendGasLimitRatio, - }); + const checkErrors = ignoreGasNotEnoughCheck + ? [] + : checkGasAndNonce({ + recommendGasLimit: `0x${gas.toString(16)}`, + recommendNonce, + gasLimit: Number(gasLimit), + nonce: Number(recommendNonce || tx.nonce), + gasExplainResponse: gasCost, + isSpeedUp: false, + isCancel: false, + tx, + isGnosisAccount: false, + nativeTokenBalance: balance, + recommendGasLimitRatio, + }); const isGasNotEnough = !isGasLess && checkErrors.some((e) => e.code === 3001); const ETH_GAS_USD_LIMIT = process.env.DEBUG diff --git a/src/ui/views/Approval/components/MiniSignTx/index.tsx b/src/ui/views/Approval/components/MiniSignTx/index.tsx index b9c3a955b5a..ebb6f366c40 100644 --- a/src/ui/views/Approval/components/MiniSignTx/index.tsx +++ b/src/ui/views/Approval/components/MiniSignTx/index.tsx @@ -336,6 +336,7 @@ export const MiniSignTx = ({ waitCompleted: false, pushType: pushInfo.type, ignoreGasCheck: true, + ignoreGasNotEnoughCheck: true, }, status: 'idle', }; @@ -372,36 +373,39 @@ export const MiniSignTx = ({ }) ); } + Promise.all( + txsResult.map(async (item) => { + const tx = { + ...item.tx, + ...(support1559 + ? { + maxFeePerGas: intToHex(Math.round(gas.price)), + maxPriorityFeePerGas: + gas.maxPriorityFee <= 0 + ? item.tx.maxFeePerGas + : intToHex(Math.round(gas.maxPriorityFee)), + } + : { gasPrice: intToHex(Math.round(gas.price)) }), + }; + return { + ...item, + tx, + gasCost: await explainGas({ + gasUsed: item.gasUsed, + gasPrice: gas.price, + chainId: chain.id, + nativeTokenPrice: item.preExecResult.native_token.price, + wallet, + tx, + gasLimit: item.gasLimit, + }), + }; + }) + ).then((res) => { + setTxsResult(res); + }); if (support1559) { - setTxsResult((pre) => { - return pre.map((item) => { - return { - ...item, - tx: { - ...item.tx, - maxFeePerGas: intToHex(Math.round(gas.price)), - maxPriorityFeePerGas: - gas.maxPriorityFee <= 0 - ? item.tx.maxFeePerGas - : intToHex(Math.round(gas.maxPriorityFee)), - }, - }; - }); - }); setMaxPriorityFee(Math.round(gas.maxPriorityFee)); - } else { - setTxsResult((pre) => { - return pre.map((item) => { - return { - ...item, - tx: { - ...item.tx, - gasPrice: intToHex(Math.round(gas.price)), - // gas: intToHex(gas.gasLimit), - }, - }; - }); - }); } };