From c9211a9e341f951097769b3c4fce9d94f20f1c60 Mon Sep 17 00:00:00 2001 From: Kurdistan Tech Ministry Date: Mon, 2 Mar 2026 01:04:06 +0300 Subject: [PATCH] fix: compare referrer addresses in SS58 format for pending approvals --- src/lib/citizenship.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/lib/citizenship.ts b/src/lib/citizenship.ts index 3476533..28f1868 100644 --- a/src/lib/citizenship.ts +++ b/src/lib/citizenship.ts @@ -167,11 +167,17 @@ export async function getPendingApprovals( for (const [key, value] of entries) { const applicantAddress = key.args[0].toString(); + + // Use codec .toString() for SS58, fallback to toJSON() for hex comparison + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const appValue = value as any; + const referrerSS58 = appValue?.referrer?.toString?.() || ''; // eslint-disable-next-line @typescript-eslint/no-explicit-any const appData = value.toJSON() as any; + const identityHash = appData?.identityHash || appValue?.identityHash?.toHex?.() || ''; - // Check if this application's referrer matches - if (!appData?.referrer || appData.referrer !== referrerAddress) { + // Compare referrer in SS58 format (codec toString returns SS58) + if (!referrerSS58 || referrerSS58 !== referrerAddress) { continue; } @@ -180,7 +186,7 @@ export async function getPendingApprovals( if (status === 'PendingReferral') { pending.push({ applicantAddress, - identityHash: appData.identityHash || '', + identityHash: typeof identityHash === 'string' ? identityHash : '', }); } }