From 7a9662b88e351fd2386654772cd9300d693f63cf Mon Sep 17 00:00:00 2001 From: Guillaume Roux Date: Tue, 26 Apr 2022 21:08:14 +0200 Subject: [PATCH] Add token standard to custom token details (#14506) * use getTokenStandardAndDetails to get token standard * remove console.log and fix test * remove console.log --- ui/pages/confirm-import-token/confirm-import-token.js | 3 +-- ui/pages/import-token/import-token.component.js | 9 ++++++++- ui/pages/import-token/import-token.test.js | 1 + 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ui/pages/confirm-import-token/confirm-import-token.js b/ui/pages/confirm-import-token/confirm-import-token.js index 88426879b..354077072 100644 --- a/ui/pages/confirm-import-token/confirm-import-token.js +++ b/ui/pages/confirm-import-token/confirm-import-token.js @@ -13,7 +13,6 @@ import { MetaMetricsContext } from '../../contexts/metametrics'; import { getMostRecentOverviewPage } from '../../ducks/history/history'; import { getPendingTokens } from '../../ducks/metamask/metamask'; import { addTokens, clearPendingTokens } from '../../store/actions'; -import { TOKEN_STANDARDS } from '../../helpers/constants/common'; import { EVENT } from '../../../shared/constants/metametrics'; import { ASSET_TYPES } from '../../../shared/constants/transaction'; @@ -46,7 +45,7 @@ const ConfirmImportToken = () => { token_decimal_precision: pendingToken.decimals, unlisted: pendingToken.unlisted, source: pendingToken.isCustom ? 'custom' : 'list', - token_standard: TOKEN_STANDARDS.ERC20, + token_standard: pendingToken.standard, asset_type: ASSET_TYPES.TOKEN, }, }); diff --git a/ui/pages/import-token/import-token.component.js b/ui/pages/import-token/import-token.component.js index 4dcd97a67..443988a27 100644 --- a/ui/pages/import-token/import-token.component.js +++ b/ui/pages/import-token/import-token.component.js @@ -23,6 +23,7 @@ import ActionableMessage from '../../components/ui/actionable-message/actionable import Typography from '../../components/ui/typography'; import { TYPOGRAPHY, FONT_WEIGHT } from '../../helpers/constants/design-system'; import Button from '../../components/ui/button'; +import { TOKEN_STANDARDS } from '../../helpers/constants/common'; import TokenSearch from './token-search'; import TokenList from './token-list'; @@ -126,6 +127,7 @@ class ImportToken extends Component { customDecimals: 0, searchResults: [], selectedTokens: {}, + standard: TOKEN_STANDARDS.NONE, tokenSelectorError: null, customAddressError: null, customSymbolError: null, @@ -231,12 +233,14 @@ class ImportToken extends Component { customSymbol: symbol, customDecimals: decimals, selectedTokens, + standard, } = this.state; const customToken = { address, symbol, decimals, + standard, }; setPendingTokens({ customToken, selectedTokens, tokenAddressList }); @@ -281,7 +285,7 @@ class ImportToken extends Component { const isMainnetNetwork = this.props.chainId === '0x1'; let standard; - if (addressIsValid && process.env.COLLECTIBLES_V1) { + if (addressIsValid) { try { ({ standard } = await this.props.getTokenStandardAndDetails( standardAddress, @@ -353,6 +357,9 @@ class ImportToken extends Component { default: if (!addressIsEmpty) { this.attemptToAutoFillTokenParams(customAddress); + if (standard) { + this.setState({ standard }); + } } } } diff --git a/ui/pages/import-token/import-token.test.js b/ui/pages/import-token/import-token.test.js index c03a9c486..8de7e1283 100644 --- a/ui/pages/import-token/import-token.test.js +++ b/ui/pages/import-token/import-token.test.js @@ -132,6 +132,7 @@ describe('Import Token', () => { customToken: { address: tokenAddress, decimals: Number(tokenPrecision), + standard: 'ERC20', symbol: tokenSymbol, }, selectedTokens: {},