#PR1: classic-ui: Prefix static caches with network id and code quality #25

Merged
Theo merged 9 commits from :master into master 2023-06-27 14:53:50 +03:00
7 changed files with 13 additions and 24 deletions
Showing only changes of commit 2fbd860f51 - Show all commits

View File

@ -1,6 +1,6 @@
export const enabledChains = ['1', '10', '56', '100', '137', '42161']
export const chainsWithEncryptedNotes = ['1', '5', '56', '100', '137']
export default {
enabledChains: ['1', '10', '56', '100', '137', '42161'],
chainsWithEncryptedNotes: ['1', '5', '56', '100', '137'],
netId1: {
rpcCallRetryAttempt: 15,
gasPrices: {

View File

@ -1,11 +1,9 @@
import networkConfig from '../networkConfig'
import networkConfig, { enabledChains } from '../networkConfig'
import { loadCachedEvents } from './helpers'
const EVENTS_PATH = './static/events/'
function main() {
const enabledChains = networkConfig.enabledChains
for (const netId of enabledChains) {
const config = networkConfig[`netId${netId}`]
const { constants, tokens, nativeCurrency, deployedBlock } = config
@ -13,7 +11,7 @@ function main() {
console.log(`\n ::: ${netId} [${nativeCurrency.toUpperCase()}] :::`)
for (const [instance, ] of Object.entries(CONTRACTS)) {
for (const [instance] of Object.entries(CONTRACTS)) {
console.log(`\n instanceDenomation - ${instance}`)
const withdrawalCachedEvents = loadCachedEvents({

View File

@ -3,7 +3,7 @@ import 'dotenv/config'
import fs from 'fs'
import { uniqBy } from 'lodash'
import networkConfig from '../networkConfig'
import networkConfig, { enabledChains } from '../networkConfig'
import ABI from '../abis/TornadoProxy.abi.json'
import { getPastEvents, loadCachedEvents } from './helpers'
@ -64,8 +64,6 @@ async function saveEncryptedNote(netId) {
async function main() {
const [, , , chain] = process.argv
const enabledChains = networkConfig.enabledChains
if (!enabledChains.includes(chain)) {
throw new Error(`Supported chain ids ${enabledChains.join(', ')}`)
}

View File

@ -3,7 +3,7 @@ import 'dotenv/config'
import fs from 'fs'
import { uniqBy } from 'lodash'
import networkConfig from '../networkConfig'
import networkConfig, { enabledChains } from '../networkConfig'
import ABI from '../abis/Instance.abi.json'
import { loadCachedEvents, getPastEvents } from './helpers'
@ -82,8 +82,6 @@ async function main(type, netId) {
async function start() {
const [, , , chain] = process.argv
const enabledChains = networkConfig.enabledChains
if (!enabledChains.includes(chain)) {
throw new Error(`Supported chain ids ${enabledChains.join(', ')}`)
}

View File

@ -6,7 +6,7 @@ import BloomFilter from 'bloomfilter.js'
import { MerkleTree } from 'fixed-merkle-tree'
import { buildMimcSponge } from 'circomlibjs'
import networkConfig from '../networkConfig'
import networkConfig, { enabledChains } from '../networkConfig'
import { loadCachedEvents, save } from './helpers'
@ -144,8 +144,6 @@ async function initMimc() {
async function main() {
const [, , , chain] = process.argv
const enabledChains = networkConfig.enabledChains
if (!enabledChains.includes(chain)) {
throw new Error(`Supported chain ids ${enabledChains.join(', ')}`)
}

View File

@ -1,6 +1,6 @@
import { uniqBy } from 'lodash'
import networkConfig from '../networkConfig'
import networkConfig, { enabledChains, chainsWithEncryptedNotes } from '../networkConfig'
import { loadCachedEvents, save } from './helpers'
@ -29,7 +29,7 @@ async function updateCommon(netId) {
if (isSaved) {
try {
await testCommon(netId, type, filename)
testCommon(netId, type, filename)
} catch (err) {
console.error(err.message)
}
@ -38,10 +38,10 @@ async function updateCommon(netId) {
}
}
async function testCommon(netId, type, filename) {
function testCommon(netId, type, filename) {
const { deployedBlock } = networkConfig[`netId${netId}`]
const cachedEvents = await loadCachedEvents({
const cachedEvents = loadCachedEvents({
name: filename,
directory: EVENTS_PATH,
deployedBlock
@ -65,9 +65,6 @@ async function testCommon(netId, type, filename) {
}
async function main() {
const enabledChains = networkConfig.enabledChains
const chainsWithEncryptedNotes = networkConfig.chainsWithEncryptedNotes
for (let i = 0; i < enabledChains.length; i++) {
const netId = enabledChains[i]

View File

@ -2,7 +2,7 @@ import Web3 from 'web3'
import graph from '@/services/graph'
import { download } from '@/store/snark'
import networkConfig from '@/networkConfig'
import networkConfig, { enabledChains } from '@/networkConfig'
import InstanceABI from '@/abis/Instance.abi.json'
import { CONTRACT_INSTANCES, eventsType, httpConfig } from '@/constants'
import { sleep, flattenNArray, formatEvents, capitalizeFirstLetter } from '@/utils'
@ -19,7 +19,7 @@ class EventService {
this.idb = window.$nuxt.$indexedDB(netId)
const { nativeCurrency } = networkConfig[`netId${netId}`]
const hasCache = networkConfig.enabledChains.includes(netId.toString())
const hasCache = enabledChains.includes(netId.toString())
this.netId = netId
this.amount = amount