improved relayer filtering

This commit is contained in:
gozzy 2022-11-23 11:28:56 +00:00
parent efcfac5774
commit 21a19e6db7

@ -3,6 +3,7 @@ import Web3 from 'web3'
import BN from 'bignumber.js' import BN from 'bignumber.js'
import namehash from 'eth-ens-namehash' import namehash from 'eth-ens-namehash'
import { httpConfig } from '@/constants'
import { schema, relayerRegisterService } from '@/services' import { schema, relayerRegisterService } from '@/services'
import { createChainIdState, parseNote, parseSemanticVersion } from '@/utils' import { createChainIdState, parseNote, parseSemanticVersion } from '@/utils'
@ -85,8 +86,9 @@ export const state = () => {
export const getters = { export const getters = {
ethProvider: (state, getters, rootState) => { ethProvider: (state, getters, rootState) => {
const { url } = rootState.settings.netId1.rpc const { url } = rootState.settings.netId1.rpc
const httpProvider = new Web3.providers.HttpProvider(url, httpConfig)
return new Web3(url) return new Web3(httpProvider)
}, },
jobs: (state, getters, rootState, rootGetters) => (type) => { jobs: (state, getters, rootState, rootGetters) => (type) => {
const netId = rootGetters['metamask/netId'] const netId = rootGetters['metamask/netId']
@ -204,7 +206,13 @@ export const actions = {
} }
const url = `${window.location.protocol}//${hostname}` const url = `${window.location.protocol}//${hostname}`
const response = await axios.get(`${url}status`, { timeout: 5000 }).catch(() => { const reqConfig = {
headers: {
'Content-Type': 'application/json, application/x-www-form-urlencoded'
},
timeout: 10000
}
const response = await axios.get(`${url}status`, reqConfig).catch(() => {
throw new Error(this.app.i18n.t('canNotFetchStatusFromTheRelayer')) throw new Error(this.app.i18n.t('canNotFetchStatusFromTheRelayer'))
}) })
@ -322,8 +330,18 @@ export const actions = {
}) })
} catch { } catch {
console.error('Method pickRandomRelayer has not picked relayer') console.error('Method pickRandomRelayer has not picked relayer')
dispatch(
'notice/addNotice',
{
notice: {
untranslatedTitle: 'Failed to fetch relayers',
type: 'warning'
},
interval: 1500
},
{ root: true }
)
} }
commit('SET_IS_LOADING_RELAYERS', false) commit('SET_IS_LOADING_RELAYERS', false)
}, },
async getKnownRelayerData({ rootGetters, getters }, { relayerAddress, name }) { async getKnownRelayerData({ rootGetters, getters }, { relayerAddress, name }) {