Browse Source

Fix unsubscribe wrong address (#90)

NorbertBodziony 4 years ago
parent
commit
b1f8dde5aa
1 changed files with 4 additions and 0 deletions
  1. 4 0
      ts/src/rpc.ts

+ 4 - 0
ts/src/rpc.ts

@@ -510,6 +510,10 @@ export class RpcFactory {
       // @ts-ignore
       accountsNamespace["unsubscribe"] = (address: PublicKey) => {
         let sub = subscriptions.get(address.toString());
+        if (!sub) {
+          console.warn("Address is not subscribed");
+          return;
+        }
         if (subscriptions) {
           provider.connection
             .removeAccountChangeListener(sub.listener)