diff --git a/patches/@debank+common+0.3.60.patch b/patches/@debank+common+0.3.60.patch new file mode 100644 index 00000000000..800b57af72f --- /dev/null +++ b/patches/@debank+common+0.3.60.patch @@ -0,0 +1,12 @@ +diff --git a/node_modules/@debank/common/dist/chain.d.ts b/node_modules/@debank/common/dist/chain.d.ts +index ae0b2d4..70873af 100644 +--- a/node_modules/@debank/common/dist/chain.d.ts ++++ b/node_modules/@debank/common/dist/chain.d.ts +@@ -2,6 +2,7 @@ import { CHAINS_ENUM, ChainRaw } from "./chain-data"; + export declare type Chain = ChainRaw & { + logo: string; + whiteLogo?: string; ++ needEstimateGas?: boolean; + }; + export { CHAINS_ENUM } from "./chain-data"; + export declare const MAINNET_CHAINS_LIST: Array; diff --git a/src/background/service/customTestnet.ts b/src/background/service/customTestnet.ts index fb8b3955873..834cb89904e 100644 --- a/src/background/service/customTestnet.ts +++ b/src/background/service/customTestnet.ts @@ -46,6 +46,7 @@ export interface TestnetChain extends TestnetChainBase { isTestnet?: boolean; logo: string; whiteLogo?: string; + needEstimateGas?: boolean; } export interface RPCItem { diff --git a/src/ui/views/SendToken/index.tsx b/src/ui/views/SendToken/index.tsx index a05942eb5d9..e040a4569f5 100644 --- a/src/ui/views/SendToken/index.tsx +++ b/src/ui/views/SendToken/index.tsx @@ -1,5 +1,5 @@ +/* eslint "react-hooks/exhaustive-deps": ["error"] */ import React, { useState, useCallback, useEffect, useMemo } from 'react'; -import ClipboardJS from 'clipboard'; import clsx from 'clsx'; import BigNumber from 'bignumber.js'; import { Trans, useTranslation } from 'react-i18next'; @@ -19,6 +19,7 @@ import { 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'; @@ -428,7 +429,7 @@ const SendToken = () => { ), }; - }, [temporaryGrant, whitelist, toAddressInWhitelist, whitelistEnabled]); + }, [t, temporaryGrant, toAddressInWhitelist, whitelistEnabled]); const canSubmit = isValidAddress(form.getFieldValue('to')) && @@ -578,6 +579,10 @@ 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( { @@ -586,17 +591,21 @@ const SendToken = () => { }, chain.serverId ); - if (estimateGas > 0) { + /** + * 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) { params.gas = intToHex(estimateGas); } else if ( code && (code === '0x' || code === '0x0') && - !ARB_LIKE_L2_CHAINS.includes(chain.enum) + noEstimateGasRequired ) { params.gas = intToHex(21000); // L2 has extra validation fee so can not set gasLimit as 21000 when send native token } } catch (e) { - if (!ARB_LIKE_L2_CHAINS.includes(chain.enum)) { + if (noEstimateGasRequired) { params.gas = intToHex(21000); // L2 has extra validation fee so can not set gasLimit as 21000 when send native token } } @@ -1066,6 +1075,7 @@ const SendToken = () => { if (inited) { initByCache(); } + // eslint-disable-next-line react-hooks/exhaustive-deps }, [inited]); const getAlianName = async () => { @@ -1156,12 +1166,14 @@ const SendToken = () => { return () => { wallet.clearPageStateCache(); }; + // eslint-disable-next-line react-hooks/exhaustive-deps }, []); useEffect(() => { if (currentAccount) { getAlianName(); } + // eslint-disable-next-line react-hooks/exhaustive-deps }, [currentAccount]); return ( diff --git a/src/utils/chain.ts b/src/utils/chain.ts index be474411409..3fb5ea8b621 100644 --- a/src/utils/chain.ts +++ b/src/utils/chain.ts @@ -464,7 +464,7 @@ export function supportedChainToChain(item: SupportedChain): Chain { nativeTokenLogo: item.native_token?.logo, nativeTokenDecimals: item.native_token?.decimals, nativeTokenAddress: item.native_token?.id, - // needEstimateGas: item.need_estimate_gas, + needEstimateGas: item.need_estimate_gas, scanLink: `${item.explorer_host}/${ item.id === 'heco' ? 'transaction' : 'tx' }/_s_`,