UNPKG

@web3auth/no-modal

Version:
33 lines (30 loc) 806 B
import { ref } from 'vue'; import { useWeb3AuthInner } from './useWeb3AuthInner.js'; import { WalletInitializationError } from '../../base/errors/index.js'; import { log } from '../../base/loglevel.js'; const useWeb3AuthDisconnect = () => { const { web3Auth } = useWeb3AuthInner(); const loading = ref(false); const error = ref(null); const disconnect = async options => { try { if (!web3Auth.value) throw WalletInitializationError.notReady(); error.value = null; loading.value = true; await web3Auth.value.logout(options); } catch (err) { log.error("Error disconnecting", err); error.value = err; } finally { loading.value = false; } }; return { loading, error, disconnect }; }; export { useWeb3AuthDisconnect };