import type { EVMTransaction, SolTransaction, TransactionResult, User, AuthProvider, SetOptions } from '@pooflabs/core'; import { PublicKey, Transaction, VersionedTransaction } from '@solana/web3.js'; export type PhantomProviderType = 'injected' | 'google' | 'apple' | 'deeplink' | 'phantom'; export interface PhantomWalletConfig { appId?: string; /** Providers to use for authentication. Accepts string[] for convenience (e.g., ["injected"]) */ providers?: PhantomProviderType[] | string[]; autoConnect?: boolean; /** Theme for the connect modal: 'light' or 'dark'. Defaults to 'dark'. */ theme?: 'light' | 'dark'; /** App name displayed in the connect modal */ appName?: string; /** App icon URL displayed in the connect modal */ appIcon?: string; /** Enable a "Log in with email" fallback button (via Privy) in the Phantom modal */ enablePrivyFallback?: boolean; /** Custom title shown at the top of the login modal. Overrides the default "Log in to your account". */ modalTitle?: string; /** Custom subtitle shown below the title in the login modal. */ modalSubtitle?: string; } /** * Per-call overrides for `login()`. All fields are optional and take precedence * over the values set in `PhantomWalletConfig` during `init()`. */ export interface LoginOptions { /** Override the modal theme just for this login call. */ theme?: 'light' | 'dark'; /** Override the modal title just for this login call. */ modalTitle?: string; /** Override the modal subtitle just for this login call. */ modalSubtitle?: string; /** * Drive a single specific login flow instead of opening the full chooser modal. * For apps that render their OWN auth UI and want each button to trigger one flow: * 'wallet' → the wallet picker (no email/social), 'email' → Privy email, * 'google' / 'apple' → Phantom OAuth directly (requires a custom Phantom app * with that OAuth provider configured). Omit to open the default modal. */ method?: 'wallet' | 'email' | 'google' | 'apple'; } export declare class PhantomWalletProvider implements AuthProvider { private static instance; private containerElement; private networkUrl; private root; private phantomMethods; private config; private resolvedProviders; private modalProviders; private modalWalletOnly; private pendingLogin; private loginInProgress; private autoLoginInProgress; private initPromise; private loginOverrides; /** Temporarily override modal appearance for a single login() call. Cleared automatically after login settles. */ setLoginOverrides(opts: LoginOptions | null): void; /** Callback to swap to a Privy provider when the user clicks "Log in with email" */ onSwitchToPrivy: (() => Promise) | null; /** Callback to swap to a Mobile Wallet Adapter provider when the user clicks "Connect Mobile Wallet" */ onSwitchToMWA: (() => Promise) | null; constructor(networkUrl?: string | null, config?: PhantomWalletConfig); private initializeAsync; /** * Check if social login providers are configured (non-injected providers). */ private hasSocialProviders; static getInstance(networkUrl: string | null, config: PhantomWalletConfig): PhantomWalletProvider; private resolveProviders; /** * Patch the Phantom extension's provider to gracefully handle `phantom_getFeatures` * instead of throwing. Privy's SDK probes this method to check feature support, * but the extension doesn't implement it, causing noisy console errors. */ private patchPhantomGetFeatures; private initialize; private ensureReady; private ensureSolanaReady; /** * Get the list of available (configured) providers for this wallet. */ getAvailableProviders(): PhantomProviderType[]; /** * Login using the Phantom connect modal. * When enablePrivyFallback is true, a custom modal is rendered with discovered * wallets and a "Log in with email" button instead of the SDK's built-in modal. */ login(): Promise; restoreSession(): Promise; private awaitTopLevelConnect; address(): Promise; runTransaction(_evmTransactionData?: EVMTransaction, solTransactionData?: SolTransaction, options?: SetOptions): Promise; /** * Signs a Solana transaction without submitting it. * * This method handles blockhash automatically if not set - you do NOT need to * set recentBlockhash on the transaction before calling this method. * The network/RPC URL is derived from the provider's configuration (set during initialization). * * @param transaction - The transaction to sign (Transaction or VersionedTransaction) * @returns The signed transaction */ signTransaction(transaction: Transaction | VersionedTransaction): Promise; /** * Signs and submits a Solana transaction to the network. * * This method handles blockhash and transaction confirmation automatically - you do NOT need to * set recentBlockhash or lastValidBlockHeight on the transaction before calling this method. * The network/RPC URL is derived from the provider's configuration (set during initialization). * * @param transaction - The transaction to sign and submit (Transaction or VersionedTransaction) * @param feePayer - Optional fee payer public key. If not provided and the transaction doesn't * already have a feePayer set, the connected wallet address will be used. * Useful for co-signing scenarios where a different account pays the fees. * @returns The transaction signature */ signAndSubmitTransaction(transaction: Transaction | VersionedTransaction, feePayer?: PublicKey): Promise; signMessage(message: string): Promise; logout(): Promise; getNativeMethods(): Promise; private getRpcUrl; private signAndSendViaPhantom; private submitSignedTransaction; private submitSignedTransactionWithBlockhash; } declare global { interface Window { CUSTOM_TAROBASE_APP_ID_HEADER?: string; } }