diff --git a/_raw/locales/en/messages.json b/_raw/locales/en/messages.json index e9bfcaa6b1a..d4b89dcd657 100644 --- a/_raw/locales/en/messages.json +++ b/_raw/locales/en/messages.json @@ -2233,7 +2233,7 @@ }, "loginConfirmModal": { "title": "Log in with Current Address", - "desc": "You can only use this address to deposit and view your GasAccount balance." + "desc": "Once confirmed, you can only deposit it at this address" }, "logoutConfirmModal": { "title": "Log out current GasAccount", diff --git a/src/background/controller/provider/controller.ts b/src/background/controller/provider/controller.ts index e08e490b4b3..6f6cfa2bd07 100644 --- a/src/background/controller/provider/controller.ts +++ b/src/background/controller/provider/controller.ts @@ -473,13 +473,25 @@ class ProviderController extends BaseController { reported: false, }; + let signedTx; try { - const signedTx = await keyringService.signTransaction( + signedTx = await keyringService.signTransaction( keyring, tx, txParams.from, opts ); + } catch (e) { + const errObj = + typeof e === 'object' + ? { message: e.message } + : ({ message: e } as any); + errObj.method = EVENTS.COMMON_HARDWARE.REJECTED; + + throw errObj; + } + + try { if ( currentAccount.type === KEYRING_TYPE.GnosisKeyring || currentAccount.type === KEYRING_TYPE.CoboArgusKeyring diff --git a/src/background/controller/provider/rpcFlow.ts b/src/background/controller/provider/rpcFlow.ts index 54cbeb40cea..1d100d749d6 100644 --- a/src/background/controller/provider/rpcFlow.ts +++ b/src/background/controller/provider/rpcFlow.ts @@ -263,15 +263,21 @@ const flowContext = flow }) .then(resolve) .catch((e: any) => { + const payload = { + method: EVENTS.SIGN_FINISHED, + params: { + success: false, + errorMsg: e?.message || JSON.stringify(e), + }, + }; + if (e.method) { + payload.method = e.method; + payload.params = e.message; + } + Sentry.captureException(e); if (isSignApproval(approvalType)) { - eventBus.emit(EVENTS.broadcastToUI, { - method: EVENTS.SIGN_FINISHED, - params: { - success: false, - errorMsg: e?.message || JSON.stringify(e), - }, - }); + eventBus.emit(EVENTS.broadcastToUI, payload); } }) ); diff --git a/src/background/service/keyring/helper.ts b/src/background/service/keyring/helper.ts index 6b126bbf56f..158d062fdc7 100644 --- a/src/background/service/keyring/helper.ts +++ b/src/background/service/keyring/helper.ts @@ -7,9 +7,7 @@ export const throwError = (error, method = EVENTS.COMMON_HARDWARE.REJECTED) => { method, params: error, }); - throw new Error(error); }; - export class SignHelper { signFn: any; errorEventName: string; @@ -27,18 +25,7 @@ export class SignHelper { } async invoke(fn: () => Promise) { - return new Promise((resolve) => { - this.signFn = async () => { - try { - const result = await fn(); - resolve(result); - } catch (e) { - Sentry.captureException(e); - throwError(e?.message ?? e, this.errorEventName); - } - }; - this.signFn(); - }); + return fn(); } } diff --git a/src/ui/utils/sendTransaction.ts b/src/ui/utils/sendTransaction.ts index 9fb9afdab74..acc5f969119 100644 --- a/src/ui/utils/sendTransaction.ts +++ b/src/ui/utils/sendTransaction.ts @@ -448,36 +448,26 @@ export const sendTransaction = async ({ // submit tx let hash = ''; try { - hash = await Promise.race([ - wallet.ethSendTransaction({ - data: { - $ctx: { - ga, - }, - params: [transaction], + hash = await wallet.ethSendTransaction({ + data: { + $ctx: { + ga, }, - session: INTERNAL_REQUEST_SESSION, - approvalRes: { - ...transaction, - signingTxId, - logId: logId, - lowGasDeadline, - isGasLess, - isGasAccount: autoUseGasAccount ? canUseGasAccount : isGasAccount, - pushType, - }, - pushed: false, - result: undefined, - }), - new Promise((_, reject) => { - eventBus.once(EVENTS.LEDGER.REJECTED, async (data) => { - if (signingTxId != null) { - wallet.removeSigningTx(signingTxId); - } - reject(new Error(data)); - }); - }), - ]); + params: [transaction], + }, + session: INTERNAL_REQUEST_SESSION, + approvalRes: { + ...transaction, + signingTxId, + logId: logId, + lowGasDeadline, + isGasLess, + isGasAccount: autoUseGasAccount ? canUseGasAccount : isGasAccount, + pushType, + }, + pushed: false, + result: undefined, + }); await handleSendAfter(); } catch (e) { await handleSendAfter(); diff --git a/src/ui/views/Approval/components/LedgerHardwareWaiting.tsx b/src/ui/views/Approval/components/LedgerHardwareWaiting.tsx index b33f4ba7c00..e61b6794125 100644 --- a/src/ui/views/Approval/components/LedgerHardwareWaiting.tsx +++ b/src/ui/views/Approval/components/LedgerHardwareWaiting.tsx @@ -152,10 +152,7 @@ const LedgerHardwareWaiting = ({ params }: { params: ApprovalParams }) => { method: params?.extra?.signTextMethod, }); } - eventBus.addEventListener(EVENTS.LEDGER.REJECT_APPROVAL, (data) => { - rejectApproval(data, false, true); - }); - eventBus.addEventListener(EVENTS.LEDGER.REJECTED, async (data) => { + eventBus.addEventListener(EVENTS.COMMON_HARDWARE.REJECTED, async (data) => { setErrorMessage(data); if (/DisconnectedDeviceDuringOperation/i.test(data)) { await rejectApproval('User rejected the request.'); diff --git a/src/ui/views/GasAccount/components/LoginPopup.tsx b/src/ui/views/GasAccount/components/LoginPopup.tsx index 68bb85c4c5f..64523f9639c 100644 --- a/src/ui/views/GasAccount/components/LoginPopup.tsx +++ b/src/ui/views/GasAccount/components/LoginPopup.tsx @@ -18,7 +18,9 @@ import { useBrandIcon } from '@/ui/hooks/useBrandIcon'; export const GasACcountCurrentAddress = ({ account, + twoColumn, }: { + twoColumn?: boolean; account?: { address: string; type: string; @@ -34,10 +36,37 @@ export const GasACcountCurrentAddress = ({ brandName: account?.brandName || currentAccount!.brandName, type: account?.type || currentAccount!.type, }); + + if (twoColumn) { + return ( +
+ +
+ + {alias} + +
+ + +
+
+
+ ); + } return ( -
+
- + {alias} {t('page.gasAccount.switchLoginAddressBeforeDeposit.desc')}
-
- +
+