Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
Merge pull request #84 from scottcanoni/feature/too-many-secrets
Browse files Browse the repository at this point in the history
Adding an option to hide the seed phrase
  • Loading branch information
mpetrunic authored Jan 18, 2022
2 parents 09bc2b6 + dde73fd commit fd5790a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
3 changes: 2 additions & 1 deletion docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ interface MetamaskOptions {
seed?: string;
password?: string;
showTestNets?: boolean;
hideSeed?: boolean;
}
```

Expand Down Expand Up @@ -109,4 +110,4 @@ enables the app to connect to MetaMask account in privacy mode

<a name="page"></a>
## `metamask.page` is Metamask plugin `Page`
**for advanced usages** in case you need custom features.
**for advanced usages** in case you need custom features.
23 changes: 18 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export type MetamaskOptions = {
seed?: string;
password?: string;
showTestNets?: boolean;
hideSeed?: boolean;
};

export type AddNetwork = {
Expand Down Expand Up @@ -117,6 +118,7 @@ export async function setupMetamask(
page,
options.seed || 'already turtle birth enroll since owner keep patch skirt drift any dinner',
options.password || 'password1234',
options.hideSeed,
);

await closeNotificationPage(browser);
Expand Down Expand Up @@ -191,18 +193,29 @@ async function confirmWelcomeScreen(metamaskPage: puppeteer.Page): Promise<void>
await continueButton.click();
}

async function importAccount(metamaskPage: puppeteer.Page, seed: string, password: string): Promise<void> {
async function importAccount(
metamaskPage: puppeteer.Page,
seed: string,
password: string,
hideSeed: boolean,
): Promise<void> {
const importLink = await metamaskPage.waitForSelector('.first-time-flow button');
await importLink.click();

const metricsOptOut = await metamaskPage.waitForSelector('.metametrics-opt-in button.btn-primary');
await metricsOptOut.click();

const showSeedPhraseInput = await metamaskPage.waitForSelector('#ftf-chk1-label');
await showSeedPhraseInput.click();
if (hideSeed) {
const seedPhraseInput = await metamaskPage.waitForSelector('.first-time-flow__seedphrase input[type=password]');
await seedPhraseInput.click();
await seedPhraseInput.type(seed);
} else {
const showSeedPhraseInput = await metamaskPage.waitForSelector('#ftf-chk1-label');
await showSeedPhraseInput.click();

const seedPhraseInput = await metamaskPage.waitForSelector('.first-time-flow textarea');
await seedPhraseInput.type(seed);
const seedPhraseInput = await metamaskPage.waitForSelector('.first-time-flow textarea');
await seedPhraseInput.type(seed);
}

const passwordInput = await metamaskPage.waitForSelector('#password');
await passwordInput.type(password);
Expand Down

0 comments on commit fd5790a

Please sign in to comment.