From dffacee9a5b655ac502b1f53d1cf41fa75644d6c Mon Sep 17 00:00:00 2001 From: ahsan-javaiid Date: Tue, 7 Mar 2023 18:04:08 +0500 Subject: [PATCH] fix: fix rns resolution --- src/components/GeneralLookupField.tsx | 4 +--- src/services/EthService/network/helpers.ts | 13 ++++++++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/components/GeneralLookupField.tsx b/src/components/GeneralLookupField.tsx index dd813fbbec6..eca96891b02 100644 --- a/src/components/GeneralLookupField.tsx +++ b/src/components/GeneralLookupField.tsx @@ -10,7 +10,6 @@ import { ProviderHandler } from '@services/EthService'; import { createENSResolutionError, isResolutionError } from '@services/EthService/ens'; -import { selectDefaultNetwork, useSelector } from '@store'; import { ErrorObject, IReceiverAddress, Network } from '@types'; import AddressLookupSelector, { LabeledAddress } from './AddressLookupSelector'; @@ -52,7 +51,6 @@ const GeneralLookupField = ({ setFieldTouched, setFieldError }: IGeneralLookupFieldComponentProps) => { - const ethNetwork = useSelector(selectDefaultNetwork); const errorMessage = error && Object.prototype.hasOwnProperty.call(error, 'message') ? (error as ErrorObject).message @@ -139,7 +137,7 @@ const GeneralLookupField = ({ setIsResolvingDomain(true); setResolutionError(undefined); try { - const provider = new ProviderHandler(ethNetwork); + const provider = new ProviderHandler(network); const resolvedAddress = await provider.resolveName(domain, network); if (!resolvedAddress) { throw new ResolutionError(ResolutionErrorCode.UnregisteredDomain, { domain }); diff --git a/src/services/EthService/network/helpers.ts b/src/services/EthService/network/helpers.ts index 2f3281d65f6..2eb9eef696c 100644 --- a/src/services/EthService/network/helpers.ts +++ b/src/services/EthService/network/helpers.ts @@ -7,6 +7,11 @@ import { ETHERSCAN_API_KEY } from '@config'; import { DPathFormat, Network, NodeOptions, NodeType } from '@types'; import { FallbackProvider } from '@vendor'; +const CHAIN_ID_TO_REGISTRY: { [key: number]: string } = { + 30: '0xcb868aeabd31e2b66f74e9a55cf064abb31a4ad5', + 31: '0x7d284aaac6e925aad802a53c0c69efe3764597b8' +}; + const getProvider = (node: NodeOptions, chainId: number) => { const { type, url } = node; if (type === NodeType.ETHERSCAN) { @@ -25,7 +30,13 @@ const getProvider = (node: NodeOptions, chainId: number) => { chainId ); } - return new StaticJsonRpcProvider(connection, chainId); + + const provider = new StaticJsonRpcProvider(connection, chainId); + if ([30, 31].includes(chainId)) { + provider.network.ensAddress = CHAIN_ID_TO_REGISTRY[chainId]; + } + + return provider; }; export const createCustomNodeProvider = (network: Network): BaseProvider => {