Skip to content

Commit

Permalink
fix: set gas limit for token no requiring estimated gas. (#2282)
Browse files Browse the repository at this point in the history
  • Loading branch information
richardo2016x authored May 24, 2024
1 parent 097f586 commit cffd8e5
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions src/ui/views/SendToken/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import {
KEYRING_CLASS,
MINIMUM_GAS_LIMIT,
CAN_ESTIMATE_L1_FEE_CHAINS,
ARB_LIKE_L2_CHAINS,
L2_ENUMS,
} from 'consts';
import { useRabbyDispatch, useRabbySelector, connectStore } from 'ui/store';
import { Account, ChainGas } from 'background/service/preference';
Expand Down Expand Up @@ -579,9 +577,6 @@ const SendToken = () => {
}

params.value = `0x${sendValue.toString(16)}`;
const noEstimateGasRequired =
!ARB_LIKE_L2_CHAINS.includes(chain.enum) &&
!L2_ENUMS.includes(chain.enum);

try {
const code = await wallet.requestETHRpc(
Expand All @@ -591,23 +586,18 @@ const SendToken = () => {
},
chain.serverId
);
const isContract = !!code && !(code === '0x' || code === '0x0');
/**
* we dont' need always fetch estimateGas, if no `params.gas` set below,
* `params.gas` would be filled on Tx Page.
*/
if (chain.needEstimateGas && estimateGas > 0) {
if (estimateGas > 0 && (chain.needEstimateGas || isContract)) {
params.gas = intToHex(estimateGas);
} else if (
code &&
(code === '0x' || code === '0x0') &&
noEstimateGasRequired
) {
} else if (!isContract) {
params.gas = intToHex(21000); // L2 has extra validation fee so can not set gasLimit as 21000 when send native token
}
} catch (e) {
if (noEstimateGasRequired) {
params.gas = intToHex(21000); // L2 has extra validation fee so can not set gasLimit as 21000 when send native token
}
params.gas = intToHex(21000);
}
if (
isShowMessageDataForToken &&
Expand Down

0 comments on commit cffd8e5

Please sign in to comment.