From e3beba7538144c4a2e42ef97ecf4d4fa233608d1 Mon Sep 17 00:00:00 2001 From: Kurdistan Tech Ministry Date: Sun, 1 Mar 2026 22:08:40 +0300 Subject: [PATCH] fix: correct KycLevel enum map and restrict founder bypass 1. Fixed enum map missing NotStarted at index 0, causing all status indices to be off by one (ReferrerApproved decoded as PendingReferral) 2. Restricted founder bypass to only show applications with no referrer, not all applications regardless of referrer --- shared/lib/citizenship-workflow.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/shared/lib/citizenship-workflow.ts b/shared/lib/citizenship-workflow.ts index 03bcc41b..bdaf4a68 100644 --- a/shared/lib/citizenship-workflow.ts +++ b/shared/lib/citizenship-workflow.ts @@ -798,8 +798,9 @@ export async function getPendingApprovalsForReferrer( } const isReferrer = referrerSS58 === referrerAddress; const isFounder = referrerAddress === FOUNDER_ADDRESS; + const hasNoReferrer = !appData.referrer || referrerSS58 === ''; - if (isReferrer || isFounder) { + if (isReferrer || (isFounder && hasNoReferrer)) { // Check if already approved via kycStatuses const kycStatus = await api.query.identityKyc.kycStatuses(applicantAddress); @@ -815,7 +816,7 @@ export async function getPendingApprovalsForReferrer( // Parse status — toJSON() can return string, object, or number: // string: "PendingReferral" / "pendingReferral" // object: { "pendingReferral": null } - // number: enum index (0=PendingReferral, 1=ReferrerApproved, 2=Approved, 3=Revoked) + // number: enum index (0=NotStarted, 1=PendingReferral, 2=ReferrerApproved, 3=Approved, 4=Revoked) const statusJson = kycStatus.toJSON?.() ?? kycStatus.toString(); let statusKey = ''; if (typeof statusJson === 'string') { @@ -823,7 +824,7 @@ export async function getPendingApprovalsForReferrer( } else if (typeof statusJson === 'object' && statusJson !== null) { statusKey = Object.keys(statusJson)[0]?.toLowerCase() ?? ''; } else if (typeof statusJson === 'number') { - const enumMap: Record = { 0: 'pendingreferral', 1: 'referrerapproved', 2: 'approved', 3: 'revoked' }; + const enumMap: Record = { 0: 'notstarted', 1: 'pendingreferral', 2: 'referrerapproved', 3: 'approved', 4: 'revoked' }; statusKey = enumMap[statusJson] ?? ''; }