Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: set gas limit for token no requiring estimated gas. #2282

Merged
merged 1 commit into from
May 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading