From 0b9a2b259569bfd262c9e61cdc79c1a66c528f34 Mon Sep 17 00:00:00 2001 From: Paul Miller Date: Wed, 8 Nov 2023 12:37:00 -0600 Subject: [PATCH] don't throw for failed zap parse --- src/utils/fetchZaps.ts | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/utils/fetchZaps.ts b/src/utils/fetchZaps.ts index 9fb6d80d..00928b20 100644 --- a/src/utils/fetchZaps.ts +++ b/src/utils/fetchZaps.ts @@ -201,9 +201,13 @@ export const fetchZaps: ResourceFetcher< for (const object of data) { if (object.kind === 10000113) { - const content = JSON.parse(object.content); - if (content?.until) { - newUntil = content?.until + 1; + try { + const content = JSON.parse(object.content); + if (content?.until) { + newUntil = content?.until + 1; + } + } catch (e) { + console.error("Failed to parse content: ", object.content); } } @@ -212,14 +216,18 @@ export const fetchZaps: ResourceFetcher< } if (object.kind === 9735) { - const event = await simpleZapFromEvent( - object, - state.mutiny_wallet! - ); - - // Only add it if it's a valid zap (not undefined) - if (event) { - zaps.push(event); + try { + const event = await simpleZapFromEvent( + object, + state.mutiny_wallet! + ); + + // Only add it if it's a valid zap (not undefined) + if (event) { + zaps.push(event); + } + } catch (e) { + console.error("Failed to parse zap event: ", object); } } }