UNPKG

@web3auth/no-modal

Version:
36 lines (33 loc) 882 B
import { ref } from 'vue'; import { useWeb3AuthInner } from './useWeb3AuthInner.js'; import { WalletInitializationError } from '../../base/errors/index.js'; import { log } from '../../base/loglevel.js'; const useWallets = () => { const { web3Auth } = useWeb3AuthInner(); const loading = ref(false); const error = ref(null); const wallets = ref([]); const syncWallets = async () => { if (!web3Auth.value) throw WalletInitializationError.notReady(); error.value = null; loading.value = true; try { const result = await web3Auth.value.getConnectedAccountsWithProviders(); wallets.value = result; } catch (err) { log.error("Error getting wallets", err); error.value = err; } finally { loading.value = false; } }; return { loading, error, wallets, syncWallets }; }; export { useWallets };