From 37833d4e611fce5c972b572ede3e2fbffdab8546 Mon Sep 17 00:00:00 2001 From: bayological <6872903+bayological@users.noreply.github.com> Date: Fri, 26 Nov 2021 09:50:00 -0500 Subject: [PATCH] feat: create function to add token --- src/metamask/addToken.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/metamask/addToken.ts diff --git a/src/metamask/addToken.ts b/src/metamask/addToken.ts new file mode 100644 index 00000000..ec2267f5 --- /dev/null +++ b/src/metamask/addToken.ts @@ -0,0 +1,19 @@ +import { Page } from 'puppeteer'; + +export const addToken = (page: Page) => async (tokenAddress: string): Promise => { + await page.bringToFront(); + + const addTokenButton = await page.waitForSelector('.add-token-button > button'); + await addTokenButton.click(); + + const addressInput = await page.waitForSelector('#custom-address'); + addressInput.type(tokenAddress); + + await page.waitForTimeout(4000); + + const nextButton = await page.waitForSelector(`button[data-testid='page-container-footer-next']:not([disabled])`); + await nextButton.click(); + + const footerButtons = await page.$$('footer > button'); + await footerButtons[1].click(); +};