From 10c8deeadb8ee17f06f76438e1df3210b9f95afc Mon Sep 17 00:00:00 2001 From: Makoto Inoue <2630+makoto@users.noreply.github.com> Date: Mon, 13 Nov 2023 19:04:34 +0000 Subject: [PATCH] Fix wildcard for subname --- crosschain-resolver/scripts/getaddr.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/crosschain-resolver/scripts/getaddr.ts b/crosschain-resolver/scripts/getaddr.ts index a768c768..a018ba65 100644 --- a/crosschain-resolver/scripts/getaddr.ts +++ b/crosschain-resolver/scripts/getaddr.ts @@ -1,6 +1,4 @@ -import hre from 'hardhat'; import packet from 'dns-packet'; -const abi = ['function name(bytes32) view returns(string)']; const encodeName = (name) => '0x' + packet.name.encode(name).toString('hex') const l1abi = [ "function getTarget(bytes,uint256) view returns (bytes32, address)", @@ -25,7 +23,14 @@ export const main = async () => { const l1provider = new ethers.JsonRpcProvider(L1_PROVIDER_URL); const l2provider = new ethers.JsonRpcProvider(L2_PROVIDER_URL); - const resolver = await l1provider.getResolver(ENS_NAME) + let resolver = await l1provider.getResolver(ENS_NAME) + // Wildcard seems not working. A workaround for now + if(!resolver){ + const parentName = ENS_NAME.split('.').slice(1).join('.') + console.log(`Resolver not found on ${ENS_NAME}. Looking up ${parentName}`) + resolver = await l1provider.getResolver(parentName) + } + console.log({ENS_NAME, resolver, encodedname, node}) const l1resolver = new ethers.Contract(resolver.address, l1abi, l1provider); const target = await l1resolver.getTarget(encodedname, 0) const l2resolverAddress = target[1]