Skip to content

Commit

Permalink
fix: unknown block number - generate-count (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
aahna-ashina committed Dec 31, 2023
1 parent ed60029 commit dec5f70
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions data-sources/citizens/generate-citizen-count-csv.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
const Web3 = require('web3')
import { ethers } from 'ethers'
const Passport = require('../abis/Passport.json')
const csvWriter = require('csv-writer')
const fs = require('fs')
const Papa = require('papaparse')

const web3 = new Web3('https://eth.llamarpc.com')
console.info('web3.version:', web3.version)
const ethersProvider = new ethers.JsonRpcProvider(
'https://rpc.ankr.com/eth'
)
console.info('ethersProvider:', ethersProvider)

const PassportContract = new web3.eth.Contract(
const passportContract = new ethers.Contract(
'0x3337dac9f251d4e403d6030e18e3cfb6a2cb1333',
Passport.abi,
'0x3337dac9f251d4e403d6030e18e3cfb6a2cb1333'
ethersProvider
)
console.info('PassportContract._address:', PassportContract._address)

loadPassportMintsByWeek()

Expand Down Expand Up @@ -77,13 +79,13 @@ async function loadPassportMintsByWeek() {

async function getNextId(): Promise<number> {
console.info('getNextId')
return await PassportContract.methods.getNextId().call()
return await passportContract.getNextId()
}

async function getTimestamp(id: number): Promise<number> {
console.info('getTimestamp, id:', id)
try {
return await PassportContract.methods.timestampOf(id).call()
return await passportContract.timestampOf(id)
} catch (err) {
console.error('err:', err)
return 0
Expand Down

0 comments on commit dec5f70

Please sign in to comment.