update: events

This commit is contained in:
Pasha8914 2022-06-13 17:13:54 +10:00 committed by Danil Kovtonyuk
parent f0e38035e7
commit 72b87db11f
48 changed files with 25 additions and 29 deletions

View file

@ -1,6 +1,7 @@
import fs from 'fs'
import Jszip from 'jszip'
import Web3 from 'web3'
import networkConfig from '../../networkConfig'
const jszip = new Jszip()
@ -48,9 +49,15 @@ export async function loadCachedEvents({ name, directory, deployedBlock }) {
}
}
export async function getPastEvents({ type, fromBlock, netId, events, rpcUrl, contractAttrs }) {
export async function getPastEvents({ type, fromBlock, netId, events, contractAttrs }) {
let downloadedEvents = events
let [{ url: rpcUrl }] = Object.values(networkConfig[`netId${netId}`].rpcUrls)
if (netId === '5') {
rpcUrl = `https://goerli.infura.io/v3/${process.env.INFURA_KEY}`
}
const provider = new Web3.providers.HttpProvider(rpcUrl)
const web3 = new Web3(provider)
const contract = new web3.eth.Contract(...contractAttrs)

View file

@ -18,12 +18,6 @@ async function saveEncryptedNote(netId) {
'tornado-proxy-light.contract.tornadocash.eth': lightProxy
} = networkConfig[`netId${netId}`]
let [{ url: rpcUrl }] = Object.values(networkConfig[`netId${netId}`].rpcUrls)
if (netId === '5') {
rpcUrl = `https://goerli.infura.io/v3/${process.env.INFURA_KEY}`
}
const contractAddress = tornadoRouter || tornadoProxy || lightProxy
let encryptedEvents = []
@ -39,7 +33,6 @@ async function saveEncryptedNote(netId) {
encryptedEvents = await getPastEvents({
netId,
rpcUrl,
type: 'EncryptedNote',
events: encryptedEvents,
fromBlock: cachedEvents.lastBlock + 1,

View file

@ -9,7 +9,7 @@ import { loadCachedEvents, getPastEvents } from './helpers'
const EVENTS_PATH = './static/events/'
const EVENTS = ['Deposit', 'Withdrawal']
const enabledChains = ['1', '56']
const enabledChains = ['1', '56', '5']
async function main(type, netId) {
const { tokens, nativeCurrency, deployedBlock } = networkConfig[`netId${netId}`]
@ -25,18 +25,11 @@ async function main(type, netId) {
console.log('cachedEvents count - ', cachedEvents.events.length)
console.log('lastBlock - ', cachedEvents.lastBlock)
let [{ url: rpcUrl }] = Object.values(networkConfig[`netId${netId}`].rpcUrls)
if (netId === '5') {
rpcUrl = `https://goerli.infura.io/v3/${process.env.INFURA_KEY}`
}
let events = []
events = await getPastEvents({
type,
netId,
rpcUrl,
events,
contractAttrs: [ABI, _contract],
fromBlock: cachedEvents.lastBlock + 1

View file

@ -11,9 +11,7 @@ function updateEncrypted(netId) {
const file = `${EVENTS_PATH}encrypted_notes_${netId}.json`
save(file)
} catch {
console.warn('Not detected any events files for chainId - ', netId)
}
} catch {}
}
async function updateCommon(netId) {
const { nativeCurrency, tokens } = networkConfig[`netId${netId}`]