Skip to content

Commit

Permalink
Include method in NWC logs
Browse files Browse the repository at this point in the history
  • Loading branch information
ekzyis committed Oct 24, 2024
1 parent cfacf42 commit 1c74468
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions wallets/nwc/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,25 +65,25 @@ export async function nwcCall ({ nwcUrl, method, params }, { logger, timeout } =

await logger?.info(`published ${method} request`)

await logger?.info('waiting for response ...')
await logger?.info(`waiting for ${method} response ...`)

const [response] = await subscription

if (!response) {
throw new Error('no response')
throw new Error(`no ${method} response`)
}

await logger?.ok('response received')
await logger?.ok(`${method} response received`)

if (!verifyEvent(response)) throw new Error('invalid response: failed to verify')
if (!verifyEvent(response)) throw new Error(`invalid ${method} response: failed to verify`)

const decrypted = await nip04.decrypt(secret, walletPubkey, response.content)
const content = JSON.parse(decrypted)

if (content.error) throw new Error(content.error.message)
if (content.result) return content.result

throw new Error('invalid response: missing error or result')
throw new Error(`invalid ${method} response: missing error or result`)
} finally {
relay?.close()
await logger?.info(`closed connection to ${relayUrl}`)
Expand Down

0 comments on commit 1c74468

Please sign in to comment.