|
|
@ -9,6 +9,7 @@ import { openAlert as displayInvalidCustomNetworkAlert } from '../../../ducks/al |
|
|
|
import { |
|
|
|
import { |
|
|
|
LOCALHOST_RPC_URL, |
|
|
|
LOCALHOST_RPC_URL, |
|
|
|
NETWORK_TYPES, |
|
|
|
NETWORK_TYPES, |
|
|
|
|
|
|
|
TEST_CHAINS, |
|
|
|
} from '../../../../shared/constants/network'; |
|
|
|
} from '../../../../shared/constants/network'; |
|
|
|
import { isPrefixedFormattedHexString } from '../../../../shared/modules/network.utils'; |
|
|
|
import { isPrefixedFormattedHexString } from '../../../../shared/modules/network.utils'; |
|
|
|
|
|
|
|
|
|
|
@ -141,11 +142,20 @@ class NetworkDropdown extends Component { |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
renderCustomRpcList(rpcListDetail, provider, opts = {}) { |
|
|
|
renderCustomRpcList(rpcListDetail, provider, shouldShowTestNetworks) { |
|
|
|
const reversedRpcListDetail = rpcListDetail.slice().reverse(); |
|
|
|
// const reversedRpcListDetail = rpcListDetail.slice().reverse();
|
|
|
|
|
|
|
|
|
|
|
|
return reversedRpcListDetail.map((entry) => { |
|
|
|
return rpcListDetail.filter((entry) => shouldShowTestNetworks ? true : !TEST_CHAINS.includes(entry.chainId)).map((entry) => { |
|
|
|
const { rpcUrl, chainId, ticker = 'ETH', nickname = '' } = entry; |
|
|
|
const { |
|
|
|
|
|
|
|
rpcUrl, |
|
|
|
|
|
|
|
chainId, |
|
|
|
|
|
|
|
ticker = 'ETH', |
|
|
|
|
|
|
|
nickname = '', |
|
|
|
|
|
|
|
providerType, |
|
|
|
|
|
|
|
} = entry; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const isDefaultNetworks = |
|
|
|
|
|
|
|
Object.values(NETWORK_TYPES).includes(providerType); |
|
|
|
const isCurrentRpcTarget = |
|
|
|
const isCurrentRpcTarget = |
|
|
|
provider.type === NETWORK_TYPES.RPC && rpcUrl === provider.rpcUrl; |
|
|
|
provider.type === NETWORK_TYPES.RPC && rpcUrl === provider.rpcUrl; |
|
|
|
|
|
|
|
|
|
|
@ -160,11 +170,7 @@ class NetworkDropdown extends Component { |
|
|
|
this.props.displayInvalidCustomNetworkAlert(nickname || rpcUrl); |
|
|
|
this.props.displayInvalidCustomNetworkAlert(nickname || rpcUrl); |
|
|
|
} |
|
|
|
} |
|
|
|
}} |
|
|
|
}} |
|
|
|
style={{ |
|
|
|
style={DROP_DOWN_MENU_ITEM_STYLE} |
|
|
|
fontSize: '16px', |
|
|
|
|
|
|
|
lineHeight: '20px', |
|
|
|
|
|
|
|
padding: '16px', |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
> |
|
|
|
> |
|
|
|
{isCurrentRpcTarget ? ( |
|
|
|
{isCurrentRpcTarget ? ( |
|
|
|
<IconCheck color="var(--color-success-default)" /> |
|
|
|
<IconCheck color="var(--color-success-default)" /> |
|
|
@ -172,13 +178,13 @@ class NetworkDropdown extends Component { |
|
|
|
<div className="network-check__transparent">✓</div> |
|
|
|
<div className="network-check__transparent">✓</div> |
|
|
|
)} |
|
|
|
)} |
|
|
|
<ColorIndicator |
|
|
|
<ColorIndicator |
|
|
|
color={opts.isLocalHost ? 'localhost' : COLORS.ICON_MUTED} |
|
|
|
color={isDefaultNetworks ? providerType : COLORS.ICON_MUTED} |
|
|
|
size={SIZES.LG} |
|
|
|
size={SIZES.LG} |
|
|
|
type={ColorIndicator.TYPES.FILLED} |
|
|
|
type={ColorIndicator.TYPES.FILLED} |
|
|
|
/> |
|
|
|
/> |
|
|
|
<span |
|
|
|
<span |
|
|
|
className="network-name-item" |
|
|
|
className="network-name-item" |
|
|
|
data-testid={`${nickname}-network-item`} |
|
|
|
data-testid={`${providerType ?? nickname}-network-item`} |
|
|
|
style={{ |
|
|
|
style={{ |
|
|
|
color: isCurrentRpcTarget |
|
|
|
color: isCurrentRpcTarget |
|
|
|
? 'var(--color-text-default)' |
|
|
|
? 'var(--color-text-default)' |
|
|
@ -269,12 +275,12 @@ class NetworkDropdown extends Component { |
|
|
|
hideTestNetMessage, |
|
|
|
hideTestNetMessage, |
|
|
|
} = this.props; |
|
|
|
} = this.props; |
|
|
|
const rpcListDetail = this.props.frequentRpcListDetail; |
|
|
|
const rpcListDetail = this.props.frequentRpcListDetail; |
|
|
|
const rpcListDetailWithoutLocalHost = rpcListDetail.filter( |
|
|
|
// const rpcListDetailWithoutLocalHost = rpcListDetail.filter(
|
|
|
|
(rpc) => rpc.rpcUrl !== LOCALHOST_RPC_URL, |
|
|
|
// (rpc) => rpc.rpcUrl !== LOCALHOST_RPC_URL,
|
|
|
|
); |
|
|
|
// );
|
|
|
|
const rpcListDetailForLocalHost = rpcListDetail.filter( |
|
|
|
// const rpcListDetailForLocalHost = rpcListDetail.filter(
|
|
|
|
(rpc) => rpc.rpcUrl === LOCALHOST_RPC_URL, |
|
|
|
// (rpc) => rpc.rpcUrl === LOCALHOST_RPC_URL,
|
|
|
|
); |
|
|
|
// );
|
|
|
|
const isOpen = this.props.networkDropdownOpen; |
|
|
|
const isOpen = this.props.networkDropdownOpen; |
|
|
|
const { t } = this.context; |
|
|
|
const { t } = this.context; |
|
|
|
|
|
|
|
|
|
|
@ -334,14 +340,15 @@ class NetworkDropdown extends Component { |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
<div className="network-dropdown-list"> |
|
|
|
<div className="network-dropdown-list"> |
|
|
|
{this.renderNetworkEntry(NETWORK_TYPES.MAINNET)} |
|
|
|
{/* {this.renderNetworkEntry(NETWORK_TYPES.MAINNET)} */} |
|
|
|
|
|
|
|
|
|
|
|
{this.renderCustomRpcList( |
|
|
|
{this.renderCustomRpcList( |
|
|
|
rpcListDetailWithoutLocalHost, |
|
|
|
rpcListDetail, |
|
|
|
this.props.provider, |
|
|
|
this.props.provider, |
|
|
|
|
|
|
|
shouldShowTestNetworks, |
|
|
|
)} |
|
|
|
)} |
|
|
|
|
|
|
|
|
|
|
|
{shouldShowTestNetworks && ( |
|
|
|
{/* {shouldShowTestNetworks && ( |
|
|
|
<> |
|
|
|
<> |
|
|
|
{this.renderNetworkEntry(NETWORK_TYPES.GOERLI)} |
|
|
|
{this.renderNetworkEntry(NETWORK_TYPES.GOERLI)} |
|
|
|
{this.renderNetworkEntry(NETWORK_TYPES.SEPOLIA)} |
|
|
|
{this.renderNetworkEntry(NETWORK_TYPES.SEPOLIA)} |
|
|
@ -351,7 +358,7 @@ class NetworkDropdown extends Component { |
|
|
|
{ isLocalHost: true }, |
|
|
|
{ isLocalHost: true }, |
|
|
|
)} |
|
|
|
)} |
|
|
|
</> |
|
|
|
</> |
|
|
|
)} |
|
|
|
)} */} |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
{this.renderAddCustomButton()} |
|
|
|
{this.renderAddCustomButton()} |
|
|
|