From 14748314aea360b739bc490c944cfb162f5c481a Mon Sep 17 00:00:00 2001 From: mfw78 Date: Thu, 28 Sep 2023 06:47:50 +0000 Subject: [PATCH] fix: handle not found --- src/types/model.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/types/model.ts b/src/types/model.ts index 172207f..2b0e5b6 100644 --- a/src/types/model.ts +++ b/src/types/model.ts @@ -146,7 +146,9 @@ export class Registry { genesisBlockNumber: number ): Promise { const db = storage.getDB(); - const ownerOrders = await loadOwnerOrders(storage, network); + const ownerOrders = await loadOwnerOrders(storage, network) + .then((orders) => orders) + .catch(() => createNewOrderMap()); const lastNotifiedError = await db .get(getNetworkStorageKey(LAST_NOTIFIED_ERROR_STORAGE_KEY, network)) .then((isoDate: string | number | Date) => @@ -285,7 +287,11 @@ function parseConditionalOrders( _version: number | undefined ): Map> { if (!serializedConditionalOrders) { - return new Map>(); + return createNewOrderMap(); } return JSON.parse(serializedConditionalOrders, _reviver); } + +function createNewOrderMap(): Map> { + return new Map>(); +}