From db45a0aef4e140a0f4c823bf24cdf43fd34cbae3 Mon Sep 17 00:00:00 2001 From: Elliot Winkler Date: Tue, 6 Jun 2023 14:10:45 -0600 Subject: [PATCH] setActiveNetwork captures network config ID (#19404) In the core version of NetworkController, when the `setActiveNetwork` method updates the provider configuration object, it will capture the ID of the network configuration used to do so within the provider config itself. In the same way, `setProviderType` clears any ID that was previously set from the provider config. This commit updates this version of NetworkController to be consistent and updates tests to match. --- app/scripts/controllers/network/network-controller.test.ts | 2 ++ app/scripts/controllers/network/network-controller.ts | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/app/scripts/controllers/network/network-controller.test.ts b/app/scripts/controllers/network/network-controller.test.ts index 916fdade9..25e6fa6a2 100644 --- a/app/scripts/controllers/network/network-controller.test.ts +++ b/app/scripts/controllers/network/network-controller.test.ts @@ -2383,6 +2383,7 @@ describe('NetworkController', () => { ticker, nickname: undefined, rpcPrefs: { blockExplorerUrl }, + id: undefined, }); }, ); @@ -3287,6 +3288,7 @@ describe('NetworkController', () => { rpcPrefs: { blockExplorerUrl: 'https://goerli.etherscan.io', }, + id: undefined, }); await waitForLookupNetworkToComplete({ diff --git a/app/scripts/controllers/network/network-controller.ts b/app/scripts/controllers/network/network-controller.ts index 4cba4063b..431c49d9d 100644 --- a/app/scripts/controllers/network/network-controller.ts +++ b/app/scripts/controllers/network/network-controller.ts @@ -181,6 +181,10 @@ export type ProviderConfiguration = { rpcPrefs?: { blockExplorerUrl?: string; }; + /** + * The ID of the network configuration used to build this provider config. + */ + id?: NetworkConfigurationId; }; /** @@ -725,6 +729,7 @@ export class NetworkController extends EventEmitter { ticker: 'ticker' in network ? network.ticker : 'ETH', nickname: undefined, rpcPrefs: { blockExplorerUrl: network.blockExplorerUrl }, + id: undefined, }); }