Skip to content

Commit

Permalink
Chary/wallet loading (#1233)
Browse files Browse the repository at this point in the history
* fix witval validator issue

* fix validator issues

* fix loading of wallet connection
  • Loading branch information
charymalloju authored May 10, 2024
1 parent 8d16582 commit 2b49181
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
15 changes: 13 additions & 2 deletions frontend/src/components/LandingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<boolean>(false);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -173,7 +184,7 @@ export const Landingpage = ({ children }: { children: React.ReactNode }) => {
chains.
</div>
</div>
{load ? (
{walletLoading || load ? (
<div className="landingpage-button">
<CircularProgress size={24} sx={{ color: 'white' }} />
</div>
Expand Down
1 change: 1 addition & 0 deletions frontend/src/store/features/wallet/walletSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 2b49181

Please sign in to comment.