From bdfc90a6513d8477d11f951c5dd4486e5170ba6b Mon Sep 17 00:00:00 2001 From: Andrew Richardson Date: Tue, 1 Aug 2023 21:22:05 -0400 Subject: [PATCH 1/3] Add deleteTokenPool Signed-off-by: Andrew Richardson --- lib/firefly.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/firefly.ts b/lib/firefly.ts index f977a5f..01dde76 100644 --- a/lib/firefly.ts +++ b/lib/firefly.ts @@ -344,6 +344,10 @@ export default class FireFly extends HttpBase { return this.getOne(`/tokens/pools/${nameOrId}`, options); } + async deleteTokenPool(nameOrId: string, options?: FireFlyDeleteOptions) { + await this.deleteOne(`/tokens/pools/${nameOrId}`, options); + } + mintTokens(transfer: FireFlyTokenMintRequest, options?: FireFlyCreateOptions) { return this.createOne('/tokens/mint', transfer, options); } From aeae1c200086338fe9f4aaea78f1fd47ed399680 Mon Sep 17 00:00:00 2001 From: Andrew Richardson Date: Wed, 11 Oct 2023 21:49:59 -0400 Subject: [PATCH 2/3] Expose "protocol_error" event type Signed-off-by: Andrew Richardson --- lib/interfaces.ts | 3 ++- package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/interfaces.ts b/lib/interfaces.ts index 0438aa5..e55aee9 100644 --- a/lib/interfaces.ts +++ b/lib/interfaces.ts @@ -171,7 +171,8 @@ export interface FireFlyEnrichedEvent extends FireFlyEventResponse { operation?: FireFlyOperationResponse; } -export interface FireFlyEventDelivery extends FireFlyEnrichedEvent { +export interface FireFlyEventDelivery extends Omit { + type: FireFlyEnrichedEvent['type'] | 'protocol_error'; subscription: { id: string; name: string; diff --git a/package-lock.json b/package-lock.json index bc914ef..cdaa705 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@hyperledger/firefly-sdk", - "version": "1.2.12", + "version": "1.2.15", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@hyperledger/firefly-sdk", - "version": "1.2.12", + "version": "1.2.15", "license": "Apache-2.0", "dependencies": { "axios": "^0.26.1", diff --git a/package.json b/package.json index 902afd0..27ef704 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hyperledger/firefly-sdk", - "version": "1.2.14", + "version": "1.2.15", "description": "Client SDK for Hyperledger FireFly", "main": "dist/index.js", "types": "dist/index.d.ts", From 75a5262cc0a1c119e35bd420c578511f44ebb75e Mon Sep 17 00:00:00 2001 From: Andrew Richardson Date: Wed, 11 Oct 2023 23:10:00 -0400 Subject: [PATCH 3/3] Add "noack" option to completely disable managed ack on websockets Also move to passing an "options" object instead of continuing to add individual parameters to the listen() function. Signed-off-by: Andrew Richardson --- lib/firefly.ts | 24 ++++++++++++++++-------- lib/interfaces.ts | 3 ++- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/lib/firefly.ts b/lib/firefly.ts index 01dde76..6d10d66 100644 --- a/lib/firefly.ts +++ b/lib/firefly.ts @@ -612,26 +612,34 @@ export default class FireFly extends HttpBase { subscriptions: string | string[] | FireFlySubscriptionBase, callback: FireFlyWebSocketCallback, socketOptions?: WebSocket.ClientOptions | http.ClientRequestArgs, - afterConnect?: FireFlyWebSocketConnectCallback, + fireflySocketOptions?: Partial | FireFlyWebSocketConnectCallback, ): FireFlyWebSocket { + if (typeof fireflySocketOptions === 'function') { + // Legacy compatibility (afterConnect callback passed as 4th arg) + fireflySocketOptions = { + afterConnect: fireflySocketOptions, + }; + } const options: FireFlyWebSocketOptions = { host: this.options.websocket.host, namespace: this.options.namespace, username: this.options.username, password: this.options.password, - subscriptions: [], - autoack: false, reconnectDelay: this.options.websocket.reconnectDelay, heartbeatInterval: this.options.websocket.heartbeatInterval, - socketOptions: socketOptions, - afterConnect: afterConnect, + autoack: false, + ...fireflySocketOptions, + socketOptions, + subscriptions: [], }; const handler: FireFlyWebSocketCallback = (socket, event) => { this.queue = this.queue.finally(() => callback(socket, event)); - this.queue.then(() => { - socket.ack(event); - }); + if (!options.noack) { + this.queue.then(() => { + socket.ack(event); + }); + } }; if (Array.isArray(subscriptions)) { diff --git a/lib/interfaces.ts b/lib/interfaces.ts index e55aee9..3f89324 100644 --- a/lib/interfaces.ts +++ b/lib/interfaces.ts @@ -76,7 +76,8 @@ export interface FireFlyWebSocketOptions { username?: string; password?: string; ephemeral?: FireFlyEphemeralSubscription; - autoack: boolean; + autoack?: boolean; + noack?: boolean; reconnectDelay: number; heartbeatInterval: number; socketOptions?: WebSocket.ClientOptions | http.ClientRequestArgs;