declare namespace Cypress { interface Chainable { /** * Connect playwright with Cypress instance * @example * cy.initPlaywright() */ initPlaywright(): Chainable; /** * Assign currently open tabs with playwright * @example * cy.assignWindows() */ assignWindows(): Chainable; /** * Assigns currently active tab * @example * cy.assignActiveTabName('tabName') */ assignActiveTabName(tabName: string): Chainable; /** * Checks if current active tab is metamask * @example * cy.isMetamaskWindowActive() */ isMetamaskWindowActive(): Chainable; /** * Checks if current active tab is cypress * @example * cy.isCypressWindowActive() */ isCypressWindowActive(): Chainable; /** * Switch to Cypress window * @example * cy.switchToCypressWindow() */ switchToCypressWindow(): Chainable; /** * Switch to metamask window * @example * cy.switchToMetamaskWindow() */ switchToMetamaskWindow(): Chainable; /** * Switch to metamask notification window * @example * cy.switchToMetamaskNotification() */ switchToMetamaskNotification(): Chainable; /** * Get current network * @example * cy.getCurrentNetwork() */ getCurrentNetwork(): Chainable; /** * Add network in metamask (and also switch to the newly added network) * List of available presets for networks: https://github.com/wagmi-dev/references/tree/main/packages/chains#chains * If preset for your custom chain is not available, you can add custom network by yourself. * @example * cy.addMetamaskNetwork('optimism') // works only if chain is available as preset * cy.addMetamaskNetwork({name: 'optimism', rpcUrl: 'https://mainnet.optimism.io', chainId: 10, symbol: 'oETH', blockExplorer: 'https://https://optimistic.etherscan.io', isTestnet: false}) * cy.addMetamaskNetwork({id: 10, name: 'optimism', nativeCurrency: { symbol: 'OP' }, rpcUrls: { default: { http: ['https://mainnet.optimism.io'] } }, testnet: false }) */ addMetamaskNetwork( network: | string | { networkName: string; rpcUrl: string; chainId: number; symbol?: string; blockExplorer?: string; isTestnet: boolean; }, ): Chainable; /** * Change network in metamask (if network is not present, it will be added) * List of available presets for networks: https://github.com/wagmi-dev/references/tree/main/packages/chains#chains * If preset for your custom chain is not available, you can add custom network by yourself with `cy.addMetamaskNetwork()`. * @example * cy.changeMetamaskNetwork('goerli') * cy.changeMetamaskNetwork('custom network name') */ changeMetamaskNetwork(network: string): Chainable; /** * Import new account in metamask using private key * @example * cy.importMetamaskAccount('private_key') */ importMetamaskAccount(privateKey: string): Chainable; /** * Create new account in metamask * @example * cy.createMetamaskAccount() * cy.createMetamaskAccount('accountName') */ createMetamaskAccount(accountName?: string): Chainable; /** * Rename current account in metamask * @example * cy.renameMetamaskAccount('fancyAccountName') */ renameMetamaskAccount(newAccountName: string): Chainable; /** * Switch metamask account * @example * cy.switchMetamaskAccount(2) * cy.switchMetamaskAccount('Account 2') */ switchMetamaskAccount( accountNameOrAccountNumber: string | number, ): Chainable; /** * Get current wallet address of metamask wallet * @example * cy.getMetamaskWalletAddress().then(address => cy.log(address)) */ getMetamaskWalletAddress(): Chainable; /** * Activate ability (in metamask settings) to specify custom gas price and limit while doing transactions in metamask * @example * cy.activateAdvancedGasControlInMetamask() */ activateAdvancedGasControlInMetamask( skipSetup?: boolean, ): Chainable; /** * Activate ability (in metamask settings) to show hex data while doing transaction in metamask * @example * cy.activateShowHexDataInMetamask() */ activateShowHexDataInMetamask(skipSetup?: boolean): Chainable; /** * Activate ability (in metamask settings) to show fiat conversions on testnets in metamask * @example * cy.activateTestnetConversionInMetamask() */ activateTestnetConversionInMetamask( skipSetup?: boolean, ): Chainable; /** * Activate ability (in metamask settings) to show testnet networks in metamask * @example * cy.activateShowTestnetNetworksInMetamask() */ activateShowTestnetNetworksInMetamask( skipSetup?: boolean, ): Chainable; /** * Activate ability (in metamask settings) to specify custom nonce while doing transactions in metamask * @example * cy.activateCustomNonceInMetamask() */ activateCustomNonceInMetamask(skipSetup?: boolean): Chainable; /** * Activate ability (in metamask settings) to dismiss secret recovery phrase reminder in metamask * @example * cy.activateDismissBackupReminderInMetamask() */ activateDismissBackupReminderInMetamask( skipSetup?: boolean, ): Chainable; /** * Activate eth sign requests in metamask settings * @example * cy.activateEthSignRequestsInMetamask() */ activateEthSignRequestsInMetamask(skipSetup?: boolean): Chainable; /** * Activate improved token allowance in metamask settings (experimental) * @example * cy.activateImprovedTokenAllowanceInMetamask() */ activateImprovedTokenAllowanceInMetamask( skipSetup?: boolean, ): Chainable; /** * Reset metamask account state in settings * @example * cy.resetMetamaskAccount() */ resetMetamaskAccount(): Chainable; /** * Disconnects metamask wallet from last connected dapp * @example * cy.disconnectMetamaskWalletFromDapp() */ disconnectMetamaskWalletFromDapp(): Chainable; /** * Disconnects metamask wallet from all connected dapps * @example * cy.disconnectMetamaskWalletFromAllDapps() */ disconnectMetamaskWalletFromAllDapps(): Chainable; /** * Confirm metamask permission to sign message * @example * cy.confirmMetamaskSignatureRequest() */ confirmMetamaskSignatureRequest(): Chainable; /** * Confirm metamask permission to sign Data message * @example * cy.confirmMetamaskDataSignatureRequest() */ confirmMetamaskDataSignatureRequest(): Chainable; /** * Reject metamask permission to sign message * @example * cy.rejectMetamaskSignatureRequest() */ rejectMetamaskSignatureRequest(): Chainable; /** * Confirm metamask request for public encryption key * @example * cy.confirmMetamaskEncryptionPublicKeyRequest() */ confirmMetamaskEncryptionPublicKeyRequest(): Chainable; /** * Reject metamask request for public encryption key * @example * cy.rejectMetamaskEncryptionPublicKeyRequest() */ rejectMetamaskEncryptionPublicKeyRequest(): Chainable; /** * Confirm metamask request to decrypt message with private key * @example * cy.confirmMetamaskDecryptionRequest() */ confirmMetamaskDecryptionRequest(): Chainable; /** * Reject metamask request to decrypt message with private key * @example * cy.rejectMetamaskDecryptionRequest() */ rejectMetamaskDecryptionRequest(): Chainable; /** * Reject metamask permission to sign Data message * @example * cy.rejectMetamaskDataSignatureRequest() */ rejectMetamaskDataSignatureRequest(): Chainable; /** * Add custom token to metamask * @example * cy.importMetamaskToken('0x509ee0d083ddf8ac028f2a56731412edd63223b9') * cy.importMetamaskToken({ address: '0x509ee0d083ddf8ac028f2a56731412edd63223b9', symbol: 'USDT'}) */ importMetamaskToken( tokenConfig?: | { address: string; symbol: string; } | string, ): Chainable; /** * Confirm metamask request to add token * @example * cy.confirmMetamaskAddToken() */ confirmMetamaskAddToken(): Chainable; /** * Reject metamask request to add token * @example * cy.rejectMetamaskAddToken() */ rejectMetamaskAddToken(): Chainable; /** * Confirm metamask permission to spend asset * @example * cy.confirmMetamaskPermissionToSpend() * cy.confirmMetamaskPermissionToSpend({ spendLimit: '999999999' }) * cy.confirmMetamaskPermissionToSpend({ spendLimit: '999999999', shouldWaitForPopupClosure: false }) */ confirmMetamaskPermissionToSpend(options: { spendLimit?: string shouldWaitForPopupClosure?: boolean }): Chainable; /** * Confirm metamask permission to access all elements (example: collectibles) * @example * cy.confirmMetamaskPermissionToApproveAll() */ confirmMetamaskPermissionToApproveAll(): Chainable; /** * Reject metamask permission to access all elements (example: collectibles) * @example * cy.rejectMetamaskPermissionToApproveAll() */ rejectMetamaskPermissionToApproveAll(): Chainable; /** * Confirm metamask revoking permission to access all elements (example: collectibles) * @example * cy.confirmMetamaskRevokePermissionToAll() */ confirmMetamaskRevokePermissionToAll(): Chainable; /** * Reject metamask revoking permission to access all elements (example: collectibles) * @example * cy.rejectMetamaskRevokePermissionToAll() */ rejectMetamaskRevokePermissionToAll(): Chainable; /** * Reject metamask permission to spend asset * @example * cy.rejectMetamaskPermissionToSpend() */ rejectMetamaskPermissionToSpend(): Chainable; /** * Accept metamask access request * @example * cy.acceptMetamaskAccess() * cy.acceptMetamaskAccess({allAccounts: true, confirmSignatureRequest: true}) */ acceptMetamaskAccess(options?: { allAccounts?: boolean; confirmSignatureRequest?: boolean; confirmDataSignatureRequest?: boolean; switchNetwork?: boolean; }): Chainable; /** * Reject metamask access request * @example * cy.rejectMetamaskAccess() */ rejectMetamaskAccess(): Chainable; /** * Confirm metamask transaction (auto-detects eip-1559 and legacy transactions) * @example * cy.confirmMetamaskTransaction() * cy.confirmMetamaskTransaction({ gasConfig: { gasLimit: 1000000, baseFee: 20, priorityFee: 20 } }) // eip-1559 * cy.confirmMetamaskTransaction({ gasConfig: { gasLimit: 1000000, gasPrice: 20 } }) // legacy * cy.confirmMetamaskTransaction({ gasConfig: 'aggressive' }) // eip-1559 only! => available options: 'low', 'market', 'aggressive', 'site' (site is usually by default) * cy.confirmMetamaskTransaction({ shouldWaitForPopupClosure: false }) */ confirmMetamaskTransaction(options: { gasConfig: | { gasLimit?: number; baseFee?: number; priorityFee?: number; } | { gasLimit?: number; gasPrice?: number; } | 'low' | 'market' | 'aggressive' | 'site', shouldWaitForPopupClosure?: boolean }): Chainable; /** * Confirm metamask transaction (auto-detects eip-1559 and legacy transactions) and wait for ALL pending transactions to be mined * @example * cy.confirmMetamaskTransactionAndWaitForMining() * cy.confirmMetamaskTransactionAndWaitForMining({ gasLimit: 1000000, baseFee: 20, priorityFee: 20 }) // eip-1559 * cy.confirmMetamaskTransactionAndWaitForMining({ gasLimit: 1000000, gasPrice: 20 }) // legacy * cy.confirmMetamaskTransactionAndWaitForMining('aggressive') // eip-1559 only! => available options: 'low', 'market', 'aggressive', 'site' (site is usually by default) */ confirmMetamaskTransactionAndWaitForMining( gasConfig?: | { gasLimit?: number; baseFee?: number; priorityFee?: number; } | { gasLimit?: number; gasPrice?: number; } | 'low' | 'market' | 'aggressive' | 'site', ): Chainable; /** * Reject metamask transaction * @example * cy.rejectMetamaskTransaction() */ rejectMetamaskTransaction(): Chainable; /** * Open metamask transaction details based on the index of the transaction in the list on the activity tab * @example * cy.openMetamaskTransactionDetails(0) * cy.openMetamaskTransactionDetails(1) */ openMetamaskTransactionDetails(txIndex: number): Chainable; /** * Close metamask transaction details popup * @example * cy.closeMetamaskTransactionDetailsPopup() */ closeMetamaskTransactionDetailsPopup(): Chainable; /** * Allow site to add new network in metamask * @example * cy.allowMetamaskToAddNetwork() * cy.allowMetamaskToAddNetwork('close') // waitForEvent */ allowMetamaskToAddNetwork(waitForEvent?: string): Chainable; /** * Reject site to add new network in metamask * @example * cy.rejectMetamaskToAddNetwork() */ rejectMetamaskToAddNetwork(): Chainable; /** * Allow site to switch network in metamask * @example * cy.allowMetamaskToSwitchNetwork() */ allowMetamaskToSwitchNetwork(): Chainable; /** * Reject site to switch network in metamask * @example * cy.rejectMetamaskToSwitchNetwork() */ rejectMetamaskToSwitchNetwork(): Chainable; /** * Allow site to add new network in metamask and switch to it * @example * cy.allowMetamaskToAddAndSwitchNetwork() */ allowMetamaskToAddAndSwitchNetwork(): Chainable; /** * Unlock metamask * @example * cy.unlockMetamask('password') */ unlockMetamask(password: string): Chainable; /** * Fetches previous metamask wallet address * @example * cy.fetchMetamaskWalletAddress().then(address => cy.log(address)) */ fetchMetamaskWalletAddress(): Chainable; /** * Run the flow for metamask setup * List of available presets for networks: https://github.com/wagmi-dev/references/tree/main/packages/chains#chains * If preset for your custom chain is not available, you can add custom network by yourself. * @example * cy.setupMetamask() // will use defaults * cy.setupMetamask('secret, words, ...', 'optimism', 'password for metamask') // works only if chain is available as preset * cy.setupMetamask('secret, words, ...', {name: 'optimism', rpcUrl: 'https://mainnet.optimism.io', chainId: 10, symbol: 'oETH', blockExplorer: 'https://https://optimistic.etherscan.io', isTestnet: false}, 'password for metamask') * cy.setupMetamask('private_key', 'goerli', 'password for metamask') * cy.setupMetamask('private_key', {name: 'optimism', rpcUrl: 'https://mainnet.optimism.io', chainId: 10, symbol: 'oETH', blockExplorer: 'https://https://optimistic.etherscan.io', isTestnet: false}, 'password for metamask') */ setupMetamask( secretWordsOrPrivateKey?: string, network?: | string | { networkName: string; rpcUrl: string; chainId: number; symbol?: string; blockExplorer?: string; isTestnet: boolean; }, password?: string, enableAdvancedSettings?: boolean, enableExperimentalSettings?: boolean, ): Chainable; /** * Get transaction status from Etherscan API * @example * cy.etherscanGetTransactionStatus('0xf..') */ etherscanGetTransactionStatus(txid: string): Chainable; /** * Wait until transaction is success using Etherscan API * @example * cy.etherscanWaitForTxSuccess('0xf..') */ etherscanWaitForTxSuccess(txid: string): Chainable; /** * Wait until all XHR requests are finished (networkidle0) * @example * cy.waitForResources() * cy.waitForResources([{name:"fa-solid-900.woff2"}]) * cy.waitForResources([{name:"fonts.gstatic.com/s/worksans",number:2}]) */ waitForResources( resources?: Array<{ name: string; number?: number }>, ): Chainable; /** * Assert that element top is within viewport * @example * cy.get('selector').topIsWithinViewport() * cy.get('selector').topIsWithinViewport(800) */ topIsWithinViewport(viewportWidth: number): Chainable; /** * Assert that element is within viewport * @example * cy.get('selector').isWithinViewport() * cy.get('selector').isWithinViewport(800, 600) */ isWithinViewport( viewportWidth: number, viewportHeight: number, ): Chainable; } }