#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 12 additions and 12 deletions
Showing only changes of commit 62f079608e - Show all commits

@ -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 })
})

@ -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

@ -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

@ -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)

@ -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)
}

@ -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({

@ -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