Skip to content

Commit

Permalink
Remove unused network client configuration (#1299)
Browse files Browse the repository at this point in the history
When constructing a non-Infura network client, the network `nickname`
and `ticker` configuration properties were passed on down to
`web3-provider-engine`. However these were entirely unused. There are
no references to these in the `web3-provider-engine` package.

Relates to #1116
  • Loading branch information
Gudahtt authored and MajorLift committed Oct 11, 2023
1 parent 02b2325 commit 7eff1d8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 32 deletions.
29 changes: 7 additions & 22 deletions packages/network-controller/src/NetworkController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,13 +318,7 @@ export class NetworkController extends BaseControllerV2<
this.#previousNetworkSpecifier = this.state.providerConfig.type;
}

#configureProvider(
type: NetworkType,
rpcUrl?: string,
chainId?: string,
ticker?: string,
nickname?: string,
) {
#configureProvider(type: NetworkType, rpcUrl?: string, chainId?: string) {
switch (type) {
case NetworkType.mainnet:
case NetworkType.goerli:
Expand All @@ -335,8 +329,7 @@ export class NetworkController extends BaseControllerV2<
this.#setupStandardProvider(LOCALHOST_RPC_URL);
break;
case NetworkType.rpc:
rpcUrl &&
this.#setupStandardProvider(rpcUrl, chainId, ticker, nickname);
rpcUrl && this.#setupStandardProvider(rpcUrl, chainId);
break;
default:
throw new Error(`Unrecognized network type: '${type}'`);
Expand All @@ -359,8 +352,8 @@ export class NetworkController extends BaseControllerV2<
state.networkStatus = NetworkStatus.Unknown;
state.networkDetails = {};
});
const { rpcUrl, type, chainId, ticker } = this.state.providerConfig;
this.#configureProvider(type, rpcUrl, chainId, ticker);
const { rpcUrl, type, chainId } = this.state.providerConfig;
this.#configureProvider(type, rpcUrl, chainId);
await this.lookupNetwork();
}

Expand All @@ -383,17 +376,10 @@ export class NetworkController extends BaseControllerV2<
this.#updateProvider(provider, blockTracker);
}

#setupStandardProvider(
rpcUrl: string,
chainId?: string,
ticker?: string,
nickname?: string,
) {
#setupStandardProvider(rpcUrl: string, chainId?: string) {
const { provider, blockTracker } = createNetworkClient({
chainId,
nickname,
rpcUrl,
ticker,
type: NetworkClientType.Custom,
});

Expand Down Expand Up @@ -428,9 +414,8 @@ export class NetworkController extends BaseControllerV2<
*
*/
async initializeProvider() {
const { type, rpcUrl, chainId, ticker, nickname } =
this.state.providerConfig;
this.#configureProvider(type, rpcUrl, chainId, ticker, nickname);
const { type, rpcUrl, chainId } = this.state.providerConfig;
this.#configureProvider(type, rpcUrl, chainId);
this.#registerProvider();
await this.lookupNetwork();
}
Expand Down
2 changes: 0 additions & 2 deletions packages/network-controller/src/create-network-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ export enum NetworkClientType {
type CustomNetworkConfiguration = {
chainId?: string;
rpcUrl: string;
nickname?: string;
ticker?: string;
type: NetworkClientType.Custom;
};

Expand Down
8 changes: 0 additions & 8 deletions packages/network-controller/tests/NetworkController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -475,9 +475,7 @@ describe('NetworkController', () => {

expect(createNetworkClientMock).toHaveBeenCalledWith({
chainId: undefined,
nickname: undefined,
rpcUrl: 'http://localhost:8545',
ticker: undefined,
type: NetworkClientType.Custom,
});
const { provider } = controller.getProviderAndBlockTracker();
Expand Down Expand Up @@ -686,9 +684,7 @@ describe('NetworkController', () => {

expect(createNetworkClientMock).toHaveBeenCalledWith({
chainId: '123',
nickname: 'some cool network',
rpcUrl: 'http://example.com',
ticker: 'ABC',
type: NetworkClientType.Custom,
});
const { provider } = controller.getProviderAndBlockTracker();
Expand Down Expand Up @@ -3549,9 +3545,7 @@ describe('NetworkController', () => {

expect(createNetworkClientMock).toHaveBeenCalledWith({
chainId: undefined,
nickname: undefined,
rpcUrl: 'http://localhost:8545',
ticker: undefined,
type: NetworkClientType.Custom,
});
const { provider } = controller.getProviderAndBlockTracker();
Expand Down Expand Up @@ -3807,9 +3801,7 @@ describe('NetworkController', () => {

expect(createNetworkClientMock).toHaveBeenCalledWith({
chainId: '0xtest',
nickname: undefined,
rpcUrl: 'https://mock-rpc-url',
ticker: 'TEST',
type: NetworkClientType.Custom,
});
const { provider } = controller.getProviderAndBlockTracker();
Expand Down

0 comments on commit 7eff1d8

Please sign in to comment.