import { GlideWidgetTheme } from './theme.ts'; import { CAIP2, CAIP19, Session } from '@paywithglide/glide-js'; import { GlideAnalyticsCallback } from './analytics.ts'; export type Hex = `0x${string}`; export type EVMTransaction = { chainId: number; account?: Hex; to: Hex; data?: Hex; value?: bigint; }; export type PermitTypedData = { types: { EIP712Domain: [ { name: "name"; type: "string"; }, { name: "version"; type: "string"; }, { name: "chainId"; type: "uint256"; }, { name: "verifyingContract"; type: "address"; } ]; Permit: [ { name: "owner"; type: "address"; }, { name: "spender"; type: "address"; }, { name: "value"; type: "uint256"; }, { name: "nonce"; type: "uint256"; }, { name: "deadline"; type: "uint256"; } ]; }; primaryType: "Permit"; domain: { name: string; version: string; chainId: ChainId; verifyingContract: Hex; }; message: { deadline: bigint; nonce: bigint; owner: Hex; spender: Hex; value: bigint; }; }; /** * Result of `sendTransactionAsync`. Return the transaction hash directly once * it's available, or `{ deferred: true }` to acknowledge the transaction and * take over signing/sending outside the widget — the widget will close and * leave the rest of the payment flow to you. */ export type SendTransactionResult = Hex | { deferred: true; }; export type GlideDepositWalletProvider = { address: Hex | undefined; availableChainIds: number[] | undefined; currentChainId: number | undefined; switchChainAsync: (args: { chainId: number; }) => Promise; sendTransactionAsync: (tx: EVMTransaction, session: Session) => Promise; signTypedDataAsync?: (args: PermitTypedData, session: Session) => Promise; }; export type GlideSolanaWalletProvider = { address: string | undefined; currentChainId: "solana:101" | "solana:103"; signMessageAsync: (message: Uint8Array) => Promise; sendTransactionAsync: (transaction: Uint8Array, session: Session) => Promise; }; export type GlideLocalStorageProvider = { getItem: (key: string) => Promise; setItem: (key: string, value: string) => Promise; removeItem: (key: string) => Promise; getKeys: () => Promise; }; export type FundingSource = "transfer" | "coinbase" | "coinbase_app" | "interac" | "fiat" | "wallet" | "debit_card_alias" | "onramp" | "onramper"; export type ShowAppLogo = "default" | "always" | "never"; export type DebitCardAlias = "fiat" | "coinbase"; export type GlideDepositOptions = { app: string; /** * Optional project ID for analytics segmentation */ projectId?: string; recipient?: string; mode?: "deposit" | "withdraw" | "pay" | "call" | "buy"; amount?: string; /** * Payment amount in USD. Use this instead of `amount` when you want to * accept a fixed USD value paid in a specific token (e.g. $20 paid in RAILS). * The token equivalent is computed server-side and cannot be manipulated by the user. * Only valid for `mode: "pay"`. */ amountUSD?: string; sessionId?: string; chainId?: CAIP2; currencyId?: string; evm?: { chainId: number; to: Hex; data?: Hex; value?: bigint; }; approval?: { token: Hex; amount: bigint; }; gasRefuelAmountPerChain?: Record; sessionMetadata?: string; preferGaslessPayment?: boolean; chainIds?: CAIP2[]; excludeChainIds?: CAIP2[]; excludeCurrencyTiers?: ("tier1" | "tier2" | "tier3")[]; excludeFundingSources?: FundingSource[]; fundingSources?: FundingSource[]; allowedPaymentCurrencies?: string[]; excludePaymentCurrencies?: string[]; /** * Pre-selects the payment token and chain in the transfer ("Deposit from anywhere") flow. * CAIP-19, e.g. "solana:101/token:EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v". * Applies when the user has no previously saved token selection, which still * takes precedence. */ defaultPaymentCurrency?: CAIP19; appMetadata?: { name?: string; logoUrl?: string; faviconUrl?: string; }; enableRefundEmails?: boolean; payerEmail?: string; walletProvider?: GlideDepositWalletProvider; solanaWalletProvider?: GlideSolanaWalletProvider; localStorageProvider?: GlideLocalStorageProvider; onOpen?: () => void; onSuccess?: (fulfillmentTxHash: Hex, session: Session) => void; onClose?: () => void; onSetMode?: (mode: "deposit" | "withdraw") => void; autoCloseOnSuccess?: boolean; container?: HTMLElement; disableWithdrawToSelfSuggestion?: boolean; hideSettlementCopy?: boolean; showAppLogo?: ShowAppLogo; showOnrampFirst?: boolean; debitCardAlias?: DebitCardAlias; copyOverrides?: Record; stableDepositAddressKey?: string; theme?: GlideWidgetTheme; popupsBlocked?: boolean; baseUrl?: string; debug?: boolean; /** * Analytics callback for tracking user events and behavior * Called with various events throughout the deposit/payment flow * Use this to integrate with your own analytics platform (e.g., Amplitude, Mixpanel) */ onAnalyticsEvent?: GlideAnalyticsCallback; }; export declare class GlideDeposit { opts: GlideDepositOptions; constructor(opts: GlideDepositOptions); open: () => void; get externalUrl(): string; private initialize; private destroy; private closeWidget; private get baseUrl(); private get iframe(); private getSafeInsetBottom; private iframeEventHandler; private openUrl; private createIframe; private removeIframe; }