Skip to content

Commit

Permalink
remove infura project_id from networks form field (#13539)
Browse files Browse the repository at this point in the history
* remove infura project_id from networks form field
  • Loading branch information
adonesky1 authored Feb 10, 2022
1 parent 59b0ae4 commit 7148607
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 22 deletions.
16 changes: 8 additions & 8 deletions shared/constants/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 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 getRpcUrl = ({ network, excludeProjectId = false }) =>
`https://${network}.infura.io/v3/${excludeProjectId ? '' : infuraProjectId}`;

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';
Expand Down
3 changes: 1 addition & 2 deletions test/e2e/tests/custom-rpc-history.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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(
Expand Down
16 changes: 6 additions & 10 deletions ui/pages/settings/networks-tab/networks-tab.constants.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
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 = [
{
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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand Down

0 comments on commit 7148607

Please sign in to comment.