Compare commits
No commits in common. "8e18fa0760fd074f439b2fb54bc4801a360d63d9" and "ddb32e0bb719982325f9361b61365dafa23adf14" have entirely different histories.
8e18fa0760
...
ddb32e0bb7
@ -1,9 +1,10 @@
|
||||
import { SSR } from '@/lib/constants'
|
||||
import { useCallback, useState } from 'react'
|
||||
|
||||
export default function useLocalState (storageKey, defaultValue) {
|
||||
export default function useLocalState (storageKey, initialValue = '') {
|
||||
const [value, innerSetValue] = useState(
|
||||
(SSR ? null : JSON.parse(window.localStorage.getItem(storageKey))) || defaultValue
|
||||
initialValue ||
|
||||
(SSR ? null : JSON.parse(window.localStorage.getItem(storageKey)))
|
||||
)
|
||||
|
||||
const setValue = useCallback((newValue) => {
|
||||
|
@ -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'
|
||||
|
@ -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)
|
||||
|
||||
|
@ -11,25 +11,19 @@ export const createInvoice = async (
|
||||
{ msats, description, descriptionHash, expiry },
|
||||
{ cert, macaroon, socket }
|
||||
) => {
|
||||
try {
|
||||
const { lnd } = await authenticatedLndGrpc({
|
||||
cert,
|
||||
macaroon,
|
||||
socket
|
||||
})
|
||||
const { lnd } = await authenticatedLndGrpc({
|
||||
cert,
|
||||
macaroon,
|
||||
socket
|
||||
})
|
||||
|
||||
const invoice = await lndCreateInvoice({
|
||||
lnd,
|
||||
description,
|
||||
description_hash: descriptionHash,
|
||||
mtokens: String(msats),
|
||||
expires_at: datePivot(new Date(), { seconds: expiry })
|
||||
})
|
||||
const invoice = await lndCreateInvoice({
|
||||
lnd,
|
||||
description,
|
||||
description_hash: descriptionHash,
|
||||
mtokens: String(msats),
|
||||
expires_at: datePivot(new Date(), { seconds: expiry })
|
||||
})
|
||||
|
||||
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)
|
||||
}
|
||||
return invoice.request
|
||||
}
|
||||
|
@ -59,10 +59,15 @@ 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: ` + error
|
||||
message: `creating invoice for ${description ?? ''} failed: ` + details
|
||||
}, { models })
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user