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

Improve error logging #1052

Merged
merged 1 commit into from
Nov 18, 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
71 changes: 41 additions & 30 deletions web/api/v2/verify/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,39 +138,50 @@ export async function POST(
});
}

// ANCHOR: Verify the proof with the World ID smart contract
const { error, success } = await verifyProof(
{
signal_hash: parsedParams.signal_hash,
proof: parsedParams.proof,
merkle_root: parsedParams.merkle_root,
nullifier_hash: parsedParams.nullifier_hash,
external_nullifier: action.external_nullifier,
},
{
is_staging: app.is_staging,
verification_level: parsedParams.verification_level,
max_age: parsedParams.max_age,
},
);

if (error || !success) {
await captureEvent({
event: "action_verify_failed",
distinctId: action.id,
properties: {
action_id: action.id,
app_id: app.id,
environment: app.is_staging ? "staging" : "production",
try {
// ANCHOR: Verify the proof with the World ID smart contract
const { error, success } = await verifyProof(
{
signal_hash: parsedParams.signal_hash,
proof: parsedParams.proof,
merkle_root: parsedParams.merkle_root,
nullifier_hash: parsedParams.nullifier_hash,
external_nullifier: action.external_nullifier,
},
{
is_staging: app.is_staging,
verification_level: parsedParams.verification_level,
error: error,
max_age: parsedParams.max_age,
},
});
);

if (error || !success) {
await captureEvent({
event: "action_verify_failed",
distinctId: action.id,
properties: {
action_id: action.id,
app_id: app.id,
environment: app.is_staging ? "staging" : "production",
verification_level: parsedParams.verification_level,
error: error,
},
});
return errorResponse({
statusCode: error?.statusCode || 400,
code: error?.code || AppErrorCodes.GenericError,
detail: error?.message || "There was an error verifying this proof.",
attribute: error?.attribute || null,
req,
});
}
} catch (e: any) {
console.warn("Error verifying proof", { error: e });
return errorResponse({
statusCode: error?.statusCode || 400,
code: error?.code || AppErrorCodes.GenericError,
detail: error?.message || "There was an error verifying this proof.",
attribute: error?.attribute || null,
statusCode: 400,
code: "verification_error",
detail: e.message,
attribute: null,
req,
});
}
Expand Down
Loading