/// import { ExternalProvider } from '@ethersproject/providers'; import { EthProviderRpcError, ProviderRequest, WalletNetwork, WalletNetworkSymbol } from '@moonpay/login-common'; import { EventEmitter } from 'events'; import { LoginWidget } from './LoginWidget'; import { SecureWalletSender } from './Sender'; /** * `MoonpayWeb3Provider` class is a custom implementation of the ExternalProvider interface * from ethers.js library. It represents a provider object that connects to Ethereum network * and has additional functionality related to the login widget and sender operations. * * @constructor * @param {SecureWalletSender} sender - Secure sender object to perform network operations * @param {LoginWidget} loginWidget - Login widget to facilitate authentication * @param {WalletNetwork} network - The network to be used (default is WalletNetwork.Ethereum) * @param {boolean} autoLogin - Option to enable auto login (default is true) */ declare class MoonpayWeb3Provider extends EventEmitter implements ExternalProvider { isMetaMask: boolean; isStatus: boolean; loginWidget: LoginWidget; sender: SecureWalletSender; autoLogin: boolean; network: WalletNetwork; networkCode: WalletNetworkSymbol; constructor(sender: SecureWalletSender, loginWidget: LoginWidget, network?: WalletNetwork, autoLogin?: boolean); /** * This method is a proxy to `request` method and is used to handle legacy methods. * It's not implemented in this provider as it's usually handled internally when using `Web3Provider`. * * @param {ProviderRequest} request - The provider request object * @param {Function} callback - The callback function to handle the response * @throws {Error} Will throw an error as the method is not implemented */ sendAsync(request: ProviderRequest, callback: (error: any, response: any) => void): void; /** * This method is a proxy to `request` method and is used to handle legacy methods. * It's not implemented in this provider as it's usually handled internally when using `Web3Provider`. * * @param {ProviderRequest} request - The provider request object * @param {Function} callback - The callback function to handle the response * @throws {Error} Will throw an error as the method is not implemented */ send(request: ProviderRequest, callback: (error: any, response: any) => void): void; /** * This method processes the provider requests and handles login operations * and emits various events based on the request. * * @async * @param {ProviderRequest} request - The provider request object * @returns {Promise} Returns a promise that resolves to the result of the provider request * @throws Will throw an error if the request processing fails */ request(request: ProviderRequest): Promise; /** * Emits specific events based on the provided request and its result. * * @param {ProviderRequest} request - The provider request object * @param {any} result - The result of the provider request */ emitEvents(request: ProviderRequest, result: any): void; /** * Emits `EthEvent.connect` event along with the provided chainId. * * @param {string} chainId - The chain ID */ emitConnect(chainId: string): void; /** * Emits `EthEvent.disconnect` event along with the provided error object. * * @param {EthProviderRpcError} error - The error object */ emitDisconnect(error: EthProviderRpcError): void; /** * Emits `EthEvent.chainChanged` event along with the provided chainId. * * @param {string} chainId - The chain ID */ emitChainChanged(chainId: string): void; /** * Emits `EthEvent.accountsChanged` event along with the provided accounts array. * * @param {string[]} accounts - The array of account addresses */ emitAccountsChanged(accounts: string[]): void; } export { MoonpayWeb3Provider };