Skip to content

Commit b08dc15

Browse files
fix(extension): an appropriate error is now shown when a trezor user rejects a transaction (#725)
1 parent 65f4066 commit b08dc15

File tree

6 files changed

+66
-5
lines changed

6 files changed

+66
-5
lines changed

apps/browser-extension-wallet/src/lib/translations/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,7 @@
708708
"send.footer.viewTransaction": "View transaction",
709709
"send.footer.view": "View",
710710
"send.footer.fail": "Back",
711+
"send.footer.unauthorized": "Back",
711712
"send.footer.save": "Save",
712713
"send.footer.signing": "Signing in progress",
713714
"send.footer.confirmWithDevice": "Confirm with {{hardwareWallet}}",
@@ -726,6 +727,7 @@
726727
"buttonText": "Learn more"
727728
},
728729
"fail.oopsSomethingWentWrong": "Oops! Something went wrong",
730+
"fail.unauthorizedTransaction": "The transaction was not authorized.",
729731
"fail.problemSubmittingYourTransaction": "There was a problem submitting your transaction.",
730732
"fail.clickBackAndTryAgain": "Click \"Back\" and try again.",
731733
"success.thisMayTakeAFewMinutesToProcessYouCanViewTheStatusByClickingViewTransaction": "This may take a few minutes to process. You can view the status by clicking view transaction.",

apps/browser-extension-wallet/src/views/browser-view/features/send-transaction/components/SendTransaction.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { SendTransactionSummary } from './SendTransactionSummary';
66
import { ConfirmPassword } from './ConfirmPassword';
77
import { TransactionSuccess } from './TransactionSuccess';
88
import { TransactionFail } from './TransactionFail';
9+
import { UnauthorizedTransaction } from './UnauthorizedTransaction';
910
import { AddressList } from './AddressList';
1011
import { AddressForm } from './AddressForm';
1112
import { SendTransactionLayout } from './SendTransactionLayout';
@@ -60,6 +61,7 @@ export const SendTransaction = withAddressBookContext(
6061
[Sections.CONFIRMATION]: <ConfirmPassword />,
6162
[Sections.SUCCESS_TX]: <TransactionSuccess />,
6263
[Sections.FAIL_TX]: <TransactionFail />,
64+
[Sections.UNAUTHORIZED_TX]: <UnauthorizedTransaction />,
6365
[Sections.ADDRESS_LIST]: <AddressList isPopupView={isPopupView} scrollableTargetId={scrollableTargetId} />,
6466
[Sections.ADDRESS_FORM]: <AddressForm isPopupView={isPopupView} />,
6567
[Sections.ASSET_PICKER]: <AssetPicker isPopupView={isPopupView} />,

apps/browser-extension-wallet/src/views/browser-view/features/send-transaction/components/SendTransactionDrawer/Footer.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export const nextStepBtnLabels: Partial<Record<Sections, string>> = {
5252
[Sections.CONFIRMATION]: 'browserView.transaction.send.footer.confirm',
5353
[Sections.SUCCESS_TX]: 'browserView.transaction.send.footer.viewTransaction',
5454
[Sections.FAIL_TX]: 'browserView.transaction.send.footer.fail',
55+
[Sections.UNAUTHORIZED_TX]: 'browserView.transaction.send.footer.unauthorized',
5556
[Sections.ADDRESS_FORM]: 'browserView.transaction.send.footer.save',
5657
[Sections.ADDRESS_CHANGE]: 'addressBook.reviewModal.confirmUpdate.button'
5758
};
@@ -134,9 +135,11 @@ export const Footer = withAddressBookContext(
134135
sendEventToPostHog(PostHogAction.SendAllDoneViewTransactionClick);
135136
break;
136137
}
138+
case Sections.UNAUTHORIZED_TX:
137139
case Sections.FAIL_TX: {
138140
sendEventToMatomo(isPopupView ? Events.FAIL_BACK_POPUP : Events.FAIL_BACK_BROWSER);
139141
sendEventToPostHog(PostHogAction.SendSomethingWentWrongBackClick);
142+
break;
140143
}
141144
}
142145
// eslint-disable-next-line react-hooks/exhaustive-deps
@@ -212,7 +215,13 @@ export const Footer = withAddressBookContext(
212215
removePassword();
213216
// Error name is 'AuthenticationError' in dev build but 'W' in prod build
214217
if (error.message?.includes('Authentication failure')) {
215-
setSubmitingTxState({ isPasswordValid: false, isSubmitingTx: false });
218+
if (isHwSummary) {
219+
sendEvent(isPopupView ? Events.TX_FAIL_POPUP : Events.TX_FAIL_BROWSER);
220+
setSection({ currentSection: Sections.UNAUTHORIZED_TX });
221+
setSubmitingTxState({ isSubmitingTx: false });
222+
} else {
223+
setSubmitingTxState({ isPasswordValid: false, isSubmitingTx: false });
224+
}
216225
} else {
217226
// TODO: identify the errors and give them a value to send it with the event and track it [LW-6497]
218227
sendEvent(isPopupView ? Events.TX_FAIL_POPUP : Events.TX_FAIL_BROWSER);
@@ -235,7 +244,9 @@ export const Footer = withAddressBookContext(
235244
sendAnalytics();
236245
const isConfirmPass = currentSection.currentSection === Sections.CONFIRMATION;
237246
const txHasSucceeded = currentSection.currentSection === Sections.SUCCESS_TX;
238-
const txHasFailed = currentSection.currentSection === Sections.FAIL_TX;
247+
const txHasFailed =
248+
currentSection.currentSection === Sections.FAIL_TX ||
249+
currentSection.currentSection === Sections.UNAUTHORIZED_TX;
239250
const isReviewingAddress = currentSection.currentSection === Sections.ADDRESS_CHANGE;
240251

241252
if (hasTempTxData()) {

apps/browser-extension-wallet/src/views/browser-view/features/send-transaction/components/SendTransactionDrawer/HeaderView.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ export const HeaderNavigation = ({ isPopupView }: HeaderNavigationProps): React.
164164
const onArrowIconClick = () => {
165165
sendAnalytics();
166166
const shouldRedirect =
167-
isPopupView && [Sections.SUCCESS_TX, Sections.FORM, Sections.FAIL_TX].includes(section.currentSection);
167+
isPopupView &&
168+
[Sections.SUCCESS_TX, Sections.FORM, Sections.FAIL_TX, Sections.UNAUTHORIZED_TX].includes(section.currentSection);
168169
if (password) {
169170
removePassword();
170171
setSubmitingTxState({ isPasswordValid: true });
@@ -188,7 +189,7 @@ export const HeaderNavigation = ({ isPopupView }: HeaderNavigationProps): React.
188189
trigger_point: triggerPoint,
189190
[TX_CREATION_TYPE_KEY]: TxCreationType.Internal
190191
});
191-
} else if (section.currentSection === Sections.FAIL_TX) {
192+
} else if (section.currentSection === Sections.FAIL_TX || section.currentSection === Sections.UNAUTHORIZED_TX) {
192193
analytics.sendEventToPostHog(PostHogAction.SendSomethingWentWrongXClick, {
193194
trigger_point: triggerPoint,
194195
[TX_CREATION_TYPE_KEY]: TxCreationType.Internal
@@ -266,6 +267,7 @@ export const useGetHeaderText = (): Record<Sections, { title: string; subtitle?:
266267
},
267268
[Sections.SUCCESS_TX]: { title: '' },
268269
[Sections.FAIL_TX]: { title: '' },
270+
[Sections.UNAUTHORIZED_TX]: { title: '' },
269271
[Sections.ADDRESS_LIST]: { title: 'browserView.transaction.send.drawer.addressBook' },
270272
[Sections.ADDRESS_FORM]: { title: 'browserView.transaction.send.drawer.addressForm' },
271273
[Sections.ASSET_PICKER]: { title: 'core.coinInputSelection.assetSelection' },
@@ -285,7 +287,9 @@ export const HeaderTitle = ({
285287
const [isMultipleSelectionAvailable, setMultipleSelection] = useMultipleSelection();
286288
const { selectedTokenList, resetTokenList } = useSelectedTokenList();
287289
const headerText = useGetHeaderText();
288-
const shouldDisplayTitle = ![Sections.FORM, Sections.FAIL_TX].includes(section.currentSection);
290+
const shouldDisplayTitle = ![Sections.FORM, Sections.FAIL_TX, Sections.UNAUTHORIZED_TX].includes(
291+
section.currentSection
292+
);
289293
const title = shouldDisplayTitle
290294
? t(headerText[section.currentSection].title, { name: headerText[section.currentSection].name })
291295
: undefined;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import React, { useEffect } from 'react';
2+
import { useTranslation } from 'react-i18next';
3+
import { ResultMessage } from '@components/ResultMessage';
4+
import { useAnalyticsContext } from '@providers';
5+
import { PostHogAction, TX_CREATION_TYPE_KEY, TxCreationType } from '@providers/AnalyticsProvider/analyticsTracker';
6+
import styles from './TransactionSuccessView.module.scss';
7+
import { useAnalyticsSendFlowTriggerPoint } from '../store';
8+
9+
export const UnauthorizedTransaction = (): React.ReactElement => {
10+
const { t } = useTranslation();
11+
const analytics = useAnalyticsContext();
12+
const { triggerPoint } = useAnalyticsSendFlowTriggerPoint();
13+
14+
useEffect(() => {
15+
analytics.sendEventToPostHog(PostHogAction.SendSomethingWentWrongView, {
16+
// eslint-disable-next-line camelcase
17+
trigger_point: triggerPoint,
18+
[TX_CREATION_TYPE_KEY]: TxCreationType.Internal
19+
});
20+
// eslint-disable-next-line react-hooks/exhaustive-deps
21+
}, []);
22+
23+
return (
24+
<div data-testid="tx-fail-container" className={styles.successTxContainer}>
25+
<ResultMessage
26+
status="error"
27+
title={
28+
<>
29+
<div data-testid="send-error-title">{t('browserView.transaction.fail.oopsSomethingWentWrong')}</div>
30+
</>
31+
}
32+
description={
33+
<>
34+
<div data-testid="send-error-description">{t('browserView.transaction.fail.unauthorizedTransaction')}</div>
35+
<div data-testid="send-error-description2">{t('browserView.transaction.fail.clickBackAndTryAgain')}</div>
36+
</>
37+
}
38+
/>
39+
</div>
40+
);
41+
};

apps/browser-extension-wallet/src/views/browser-view/features/send-transaction/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export enum Sections {
99
CONFIRMATION = 'confirmation',
1010
SUCCESS_TX = 'success_tx',
1111
FAIL_TX = 'fail_tx',
12+
UNAUTHORIZED_TX = 'unauthorized_tx',
1213
ADDRESS_LIST = 'address_list',
1314
ADDRESS_FORM = 'address_form',
1415
ASSET_PICKER = 'asset_picker',

0 commit comments

Comments
 (0)