1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 01:47:00 +01:00

remove infura project_id from networks form field (#13539)

* remove infura project_id from networks form field
This commit is contained in:
Alex Donesky 2022-02-10 13:23:52 -06:00 committed by GitHub
parent 59b0ae4b40
commit 7148607906
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 21 deletions

View File

@ -41,14 +41,14 @@ export const GOERLI_DISPLAY_NAME = 'Goerli';
export const LOCALHOST_DISPLAY_NAME = 'Localhost 8545';
const infuraProjectId = process.env.INFURA_PROJECT_ID;
const getRpcUrl = (network) =>
`https://${network}.infura.io/v3/${infuraProjectId}`;
export const getRpcUrl = ({ network, excludeProjectId = false }) =>
`https://${network}.infura.io/v3/${excludeProjectId ? '' : infuraProjectId}`;
export const ROPSTEN_RPC_URL = getRpcUrl('ropsten');
export const RINKEBY_RPC_URL = getRpcUrl('rinkeby');
export const KOVAN_RPC_URL = getRpcUrl('kovan');
export const MAINNET_RPC_URL = getRpcUrl('mainnet');
export const GOERLI_RPC_URL = getRpcUrl('goerli');
export const ROPSTEN_RPC_URL = getRpcUrl({ network: ROPSTEN });
export const RINKEBY_RPC_URL = getRpcUrl({ network: RINKEBY });
export const KOVAN_RPC_URL = getRpcUrl({ network: KOVAN });
export const MAINNET_RPC_URL = getRpcUrl({ network: MAINNET });
export const GOERLI_RPC_URL = getRpcUrl({ network: GOERLI });
export const LOCALHOST_RPC_URL = 'http://localhost:8545';
export const ETH_SYMBOL = 'ETH';

View File

@ -75,8 +75,7 @@ describe('Stores custom RPC history', function () {
await driver.press('#password', driver.Key.ENTER);
// duplicate network
const duplicateRpcUrl =
'https://mainnet.infura.io/v3/00000000000000000000000000000000';
const duplicateRpcUrl = 'https://mainnet.infura.io/v3/';
await driver.clickElement('.network-display');

View File

@ -4,7 +4,7 @@ import { fireEvent, screen } from '@testing-library/react';
import nock from 'nock';
import { renderWithProvider } from '../../../../../test/jest/rendering';
import { defaultNetworksData } from '../networks-tab.constants';
import { MAINNET_RPC_URL } from '../../../../../shared/constants/network';
import { MAINNET, getRpcUrl } from '../../../../../shared/constants/network';
import NetworksForm from '.';
const renderComponent = (props) => {
@ -169,7 +169,9 @@ describe('NetworkForm Component', () => {
expect(await screen.findByText('Invalid RPC URL')).toBeInTheDocument();
await fireEvent.change(rpcUrlField, {
target: { value: MAINNET_RPC_URL },
target: {
value: getRpcUrl({ network: MAINNET, excludeProjectId: true }),
},
});
expect(

View File

@ -1,19 +1,15 @@
import {
GOERLI,
GOERLI_CHAIN_ID,
GOERLI_RPC_URL,
KOVAN,
KOVAN_CHAIN_ID,
KOVAN_RPC_URL,
MAINNET,
MAINNET_CHAIN_ID,
MAINNET_RPC_URL,
RINKEBY,
RINKEBY_CHAIN_ID,
RINKEBY_RPC_URL,
ROPSTEN,
ROPSTEN_CHAIN_ID,
ROPSTEN_RPC_URL,
getRpcUrl,
} from '../../../../shared/constants/network';
const defaultNetworksData = [
@ -21,7 +17,7 @@ const defaultNetworksData = [
labelKey: MAINNET,
iconColor: '#29B6AF',
providerType: MAINNET,
rpcUrl: MAINNET_RPC_URL,
rpcUrl: getRpcUrl({ network: MAINNET, excludeProjectId: true }),
chainId: MAINNET_CHAIN_ID,
ticker: 'ETH',
blockExplorerUrl: 'https://etherscan.io',
@ -30,7 +26,7 @@ const defaultNetworksData = [
labelKey: ROPSTEN,
iconColor: '#FF4A8D',
providerType: ROPSTEN,
rpcUrl: ROPSTEN_RPC_URL,
rpcUrl: getRpcUrl({ network: ROPSTEN, excludeProjectId: true }),
chainId: ROPSTEN_CHAIN_ID,
ticker: 'ETH',
blockExplorerUrl: 'https://ropsten.etherscan.io',
@ -39,7 +35,7 @@ const defaultNetworksData = [
labelKey: RINKEBY,
iconColor: '#F6C343',
providerType: RINKEBY,
rpcUrl: RINKEBY_RPC_URL,
rpcUrl: getRpcUrl({ network: RINKEBY, excludeProjectId: true }),
chainId: RINKEBY_CHAIN_ID,
ticker: 'ETH',
blockExplorerUrl: 'https://rinkeby.etherscan.io',
@ -48,7 +44,7 @@ const defaultNetworksData = [
labelKey: GOERLI,
iconColor: '#3099f2',
providerType: GOERLI,
rpcUrl: GOERLI_RPC_URL,
rpcUrl: getRpcUrl({ network: GOERLI, excludeProjectId: true }),
chainId: GOERLI_CHAIN_ID,
ticker: 'ETH',
blockExplorerUrl: 'https://goerli.etherscan.io',
@ -57,7 +53,7 @@ const defaultNetworksData = [
labelKey: KOVAN,
iconColor: '#9064FF',
providerType: KOVAN,
rpcUrl: KOVAN_RPC_URL,
rpcUrl: getRpcUrl({ network: KOVAN, excludeProjectId: true }),
chainId: KOVAN_CHAIN_ID,
ticker: 'ETH',
blockExplorerUrl: 'https://kovan.etherscan.io',