1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 01:47:00 +01:00

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.
This commit is contained in:
Elliot Winkler 2023-06-06 14:10:45 -06:00 committed by GitHub
parent 2b95d7b242
commit db45a0aef4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View File

@ -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({

View File

@ -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,
});
}