From e5fee93933a5c4264d30372f8cd72ff0ebf37366 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Tue, 15 Feb 2022 21:11:05 -0300 Subject: [PATCH] prepare for upgrade to nos2x that will return full events instead of just the signature. --- src/pool.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/pool.js b/src/pool.js index 022cfaf..14c8e19 100644 --- a/src/pool.js +++ b/src/pool.js @@ -8,7 +8,15 @@ pool.setPolicy('randomChoice', 3) // this will try to sign either with window.nostr or using a manual prompt export async function signAsynchronously(event) { if (window.nostr) { - return window.nostr.signEvent(event) + let signatureOrEvent = await window.nostr.signEvent(event) + switch (typeof signatureOrEvent) { + case 'string': + return signatureOrEvent + case 'object': + return signatureOrEvent.sig + default: + throw new Error('Failed to sign with Nostr extension.') + } } else { return new Promise((resolve, reject) => { Dialog.create({