Skip to content

Commit

Permalink
fix(wallet): refetch using query directly to avoid circular dep
Browse files Browse the repository at this point in the history
  • Loading branch information
ygrishajev committed Sep 19, 2024
1 parent 6e4e991 commit 7d38ebf
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions apps/deploy-web/src/context/WalletProvider/WalletProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import { browserEnvConfig } from "@src/config/browser-env.config";
import { useAllowance } from "@src/hooks/useAllowance";
import { useManagedWallet } from "@src/hooks/useManagedWallet";
import { useUser } from "@src/hooks/useUser";
import { useWalletBalance } from "@src/hooks/useWalletBalance";
import { useWhen } from "@src/hooks/useWhen";
import { useBalances } from "@src/queries/useBalancesQuery";
import { txHttpService } from "@src/services/http/http.service";
import networkStore from "@src/store/networkStore";
import { AnalyticsEvents } from "@src/utils/analytics";
Expand Down Expand Up @@ -72,7 +72,6 @@ export const WalletProvider = ({ children }) => {
const { enqueueSnackbar, closeSnackbar } = useSnackbar();
const router = useRouter();
const { settings } = useSettings();
const { refetch: refetchBalances } = useWalletBalance();
const user = useUser();
const userWallet = useSelectedChain();
const { wallet: managedWallet, isLoading, create: createManagedWallet } = useManagedWallet();
Expand All @@ -84,6 +83,7 @@ export const WalletProvider = ({ children }) => {
username,
isWalletConnected
} = useMemo(() => (selectedWalletType === "managed" && managedWallet) || userWallet, [managedWallet, userWallet, selectedWalletType]);
const { refetch: refetchBalances } = useBalances(walletAddress);
const { addEndpoints } = useManager();
const isManaged = useMemo(() => !!managedWallet && managedWallet?.address === walletAddress, [walletAddress, managedWallet]);

Expand Down Expand Up @@ -261,7 +261,8 @@ export const WalletProvider = ({ children }) => {

return false;
} finally {
refetchBalances();
console.log("DEBUG refetching");
refetchBalances({ force: true });
if (pendingSnackbarKey) {
closeSnackbar(pendingSnackbarKey);
}
Expand Down

0 comments on commit 7d38ebf

Please sign in to comment.