Fix NWC support detection (#845)
* Fix NWC support detection * Fix missing toast if support for pay_invoice not detected
This commit is contained in:
parent
7065008f5d
commit
81ab960d92
@ -47,8 +47,8 @@ export function NWCProvider ({ children }) {
|
|||||||
setSecret(params.secret)
|
setSecret(params.secret)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const supported = await validateParams(params)
|
await validateParams(params)
|
||||||
setEnabled(supported.includes('pay_invoice'))
|
setEnabled(true)
|
||||||
await updateRelay(params.relayUrl)
|
await updateRelay(params.relayUrl)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('invalid NWC config:', err)
|
console.error('invalid NWC config:', err)
|
||||||
@ -78,8 +78,8 @@ export function NWCProvider ({ children }) {
|
|||||||
window.localStorage.setItem(storageKey, JSON.stringify(config))
|
window.localStorage.setItem(storageKey, JSON.stringify(config))
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const supported = await validateParams(params)
|
await validateParams(params)
|
||||||
setEnabled(supported.includes('pay_invoice'))
|
setEnabled(true)
|
||||||
await updateRelay(params.relayUrl)
|
await updateRelay(params.relayUrl)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('invalid NWC config:', err)
|
console.error('invalid NWC config:', err)
|
||||||
@ -214,8 +214,8 @@ async function getInfoWithRelay (relay, walletPubkey) {
|
|||||||
], {
|
], {
|
||||||
onevent (event) {
|
onevent (event) {
|
||||||
clearTimeout(timer)
|
clearTimeout(timer)
|
||||||
const supported = event.content.split()
|
const supported = event.content.split(',')
|
||||||
resolve(supported)
|
supported.includes('pay_invoice') ? resolve() : reject(new Error('wallet does not support pay_invoice'))
|
||||||
sub.close()
|
sub.close()
|
||||||
},
|
},
|
||||||
onclose (reason) {
|
onclose (reason) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user