-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feature: add Torus Wallet account import feature (#964) * Add Torus Wallet account import feature * Improve validation of Torus Wallet secret key imports * Update Torus Wallet secret and public keys for E2E tests * Replace ERC20 icon with CEP18 contract icon in UI components (#962) * Release 1.8.4 version --------- Co-authored-by: Ostap Piatkovskyi <[email protected]>
- Loading branch information
Showing
29 changed files
with
1,508 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
e2e-tests/popup/import-torus-account/import-torus-account.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { | ||
ACCOUNT_NAMES, | ||
IMPORTED_TORUS_ACCOUNT, | ||
torusSecretKeyHex | ||
} from '../../constants'; | ||
import { popup, popupExpect } from '../../fixtures'; | ||
|
||
popup.describe('Popup UI: import account with file', () => { | ||
popup('should import torus account', async ({ unlockVault, popupPage }) => { | ||
await unlockVault(); | ||
|
||
await popupPage.getByTestId('menu-open-icon').click(); | ||
await popupPage.getByText('Import Torus account').click(); | ||
|
||
await popupExpect( | ||
popupPage.getByRole('heading', { | ||
name: 'Import account from Torus Wallet' | ||
}) | ||
).toBeVisible(); | ||
|
||
await popupPage.getByRole('button', { name: 'Next' }).click(); | ||
|
||
await popupPage | ||
.getByPlaceholder('Secret key', { exact: true }) | ||
.fill(torusSecretKeyHex); | ||
await popupPage | ||
.getByPlaceholder('Account name', { exact: true }) | ||
.fill(IMPORTED_TORUS_ACCOUNT.accountName); | ||
|
||
await popupPage.getByRole('button', { name: 'Import' }).click(); | ||
|
||
await popupExpect( | ||
popupPage.getByRole('heading', { | ||
name: 'Your account was successfully imported' | ||
}) | ||
).toBeVisible(); | ||
|
||
await popupPage.getByRole('button', { name: 'Done' }).click(); | ||
|
||
await popupPage.getByTestId('connection-status-modal').click(); | ||
|
||
await popupExpect( | ||
popupPage.getByText(ACCOUNT_NAMES.importedTorusAccountName) | ||
).toBeVisible(); | ||
await popupExpect( | ||
popupPage.getByText(IMPORTED_TORUS_ACCOUNT.truncatedPublicKey) | ||
).toBeVisible(); | ||
await popupExpect( | ||
popupPage.getByText('Imported', { exact: true }) | ||
).toBeVisible(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/apps/popup/pages/import-account-from-torus/failure.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import React from 'react'; | ||
import { Trans, useTranslation } from 'react-i18next'; | ||
|
||
import { | ||
ContentContainer, | ||
IllustrationContainer, | ||
ParagraphContainer, | ||
SpacingSize | ||
} from '@libs/layout'; | ||
import { SvgIcon, Typography } from '@libs/ui/components'; | ||
|
||
interface ImportTorusAccountFailureProps { | ||
message?: string; | ||
} | ||
|
||
export const ImportTorusAccountFailure = ({ | ||
message | ||
}: ImportTorusAccountFailureProps) => { | ||
const { t } = useTranslation(); | ||
|
||
return ( | ||
<ContentContainer> | ||
<IllustrationContainer> | ||
<SvgIcon | ||
src="assets/illustrations/error.svg" | ||
width={200} | ||
height={120} | ||
/> | ||
</IllustrationContainer> | ||
<ParagraphContainer top={SpacingSize.XL}> | ||
<Typography type="header"> | ||
<Trans t={t}>Something went wrong</Trans> | ||
</Typography> | ||
</ParagraphContainer> | ||
<ParagraphContainer top={SpacingSize.Medium}> | ||
<Typography type="body" color="contentSecondary"> | ||
{message | ||
? message | ||
: 'We couldn’t import your account. Please confirm that you’re importing a secret key (not to be confused with your public key).'} | ||
</Typography> | ||
</ParagraphContainer> | ||
</ContentContainer> | ||
); | ||
}; |
56 changes: 56 additions & 0 deletions
56
src/apps/popup/pages/import-account-from-torus/import-form.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import React from 'react'; | ||
import { FieldErrors, UseFormRegister } from 'react-hook-form'; | ||
import { Trans, useTranslation } from 'react-i18next'; | ||
|
||
import { | ||
ContentContainer, | ||
InputsContainer, | ||
ParagraphContainer, | ||
SpacingSize | ||
} from '@libs/layout'; | ||
import { | ||
FormField, | ||
FormFieldStatus, | ||
Input, | ||
TextArea, | ||
Typography | ||
} from '@libs/ui/components'; | ||
import { ImportAccountFromTorusFromValues } from '@libs/ui/forms/import-account-from-torus'; | ||
|
||
interface ImportTorusFormProps { | ||
register: UseFormRegister<ImportAccountFromTorusFromValues>; | ||
errors: FieldErrors<ImportAccountFromTorusFromValues>; | ||
} | ||
|
||
export const ImportTorusForm = ({ register, errors }: ImportTorusFormProps) => { | ||
const { t } = useTranslation(); | ||
|
||
return ( | ||
<ContentContainer> | ||
<ParagraphContainer top={SpacingSize.XL}> | ||
<Typography type="header"> | ||
<Trans t={t}>Account details</Trans> | ||
</Typography> | ||
</ParagraphContainer> | ||
<InputsContainer> | ||
<FormField | ||
statusText={errors.secretKey?.message} | ||
status={!!errors.secretKey ? FormFieldStatus.Error : undefined} | ||
> | ||
<TextArea | ||
{...register('secretKey')} | ||
placeholder={t('Secret key')} | ||
type="bodyHash" | ||
/> | ||
</FormField> | ||
<Input | ||
type="text" | ||
placeholder={t('Account name')} | ||
{...register('name')} | ||
error={!!errors.name} | ||
validationText={errors.name?.message} | ||
/> | ||
</InputsContainer> | ||
</ContentContainer> | ||
); | ||
}; |
Oops, something went wrong.