Skip to content

Commit

Permalink
fix: DCFoundation#43 - asks user to select network when none has been…
Browse files Browse the repository at this point in the history
… selected
  • Loading branch information
gacogo committed May 1, 2024
1 parent 2ee984c commit 2a026d8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/contexts/wallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { AccountData } from "@keplr-wallet/types";
import { useNetwork } from "../hooks/useNetwork";
import { suggestChain } from "../lib/suggestChain";
import { registry } from "../lib/messageBuilder";
import { toast } from "react-toastify";

console.error(
" registry we have ",
Expand Down Expand Up @@ -97,6 +98,10 @@ export const WalletContextProvider = ({
}
} catch (error) {
console.error("Failed to suggest chain:", error);
toast.error("Select network first.", {
position: 'top-right',
autoClose: 3000,
});
} finally {
setIsLoading(false);
}
Expand All @@ -107,7 +112,7 @@ export const WalletContextProvider = ({
if (walletAddress) connectWallet();
setCurrNetName(netName);
}
}, [netName, currNetName, walletAddress, connectWallet]);
}, [netName, chain, currNetName, walletAddress, connectWallet]);

useEffect(() => {
if (!netName && stargateClient.current) {
Expand All @@ -117,7 +122,7 @@ export const WalletContextProvider = ({
if (walletAddress && netName && !stargateClient.current) {
connectWallet();
}
}, [walletAddress, netName, connectWallet]);
}, [chain, walletAddress, netName, connectWallet]);

return (
<WalletContext.Provider
Expand Down

0 comments on commit 2a026d8

Please sign in to comment.