Reduce calls to IDX profile streams

Check first for a ENS profile and in case it returns null, go for the
IDX profile.

Signed-off-by: Sebastian Martinez <sebastinez@me.com>
This commit is contained in:
Sebastian Martinez
2021-09-14 15:12:40 +02:00
parent 75983dc98e
commit 5015018b6e
+4 -7
View File
@@ -100,13 +100,10 @@ export class Profile {
}
try {
const [ens, idx] = await Promise.allSettled([
resolveEnsProfile(address, profileType, config),
resolveIdxProfile(formatCAIP10Address(address, "eip155", config.network.chainId), config)
]);
if (ens.status == "fulfilled") profile.ens = ens.value;
if (idx.status == "fulfilled") profile.idx = idx.value;
profile.ens = await resolveEnsProfile(address, profileType, config);
if (!profile.ens) {
profile.idx = await resolveIdxProfile(formatCAIP10Address(address, "eip155", config.network.chainId), config);
}
} catch (error) {
console.error(error);
}