@coinbase/onchaintestkit
Version:
End-to-end testing toolkit for blockchain applications, powered by Playwright
57 lines (56 loc) • 2.79 kB
TypeScript
import type { BrowserContext, Page } from "@playwright/test";
import { ActionOptions, BaseActionType, BaseWallet } from "../BaseWallet";
import { CoinbaseConfig } from "../types";
import { PasskeyAuthenticator, WebAuthnCredential } from "./PasskeyAuthenticator";
import { HomePage, NotificationPage, OnboardingPage } from "./pages";
export declare enum CoinbaseSpecificActionType {
LOCK = "lock",
UNLOCK = "unlock",
ADD_TOKEN = "addToken",
ADD_ACCOUNT = "addAccount",
SWITCH_ACCOUNT = "switchAccount",
ADD_NETWORK = "addNetwork",
SEND_TOKENS = "sendTokens",
HANDLE_PASSKEY_POPUP = "handlePasskeyPopup"
}
type CoinbaseActionType = BaseActionType | CoinbaseSpecificActionType;
export type PasskeyConfig = {
name: string;
rpId: string;
rpName: string;
userId: string;
isUserVerified?: boolean;
};
export declare class CoinbaseWallet extends BaseWallet {
private readonly context;
private readonly extensionId?;
readonly config: CoinbaseConfig;
private readonly page;
readonly onboardingPage: OnboardingPage;
readonly homePage: HomePage;
readonly notificationPage: NotificationPage;
passkeyAuthenticator: PasskeyAuthenticator | null;
passkeyCredentials: WebAuthnCredential[];
get authenticator(): PasskeyAuthenticator | null;
constructor(walletConfig: CoinbaseConfig, context: BrowserContext, page: Page, extensionId?: string);
static initialize(currentContext: BrowserContext, contextPath: string, _walletConfig: CoinbaseConfig): Promise<{
coinbasePage: Page;
coinbaseContext: BrowserContext;
}>;
static createContext(contextPath: string, slowMo?: number): Promise<BrowserContext>;
/**
* Handle a passkey popup for registration or authentication.
* For registration, receives the main page and the first popup, clicks the switch link, waits for the second popup, and registers there.
* For approve, receives the transaction popup directly.
* @param mainPage The Playwright Page for the main dapp (only needed for registration)
* @param popup The Playwright Page for the popup (first popup for registration, transaction popup for approve)
* @param action 'register' or 'approve'
* @param config PasskeyConfig (required for 'register')
*/
handlePasskeyPopup(mainPageOrPopup: Page, popup: Page, action: "registerWithCBExtension" | "registerWithSmartWalletSDK" | "signMessage" | "approve" | "grantSpendPermission" | "signIn" | "signInWithCBExtension", config?: PasskeyConfig): Promise<void>;
handleAction(action: CoinbaseActionType, options?: ActionOptions): Promise<void>;
get walletContext(): BrowserContext;
get walletPage(): Page;
get walletExtensionId(): string | undefined;
}
export * from "./fixtures";