diff --git a/wallets/phantom/src/cypress/Phantom.ts b/wallets/phantom/src/cypress/Phantom.ts index 4b52a77f..5123aae4 100644 --- a/wallets/phantom/src/cypress/Phantom.ts +++ b/wallets/phantom/src/cypress/Phantom.ts @@ -1,5 +1,4 @@ import { type BrowserContext, type Page, expect } from '@playwright/test' -import { type Anvil, type CreateAnvilOptions, type Pool, createPool } from '@viem/anvil' import { Phantom as PhantomPlaywright } from '../playwright/Phantom' import { waitFor } from '../playwright/utils/waitFor' import HomePageSelectors from '../selectors/pages/HomePage' @@ -7,11 +6,8 @@ import Selectors from '../selectors/pages/HomePage' import type { SettingsSidebarMenus } from '../selectors/pages/HomePage/settings' import TransactionPage from '../selectors/pages/NotificationPage/transactionPage' import type { GasSettings } from '../type/GasSettings' -import type { Network } from '../type/Network' import getPlaywrightPhantom from './getPlaywrightPhantom' -let pool: Pool - /** * Phantom class for interacting with the Phantom extension in Cypress tests. */ @@ -173,90 +169,6 @@ export default class Phantom { }) } - /** - * Creates an Anvil node for testing. - * @param options - Optional Anvil node creation options - * @returns Object containing the Anvil instance, RPC URL, and chain ID - */ - async createAnvilNode(options?: CreateAnvilOptions): Promise<{ anvil: Anvil; rpcUrl: string; chainId: number }> { - pool = createPool() - const nodeId = Array.from(pool.instances()).length - const anvil = await pool.start(nodeId, options) - const rpcUrl = `http://${anvil.host}:${anvil.port}` - const DEFAULT_ANVIL_CHAIN_ID = 31337 - const chainId = options?.chainId ?? DEFAULT_ANVIL_CHAIN_ID - return { anvil, rpcUrl, chainId } - } - - /** - * Empties the Anvil node pool. - * @returns True if the operation was successful - */ - async emptyAnvilNode(): Promise { - await pool.empty() - return true - } - - /** - * Connects to an Anvil node. - * @param options - Object containing the RPC URL and chain ID - * @param options.rpcUrl - The RPC URL of the Anvil node - * @param options.chainId - The chain ID of the Anvil node - * @returns True if the connection was successful, false otherwise - */ - async connectToAnvil({ - rpcUrl, - chainId - }: { - rpcUrl: string - chainId: number - }): Promise { - try { - await this.phantomPlaywright.addNetwork({ - name: 'Anvil', - rpcUrl, - chainId, - symbol: 'ETH', - blockExplorerUrl: 'https://etherscan.io/' - }) - await this.phantomPlaywright.switchNetwork('Anvil') - return true - } catch (e) { - console.error('Error connecting to Anvil network', e) - return false - } - } - - /** - * Adds a new network to Phantom. - * @param network - The network configuration to add - * @returns True if the network was added successfully - */ - async addNetwork(network: Network): Promise { - await this.phantomPlaywright.addNetwork(network) - await waitFor( - () => this.phantomExtensionPage.locator(HomePageSelectors.networkAddedPopover.switchToNetworkButton).isVisible(), - 3_000, - false - ) - await this.phantomExtensionPage.locator(HomePageSelectors.networkAddedPopover.switchToNetworkButton).click() - return true - } - - /** - * Deploys a token. - * @returns True if the token was deployed successfully - */ - async deployToken(): Promise { - await waitFor( - () => this.phantomExtensionPage.locator(TransactionPage.nftApproveAllConfirmationPopup.approveButton).isVisible(), - 3_000, - false - ) - await this.phantomPlaywright.confirmTransaction() - return true - } - /** * Adds a new token to Phantom. * @returns True if the token was added successfully @@ -297,62 +209,6 @@ export default class Phantom { return true } - /** - * Approves adding a new network. - * @returns True if the new network was approved successfully - */ - async approveNewNetwork(): Promise { - await this.phantomPlaywright.approveNewNetwork() - return true - } - - /** - * Approves switching to a new network. - * @returns True if the network switch was approved successfully - */ - async approveSwitchNetwork(): Promise { - await this.phantomPlaywright.approveSwitchNetwork() - return true - } - - /** - * Rejects adding a new network. - * @returns True if the new network was rejected successfully - */ - async rejectNewNetwork(): Promise { - await this.phantomPlaywright.rejectNewNetwork() - return true - } - - /** - * Rejects switching to a new network. - * @returns True if the network switch was rejected successfully - */ - async rejectSwitchNetwork(): Promise { - await this.phantomPlaywright.rejectSwitchNetwork() - return true - } - - /** - * Approves adding a new RPC provider for Ethereum Mainnet. - * - * @returns True if the RPC provider was approved successfully - */ - async approveNewEthereumRPC(): Promise { - await this.phantomPlaywright.approveNewEthereumRPC() - return true - } - - /** - * Rejects adding a new RPC provider for Ethereum Mainnet. - * - * @returns True if the RPC provider was rejected successfully - */ - async rejectNewEthereumRPC(): Promise { - await this.phantomPlaywright.rejectNewEthereumRPC() - return true - } - /** * Locks the Phantom wallet. * @returns True if the wallet was locked successfully diff --git a/wallets/phantom/src/cypress/configureSynpress.ts b/wallets/phantom/src/cypress/configureSynpress.ts index b55ac7f0..58bc4533 100644 --- a/wallets/phantom/src/cypress/configureSynpress.ts +++ b/wallets/phantom/src/cypress/configureSynpress.ts @@ -1,9 +1,7 @@ import type { BrowserContext, Page } from '@playwright/test' import { ensureRdpPort } from '@synthetixio/synpress-core' -import type { CreateAnvilOptions } from '@viem/anvil' import type { SettingsSidebarMenus } from '../selectors/pages/HomePage/settings' import type { GasSettings } from '../type/GasSettings' -import type { Network } from '../type/Network' import Phantom from './Phantom' import importPhantomWallet from './support/importPhantomWallet' import { initPhantom } from './support/initPhantom' @@ -140,20 +138,8 @@ export default function configureSynpress( networkName, isTestnet }), - addNetwork: (network: Network) => phantom?.addNetwork(network), - approveNewNetwork: () => phantom?.approveNewNetwork(), - approveSwitchNetwork: () => phantom?.approveSwitchNetwork(), - approveNewEthereumRPC: () => phantom?.approveNewEthereumRPC(), - rejectNewNetwork: () => phantom?.rejectNewNetwork(), - rejectSwitchNetwork: () => phantom?.rejectSwitchNetwork(), - rejectNewEthereumRPC: () => phantom?.rejectNewEthereumRPC(), - - // Anvil - createAnvilNode: (options?: CreateAnvilOptions) => phantom?.createAnvilNode(options), - emptyAnvilNode: () => phantom?.emptyAnvilNode(), // Token - deployToken: () => phantom?.deployToken(), addNewToken: () => phantom?.addNewToken(), approveTokenPermission: (options?: { spendLimit?: number | 'max' diff --git a/wallets/phantom/src/cypress/support/synpressCommands.ts b/wallets/phantom/src/cypress/support/synpressCommands.ts index 21ea249e..65eb66c1 100644 --- a/wallets/phantom/src/cypress/support/synpressCommands.ts +++ b/wallets/phantom/src/cypress/support/synpressCommands.ts @@ -9,10 +9,8 @@ // https://on.cypress.io/custom-commands // *********************************************** -import type { Anvil, CreateAnvilOptions } from '@viem/anvil' import type { SettingsSidebarMenus } from '../../selectors/pages/HomePage/settings' import type { GasSettings } from '../../type/GasSettings' -import type { Network } from '../../type/Network' declare global { namespace Cypress { @@ -32,22 +30,7 @@ declare global { resetAccount(): Chainable switchNetwork(networkName: string, isTestnet?: boolean): Chainable - createAnvilNode(options?: CreateAnvilOptions): Chainable<{ - anvil: Anvil - rpcUrl: string - chainId: number - }> - connectToAnvil(): Chainable - emptyAnvilNode(): Chainable - addNetwork(network: Network): Chainable - approveNewNetwork(): Chainable - approveSwitchNetwork(): Chainable - approveNewEthereumRPC(): Chainable - rejectNewNetwork(): Chainable - rejectSwitchNetwork(): Chainable - rejectNewEthereumRPC(): Chainable - - deployToken(): Chainable + addNewToken(): Chainable approveTokenPermission(options?: { spendLimit?: number | 'max' @@ -59,7 +42,9 @@ declare global { decrypt(): Chainable confirmSignature(): Chainable rejectSignature(): Chainable - confirmTransaction(options?: { gasSetting?: GasSettings }): Chainable + confirmTransaction(options?: { + gasSetting?: GasSettings + }): Chainable rejectTransaction(): Chainable confirmTransactionAndWaitForMining(): Chainable openTransactionDetails(txIndex: number): Chainable @@ -90,7 +75,7 @@ declare global { * Key features: * - Wallet: Import wallet, connect to dApps * - Account: Add, switch, rename, reset accounts - * - Network: Switch networks, create and manage Anvil nodes, add custom networks + * - Network: Switch networks * - Tokens: Deploy tokens, add new tokens, approve token permissions * - Transactions: Confirm, reject, and view transaction details * - Phantom UI: Lock/unlock, toggle settings, navigate UI @@ -195,104 +180,8 @@ export default function synpressCommandsForPhantom(): void { return cy.task('switchNetwork', { networkName, isTestnet }) }) - /** - * Creates an Anvil node - * @param options - Options for creating the Anvil node - * @returns An object containing the Anvil instance, RPC URL, and chain ID - */ - Cypress.Commands.add('createAnvilNode', (options?: CreateAnvilOptions) => { - return cy.task('createAnvilNode', options) - }) - - /** - * Connects to an Anvil node - */ - Cypress.Commands.add('connectToAnvil', () => { - return cy.task('createAnvilNode').then((anvilNetwork) => { - const anvilNetworkDetails = anvilNetwork as { - anvil: Anvil - rpcUrl: string - chainId: number - } - - const network = { - name: 'Anvil', - rpcUrl: anvilNetworkDetails.rpcUrl, - chainId: anvilNetworkDetails.chainId, - symbol: 'ETH', - blockExplorerUrl: 'https://etherscan.io/' - } - - return cy.task('addNetwork', network) - }) - }) - - /** - * Empties the Anvil node - */ - Cypress.Commands.add('emptyAnvilNode', () => { - return cy.task('emptyAnvilNode') - }) - - /** - * Adds a new network - * @param network - The network to add - */ - Cypress.Commands.add('addNetwork', (network: Network) => { - return cy.task('addNetwork', network) - }) - - /** - * Approves adding a new network - */ - Cypress.Commands.add('approveNewNetwork', () => { - return cy.task('approveNewNetwork') - }) - - /** - * Approves switching to a new network - */ - Cypress.Commands.add('approveSwitchNetwork', () => { - return cy.task('approveSwitchNetwork') - }) - - /** - * Rejects adding a new network - */ - Cypress.Commands.add('rejectNewNetwork', () => { - return cy.task('rejectNewNetwork') - }) - - /** - * Rejects switching to a new network - */ - Cypress.Commands.add('rejectSwitchNetwork', () => { - return cy.task('rejectSwitchNetwork') - }) - - /** - * Approves adding a new RPC provider for Ethereum Mainnet - */ - Cypress.Commands.add('approveNewEthereumRPC', () => { - return cy.task('approveNewEthereumRPC') - }) - - /** - * Rejects adding a new RPC provider for Ethereum Mainnet - */ - Cypress.Commands.add('rejectNewEthereumRPC', () => { - return cy.task('rejectNewEthereumRPC') - }) - // Token - /** - * Deploys a token - */ - Cypress.Commands.add('deployToken', () => { - return cy.task('deployToken') - }) - /** * Adds a new token */ @@ -308,10 +197,7 @@ export default function synpressCommandsForPhantom(): void { */ Cypress.Commands.add( 'approveTokenPermission', - (options?: { - spendLimit?: number | 'max' - gasSetting?: GasSettings - }) => { + (options?: { spendLimit?: number | 'max'; gasSetting?: GasSettings }) => { return cy.task('approveTokenPermission', options) } ) diff --git a/wallets/phantom/src/playwright/Phantom.ts b/wallets/phantom/src/playwright/Phantom.ts index 9c86f726..e580f4a0 100644 --- a/wallets/phantom/src/playwright/Phantom.ts +++ b/wallets/phantom/src/playwright/Phantom.ts @@ -1,7 +1,6 @@ import type { BrowserContext, Page } from '@playwright/test' import { SettingsSidebarMenus } from '../selectors/pages/HomePage/settings' import type { GasSettings } from '../type/GasSettings' -import type { Network } from '../type/Network' import { PhantomAbstract } from '../type/PhantomAbstract' import { CrashPage, HomePage, LockPage, NotificationPage, OnboardingPage } from './pages' import { SettingsPage } from './pages/SettingsPage/page' @@ -147,15 +146,6 @@ export class Phantom extends PhantomAbstract { await this.homePage.switchAccount(accountName) } - /** - * Adds a new network to Phantom. - * - * @param network - The network configuration to add. - */ - async addNetwork(network: Network): Promise { - await this.homePage.addNetwork(network) - } - /** * Gets the address of the currently selected account. * @@ -242,84 +232,6 @@ export class Phantom extends PhantomAbstract { await this.notificationPage.rejectMessage(this.extensionId) } - /** - * Approves adding a new network. - * - * @throws {Error} If extensionId is not set. - */ - async approveNewNetwork(): Promise { - if (!this.extensionId) { - throw NO_EXTENSION_ID_ERROR - } - - await this.notificationPage.approveNewNetwork(this.extensionId) - } - - /** - * Rejects adding a new network. - * - * @throws {Error} If extensionId is not set. - */ - async rejectNewNetwork(): Promise { - if (!this.extensionId) { - throw NO_EXTENSION_ID_ERROR - } - - await this.notificationPage.rejectNewNetwork(this.extensionId) - } - - /** - * Approves switching to a new network. - * - * @throws {Error} If extensionId is not set. - */ - async approveSwitchNetwork(): Promise { - if (!this.extensionId) { - throw NO_EXTENSION_ID_ERROR - } - - await this.notificationPage.approveSwitchNetwork(this.extensionId) - } - - /** - * Rejects switching to a new network. - * - * @throws {Error} If extensionId is not set. - */ - async rejectSwitchNetwork(): Promise { - if (!this.extensionId) { - throw NO_EXTENSION_ID_ERROR - } - - await this.notificationPage.rejectSwitchNetwork(this.extensionId) - } - - /** - * Approves adding a new RPC provider for Ethereum Mainnet. - * - * @throws {Error} If extensionId is not set. - */ - async approveNewEthereumRPC(): Promise { - if (!this.extensionId) { - throw NO_EXTENSION_ID_ERROR - } - - await this.notificationPage.approveNewEthereumRPC(this.extensionId) - } - - /** - * Rejects adding a new RPC provider for Ethereum Mainnet. - * - * @throws {Error} If extensionId is not set. - */ - async rejectNewEthereumRPC(): Promise { - if (!this.extensionId) { - throw NO_EXTENSION_ID_ERROR - } - - await this.notificationPage.rejectNewEthereumRPC(this.extensionId) - } - /** * Confirms a transaction. * diff --git a/wallets/phantom/src/playwright/fixtures/phantomFixtures.ts b/wallets/phantom/src/playwright/fixtures/phantomFixtures.ts index c54ad283..f1a37207 100644 --- a/wallets/phantom/src/playwright/fixtures/phantomFixtures.ts +++ b/wallets/phantom/src/playwright/fixtures/phantomFixtures.ts @@ -7,7 +7,6 @@ import { defineWalletSetup, removeTempContextDir } from '@synthetixio/synpress-cache' -import { type Anvil, type CreateAnvilOptions, createPool } from '@viem/anvil' import fs from 'fs-extra' import { prepareExtensionPhantom } from '../../prepareExtensionPhantom' import { Phantom } from '../Phantom' @@ -20,10 +19,6 @@ type PhantomFixtures = { phantom: Phantom extensionId: string phantomPage: Page - createAnvilNode: (options?: CreateAnvilOptions) => Promise<{ anvil: Anvil; rpcUrl: string; chainId: number }> - connectToAnvil: () => Promise - deployToken: () => Promise - deployAndMintERC1155: () => Promise } // If setup phantomPage in a fixture, browser does not handle it properly (even if ethereum.isConnected() is true, it's not reflected on the page). @@ -109,58 +104,6 @@ export const phantomFixtures = (walletSetup: ReturnType { - const pool = createPool() - - await use(async (options?: CreateAnvilOptions) => { - const nodeId = Array.from(pool.instances()).length - const anvil = await pool.start(nodeId, options) - - const rpcUrl = `http://${anvil.host}:${anvil.port}` - - const DEFAULT_ANVIL_CHAIN_ID = 31337 - const chainId = options?.chainId ?? DEFAULT_ANVIL_CHAIN_ID - - return { anvil, rpcUrl, chainId } - }) - - await pool.empty() - }, - connectToAnvil: async ({ phantom, createAnvilNode }, use) => { - await use(async () => { - const { rpcUrl, chainId } = await createAnvilNode({ - chainId: 1338 - }) - - await phantom.addNetwork({ - name: 'Anvil', - rpcUrl, - chainId, - symbol: 'ETH', - blockExplorerUrl: 'https://etherscan.io/' - }) - }) - }, - deployToken: async ({ page, phantom, connectToAnvil }, use) => { - await use(async () => { - await connectToAnvil() - - await page.locator('#createToken').click() - - await phantom.confirmTransaction() - }) - }, - deployAndMintERC1155: async ({ page, phantom, connectToAnvil }, use) => { - await use(async () => { - await connectToAnvil() - - await page.locator('#deployERC1155Button').click() - await phantom.confirmTransaction() - - await page.locator('#batchMintButton').click() - await phantom.confirmTransactionAndWaitForMining() - }) } }) } diff --git a/wallets/phantom/src/playwright/pages/HomePage/actions/addNetwork.ts b/wallets/phantom/src/playwright/pages/HomePage/actions/addNetwork.ts deleted file mode 100644 index 0162ca5f..00000000 --- a/wallets/phantom/src/playwright/pages/HomePage/actions/addNetwork.ts +++ /dev/null @@ -1,56 +0,0 @@ -import type { Page } from '@playwright/test' -import Selectors from '../../../../selectors/pages/HomePage' -import { type Network, NetworkValidation } from '../../../../type/Network' -import { waitFor } from '../../../utils/waitFor' -import { closeNetworkAddedPopover, closeNewNetworkInfoPopover } from './popups' - -export async function addNetwork(page: Page, network: Network) { - const { name, rpcUrl, chainId, symbol, blockExplorerUrl } = NetworkValidation.parse(network) - - await page.locator(Selectors.networkDropdown.dropdownButton).click() - await page.locator(Selectors.networkDropdown.addNetworkButton).click() - - await page.locator(Selectors.settings.networks.addNetworkManuallyButton).click() - - await page.locator(Selectors.settings.networks.newNetworkForm.networkNameInput).fill(name) - - await page.locator(Selectors.settings.networks.newNetworkForm.rpcUrlInput).fill(rpcUrl) - - // We have to wait for the RPC URL error to appear. - const rpcUrlErrorLocator = page.locator(Selectors.settings.networks.newNetworkForm.rpcUrlError) - if (await waitFor(() => rpcUrlErrorLocator.isVisible(), 1_000, false)) { - const rpcUrlErrorText = await rpcUrlErrorLocator.textContent({ - timeout: 1_000 - }) - throw new Error(`[AddNetwork] RPC URL error: ${rpcUrlErrorText}`) - } - - await page.locator(Selectors.settings.networks.newNetworkForm.chainIdInput).fill(chainId.toString()) - - // We have to wait for the Chain ID error to appear. - const chainIdErrorLocator = page.locator(Selectors.settings.networks.newNetworkForm.chainIdError) - if (await waitFor(() => chainIdErrorLocator.isVisible(), 1_000, false)) { - const chainIdErrorText = await chainIdErrorLocator.textContent({ - timeout: 1_000 - }) - throw new Error(`[AddNetwork] Chain ID error: ${chainIdErrorText}`) - } - - await page.locator(Selectors.settings.networks.newNetworkForm.symbolInput).fill(symbol) - - await waitFor( - async () => page.locator(Selectors.settings.networks.newNetworkForm.symbolError).isVisible(), - 1_000, - false - ) - - if (blockExplorerUrl) { - await page.locator(Selectors.settings.networks.newNetworkForm.blockExplorerUrlInput).fill(blockExplorerUrl) - } - - await page.locator(Selectors.settings.networks.newNetworkForm.saveButton).click() - - await closeNetworkAddedPopover(page) - - await closeNewNetworkInfoPopover(page) -} diff --git a/wallets/phantom/src/playwright/pages/HomePage/actions/index.ts b/wallets/phantom/src/playwright/pages/HomePage/actions/index.ts index 05f91893..edb5c450 100644 --- a/wallets/phantom/src/playwright/pages/HomePage/actions/index.ts +++ b/wallets/phantom/src/playwright/pages/HomePage/actions/index.ts @@ -4,7 +4,6 @@ export * from './importWalletFromPrivateKey' export * from './switchAccount' export * from './settings' export * from './switchNetwork' -export * from './addNetwork' export * from './toggleShowTestNetworks' export * from './addNewAccount' export * from './transactionDetails' diff --git a/wallets/phantom/src/playwright/pages/HomePage/page.ts b/wallets/phantom/src/playwright/pages/HomePage/page.ts index af11bc91..ce99f390 100644 --- a/wallets/phantom/src/playwright/pages/HomePage/page.ts +++ b/wallets/phantom/src/playwright/pages/HomePage/page.ts @@ -1,9 +1,7 @@ import type { Page } from '@playwright/test' import Selectors from '../../../selectors/pages/HomePage' import type { SettingsSidebarMenus } from '../../../selectors/pages/HomePage/settings' -import type { Network } from '../../../type/Network' import { - addNetwork, addNewAccount, getAccountAddress, importWalletFromPrivateKey, @@ -82,10 +80,6 @@ export class HomePage { await switchNetwork(this.page, networkName, isTestnet) } - async addNetwork(network: Network) { - await addNetwork(this.page, network) - } - async openTransactionDetails(txIndex: number) { await transactionDetails.open(this.page, txIndex) } diff --git a/wallets/phantom/src/playwright/pages/NotificationPage/actions/ethereumRpc.ts b/wallets/phantom/src/playwright/pages/NotificationPage/actions/ethereumRpc.ts deleted file mode 100644 index 1c3f6d1c..00000000 --- a/wallets/phantom/src/playwright/pages/NotificationPage/actions/ethereumRpc.ts +++ /dev/null @@ -1,15 +0,0 @@ -import type { Page } from '@playwright/test' -import Selectors from '../../../../selectors/pages/NotificationPage' - -const approveNewEthereumRPC = async (notificationPage: Page) => { - await notificationPage.locator(Selectors.EthereumRpcPage.approveNewRpc).click() -} - -const rejectNewEthereumRPC = async (notificationPage: Page) => { - await notificationPage.locator(Selectors.EthereumRpcPage.rejectNewRpc).click() -} - -export const ethereumRpc = { - approveNewEthereumRPC, - rejectNewEthereumRPC -} diff --git a/wallets/phantom/src/playwright/pages/NotificationPage/actions/index.ts b/wallets/phantom/src/playwright/pages/NotificationPage/actions/index.ts index 11a7730c..d7348e72 100644 --- a/wallets/phantom/src/playwright/pages/NotificationPage/actions/index.ts +++ b/wallets/phantom/src/playwright/pages/NotificationPage/actions/index.ts @@ -3,7 +3,5 @@ export * from './signSimpleMessage' export * from './signStructuredMessage' export * from './approvePermission' export * from './transaction' -export * from './network' export * from './token' export * from './encryption' -export * from './ethereumRpc' diff --git a/wallets/phantom/src/playwright/pages/NotificationPage/actions/network.ts b/wallets/phantom/src/playwright/pages/NotificationPage/actions/network.ts deleted file mode 100644 index bafe7e69..00000000 --- a/wallets/phantom/src/playwright/pages/NotificationPage/actions/network.ts +++ /dev/null @@ -1,25 +0,0 @@ -import type { Page } from '@playwright/test' -import Selectors from '../../../../selectors/pages/NotificationPage' - -const approveNewNetwork = async (notificationPage: Page) => { - await notificationPage.locator(Selectors.NetworkPage.addNetwork.approveButton).click() -} - -const rejectNewNetwork = async (notificationPage: Page) => { - await notificationPage.locator(Selectors.NetworkPage.addNetwork.cancelButton).click() -} - -const approveSwitchNetwork = async (notificationPage: Page) => { - await notificationPage.locator(Selectors.NetworkPage.switchNetwork.switchNetworkButton).click() -} - -const rejectSwitchNetwork = async (notificationPage: Page) => { - await notificationPage.locator(Selectors.NetworkPage.switchNetwork.cancelButton).click() -} - -export const network = { - approveNewNetwork, - rejectNewNetwork, - approveSwitchNetwork, - rejectSwitchNetwork -} diff --git a/wallets/phantom/src/playwright/pages/NotificationPage/page.ts b/wallets/phantom/src/playwright/pages/NotificationPage/page.ts index 12209d59..94d39481 100644 --- a/wallets/phantom/src/playwright/pages/NotificationPage/page.ts +++ b/wallets/phantom/src/playwright/pages/NotificationPage/page.ts @@ -6,8 +6,6 @@ import { approvePermission, connectToDapp, decryptMessage, - ethereumRpc, - network, providePublicEncryptionKey, signSimpleMessage, signStructuredMessage, @@ -76,42 +74,6 @@ export class NotificationPage { } } - async approveNewNetwork(extensionId: string) { - const notificationPage = await getNotificationPageAndWaitForLoad(this.page.context(), extensionId) - - await network.approveNewNetwork(notificationPage) - } - - async rejectNewNetwork(extensionId: string) { - const notificationPage = await getNotificationPageAndWaitForLoad(this.page.context(), extensionId) - - await network.rejectNewNetwork(notificationPage) - } - - async approveSwitchNetwork(extensionId: string) { - const notificationPage = await getNotificationPageAndWaitForLoad(this.page.context(), extensionId) - - await network.approveSwitchNetwork(notificationPage) - } - - async rejectSwitchNetwork(extensionId: string) { - const notificationPage = await getNotificationPageAndWaitForLoad(this.page.context(), extensionId) - - await network.rejectSwitchNetwork(notificationPage) - } - - async approveNewEthereumRPC(extensionId: string) { - const notificationPage = await getNotificationPageAndWaitForLoad(this.page.context(), extensionId) - - await ethereumRpc.approveNewEthereumRPC(notificationPage) - } - - async rejectNewEthereumRPC(extensionId: string) { - const notificationPage = await getNotificationPageAndWaitForLoad(this.page.context(), extensionId) - - await ethereumRpc.rejectNewEthereumRPC(notificationPage) - } - async confirmTransaction(extensionId: string, options?: { gasSetting?: GasSettings }) { const notificationPage = await getNotificationPageAndWaitForLoad(this.page.context(), extensionId) diff --git a/wallets/phantom/src/selectors/pages/HomePage/index.ts b/wallets/phantom/src/selectors/pages/HomePage/index.ts index f21cf438..2a5cd6ee 100644 --- a/wallets/phantom/src/selectors/pages/HomePage/index.ts +++ b/wallets/phantom/src/selectors/pages/HomePage/index.ts @@ -88,7 +88,6 @@ const networkDropdown = { networksList: `${networkDropdownContainer} .multichain-network-list-menu`, networks: `${networkDropdownContainer} .multichain-network-list-item p`, showTestNetworksToggle: `${networkDropdownContainer} > section > div > label.toggle-button`, - addNetworkButton: `${networkDropdownContainer} div.mm-box.mm-box--padding-4 > button`, toggleOff: `${networkDropdownContainer} label.toggle-button.toggle-button--off`, toggleOn: `${networkDropdownContainer} label.toggle-button.toggle-button--on`, closeNetworkPopupButton: diff --git a/wallets/phantom/src/selectors/pages/HomePage/settings.ts b/wallets/phantom/src/selectors/pages/HomePage/settings.ts index e4b58898..43ba4a73 100644 --- a/wallets/phantom/src/selectors/pages/HomePage/settings.ts +++ b/wallets/phantom/src/selectors/pages/HomePage/settings.ts @@ -28,27 +28,8 @@ const advanced = { dismissSecretRecoveryPhraseReminderToggle: '.settings-page__content-row:nth-of-type(11) .toggle-button' } -const newNetworkFormContainer = '.networks-tab__add-network-form' -const newNetworkForm = { - networkNameInput: `${newNetworkFormContainer} .form-field:nth-child(1) input`, - rpcUrlInput: `${newNetworkFormContainer} .form-field:nth-child(2) input`, - rpcUrlError: `${newNetworkFormContainer} .form-field:nth-child(2) .form-field__error`, - chainIdInput: `${newNetworkFormContainer} .form-field:nth-child(3) input`, - chainIdError: `${newNetworkFormContainer} .form-field:nth-child(3) .form-field__error`, - symbolInput: `${createDataTestSelector('network-form-ticker')} input`, - symbolError: createDataTestSelector('network-form-ticker-warning'), - blockExplorerUrlInput: `${newNetworkFormContainer} .form-field:last-child input`, - saveButton: `${newNetworkFormContainer} .networks-tab__add-network-form-footer button.btn-primary` -} - -const networks = { - addNetworkManuallyButton: `${createDataTestSelector('add-network-manually')}`, - newNetworkForm -} - export default { SettingsSidebarMenus, sidebarMenu, - advanced, - networks + advanced } diff --git a/wallets/phantom/src/selectors/pages/NotificationPage/index.ts b/wallets/phantom/src/selectors/pages/NotificationPage/index.ts index 76744ae8..a26d3856 100644 --- a/wallets/phantom/src/selectors/pages/NotificationPage/index.ts +++ b/wallets/phantom/src/selectors/pages/NotificationPage/index.ts @@ -1,6 +1,5 @@ import ActionFooter from './actionFooter' import ConnectPage from './connectPage' -import EthereumRpcPage from './ethereumRpcPage' import NetworkPage from './networkPage' import PermissionPage from './permissionPage' import SignaturePage from './signaturePage' @@ -9,7 +8,6 @@ import TransactionPage from './transactionPage' export default { ActionFooter, ConnectPage, - EthereumRpcPage, NetworkPage, PermissionPage, SignaturePage, diff --git a/wallets/phantom/src/selectors/pages/NotificationPage/networkPage.ts b/wallets/phantom/src/selectors/pages/NotificationPage/networkPage.ts index ec13d78a..3e052b77 100644 --- a/wallets/phantom/src/selectors/pages/NotificationPage/networkPage.ts +++ b/wallets/phantom/src/selectors/pages/NotificationPage/networkPage.ts @@ -1,14 +1,8 @@ -const addNetwork = { - approveButton: '.confirmation-footer__actions button.btn-primary', - cancelButton: '.confirmation-footer__actions button.btn-secondary' -} - const switchNetwork = { switchNetworkButton: '.confirmation-footer__actions button.btn-primary', cancelButton: '.confirmation-footer__actions button.btn-secondary' } export default { - addNetwork, switchNetwork } diff --git a/wallets/phantom/src/type/Network.ts b/wallets/phantom/src/type/Network.ts deleted file mode 100644 index 0621fbd0..00000000 --- a/wallets/phantom/src/type/Network.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { z } from 'zod' - -export const NetworkValidation = z.object({ - name: z.string(), - rpcUrl: z.string(), - chainId: z.number(), - symbol: z.string(), - blockExplorerUrl: z.string().optional() -}) - -export type Network = z.infer diff --git a/wallets/phantom/src/type/PhantomAbstract.ts b/wallets/phantom/src/type/PhantomAbstract.ts index da752998..a079c262 100644 --- a/wallets/phantom/src/type/PhantomAbstract.ts +++ b/wallets/phantom/src/type/PhantomAbstract.ts @@ -1,6 +1,5 @@ import { SettingsSidebarMenus } from '../selectors/pages/HomePage/settings' import type { GasSettings } from './GasSettings' -import type { Network } from './Network' export abstract class PhantomAbstract { /** @@ -55,18 +54,6 @@ export abstract class PhantomAbstract { */ abstract switchAccount(accountName: string): void - /** - * Adds a new network. - * - * @param network - The network object to use for adding the new network. - * @param network.name - The name of the network. - * @param network.rpcUrl - The RPC URL of the network. - * @param network.chainId - The chain ID of the network. - * @param network.symbol - The currency symbol of the network. - * @param network.blockExplorerUrl - The block explorer URL of the network. - */ - abstract addNetwork(network: Network): void - /** * Retrieves the current account address. */ @@ -110,36 +97,6 @@ export abstract class PhantomAbstract { */ abstract rejectSignature(): void - /** - * Approves a new network request. - */ - abstract approveNewNetwork(): void - - /** - * Rejects a new network request. - */ - abstract rejectNewNetwork(): void - - /** - * Approves a switch network request. - */ - abstract approveSwitchNetwork(): void - - /** - * Rejects a switch network request. - */ - abstract rejectSwitchNetwork(): void - - /** - * Approves a new RPC provider request. - */ - abstract approveNewEthereumRPC(): void - - /** - * Rejects a new RPC provider request. - */ - abstract rejectNewEthereumRPC(): void - /** * Confirms a transaction request. *