From 2d801c182f933cc089864c9424615ed8c9f6f19c Mon Sep 17 00:00:00 2001 From: Kanthesha Devaramane Date: Tue, 30 Jul 2024 10:47:29 +0100 Subject: [PATCH] refactor EnsController setEthProvider --- packages/ens-controller/src/EnsController.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/ens-controller/src/EnsController.ts b/packages/ens-controller/src/EnsController.ts index 55fcc0b006f..e3f4247ca82 100644 --- a/packages/ens-controller/src/EnsController.ts +++ b/packages/ens-controller/src/EnsController.ts @@ -288,18 +288,20 @@ export class EnsController extends BaseController< selectedNetworkClientId: string, registriesByChainId?: Record, ) { - const selectedNetworkClient = this.messagingSystem.call( + const { + configuration: { chainId: currentChainId }, + provider, + } = this.messagingSystem.call( 'NetworkController:getNetworkClientById', selectedNetworkClientId, ); - const currentChainId = selectedNetworkClient.configuration.chainId; if ( registriesByChainId && registriesByChainId[parseInt(currentChainId, 16)] && this.#getChainEnsSupport(currentChainId) ) { - this.#ethProvider = new Web3Provider(selectedNetworkClient.provider, { + this.#ethProvider = new Web3Provider(provider, { chainId: convertHexToDecimal(currentChainId), name: CHAIN_ID_TO_ETHERS_NETWORK_NAME_MAP[currentChainId as ChainId], ensAddress: registriesByChainId[parseInt(currentChainId, 16)],