From 6ac55ecf88efd103b71428d1285ed67dcf97fa98 Mon Sep 17 00:00:00 2001 From: Kurdistan Tech Ministry Date: Fri, 20 Feb 2026 00:44:05 +0300 Subject: [PATCH] fix: citizenship pending approvals not showing for founder Application struct has no status field - was filtering by appData.status === 'PendingReferral' which always returned false. Now checks kycStatuses storage instead, and allows founder to see all pending applications. --- shared/lib/citizenship-workflow.ts | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/shared/lib/citizenship-workflow.ts b/shared/lib/citizenship-workflow.ts index dbda6595..01ff6e82 100644 --- a/shared/lib/citizenship-workflow.ts +++ b/shared/lib/citizenship-workflow.ts @@ -788,14 +788,25 @@ export async function getPendingApprovalsForReferrer( const applicantAddress = key.args[0].toString(); const appData = (value as any).toJSON() as Record; - if ( - appData.status === 'PendingReferral' && - appData.referrer?.toString() === referrerAddress - ) { - pending.push({ - applicantAddress, - identityHash: (appData.identityHash as string) || '' - }); + // Application struct has { identityHash, referrer } - no status field. + // An application is "pending" if it exists in applications but is NOT yet + // approved in kycStatuses. Check referrer matches current user, or current + // user is the founder (can approve any application). + const isReferrer = appData.referrer?.toString() === referrerAddress; + const isFounder = referrerAddress === FOUNDER_ADDRESS; + + if (isReferrer || isFounder) { + // Check if already approved via kycStatuses + const kycStatus = await api.query.identityKyc.kycStatuses(applicantAddress); + const statusStr = kycStatus.isEmpty ? null : kycStatus.toString(); + + // Pending = not yet approved (no status or PendingReferral) + if (!statusStr || statusStr === 'PendingReferral') { + pending.push({ + applicantAddress, + identityHash: (appData.identityHash as string) || '' + }); + } } }