Skip to content

Commit 5429ad4

Browse files
authored
Merge branch 'develop' into dependabot/npm_and_yarn/develop/ledgerhq/hw-transport-webhid-6.30.0
2 parents 396a172 + 3fd3bde commit 5429ad4

File tree

23 files changed

+220
-92
lines changed

23 files changed

+220
-92
lines changed

e2e-tests/constants.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { Page } from '@playwright/test';
21
import path from 'path';
32

43
export const newPassword = 'this is new password';
@@ -131,12 +130,12 @@ export const RPC_RESPONSE = {
131130
})
132131
},
133132
failure: {
134-
status: 500,
133+
status: 200,
135134
body: JSON.stringify({
136-
sourceErr: {
135+
error: {
137136
code: -32016,
138-
data: 'error description',
139-
message: 'error message'
137+
data: 'Error description',
138+
message: 'Error message'
140139
},
141140
id: 1,
142141
jsonrpc: '2.0'

e2e-tests/popup/transfers/casper-native-transfer.spec.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,10 @@ popup.describe('Popup UI: Casper Native Transfer', () => {
162162

163163
await popupExpect(
164164
popupPage.getByRole('heading', {
165-
name: 'failed to send http request, details: Code: 500, err: Internal Server Error'
165+
name: 'Error message'
166166
})
167167
).toBeVisible();
168-
await popupExpect(
169-
popupPage.getByText(
170-
'Please check browser console for error details, this will be a valuable for our team to fix the issue.'
171-
)
172-
).toBeVisible();
168+
await popupExpect(popupPage.getByText('Error description')).toBeVisible();
173169

174170
await popupPage.getByRole('button', { name: 'Close' }).click();
175171
});

e2e-tests/popup/transfers/erc-20-transfer.spec.ts

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -98,19 +98,8 @@ popup.describe('Popup UI: ERC-20 transfer', () => {
9898
popup('should made a failed transfer', async ({ unlockVault, popupPage }) => {
9999
await unlockVault();
100100

101-
await popupPage.route('https://node.testnet.cspr.cloud/rpc', route =>
102-
route.fulfill({
103-
status: 500,
104-
body: JSON.stringify({
105-
jsonrpc: '2.0',
106-
id: 1717761373590,
107-
error: {
108-
code: '',
109-
data: 'Error description',
110-
message: 'Error message'
111-
}
112-
})
113-
})
101+
await popupPage.route(URLS.rpc, route =>
102+
route.fulfill(RPC_RESPONSE.failure)
114103
);
115104

116105
await new Promise(r => setTimeout(r, 5000));
@@ -191,14 +180,10 @@ popup.describe('Popup UI: ERC-20 transfer', () => {
191180

192181
await popupExpect(
193182
popupPage.getByRole('heading', {
194-
name: 'failed to send http request, details: Code: 500, err: Internal Server Error'
183+
name: 'Error message'
195184
})
196185
).toBeVisible();
197-
await popupExpect(
198-
popupPage.getByText(
199-
'Please check browser console for error details, this will be a valuable for our team to fix the issue.'
200-
)
201-
).toBeVisible();
186+
await popupExpect(popupPage.getByText('Error description')).toBeVisible();
202187

203188
await popupPage.getByRole('button', { name: 'Close' }).click();
204189
});

src/apps/connect-to-app/app-router.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { useTranslation } from 'react-i18next';
33
import { useSelector } from 'react-redux';
44
import { HashRouter, Route, Routes } from 'react-router-dom';
55

6+
import { ErrorMessages } from '@src/constants';
7+
68
import { ApproveConnectionPage } from '@connect-to-app/pages/approve-connection';
79
import { ConnectingPage } from '@connect-to-app/pages/connecting';
810
import { SelectAccountPage } from '@connect-to-app/pages/select-account';
@@ -87,7 +89,9 @@ function useSiteRelatedData() {
8789
const siteTitle = searchParams.get('title');
8890

8991
if (origin == null) {
90-
throw new Error('Missing origin search param');
92+
throw new Error(
93+
`${ErrorMessages.common.MISSING_SEARCH_PARAM.description} origin`
94+
);
9195
}
9296

9397
const connectWith = t('Connect with');

src/apps/connect-to-app/pages/approve-connection/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import React from 'react';
33
import { Trans } from 'react-i18next';
44
import styled from 'styled-components';
55

6+
import { ErrorMessages } from '@src/constants';
7+
68
import { useAccountManager } from '@popup/hooks/use-account-actions-with-events';
79

810
import { closeCurrentWindow } from '@background/close-current-window';
@@ -42,8 +44,9 @@ export function ApproveConnectionPage({
4244
const requestId = searchParams.get('requestId');
4345

4446
if (!requestId) {
45-
const error = Error(`Missing search param: ${requestId}`);
46-
throw error;
47+
throw Error(
48+
`${ErrorMessages.common.MISSING_SEARCH_PARAM.description} ${requestId}`
49+
);
4750
}
4851

4952
const selectedAccountNamesLength = selectedAccountNames.length;

src/apps/connect-to-app/pages/select-account/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { Trans, useTranslation } from 'react-i18next';
33
import { useSelector } from 'react-redux';
44
import styled from 'styled-components';
55

6+
import { ErrorMessages } from '@src/constants';
7+
68
import { closeCurrentWindow } from '@background/close-current-window';
79
import { selectIsActiveAccountConnectedWithActiveOrigin } from '@background/redux/vault/selectors';
810
import { sendSdkResponseToSpecificTab } from '@background/send-sdk-response-to-specific-tab';
@@ -41,8 +43,9 @@ export function SelectAccountPage({
4143
const requestId = searchParams.get('requestId');
4244

4345
if (!requestId) {
44-
const error = Error(`Missing search param: ${requestId}`);
45-
throw error;
46+
throw Error(
47+
`${ErrorMessages.common.MISSING_SEARCH_PARAM.description} ${requestId}`
48+
);
4649
}
4750

4851
const isActiveAccountConnected = useSelector(

src/apps/connect-to-app/pages/switch-account/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import React from 'react';
22

3+
import { ErrorMessages } from '@src/constants';
4+
35
import { closeCurrentWindow } from '@background/close-current-window';
46
import { sendSdkResponseToSpecificTab } from '@background/send-sdk-response-to-specific-tab';
57

@@ -18,8 +20,9 @@ export function SwitchAccountPage() {
1820
const requestId = searchParams.get('requestId');
1921

2022
if (!requestId) {
21-
const error = Error(`Missing search param: ${requestId}`);
22-
throw error;
23+
throw Error(
24+
`${ErrorMessages.common.MISSING_SEARCH_PARAM.description} ${requestId}`
25+
);
2326
}
2427

2528
const handleCancel = async () => {

src/apps/import-account-with-file/pages/import-account-with-file-failure/content.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import React from 'react';
22
import { Trans, useTranslation } from 'react-i18next';
33

4+
import { ErrorMessages } from '@src/constants';
5+
46
import { useTypedLocation } from '@import-account-with-file/router';
57

68
import {
@@ -27,15 +29,21 @@ export function ImportAccountWithFileFailureContentPage() {
2729
</IllustrationContainer>
2830
<ParagraphContainer top={SpacingSize.XL}>
2931
<Typography type="header">
30-
<Trans t={t}>Something went wrong</Trans>
32+
<Trans t={t}>
33+
{
34+
ErrorMessages.importAccountWithFile
35+
.IMPORT_ACCOUNT_WITH_FILE_FAILED.message
36+
}
37+
</Trans>
3138
</Typography>
3239
</ParagraphContainer>
3340
<ParagraphContainer top={SpacingSize.Medium}>
3441
<Typography type="body" color="contentSecondary">
3542
{state?.importAccountStatusMessage
3643
? state.importAccountStatusMessage
3744
: t(
38-
': We couldn’t import your account. Please confirm that you’re importing a file containing your secret key (not to be confused with your public key).'
45+
ErrorMessages.importAccountWithFile
46+
.IMPORT_ACCOUNT_WITH_FILE_FAILED.description
3947
)}
4048
</Typography>
4149
</ParagraphContainer>

src/apps/import-account-with-file/pages/import-account-with-file-upload/hooks/use-secret-key-file-reader.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { isError } from 'casper-wallet-core';
22
import { useCallback } from 'react';
33
import { useTranslation } from 'react-i18next';
44

5+
import { ErrorMessages } from '@src/constants';
6+
57
import { checkSecretKeyExist } from '@background/redux/import-account-actions-should-be-removed';
68

79
import { parseSecretKeyString } from '@libs/crypto';
@@ -26,7 +28,7 @@ export function useSecretKeyFileReader({
2628
const isFileValid = (fileContents: string): Error | undefined => {
2729
if (!fileContents || fileContents.includes('PUBLIC KEY')) {
2830
return new Error(
29-
t('A private key was not detected. Try importing a different file.')
31+
t(ErrorMessages.secretKeyFile.INVALID_FILE_CONTENTS.description)
3032
);
3133
}
3234
};
@@ -38,7 +40,7 @@ export function useSecretKeyFileReader({
3840
secretKeyBase64 && (await checkSecretKeyExist(secretKeyBase64));
3941
if (existence) {
4042
return new Error(
41-
t('This account already exists. Try importing a different file.')
43+
t(ErrorMessages.secretKeyFile.ACCOUNT_EXISTS.description)
4244
);
4345
}
4446
};
@@ -77,9 +79,7 @@ export function useSecretKeyFileReader({
7779
return onFailure(
7880
isError(e)
7981
? e.message
80-
: t(
81-
'A private key was not detected. Try importing a different file.'
82-
)
82+
: t(ErrorMessages.secretKeyFile.PARSING_ERROR.description)
8383
);
8484
}
8585
};

src/apps/onboarding/pages/confirm-secret-phrase/index.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import React, { useState } from 'react';
22
import { Trans, useTranslation } from 'react-i18next';
33
import { Navigate } from 'react-router-dom';
44

5+
import { ErrorMessages } from '@src/constants';
6+
57
import { Stepper } from '@onboarding/components/stepper';
68
import { RouterPath } from '@onboarding/router';
79
import { useTypedNavigate } from '@onboarding/router/use-typed-navigate';
@@ -45,16 +47,18 @@ export function ConfirmSecretPhrasePage({
4547
dispatchToMainStore(initVault({ secretPhrase: phrase }));
4648
navigate(RouterPath.ConfirmSecretPhraseSuccess);
4749
} else {
48-
throw Error('Invalid secret phrase.');
50+
throw Error(ErrorMessages.secretPhrase.INVALID_SECRET_PHRASE.message);
4951
}
5052
} catch (err) {
5153
console.error(err);
5254
navigate(
5355
ErrorPath,
5456
createErrorLocationState({
55-
errorHeaderText: t("That's not the correct word order"),
57+
errorHeaderText: t(
58+
ErrorMessages.secretPhrase.WRONG_SECRET_PHRASE_ORDER.message
59+
),
5660
errorContentText: t(
57-
'Please start over. Make sure you save your secret phrase as a text file or write it down somewhere.'
61+
ErrorMessages.secretPhrase.WRONG_SECRET_PHRASE_ORDER.description
5862
),
5963
errorPrimaryButtonLabel: t('Generate a new secret recovery phrase'),
6064
errorRedirectPath: RouterPath.CreateSecretPhraseConfirmation

0 commit comments

Comments
 (0)