Skip to content

Commit

Permalink
added missing logs (#22)
Browse files Browse the repository at this point in the history
Added logs that were removed during #20

This logs are necessary because, if the action is failing with a
specific user, having their address can be very helpful at debugging.
  • Loading branch information
Bullrich authored Apr 4, 2024
1 parent a5b239d commit b01c274
Showing 1 changed file with 24 additions and 3 deletions.
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

0 comments on commit b01c274

Please sign in to comment.