static cache should be prefixed by network
Signed-off-by: AlienTornadosaurusHex <>
This commit is contained in:
parent
e49e3e0c0d
commit
ad0d1391dc
120 changed files with 81 additions and 43 deletions
|
@ -1,6 +1,7 @@
|
|||
import { uniqBy } from 'lodash'
|
||||
|
||||
import networkConfig from '../networkConfig'
|
||||
|
||||
import { loadCachedEvents, save } from './helpers'
|
||||
|
||||
const EVENTS_PATH = './static/events/'
|
||||
|
@ -9,19 +10,23 @@ const EVENTS = ['Deposit', 'Withdrawal']
|
|||
function updateEncrypted(netId) {
|
||||
try {
|
||||
const file = `${EVENTS_PATH}encrypted_notes_${netId}.json`
|
||||
|
||||
save(file)
|
||||
} catch {}
|
||||
}
|
||||
|
||||
async function updateCommon(netId) {
|
||||
const { nativeCurrency, tokens } = networkConfig[`netId${netId}`]
|
||||
|
||||
console.log(Object.keys(tokens[nativeCurrency].instanceAddress))
|
||||
|
||||
for await (const type of EVENTS) {
|
||||
for await (const instance of Object.keys(tokens[nativeCurrency].instanceAddress)) {
|
||||
console.warn('instance', instance)
|
||||
const filename = `${type.toLowerCase()}s_${nativeCurrency}_${instance}.json`
|
||||
|
||||
const filename = `${type.toLowerCase()}s_${netId}_${nativeCurrency}_${instance}.json`
|
||||
|
||||
const isSaved = save(`${EVENTS_PATH}${filename}`)
|
||||
|
||||
if (isSaved) {
|
||||
try {
|
||||
await testCommon(netId, type, filename)
|
||||
|
@ -45,11 +50,13 @@ async function testCommon(netId, type, filename) {
|
|||
console.log('cachedEvents', cachedEvents.events.length, type)
|
||||
|
||||
let events = cachedEvents.events
|
||||
|
||||
if (type === 'Withdrawal') {
|
||||
events = uniqBy(cachedEvents.events, 'nullifierHash')
|
||||
} else if (type === 'Deposit') {
|
||||
events = cachedEvents.events.filter((e, index) => Number(e.leafIndex) === index)
|
||||
}
|
||||
|
||||
if (events.length !== cachedEvents.events.length) {
|
||||
console.error('events.length', events.length)
|
||||
console.error('cachedEvents.events.length', cachedEvents.events.length)
|
||||
|
@ -58,10 +65,14 @@ async function testCommon(netId, type, filename) {
|
|||
}
|
||||
|
||||
async function main() {
|
||||
const NETWORKS = [1, 5, 56, 100, 137 ]
|
||||
const enabledChains = networkConfig.enabledChains
|
||||
const chainsWithEncryptedNotes = networkConfig.chainsWithEncryptedNotes
|
||||
|
||||
for (let i = 0; i < enabledChains.length; i++) {
|
||||
const netId = enabledChains[i]
|
||||
|
||||
if (netId === chainsWithEncryptedNotes[i]) updateEncrypted(netId)
|
||||
|
||||
for await (const netId of NETWORKS) {
|
||||
updateEncrypted(netId)
|
||||
await updateCommon(netId)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue