import { Web3Provider } from '@ethersproject/providers'; import { LoginSDKInitOptions, SDKNetworkOptions, WalletUserData } from '@moonpay/login-common'; import * as LanguageDetector from './LanguageDetector'; import BitcoinWalletsSDK from './MoonpayBitcoinSDK'; export interface SDKOptions { loginDomain: string; secureWalletDomain: string; language?: LanguageDetector.AllowedLocales; apiKey: string; /** * An optional flag to disable automatic login. */ autoLogin?: boolean; /** * An optional flag to make wallet interactions headless. * This is useful for web 2.5 apps */ headless?: boolean; /** * An optional network and chain to initialize the wallet with. * Network always takes precedence over chain in the case the chain is supported by another chain. * * Supported networks and chains: * Ethereum: [1: Mainnet, 5: Goerli, 137: Polygon Mainnet, 80001: Polygon Mumbai] * Bitcoin: [0: Mainnet, 1: Testnet] */ initialChainNetworkOption?: SDKNetworkOptions; /** * An optional flag that makes the secure wallet embeddable and not full screen. */ embeddable?: boolean; /** * If embeddable is true, this is the id of the div to embed the secure wallet in. */ embeddableId?: string; /** * An optional themeId to use for the secure wallet. */ themeId?: string; /** * An optional dark/light colorScheme flag to use for the secure wallet. */ colorScheme?: 'dark' | 'light'; /** * An optional flag to turn off legacy mode, right now legacyMode is assumed to be true. * Legacy mode refers to the cookie mode, when set to false, we will use indexedDB instead. */ legacyMode?: boolean; /** * An optional callback that is called when the prompt state changes. */ onPromptChangeCallback?: (promptState: 'loading' | 'ready' | 'approved' | 'rejected') => void; iframeStyle?: Partial; } export interface WidgetTextCustomisation { signInMessage?: string; } export interface LoginOptions { onCloseCallback?: () => void; onReadyCallback?: (readyMessage: object) => void; /** * An optional object to override and customize the default copy in the MoonPay widget */ widgetTextCustomisation?: WidgetTextCustomisation; } /** * This class represents the Moonpay Wallet SDK, providing a broad range of * functionalities to interact with Ethereum and Bitcoin networks. * * @constructor * @param {SDKOptions} options - Set of configuration options to setup the SDK * @param {LoginOptions} loginOptions - Optional set of configuration options for the login flow */ declare class MoonpayWalletSDK { private sender; private loginWidget; provider: Web3Provider | undefined; bitcoin: BitcoinWalletsSDK | undefined; options: SDKOptions; private customerEmail?; constructor(options: SDKOptions, loginOptions?: LoginOptions); private setupSecureWallet; /** * Initializes the Moonpay Wallet SDK. * It sets up the secure wallet, establishes a connection to Ethereum and Bitcoin networks, * and waits for the secure wallet to be ready. * * @param {LoginSDKInitOptions} initOptions - options to initialize the SDK * @async * @throws Will throw an error if the secure wallet setup fails or times out. */ init(initOptions?: LoginSDKInitOptions): Promise; /** * Returns the user data stored in the wallet. * * @returns {WalletUserData} The wallet's user data. */ getWalletMetaData(): WalletUserData | null; /** * Allows a customers email to be specified to bypass the email login screen * @param {string} email - The email address of the customer * @returns {void} */ setCustomerEmail(email: string): void; /** * Get secure wallet if it is mounted in the DOM. * * @returns {HTMLElement | undefined} The secure wallet element if it is mounted, undefined otherwise. */ private getSecureWalletWindow; /** * Public method to set the language of the login widget and secure wallet. * Should be called after the login widget is initialized. * @param {string} language the new language to set */ setLanguage(language: LanguageDetector.AllowedLocales): void; /** * Disconnects the wallet. * If there is a provider available, it sends a 'wallet_disconnect' request. */ disconnectWallet(): void; /** * Logs out the user from the wallet and MoonPay Account. */ logout(): Promise; /** * Combines disconnection of wallet and Logs out the user from the wallet and MoonPay Account. */ disconnect(): Promise; /** * Tears down the wallet SDK. * If there is a sender available, it unregisters all message handlers. */ tearDown(): void; } export { MoonpayWalletSDK };