UNPKG

pulsar_sdk_js

Version:

A convenient way for you to interact with Pulsar's Third Party APIs, using typified classes.

56 lines (55 loc) 2.19 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const uuid_1 = require("uuid"); const base_1 = __importDefault(require("./base")); const schema_1 = require("../data/dataclasses/schema"); class WalletBalancesClient { constructor(wsClient) { this.websocketClient = wsClient; } async *getWalletBalances(walletAddr, chain, options = new schema_1.WalletRequestSettings()) { if (typeof options === 'boolean') { throw new Error('The `ignore_cache` parameter is now a part of the options object. Please pass { ignore_cache: true } instead of just `true`.'); } const requestId = (0, uuid_1.v4)(); let data_dict = { address: walletAddr, chain: chain }; if (options) { data_dict = Object.assign(data_dict, options); } const msg = { method: 'COMMAND', command: { key: 'WALLET_BALANCES', data: data_dict, }, request_id: requestId, }; const finishedEventType = 'WALLET_BALANCES_FINISHED'; for await (const response of this.websocketClient.handleResponse(requestId, msg, finishedEventType)) { yield response; } } async *getWalletTimeseries(walletAddr, chain, tier, options = new schema_1.WalletRequestSettings()) { const requestId = (0, uuid_1.v4)(); let data_dict = { address: walletAddr, chain: chain, tier: tier }; if (options) { data_dict = Object.assign(data_dict, options); } const msg = { method: 'COMMAND', command: { key: 'GET_WALLET_TIMESERIES', data: data_dict, }, request_id: requestId, }; const finishedEventType = 'GET_WALLET_TIMESERIES_FINISHED'; for await (const response of this.websocketClient.handleResponse(requestId, msg, finishedEventType)) { yield response; } } } exports.default = WalletBalancesClient;