diff --git a/_raw/locales/en/messages.json b/_raw/locales/en/messages.json index e6133986254..9764765dcc8 100644 --- a/_raw/locales/en/messages.json +++ b/_raw/locales/en/messages.json @@ -72,6 +72,11 @@ "enoughSafeSigCollected": "Enough signature collected", "moreSafeSigNeeded": "{{0}} more confirmation needed", "safeAdminSigned": "Signed", + "customRPCErrorModal": { + "title": "Custom RPC Error", + "content": "Your custom RPC is unavailable now. You can disable it and continue signing using Rabby's official RPC", + "button": "Disable Custom RPC" + }, "swap": { "title": "Swap Token", "payToken": "Pay", @@ -2110,4 +2115,4 @@ }, "IMPORTED_HD_KEYRING_NEED_PASSPHRASE": "Imported by Seed Phrase (Passphrase)" } -} +} \ No newline at end of file diff --git a/src/ui/style/antd-overwrite.less b/src/ui/style/antd-overwrite.less index a7491f6ec78..d8109f8e014 100644 --- a/src/ui/style/antd-overwrite.less +++ b/src/ui/style/antd-overwrite.less @@ -205,7 +205,7 @@ justify-content: space-between; width: 100%; .ant-btn { - width: 144px; + min-width: 144px; font-size: 15px; font-weight: 500; height: 44px; diff --git a/src/ui/utils/hooks.ts b/src/ui/utils/hooks.ts index 3833d3d3a65..7fc1cee3095 100644 --- a/src/ui/utils/hooks.ts +++ b/src/ui/utils/hooks.ts @@ -52,16 +52,6 @@ export const useApproval = () => { history.push('/'); } }; - - useEffect(() => { - if (!getUiType().isNotification) { - return; - } - window.addEventListener('beforeunload', rejectApproval); - - return () => window.removeEventListener('beforeunload', rejectApproval); - }, []); - return [getApproval, resolveApproval, rejectApproval] as const; }; diff --git a/src/ui/views/Approval/components/SignTx.tsx b/src/ui/views/Approval/components/SignTx.tsx index 78d1e58360d..5e26829fd23 100644 --- a/src/ui/views/Approval/components/SignTx.tsx +++ b/src/ui/views/Approval/components/SignTx.tsx @@ -52,7 +52,6 @@ import GasSelector, { GasSelectorResponse } from './TxComponents/GasSelecter'; import GnosisDrawer from './TxComponents/GnosisDrawer'; import Loading from './TxComponents/Loading'; import { useLedgerDeviceConnected } from '@/ui/utils/ledger'; -import { TransactionGroup } from 'background/service/transactionHistory'; import { intToHex } from 'ui/utils/number'; import { calcMaxPriorityFee } from '@/utils/transaction'; import { FooterBar } from './FooterBar/FooterBar'; @@ -62,7 +61,6 @@ import { fetchActionRequiredData, ActionRequireData, formatSecurityEngineCtx, - getActionTypeText, } from '../components/Actions/utils'; import Actions from './Actions'; import { useSecurityEngine } from 'ui/utils/securityEngine'; @@ -778,6 +776,23 @@ const SignTx = ({ params, origin }: SignTxProps) => { } }; + const triggerCustomRPCErrorModal = () => { + Modal.error({ + className: 'modal-support-darkmode', + closable: true, + title: t('page.signTx.customRPCErrorModal.title'), + content: t('page.signTx.customRPCErrorModal.content'), + okText: t('page.signTx.customRPCErrorModal.button'), + okButtonProps: { + className: 'w-[280px]', + }, + async onOk() { + await wallet.setRPCEnable(chain.enum, false); + location.reload(); + }, + }); + }; + const { data = '0x', from, @@ -916,12 +931,18 @@ const SignTx = ({ params, origin }: SignTxProps) => { const explainTx = async (address: string) => { let recommendNonce = '0x0'; if (!isGnosisAccount && !isCoboArugsAccount) { - recommendNonce = await getRecommendNonce({ - tx, - wallet, - chainId, - }); - setRecommendNonce(recommendNonce); + try { + recommendNonce = await getRecommendNonce({ + tx, + wallet, + chainId, + }); + setRecommendNonce(recommendNonce); + } catch (e) { + if (await wallet.hasCustomRPC(chain.enum)) { + triggerCustomRPCErrorModal(); + } + } } if (updateNonce && !isGnosisAccount && !isCoboArugsAccount) { setRealNonce(recommendNonce); @@ -986,7 +1007,9 @@ const SignTx = ({ params, origin }: SignTxProps) => { ); setBlockInfo(block); } catch (e) { - // DO NOTHING + if (await wallet.hasCustomRPC(chain.enum)) { + triggerCustomRPCErrorModal(); + } } if (tx.gas && origin === INTERNAL_REQUEST_ORIGIN) { setGasLimit(intToHex(Number(tx.gas))); // use origin gas as gasLimit when tx is an internal tx with gasLimit(i.e. for SendMax native token) @@ -1635,13 +1658,19 @@ const SignTx = ({ params, origin }: SignTxProps) => { (item) => item.type === currentAccount.type ) ); - const balance = await getNativeTokenBalance({ - wallet, - chainId, - address: currentAccount.address, - }); + try { + const balance = await getNativeTokenBalance({ + wallet, + chainId, + address: currentAccount.address, + }); - setNativeTokenBalance(balance); + setNativeTokenBalance(balance); + } catch (e) { + if (await wallet.hasCustomRPC(chain.enum)) { + triggerCustomRPCErrorModal(); + } + } wallet.reportStats('createTransaction', { type: currentAccount.brandName,