Compare commits
2 Commits
master
...
legacy-awa
Author | SHA1 | Date | |
---|---|---|---|
|
2faf0d8e09 | ||
|
a65389e901 |
@ -3,7 +3,7 @@ import { loadCachedEvents } from './helpers'
|
|||||||
|
|
||||||
const EVENTS_PATH = './static/events/'
|
const EVENTS_PATH = './static/events/'
|
||||||
|
|
||||||
function main() {
|
async function main() {
|
||||||
for (const netId of enabledChains) {
|
for (const netId of enabledChains) {
|
||||||
const config = networkConfig[`netId${netId}`]
|
const config = networkConfig[`netId${netId}`]
|
||||||
const { constants, tokens, nativeCurrency, deployedBlock } = config
|
const { constants, tokens, nativeCurrency, deployedBlock } = config
|
||||||
@ -14,7 +14,7 @@ function main() {
|
|||||||
for (const [instance] of Object.entries(CONTRACTS)) {
|
for (const [instance] of Object.entries(CONTRACTS)) {
|
||||||
console.log(`\n instanceDenomation - ${instance}`)
|
console.log(`\n instanceDenomation - ${instance}`)
|
||||||
|
|
||||||
const withdrawalCachedEvents = loadCachedEvents({
|
const withdrawalCachedEvents = await loadCachedEvents({
|
||||||
name: `withdrawals_${netId}_${nativeCurrency}_${instance}.json`,
|
name: `withdrawals_${netId}_${nativeCurrency}_${instance}.json`,
|
||||||
directory: EVENTS_PATH,
|
directory: EVENTS_PATH,
|
||||||
deployedBlock
|
deployedBlock
|
||||||
@ -24,7 +24,7 @@ function main() {
|
|||||||
console.log('cachedEvents count - ', withdrawalCachedEvents.events.length)
|
console.log('cachedEvents count - ', withdrawalCachedEvents.events.length)
|
||||||
console.log('lastBlock - ', withdrawalCachedEvents.lastBlock)
|
console.log('lastBlock - ', withdrawalCachedEvents.lastBlock)
|
||||||
|
|
||||||
const depositCachedEvents = loadCachedEvents({
|
const depositCachedEvents = await loadCachedEvents({
|
||||||
name: `deposits_${netId}_${nativeCurrency}_${instance}.json`,
|
name: `deposits_${netId}_${nativeCurrency}_${instance}.json`,
|
||||||
directory: EVENTS_PATH,
|
directory: EVENTS_PATH,
|
||||||
deployedBlock
|
deployedBlock
|
||||||
@ -34,7 +34,7 @@ function main() {
|
|||||||
console.log('cachedEvents count - ', depositCachedEvents.events.length)
|
console.log('cachedEvents count - ', depositCachedEvents.events.length)
|
||||||
console.log('lastBlock - ', depositCachedEvents.lastBlock)
|
console.log('lastBlock - ', depositCachedEvents.lastBlock)
|
||||||
|
|
||||||
const notesCachedEvents = loadCachedEvents({
|
const notesCachedEvents = await loadCachedEvents({
|
||||||
name: `encrypted_notes_${netId}.json`,
|
name: `encrypted_notes_${netId}.json`,
|
||||||
directory: EVENTS_PATH,
|
directory: EVENTS_PATH,
|
||||||
deployedBlock: constants.ENCRYPTED_NOTES_BLOCK
|
deployedBlock: constants.ENCRYPTED_NOTES_BLOCK
|
||||||
|
@ -4,7 +4,7 @@ import Web3 from 'web3'
|
|||||||
|
|
||||||
import networkConfig from '../../networkConfig'
|
import networkConfig from '../../networkConfig'
|
||||||
|
|
||||||
export function download({ name, directory }) {
|
export async function download({ name, directory }) {
|
||||||
const path = `${directory}${name}.gz`.toLowerCase()
|
const path = `${directory}${name}.gz`.toLowerCase()
|
||||||
|
|
||||||
const data = fs.readFileSync(path, { flag: 'as+' })
|
const data = fs.readFileSync(path, { flag: 'as+' })
|
||||||
@ -13,9 +13,9 @@ export function download({ name, directory }) {
|
|||||||
return content
|
return content
|
||||||
}
|
}
|
||||||
|
|
||||||
export function loadCachedEvents({ name, directory, deployedBlock }) {
|
export async function loadCachedEvents({ name, directory, deployedBlock }) {
|
||||||
try {
|
try {
|
||||||
const module = download({ contentType: 'string', directory, name })
|
const module = await download({ contentType: 'string', directory, name })
|
||||||
|
|
||||||
if (module) {
|
if (module) {
|
||||||
const events = JSON.parse(module)
|
const events = JSON.parse(module)
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
import zlib from 'zlib'
|
import zlib from 'zlib'
|
||||||
|
|
||||||
export function save(filePath) {
|
export async function save(filePath) {
|
||||||
try {
|
try {
|
||||||
const data = fs.readFileSync(`${filePath}`)
|
const data = fs.readFileSync(`${filePath}`)
|
||||||
|
|
||||||
const payload = zlib.deflateSync(data, {
|
const payload = await zlib.deflateSync(data, {
|
||||||
level: zlib.constants.Z_BEST_COMPRESSION,
|
level: zlib.constants.Z_BEST_COMPRESSION,
|
||||||
strategy: zlib.constants.Z_FILTERED
|
strategy: zlib.constants.Z_FILTERED
|
||||||
})
|
})
|
||||||
|
@ -23,7 +23,7 @@ async function saveEncryptedNote(netId) {
|
|||||||
let encryptedEvents = []
|
let encryptedEvents = []
|
||||||
const name = `encrypted_notes_${netId}.json`
|
const name = `encrypted_notes_${netId}.json`
|
||||||
|
|
||||||
const cachedEvents = loadCachedEvents({
|
const cachedEvents = await loadCachedEvents({
|
||||||
name,
|
name,
|
||||||
directory: EVENTS_PATH,
|
directory: EVENTS_PATH,
|
||||||
deployedBlock: constants.ENCRYPTED_NOTES_BLOCK
|
deployedBlock: constants.ENCRYPTED_NOTES_BLOCK
|
||||||
|
@ -73,7 +73,7 @@ async function main(netId, chosenToken, chosenEvent) {
|
|||||||
const address = data[1]
|
const address = data[1]
|
||||||
|
|
||||||
// Now load cached events
|
// Now load cached events
|
||||||
const cachedEvents = loadCachedEvents({
|
const cachedEvents = await loadCachedEvents({
|
||||||
name: `${eventName.toLowerCase()}s_${netId}_${tokenSymbol}_${denom}.json`,
|
name: `${eventName.toLowerCase()}s_${netId}_${tokenSymbol}_${denom}.json`,
|
||||||
directory: EVENTS_PATH,
|
directory: EVENTS_PATH,
|
||||||
deployedBlock
|
deployedBlock
|
||||||
|
@ -78,7 +78,7 @@ async function createTree(netId) {
|
|||||||
|
|
||||||
console.log('createTree', { type, instance })
|
console.log('createTree', { type, instance })
|
||||||
|
|
||||||
const { events } = loadCachedEvents({
|
const { events } = await loadCachedEvents({
|
||||||
name: `${type}s_${netId}_${nativeCurrency}_${instance}.json`,
|
name: `${type}s_${netId}_${nativeCurrency}_${instance}.json`,
|
||||||
directory: EVENTS_PATH,
|
directory: EVENTS_PATH,
|
||||||
deployedBlock
|
deployedBlock
|
||||||
@ -152,7 +152,7 @@ async function main() {
|
|||||||
|
|
||||||
await createTree(chain)
|
await createTree(chain)
|
||||||
|
|
||||||
createTreeZip(chain)
|
await createTreeZip(chain)
|
||||||
}
|
}
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
@ -29,7 +29,7 @@ async function updateCommon(netId) {
|
|||||||
|
|
||||||
if (isSaved) {
|
if (isSaved) {
|
||||||
try {
|
try {
|
||||||
testCommon(netId, type, filename)
|
await testCommon(netId, type, filename)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err.message)
|
console.error(err.message)
|
||||||
}
|
}
|
||||||
@ -38,10 +38,10 @@ async function updateCommon(netId) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function testCommon(netId, type, filename) {
|
async function testCommon(netId, type, filename) {
|
||||||
const { deployedBlock } = networkConfig[`netId${netId}`]
|
const { deployedBlock } = networkConfig[`netId${netId}`]
|
||||||
|
|
||||||
const cachedEvents = loadCachedEvents({
|
const cachedEvents = await loadCachedEvents({
|
||||||
name: filename,
|
name: filename,
|
||||||
directory: EVENTS_PATH,
|
directory: EVENTS_PATH,
|
||||||
deployedBlock
|
deployedBlock
|
||||||
|
Loading…
x
Reference in New Issue
Block a user