2021-02-04 19:15:23 +01:00
|
|
|
import { connect } from 'react-redux';
|
2018-05-20 08:04:19 +02:00
|
|
|
|
2022-01-19 15:38:33 +01:00
|
|
|
import {
|
|
|
|
setPendingTokens,
|
|
|
|
clearPendingTokens,
|
|
|
|
getTokenStandardAndDetails,
|
|
|
|
} from '../../store/actions';
|
2021-02-04 19:15:23 +01:00
|
|
|
import { getMostRecentOverviewPage } from '../../ducks/history/history';
|
2021-05-18 19:23:54 +02:00
|
|
|
import {
|
|
|
|
getRpcPrefsForCurrentProvider,
|
2022-03-31 15:48:05 +02:00
|
|
|
getIsTokenDetectionSupported,
|
|
|
|
getTokenDetectionSupportNetworkByChainId,
|
2022-04-07 19:11:42 +02:00
|
|
|
getIsMainnet,
|
2021-05-18 19:23:54 +02:00
|
|
|
} from '../../selectors/selectors';
|
2021-09-10 22:21:04 +02:00
|
|
|
import ImportToken from './import-token.component';
|
2018-05-20 08:04:19 +02:00
|
|
|
|
2020-06-01 19:54:32 +02:00
|
|
|
const mapStateToProps = (state) => {
|
2020-11-03 00:41:28 +01:00
|
|
|
const {
|
2021-05-18 19:23:54 +02:00
|
|
|
metamask: {
|
|
|
|
identities,
|
|
|
|
tokens,
|
|
|
|
pendingTokens,
|
|
|
|
provider: { chainId },
|
2021-09-15 18:09:23 +02:00
|
|
|
useTokenDetection,
|
|
|
|
tokenList,
|
2022-01-19 15:38:33 +01:00
|
|
|
selectedAddress,
|
2021-05-18 19:23:54 +02:00
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
} = state;
|
2022-04-07 19:11:42 +02:00
|
|
|
|
|
|
|
const tokenDetectionV2Supported =
|
|
|
|
process.env.TOKEN_DETECTION_V2 && getIsTokenDetectionSupported(state);
|
2021-09-15 18:09:23 +02:00
|
|
|
const showSearchTab =
|
2022-04-07 19:11:42 +02:00
|
|
|
getIsMainnet(state) ||
|
|
|
|
tokenDetectionV2Supported ||
|
|
|
|
Boolean(process.env.IN_TEST);
|
|
|
|
|
2018-05-20 08:04:19 +02:00
|
|
|
return {
|
|
|
|
identities,
|
2020-06-01 19:54:32 +02:00
|
|
|
mostRecentOverviewPage: getMostRecentOverviewPage(state),
|
2018-05-20 08:04:19 +02:00
|
|
|
tokens,
|
|
|
|
pendingTokens,
|
2021-09-15 18:09:23 +02:00
|
|
|
showSearchTab,
|
2021-05-18 19:23:54 +02:00
|
|
|
chainId,
|
|
|
|
rpcPrefs: getRpcPrefsForCurrentProvider(state),
|
2021-09-15 18:09:23 +02:00
|
|
|
tokenList,
|
2021-11-29 19:28:35 +01:00
|
|
|
useTokenDetection,
|
2022-01-19 15:38:33 +01:00
|
|
|
selectedAddress,
|
2022-03-31 15:48:05 +02:00
|
|
|
isTokenDetectionSupported: getIsTokenDetectionSupported(state),
|
|
|
|
networkName: getTokenDetectionSupportNetworkByChainId(state),
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
|
|
|
};
|
2020-02-15 21:34:12 +01:00
|
|
|
const mapDispatchToProps = (dispatch) => {
|
2018-05-20 08:04:19 +02:00
|
|
|
return {
|
2020-02-15 21:34:12 +01:00
|
|
|
setPendingTokens: (tokens) => dispatch(setPendingTokens(tokens)),
|
2018-05-20 08:04:19 +02:00
|
|
|
clearPendingTokens: () => dispatch(clearPendingTokens()),
|
2022-01-19 15:38:33 +01:00
|
|
|
getTokenStandardAndDetails: (address, selectedAddress) =>
|
|
|
|
getTokenStandardAndDetails(address, selectedAddress, null),
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
|
|
|
};
|
2018-05-20 08:04:19 +02:00
|
|
|
|
2021-09-10 22:21:04 +02:00
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(ImportToken);
|