import { MetaMaskInpageProvider } from "@metamask/providers"; import type { LaunchOptions as PlaywrightLaunchOptions } from "playwright"; import type { launch as puppeteerLaunch } from "puppeteer"; import { DappeteerPage, Serializable } from "./page"; import { Path } from "./setup/utils/metaMaskDownloader"; import { InstallStep } from "./snap/install"; import { NotificationItem, NotificationList } from "./snap/types"; import NotificationsEmitter from "./snap/NotificationsEmitter"; import { DappeteerBrowser, RECOMMENDED_METAMASK_VERSION } from "./index"; export declare type DappeteerLaunchOptions = { metaMaskVersion?: typeof RECOMMENDED_METAMASK_VERSION | "latest" | "local" | string; metaMaskLocation?: Path; metaMaskPath?: string; metaMaskFlask?: boolean; automation?: "puppeteer" | "playwright" | "custom"; customAutomation?: CustomAutomation; headless?: boolean; puppeteerOptions?: Parameters[0]; playwrightOptions?: PlaywrightLaunchOptions; userDataDir?: string; key?: string; }; export declare type CustomAutomation = (metamaskPath: string, userDataDir: string, options: DappeteerLaunchOptions) => Promise; declare global { interface Window { ethereum: MetaMaskInpageProvider; emitNotification: (notification: NotificationItem) => void; } } export declare type MetaMaskOptions = { seed?: string; password?: string; showTestNets?: boolean; }; export declare type TransactionOptions = { gas?: number; gasLimit?: number; priority?: number; }; export declare type Dappeteer = { lock: () => Promise; unlock: (password: string) => Promise; acceptAddNetwork: (shouldSwitch?: boolean) => Promise; rejectAddNetwork: () => Promise; acceptAddToken: () => Promise; rejectAddToken: () => Promise; importPK: (pk: string) => Promise; switchAccount: (accountNumber: number) => Promise; switchNetwork: (network: string) => Promise; confirmTransaction: (options?: TransactionOptions) => Promise; sign: () => Promise; signTypedData: () => Promise; approve: () => Promise; createAccount: (accountName: string) => Promise; helpers: { getTokenBalance: (tokenSymbol: string) => Promise; deleteAccount: (accountNumber: number) => Promise; deleteNetwork: (name: string) => Promise; }; page: DappeteerPage; snaps: { /** * Returns emitter to listen for notifications appearance in notification page */ getNotificationEmitter: () => Promise; /** * Returns all notifications in MetaMask notifications page */ getAllNotifications: () => Promise; /** * Invoke a MetaMask snap method. Function will throw if there is an error while invoking snap. * Use generic params to override result and parameter types. * @param page Browser page where injected MetaMask provider will be available. * For most snaps, openning example.org will suffice. * @param snapId id of your installed snap (result of invoking `installSnap` method) * @param method snap method you want to invoke * @param params required parameters of snap method */ invokeSnap: (page: DappeteerPage, snapId: string, method: string, params?: Params) => Promise>; /** * Installs snap. Function will throw if there is an error while installing snap. * @param snapIdOrLocation either pass in snapId or full path to your snap directory * where we can find bundled snap (you need to ensure snap is built) * @param opts {Object} snap method you want to invoke * @param installationSnapUrl url of your dapp. Defaults to example.org */ installSnap: (snapIdOrLocation: string, opts?: { customSteps?: InstallStep[]; version?: string; installationSnapUrl?: string; }) => Promise; dialog: { /** * Accepts snap_dialog dialog */ accept: () => Promise; /** * Rejects snap_dialog dialog */ reject: () => Promise; /** * type in snap_dialog dialog input field * @param value {string} value that will be typed in field */ type: (value: string) => Promise; }; }; };