@pioneer-platform/pioneer-events 8.18.0 → 8.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @pioneer-platform/pioneer-events
2
2
 
3
+ ## 8.20.0
4
+
5
+ ### Minor Changes
6
+
7
+ - chore: Merge pull request #10 from coinmastersguild/feature/fix-blockbook-websocket-subscriptions
8
+
9
+ ## 8.19.0
10
+
11
+ ### Minor Changes
12
+
13
+ - Merge pull request #10 from coinmastersguild/feature/fix-blockbook-websocket-subscriptions
14
+
15
+ ## 8.18.1
16
+
17
+ ### Patch Changes
18
+
19
+ - fix: Filter xpubs from Blockbook WebSocket subscriptions
20
+
3
21
  ## 8.18.0
4
22
 
5
23
  ### Minor Changes
package/lib/index.d.ts CHANGED
@@ -4,17 +4,27 @@ export declare class Events {
4
4
  private username;
5
5
  private queryKey;
6
6
  private socket;
7
- private events;
7
+ events: any;
8
8
  private isConnected;
9
9
  private isTestnet;
10
10
  private isPaired;
11
- private init;
11
+ init: () => Promise<boolean>;
12
12
  private emitter;
13
- private setUsername;
14
- private pair;
15
- private disconnect;
13
+ setUsername: (username: string) => Promise<void>;
14
+ pair: (username?: string) => Promise<boolean>;
15
+ disconnect: () => Promise<void>;
16
16
  private subscribeToKey;
17
17
  private subscribeToInvocation;
18
- private send;
18
+ send: (channel: string, event: any) => Promise<boolean>;
19
+ subscribeToXpub: (params: {
20
+ chain: string;
21
+ xpub: string;
22
+ script_type?: string;
23
+ }) => Promise<boolean>;
24
+ unsubscribeFromXpub: (params: {
25
+ chain: string;
26
+ xpub: string;
27
+ }) => Promise<boolean>;
28
+ listSubscriptions: () => Promise<boolean>;
19
29
  constructor(config: EventsConfig);
20
30
  }
package/lib/index.js CHANGED
@@ -124,6 +124,33 @@ var Events = /** @class */ (function () {
124
124
  this.socket.on('sync:complete', function (message) {
125
125
  _this.events.emit('sync:complete', message);
126
126
  });
127
+ // Listen for xpub subscription events (Phase 2)
128
+ this.socket.on('pioneer:subscribed', function (message) {
129
+ _this.events.emit('pioneer:subscribed', message);
130
+ });
131
+ this.socket.on('pioneer:unsubscribed', function (message) {
132
+ _this.events.emit('pioneer:unsubscribed', message);
133
+ });
134
+ this.socket.on('pioneer:subscription_list', function (message) {
135
+ _this.events.emit('pioneer:subscription_list', message);
136
+ });
137
+ this.socket.on('pioneer:error', function (message) {
138
+ _this.events.emit('pioneer:error', message);
139
+ });
140
+ // Transaction events from Blockbook via Pioneer (Phase 2)
141
+ this.socket.on('pioneer:tx', function (message) {
142
+ console.log(tag, '🔔 [PIONEER-EVENTS] Received pioneer:tx from server:', message);
143
+ _this.events.emit('pioneer:tx', message);
144
+ console.log(tag, '🔔 [PIONEER-EVENTS] Re-emitted pioneer:tx to EventEmitter');
145
+ });
146
+ this.socket.on('pioneer:utxo', function (message) {
147
+ console.log(tag, '💰 [PIONEER-EVENTS] Received pioneer:utxo from server:', message);
148
+ _this.events.emit('pioneer:utxo', message);
149
+ });
150
+ this.socket.on('pioneer:balance', function (message) {
151
+ console.log(tag, '💵 [PIONEER-EVENTS] Received pioneer:balance from server:', message);
152
+ _this.events.emit('pioneer:balance', message);
153
+ });
127
154
  maxWaitTime = 15000;
128
155
  startTime = Date.now();
129
156
  _a.label = 2;
@@ -228,6 +255,69 @@ var Events = /** @class */ (function () {
228
255
  });
229
256
  });
230
257
  };
258
+ this.subscribeToXpub = function (params) {
259
+ return __awaiter(this, void 0, void 0, function () {
260
+ var tag;
261
+ return __generator(this, function (_a) {
262
+ tag = TAG + " | subscribeToXpub | ";
263
+ try {
264
+ if (!this.socket || !this.isConnected) {
265
+ throw Error("Socket not connected");
266
+ }
267
+ console.log(tag, "Subscribing to ".concat(params.chain, " xpub:"), params.xpub.substring(0, 20) + '...');
268
+ this.socket.emit('pioneer:subscribe', params);
269
+ return [2 /*return*/, true];
270
+ }
271
+ catch (e) {
272
+ console.error(tag, e);
273
+ throw e;
274
+ }
275
+ return [2 /*return*/];
276
+ });
277
+ });
278
+ };
279
+ this.unsubscribeFromXpub = function (params) {
280
+ return __awaiter(this, void 0, void 0, function () {
281
+ var tag;
282
+ return __generator(this, function (_a) {
283
+ tag = TAG + " | unsubscribeFromXpub | ";
284
+ try {
285
+ if (!this.socket || !this.isConnected) {
286
+ throw Error("Socket not connected");
287
+ }
288
+ console.log(tag, "Unsubscribing from ".concat(params.chain, " xpub:"), params.xpub.substring(0, 20) + '...');
289
+ this.socket.emit('pioneer:unsubscribe', params);
290
+ return [2 /*return*/, true];
291
+ }
292
+ catch (e) {
293
+ console.error(tag, e);
294
+ throw e;
295
+ }
296
+ return [2 /*return*/];
297
+ });
298
+ });
299
+ };
300
+ this.listSubscriptions = function () {
301
+ return __awaiter(this, void 0, void 0, function () {
302
+ var tag;
303
+ return __generator(this, function (_a) {
304
+ tag = TAG + " | listSubscriptions | ";
305
+ try {
306
+ if (!this.socket || !this.isConnected) {
307
+ throw Error("Socket not connected");
308
+ }
309
+ console.log(tag, 'Requesting subscription list');
310
+ this.socket.emit('pioneer:list_subscriptions');
311
+ return [2 /*return*/, true];
312
+ }
313
+ catch (e) {
314
+ console.error(tag, e);
315
+ throw e;
316
+ }
317
+ return [2 /*return*/];
318
+ });
319
+ });
320
+ };
231
321
  this.pair = function (username) {
232
322
  return __awaiter(this, void 0, void 0, function () {
233
323
  var tag;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pioneer-platform/pioneer-events",
3
- "version": "8.18.0",
3
+ "version": "8.20.0",
4
4
  "main": "./lib/index.js",
5
5
  "types": "./lib/index.d.ts",
6
6
  "scripts": {