Skip to content

Commit

Permalink
refactor: update useAccount hook
Browse files Browse the repository at this point in the history
  • Loading branch information
grikomsn committed Jan 25, 2024
1 parent 269b805 commit 10aba6d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/hooks/useAccount.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useChain as useCosmosChain } from "@cosmos-kit/react";
import { useManager as useCosmosManager } from "@cosmos-kit/react";
import { useMemo } from "react";
import { useAccount as useWagmiAccount } from "wagmi";

Expand All @@ -10,12 +10,13 @@ export function useAccount(context: TrackWalletCtx) {
const trackedWallet = useTrackWallet(context);

const { data: chain } = useChainByID(trackedWallet?.chainID);

const { walletRepo } = useCosmosChain(chain?.chainType === "cosmos" ? chain.chainName : "cosmoshub");
const { getWalletRepo } = useCosmosManager();

const cosmosWallet = useMemo(() => {
return walletRepo.wallets.find((w) => w.walletName === trackedWallet?.walletName);
}, [trackedWallet?.walletName, walletRepo.wallets]);
if (chain?.chainType !== "cosmos") return;
const { wallets } = getWalletRepo(chain.chainName);
return wallets.find((w) => w.walletName === trackedWallet?.walletName);
}, [chain?.chainName, chain?.chainType, getWalletRepo, trackedWallet?.walletName]);

const wagmiAccount = useWagmiAccount();

Expand Down

0 comments on commit 10aba6d

Please sign in to comment.