From 21a19e6db7d6adc23cbf89be5d399439ea272ce2 Mon Sep 17 00:00:00 2001 From: gozzy Date: Wed, 23 Nov 2022 11:28:56 +0000 Subject: [PATCH] improved relayer filtering --- store/relayer.js | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/store/relayer.js b/store/relayer.js index 0b7c725..dfaaa52 100644 --- a/store/relayer.js +++ b/store/relayer.js @@ -3,6 +3,7 @@ import Web3 from 'web3' import BN from 'bignumber.js' import namehash from 'eth-ens-namehash' +import { httpConfig } from '@/constants' import { schema, relayerRegisterService } from '@/services' import { createChainIdState, parseNote, parseSemanticVersion } from '@/utils' @@ -85,8 +86,9 @@ export const state = () => { export const getters = { ethProvider: (state, getters, rootState) => { 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) => { const netId = rootGetters['metamask/netId'] @@ -204,7 +206,13 @@ export const actions = { } 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')) }) @@ -322,8 +330,18 @@ export const actions = { }) } catch { 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) }, async getKnownRelayerData({ rootGetters, getters }, { relayerAddress, name }) {