1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-03 06:34:27 +01:00
metamask-extension/ui/components/app/loading-network-screen/loading-network-screen.container.js
Mark Stacey d1cea85f33
Rename provider to providerConfig (#18907)
* Rename `provider` to `providerConfig`

The network controller `provider` state has been renamed to
 `providerConfig`. This better reflects what this state is, and makes
this controller more closely aligned with the core network controller.

All references to the provider configuration have been updated to
prefer `providerConfig` over `provider`, to make the distinction clear
between a provider and provider config.

Closes #18902

* Add migration
2023-05-02 13:23:20 -02:30

49 lines
1.6 KiB
JavaScript

import { connect } from 'react-redux';
import { NETWORK_TYPES } from '../../../../shared/constants/network';
import * as actions from '../../../store/actions';
import { getNetworkIdentifier, isNetworkLoading } from '../../../selectors';
import { getProviderConfig } from '../../../ducks/metamask/metamask';
import LoadingNetworkScreen from './loading-network-screen.component';
const DEPRECATED_TEST_NET_CHAINIDS = ['0x3', '0x2a', '0x4'];
const mapStateToProps = (state) => {
const { loadingMessage } = state.appState;
const providerConfig = getProviderConfig(state);
const { rpcUrl, chainId, ticker, nickname, type } = providerConfig;
const setProviderArgs =
type === NETWORK_TYPES.RPC ? [rpcUrl, chainId, ticker, nickname] : [type];
const providerChainId = chainId;
const isDeprecatedNetwork =
DEPRECATED_TEST_NET_CHAINIDS.includes(providerChainId);
const isInfuraRpcUrl = rpcUrl && new URL(rpcUrl).host.endsWith('.infura.io');
const showDeprecatedRpcUrlWarning = isDeprecatedNetwork && isInfuraRpcUrl;
return {
isNetworkLoading: isNetworkLoading(state),
loadingMessage,
setProviderArgs,
providerConfig,
providerId: getNetworkIdentifier(state),
showDeprecatedRpcUrlWarning,
};
};
const mapDispatchToProps = (dispatch) => {
return {
setProviderType: (type) => {
dispatch(actions.setProviderType(type));
},
rollbackToPreviousProvider: () =>
dispatch(actions.rollbackToPreviousProvider()),
showNetworkDropdown: () => dispatch(actions.showNetworkDropdown()),
};
};
export default connect(
mapStateToProps,
mapDispatchToProps,
)(LoadingNetworkScreen);