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

View File

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

View File

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

View File

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

View File

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

View File

@ -10,6 +10,8 @@ import networkConfig from '@/networkConfig'
import GovernanceABI from '@/abis/Governance.abi.json'
import AggregatorABI from '@/abis/Aggregator.abi.json'
import { httpConfig } from '@/constants'
const { numberToHex, toWei, fromWei, toBN, hexToNumber, hexToNumberString } = require('web3-utils')
const state = () => {
@ -47,7 +49,9 @@ const getters = {
},
getWeb3: (state, getters, rootState) => ({ netId }) => {
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 }) => {
const config = getters.getConfig({ netId })

View File

@ -18,7 +18,7 @@ function buildGroth16() {
function getEns() {
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
}