This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: replace outdated methods (#189)
* feat!: replaced addTokenMethod * feat: remove add network method
- Loading branch information
Showing
7 changed files
with
139 additions
and
120 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,22 @@ | ||
import { | ||
clickOnButton, | ||
getErrorMessage, | ||
openNetworkDropdown, | ||
typeOnInputField, | ||
} from "../helpers"; | ||
import { AddNetwork } from "../index"; | ||
import { clickOnButton } from "../helpers"; | ||
import { DappeteerPage } from "../page"; | ||
|
||
export const addNetwork = | ||
export const acceptAddNetwork = | ||
(page: DappeteerPage) => | ||
async ({ networkName, rpc, chainId, symbol }: AddNetwork): Promise<void> => { | ||
async (shouldSwitch = false): Promise<void> => { | ||
await page.bringToFront(); | ||
await openNetworkDropdown(page); | ||
await clickOnButton(page, "Add network"); | ||
|
||
const responsePromise = page.waitForResponse( | ||
(response) => new URL(response.url()).pathname === new URL(rpc).pathname | ||
); | ||
|
||
await page.waitForTimeout(500); | ||
|
||
await typeOnInputField(page, "Network name", networkName); | ||
await typeOnInputField(page, "New RPC URL", rpc); | ||
await typeOnInputField(page, "Chain ID", String(chainId)); | ||
await typeOnInputField(page, "Currency symbol", symbol); | ||
|
||
await responsePromise; | ||
await page.waitForTimeout(500); | ||
|
||
const errorMessage = await getErrorMessage(page); | ||
if (errorMessage) throw new SyntaxError(errorMessage); | ||
|
||
await clickOnButton(page, "Save"); | ||
await page.reload(); | ||
await clickOnButton(page, "Approve"); | ||
if (shouldSwitch) { | ||
await clickOnButton(page, "Switch network"); | ||
} else { | ||
await clickOnButton(page, "Cancel"); | ||
} | ||
}; | ||
|
||
await page.waitForXPath(`//*[text() = '${networkName}']`); | ||
await clickOnButton(page, "Got it"); | ||
export const rejectAddNetwork = | ||
(page: DappeteerPage) => async (): Promise<void> => { | ||
await page.bringToFront(); | ||
await page.reload(); | ||
await clickOnButton(page, "Cancel"); | ||
}; |
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 |
---|---|---|
@@ -1,32 +1,16 @@ | ||
import { | ||
clickOnButton, | ||
clickOnElement, | ||
clickOnLogo, | ||
getElementByContent, | ||
typeOnInputField, | ||
} from "../helpers"; | ||
import { AddToken } from "../index"; | ||
import { clickOnButton } from "../helpers"; | ||
import { DappeteerPage } from "../page"; | ||
|
||
export const addToken = | ||
(page: DappeteerPage) => | ||
async ({ tokenAddress, symbol, decimals = 0 }: AddToken): Promise<void> => { | ||
export const acceptAddToken = | ||
(page: DappeteerPage) => async (): Promise<void> => { | ||
await page.bringToFront(); | ||
await clickOnButton(page, "Assets"); | ||
await page.waitForSelector(".asset-list-item__token-button", { | ||
visible: true, | ||
}); | ||
await clickOnElement(page, "import tokens"); | ||
await clickOnButton(page, "Custom token"); | ||
|
||
await typeOnInputField(page, "Token decimal", String(decimals), true); | ||
await typeOnInputField(page, "Token contract address", tokenAddress); | ||
await page.waitForTimeout(333); | ||
await typeOnInputField(page, "Token symbol", symbol, true); | ||
|
||
await clickOnButton(page, "Add custom token"); | ||
await clickOnButton(page, "Import tokens"); | ||
await page.reload(); | ||
await clickOnButton(page, "Add token"); | ||
}; | ||
|
||
await getElementByContent(page, symbol); | ||
await clickOnLogo(page); | ||
export const rejectAddToken = | ||
(page: DappeteerPage) => async (): Promise<void> => { | ||
await page.bringToFront(); | ||
await page.reload(); | ||
await clickOnButton(page, "Cancel"); | ||
}; |
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