From 2b4918111b245709a359cf9ed53424ce4aa2dd4c Mon Sep 17 00:00:00 2001 From: chary <57086313+charymalloju@users.noreply.github.com> Date: Fri, 10 May 2024 11:49:07 +0530 Subject: [PATCH] Chary/wallet loading (#1233) * fix witval validator issue * fix validator issues * fix loading of wallet connection --- frontend/src/components/LandingPage.tsx | 15 +++++++++++++-- frontend/src/store/features/wallet/walletSlice.ts | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/LandingPage.tsx b/frontend/src/components/LandingPage.tsx index d743f0a7d..3452848bc 100644 --- a/frontend/src/components/LandingPage.tsx +++ b/frontend/src/components/LandingPage.tsx @@ -34,6 +34,17 @@ export const Landingpage = ({ children }: { children: React.ReactNode }) => { const connected = useAppSelector( (state: RootState) => state.wallet.connected ); + + const walletLoading = useAppSelector( + (state: RootState) => state.wallet.isLoading + ) + + useEffect(() => { + if (!walletLoading) { + setLoad(false); + } + }, [walletLoading]) + const isLoading = useAppSelector((state) => state.wallet.isLoading); const [connectWalletDialogOpen, setConnectWalletDialogOpen] = useState(false); @@ -71,8 +82,8 @@ export const Landingpage = ({ children }: { children: React.ReactNode }) => { }; const tryConnectWallet = async (walletName: string) => { - setLoad(true); if (walletName === 'metamask') { + setLoad(true); try { for (let i = 0; i < networks.length; i++) { const chainId: string = networks[i].config.chainId; @@ -173,7 +184,7 @@ export const Landingpage = ({ children }: { children: React.ReactNode }) => { chains. - {load ? ( + {walletLoading || load ? (
diff --git a/frontend/src/store/features/wallet/walletSlice.ts b/frontend/src/store/features/wallet/walletSlice.ts index 616c19aaf..d5dc9d2a4 100644 --- a/frontend/src/store/features/wallet/walletSlice.ts +++ b/frontend/src/store/features/wallet/walletSlice.ts @@ -225,6 +225,7 @@ const walletSlice = createSlice({ builder .addCase(establishWalletConnection.pending, (state) => { state.status = TxStatus.PENDING; + state.isLoading = true }) .addCase(establishWalletConnection.fulfilled, (state, action) => { const networks = action.payload.chainInfos;