UNPKG

chaingate

Version:

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

40 lines 1.28 kB
import { CurrencyModules } from '../Currencies/CurrencyModules'; export class Wallet { get client() { return this.context.client; } context; transports; constructor(context, transports) { this.context = context; this.transports = transports; } currency(id) { const module = CurrencyModules[id]; const utils = new module.utils(this.context); const WalletClass = module.wallet; return new WalletClass(utils, this.transports); } get allCurrencies() { return this.supportedCurrencies.map((c) => this.currency(c)); } async serialize() { return JSON.stringify(await this.serializeInternal()); } async getAllBalances() { return Promise.all(this.allCurrencies.map(async (w) => ({ currency: w.utils.currencyInfo, balance: await w.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; return 'walletUniqueId' in serialized; } } //# sourceMappingURL=Wallet.js.map