From 7892480851effe0ff49cda6f8227daa751303139 Mon Sep 17 00:00:00 2001 From: DMY <147dmy@gmail.com> Date: Tue, 3 Sep 2024 17:48:21 +0800 Subject: [PATCH] fix --- _raw/locales/en/messages.json | 1 + src/ui/utils/number.ts | 3 ++ src/ui/views/AddressManagement/index.tsx | 2 +- .../components/FooterBar/FooterBar.tsx | 5 ++- .../FooterBar/GasLessComponents.tsx | 19 ++++----- .../components/MiniSignTx/MiniFooterBar.tsx | 5 ++- .../Approval/components/MiniSignTx/index.tsx | 1 + src/ui/views/Approval/components/SignTx.tsx | 1 + .../TxComponents/GasSelectorHeader.tsx | 39 +++++++++++-------- .../components/GasAccountTxPopups.tsx | 9 +++-- .../GasAccount/components/LoginPopup.tsx | 2 +- src/ui/views/GasAccount/hooks/checkTxs.ts | 2 +- src/ui/views/GasAccount/hooks/index.ts | 8 +++- src/ui/views/GasAccount/index.tsx | 5 ++- 14 files changed, 65 insertions(+), 37 deletions(-) diff --git a/_raw/locales/en/messages.json b/_raw/locales/en/messages.json index 217de414d5c..9aa3447c102 100644 --- a/_raw/locales/en/messages.json +++ b/_raw/locales/en/messages.json @@ -351,6 +351,7 @@ "watchUnavailableTip": "Watch-only address is not supported for Free Gas" }, "gasAccount": { + "customRPC": "Not supported when using custom RPC", "notEnough": "Gas balance is not enough", "useGasAccount": "Use GasAccount", "WalletConnectTips": "WalletConnect is not supported by GasAccount", diff --git a/src/ui/utils/number.ts b/src/ui/utils/number.ts index 6559a07db72..c703d0bdf29 100644 --- a/src/ui/utils/number.ts +++ b/src/ui/utils/number.ts @@ -32,6 +32,9 @@ export const formatTokenAmount = ( if (moreDecimalsWhenNotEnough && bn.lt(0.0001) && decimals < 8) { realDecimals = 8; } + if (moreDecimalsWhenNotEnough && bn.lt(0.00000001)) { + return '<0.00000001'; + } if (!split[1] || split[1].length < realDecimals) { return splitNumberByStep(bn.toFixed()); } diff --git a/src/ui/views/AddressManagement/index.tsx b/src/ui/views/AddressManagement/index.tsx index 25efc919120..186dd08411d 100644 --- a/src/ui/views/AddressManagement/index.tsx +++ b/src/ui/views/AddressManagement/index.tsx @@ -515,7 +515,7 @@ const AddressManagement = () => { {enableSwitch ? t('page.manageAddress.current-address') : t('page.manageAddress.address-management')} -
+
{ isGasAccountLogin?: boolean; isWalletConnect?: boolean; gasAccountCanPay?: boolean; + noCustomRPC?: boolean; } const Wrapper = styled.section` @@ -161,6 +162,7 @@ export const FooterBar: React.FC = ({ isGasAccountLogin, isWalletConnect, gasAccountCanPay, + noCustomRPC, ...props }) => { const [account, setAccount] = React.useState(); @@ -316,7 +318,7 @@ export const FooterBar: React.FC = ({ ) : isWatchAddr ? null : ( ) @@ -327,6 +329,7 @@ export const FooterBar: React.FC = ({ gasAccountCost={gasAccountCost} isGasAccountLogin={isGasAccountLogin} isWalletConnect={isWalletConnect} + noCustomRPC={noCustomRPC} /> ) : null} diff --git a/src/ui/views/Approval/components/FooterBar/GasLessComponents.tsx b/src/ui/views/Approval/components/FooterBar/GasLessComponents.tsx index c9eef8584aa..598015ad75c 100644 --- a/src/ui/views/Approval/components/FooterBar/GasLessComponents.tsx +++ b/src/ui/views/Approval/components/FooterBar/GasLessComponents.tsx @@ -29,13 +29,13 @@ export type GasLessConfig = { export function GasLessNotEnough({ gasLessFailedReason, - gasAccountCost, onChangeGasAccount, + gasAccountCanPay, }: { url?: string; gasLessFailedReason?: string; - gasAccountCost?: GasAccountCheckResult; onChangeGasAccount?: () => void; + gasAccountCanPay?: boolean; }) { const { t } = useTranslation(); const [ @@ -43,11 +43,6 @@ export function GasLessNotEnough({ setHoverGasLessFailedReason, ] = React.useState(false); - const canUseGasAccount = - !!gasAccountCost?.is_gas_account && - !!gasAccountCost?.balance_is_enough && - !gasAccountCost?.chain_not_support; - return (
- {canUseGasAccount ? ( + {gasAccountCanPay ? (
{ + if (!noCustomRPC) { + return [t('page.signFooterBar.gasAccount.customRPC'), null]; + } if (isWalletConnect) { return [t('page.signFooterBar.gasAccount.WalletConnectTips'), null]; } @@ -400,7 +400,8 @@ export function GasAccountTips({ !isWalletConnect && isGasAccountLogin && gasAccountCost?.balance_is_enough && - !gasAccountCost.chain_not_support + !gasAccountCost.chain_not_support && + noCustomRPC ) { return null; } diff --git a/src/ui/views/Approval/components/MiniSignTx/MiniFooterBar.tsx b/src/ui/views/Approval/components/MiniSignTx/MiniFooterBar.tsx index 7bd2db6135b..0a2826887a2 100644 --- a/src/ui/views/Approval/components/MiniSignTx/MiniFooterBar.tsx +++ b/src/ui/views/Approval/components/MiniSignTx/MiniFooterBar.tsx @@ -58,6 +58,7 @@ interface Props extends Omit { isGasAccountLogin?: boolean; isWalletConnect?: boolean; gasAccountCanPay?: boolean; + noCustomRPC?: boolean; } const Wrapper = styled.section` @@ -169,6 +170,7 @@ export const MiniFooterBar: React.FC = ({ isGasAccountLogin, isWalletConnect, gasAccountCanPay, + noCustomRPC, task, ...props }) => { @@ -290,7 +292,7 @@ export const MiniFooterBar: React.FC = ({ ) : isWatchAddr ? null : ( ) @@ -301,6 +303,7 @@ export const MiniFooterBar: React.FC = ({ gasAccountCost={gasAccountCost} isGasAccountLogin={isGasAccountLogin} isWalletConnect={isWalletConnect} + noCustomRPC={noCustomRPC} /> ) : null} diff --git a/src/ui/views/Approval/components/MiniSignTx/index.tsx b/src/ui/views/Approval/components/MiniSignTx/index.tsx index 932367489d4..46e63db48f8 100644 --- a/src/ui/views/Approval/components/MiniSignTx/index.tsx +++ b/src/ui/views/Approval/components/MiniSignTx/index.tsx @@ -895,6 +895,7 @@ export const MiniSignTx = ({ />
} + noCustomRPC={noCustomRPC} gasMethod={gasMethod} gasAccountCost={gasAccountCost} gasAccountCanPay={gasAccountCanPay} diff --git a/src/ui/views/Approval/components/SignTx.tsx b/src/ui/views/Approval/components/SignTx.tsx index ed553db8e14..b84a4920127 100644 --- a/src/ui/views/Approval/components/SignTx.tsx +++ b/src/ui/views/Approval/components/SignTx.tsx @@ -2007,6 +2007,7 @@ const SignTx = ({ params, origin }: SignTxProps) => { isWatchAddr={ currentAccountType === KEYRING_TYPE.WatchAddressKeyring } + noCustomRPC={noCustomRPC} gasMethod={gasMethod} gasAccountCost={gasAccountCost} gasAccountCanPay={gasAccountCanPay} diff --git a/src/ui/views/Approval/components/TxComponents/GasSelectorHeader.tsx b/src/ui/views/Approval/components/TxComponents/GasSelectorHeader.tsx index 77e1fabf179..93ed22e2358 100644 --- a/src/ui/views/Approval/components/TxComponents/GasSelectorHeader.tsx +++ b/src/ui/views/Approval/components/TxComponents/GasSelectorHeader.tsx @@ -713,7 +713,8 @@ const GasSelectorHeader = ({ const gasCostAmountStr = useMemo(() => { return `${formatTokenAmount( new BigNumber(modalExplainGas.gasCostAmount).toString(10), - 6 + 6, + true )} ${chain.nativeTokenSymbol}`; }, [modalExplainGas?.gasCostAmount]); @@ -791,8 +792,8 @@ const GasSelectorHeader = ({ ) : gasMethod === 'gasAccount' ? (
-
@@ -817,13 +818,13 @@ const GasSelectorHeader = ({ } > -
+
{gasAccountCost?.gas_account_cost.total_cost} USD
- +
) : ( -
+
{gasMethod ? ( -
- - {gasCostUsdStr} - - - {gasCostAmountStr} - -
+ +
+ {gasCostAmountStr} +
+
) : ( { const { active, onChange, ActiveComponent, BlurComponent, tips } = props; return ( -
-
+ ); }; diff --git a/src/ui/views/GasAccount/components/GasAccountTxPopups.tsx b/src/ui/views/GasAccount/components/GasAccountTxPopups.tsx index 0cf0831a607..03b1e4dcedc 100644 --- a/src/ui/views/GasAccount/components/GasAccountTxPopups.tsx +++ b/src/ui/views/GasAccount/components/GasAccountTxPopups.tsx @@ -9,12 +9,13 @@ import PNGDepositTip from '@/ui/assets/gas-account/gas-account-deposit-tip.png'; import { GasAccountBlueLogo } from './GasAccountBlueLogo'; import { ReactComponent as RcIconQuoteStart } from '@/ui/assets/gas-account/quote-start.svg'; import { ReactComponent as RcIconQuoteEnd } from '@/ui/assets/gas-account/quote-end.svg'; +import { GasAccountWrapperBg } from './WrapperBg'; const GasAccountDepositTipContent = ({ onClose }: { onClose: () => void }) => { const { t } = useTranslation(); return ( -
+
{t('page.gasAccount.GasAccountDepositTipPopup.title')}
@@ -29,7 +30,7 @@ const GasAccountDepositTipContent = ({ onClose }: { onClose: () => void }) => { {t('page.gasAccount.GasAccountDepositTipPopup.gotIt')}
-
+ ); }; @@ -56,7 +57,7 @@ const GasAccountLoginTipContent = ({ onClose }: { onClose: () => void }) => { const { t } = useTranslation(); return ( -
+
void }) => { {t('page.gasAccount.GasAccountDepositTipPopup.gotIt')}
-
+ ); }; diff --git a/src/ui/views/GasAccount/components/LoginPopup.tsx b/src/ui/views/GasAccount/components/LoginPopup.tsx index f9f6224c4a1..3d8bf8a2eeb 100644 --- a/src/ui/views/GasAccount/components/LoginPopup.tsx +++ b/src/ui/views/GasAccount/components/LoginPopup.tsx @@ -117,7 +117,7 @@ const GasAccountLoginContent = ({ onClose }: { onClose: () => void }) => { block size="large" type="primary" - className="h-[44px] text-r-neutral-title2 text-15 font-medium" + className="h-[48px] text-r-neutral-title2 text-15 font-medium" > {t('global.Confirm')} diff --git a/src/ui/views/GasAccount/hooks/checkTxs.ts b/src/ui/views/GasAccount/hooks/checkTxs.ts index 8338f92acd8..b6aff3ae03e 100644 --- a/src/ui/views/GasAccount/hooks/checkTxs.ts +++ b/src/ui/views/GasAccount/hooks/checkTxs.ts @@ -30,7 +30,7 @@ export const useGasAccountTxsCheck = ({ setIsGasAccountLogin(false); } return wallet.openapi.checkGasAccountTxs({ - sig: sig!, + sig: sig || '', account_id: accountId!, tx_list: txs, }); diff --git a/src/ui/views/GasAccount/hooks/index.ts b/src/ui/views/GasAccount/hooks/index.ts index ada0b96747f..76ac1ffd351 100644 --- a/src/ui/views/GasAccount/hooks/index.ts +++ b/src/ui/views/GasAccount/hooks/index.ts @@ -146,7 +146,10 @@ export const useGasAccountHistory = () => { reloadDeps: [sig], isNoMore(data) { if (data) { - return !(!!data?.rechargeList && data?.rechargeList?.length > 0); + return ( + data.totalCount <= + (data.list.length || 0) + (data?.rechargeList?.length || 0) + ); } return true; }, @@ -191,9 +194,12 @@ export const useGasAccountHistory = () => { const [inViewport] = useInViewport(ref); + console.log('inViewport', inViewport, noMore, loadingMore); + useEffect(() => { if (!noMore && inViewport && !loadingMore && loadMore) { loadMore(); + console.log('loadMore'); } }, [inViewport, loadMore, loading, loadingMore, noMore]); diff --git a/src/ui/views/GasAccount/index.tsx b/src/ui/views/GasAccount/index.tsx index 365176191a3..da96812661e 100644 --- a/src/ui/views/GasAccount/index.tsx +++ b/src/ui/views/GasAccount/index.tsx @@ -153,7 +153,10 @@ const GasAccountInner = () => { /> setLogoutVisible(false)} + onCancel={() => { + gotoDashboard(); + setLogoutVisible(false); + }} />