diff --git a/src/lib/ConnectMassaWallets/store/accountStore.ts b/src/lib/ConnectMassaWallets/store/accountStore.ts index e16a8a10..6d9b0b1b 100644 --- a/src/lib/ConnectMassaWallets/store/accountStore.ts +++ b/src/lib/ConnectMassaWallets/store/accountStore.ts @@ -1,4 +1,6 @@ import { Provider } from '@massalabs/massa-web3'; +import { create } from 'zustand'; + import { SUPPORTED_MASSA_WALLETS } from '../../massa-react/const'; import { Wallet } from '@massalabs/wallet-provider'; @@ -41,10 +43,7 @@ export interface AccountStoreState { setConnectedAccount: (account?: Provider) => void; } -const accountStore = ( - set: (params: Partial) => void, - get: () => AccountStoreState, -) => ({ +export const useAccountStore = create((set, get) => ({ accounts: undefined, connectedAccount: undefined, accountObserver: undefined, @@ -157,6 +156,4 @@ const accountStore = ( setConnectedAccount: async (connectedAccount?: Provider) => { set({ connectedAccount }); }, -}); - -export default accountStore; +})); diff --git a/src/lib/ConnectMassaWallets/store/index.ts b/src/lib/ConnectMassaWallets/store/index.ts index 7bcbf191..ed41d175 100644 --- a/src/lib/ConnectMassaWallets/store/index.ts +++ b/src/lib/ConnectMassaWallets/store/index.ts @@ -1,13 +1,8 @@ import { WalletsListener } from '@massalabs/wallet-provider'; -import { create } from 'zustand'; +import { useAccountStore } from './accountStore'; +export { useAccountStore } from './accountStore'; -import accountStore, { AccountStoreState } from './accountStore'; - -export const useAccountStore = create((set, get) => ({ - ...accountStore(set, get), -})); - -async function initAccountStore() { +export async function initAccountStore() { new WalletsListener(4_000).subscribe((wallets) => { useAccountStore.getState().setWallets(wallets); });