diff --git a/README.md b/README.md index 62a917a..d46e24b 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,7 @@ yarn update:zip ``` yarn update:events 56 +yarn update:encrypted 56 yarn update:zip ``` diff --git a/constants/variables.js b/constants/variables.js index 4568cff..8789410 100644 --- a/constants/variables.js +++ b/constants/variables.js @@ -50,10 +50,13 @@ export const addressType = { type: 'string', pattern: '^0x[a-fA-F0-9]{40}$' } // TODO auto update in yarn updateCache export const cachedEventsLength = { mainnet: { - ENCRYPTED_NOTES: 16890 + ENCRYPTED_NOTES: 16898 }, goerli: { - ENCRYPTED_NOTES: 1366 + ENCRYPTED_NOTES: 1662 + }, + bsc: { + ENCRYPTED_NOTES: 11333 } } diff --git a/plugins/idb.js b/plugins/idb.js index c7b894f..aa6a1a5 100644 --- a/plugins/idb.js +++ b/plugins/idb.js @@ -39,7 +39,7 @@ class IndexedDB { return } - this.db = await openDB(this.dbName, 32, this.options) // version (optional): Schema version, or undefined to open the current version. + this.db = await openDB(this.dbName, 33, this.options) // version (optional): Schema version, or undefined to open the current version. this.onEventHandler() this.dbExists = true diff --git a/scripts/helpers/download.js b/scripts/helpers/download.js index 6ff4f11..293cf69 100644 --- a/scripts/helpers/download.js +++ b/scripts/helpers/download.js @@ -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) diff --git a/scripts/updateEncryptedEvents.js b/scripts/updateEncryptedEvents.js index df6f6be..539942a 100644 --- a/scripts/updateEncryptedEvents.js +++ b/scripts/updateEncryptedEvents.js @@ -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, diff --git a/scripts/updateEvents.js b/scripts/updateEvents.js index a4b7aac..825f417 100644 --- a/scripts/updateEvents.js +++ b/scripts/updateEvents.js @@ -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 diff --git a/scripts/updateZip.js b/scripts/updateZip.js index 0cbfa90..dc62dae 100644 --- a/scripts/updateZip.js +++ b/scripts/updateZip.js @@ -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}`] diff --git a/static/events/deposits_bnb_0.1.json.zip b/static/events/deposits_bnb_0.1.json.zip index b492ff6..a2fcb74 100644 Binary files a/static/events/deposits_bnb_0.1.json.zip and b/static/events/deposits_bnb_0.1.json.zip differ diff --git a/static/events/deposits_bnb_1.json.zip b/static/events/deposits_bnb_1.json.zip index f5bd01b..2251732 100644 Binary files a/static/events/deposits_bnb_1.json.zip and b/static/events/deposits_bnb_1.json.zip differ diff --git a/static/events/deposits_bnb_10.json.zip b/static/events/deposits_bnb_10.json.zip index 9ec414b..7342680 100644 Binary files a/static/events/deposits_bnb_10.json.zip and b/static/events/deposits_bnb_10.json.zip differ diff --git a/static/events/deposits_bnb_100.json.zip b/static/events/deposits_bnb_100.json.zip index c854bec..0362a13 100644 Binary files a/static/events/deposits_bnb_100.json.zip and b/static/events/deposits_bnb_100.json.zip differ diff --git a/static/events/deposits_eth_0.1.json.zip b/static/events/deposits_eth_0.1.json.zip index 59a4eef..a536139 100644 Binary files a/static/events/deposits_eth_0.1.json.zip and b/static/events/deposits_eth_0.1.json.zip differ diff --git a/static/events/deposits_eth_1.json.zip b/static/events/deposits_eth_1.json.zip index bfaa8c6..533716a 100644 Binary files a/static/events/deposits_eth_1.json.zip and b/static/events/deposits_eth_1.json.zip differ diff --git a/static/events/deposits_eth_10.json.zip b/static/events/deposits_eth_10.json.zip index 81ddf4f..617faf2 100644 Binary files a/static/events/deposits_eth_10.json.zip and b/static/events/deposits_eth_10.json.zip differ diff --git a/static/events/deposits_eth_100.json.zip b/static/events/deposits_eth_100.json.zip index 341ab0e..109f0c7 100644 Binary files a/static/events/deposits_eth_100.json.zip and b/static/events/deposits_eth_100.json.zip differ diff --git a/static/events/withdrawals_bnb_0.1.json.zip b/static/events/withdrawals_bnb_0.1.json.zip index 524c131..ce96b69 100644 Binary files a/static/events/withdrawals_bnb_0.1.json.zip and b/static/events/withdrawals_bnb_0.1.json.zip differ diff --git a/static/events/withdrawals_bnb_1.json.zip b/static/events/withdrawals_bnb_1.json.zip index 9319123..e8784a8 100644 Binary files a/static/events/withdrawals_bnb_1.json.zip and b/static/events/withdrawals_bnb_1.json.zip differ diff --git a/static/events/withdrawals_bnb_10.json.zip b/static/events/withdrawals_bnb_10.json.zip index c8d7424..f6655c9 100644 Binary files a/static/events/withdrawals_bnb_10.json.zip and b/static/events/withdrawals_bnb_10.json.zip differ diff --git a/static/events/withdrawals_bnb_100.json.zip b/static/events/withdrawals_bnb_100.json.zip index ace946a..73320ce 100644 Binary files a/static/events/withdrawals_bnb_100.json.zip and b/static/events/withdrawals_bnb_100.json.zip differ diff --git a/static/events/withdrawals_eth_0.1.json.zip b/static/events/withdrawals_eth_0.1.json.zip index 2739b88..7eec8d3 100644 Binary files a/static/events/withdrawals_eth_0.1.json.zip and b/static/events/withdrawals_eth_0.1.json.zip differ diff --git a/static/events/withdrawals_eth_1.json.zip b/static/events/withdrawals_eth_1.json.zip index d95205f..219a834 100644 Binary files a/static/events/withdrawals_eth_1.json.zip and b/static/events/withdrawals_eth_1.json.zip differ diff --git a/static/events/withdrawals_eth_10.json.zip b/static/events/withdrawals_eth_10.json.zip index 418875a..e90f9ed 100644 Binary files a/static/events/withdrawals_eth_10.json.zip and b/static/events/withdrawals_eth_10.json.zip differ diff --git a/static/events/withdrawals_eth_100.json.zip b/static/events/withdrawals_eth_100.json.zip index 684652d..7ac0e31 100644 Binary files a/static/events/withdrawals_eth_100.json.zip and b/static/events/withdrawals_eth_100.json.zip differ diff --git a/static/trees/deposits_eth_0.1.json.zip b/static/trees/deposits_eth_0.1.json.zip deleted file mode 100644 index b0589e2..0000000 Binary files a/static/trees/deposits_eth_0.1.json.zip and /dev/null differ diff --git a/static/trees/deposits_eth_0.1_bloom.json.zip b/static/trees/deposits_eth_0.1_bloom.json.zip index 736ff71..2670de2 100644 Binary files a/static/trees/deposits_eth_0.1_bloom.json.zip and b/static/trees/deposits_eth_0.1_bloom.json.zip differ diff --git a/static/trees/deposits_eth_0.1_slice1.json.zip b/static/trees/deposits_eth_0.1_slice1.json.zip index 20b586a..fe8bf89 100644 Binary files a/static/trees/deposits_eth_0.1_slice1.json.zip and b/static/trees/deposits_eth_0.1_slice1.json.zip differ diff --git a/static/trees/deposits_eth_0.1_slice2.json.zip b/static/trees/deposits_eth_0.1_slice2.json.zip index 735d752..0e89bd5 100644 Binary files a/static/trees/deposits_eth_0.1_slice2.json.zip and b/static/trees/deposits_eth_0.1_slice2.json.zip differ diff --git a/static/trees/deposits_eth_0.1_slice3.json.zip b/static/trees/deposits_eth_0.1_slice3.json.zip index 47d7a05..52da726 100644 Binary files a/static/trees/deposits_eth_0.1_slice3.json.zip and b/static/trees/deposits_eth_0.1_slice3.json.zip differ diff --git a/static/trees/deposits_eth_0.1_slice4.json.zip b/static/trees/deposits_eth_0.1_slice4.json.zip index 52564f6..ef59911 100644 Binary files a/static/trees/deposits_eth_0.1_slice4.json.zip and b/static/trees/deposits_eth_0.1_slice4.json.zip differ diff --git a/static/trees/deposits_eth_1.json.zip b/static/trees/deposits_eth_1.json.zip deleted file mode 100644 index a517d42..0000000 Binary files a/static/trees/deposits_eth_1.json.zip and /dev/null differ diff --git a/static/trees/deposits_eth_10.json.zip b/static/trees/deposits_eth_10.json.zip deleted file mode 100644 index ee242b0..0000000 Binary files a/static/trees/deposits_eth_10.json.zip and /dev/null differ diff --git a/static/trees/deposits_eth_100.json.zip b/static/trees/deposits_eth_100.json.zip deleted file mode 100644 index 8bb13d1..0000000 Binary files a/static/trees/deposits_eth_100.json.zip and /dev/null differ diff --git a/static/trees/deposits_eth_100_bloom.json.zip b/static/trees/deposits_eth_100_bloom.json.zip index 9aa9d6e..e22eee6 100644 Binary files a/static/trees/deposits_eth_100_bloom.json.zip and b/static/trees/deposits_eth_100_bloom.json.zip differ diff --git a/static/trees/deposits_eth_100_slice1.json.zip b/static/trees/deposits_eth_100_slice1.json.zip index d4cd085..bbe420f 100644 Binary files a/static/trees/deposits_eth_100_slice1.json.zip and b/static/trees/deposits_eth_100_slice1.json.zip differ diff --git a/static/trees/deposits_eth_100_slice2.json.zip b/static/trees/deposits_eth_100_slice2.json.zip index 226f6c5..4223177 100644 Binary files a/static/trees/deposits_eth_100_slice2.json.zip and b/static/trees/deposits_eth_100_slice2.json.zip differ diff --git a/static/trees/deposits_eth_100_slice3.json.zip b/static/trees/deposits_eth_100_slice3.json.zip index a867adf..d07c190 100644 Binary files a/static/trees/deposits_eth_100_slice3.json.zip and b/static/trees/deposits_eth_100_slice3.json.zip differ diff --git a/static/trees/deposits_eth_100_slice4.json.zip b/static/trees/deposits_eth_100_slice4.json.zip index 134bd36..6d29fa2 100644 Binary files a/static/trees/deposits_eth_100_slice4.json.zip and b/static/trees/deposits_eth_100_slice4.json.zip differ diff --git a/static/trees/deposits_eth_10_bloom.json.zip b/static/trees/deposits_eth_10_bloom.json.zip index da9cc22..6661a23 100644 Binary files a/static/trees/deposits_eth_10_bloom.json.zip and b/static/trees/deposits_eth_10_bloom.json.zip differ diff --git a/static/trees/deposits_eth_10_slice1.json.zip b/static/trees/deposits_eth_10_slice1.json.zip index 79e30dd..4adebc3 100644 Binary files a/static/trees/deposits_eth_10_slice1.json.zip and b/static/trees/deposits_eth_10_slice1.json.zip differ diff --git a/static/trees/deposits_eth_10_slice2.json.zip b/static/trees/deposits_eth_10_slice2.json.zip index 753765a..47fb8af 100644 Binary files a/static/trees/deposits_eth_10_slice2.json.zip and b/static/trees/deposits_eth_10_slice2.json.zip differ diff --git a/static/trees/deposits_eth_10_slice3.json.zip b/static/trees/deposits_eth_10_slice3.json.zip index ede7f07..962a309 100644 Binary files a/static/trees/deposits_eth_10_slice3.json.zip and b/static/trees/deposits_eth_10_slice3.json.zip differ diff --git a/static/trees/deposits_eth_10_slice4.json.zip b/static/trees/deposits_eth_10_slice4.json.zip index cb58c1f..e78d7d3 100644 Binary files a/static/trees/deposits_eth_10_slice4.json.zip and b/static/trees/deposits_eth_10_slice4.json.zip differ diff --git a/static/trees/deposits_eth_1_bloom.json.zip b/static/trees/deposits_eth_1_bloom.json.zip index fa60a6a..e5193a4 100644 Binary files a/static/trees/deposits_eth_1_bloom.json.zip and b/static/trees/deposits_eth_1_bloom.json.zip differ diff --git a/static/trees/deposits_eth_1_slice1.json.zip b/static/trees/deposits_eth_1_slice1.json.zip index adc5bee..d773f69 100644 Binary files a/static/trees/deposits_eth_1_slice1.json.zip and b/static/trees/deposits_eth_1_slice1.json.zip differ diff --git a/static/trees/deposits_eth_1_slice2.json.zip b/static/trees/deposits_eth_1_slice2.json.zip index b3824e7..34cc0ec 100644 Binary files a/static/trees/deposits_eth_1_slice2.json.zip and b/static/trees/deposits_eth_1_slice2.json.zip differ diff --git a/static/trees/deposits_eth_1_slice3.json.zip b/static/trees/deposits_eth_1_slice3.json.zip index 506a24d..191e68f 100644 Binary files a/static/trees/deposits_eth_1_slice3.json.zip and b/static/trees/deposits_eth_1_slice3.json.zip differ diff --git a/static/trees/deposits_eth_1_slice4.json.zip b/static/trees/deposits_eth_1_slice4.json.zip index 25488a8..7b4d63e 100644 Binary files a/static/trees/deposits_eth_1_slice4.json.zip and b/static/trees/deposits_eth_1_slice4.json.zip differ diff --git a/store/application.js b/store/application.js index e822a5e..b031e59 100644 --- a/store/application.js +++ b/store/application.js @@ -451,16 +451,17 @@ const actions = { let cachedEvents = await dispatch('getEncryptedEventsFromDb', { netId }) - const networksWithCache = [1, 5, 56] + const networksWithCache = { + 1: cachedEventsLength.mainnet.ENCRYPTED_NOTES, + 5: cachedEventsLength.goerli.ENCRYPTED_NOTES, + 56: cachedEventsLength.bsc.ENCRYPTED_NOTES + } - const LENGTH_CACHE = - Number(netId) === 1 - ? cachedEventsLength.mainnet.ENCRYPTED_NOTES - : cachedEventsLength.goerli.ENCRYPTED_NOTES + const LENGTH_CACHE = networksWithCache[Number(netId)] if ( - ((isEmptyArray(cachedEvents) || !cachedEvents) && networksWithCache.includes(netId)) || - (cachedEvents.length < LENGTH_CACHE && networksWithCache.includes(netId)) + ((isEmptyArray(cachedEvents) || !cachedEvents) && networksWithCache[Number(netId)]) || + (cachedEvents.length < LENGTH_CACHE && networksWithCache[Number(netId)]) ) { ;({ events: cachedEvents } = await dispatch('loadEncryptedEvents', { netId })) }