stop event update reqs after gql failure

This commit is contained in:
gozzy 2022-11-24 08:43:32 +00:00
parent 2ec1ed18b1
commit 889f02fa8c
6 changed files with 16 additions and 13 deletions

@ -61,7 +61,6 @@ export const cachedEventsLength = {
} }
export const httpConfig = { export const httpConfig = {
withCredentials: false,
// buffer for tor connections // buffer for tor connections
timeout: 30000, timeout: 30000,
keepAlive: true keepAlive: true

@ -278,8 +278,8 @@ export default {
echoContractAccount: '0xa75BF2815618872f155b7C4B0C81bF990f5245E4', echoContractAccount: '0xa75BF2815618872f155b7C4B0C81bF990f5245E4',
rpcUrls: { rpcUrls: {
Arbitrum: { Arbitrum: {
name: 'Arbitrum Public RPC', name: '1RPC',
url: 'https://arb1.arbitrum.io/rpc' url: 'https://1rpc.io/arb'
} }
}, },
tokens: { tokens: {

@ -3,7 +3,7 @@
import Web3 from 'web3' import Web3 from 'web3'
import networkConfig from '@/networkConfig' import networkConfig from '@/networkConfig'
import { cachedEventsLength, eventsType } from '@/constants' import { cachedEventsLength, eventsType, httpConfig } from '@/constants'
import MulticallABI from '@/abis/Multicall.json' import MulticallABI from '@/abis/Multicall.json'
import InstanceABI from '@/abis/Instance.abi.json' import InstanceABI from '@/abis/Instance.abi.json'
@ -117,7 +117,8 @@ const getters = {
const config = networkConfig[`netId${netId}`] const config = networkConfig[`netId${netId}`]
const { url } = rootState.settings[`netId${netId}`].rpc const { url } = rootState.settings[`netId${netId}`].rpc
const address = config.tokens[currency].instanceAddress[amount] const address = config.tokens[currency].instanceAddress[amount]
const web3 = new Web3(url) const httpProvider = new Web3.providers.HttpProvider(url, httpConfig)
const web3 = new Web3(httpProvider)
return new web3.eth.Contract(InstanceABI, address) return new web3.eth.Contract(InstanceABI, address)
}, },
multicallContract: (state, getters, rootState) => ({ netId }) => { multicallContract: (state, getters, rootState) => ({ netId }) => {
@ -258,6 +259,7 @@ const getters = {
const actions = { const actions = {
setAndUpdateStatistic({ dispatch, commit }, { currency, amount }) { setAndUpdateStatistic({ dispatch, commit }, { currency, amount }) {
commit('SET_SELECTED_STATISTIC', { currency, amount }) commit('SET_SELECTED_STATISTIC', { currency, amount })
dispatch('updateSelectEvents') dispatch('updateSelectEvents')
}, },
async updateSelectEvents({ dispatch, commit, state, rootGetters, getters }) { async updateSelectEvents({ dispatch, commit, state, rootGetters, getters }) {
@ -265,15 +267,14 @@ const actions = {
const { currency, amount } = state.selectedStatistic const { currency, amount } = state.selectedStatistic
const eventService = getters.eventsInterface.getService({ netId, amount, currency }) const eventService = getters.eventsInterface.getService({ netId, amount, currency })
const graphEvents = await eventService.getEventsFromGraph({ methodName: 'getStatistic' }) const graphEvents = await eventService.getEventsFromGraph({ methodName: 'getStatistic' })
let statistic = graphEvents?.events let statistic = graphEvents?.events
if (!statistic || !statistic.length) { const latestDeposits = []
const fresh = await eventService.getStatisticsRpc({ eventsCount: 10 })
statistic = fresh || [] if (!statistic || !statistic.length) {
statistic = []
} }
const { nextDepositIndex, anonymitySet } = await dispatch('getLastDepositIndex', { const { nextDepositIndex, anonymitySet } = await dispatch('getLastDepositIndex', {
@ -284,8 +285,6 @@ const actions = {
statistic = statistic.sort((a, b) => a.leafIndex - b.leafIndex) statistic = statistic.sort((a, b) => a.leafIndex - b.leafIndex)
const latestDeposits = []
for (const event of statistic.slice(-10)) { for (const event of statistic.slice(-10)) {
latestDeposits.unshift({ latestDeposits.unshift({
index: event.leafIndex, index: event.leafIndex,

@ -32,6 +32,7 @@ export const getters = {
const address = config.ovmGasPriceOracleContract const address = config.ovmGasPriceOracleContract
if (address) { if (address) {
const web3 = new Web3(url) const web3 = new Web3(url)
return new web3.eth.Contract(OvmGasPriceOracleABI, address) return new web3.eth.Contract(OvmGasPriceOracleABI, address)
} }

@ -10,6 +10,8 @@ import networkConfig from '@/networkConfig'
import GovernanceABI from '@/abis/Governance.abi.json' import GovernanceABI from '@/abis/Governance.abi.json'
import AggregatorABI from '@/abis/Aggregator.abi.json' import AggregatorABI from '@/abis/Aggregator.abi.json'
import { httpConfig } from '@/constants'
const { numberToHex, toWei, fromWei, toBN, hexToNumber, hexToNumberString } = require('web3-utils') const { numberToHex, toWei, fromWei, toBN, hexToNumber, hexToNumberString } = require('web3-utils')
const state = () => { const state = () => {
@ -47,7 +49,9 @@ const getters = {
}, },
getWeb3: (state, getters, rootState) => ({ netId }) => { getWeb3: (state, getters, rootState) => ({ netId }) => {
const { url } = rootState.settings[`netId${netId}`].rpc const { url } = rootState.settings[`netId${netId}`].rpc
return new Web3(url) const httpProvider = new Web3.providers.HttpProvider(url, httpConfig)
return new Web3(httpProvider)
}, },
govContract: (state, getters, rootState) => ({ netId }) => { govContract: (state, getters, rootState) => ({ netId }) => {
const config = getters.getConfig({ netId }) const config = getters.getConfig({ netId })

@ -18,7 +18,7 @@ function buildGroth16() {
function getEns() { function getEns() {
const { url } = Object.values(networkConfig.netId1.rpcUrls)[0] const { url } = Object.values(networkConfig.netId1.rpcUrls)[0]
const provider = new Web3(new Web3.providers.HttpProvider(url)) const provider = new Web3(url)
return provider.eth.ens return provider.eth.ens
} }