Skip to content

Commit

Permalink
✨ feat(metamask): Check if onboarding process is completed (#1041)
Browse files Browse the repository at this point in the history
  • Loading branch information
duckception authored Dec 14, 2023
1 parent bc82498 commit 5e674f8
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions wallets/metamask/src/pages/OnboardingPage/actions/importWallet.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import assert from 'node:assert'
import type { Page } from '@playwright/test'
import { closePopover } from '../../HomePage/actions'
import HomePageSelectors from '../../HomePage/selectors'
import Selectors from '../selectors'
import { confirmSecretRecoveryPhrase, createPassword } from './helpers'

Expand All @@ -19,4 +21,23 @@ export async function importWallet(page: Page, seedPhrase: string, password: str
await page.locator(Selectors.PinExtensionPageSelectors.confirmButton).click()

await closePopover(page)

await verifyImportedWallet(page)
}

// Checks if the wallet was imported successfully.
// On rare occasions, the MetaMask hangs during the onboarding process.
async function verifyImportedWallet(page: Page) {
const accountAddress = await page.locator(HomePageSelectors.copyAccountAddressButton).textContent()

assert.strictEqual(
accountAddress?.startsWith('0x'),
true,
new Error(
[
`Incorrect state after importing the seed phrase. Account address is expected to start with "0x", but got "${accountAddress}" instead.`,
'Note: Try to re-run the cache creation. This is a known but rare error where MetaMask hangs during the onboarding process. If it persists, please file an issue on GitHub.'
].join('\n')
)
)
}

0 comments on commit 5e674f8

Please sign in to comment.