Skip to content

Commit

Permalink
fix: handle not found
Browse files Browse the repository at this point in the history
  • Loading branch information
mfw78 committed Sep 29, 2023
1 parent adcd0b7 commit 1474831
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/types/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ export class Registry {
genesisBlockNumber: number
): Promise<Registry> {
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) =>
Expand Down Expand Up @@ -285,7 +287,11 @@ function parseConditionalOrders(
_version: number | undefined
): Map<Owner, Set<ConditionalOrder>> {
if (!serializedConditionalOrders) {
return new Map<Owner, Set<ConditionalOrder>>();
return createNewOrderMap();
}
return JSON.parse(serializedConditionalOrders, _reviver);
}

function createNewOrderMap(): Map<Owner, Set<ConditionalOrder>> {
return new Map<Owner, Set<ConditionalOrder>>();
}

0 comments on commit 1474831

Please sign in to comment.