Skip to content

Commit

Permalink
Refactor useResolveAddressMultiChain to utilize mainnet client for EN…
Browse files Browse the repository at this point in the history
…S address resolution
  • Loading branch information
Da-Colon committed Dec 16, 2024
1 parent c7b41c5 commit 4cbf0c5
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/hooks/utils/useResolveAddressMultiChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,18 @@ export const useResolveAddressMultiChain = () => {
setIsLoading(false);
return returnedResult;
}
const mainnet = supportedNetworks.find(network => network.chain.id === 1);
if (!mainnet) {
throw new Error('Mainnet not found');
}

const mainnetPublicClient = createPublicClient({
chain: mainnet.chain,
transport: http(mainnet.rpcEndpoint),
});
for (const network of supportedNetworks) {
const client = createPublicClient({
chain: network.chain,
transport: http(network.rpcEndpoint),
});
try {
const resolvedAddress = await client.getEnsAddress({ name: normalizedName });
const resolvedAddress = await mainnetPublicClient.getEnsAddress({ name: normalizedName });
if (resolvedAddress) {
returnedResult.resolved.push({
address: resolvedAddress,
Expand Down

0 comments on commit 4cbf0c5

Please sign in to comment.