UNPKG

chaingate

Version:

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

44 lines 1.43 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Wallet = void 0; const CurrencyModules_1 = require("../Currencies/CurrencyModules"); class Wallet { get client() { return this.context.client; } context; transports; constructor(context, transports) { this.context = context; this.transports = transports; } currency(id) { const module = CurrencyModules_1.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; } } exports.Wallet = Wallet; //# sourceMappingURL=Wallet.js.map