mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +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:
parent
9cea6f57ef
commit
71d0873ded
@ -13,7 +13,6 @@ import { MetaMetricsContext } from '../../contexts/metametrics';
|
|||||||
import { getMostRecentOverviewPage } from '../../ducks/history/history';
|
import { getMostRecentOverviewPage } from '../../ducks/history/history';
|
||||||
import { getPendingTokens } from '../../ducks/metamask/metamask';
|
import { getPendingTokens } from '../../ducks/metamask/metamask';
|
||||||
import { addTokens, clearPendingTokens } from '../../store/actions';
|
import { addTokens, clearPendingTokens } from '../../store/actions';
|
||||||
import { TOKEN_STANDARDS } from '../../helpers/constants/common';
|
|
||||||
import { ASSET_TYPES } from '../../../shared/constants/transaction';
|
import { ASSET_TYPES } from '../../../shared/constants/transaction';
|
||||||
|
|
||||||
const getTokenName = (name, symbol) => {
|
const getTokenName = (name, symbol) => {
|
||||||
@ -45,7 +44,7 @@ const ConfirmImportToken = () => {
|
|||||||
token_decimal_precision: pendingToken.decimals,
|
token_decimal_precision: pendingToken.decimals,
|
||||||
unlisted: pendingToken.unlisted,
|
unlisted: pendingToken.unlisted,
|
||||||
source: pendingToken.isCustom ? 'custom' : 'list',
|
source: pendingToken.isCustom ? 'custom' : 'list',
|
||||||
token_standard: TOKEN_STANDARDS.ERC20,
|
token_standard: pendingToken.standard,
|
||||||
asset_type: ASSET_TYPES.TOKEN,
|
asset_type: ASSET_TYPES.TOKEN,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -23,6 +23,7 @@ import ActionableMessage from '../../components/ui/actionable-message/actionable
|
|||||||
import Typography from '../../components/ui/typography';
|
import Typography from '../../components/ui/typography';
|
||||||
import { TYPOGRAPHY, FONT_WEIGHT } from '../../helpers/constants/design-system';
|
import { TYPOGRAPHY, FONT_WEIGHT } from '../../helpers/constants/design-system';
|
||||||
import Button from '../../components/ui/button';
|
import Button from '../../components/ui/button';
|
||||||
|
import { TOKEN_STANDARDS } from '../../helpers/constants/common';
|
||||||
import TokenSearch from './token-search';
|
import TokenSearch from './token-search';
|
||||||
import TokenList from './token-list';
|
import TokenList from './token-list';
|
||||||
|
|
||||||
@ -126,6 +127,7 @@ class ImportToken extends Component {
|
|||||||
customDecimals: 0,
|
customDecimals: 0,
|
||||||
searchResults: [],
|
searchResults: [],
|
||||||
selectedTokens: {},
|
selectedTokens: {},
|
||||||
|
standard: TOKEN_STANDARDS.NONE,
|
||||||
tokenSelectorError: null,
|
tokenSelectorError: null,
|
||||||
customAddressError: null,
|
customAddressError: null,
|
||||||
customSymbolError: null,
|
customSymbolError: null,
|
||||||
@ -231,12 +233,14 @@ class ImportToken extends Component {
|
|||||||
customSymbol: symbol,
|
customSymbol: symbol,
|
||||||
customDecimals: decimals,
|
customDecimals: decimals,
|
||||||
selectedTokens,
|
selectedTokens,
|
||||||
|
standard,
|
||||||
} = this.state;
|
} = this.state;
|
||||||
|
|
||||||
const customToken = {
|
const customToken = {
|
||||||
address,
|
address,
|
||||||
symbol,
|
symbol,
|
||||||
decimals,
|
decimals,
|
||||||
|
standard,
|
||||||
};
|
};
|
||||||
|
|
||||||
setPendingTokens({ customToken, selectedTokens, tokenAddressList });
|
setPendingTokens({ customToken, selectedTokens, tokenAddressList });
|
||||||
@ -281,7 +285,7 @@ class ImportToken extends Component {
|
|||||||
const isMainnetNetwork = this.props.chainId === '0x1';
|
const isMainnetNetwork = this.props.chainId === '0x1';
|
||||||
|
|
||||||
let standard;
|
let standard;
|
||||||
if (addressIsValid && process.env.COLLECTIBLES_V1) {
|
if (addressIsValid) {
|
||||||
try {
|
try {
|
||||||
({ standard } = await this.props.getTokenStandardAndDetails(
|
({ standard } = await this.props.getTokenStandardAndDetails(
|
||||||
standardAddress,
|
standardAddress,
|
||||||
@ -353,6 +357,9 @@ class ImportToken extends Component {
|
|||||||
default:
|
default:
|
||||||
if (!addressIsEmpty) {
|
if (!addressIsEmpty) {
|
||||||
this.attemptToAutoFillTokenParams(customAddress);
|
this.attemptToAutoFillTokenParams(customAddress);
|
||||||
|
if (standard) {
|
||||||
|
this.setState({ standard });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -132,6 +132,7 @@ describe('Import Token', () => {
|
|||||||
customToken: {
|
customToken: {
|
||||||
address: tokenAddress,
|
address: tokenAddress,
|
||||||
decimals: Number(tokenPrecision),
|
decimals: Number(tokenPrecision),
|
||||||
|
standard: 'ERC20',
|
||||||
symbol: tokenSymbol,
|
symbol: tokenSymbol,
|
||||||
},
|
},
|
||||||
selectedTokens: {},
|
selectedTokens: {},
|
||||||
|
Loading…
Reference in New Issue
Block a user