UNPKG

tardis-dev

Version:

Convenient access to tick-level historical and real-time cryptocurrency market data via Node.js

44 lines 1.51 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BlockchainComRealTimeFeed = void 0; const handy_1 = require("../handy"); const realtimefeed_1 = require("./realtimefeed"); class BlockchainComRealTimeFeed extends realtimefeed_1.RealTimeFeedBase { constructor() { super(...arguments); this.wssURL = 'wss://ws.blockchain.info/mercury-gateway/v1/ws'; this.originHeader = 'https://exchange.blockchain.com'; } mapToSubscribeMessages(filters) { const subs = filters .map((filter) => { if (!filter.symbols || filter.symbols.length === 0) { throw new Error('BlockchainComRealTimeFeed requires explicitly specified symbols when subscribing to live feed'); } return filter.symbols.map((symbol) => { return { action: 'subscribe', channel: filter.channel, symbol }; }); }) .flatMap((f) => f); return subs; } messageIsError(message) { return message.event === 'rejected'; } messageIsHeartbeat(msg) { return msg.channel === 'heartbeat'; } async onConnected() { this.send({ action: 'subscribe', channel: 'heartbeat' }); await (0, handy_1.wait)(0); } } exports.BlockchainComRealTimeFeed = BlockchainComRealTimeFeed; //# sourceMappingURL=blockchaincom.js.map