diff --git a/src/base/registrations/registrar.ts b/src/base/registrations/registrar.ts index 3a2a1a91e..0cb589067 100644 --- a/src/base/registrations/registrar.ts +++ b/src/base/registrations/registrar.ts @@ -6,7 +6,7 @@ import type { TypedDataSigner } from "@ethersproject/abstract-signer"; import * as session from "@app/session"; import { Failure } from "@app/error"; import type { Config } from "@app/config"; -import { unixTime } from "@app/utils"; +import { isFulfilled, unixTime } from "@app/utils"; import { assert } from "@app/error"; import { Seed, InvalidSeed } from "@app/base/seeds/Seed"; import * as cache from "@app/cache"; @@ -105,9 +105,7 @@ export async function getRegistration( anchorsAccount, twitter, github, - ] = meta.map(r => - r.status === "fulfilled" && r.value ? r.value : undefined, - ); + ] = meta.filter(isFulfilled).map(r => (r.value ? r.value : undefined)); const profile: EnsProfile = { name, diff --git a/src/profile.ts b/src/profile.ts index 25f335eb0..e89487e0d 100644 --- a/src/profile.ts +++ b/src/profile.ts @@ -9,6 +9,7 @@ import { parseUsername, AddressType, identifyAddress, + isFulfilled, } from "@app/utils"; import type { Config } from "@app/config"; import { cached } from "@app/cache"; @@ -215,10 +216,10 @@ export class Profile { const profilePromises = addressesOrNames.map(addressOrName => this.lookupProfile(addressOrName, ProfileType.Minimal, config), ); - const profiles = await Promise.all(profilePromises); - return profiles.map(profile => { - return new Profile(profile); - }); + const profiles = await Promise.allSettled(profilePromises); + return profiles + .filter(isFulfilled) + .map(profile => new Profile(profile.value)); } static async get( diff --git a/src/project.ts b/src/project.ts index cdb19f95b..2a90ea139 100644 --- a/src/project.ts +++ b/src/project.ts @@ -2,7 +2,7 @@ import { navigate } from "svelte-routing"; import { get, writable } from "svelte/store"; import { type Host, Request } from "@app/api"; import type { Commit, CommitHeader, CommitsHistory } from "@app/commit"; -import { isOid, isRadicleId } from "@app/utils"; +import { isFulfilled, isOid, isRadicleId } from "@app/utils"; import { Profile, ProfileType } from "@app/profile"; import { Seed } from "@app/base/seeds/Seed"; import type { Config } from "@app/config"; @@ -498,9 +498,6 @@ export class Project implements ProjectInfo { ); } const results = await Promise.allSettled(promises); - const isFulfilled = ( - input: PromiseSettledResult, - ): input is PromiseFulfilledResult => input.status === "fulfilled"; return results.filter(isFulfilled).map(r => r.value); } diff --git a/src/utils.ts b/src/utils.ts index bead68223..c15174e4f 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -350,7 +350,7 @@ export function isDid(input: string): boolean { export function isENSName(input: string, config: Config): boolean { const domain = config.registrar.domain.replace(".", "\\."); - const regEx = new RegExp(`^[a-zA-Z0-9]+.${domain}$`); + const regEx = new RegExp(`^[a-zA-Z0-9]+.(${domain}|eth)$`); return regEx.test(input); } @@ -359,6 +359,12 @@ export function isAddress(input: string): boolean { return ethers.utils.isAddress(input); } +export function isFulfilled( + input: PromiseSettledResult, +): input is PromiseFulfilledResult { + return input.status === "fulfilled"; +} + // Get search parameters from location. export function getSearchParam( key: string, @@ -556,9 +562,7 @@ export async function resolveEnsProfile( const [avatar, address, seed, anchorsAccount] = // Just checking for r.value equal null and casting to undefined, // since resolver functions return null. - project.map(r => - r.status === "fulfilled" && r.value ? r.value : null, - ); + project.filter(isFulfilled).map(r => (r.value ? r.value : null)); return { name,