UNPKG

@web3auth/no-modal

Version:
35 lines (32 loc) 1.02 kB
import { ref } from 'vue'; import { useWalletServicesPlugin } from './useWalletServicesPlugin.js'; import { WalletServicesPluginError } from '../../base/plugin/errors.js'; import { log } from '../../base/loglevel.js'; const useWalletConnectScanner = () => { const { plugin, ready } = useWalletServicesPlugin(); const loading = ref(false); const error = ref(null); const showWalletConnectScanner = async showWalletConnectScannerParams => { loading.value = true; error.value = null; try { if (!plugin) throw WalletServicesPluginError.notInitialized(); if (!ready) throw WalletServicesPluginError.walletPluginNotConnected(); await plugin.value.showWalletConnectScanner(showWalletConnectScannerParams); } catch (err) { log.error("Error showing wallet connect scanner", err); error.value = err; } finally { loading.value = false; } }; return { loading, error, showWalletConnectScanner }; }; export { useWalletConnectScanner };