From d820292491cc56363da73e22b1f3f491924bd970 Mon Sep 17 00:00:00 2001 From: Chen Wei Date: Mon, 9 Sep 2019 21:45:05 +0800 Subject: use rpcUrl from network config when estimating gas --- ui/app/components/app/dropdowns/network-dropdown.js | 1 - ui/app/ducks/gas/gas.duck.js | 15 +++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ui/app/components/app/dropdowns/network-dropdown.js b/ui/app/components/app/dropdowns/network-dropdown.js index 8563f0771..1d3ff521f 100644 --- a/ui/app/components/app/dropdowns/network-dropdown.js +++ b/ui/app/components/app/dropdowns/network-dropdown.js @@ -307,7 +307,6 @@ NetworkDropdown.prototype.getNetworkName = function () { let name if (providerName === 'tangerine_testnet') { - console.log('tangerine netowkr get name!!') name = this.context.t('tangerine_testnet') } else if (providerName === 'mainnet') { name = this.context.t('mainnet') diff --git a/ui/app/ducks/gas/gas.duck.js b/ui/app/ducks/gas/gas.duck.js index bcb9a8450..5dc5d6b87 100644 --- a/ui/app/ducks/gas/gas.duck.js +++ b/ui/app/ducks/gas/gas.duck.js @@ -11,6 +11,9 @@ import { import { isEthereumNetwork, } from '../../selectors/selectors' +import { + defaultNetworksData +} from '../../pages/settings/networks-tab/networks-tab.constants'; // Actions const BASIC_GAS_ESTIMATE_LOADING_FINISHED = 'metamask/gas/BASIC_GAS_ESTIMATE_LOADING_FINISHED' @@ -186,8 +189,12 @@ export function fetchBasicGasEstimates () { const timeLastRetrieved = basicPriceEstimatesLastRetrieved || loadLocalStorageData('BASIC_PRICE_ESTIMATES_LAST_RETRIEVED') || 0 dispatch(basicGasEstimatesLoadingStarted()) + + const { provider } = getState().metamask; + const { rpcUrl } = defaultNetworksData.find(it => it.providerType === provider.type) || {}; + const promiseToFetch = Date.now() - timeLastRetrieved > 75000 - ? fetch('https://testnet-rpc.tangerine-network.io', { + ? fetch(rpcUrl, { 'headers': { 'Content-Type': 'application/json', }, @@ -236,10 +243,14 @@ export function fetchBasicGasAndTimeEstimates () { } = getState().gas const timeLastRetrieved = basicPriceAndTimeEstimatesLastRetrieved || loadLocalStorageData('BASIC_GAS_AND_TIME_API_ESTIMATES_LAST_RETRIEVED') || 0 + + const { provider } = getState().metamask; + const { rpcUrl } = defaultNetworksData.find(it => it.providerType === provider.type) || {}; + dispatch(basicGasEstimatesLoadingStarted()) const promiseToFetch = Date.now() - timeLastRetrieved > 75000 - ? fetch('https://testnet-rpc.tangerine-network.io', { + ? fetch(rpcUrl, { 'headers': { 'Content-Type': 'application/json', }, -- cgit