diff --git a/.changeset/tame-dragons-arrive.md b/.changeset/tame-dragons-arrive.md new file mode 100644 index 0000000..7ad7981 --- /dev/null +++ b/.changeset/tame-dragons-arrive.md @@ -0,0 +1,5 @@ +--- +"@babylonlabs-io/bbn-wallet-connect": patch +--- + +add unsubscribe method to BTCProvider diff --git a/src/core/wallets/btc/BTCProvider.ts b/src/core/wallets/btc/BTCProvider.ts index 22d0fc0..2ac2078 100644 --- a/src/core/wallets/btc/BTCProvider.ts +++ b/src/core/wallets/btc/BTCProvider.ts @@ -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. diff --git a/src/core/wallets/btc/okx/provider.ts b/src/core/wallets/btc/okx/provider.ts index 7b42456..2dfa942 100644 --- a/src/core/wallets/btc/okx/provider.ts +++ b/src/core/wallets/btc/okx/provider.ts @@ -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 => { return await this.mempool.getAddressBalance(await this.getAddress());