Skip to content

Commit

Permalink
feat: Show network badge in detected tokens modal
Browse files Browse the repository at this point in the history
  • Loading branch information
darkwing committed Oct 31, 2024
1 parent dd03cc2 commit eaef0c5
Showing 1 changed file with 29 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
import React from 'react';
import PropTypes from 'prop-types';
import { useSelector } from 'react-redux';

import { Box } from '../../../component-library';
import Identicon from '../../../ui/identicon';
import {
AvatarNetwork,
AvatarNetworkSize,
AvatarToken,
BadgeWrapper,
Box,
} from '../../../component-library';
import DetectedTokenValues from '../detected-token-values/detected-token-values';
import DetectedTokenAddress from '../detected-token-address/detected-token-address';
import DetectedTokenAggregators from '../detected-token-aggregators/detected-token-aggregators';
import { Display } from '../../../../helpers/constants/design-system';
import { getTokenList } from '../../../../selectors';
import {
getCurrentNetwork,
getTestNetworkBackgroundColor,
getTokenList,
} from '../../../../selectors';

const DetectedTokenDetails = ({
token,
Expand All @@ -17,18 +25,30 @@ const DetectedTokenDetails = ({
}) => {
const tokenList = useSelector(getTokenList);
const tokenData = tokenList[token.address?.toLowerCase()];
const testNetworkBackgroundColor = useSelector(getTestNetworkBackgroundColor);
const currentNetwork = useSelector(getCurrentNetwork);

return (
<Box
display={Display.Flex}
className="detected-token-details"
marginBottom={4}
>
<Identicon
<BadgeWrapper
badge={
<AvatarNetwork
size={AvatarNetworkSize.Xs}
name={currentNetwork?.nickname || ''}
src={currentNetwork?.rpcPrefs?.imageUrl}
backgroundColor={testNetworkBackgroundColor}
/>
}
marginRight={4}
className="detected-token-details__identicon"
address={token.address}
diameter={40}
/>
>
<AvatarToken name={token.symbol} src={token.image} />
</BadgeWrapper>

<Box
display={Display.Grid}
marginLeft={2}
Expand All @@ -55,6 +75,7 @@ DetectedTokenDetails.propTypes = {
symbol: PropTypes.string,
iconUrl: PropTypes.string,
aggregators: PropTypes.array,
image: PropTypes.string,
}),
handleTokenSelection: PropTypes.func.isRequired,
tokensListDetected: PropTypes.object,
Expand Down

0 comments on commit eaef0c5

Please sign in to comment.