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';
|
2023-05-02 14:36:24 +02:00
|
|
|
import { getProviderConfig } from '../../ducks/metamask/metamask';
|
2021-05-18 19:23:54 +02:00
|
|
|
import {
|
|
|
|
getRpcPrefsForCurrentProvider,
|
2022-03-31 15:48:05 +02:00
|
|
|
getIsTokenDetectionSupported,
|
|
|
|
getTokenDetectionSupportNetworkByChainId,
|
2022-08-10 03:26:25 +02:00
|
|
|
getIsTokenDetectionInactiveOnMainnet,
|
|
|
|
getIsDynamicTokenListAvailable,
|
|
|
|
getIstokenDetectionInactiveOnNonMainnetSupportedNetwork,
|
|
|
|
getTokenList,
|
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,
|
2021-09-15 18:09:23 +02:00
|
|
|
useTokenDetection,
|
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;
|
2023-05-02 14:36:24 +02:00
|
|
|
const { chainId } = getProviderConfig(state);
|
2022-04-07 19:11:42 +02:00
|
|
|
|
2022-08-10 03:26:25 +02:00
|
|
|
const isTokenDetectionInactiveOnMainnet =
|
|
|
|
getIsTokenDetectionInactiveOnMainnet(state);
|
2021-09-15 18:09:23 +02:00
|
|
|
const showSearchTab =
|
2022-08-10 03:26:25 +02:00
|
|
|
getIsTokenDetectionSupported(state) ||
|
|
|
|
isTokenDetectionInactiveOnMainnet ||
|
2022-04-07 19:11:42 +02:00
|
|
|
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),
|
2022-08-10 03:26:25 +02:00
|
|
|
tokenList: getTokenList(state),
|
2021-11-29 19:28:35 +01:00
|
|
|
useTokenDetection,
|
2022-01-19 15:38:33 +01:00
|
|
|
selectedAddress,
|
2022-08-10 03:26:25 +02:00
|
|
|
isDynamicTokenListAvailable: getIsDynamicTokenListAvailable(state),
|
2022-03-31 15:48:05 +02:00
|
|
|
networkName: getTokenDetectionSupportNetworkByChainId(state),
|
2022-08-10 03:26:25 +02:00
|
|
|
tokenDetectionInactiveOnNonMainnetSupportedNetwork:
|
|
|
|
getIstokenDetectionInactiveOnNonMainnetSupportedNetwork(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);
|