From 10aba6de840f2c13539c31d813911b58d301ac60 Mon Sep 17 00:00:00 2001 From: Griko Nibras Date: Thu, 25 Jan 2024 16:16:35 +0700 Subject: [PATCH] refactor: update useAccount hook --- src/hooks/useAccount.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/hooks/useAccount.ts b/src/hooks/useAccount.ts index 65122f3a..9b7d587f 100644 --- a/src/hooks/useAccount.ts +++ b/src/hooks/useAccount.ts @@ -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"; @@ -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();