Compare commits

..

2 Commits

Author SHA1 Message Date
ekzyis 8e18fa0760
Remove TODO about errors in createInvoice (#1300) 2024-08-14 14:56:02 -05:00
ekzyis 4000522773
Fix WebLN checkbox unclickable (#1299)
Checkbox was unclickable because wallet.isConfigured is false if wallet.config was null.
2024-08-14 14:29:24 -05:00
5 changed files with 24 additions and 24 deletions

View File

@ -1,10 +1,9 @@
import { SSR } from '@/lib/constants'
import { useCallback, useState } from 'react'
export default function useLocalState (storageKey, initialValue = '') {
export default function useLocalState (storageKey, defaultValue) {
const [value, innerSetValue] = useState(
initialValue ||
(SSR ? null : JSON.parse(window.localStorage.getItem(storageKey)))
(SSR ? null : JSON.parse(window.localStorage.getItem(storageKey))) || defaultValue
)
const setValue = useCallback((newValue) => {

View File

@ -31,7 +31,7 @@ export default function WalletSettings () {
...acc,
[field.name]: wallet.config?.[field.name] || ''
}
}, wallet.config || {})
}, wallet.config)
// check if wallet uses the form-level validation built into Formik or a Yup schema
const validateProps = typeof wallet.fieldValidation === 'function'

View File

@ -158,7 +158,7 @@ function useConfig (wallet) {
const me = useMe()
const storageKey = getStorageKey(wallet?.name, me)
const [clientConfig, setClientConfig, clearClientConfig] = useClientConfig(storageKey)
const [clientConfig, setClientConfig, clearClientConfig] = useClientConfig(storageKey, {})
const [serverConfig, setServerConfig, clearServerConfig] = useServerConfig(wallet)

View File

@ -11,6 +11,7 @@ export const createInvoice = async (
{ msats, description, descriptionHash, expiry },
{ cert, macaroon, socket }
) => {
try {
const { lnd } = await authenticatedLndGrpc({
cert,
macaroon,
@ -26,4 +27,9 @@ export const createInvoice = async (
})
return invoice.request
} catch (err) {
// LND errors can be in this shape: [code, type, { err: { code, details, metadata } }]
const details = err[2]?.err?.details || err.message || err.toString?.()
throw new Error(details)
}
}

View File

@ -59,15 +59,10 @@ export async function createInvoice (userId, { msats, description, descriptionHa
return { invoice, wallet }
} catch (error) {
console.error(error)
// TODO: I think this is a bug, `createInvoice` should parse the error
// LND errors are in this shape: [code, type, { err: { code, details, metadata } }]
const details = error[2]?.err?.details || error.message || error.toString?.()
await addWalletLog({
wallet,
level: 'ERROR',
message: `creating invoice for ${description ?? ''} failed: ` + details
message: `creating invoice for ${description ?? ''} failed: ` + error
}, { models })
}
}