Compare commits
2 Commits
ddb32e0bb7
...
8e18fa0760
Author | SHA1 | Date | |
---|---|---|---|
|
8e18fa0760 | ||
|
4000522773 |
@ -1,10 +1,9 @@
|
|||||||
import { SSR } from '@/lib/constants'
|
import { SSR } from '@/lib/constants'
|
||||||
import { useCallback, useState } from 'react'
|
import { useCallback, useState } from 'react'
|
||||||
|
|
||||||
export default function useLocalState (storageKey, initialValue = '') {
|
export default function useLocalState (storageKey, defaultValue) {
|
||||||
const [value, innerSetValue] = useState(
|
const [value, innerSetValue] = useState(
|
||||||
initialValue ||
|
(SSR ? null : JSON.parse(window.localStorage.getItem(storageKey))) || defaultValue
|
||||||
(SSR ? null : JSON.parse(window.localStorage.getItem(storageKey)))
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const setValue = useCallback((newValue) => {
|
const setValue = useCallback((newValue) => {
|
||||||
|
@ -31,7 +31,7 @@ export default function WalletSettings () {
|
|||||||
...acc,
|
...acc,
|
||||||
[field.name]: wallet.config?.[field.name] || ''
|
[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
|
// check if wallet uses the form-level validation built into Formik or a Yup schema
|
||||||
const validateProps = typeof wallet.fieldValidation === 'function'
|
const validateProps = typeof wallet.fieldValidation === 'function'
|
||||||
|
@ -158,7 +158,7 @@ function useConfig (wallet) {
|
|||||||
const me = useMe()
|
const me = useMe()
|
||||||
|
|
||||||
const storageKey = getStorageKey(wallet?.name, me)
|
const storageKey = getStorageKey(wallet?.name, me)
|
||||||
const [clientConfig, setClientConfig, clearClientConfig] = useClientConfig(storageKey)
|
const [clientConfig, setClientConfig, clearClientConfig] = useClientConfig(storageKey, {})
|
||||||
|
|
||||||
const [serverConfig, setServerConfig, clearServerConfig] = useServerConfig(wallet)
|
const [serverConfig, setServerConfig, clearServerConfig] = useServerConfig(wallet)
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ export const createInvoice = async (
|
|||||||
{ msats, description, descriptionHash, expiry },
|
{ msats, description, descriptionHash, expiry },
|
||||||
{ cert, macaroon, socket }
|
{ cert, macaroon, socket }
|
||||||
) => {
|
) => {
|
||||||
|
try {
|
||||||
const { lnd } = await authenticatedLndGrpc({
|
const { lnd } = await authenticatedLndGrpc({
|
||||||
cert,
|
cert,
|
||||||
macaroon,
|
macaroon,
|
||||||
@ -26,4 +27,9 @@ export const createInvoice = async (
|
|||||||
})
|
})
|
||||||
|
|
||||||
return invoice.request
|
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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,15 +59,10 @@ export async function createInvoice (userId, { msats, description, descriptionHa
|
|||||||
return { invoice, wallet }
|
return { invoice, wallet }
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(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({
|
await addWalletLog({
|
||||||
wallet,
|
wallet,
|
||||||
level: 'ERROR',
|
level: 'ERROR',
|
||||||
message: `creating invoice for ${description ?? ''} failed: ` + details
|
message: `creating invoice for ${description ?? ''} failed: ` + error
|
||||||
}, { models })
|
}, { models })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user