mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-29 02:00:31 +08:00
Refactor isFulfilled check into a utils function
Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
This commit is contained in:
+8
-4
@@ -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<T>(
|
||||
input: PromiseSettledResult<T>,
|
||||
): input is PromiseFulfilledResult<T> {
|
||||
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,
|
||||
|
||||
Reference in New Issue
Block a user