UNPKG

@roochnetwork/rooch-sdk-kit

Version:
47 lines (46 loc) 2.26 kB
import { StateStorage } from 'zustand/middleware'; import { ThirdPartyAddress } from '@roochnetwork/rooch-sdk'; import { SupportChain } from '../feature/index.js'; import { Wallet } from '../wellet/index.js'; type WalletConnectionStatus = 'disconnected' | 'connecting' | 'connected'; export type WalletActions = { setChain: (chain: SupportChain) => void; setAddressSwitched: (selectedAccount: ThirdPartyAddress) => void; setConnectionStatus: (connectionStatus: WalletConnectionStatus) => void; setWalletConnected: (wallet: Wallet, connectedAddress: readonly ThirdPartyAddress[], selectedAddress: ThirdPartyAddress | null) => void; updateWalletAddresses: (accounts: readonly ThirdPartyAddress[]) => void; setWalletDisconnected: () => void; updateWallets: (wallets: readonly Wallet[]) => void; }; export type WalletStore = ReturnType<typeof createWalletStore>; export type WalletStoreState = { autoConnectEnabled: boolean; currentChain: SupportChain; currentWallet: Wallet | undefined; wallets: readonly Wallet[]; addresses: readonly ThirdPartyAddress[]; currentAddress: ThirdPartyAddress | undefined; lastConnectedAddress: string | undefined; lastConnectedWalletName: string | undefined; connectionStatus: WalletConnectionStatus; } & WalletActions; type WalletConfiguration = { autoConnectEnabled: boolean; chain: SupportChain; currentWallet: Wallet | undefined; wallets: Wallet[]; storage: StateStorage; storageKey: string; }; export declare function createWalletStore({ chain, currentWallet, wallets, storage, storageKey, autoConnectEnabled, }: WalletConfiguration): Omit<import("zustand").StoreApi<WalletStoreState>, "persist"> & { persist: { setOptions: (options: Partial<import("zustand/middleware.js").PersistOptions<WalletStoreState, unknown>>) => void; clearStorage: () => void; rehydrate: () => Promise<void> | void; hasHydrated: () => boolean; onHydrate: (fn: (state: WalletStoreState) => void) => () => void; onFinishHydration: (fn: (state: WalletStoreState) => void) => () => void; getOptions: () => Partial<import("zustand/middleware.js").PersistOptions<WalletStoreState, unknown>>; }; }; export {};