Skip to content

Commit

Permalink
feat: add loading state to useWeb3ModalState hook (#1911)
Browse files Browse the repository at this point in the history
  • Loading branch information
enesozturk authored Apr 18, 2024
1 parent f339383 commit 5262d08
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/core/src/controllers/ModalController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,6 @@ export const ModalController = {

setLoading(loading: ModalControllerState['loading']) {
state.loading = loading
PublicStateController.set({ loading })
}
}
2 changes: 2 additions & 0 deletions packages/core/src/controllers/PublicStateController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<PublicStateControllerState>({
loading: false,
open: false,
selectedNetworkId: undefined
})
Expand Down
2 changes: 1 addition & 1 deletion packages/scaffold/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export class Web3ModalScaffold {
}

public getState() {
return { ...PublicStateController.state }
return PublicStateController.state
}

public subscribeState(callback: (newState: PublicStateControllerState) => void) {
Expand Down

0 comments on commit 5262d08

Please sign in to comment.