mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Displaying the aggregators from tokenList in Detected token popover (#15835)
* using the aggregators from tokenList instead of detectedToken to avoid conflicts between static and dynamic list * removing aggregator from the detectTokens object List
This commit is contained in:
parent
c35b4d6ec8
commit
06fc3a1dd5
@ -174,8 +174,8 @@ const state = {
|
|||||||
name: 'Falconswap',
|
name: 'Falconswap',
|
||||||
iconUrl:
|
iconUrl:
|
||||||
'https://assets.coingecko.com/coins/images/12256/thumb/falconswap.png?1598534184',
|
'https://assets.coingecko.com/coins/images/12256/thumb/falconswap.png?1598534184',
|
||||||
aggregators: ['CoinGecko', '1inch', 'Paraswap', 'Zapper', 'Zerion'],
|
aggregators: ['CoinGecko', '1inch', 'Lifi'],
|
||||||
occurrences: 12,
|
occurrences:3,
|
||||||
unlisted: false,
|
unlisted: false,
|
||||||
},
|
},
|
||||||
'0xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f': {
|
'0xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f': {
|
||||||
|
@ -152,7 +152,7 @@ export default class DetectTokensController {
|
|||||||
if (result) {
|
if (result) {
|
||||||
const nonZeroTokenAddresses = Object.keys(result);
|
const nonZeroTokenAddresses = Object.keys(result);
|
||||||
for (const nonZeroTokenAddress of nonZeroTokenAddresses) {
|
for (const nonZeroTokenAddress of nonZeroTokenAddresses) {
|
||||||
const { address, symbol, decimals, aggregators } =
|
const { address, symbol, decimals } =
|
||||||
tokenListUsed[nonZeroTokenAddress];
|
tokenListUsed[nonZeroTokenAddress];
|
||||||
|
|
||||||
eventTokensDetails.push(`${symbol} - ${address}`);
|
eventTokensDetails.push(`${symbol} - ${address}`);
|
||||||
@ -161,7 +161,6 @@ export default class DetectTokensController {
|
|||||||
address,
|
address,
|
||||||
symbol,
|
symbol,
|
||||||
decimals,
|
decimals,
|
||||||
aggregators,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,7 +249,7 @@ describe('DetectTokensController', function () {
|
|||||||
address: tokenValues[0].address,
|
address: tokenValues[0].address,
|
||||||
symbol: tokenValues[0].symbol,
|
symbol: tokenValues[0].symbol,
|
||||||
decimals: tokenValues[0].decimals,
|
decimals: tokenValues[0].decimals,
|
||||||
aggregators: tokenValues[0].aggregators,
|
aggregators: undefined,
|
||||||
image: undefined,
|
image: undefined,
|
||||||
isERC721: undefined,
|
isERC721: undefined,
|
||||||
},
|
},
|
||||||
@ -270,7 +270,7 @@ describe('DetectTokensController', function () {
|
|||||||
address: toChecksumHexAddress(tokenValues[0].address),
|
address: toChecksumHexAddress(tokenValues[0].address),
|
||||||
decimals: tokenValues[0].decimals,
|
decimals: tokenValues[0].decimals,
|
||||||
symbol: tokenValues[0].symbol,
|
symbol: tokenValues[0].symbol,
|
||||||
aggregators: tokenValues[0].aggregators,
|
aggregators: undefined,
|
||||||
image: undefined,
|
image: undefined,
|
||||||
isERC721: undefined,
|
isERC721: undefined,
|
||||||
},
|
},
|
||||||
@ -303,7 +303,7 @@ describe('DetectTokensController', function () {
|
|||||||
address: existingToken.address,
|
address: existingToken.address,
|
||||||
symbol: existingToken.symbol,
|
symbol: existingToken.symbol,
|
||||||
decimals: existingToken.decimals,
|
decimals: existingToken.decimals,
|
||||||
aggregators: existingToken.aggregators,
|
aggregators: undefined,
|
||||||
image: undefined,
|
image: undefined,
|
||||||
isERC721: undefined,
|
isERC721: undefined,
|
||||||
},
|
},
|
||||||
@ -321,7 +321,7 @@ describe('DetectTokensController', function () {
|
|||||||
address: toChecksumHexAddress(existingTokenAddress),
|
address: toChecksumHexAddress(existingTokenAddress),
|
||||||
decimals: existingToken.decimals,
|
decimals: existingToken.decimals,
|
||||||
symbol: existingToken.symbol,
|
symbol: existingToken.symbol,
|
||||||
aggregators: existingToken.aggregators,
|
aggregators: undefined,
|
||||||
image: undefined,
|
image: undefined,
|
||||||
isERC721: undefined,
|
isERC721: undefined,
|
||||||
},
|
},
|
||||||
@ -329,7 +329,7 @@ describe('DetectTokensController', function () {
|
|||||||
address: toChecksumHexAddress(tokenAddressToAdd),
|
address: toChecksumHexAddress(tokenAddressToAdd),
|
||||||
decimals: tokenToAdd.decimals,
|
decimals: tokenToAdd.decimals,
|
||||||
symbol: tokenToAdd.symbol,
|
symbol: tokenToAdd.symbol,
|
||||||
aggregators: tokenToAdd.aggregators,
|
aggregators: undefined,
|
||||||
image: undefined,
|
image: undefined,
|
||||||
isERC721: undefined,
|
isERC721: undefined,
|
||||||
},
|
},
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
import { useSelector } from 'react-redux';
|
||||||
|
|
||||||
import Box from '../../../ui/box';
|
import Box from '../../../ui/box';
|
||||||
import Identicon from '../../../ui/identicon';
|
import Identicon from '../../../ui/identicon';
|
||||||
@ -7,12 +8,16 @@ import DetectedTokenValues from '../detected-token-values/detected-token-values'
|
|||||||
import DetectedTokenAddress from '../detected-token-address/detected-token-address';
|
import DetectedTokenAddress from '../detected-token-address/detected-token-address';
|
||||||
import DetectedTokenAggregators from '../detected-token-aggregators/detected-token-aggregators';
|
import DetectedTokenAggregators from '../detected-token-aggregators/detected-token-aggregators';
|
||||||
import { DISPLAY } from '../../../../helpers/constants/design-system';
|
import { DISPLAY } from '../../../../helpers/constants/design-system';
|
||||||
|
import { getTokenList } from '../../../../selectors';
|
||||||
|
|
||||||
const DetectedTokenDetails = ({
|
const DetectedTokenDetails = ({
|
||||||
token,
|
token,
|
||||||
handleTokenSelection,
|
handleTokenSelection,
|
||||||
tokensListDetected,
|
tokensListDetected,
|
||||||
}) => {
|
}) => {
|
||||||
|
const tokenList = useSelector(getTokenList);
|
||||||
|
const tokenData = tokenList[token.address?.toLowerCase()];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
display={DISPLAY.FLEX}
|
display={DISPLAY.FLEX}
|
||||||
@ -35,8 +40,8 @@ const DetectedTokenDetails = ({
|
|||||||
tokensListDetected={tokensListDetected}
|
tokensListDetected={tokensListDetected}
|
||||||
/>
|
/>
|
||||||
<DetectedTokenAddress tokenAddress={token.address} />
|
<DetectedTokenAddress tokenAddress={token.address} />
|
||||||
{token.aggregators.length && (
|
{tokenData?.aggregators.length > 0 && (
|
||||||
<DetectedTokenAggregators aggregators={token.aggregators} />
|
<DetectedTokenAggregators aggregators={tokenData?.aggregators} />
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
|
@ -87,7 +87,7 @@ describe('DetectedTokenDetails', () => {
|
|||||||
fireEvent.click(screen.getByText('+ 10 more'));
|
fireEvent.click(screen.getByText('+ 10 more'));
|
||||||
expect(
|
expect(
|
||||||
screen.getByText(
|
screen.getByText(
|
||||||
'Aave, Bancor, CMC, Crypto.com, CoinGecko, 1Inch, Paraswap, PMM, Synthetix, Zapper, Zerion, 0x.',
|
'Aave, Bancor, CMC, Crypto.com, CoinGecko, 1inch, Paraswap, PMM, Synthetix, Zapper, Zerion, 0x.',
|
||||||
),
|
),
|
||||||
).toBeInTheDocument();
|
).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
@ -23,27 +23,25 @@ describe('DetectedToken', () => {
|
|||||||
expect(screen.getByText('0xc00...6888')).toBeInTheDocument();
|
expect(screen.getByText('0xc00...6888')).toBeInTheDocument();
|
||||||
expect(screen.getByText('0xfff...26DB')).toBeInTheDocument();
|
expect(screen.getByText('0xfff...26DB')).toBeInTheDocument();
|
||||||
expect(screen.getAllByText('From token lists:')).toHaveLength(3);
|
expect(screen.getAllByText('From token lists:')).toHaveLength(3);
|
||||||
expect(screen.getByText('coinGecko, oneInch')).toBeInTheDocument();
|
expect(screen.getByText('Aave, Bancor')).toBeInTheDocument();
|
||||||
expect(screen.getByText('+ 3 more')).toBeInTheDocument();
|
expect(screen.getByText('+ 9 more')).toBeInTheDocument();
|
||||||
fireEvent.click(screen.getByText('+ 3 more'));
|
fireEvent.click(screen.getByText('+ 9 more'));
|
||||||
expect(
|
expect(
|
||||||
screen.getByText('coinGecko, oneInch, paraswap, zapper, zerion.'),
|
screen.getByText(
|
||||||
|
'Aave, Bancor, CMC, Crypto.com, CoinGecko, 1inch, Paraswap, PMM, Zapper, Zerion, 0x.',
|
||||||
|
),
|
||||||
).toBeInTheDocument();
|
).toBeInTheDocument();
|
||||||
expect(screen.getByText('bancor, cmc')).toBeInTheDocument();
|
expect(screen.getByText('Bancor, CMC')).toBeInTheDocument();
|
||||||
expect(screen.getByText('+ 8 more')).toBeInTheDocument();
|
expect(screen.getByText('+ 8 more')).toBeInTheDocument();
|
||||||
fireEvent.click(screen.getByText('+ 8 more'));
|
fireEvent.click(screen.getByText('+ 8 more'));
|
||||||
expect(
|
expect(
|
||||||
screen.getByText(
|
screen.getByText(
|
||||||
'bancor, cmc, cryptocom, coinGecko, oneInch, paraswap, pmm, zapper, zerion, zeroEx.',
|
'Bancor, CMC, Crypto.com, CoinGecko, 1inch, Paraswap, PMM, Zapper, Zerion, 0x.',
|
||||||
),
|
|
||||||
).toBeInTheDocument();
|
|
||||||
expect(screen.getByText('aave, cmc')).toBeInTheDocument();
|
|
||||||
expect(screen.getByText('+ 5 more')).toBeInTheDocument();
|
|
||||||
fireEvent.click(screen.getByText('+ 5 more'));
|
|
||||||
expect(
|
|
||||||
screen.getByText(
|
|
||||||
'aave, cmc, coinGecko, oneInch, paraswap, zapper, zerion.',
|
|
||||||
),
|
),
|
||||||
).toBeInTheDocument();
|
).toBeInTheDocument();
|
||||||
|
expect(screen.getByText('CoinGecko, 1inch')).toBeInTheDocument();
|
||||||
|
expect(screen.getByText('+ 1 more')).toBeInTheDocument();
|
||||||
|
fireEvent.click(screen.getByText('+ 1 more'));
|
||||||
|
expect(screen.getByText('CoinGecko, 1inch, Lifi.')).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user