import { Passport } from '@imtbl/passport'; import { Eip1193Provider } from 'ethers'; import { AvailabilityService } from './availability'; import { CheckoutConfiguration } from './config'; import { FiatRampService } from './fiatRamp'; import { AddNetworkParams, BuyParams, BuyResult, CancelResult, CheckConnectionParams, CheckConnectionResult, CheckoutModuleConfiguration, ConnectParams, ConnectResult, CreateProviderParams, EIP6963ProviderDetail, FiatRampParams, GasEstimateBridgeToL2Result, GasEstimateParams, GasEstimateSwapResult, GetAllBalancesParams, GetAllBalancesResult, GetBalanceParams, GetBalanceResult, GetNetworkAllowListParams, GetNetworkAllowListResult, GetNetworkParams, GetTokenAllowListParams, GetTokenAllowListResult, GetTokenInfoParams, GetWalletAllowListParams, GetWalletAllowListResult, WrappedBrowserProvider, NetworkInfo, OnRampProviderFees, SellResult, SendTransactionParams, SendTransactionResult, SmartCheckoutParams, SmartCheckoutResult, SwitchNetworkParams, SwitchNetworkResult, TokenInfo, CreateProviderResult } from './types'; import { CancelParams } from './types/cancel'; import { SellParams } from './types/sell'; import { SwapParams, SwapQuoteResult, SwapResult } from './types/swap'; import { WidgetsInit } from './types/widgets'; import { AssessmentResult } from './riskAssessment'; export declare class Checkout { private readOnlyProviders; private httpClient; readonly config: CheckoutConfiguration; readonly fiatRampService: FiatRampService; readonly availability: AvailabilityService; readonly passport?: Passport; /** * Constructs a new instance of the CheckoutModule class. * @param {CheckoutModuleConfiguration} [config=SANDBOX_CONFIGURATION] - The configuration object for the CheckoutModule. */ constructor(config?: CheckoutModuleConfiguration); /** * Loads the widgets bundle and initiates the widgets factory. * @param {WidgetsInit} init - The initialisation parameters for loading the widgets bundle and applying configuration * @returns {Promise} A promise that resolves to the widgets factory instance * that can be used to create and manage widgets * @throws {CheckoutError} When the widgets script fails to load */ widgets(init: WidgetsInit): Promise; /** * Creates a provider using the given parameters. * @param {CreateProviderParams} params - The parameters for creating the provider. * @returns {Promise} A promise that resolves to the created provider. */ createProvider(params: CreateProviderParams): Promise; /** * Returns a list of EIP-6963 injected providers and their metadata. * @returns {readonly EIP6963ProviderDetail[]} A readonly array of injected providers and their metadata. */ getInjectedProviders(): readonly EIP6963ProviderDetail[]; /** * Finds an injected provider by its RDNS. * @param {{rdns: string}} args - The parameters for finding the injected provider. * @returns {EIP6963ProviderDetail | undefined} - The found provider and metadata or undefined. */ findInjectedProvider(args: { rdns: string; }): EIP6963ProviderDetail | undefined; /** * Subscribes to changes in the injected providers. * @param {(providers: EIP6963ProviderDetail[]) => void} listener - The listener to be called when the injected providers change. * @returns {() => void} - A function to unsubscribe the listener. */ onInjectedProvidersChange(listener: (providers: EIP6963ProviderDetail[]) => void): () => void; /** * Clears all registered injected providers and their subscriptions. * @returns {void} This method doesn't return a value */ clearInjectedProviders(): void; /** * Checks if a wallet is connected to the specified provider. * @param {CheckConnectionParams} params - The parameters for checking the wallet connection. * @returns {Promise} - A promise that resolves to the result of the check. */ checkIsWalletConnected(params: CheckConnectionParams): Promise; /** * Fetches the risk assessment for the given addresses. * @deprecated This function is deprecated and will be removed. * @param {string[]} addresses - The addresses to assess. * @returns {Promise} - A promise that resolves to the risk assessment result. */ getRiskAssessment(addresses: string[]): Promise; /** * Helper method that checks if given risk assessment results contain sanctioned addresses. * @deprecated This function is deprecated and will be removed. * @param {AssessmentResult} assessment - Risk assessment to analyse. * @param {string} [address] - If defined, only sanctions for the given address will be checked. * @returns {boolean} - Result of the check. */ checkIsAddressSanctioned(assessment: AssessmentResult, address?: string): boolean; /** * Connects to a blockchain network using the specified provider. * @param {ConnectParams} params - The parameters for connecting to the network. * @returns {Promise} A promise that resolves to an object containing the provider and network information. * @throws {Error} If the provider is not valid or if there is an error connecting to the network. */ connect(params: ConnectParams): Promise; /** * Adds the network for the current wallet provider. * @param {AddNetworkParams} params - The parameters for adding the network. * @returns {Promise} - A promise that resolves to the result of adding the network. * @throws {CheckoutError} When the network cannot be added to the wallet */ addNetwork(params: AddNetworkParams): Promise; /** * Switches the network for the current wallet provider. * @param {SwitchNetworkParams} params - The parameters for switching the network. * @returns {Promise} - A promise that resolves to the result of switching the network. */ switchNetwork(params: SwitchNetworkParams): Promise; /** * Retrieves the token information given the token address. This function makes RPC calls to * ERC20 contracts to fetch the main contract information (e.g. symbol). * @param {GetTokenInfoParams} params - The parameters for retrieving the token information. * @returns {Promise} - A promise that resolves to the token info request. */ getTokenInfo(params: GetTokenInfoParams): Promise; /** * Retrieves the balance of a wallet address. * @param {GetBalanceParams} params - The parameters for retrieving the balance. * @returns {Promise} - A promise that resolves to the balance result. */ getBalance(params: GetBalanceParams): Promise; /** * Retrieves the balances of all tokens for a given wallet address on a specific chain. * @param {GetAllBalancesParams} params - The parameters for retrieving the balances. * @returns {Promise} - A promise that resolves to the result of retrieving the balances. */ getAllBalances(params: GetAllBalancesParams): Promise; /** * Retrieves the supported networks based on the provided parameters. * @param {GetNetworkAllowListParams} params - The parameters for retrieving the network allow list. * @returns {Promise} - A promise that resolves to the network allow list result. */ getNetworkAllowList(params: GetNetworkAllowListParams): Promise; /** * Retrieves the supported tokens based on the provided parameters. * @param {GetTokenAllowListParams} params - The parameters for retrieving the token allow list. * @returns {Promise} - A promise that resolves to the token allow list result. */ getTokenAllowList(params: GetTokenAllowListParams): Promise; /** * Retrieves the default supported wallets based on the provided parameters. * @param {GetWalletAllowListParams} params - The parameters for retrieving the wallet allow list. * @returns {Promise} - A promise that resolves to the wallet allow list result. */ getWalletAllowList(params: GetWalletAllowListParams): Promise; /** * Sends a transaction using the specified provider and transaction parameters. * @param {SendTransactionParams} params - The parameters for sending the transaction. * @returns {Promise} A promise that resolves to the result of the transaction. */ sendTransaction(params: SendTransactionParams): Promise; /** * Wraps a WrappedBrowserProvider call to validate the provider and handle errors. * @param {BrowserProvider} browserProvider - The provider to connect to the network. * @param {(browserProvider: WrappedBrowserProvider) => Promise)} block - The block executing the provider call. * @returns {Promise} Returns the result of the provided block param. */ providerCall(browserProvider: WrappedBrowserProvider | Eip1193Provider, block: (browserProvider: WrappedBrowserProvider) => Promise): Promise; /** * Retrieves network information using the specified provider. * @param {GetNetworkParams} params - The parameters for retrieving network information. * @returns {Promise} A promise that resolves to the network information. */ getNetworkInfo(params: GetNetworkParams): Promise; /** * Determines the requirements for performing a buy. * @param {BuyParams} params - The parameters for the buy. * @returns {Promise} A promise that resolves to the buy transaction requirements * @deprecated Please use orderbook.fulfillOrder or orderbook.fulfillBulkOrders instead. The smartCheckout * method can still be used to ensure the transaction requirements are met before preparing the order fulfillment */ buy(params: BuyParams): Promise; /** * Determines the requirements for performing a sell. * @param {SellParams} params - The parameters for the sell. * @returns {Promise} A promise that resolves to the sell transaction requirements * Only currently actions the first order in the array until we support batch processing. * Only currently actions the first fee in the fees array of each order until we support multiple fees. * @deprecated Please use orderbook.prepareListing or orderbook.prepareBulkListing instead. The smartCheckout * method can still be used to ensure the transaction requirements are met before preparing the listing */ sell(params: SellParams): Promise; /** * Cancels a sell. * @param {CancelParams} params - The parameters for the cancel. * @returns {Promise} A promise that resolves to the cancel transaction result * @deprecated Please use orderbook.prepareOrderCancellations instead. */ cancel(params: CancelParams): Promise; /** * Determines the transaction requirements to complete a purchase. * This includes checking token approvals, native currency balance, * and calculating the optimal route for completing the transaction. * @param {SmartCheckoutParams} params - The parameters for smart checkout. * @returns {Promise} A promise that resolves to the transaction requirements including: * - Required token approvals * - Required native currency balance * - Suggested transaction route * - Estimated gas costs * @throws {CheckoutError} When item requirements cannot be mapped or checkout validation fails */ smartCheckout(params: SmartCheckoutParams): Promise; /** * Checks if the given object is a WrappedBrowserProvider. * @param {BrowserProvider} browserProvider - The object to check. * @returns {boolean} - True if the object is a WrappedBrowserProvider, false otherwise. */ static isWrappedBrowserProvider(browserProvider: WrappedBrowserProvider): boolean; /** * Estimates the gas required for a swap or bridge transaction. * @param {GasEstimateParams} params - The parameters for the gas estimation. * @returns {Promise} - A promise that resolves to the gas estimation result. */ gasEstimate(params: GasEstimateParams): Promise; /** * Creates and returns a URL for the fiat ramp widget. * @param {FiatRampParams} params - The parameters for creating the url. * @returns {Promise} - A promise that resolves to a string url. */ createFiatRampUrl(params: FiatRampParams): Promise; /** * Fetches fiat ramp fee estimations. * @returns {Promise} - A promise that resolves to OnRampProviderFees. */ getExchangeFeeEstimate(): Promise; /** * Fetches Swap widget availability. * @returns {Promise} - A promise that resolves to a boolean. */ isSwapAvailable(): Promise; /** * Fetches a quote and then performs the approval and swap transaction. * @param {SwapParams} params - The parameters for the swap. * @returns {Promise} - A promise that resolves to the swap result (swap tx, swap tx receipt, quote used in the swap). */ swap(params: SwapParams): Promise; /** * Fetches a quote for the swap. * @param {SwapParams} params - The parameters for the swap. * @returns {Promise} - A promise that resolves to the swap quote result. */ swapQuote(params: SwapParams): Promise; }