Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added missing logs #22

Merged
merged 1 commit into from
Apr 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions src/fellows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,40 @@ export const fetchAllFellows = async (
const getGhHandle = async (
address: SS58String,
): Promise<string | undefined> => {
logger.debug(`Fetching identity of '${address}'`);
const identity =
await relayApi.query.Identity.IdentityOf.getValue(address);

if (identity)
return identity.info.additional
if (identity) {
const handle = identity.info.additional
.find(([key]) => key.value?.asText() === "github")?.[1]
.value?.asText()
.replace("@", "");
if (handle) {
logger.info(`Found github handle for '${address}': '${handle}'`);
} else {
logger.debug(`'${address}' does not have a GitHub handle`);
}
return handle;
}

logger.debug(
`Identity of '${address}' is null. Checking for super identity`,
);

const superIdentityAddress = (
await relayApi.query.Identity.SuperOf.getValue(address)
)?.[0];
return await (superIdentityAddress && getGhHandle(superIdentityAddress));

if (superIdentityAddress) {
logger.debug(
`'${address}' has a super identity: '${superIdentityAddress}'. Fetching that identity`,
);
return await getGhHandle(superIdentityAddress);
} else {
logger.debug(`No superidentity for ${address} found.`);
return undefined;
}
};

logger.info("Initializing the collectives client");
Expand Down
Loading