2021-02-04 19:15:23 +01:00
|
|
|
import { connect } from 'react-redux';
|
2018-05-20 08:04:19 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
import { setPendingTokens, clearPendingTokens } from '../../store/actions';
|
|
|
|
import { getMostRecentOverviewPage } from '../../ducks/history/history';
|
2021-05-18 19:23:54 +02:00
|
|
|
import {
|
|
|
|
getRpcPrefsForCurrentProvider,
|
2021-09-15 18:09:23 +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,
|
2021-05-18 19:23:54 +02:00
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
} = state;
|
2021-09-15 18:09:23 +02:00
|
|
|
const showSearchTabCustomNetwork =
|
|
|
|
useTokenDetection && Boolean(Object.keys(tokenList).length);
|
|
|
|
const showSearchTab =
|
2021-12-02 19:16:46 +01:00
|
|
|
getIsMainnet(state) || showSearchTabCustomNetwork || 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,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
|
|
|
};
|
2018-05-20 08:04:19 +02: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()),
|
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);
|