1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 18:00:18 +01:00

Add token standard to custom token details (#14506)

* use getTokenStandardAndDetails to get token standard

* remove console.log and fix test

* remove console.log
This commit is contained in:
Guillaume Roux 2022-04-26 21:08:14 +02:00 committed by GitHub
parent 223124a561
commit 7a9662b88e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 3 deletions

View File

@ -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,
},
});

View File

@ -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 });
}
}
}
}

View File

@ -132,6 +132,7 @@ describe('Import Token', () => {
customToken: {
address: tokenAddress,
decimals: Number(tokenPrecision),
standard: 'ERC20',
symbol: tokenSymbol,
},
selectedTokens: {},