UNPKG

chaingate

Version:

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

43 lines 1.43 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Wallet = void 0; const CurrencyModules_1 = require("../Currencies/CurrencyModules"); class Wallet { client; transports; markets; constructor(client, transports, markets) { this.client = client; this.transports = transports; this.markets = markets; } currency(id) { const module = CurrencyModules_1.CurrencyModules[id]; const utils = new module.utils(this.client, this.markets); 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