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

Make _switchNetwork async (#18597)

The network controller internal method `_switchNetwork` has been made
async, and the `lookupNetwork` call is now awaited. Because this method
is only used internally, and because the `await`-ed async operation was
the last operation in this function, this change has no functional
impact whatsoever.

Relates to https://github.com/MetaMask/metamask-extension/issues/18587
This commit is contained in:
Mark Stacey 2023-04-14 14:53:57 -02:30 committed by GitHub
parent 40e4a3653f
commit d85d2318a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -904,14 +904,14 @@ export class NetworkController extends EventEmitter {
* @param providerConfig - The provider configuration object that specifies
* the new network.
*/
_switchNetwork(providerConfig: ProviderConfiguration): void {
async _switchNetwork(providerConfig: ProviderConfiguration) {
this.messenger.publish(NetworkControllerEventType.NetworkWillChange);
this._resetNetworkId();
this._resetNetworkStatus();
this._resetNetworkDetails();
this._configureProvider(providerConfig);
this.messenger.publish(NetworkControllerEventType.NetworkDidChange);
this.lookupNetwork();
await this.lookupNetwork();
}
/**