From 7eff1d820885a6109d07848f22af73b9d643defe Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Tue, 2 May 2023 15:33:47 -0230 Subject: [PATCH] Remove unused network client configuration (#1299) 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 --- .../src/NetworkController.ts | 29 +++++-------------- .../src/create-network-client.ts | 2 -- .../tests/NetworkController.test.ts | 8 ----- 3 files changed, 7 insertions(+), 32 deletions(-) diff --git a/packages/network-controller/src/NetworkController.ts b/packages/network-controller/src/NetworkController.ts index 25d095f4d6a..93f939dc450 100644 --- a/packages/network-controller/src/NetworkController.ts +++ b/packages/network-controller/src/NetworkController.ts @@ -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: @@ -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}'`); @@ -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(); } @@ -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, }); @@ -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(); } diff --git a/packages/network-controller/src/create-network-client.ts b/packages/network-controller/src/create-network-client.ts index 58f75b666f1..ad0807259e7 100644 --- a/packages/network-controller/src/create-network-client.ts +++ b/packages/network-controller/src/create-network-client.ts @@ -20,8 +20,6 @@ export enum NetworkClientType { type CustomNetworkConfiguration = { chainId?: string; rpcUrl: string; - nickname?: string; - ticker?: string; type: NetworkClientType.Custom; }; diff --git a/packages/network-controller/tests/NetworkController.test.ts b/packages/network-controller/tests/NetworkController.test.ts index b36db0ae85d..4b077f02441 100644 --- a/packages/network-controller/tests/NetworkController.test.ts +++ b/packages/network-controller/tests/NetworkController.test.ts @@ -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(); @@ -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(); @@ -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(); @@ -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();