{#each members as address}
- {#await Profile.get(address, config)}
+ {#await Profile.get(address, ProfileType.Minimal, config)}
{:then profile}
diff --git a/src/base/projects/Browser.svelte b/src/base/projects/Browser.svelte
index 85fc74017..b31cea8ed 100644
--- a/src/base/projects/Browser.svelte
+++ b/src/base/projects/Browser.svelte
@@ -1,6 +1,7 @@
@@ -191,18 +194,14 @@
{/if}
- {#if org}
+ {#if orgAddress}
{#await getAnchor}
{:then anchor}
{#if anchor === commit}
anchored
- {#await Org.getProfile(org, config)}
-
- {:then profile}
-
- {/await}
+
{:else}
diff --git a/src/base/projects/View.svelte b/src/base/projects/View.svelte
index ef1d7a049..b23d775f6 100644
--- a/src/base/projects/View.svelte
+++ b/src/base/projects/View.svelte
@@ -6,6 +6,7 @@
import Modal from '@app/Modal.svelte';
import Avatar from '@app/Avatar.svelte';
import { Org } from '@app/base/orgs/Org';
+ import type { Profile } from '@app/profile';
import Browser from './Browser.svelte';
@@ -16,16 +17,17 @@
export let path: string;
let projectRoot = proj.path({ urn, org, commit });
- let getProject = new Promise(resolve => {
+ let getProject = new Promise(resolve => {
if (org) {
- Org.getProfile(org, config).then(p => resolve(p?.seed || null));
+ Org.getProjectProfile(org, config).then(p => resolve(p));
} else {
resolve(null);
}
- }).then(async (seed) => {
+ }).then(async (orgProfile) => {
+ const seed = orgProfile?.seed;
const cfg = seed ? config.withSeed(seed) : config;
const info = await proj.getInfo(urn, cfg);
- return { project: info, config: cfg };
+ return { project: info, config: cfg, org: orgProfile };
});
const back = () => window.history.back();
@@ -96,7 +98,7 @@
{:catch}
diff --git a/src/base/registrations/View.svelte b/src/base/registrations/View.svelte
index 08424972b..1bf790339 100644
--- a/src/base/registrations/View.svelte
+++ b/src/base/registrations/View.svelte
@@ -46,8 +46,8 @@
.then(async r => {
if (r) {
let reverseRecord = false;
- if (r.address) {
- reverseRecord = await isReverseRecordSet(r.address, name, config);
+ if (r.profile.address) {
+ reverseRecord = await isReverseRecordSet(r.profile.address, name, config);
}
fields = [
@@ -62,25 +62,25 @@
+ "For this name to be correctly associated with the address, "
+ "a reverse record should be set."
),
- value: r.address, editable: true },
+ value: r.profile.address, editable: true },
{ name: "url", label: "URL", validate: "url", placeholder: "https://acme.org",
description: "A homepage or other URL associated with this name.",
- value: r.url,editable: true },
+ value: r.profile.url,editable: true },
{ name: "avatar", validate: "url", placeholder: "https://acme.org/avatar.png",
description: "An avatar or square image associated with this name.",
- value: r.avatar, editable: true },
+ value: r.profile.avatar, editable: true },
{ name: "twitter", validate: "handle", placeholder: "Twitter username, eg. 'acme'",
description: "The Twitter handle associated with this name.",
- value: r.twitter, editable: true },
+ value: r.profile.twitter, editable: true },
{ name: "github", validate: "handle", label: "GitHub", placeholder: "GitHub username, eg. 'acme'",
description: "The GitHub username associated with this name.",
- value: r.github, editable: true },
+ value: r.profile.github, editable: true },
{ name: "seed.id", label: "Seed ID", placeholder: "hynkyn...3nrzc@seed.acme.org:8887",
description: "The ID of a Radicle Link node that hosts entities associated with this name.",
- value: r.seedId, editable: true },
+ value: r.profile.seedId, editable: true },
{ name: "seed.api", label: "Seed API", validate: "url", placeholder: "https://seed.acme.org:8888",
description: "The HTTP address of a node that serves Radicle entities over HTTP.",
- value: r.seedApi, editable: true },
+ value: r.profile.seedApi, editable: true },
];
state = { status: Status.Found, registration: r };
} else {
diff --git a/src/base/registrations/registrar.ts b/src/base/registrations/registrar.ts
index 54ce882ce..3c3addab8 100644
--- a/src/base/registrations/registrar.ts
+++ b/src/base/registrations/registrar.ts
@@ -10,8 +10,14 @@ import { unixTime } from '@app/utils';
import { assert } from '@app/error';
export interface Registration {
- name: string;
owner: string;
+ profile: EnsProfile;
+ resolver: EnsResolver;
+}
+
+export interface EnsProfile {
+ name: string;
+ owner?: string;
address: string | null;
seedId: string | null;
seedApi: string | null;
@@ -19,7 +25,6 @@ export interface Registration {
avatar: string | null;
twitter: string | null;
github: string | null;
- resolver: EnsResolver;
}
export enum State {
@@ -76,19 +81,41 @@ export async function getRegistration(name: string, config: Config): Promise r.status == "fulfilled" ? r.value : null);
return {
- name,
- url,
- avatar,
- seedId,
- seedApi,
owner,
- address,
- twitter,
- github,
resolver,
+ profile: {
+ name,
+ url,
+ avatar,
+ seedId,
+ seedApi,
+ address,
+ twitter,
+ github,
+ },
};
}
+export async function getAvatar(name: string, config: Config): Promise {
+ name = name.toLowerCase();
+
+ const resolver = await config.provider.getResolver(name);
+ if (! resolver) {
+ return null;
+ }
+ return resolver.getText('avatar');
+}
+
+export async function getSeed(name: string, config: Config): Promise {
+ name = name.toLowerCase();
+
+ const resolver = await config.provider.getResolver(name);
+ if (! resolver) {
+ return null;
+ }
+ return resolver.getText('eth.radicle.seed.api');
+}
+
export function registrar(config: Config): ethers.Contract {
return new ethers.Contract(config.registrar.address, config.abi.registrar, config.provider);
}
diff --git a/src/base/users/View.svelte b/src/base/users/View.svelte
index 551598e43..50c23669c 100644
--- a/src/base/users/View.svelte
+++ b/src/base/users/View.svelte
@@ -3,7 +3,7 @@
import Icon from '@app/Icon.svelte';
import Address from '@app/Address.svelte';
import Avatar from '@app/Avatar.svelte';
- import { Profile } from '@app/profile';
+ import { ProfileType, Profile } from '@app/profile';
import Loading from '@app/Loading.svelte';
import { Org } from '@app/base/orgs/Org';
import Message from '@app/Message.svelte';
@@ -57,7 +57,7 @@
}
-{#await Profile.get(address, config)}
+{#await Profile.get(address, ProfileType.Full, config)}
{:then profile}
diff --git a/src/profile.ts b/src/profile.ts
index 3eb1a7eda..d41af7e19 100644
--- a/src/profile.ts
+++ b/src/profile.ts
@@ -1,5 +1,5 @@
import { ethers } from "ethers";
-import type { Registration } from "@app/base/registrations/registrar";
+import type { EnsProfile } from "@app/base/registrations/registrar";
import type { BasicProfile } from "@ceramicstudio/idx-constants";
import {
formatCAIP10Address, formatIpfsFile, resolveEnsProfile, resolveIdxProfile, parseUsername,
@@ -7,10 +7,16 @@ import {
import type { Config } from "./config";
export interface IProfile {
- ens: Registration | null;
+ ens: EnsProfile | null;
idx: BasicProfile | null;
}
+export enum ProfileType {
+ Full,
+ Minimal,
+ Project,
+}
+
export class Profile {
profile: IProfile;
address: string;
@@ -21,7 +27,7 @@ export class Profile {
}
// Get the ENS profile
- get ens(): Registration | null {
+ get ens(): EnsProfile | null {
return this.profile.ens;
}
@@ -80,7 +86,11 @@ export class Profile {
}
// Keeping this function private since the desired entrypoint is .get()
- private static async lookupAddress(address: string, config: Config): Promise<[IProfile, string]> {
+ private static async lookupAddress(
+ address: string,
+ profileType: ProfileType,
+ config: Config
+ ): Promise<[IProfile, string]> {
const profile: IProfile = { ens: null, idx: null };
try {
@@ -91,7 +101,7 @@ export class Profile {
try {
const [ens, idx] = await Promise.allSettled([
- resolveEnsProfile(address, config),
+ resolveEnsProfile(address, profileType, config),
resolveIdxProfile(formatCAIP10Address(address, "eip155", config.network.chainId), config)
]);
@@ -105,16 +115,17 @@ export class Profile {
}
static async getMulti(addresses: string[], config: Config): Promise {
- const profilePromises = addresses.map(address => this.lookupAddress(address, config));
+ const profilePromises = addresses.map(address => this.lookupAddress(address, ProfileType.Minimal, config));
const profiles = await Promise.all(profilePromises);
return profiles.map(profile => { return new Profile(...profile); });
}
static async get(
address: string,
+ profileType: ProfileType,
config: Config,
): Promise {
- const profile = await this.lookupAddress(address, config);
+ const profile = await this.lookupAddress(address, profileType, config);
return new Profile(...profile);
}
}
diff --git a/src/utils.ts b/src/utils.ts
index f71edde22..35e974ed1 100644
--- a/src/utils.ts
+++ b/src/utils.ts
@@ -6,10 +6,10 @@ import EthersSafe from "@gnosis.pm/safe-core-sdk";
import type { Config } from '@app/config';
import config from "@app/config.json";
import { assert } from '@app/error';
-import type { Registration } from "@app/base/registrations/registrar";
-import { getRegistration } from '@app/base/registrations/registrar';
+import type { EnsProfile } from "@app/base/registrations/registrar";
+import { getAvatar, getSeed, getRegistration } from '@app/base/registrations/registrar';
import type { BasicProfile } from "@ceramicstudio/idx-constants";
-
+import { ProfileType } from '@app/profile';
export enum AddressType {
Contract,
@@ -246,10 +246,42 @@ export async function resolveIdxProfile(caip10: string, config: Config): Promise
}
// Resolves an ENS profile or return null
-export async function resolveEnsProfile(address: string, config: Config): Promise {
+export async function resolveEnsProfile(address: string, profileType: ProfileType, config: Config): Promise {
const name = await config.provider.lookupAddress(address);
if (name) {
- return await getRegistration(name, config);
+ if (profileType === ProfileType.Full) {
+ const registration = await getRegistration(name, config);
+ if (registration) {
+ return registration.profile;
+ }
+ } else if (profileType === ProfileType.Project) {
+ const avatar = await getAvatar(name, config);
+ const seedApi = await getSeed(name, config);
+
+ return {
+ name,
+ address,
+ avatar,
+ seedApi,
+ url: null,
+ seedId: null,
+ twitter: null,
+ github: null,
+ };
+ } else if (profileType === ProfileType.Minimal) {
+ const avatar = await getAvatar(name, config);
+
+ return {
+ name,
+ address,
+ avatar,
+ url: null,
+ seedId: null,
+ seedApi: null,
+ twitter: null,
+ github: null,
+ };
+ }
}
return null;
}
{urn}
{result.project.meta.description}
-