diff --git a/components/wallet-logger.js b/components/wallet-logger.js index c296dd1a..a591601a 100644 --- a/components/wallet-logger.js +++ b/components/wallet-logger.js @@ -252,15 +252,13 @@ export const WalletLoggerProvider = ({ children }) => { return () => idb.current?.close() }, []) - const appendLog = useCallback((walletName, level, message) => { - const log = { wallet: walletName, level, message, ts: +new Date() } + const appendLog = useCallback((wallet, level, message) => { + const log = { wallet: wallet.name, level, message, ts: +new Date() } saveLog(log) setLogs((prevLogs) => [...prevLogs, log]) }, [saveLog]) - const deleteLogs = useCallback(async (walletName) => { - const wallet = walletName ? getWalletByName(walletName, me) : null - + const deleteLogs = useCallback(async (wallet) => { if (!wallet || wallet.canReceive) { await deleteServerWalletLogs({ variables: { wallet: wallet?.type } }) } @@ -302,9 +300,9 @@ export function useWalletLogger (wallet) { // TODO: // also send this to us if diagnostics was enabled, // very similar to how the service worker logger works. - appendLog(wallet.name, level, message) + appendLog(wallet, level, message) console[level !== 'error' ? 'info' : 'error'](`[${wallet.name}]`, message) - }, [appendLog, wallet?.name]) + }, [appendLog, wallet]) const logger = useMemo(() => ({ ok: (...message) => log('ok')(message.join(' ')), @@ -312,7 +310,7 @@ export function useWalletLogger (wallet) { error: (...message) => log('error')(message.join(' ')) }), [log, wallet?.name]) - const deleteLogs = useCallback((w) => innerDeleteLogs(w?.name || wallet?.name), [innerDeleteLogs, wallet?.name]) + const deleteLogs = useCallback((w) => innerDeleteLogs(w || wallet), [innerDeleteLogs, wallet]) return { logger, deleteLogs } } diff --git a/components/wallet/index.js b/components/wallet/index.js index c1e7f10c..c713a99e 100644 --- a/components/wallet/index.js +++ b/components/wallet/index.js @@ -70,6 +70,8 @@ export function useWallet (name) { disable, isConfigured: !!config, status: config?.enabled ? Status.Enabled : Status.Initialized, + canPay: !!wallet?.sendPayment, + canReceive: !!wallet?.createInvoice, logger } } @@ -81,7 +83,7 @@ export function getWalletByName (name, me) { export function getEnabledWallet (me) { // TODO: handle multiple enabled wallets return WALLET_DEFS - .filter(def => def.canPay) + .filter(def => !!def.sendPayment) .find(def => { const key = getStorageKey(def.name, me) const config = SSR ? null : JSON.parse(window?.localStorage.getItem(key)) diff --git a/components/wallet/lnbits.js b/components/wallet/lnbits.js index 186cb142..0eb88d0d 100644 --- a/components/wallet/lnbits.js +++ b/components/wallet/lnbits.js @@ -1,8 +1,5 @@ export const name = 'lnbits' -export const canPay = true -export const canReceive = false - export const fields = [ { name: 'url',