Skip to content

Commit

Permalink
Merge pull request #31 from babylonlabs-io/add-ee
Browse files Browse the repository at this point in the history
feat: add unsubscribe method to BTCProvider
  • Loading branch information
totraev authored Nov 23, 2024
2 parents 0b7568a + 957fc84 commit b21e83a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/tame-dragons-arrive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@babylonlabs-io/bbn-wallet-connect": patch
---

add unsubscribe method to BTCProvider
2 changes: 2 additions & 0 deletions src/core/wallets/btc/BTCProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ export abstract class BTCProvider implements IProvider {
*/
abstract on(eventName: string, callBack: () => void): void;

abstract off(eventName: string, callBack: () => void): void;

/**
* Gets the balance for the connected wallet address.
* By default, this method will return the mempool balance if not implemented by the child class.
Expand Down
10 changes: 10 additions & 0 deletions src/core/wallets/btc/okx/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,16 @@ export class OKXProvider extends BTCProvider {
}
};

off = (eventName: string, callBack: () => void) => {
if (!this.walletInfo) {
throw new Error("OKX Wallet not connected");
}
// subscribe to account change event
if (eventName === "accountChanged") {
return this.provider.off(eventName, callBack);
}
};

// Mempool calls
getBalance = async (): Promise<number> => {
return await this.mempool.getAddressBalance(await this.getAddress());
Expand Down

0 comments on commit b21e83a

Please sign in to comment.