mirror of
https://github.com/tornadocash/tornado-classic-ui
synced 2024-02-02 15:04:09 +01:00
fix: withdrawal idb store
This commit is contained in:
parent
dce468cace
commit
c7d1a5cb8e
@ -39,7 +39,7 @@ class IndexedDB {
|
||||
return
|
||||
}
|
||||
|
||||
this.db = await openDB(this.dbName, 33, this.options) // version (optional): Schema version, or undefined to open the current version.
|
||||
this.db = await openDB(this.dbName, 34, this.options) // version (optional): Schema version, or undefined to open the current version.
|
||||
this.onEventHandler()
|
||||
|
||||
this.dbExists = true
|
||||
@ -224,12 +224,10 @@ class IndexedDB {
|
||||
|
||||
export default async (ctx, inject) => {
|
||||
const DEPOSIT_INDEXES = [
|
||||
{ name: 'instance', unique: false },
|
||||
{ name: 'transactionHash', unique: false },
|
||||
{ name: 'commitment', unique: true }
|
||||
]
|
||||
const WITHDRAWAL_INDEXES = [
|
||||
{ name: 'instance', unique: false },
|
||||
{ name: 'nullifierHash', unique: true } // keys on which the index is created
|
||||
]
|
||||
const LAST_EVENT_INDEXES = [{ name: 'name', unique: false }]
|
||||
@ -240,11 +238,6 @@ export default async (ctx, inject) => {
|
||||
name: 'encrypted_events',
|
||||
keyPath: 'transactionHash'
|
||||
},
|
||||
{
|
||||
name: 'withdrawals',
|
||||
keyPath: 'transactionHash',
|
||||
indexes: WITHDRAWAL_INDEXES
|
||||
},
|
||||
{
|
||||
name: 'lastEvents',
|
||||
keyPath: 'name',
|
||||
@ -289,6 +282,12 @@ export default async (ctx, inject) => {
|
||||
indexes: DEPOSIT_INDEXES
|
||||
})
|
||||
|
||||
stores.push({
|
||||
name: `withdrawals_${token}_${amount}_${netId}`,
|
||||
keyPath: 'transactionHash',
|
||||
indexes: WITHDRAWAL_INDEXES
|
||||
})
|
||||
|
||||
stores.push({
|
||||
name: `stringify_tree_${token}_${amount}_${netId}`,
|
||||
keyPath: 'hashTree'
|
||||
|
@ -26,7 +26,7 @@ class EventService {
|
||||
|
||||
getStoreNames(type) {
|
||||
const instanceName = `${type}s_${this.currency}_${this.amount}`
|
||||
const storeName = type === eventsType.DEPOSIT ? `${instanceName}_${this.netId}` : `${type}s_${this.netId}`
|
||||
const storeName = `${instanceName}_${this.netId}`
|
||||
|
||||
return { instanceName, storeName }
|
||||
}
|
||||
@ -338,9 +338,6 @@ class EventService {
|
||||
|
||||
await this.idb.createMultipleTransactions({
|
||||
data: events,
|
||||
index: {
|
||||
instance: instanceName
|
||||
},
|
||||
storeName
|
||||
})
|
||||
|
||||
|
@ -147,9 +147,11 @@ async function getAllDeposits({ currency, amount, fromBlock, netId }) {
|
||||
const lastSyncBlock = await getMeta({ netId })
|
||||
|
||||
const data = deposits.map((e) => ({
|
||||
...e,
|
||||
timestamp: e.timestamp,
|
||||
commitment: e.commitment,
|
||||
leafIndex: Number(e.index),
|
||||
blockNumber: Number(e.blockNumber)
|
||||
blockNumber: Number(e.blockNumber),
|
||||
transactionHash: e.transactionHash
|
||||
}))
|
||||
|
||||
const [lastEvent] = data.slice(-1)
|
||||
@ -270,10 +272,12 @@ async function getAllWithdrawals({ currency, amount, fromBlock, netId }) {
|
||||
const lastSyncBlock = await getMeta({ netId })
|
||||
|
||||
const data = withdrawals.map((e) => ({
|
||||
...e,
|
||||
to: e.to,
|
||||
fee: e.fee,
|
||||
timestamp: e.timestamp,
|
||||
nullifierHash: e.nullifier,
|
||||
leafIndex: Number(e.index),
|
||||
blockNumber: Number(e.blockNumber)
|
||||
blockNumber: Number(e.blockNumber),
|
||||
transactionHash: e.transactionHash
|
||||
}))
|
||||
|
||||
const [lastEvent] = data.slice(-1)
|
||||
|
@ -16,10 +16,8 @@ export const GET_WITHDRAWALS = `
|
||||
amount: $amount,
|
||||
blockNumber_gte: $fromBlock
|
||||
}) {
|
||||
id
|
||||
to
|
||||
fee
|
||||
index
|
||||
nullifier
|
||||
timestamp
|
||||
blockNumber
|
||||
@ -48,7 +46,6 @@ export const GET_DEPOSITS = `
|
||||
currency: $currency,
|
||||
blockNumber_gte: $fromBlock
|
||||
}) {
|
||||
id
|
||||
index
|
||||
timestamp
|
||||
commitment
|
||||
|
Loading…
Reference in New Issue
Block a user