Jump to org in resolver

This commit is contained in:
Alexis Sellier
2021-06-03 12:07:31 +02:00
parent 86df6db88e
commit 8e598eeef3
2 changed files with 14 additions and 2 deletions
+9 -2
View File
@@ -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 {
+5
View File
@@ -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<string | null> {
return config.provider.resolveName(`${label}.${config.registrar.domain}`);
}