From 12cefbd1b3dfd684f71bca753595b3422b1bbe73 Mon Sep 17 00:00:00 2001 From: Aahna Ashina <95955389+aahna-ashina@users.noreply.github.com> Date: Mon, 2 Oct 2023 00:43:54 +0800 Subject: [PATCH] fix: execution reverted Fix "execution reverted" error caused by trying to looking timestamp of non-existing passport. --- data-sources/citizens/generate-citizen-count-csv.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/data-sources/citizens/generate-citizen-count-csv.ts b/data-sources/citizens/generate-citizen-count-csv.ts index a79aa65fc..fdd94148f 100644 --- a/data-sources/citizens/generate-citizen-count-csv.ts +++ b/data-sources/citizens/generate-citizen-count-csv.ts @@ -47,17 +47,13 @@ async function loadPassportMintsByWeek() { console.info('week:', `[${weekBeginDate.toISOString()} → ${weekEndDate.toISOString()}]`) let newCitizensCount: number = 0 - while (await getTimestamp(id) < (weekEndDate.getTime() / 1000)) { + while ((id < nextId) && (await getTimestamp(id) < (weekEndDate.getTime() / 1000))) { console.info('id:', id) newCitizensCount++ console.info('newCitizensCount:', newCitizensCount) id++ - if (id == nextId) { - console.info('Reached last passport ID:', (nextId - 1)) - break - } } const totalExpiredPassports: number = getTotalExpiredPassports(weekEndDate, id) @@ -85,7 +81,7 @@ async function getNextId(): Promise { } async function getTimestamp(id: number): Promise { - console.info('getTimestamp') + console.info('getTimestamp, id:', id) return await PassportContract.methods.timestampOf(id).call() }