1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Use our local ETH_SWAPS_TOKEN_OBJECT in place of the swaps api ETH 'token', in the swaps token array (#9678)

This commit is contained in:
Dan J Miller 2020-10-22 12:29:58 -02:30 committed by GitHub
parent 07c03e362e
commit 21ab6fb7b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -1,3 +1,5 @@
import { ETH_SWAPS_TOKEN_OBJECT } from '../../helpers/constants/swaps'
export const TRADES_BASE_PROD_URL = 'https://api.metaswap.codefi.network/trades?' export const TRADES_BASE_PROD_URL = 'https://api.metaswap.codefi.network/trades?'
export const TOKENS_BASE_PROD_URL = 'https://api.metaswap.codefi.network/tokens' export const TOKENS_BASE_PROD_URL = 'https://api.metaswap.codefi.network/tokens'
export const AGGREGATOR_METADATA_BASE_PROD_URL = 'https://api.metaswap.codefi.network/aggregatorMetadata' export const AGGREGATOR_METADATA_BASE_PROD_URL = 'https://api.metaswap.codefi.network/aggregatorMetadata'
@ -16,6 +18,7 @@ export const TOKENS = [
{ erc20: true, symbol: 'USDT', decimals: 6, address: '0xdAC17F958D2ee523a2206206994597C13D831ec7' }, { erc20: true, symbol: 'USDT', decimals: 6, address: '0xdAC17F958D2ee523a2206206994597C13D831ec7' },
{ erc20: true, symbol: 'WED', decimals: 18, address: '0x7848ae8F19671Dc05966dafBeFbBbb0308BDfAbD' }, { erc20: true, symbol: 'WED', decimals: 18, address: '0x7848ae8F19671Dc05966dafBeFbBbb0308BDfAbD' },
{ erc20: true, symbol: 'WBTC', decimals: 8, address: '0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599' }, { erc20: true, symbol: 'WBTC', decimals: 8, address: '0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599' },
ETH_SWAPS_TOKEN_OBJECT,
] ]
export const MOCK_TRADE_RESPONSE_1 = [ export const MOCK_TRADE_RESPONSE_1 = [

View File

@ -2,6 +2,7 @@ import log from 'loglevel'
import BigNumber from 'bignumber.js' import BigNumber from 'bignumber.js'
import abi from 'human-standard-token-abi' import abi from 'human-standard-token-abi'
import { isValidAddress } from 'ethereumjs-util' import { isValidAddress } from 'ethereumjs-util'
import { ETH_SWAPS_TOKEN_OBJECT } from '../../helpers/constants/swaps'
import { calcTokenValue, calcTokenAmount } from '../../helpers/utils/token-util' import { calcTokenValue, calcTokenAmount } from '../../helpers/utils/token-util'
import { constructTxParams, toPrecisionWithoutTrailingZeros } from '../../helpers/utils/util' import { constructTxParams, toPrecisionWithoutTrailingZeros } from '../../helpers/utils/util'
import { decimalToHex, getValueFromWeiHex } from '../../helpers/utils/conversions.util' import { decimalToHex, getValueFromWeiHex } from '../../helpers/utils/conversions.util'
@ -212,7 +213,10 @@ export async function fetchTradesInfo ({
export async function fetchTokens () { export async function fetchTokens () {
const tokenUrl = getBaseApi('tokens') const tokenUrl = getBaseApi('tokens')
const tokens = await fetchWithCache(tokenUrl, { method: 'GET' }, { cacheRefreshTime: CACHE_REFRESH_ONE_HOUR }) const tokens = await fetchWithCache(tokenUrl, { method: 'GET' }, { cacheRefreshTime: CACHE_REFRESH_ONE_HOUR })
const filteredTokens = tokens.filter((token) => validateData(TOKEN_VALIDATORS, token, tokenUrl)) const filteredTokens = tokens.filter((token) => {
return validateData(TOKEN_VALIDATORS, token, tokenUrl) && (token.address !== ETH_SWAPS_TOKEN_OBJECT.address)
})
filteredTokens.push(ETH_SWAPS_TOKEN_OBJECT)
return filteredTokens return filteredTokens
} }