From 937c221e2223c243e136015cf3b675fa13cdfde7 Mon Sep 17 00:00:00 2001 From: AlienTornadosaurusHex <> Date: Thu, 18 May 2023 22:26:08 +0000 Subject: [PATCH] allow any token events to be updated Signed-off-by: AlienTornadosaurusHex <> --- networkConfig.js | 1 + scripts/updateEvents.js | 21 ++++++++++----------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/networkConfig.js b/networkConfig.js index 5646c83..1721e9a 100644 --- a/networkConfig.js +++ b/networkConfig.js @@ -31,6 +31,7 @@ export default { } }, multicall: '0xeefba1e63905ef1d7acba5a8513c70307c1ce441', + routerContract: '0xd90e2f925DA726b50C4Ed8D0Fb90Ad053324F31b', registryContract: '0x58E8dCC13BE9780fC42E8723D8EaD4CF46943dF2', echoContractAccount: '0x9B27DD5Bb15d42DC224FCD0B7caEbBe16161Df42', aggregatorContract: '0xE8F47A78A6D52D317D0D2FFFac56739fE14D1b49', diff --git a/scripts/updateEvents.js b/scripts/updateEvents.js index e4f8d28..4947c72 100644 --- a/scripts/updateEvents.js +++ b/scripts/updateEvents.js @@ -11,18 +11,20 @@ import { loadCachedEvents, getPastEvents } from './helpers' const EVENTS_PATH = './static/events/' const EVENTS = ['Deposit', 'Withdrawal'] -async function main(type, netId) { +async function main(type, netId, chosenToken) { const { tokens, nativeCurrency, deployedBlock } = networkConfig[`netId${netId}`] - const CONTRACTS = tokens[nativeCurrency].instanceAddress + const token = chosenToken !== undefined ? chosenToken : nativeCurrency + + const CONTRACTS = tokens[token].instanceAddress for (const [instance, _contract] of Object.entries(CONTRACTS)) { - const cachedEvents = await loadCachedEvents({ - name: `${type.toLowerCase()}s_${netId}_${nativeCurrency}_${instance}.json`, + const cachedEvents = loadCachedEvents({ + name: `${type.toLowerCase()}s_${netId}_${token}_${instance}.json`, directory: EVENTS_PATH, deployedBlock }) - console.log('Update events for', instance, nativeCurrency.toUpperCase(), `${type.toLowerCase()}s`) + console.log('Update events for', instance, token.toUpperCase(), `${type.toLowerCase()}s`) console.log('cachedEvents count - ', cachedEvents.events.length) console.log('lastBlock - ', cachedEvents.lastBlock) @@ -72,22 +74,19 @@ async function main(type, netId) { const eventsJson = JSON.stringify(freshEvents, null, 2) + '\n' - fs.writeFileSync( - `${EVENTS_PATH}${type.toLowerCase()}s_${netId}_${nativeCurrency}_${instance}.json`, - eventsJson - ) + fs.writeFileSync(`${EVENTS_PATH}${type.toLowerCase()}s_${netId}_${token}_${instance}.json`, eventsJson) } } async function start() { - const [, , , chain] = process.argv + const [, , , chain, chosenToken] = process.argv if (!enabledChains.includes(chain)) { throw new Error(`Supported chain ids ${enabledChains.join(', ')}`) } for (const event of EVENTS) { - await main(event, chain) + await main(event, chain, chosenToken) } }