import { type BrowserContext, type Page } from '@playwright/test'; import { type Anvil, type CreateAnvilOptions } from '@viem/anvil'; import { MetaMask as MetaMaskPlaywright } from '../playwright/MetaMask'; import type { SettingsSidebarMenus } from '../selectors/pages/HomePage/settings'; import type { GasSettings } from '../type/GasSettings'; import type { Network } from '../type/Network'; /** * MetaMask class for interacting with the MetaMask extension in Cypress tests. */ export default class MetaMask { /** The MetaMask instance for Playwright */ readonly metamaskPlaywright: MetaMaskPlaywright; /** The MetaMask extension page */ readonly metamaskExtensionPage: Page; /** * Creates an instance of MetaMask. * @param context - The browser context * @param metamaskExtensionPage - The MetaMask extension page * @param metamaskExtensionId - The MetaMask extension ID */ constructor(context: BrowserContext, metamaskExtensionPage: Page, metamaskExtensionId: string); /** * Gets the current account name. * @returns The current account name */ getAccount(): Promise; /** * Gets the current account address. * @returns The current account address */ getAccountAddress(): Promise; /** * Gets the current network name. * @returns The current network name */ getNetwork(): Promise; /** * Connects MetaMask to a dApp. * @param accounts - Optional array of account addresses to connect * @returns True if the connection was successful */ connectToDapp(accounts?: string[]): Promise; /** * Imports a wallet using a seed phrase. * @param seedPhrase - The seed phrase to import * @returns True if the import was successful */ importWallet(seedPhrase: string): Promise; /** * Imports a wallet using a private key. * @param privateKey - The private key to import * @returns True if the import was successful */ importWalletFromPrivateKey(privateKey: string): Promise; /** * Adds a new account with the given name. * @param accountName - The name for the new account * @returns True if the account was added successfully */ addNewAccount(accountName: string): Promise; /** * Switches to the account with the given name. * @param accountName - The name of the account to switch to * @returns True if the switch was successful */ switchAccount(accountName: string): Promise; /** * Renames an account. * @param options - Object containing the current and new account names * @param options.currentAccountName - The current name of the account * @param options.newAccountName - The new name for the account * @returns True if the rename was successful */ renameAccount({ currentAccountName, newAccountName }: { currentAccountName: string; newAccountName: string; }): Promise; /** * Resets the current account. * @returns True if the reset was successful */ resetAccount(): Promise; /** * Switches to the specified network. * @param options - Object containing the network name and testnet flag * @param options.networkName - The name of the network to switch to * @param options.isTestnet - Whether the network is a testnet (default: false) * @returns True if the switch was successful, false otherwise */ switchNetwork({ networkName, isTestnet }: { networkName: string; isTestnet?: boolean; }): Promise; /** * Creates an Anvil node for testing. * @param options - Optional Anvil node creation options * @returns Object containing the Anvil instance, RPC URL, and chain ID */ createAnvilNode(options?: CreateAnvilOptions): Promise<{ anvil: Anvil; rpcUrl: string; chainId: number; }>; /** * Empties the Anvil node pool. * @returns True if the operation was successful */ emptyAnvilNode(): Promise; /** * 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 */ connectToAnvil({ rpcUrl, chainId }: { rpcUrl: string; chainId: number; }): Promise; /** * Adds a new network to MetaMask. * @param network - The network configuration to add * @returns True if the network was added successfully */ addNetwork(network: Network): Promise; /** * Deploys a token. * @returns True if the token was deployed successfully */ deployToken(): Promise; /** * Adds a new token to MetaMask. * @returns True if the token was added successfully */ addNewToken(): Promise; /** * Approves token permission. * @param options - Optional settings for token approval * @param options.spendLimit - The spend limit for the token (number or 'max') * @param options.gasSetting - Gas settings for the transaction * @returns True if the permission was approved, false otherwise */ approveTokenPermission(options?: { spendLimit?: number | 'max'; gasSetting?: GasSettings; }): Promise; /** * Rejects token permission. * @returns True if the permission was rejected successfully */ rejectTokenPermission(): Promise; /** * Approves adding a new network. * @returns True if the new network was approved successfully */ approveNewNetwork(): Promise; /** * Approves switching to a new network. * @returns True if the network switch was approved successfully */ approveSwitchNetwork(): Promise; /** * Rejects adding a new network. * @returns True if the new network was rejected successfully */ rejectNewNetwork(): Promise; /** * Rejects switching to a new network. * @returns True if the network switch was rejected successfully */ rejectSwitchNetwork(): Promise; /** * Approves adding a new RPC provider for Ethereum Mainnet. * * @returns True if the RPC provider was approved successfully */ approveNewEthereumRPC(): Promise; /** * Rejects adding a new RPC provider for Ethereum Mainnet. * * @returns True if the RPC provider was rejected successfully */ rejectNewEthereumRPC(): Promise; /** * Locks the MetaMask wallet. * @returns True if the wallet was locked successfully */ lock(): Promise; /** * Unlocks the MetaMask wallet. * @returns True if the wallet was unlocked successfully */ unlock(): Promise; /** * Provides a public encryption key. * @returns True if the key was provided successfully, false otherwise */ providePublicEncryptionKey(): Promise; /** * Decrypts a message. * @returns True if the message was decrypted successfully, false otherwise */ decrypt(): Promise; /** * Confirms a signature request. * @returns True if the signature was confirmed successfully, false otherwise */ confirmSignature(): Promise; /** * Rejects a signature request. * @returns True if the signature was rejected successfully */ rejectSignature(): Promise; /** * Confirms a transaction. * @param options - Optional gas settings for the transaction * @returns True if the transaction was confirmed successfully */ confirmTransaction(options?: { gasSetting?: GasSettings; }): Promise; /** * Rejects a transaction. * @returns True if the transaction was rejected successfully */ rejectTransaction(): Promise; /** * Confirms a transaction and waits for it to be mined. * @returns True if the transaction was confirmed and mined successfully, false otherwise */ confirmTransactionAndWaitForMining(): Promise; /** * Opens the details of a specific transaction. * @param txIndex - The index of the transaction to open * @returns True if the transaction details were opened successfully, false otherwise */ openTransactionDetails(txIndex: number): Promise; /** * Closes the transaction details view. * @returns True if the transaction details were closed successfully, false otherwise */ closeTransactionDetails(): Promise; /** * Toggles the display of test networks. * @returns True if the toggle was successful */ toggleShowTestNetworks(): Promise; /** * Toggles the dismissal of the secret recovery phrase reminder. * @returns True if the toggle was successful */ toggleDismissSecretRecoveryPhraseReminder(): Promise; /** * Navigates back to the home page. * @returns True if the navigation was successful */ goBackToHomePage(): Promise; /** * Opens the settings page. * @returns True if the settings page was opened successfully */ openSettings(): Promise; /** * Opens a specific sidebar menu in the settings. * @param menu - The menu to open * @returns True if the menu was opened successfully */ openSidebarMenu(menu: SettingsSidebarMenus): Promise; } //# sourceMappingURL=MetaMask.d.ts.map