Skip to content
This repository has been archived by the owner on Jun 24, 2022. It is now read-only.

Commit

Permalink
remove test fn and use fixed call
Browse files Browse the repository at this point in the history
  • Loading branch information
W3stside committed Dec 20, 2021
1 parent 3605617 commit 5bed219
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 19 deletions.
17 changes: 7 additions & 10 deletions src/custom/api/gnosisProtocol/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,18 @@ function getProfileUrl(): Partial<Record<ChainId, string>> {
process.env.REACT_APP_PROFILE_API_URL_STAGING_MAINNET || 'https://protocol-affiliate.gnosis.io/api',
}
}

const STRATEGY_URL_BASE = 'https://raw.githubusercontent.com/gnosis/cowswap/configuration/config/strategies'
function getPriceStrategyUrl(): Record<SupportedChainId, string> {
return {
[SupportedChainId.MAINNET]: 'https://raw.githubusercontent.com/gnosis/cowswap/configuration/price/strategy-1.json',
[SupportedChainId.RINKEBY]: 'https://raw.githubusercontent.com/gnosis/cowswap/configuration/price/strategy-4.json',
[SupportedChainId.XDAI]: 'https://raw.githubusercontent.com/gnosis/cowswap/configuration/price/strategy-100.json',
[SupportedChainId.MAINNET]: STRATEGY_URL_BASE + '/strategy-1.json',
[SupportedChainId.RINKEBY]: STRATEGY_URL_BASE + '/strategy-4.json',
[SupportedChainId.XDAI]: STRATEGY_URL_BASE + '/strategy-100.json',
}
}

const API_BASE_URL = getGnosisProtocolUrl()
const PROFILE_API_BASE_URL = getProfileUrl()
const STRATEGY_API_BASE_URL = getPriceStrategyUrl()
const STRATEGY_API_URL = getPriceStrategyUrl()

const DEFAULT_HEADERS = {
'Content-Type': 'application/json',
Expand Down Expand Up @@ -156,7 +156,7 @@ function _getProfileApiBaseUrl(chainId: ChainId): string {
}

function _getPriceStrategyApiBaseUrl(chainId: ChainId): string {
const baseUrl = STRATEGY_API_BASE_URL[chainId]
const baseUrl = STRATEGY_API_URL[chainId]

if (!baseUrl) {
new Error(
Expand Down Expand Up @@ -200,10 +200,7 @@ function _fetchProfile(

function _fetchPriceStrategy(chainId: ChainId): Promise<Response> {
const baseUrl = _getPriceStrategyApiBaseUrl(chainId)
return fetch(baseUrl, {
headers: DEFAULT_HEADERS,
method: 'GET',
})
return fetch(baseUrl)
}

function _post(chainId: ChainId, url: string, data: any): Promise<Response> {
Expand Down
10 changes: 1 addition & 9 deletions src/custom/hooks/useGetGpPriceStrategy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import ms from 'ms.macro'
import { useState, useEffect, useCallback } from 'react'
import { DEFAULT_GP_PRICE_STRATEGY } from 'constants/index'
import { registerOnWindow } from 'utils/misc'
import { getPriceStrategy, PriceStrategy } from 'api/gnosisProtocol/api'
import { useActiveWeb3React } from 'hooks'
import { supportedChainId } from 'utils/supportedChainId'
Expand Down Expand Up @@ -43,12 +42,5 @@ export default function useGetGpPriceStrategy(): GpPriceStrategy {
return () => clearInterval(intervalId)
}, [_handleSetStrategy, gpPriceStrategy, preChainId])

// TODO: REMOVE
return process.env.NODE_ENV !== 'production' ? (window as any).GP_STRATEGY : gpPriceStrategy
return gpPriceStrategy
}

/* TESTING ONLY! */
;(window as any).GP_STRATEGY = DEFAULT_GP_PRICE_STRATEGY
registerOnWindow({
setStrategy: (strat: GpPriceStrategy) => ((window as any).GP_STRATEGY = strat),
})

0 comments on commit 5bed219

Please sign in to comment.