From 8e598eeef31ee89d61cc3bcac4cef9ba2e2f8d4a Mon Sep 17 00:00:00 2001 From: Alexis Sellier Date: Thu, 3 Jun 2021 12:07:31 +0200 Subject: [PATCH] Jump to org in resolver --- src/base/resolver/Query.svelte | 11 +++++++++-- src/utils.ts | 5 +++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/base/resolver/Query.svelte b/src/base/resolver/Query.svelte index 95f353772..6f9ce158e 100644 --- a/src/base/resolver/Query.svelte +++ b/src/base/resolver/Query.svelte @@ -11,7 +11,7 @@ let error = false; - onMount(() => { + onMount(async () => { if (query) { if (ethers.utils.isAddress(query)) { // Go to org. @@ -24,7 +24,14 @@ if (label.includes(".")) { error = true; } else { - navigate(`/registrations/${label}`, { replace: true }); + // Jump straight to org, if the ENS entry points to an org. Otherwise just go to the + // registration. + const address = await utils.resolveLabel(label, config); + if (address && await utils.identifyAddress(address, config) === utils.AddressType.Org) { + navigate(`/orgs/${address}`, { replace: true }); + } else { + navigate(`/registrations/${label}`, { replace: true }); + } } } } else { diff --git a/src/utils.ts b/src/utils.ts index 7a954e68c..0d0a74aa1 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -138,3 +138,8 @@ export async function identifyAddress(address: string, config: Config): Promise< } return AddressType.EOA; } + +// Resolve a label under the radicle domain. +export async function resolveLabel(label: string, config: Config): Promise { + return config.provider.resolveName(`${label}.${config.registrar.domain}`); +}