Skip to content

Commit

Permalink
fix: update disconnect method (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
totraev authored Dec 1, 2024
1 parent c241d94 commit 1717074
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/lovely-hotels-lay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@babylonlabs-io/bbn-wallet-connect": patch
---

update disconnect method
15 changes: 12 additions & 3 deletions src/hooks/useWalletConnect.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
import { useCallback, useMemo } from "react";

import { useChainProviders } from "@/context/Chain.context";
import { useWidgetState } from "./useWidgetState";

export function useWalletConnect() {
const { confirmed, chains: chainMap, selectedWallets, open: openModal, close, reset } = useWidgetState();
const { confirmed, chains: chainMap, selectedWallets, open: openModal, reset } = useWidgetState();
const connectors = useChainProviders();

const open = useCallback(() => {
reset?.();
openModal?.();
}, [openModal, reset]);

const disconnect = useCallback(() => {
const disconnect = useCallback(async () => {
for (const connector of Object.values(connectors)) {
if (!connector) continue;

await connector.disconnect();
}

reset?.();
}, [close]);
}, []);

const selected = useMemo(() => {
const chains = Object.values(chainMap).filter(Boolean);
Expand Down

0 comments on commit 1717074

Please sign in to comment.