From 62f079608e466585ab3337e5339d6f99d4ad63d2 Mon Sep 17 00:00:00 2001 From: AlienTornadosaurusHex <> Date: Fri, 23 Jun 2023 17:00:40 +0000 Subject: [PATCH] hopefully fix rest of issues with netId addition Signed-off-by: AlienTornadosaurusHex <> --- .../account/store/actions/decryptNotes/encryptFormatTx.js | 4 ++-- scripts/updateEncryptedEvents.js | 2 +- scripts/updateTree.js | 2 +- services/events.js | 2 +- services/merkleTree.js | 2 +- store/application.js | 4 ++-- store/txHashKeeper.js | 8 ++++---- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/modules/account/store/actions/decryptNotes/encryptFormatTx.js b/modules/account/store/actions/decryptNotes/encryptFormatTx.js index 9050e05..4fb2a4e 100644 --- a/modules/account/store/actions/decryptNotes/encryptFormatTx.js +++ b/modules/account/store/actions/decryptNotes/encryptFormatTx.js @@ -25,7 +25,7 @@ export async function _encryptFormatTx({ dispatch, getters, rootGetters }, { eve if (!instance) { return acc } - const name = `${instance.amount}${instance.currency}` + const name = `${netId}${instance.amount}${instance.currency}` if (!acc[name]) { const service = eventsInterface.getService({ netId, ...instance }) acc[name] = { ...instance, service } @@ -49,7 +49,7 @@ export async function _encryptFormatTx({ dispatch, getters, rootGetters }, { eve if (!instance) { return } - const { service } = instances[`${instance.amount}${instance.currency}`] + const { service } = instances[`${netId}${instance.amount}${instance.currency}`] return getDeposit({ event, netId, service, instance }) }) diff --git a/scripts/updateEncryptedEvents.js b/scripts/updateEncryptedEvents.js index b880197..e3a338d 100644 --- a/scripts/updateEncryptedEvents.js +++ b/scripts/updateEncryptedEvents.js @@ -23,7 +23,7 @@ async function saveEncryptedNote(netId) { let encryptedEvents = [] const name = `encrypted_notes_${netId}.json` - const cachedEvents = await loadCachedEvents({ + const cachedEvents = loadCachedEvents({ name, directory: EVENTS_PATH, deployedBlock: constants.ENCRYPTED_NOTES_BLOCK diff --git a/scripts/updateTree.js b/scripts/updateTree.js index 4388b57..bb21b16 100644 --- a/scripts/updateTree.js +++ b/scripts/updateTree.js @@ -78,7 +78,7 @@ async function createTree(netId) { console.log('createTree', { type, instance }) - const { events } = await loadCachedEvents({ + const { events } = loadCachedEvents({ name: `${type}s_${netId}_${nativeCurrency}_${instance}.json`, directory: EVENTS_PATH, deployedBlock diff --git a/services/events.js b/services/events.js index c4eb014..68b9fe8 100644 --- a/services/events.js +++ b/services/events.js @@ -464,7 +464,7 @@ class EventsFactory { } getService = (payload) => { - const instanceName = `${payload.currency}_${payload.amount}` + const instanceName = `${payload.netId}_${payload.currency}_${payload.amount}` if (this.instances.has(instanceName)) { return this.instances.get(instanceName) diff --git a/services/merkleTree.js b/services/merkleTree.js index 0517335..42fd482 100644 --- a/services/merkleTree.js +++ b/services/merkleTree.js @@ -186,7 +186,7 @@ class TreesFactory { instances = new Map() getService = (payload) => { - const instanceName = `${payload.currency}_${payload.amount}` + const instanceName = `${payload.netId}_${payload.currency}_${payload.amount}` if (this.instances.has(instanceName)) { return this.instances.get(instanceName) } diff --git a/store/application.js b/store/application.js index 8efea1b..001331e 100644 --- a/store/application.js +++ b/store/application.js @@ -324,7 +324,7 @@ const actions = { lastBlock = await this.$indexedDB(netId).getFromIndex({ indexName: 'name', storeName: 'lastEvents', - key: `${type}s_${currency}_${amount}` + key: `${type}s_${netId}_${currency}_${amount}` }) } @@ -661,7 +661,7 @@ const actions = { } }, async buildTree({ dispatch }, { currency, amount, netId, commitmentHex }) { - const treeInstanceName = `${currency}_${amount}` + const treeInstanceName = `${netId}_${currency}_${amount}` const params = { netId, amount, currency } const treeService = treesInterface.getService({ diff --git a/store/txHashKeeper.js b/store/txHashKeeper.js index 78fd62e..dcecddc 100644 --- a/store/txHashKeeper.js +++ b/store/txHashKeeper.js @@ -129,7 +129,7 @@ export const actions = { const instances = txs.reduce((acc, curr) => { const [, currency, amount, netId] = curr.prefix.split('-') - const name = `${amount}${currency}` + const name = `${netId}${amount}${currency}` if (!acc[name]) { const service = eventsInterface.getService({ netId, amount, currency }) acc[name] = { currency, amount, netId, service } @@ -161,7 +161,7 @@ export const actions = { txHash: tx.txHash, type: eventsType.DEPOSIT, commitment: tx.commitmentHex, - service: instances[`${amount}${currency}`] + service: instances[`${netId}${amount}${currency}`] }) } }, @@ -213,7 +213,7 @@ export const actions = { if (!tx.isSpent) { const { currency, amount, netId, nullifierHex } = parseNote(`${tx.prefix}-${tx.note}`) - const isSpent = await instances[`${amount}${currency}`].service.findEvent({ + const isSpent = await instances[`${netId}${amount}${currency}`].service.findEvent({ eventName: 'nullifierHash', eventToFind: nullifierHex, type: eventsType.WITHDRAWAL @@ -364,7 +364,7 @@ export const actions = { if (tx && !tx.isSpent) { const { currency, amount, netId, nullifierHex } = parseNote(`${tx.prefix}-${tx.note}`) - const isSpent = await instances[`${amount}${currency}`].service.findEvent({ + const isSpent = await instances[`${netId}${amount}${currency}`].service.findEvent({ eventName: 'nullifierHash', eventToFind: nullifierHex, type: eventsType.WITHDRAWAL