From 73b9c1095aa27b7720cee7d0c5203b512b75f9bb Mon Sep 17 00:00:00 2001 From: Elliot Winkler Date: Thu, 20 Apr 2023 12:20:59 -0600 Subject: [PATCH] Update NC setProviderType to clear rpcUrl/nickname (#18675) In the core version of NetworkController, `setProviderType` sets `rpcTarget` (its name for `rpcUrl`) and `nickname` to `undefined`. While it would be better to completely remove these properties, it would be better to follow suit so that we can make the tests between the two versions of the controllers more alike. --- .../controllers/network/network-controller.test.ts | 8 ++++---- app/scripts/controllers/network/network-controller.ts | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/scripts/controllers/network/network-controller.test.ts b/app/scripts/controllers/network/network-controller.test.ts index 872b348d1..c3360c140 100644 --- a/app/scripts/controllers/network/network-controller.test.ts +++ b/app/scripts/controllers/network/network-controller.test.ts @@ -5006,10 +5006,10 @@ describe('NetworkController', () => { expect(controller.store.getState().provider).toStrictEqual({ type: networkType, - rpcUrl: '', + rpcUrl: undefined, chainId, ticker, - nickname: '', + nickname: undefined, rpcPrefs: { blockExplorerUrl }, }); }, @@ -6975,10 +6975,10 @@ describe('NetworkController', () => { await controller.setProviderType('goerli'); expect(controller.store.getState().provider).toStrictEqual({ type: 'goerli', - rpcUrl: '', + rpcUrl: undefined, chainId: '0x5', ticker: 'GoerliETH', - nickname: '', + nickname: undefined, rpcPrefs: { blockExplorerUrl: 'https://goerli.etherscan.io', }, diff --git a/app/scripts/controllers/network/network-controller.ts b/app/scripts/controllers/network/network-controller.ts index eaf3f6931..545e47ccc 100644 --- a/app/scripts/controllers/network/network-controller.ts +++ b/app/scripts/controllers/network/network-controller.ts @@ -742,10 +742,10 @@ export class NetworkController extends EventEmitter { const network = BUILT_IN_INFURA_NETWORKS[type]; await this.#setProviderConfig({ type, - rpcUrl: '', + rpcUrl: undefined, chainId: network.chainId, ticker: 'ticker' in network ? network.ticker : 'ETH', - nickname: '', + nickname: undefined, rpcPrefs: { blockExplorerUrl: network.blockExplorerUrl }, }); }