Skip to content

Commit

Permalink
refactor EnsController setEthProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
kanthesha committed Jul 30, 2024
1 parent 98eadd3 commit 2d801c1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/ens-controller/src/EnsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,18 +288,20 @@ export class EnsController extends BaseController<
selectedNetworkClientId: string,
registriesByChainId?: Record<number, Hex>,
) {
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)],
Expand Down

0 comments on commit 2d801c1

Please sign in to comment.