From 5262d0884715026f2dbd65b0833212c890087df7 Mon Sep 17 00:00:00 2001 From: Enes Date: Thu, 18 Apr 2024 11:05:13 +0300 Subject: [PATCH] feat: add loading state to useWeb3ModalState hook (#1911) --- packages/core/src/controllers/ModalController.ts | 1 + packages/core/src/controllers/PublicStateController.ts | 2 ++ packages/scaffold/src/client.ts | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/core/src/controllers/ModalController.ts b/packages/core/src/controllers/ModalController.ts index c89fb00dec..6cb02f7c77 100644 --- a/packages/core/src/controllers/ModalController.ts +++ b/packages/core/src/controllers/ModalController.ts @@ -71,5 +71,6 @@ export const ModalController = { setLoading(loading: ModalControllerState['loading']) { state.loading = loading + PublicStateController.set({ loading }) } } diff --git a/packages/core/src/controllers/PublicStateController.ts b/packages/core/src/controllers/PublicStateController.ts index f4b91511a2..03f83ed2da 100644 --- a/packages/core/src/controllers/PublicStateController.ts +++ b/packages/core/src/controllers/PublicStateController.ts @@ -3,12 +3,14 @@ import type { CaipNetworkId } from '../utils/TypeUtil.js' // -- Types --------------------------------------------- // export interface PublicStateControllerState { + loading: boolean open: boolean selectedNetworkId?: CaipNetworkId } // -- State --------------------------------------------- // const state = proxy({ + loading: false, open: false, selectedNetworkId: undefined }) diff --git a/packages/scaffold/src/client.ts b/packages/scaffold/src/client.ts index 0ad3824941..1139c9f59a 100644 --- a/packages/scaffold/src/client.ts +++ b/packages/scaffold/src/client.ts @@ -118,7 +118,7 @@ export class Web3ModalScaffold { } public getState() { - return { ...PublicStateController.state } + return PublicStateController.state } public subscribeState(callback: (newState: PublicStateControllerState) => void) {