Skip to content

Commit

Permalink
fix: process review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ariesgun committed Oct 21, 2024
1 parent ad58dcb commit 80443f0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
20 changes: 9 additions & 11 deletions src/handlers/query-wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,17 @@ export async function registerWallet(context: Context, body: string) {
const ensName = extractEnsName(body.replace("/wallet", "").trim());

if (!address && ensName) {
context.logger.debug("Trying to resolve address from ENS name", { ensName });
logger.debug("Trying to resolve address from ENS name", { ensName });
address = await resolveAddress(ensName);
if (!address) {
throw new Error(`Resolving address from ENS name failed: ${ensName}`);
}
context.logger.debug("Resolved address from ENS name", { ensName, address });
logger.debug("Resolved address from ENS name", { ensName, address });
}

if (!address) {
const message = "Skipping to register a wallet address because both address/ens doesn't exist";
await addCommentToIssue(context, `\`\`\`diff\n# ${message}`);
context.logger.info(message);
const logMessage = logger.info("Skipping to register a wallet address because both address/ens doesn't exist");
await addCommentToIssue(context, logMessage.logMessage.diff);
return;
}

Expand All @@ -42,9 +41,9 @@ export async function registerWallet(context: Context, body: string) {
}

if (address == ethers.ZeroAddress) {
const message = "Skipping to register a wallet address because user is trying to set their address to null address";
await addCommentToIssue(context, `\`\`\`diff\n! ${message}`);
logger.error(message);
const logMessage = logger.error("Skipping to register a wallet address because user is trying to set their address to null address");
await addCommentToIssue(context, logMessage.logMessage.diff);

return;
}

Expand All @@ -55,9 +54,8 @@ export async function registerWallet(context: Context, body: string) {
const { wallet } = adapters.supabase;
await wallet.upsertWalletAddress(context, address);

const message = "Successfully registered wallet address";
await addCommentToIssue(context, `\`\`\`diff\n# ${message}`);
context.logger.ok(message, { sender, address });
const message = logger.ok("Successfully registered wallet address", { sender, address });
await addCommentToIssue(context, message.logMessage.diff);
} else {
throw new Error("Payload comment is undefined");
}
Expand Down
8 changes: 0 additions & 8 deletions src/types/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,4 @@ export interface Context<T extends SupportedEventsU = SupportedEventsU, TU exten
config: PluginSettings;
env: Env;
logger: Logs;
// {
// fatal: (message: unknown, ...optionalParams: unknown[]) => void;
// error: (message: unknown, ...optionalParams: unknown[]) => Promise<void>;
// warn: (message: unknown, ...optionalParams: unknown[]) => void;
// info: (message: unknown, ...optionalParams: unknown[]) => Promise<void>;
// ok: (message: unknown, ...optionalParams: unknown[]) => Promise<void>;
// debug: (message: unknown, ...optionalParams: unknown[]) => void;
// };
}

0 comments on commit 80443f0

Please sign in to comment.