From d079c10d94cde2a7899953c85b0d237ea75933c6 Mon Sep 17 00:00:00 2001 From: ChaituVR Date: Fri, 20 Dec 2024 23:25:57 +0530 Subject: [PATCH] fix: validate resolver address before setting snapshot text record --- apps/ui/src/helpers/ens.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/apps/ui/src/helpers/ens.ts b/apps/ui/src/helpers/ens.ts index 259a77a45..6da139284 100644 --- a/apps/ui/src/helpers/ens.ts +++ b/apps/ui/src/helpers/ens.ts @@ -111,8 +111,17 @@ export async function setEnsTextRecord( const ensHash = namehash(ensNormalize(ens)); + const resolverAddress = await call( + getProvider(chainId), + ENS_CONTRACTS.registryAbi, + [ENS_CONTRACTS.registry, 'resolver', [ensHash]] + ); + + if (!resolvers.includes(resolverAddress)) + throw new Error('Unsupported resolver'); + const contract = new Contract( - resolvers[0], + resolverAddress, ENS_CONTRACTS.resolverAbi, signer );