forked from tornadocash/classic-ui
Remove chainnodes rpc and fixed progress bar #1
@ -3,14 +3,15 @@
|
|||||||
<div class="loading-container">
|
<div class="loading-container">
|
||||||
<div class="loading-tornado" data-test="tornado_loader"></div>
|
<div class="loading-tornado" data-test="tornado_loader"></div>
|
||||||
<div class="loading-message">{{ message }}...</div>
|
<div class="loading-message">{{ message }}...</div>
|
||||||
<div v-if="progress >= 0" class="loading-message">{{ progress }}%</div>
|
|
||||||
<approve-loader v-if="isApprove" />
|
<approve-loader v-if="isApprove" />
|
||||||
</div>
|
</div>
|
||||||
</b-loading>
|
</b-loading>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { mapState, mapGetters } from 'vuex'
|
import { mapState, mapGetters } from 'vuex'
|
||||||
|
|
||||||
import ApproveLoader from './ApproveLoader'
|
import ApproveLoader from './ApproveLoader'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
ApproveLoader
|
ApproveLoader
|
||||||
@ -18,7 +19,7 @@ export default {
|
|||||||
computed: {
|
computed: {
|
||||||
...mapGetters('metamask', ['isWalletConnect']),
|
...mapGetters('metamask', ['isWalletConnect']),
|
||||||
...mapState('metamask', ['providerName']),
|
...mapState('metamask', ['providerName']),
|
||||||
...mapState('loading', ['enabled', 'message', 'progress', 'type']),
|
...mapState('loading', ['enabled', 'message', 'type']),
|
||||||
isApprove() {
|
isApprove() {
|
||||||
return this.type === 'approve'
|
return this.type === 'approve'
|
||||||
}
|
}
|
||||||
|
@ -338,7 +338,6 @@ export default {
|
|||||||
}
|
}
|
||||||
this.$store.dispatch('application/setAndUpdateStatistic', { currency, amount: Number(amount) })
|
this.$store.dispatch('application/setAndUpdateStatistic', { currency, amount: Number(amount) })
|
||||||
this.$store.dispatch('fees/calculateWithdrawalFeeViaRelayer', {})
|
this.$store.dispatch('fees/calculateWithdrawalFeeViaRelayer', {})
|
||||||
this.$store.dispatch('loading/updateProgress', { progress: -1 })
|
|
||||||
this.depositsPast = Number(depositsPast) <= 0 ? 0 : depositsPast
|
this.depositsPast = Number(depositsPast) <= 0 ? 0 : depositsPast
|
||||||
this.depositTxHash = txHash
|
this.depositTxHash = txHash
|
||||||
this.depositTimestamp = timestamp
|
this.depositTimestamp = timestamp
|
||||||
|
@ -7,13 +7,6 @@ import InstanceABI from '@/abis/Instance.abi.json'
|
|||||||
import { CONTRACT_INSTANCES, eventsType, httpConfig } from '@/constants'
|
import { CONTRACT_INSTANCES, eventsType, httpConfig } from '@/constants'
|
||||||
import { sleep, flattenNArray, formatEvents, capitalizeFirstLetter } from '@/utils'
|
import { sleep, flattenNArray, formatEvents, capitalizeFirstLetter } from '@/utils'
|
||||||
|
|
||||||
let store
|
|
||||||
if (process.browser) {
|
|
||||||
window.onNuxtReady(({ $store }) => {
|
|
||||||
store = $store
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
class EventService {
|
class EventService {
|
||||||
constructor({ netId, amount, currency, factoryMethods }) {
|
constructor({ netId, amount, currency, factoryMethods }) {
|
||||||
this.idb = window.$nuxt.$indexedDB(netId)
|
this.idb = window.$nuxt.$indexedDB(netId)
|
||||||
@ -36,15 +29,6 @@ class EventService {
|
|||||||
return `${type}s_${this.netId}_${this.currency}_${this.amount}`
|
return `${type}s_${this.netId}_${this.currency}_${this.amount}`
|
||||||
}
|
}
|
||||||
|
|
||||||
updateEventProgress(percentage, type) {
|
|
||||||
if (store) {
|
|
||||||
store.dispatch('loading/updateProgress', {
|
|
||||||
message: `Fetching past ${type} events`,
|
|
||||||
progress: Math.ceil(percentage * 100)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async getEvents(type) {
|
async getEvents(type) {
|
||||||
let cachedEvents = await this.getEventsFromDB(type)
|
let cachedEvents = await this.getEventsFromDB(type)
|
||||||
|
|
||||||
@ -345,8 +329,6 @@ class EventService {
|
|||||||
const batchCount = Math.ceil(batchDigest / batchSize)
|
const batchCount = Math.ceil(batchDigest / batchSize)
|
||||||
|
|
||||||
if (fromBlock < currentBlockNumber) {
|
if (fromBlock < currentBlockNumber) {
|
||||||
this.updateEventProgress(0, type)
|
|
||||||
|
|
||||||
for (let batchIndex = 0; batchIndex < batchCount; batchIndex++) {
|
for (let batchIndex = 0; batchIndex < batchCount; batchIndex++) {
|
||||||
const isLastBatch = batchIndex === batchCount - 1
|
const isLastBatch = batchIndex === batchCount - 1
|
||||||
const params = new Array(batchSize).fill('').map((_, i) => {
|
const params = new Array(batchSize).fill('').map((_, i) => {
|
||||||
@ -361,8 +343,6 @@ class EventService {
|
|||||||
failed = failed.concat(requests.filter((e) => e.isFailedBatch))
|
failed = failed.concat(requests.filter((e) => e.isFailedBatch))
|
||||||
lastBlock = params[batchSize - 1].toBlock
|
lastBlock = params[batchSize - 1].toBlock
|
||||||
|
|
||||||
const progressIndex = batchIndex - failed.length / batchSize
|
|
||||||
|
|
||||||
if (isLastBatch && failed.length !== 0) {
|
if (isLastBatch && failed.length !== 0) {
|
||||||
const failedBatch = await Promise.all(this.createBatchRequest(failed))
|
const failedBatch = await Promise.all(this.createBatchRequest(failed))
|
||||||
const failedReqs = flattenNArray(failedBatch)
|
const failedReqs = flattenNArray(failedBatch)
|
||||||
@ -374,7 +354,6 @@ class EventService {
|
|||||||
throw new Error('Failed to batch events')
|
throw new Error('Failed to batch events')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.updateEventProgress(progressIndex / batchCount, type)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
export const state = () => {
|
export const state = () => {
|
||||||
return {
|
return {
|
||||||
message: '',
|
message: '',
|
||||||
progress: -1,
|
|
||||||
enabled: false,
|
enabled: false,
|
||||||
type: null
|
type: null
|
||||||
}
|
}
|
||||||
@ -10,16 +9,14 @@ export const state = () => {
|
|||||||
export const getters = {}
|
export const getters = {}
|
||||||
|
|
||||||
export const mutations = {
|
export const mutations = {
|
||||||
ENABLE(state, { message, progress, type }) {
|
ENABLE(state, { message, type }) {
|
||||||
state.message = message
|
state.message = message
|
||||||
state.enabled = true
|
state.enabled = true
|
||||||
state.progress = progress
|
|
||||||
state.type = type
|
state.type = type
|
||||||
},
|
},
|
||||||
DISABLE(state) {
|
DISABLE(state) {
|
||||||
state.message = ''
|
state.message = ''
|
||||||
state.enabled = false
|
state.enabled = false
|
||||||
state.progress = -1
|
|
||||||
state.type = null
|
state.type = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -31,9 +28,6 @@ export const actions = {
|
|||||||
changeText({ commit }, { message, type }) {
|
changeText({ commit }, { message, type }) {
|
||||||
commit('ENABLE', { message, type })
|
commit('ENABLE', { message, type })
|
||||||
},
|
},
|
||||||
updateProgress({ commit }, { message, progress }) {
|
|
||||||
commit('ENABLE', { message, progress })
|
|
||||||
},
|
|
||||||
disable({ commit }) {
|
disable({ commit }) {
|
||||||
commit('DISABLE')
|
commit('DISABLE')
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user