From 96610742cea5514be628ca587eee8a6b1efc9cd7 Mon Sep 17 00:00:00 2001
From: Niranjana Binoy <43930900+NiranjanaBinoy@users.noreply.github.com>
Date: Sat, 2 Apr 2022 17:33:35 -0400
Subject: [PATCH] Token Details component for Tokens Detected page (#14169)
---
ui/components/app/app-components.scss | 1 +
.../detected-token-details.js | 41 +++++++++++++++++++
.../detected-token-details.stories.js | 26 ++++++++++++
.../detected-token-details.test.js | 35 ++++++++++++++++
.../detected-token-details/index.scss | 9 ++++
5 files changed, 112 insertions(+)
create mode 100644 ui/components/app/detected-token/detected-token-details/detected-token-details.js
create mode 100644 ui/components/app/detected-token/detected-token-details/detected-token-details.stories.js
create mode 100644 ui/components/app/detected-token/detected-token-details/detected-token-details.test.js
create mode 100644 ui/components/app/detected-token/detected-token-details/index.scss
diff --git a/ui/components/app/app-components.scss b/ui/components/app/app-components.scss
index 4a7812116..0493d234a 100644
--- a/ui/components/app/app-components.scss
+++ b/ui/components/app/app-components.scss
@@ -87,3 +87,4 @@
@import 'detected-token/detected-token-address/index';
@import 'detected-token/detected-token-aggregators/index';
@import 'detected-token/detected-token-values/index';
+@import 'detected-token/detected-token-details/index'
diff --git a/ui/components/app/detected-token/detected-token-details/detected-token-details.js b/ui/components/app/detected-token/detected-token-details/detected-token-details.js
new file mode 100644
index 000000000..0b6d4d59a
--- /dev/null
+++ b/ui/components/app/detected-token/detected-token-details/detected-token-details.js
@@ -0,0 +1,41 @@
+import React from 'react';
+import { useSelector } from 'react-redux';
+import PropTypes from 'prop-types';
+
+import Box from '../../../ui/box';
+import Identicon from '../../../ui/identicon';
+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';
+
+const DetectedTokenDetails = ({ tokenAddress }) => {
+ const tokenList = useSelector(getTokenList);
+ const token = tokenList[tokenAddress];
+
+ return (
+
+
+
+
+
+
+
+
+ );
+};
+
+DetectedTokenDetails.propTypes = {
+ tokenAddress: PropTypes.string,
+};
+
+export default DetectedTokenDetails;
diff --git a/ui/components/app/detected-token/detected-token-details/detected-token-details.stories.js b/ui/components/app/detected-token/detected-token-details/detected-token-details.stories.js
new file mode 100644
index 000000000..fe95977f6
--- /dev/null
+++ b/ui/components/app/detected-token/detected-token-details/detected-token-details.stories.js
@@ -0,0 +1,26 @@
+import React from 'react';
+
+import DetectedTokenDetails from './detected-token-details';
+
+export default {
+ title: 'Components/App/DetectedToken/DetectedTokenDetails',
+ id: __filename,
+ argTypes: {
+ address: { control: 'text' },
+ },
+ args: {
+ address: '0xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f',
+ },
+};
+
+const Template = (args) => {
+ return (
+
+
+
+ );
+};
+
+export const DefaultStory = Template.bind({});
+
+DefaultStory.storyName = 'Default';
diff --git a/ui/components/app/detected-token/detected-token-details/detected-token-details.test.js b/ui/components/app/detected-token/detected-token-details/detected-token-details.test.js
new file mode 100644
index 000000000..4bebcb8eb
--- /dev/null
+++ b/ui/components/app/detected-token/detected-token-details/detected-token-details.test.js
@@ -0,0 +1,35 @@
+import * as React from 'react';
+import {
+ renderWithProvider,
+ screen,
+ fireEvent,
+} from '../../../../../test/jest';
+import configureStore from '../../../../store/store';
+import testData from '../../../../../.storybook/test-data';
+
+import DetectedTokenDetails from './detected-token-details';
+
+describe('DetectedTokenDetails', () => {
+ const args = {
+ tokenAddress: '0xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f',
+ };
+
+ it('should render the detected token details', async () => {
+ const store = configureStore(testData);
+ renderWithProvider(, store);
+
+ expect(screen.getByText('0 SNX')).toBeInTheDocument();
+ expect(screen.getByText('$0')).toBeInTheDocument();
+ expect(screen.getByText('Token address:')).toBeInTheDocument();
+ expect(screen.getByText('0xc01...2a6f')).toBeInTheDocument();
+ expect(screen.getByText('From token lists:')).toBeInTheDocument();
+ expect(screen.getByText('Aave, Bancor')).toBeInTheDocument();
+ expect(screen.getByText('+ 10 more')).toBeInTheDocument();
+ fireEvent.click(screen.getByText('+ 10 more'));
+ expect(
+ screen.getByText(
+ 'Aave, Bancor, CMC, Crypto.com, CoinGecko, 1inch, Paraswap, PMM, Synthetix, Zapper, Zerion, 0x.',
+ ),
+ ).toBeInTheDocument();
+ });
+});
diff --git a/ui/components/app/detected-token/detected-token-details/index.scss b/ui/components/app/detected-token/detected-token-details/index.scss
new file mode 100644
index 000000000..1722f3517
--- /dev/null
+++ b/ui/components/app/detected-token/detected-token-details/index.scss
@@ -0,0 +1,9 @@
+.detected-token-details {
+ &__identicon {
+ margin-top: 4px;
+ }
+
+ &__data {
+ flex-grow: 1;
+ }
+}