Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions lib/firefly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,10 @@ export default class FireFly extends HttpBase {
return this.getOne<FireFlyTokenPoolResponse>(`/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<FireFlyTokenTransferResponse>('/tokens/mint', transfer, options);
}
Expand Down Expand Up @@ -608,26 +612,34 @@ export default class FireFly extends HttpBase {
subscriptions: string | string[] | FireFlySubscriptionBase,
callback: FireFlyWebSocketCallback,
socketOptions?: WebSocket.ClientOptions | http.ClientRequestArgs,
afterConnect?: FireFlyWebSocketConnectCallback,
fireflySocketOptions?: Partial<FireFlyWebSocketOptions> | FireFlyWebSocketConnectCallback,
): FireFlyWebSocket {
if (typeof fireflySocketOptions === 'function') {
// Legacy compatibility (afterConnect callback passed as 4th arg)
fireflySocketOptions = <FireFlyWebSocketOptions>{
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)) {
Expand Down
6 changes: 4 additions & 2 deletions lib/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -171,7 +172,8 @@ export interface FireFlyEnrichedEvent extends FireFlyEventResponse {
operation?: FireFlyOperationResponse;
}

export interface FireFlyEventDelivery extends FireFlyEnrichedEvent {
export interface FireFlyEventDelivery extends Omit<FireFlyEnrichedEvent, 'type'> {
type: FireFlyEnrichedEvent['type'] | 'protocol_error';
subscription: {
id: string;
name: string;
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down