UNPKG

@web3auth/modal

Version:

Multi chain wallet aggregator for web3Auth

35 lines (31 loc) 872 B
'use strict'; var noModal = require('@web3auth/no-modal'); var vue = require('vue'); var useWalletServicesPlugin = require('./useWalletServicesPlugin.js'); const useCheckout = () => { const { plugin, ready } = useWalletServicesPlugin.useWalletServicesPlugin(); const loading = vue.ref(false); const error = vue.ref(null); const showCheckout = async showCheckoutParams => { loading.value = true; error.value = null; try { if (!plugin) throw noModal.WalletServicesPluginError.notInitialized(); if (!ready) throw noModal.WalletServicesPluginError.walletPluginNotConnected(); await plugin.value.showCheckout(showCheckoutParams); } catch (err) { error.value = err; } finally { loading.value = false; } }; return { loading, error, showCheckout }; }; exports.useCheckout = useCheckout;