Skip to content

Commit

Permalink
fix: execution reverted
Browse files Browse the repository at this point in the history
Fix "execution reverted" error caused by trying to looking timestamp of non-existing passport.
  • Loading branch information
aahna-ashina committed Oct 1, 2023
1 parent 938d0f4 commit 12cefbd
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions data-sources/citizens/generate-citizen-count-csv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -85,7 +81,7 @@ async function getNextId(): Promise<number> {
}

async function getTimestamp(id: number): Promise<number> {
console.info('getTimestamp')
console.info('getTimestamp, id:', id)
return await PassportContract.methods.timestampOf(id).call()
}

Expand Down

0 comments on commit 12cefbd

Please sign in to comment.