UNPKG

zumokit

Version:

ZumoKit is a Wallet as a Service SDK

95 lines (94 loc) 3.64 kB
import { CurrencyCode, TokenSet, LogLevel } from './interfaces'; import { ExchangeRate, ExchangeRates, TransactionFeeRate, TransactionFeeRates } from './models'; import { User } from './User'; import { Utils } from './Utils'; /** * ZumoKit instance. Refer to <a href="https://developers.zumo.money/docs/guides/initialize-zumokit">documentation</a> for usage details. * */ export declare class ZumoKit { private zumoCoreModule; private socket; private wsListener; private zumoCore; private changeListeners; private changeListenersImpl; private disconnected; /** ZumoKit SDK semantic version tag if exists, commit hash otherwise. */ version: string; /** Currently signed-in user or null. */ currentUser: User | null; /** Crypto utilities. */ utils: Utils; /** Mapping between currency pairs and available exchange rates. */ exchangeRates: ExchangeRates; /** Mapping between cryptocurrencies and available transaction fee rates. */ transactionFeeRates: TransactionFeeRates; private request; private connectWebSocket; private subscribe; send(message: string): void; private createWebSocket; /** @internal */ constructor(zumoCoreModule: any, apiKey: string, apiUrl: string, transactionServiceUrl: string, cardServiceUrl: string, notificationServiceUrl: string, exchangeServiceUrl: string, custodyServiceUrl: string); /** * Sets log level for current logger. * * @param logLevel log level, e.g. 'debug' or 'info' */ setLogLevel(logLevel: LogLevel): void; /** * Sets log handler for all ZumoKit related logs. * * @param listener interface to listen to changes * @param logLevel log level, e.g. 'debug' or 'info' */ onLog(listener: (message: string) => void, logLevel: LogLevel): void; /** * Signs in user corresponding to user token set. Sets current user to the newly signed in user. * Refer to <a href="https://developers.zumo.money/docs/setup/server#get-zumokit-user-token">Server</a> guide for details on how to get user token set. * * @param tokenSet user token set */ signIn(userTokenSet: TokenSet): Promise<User>; /** Signs out current user. */ signOut(): void; /** * Get exchange rate for selected currency pair. * * @param fromCurrency currency code * @param toCurrency currency code * * @return exchange rate or null */ getExchangeRate(fromCurrency: CurrencyCode, toCurrency: CurrencyCode): ExchangeRate | null; /** * Get transaction fee rate for selected crypto currency. * * @param currency currency code * * @return transaction fee rate or null */ getTransactionFeeRate(currency: CurrencyCode): TransactionFeeRate | null; /** * Fetch historical exchange rates for supported time intervals. * * @return historical exchange rates */ fetchHistoricalExchangeRates(): Promise<Partial<Record<import("./interfaces").TimeInterval, Partial<Record<CurrencyCode, Partial<Record<CurrencyCode, ExchangeRate[]>>>>>>>; /** * Listen to changes in current user’s sign in state, exchange rates, exchange settings or transaction fee rates. * * @param listener interface to listen to changes */ addChangeListener(listener: () => void): void; /** * Remove change listener. * * @param listener interface to listen to changes */ removeChangeListener(listener: () => void): void; /** * Stops WebSocket connection to Zumo Enterprise services. */ disconnect(): void; }