UNPKG

chaingate

Version:

A complete TypeScript library for connecting to and making transactions on different blockchains

50 lines 1.7 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Wallet = exports.Currencies = exports.UtxoCurrencies = exports.EvmCurrencies = void 0; exports.EvmCurrencies = [ 'arbitrum', 'avalanche', 'base', 'bnbChain', 'ethereum', 'fantomOpera', 'polygon' ]; exports.UtxoCurrencies = [ 'bitcoin', 'bitcoinTestnet', 'dogecoin', 'litecoin', 'bitcoinCash' ]; exports.Currencies = [...exports.EvmCurrencies, ...exports.UtxoCurrencies]; class Wallet { apiClient; currencyProviders; constructor(apiClient, currencyProviders) { this.apiClient = apiClient; this.currencyProviders = currencyProviders; } get allCurrencies() { return this.supportedCurrencies.map((currency) => this.currency(currency)); } async serialize() { return JSON.stringify(await this.serializeInternal()); } /** * Retrieves the balances for all supported currencies. * * @returns A promise that resolves to an array of currency balances. */ async getAllBalances() { return await Promise.all(this.allCurrencies.map(async (currency) => ({ currency: currency.currencyInfo, balance: await currency.getBalance() }))); } static isSerializedWallet(serialized) { if (!('format' in serialized)) return false; if (serialized.format != 'ChainGate Serialize Wallet Format Version 2') return false; if (!('walletType' in serialized)) return false; if (!('walletUniqueId' in serialized)) return false; return true; } } exports.Wallet = Wallet; //# sourceMappingURL=Wallet.js.map