This commit is contained in:
Alexey 2021-04-01 21:13:12 +03:00
parent f7832f6ed3
commit 42b2318d2a

View File

@ -2,7 +2,7 @@ const { getTornadoTrees, getProvider } = require('./singletons')
const { action } = require('./utils') const { action } = require('./utils')
const ethers = require('ethers') const ethers = require('ethers')
const abi = new ethers.utils.AbiCoder() const abi = new ethers.utils.AbiCoder()
const fs = require('fs') // const fs = require('fs')
const { poseidonHash, toFixedHex } = require('./utils') const { poseidonHash, toFixedHex } = require('./utils')
async function getTornadoTreesEvents(type, fromBlock, toBlock) { async function getTornadoTreesEvents(type, fromBlock, toBlock) {
@ -63,16 +63,8 @@ async function getMigrationEvents(type) {
...e, ...e,
poseidon: toFixedHex(poseidonHash([e.instance, e.hash, e.block])), poseidon: toFixedHex(poseidonHash([e.instance, e.hash, e.block])),
})) }))
console.log('allEvents.slice(-1)', allEvents.slice(-1))
const trees = await getTornadoTrees()
const lastHash = allEvents.slice(-1)[0].hash
const eventType = type === action.DEPOSIT ? 'DepositData' : 'WithdrawalData'
const eventFilter = trees.filters[eventType](null, lastHash)
const event = await trees.queryFilter(eventFilter)
console.log('event', event[0].blockNumber)
// it can be useful to get all necessary events for claiming AP // it can be useful to get all necessary events for claiming AP
fs.writeFileSync(`./cache/${type}.json`, JSON.stringify(allEvents, null, 2)) // fs.writeFileSync(`./cache/${type}.json`, JSON.stringify(allEvents, null, 2))
return { return {
committedEvents: allEvents.slice(0, committedCount.toNumber()), committedEvents: allEvents.slice(0, committedCount.toNumber()),
pendingEvents: allEvents.slice(committedCount.toNumber()), pendingEvents: allEvents.slice(committedCount.toNumber()),