Skip to content

Commit ffe03a7

Browse files
gabrielKerekeskomret
authored andcommitted
fix(suite): potentially fix Solana account subscription
(cherry picked from commit a0a35d0)
1 parent a68b2b9 commit ffe03a7

File tree

1 file changed

+15
-1
lines changed
  • packages/blockchain-link/src/workers/solana

1 file changed

+15
-1
lines changed

packages/blockchain-link/src/workers/solana/index.ts

+15-1
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,8 @@ const subscribeAccounts = async (
329329
},
330330
},
331331
});
332-
state.addAccounts([{ ...a, subscriptionId }]);
333332
});
333+
state.addAccounts([{ ...a, subscriptionId }]);
334334
});
335335
return { subscribed: true };
336336
};
@@ -433,6 +433,20 @@ class SolanaWorker extends BaseWorker<SolanaAPI> {
433433
}
434434

435435
disconnect(): void {
436+
if (!this.api) {
437+
return;
438+
}
439+
440+
this.state.accounts.forEach(
441+
a => a.subscriptionId && this.api?.removeAccountChangeListener(a.subscriptionId),
442+
);
443+
444+
if (this.state.getSubscription('block')) {
445+
const interval = this.state.getSubscription('block') as NodeJS.Timer;
446+
clearInterval(interval);
447+
this.state.removeSubscription('block');
448+
}
449+
436450
this.api = undefined;
437451
}
438452
}

0 commit comments

Comments
 (0)