From 5bdc80e3ed5625a7fd1c60cf67aa77afff3d2e90 Mon Sep 17 00:00:00 2001 From: Kurdistan Tech Ministry Date: Sat, 28 Feb 2026 01:59:04 +0300 Subject: [PATCH] fix: use dynamic SS58 prefix in referral/KYC address encoding Replace hardcoded SS58 prefix 42 with api.registry.chainSS58 ?? 42 for robustness in getPendingApprovalsForReferrer, getReferralInfo, and getMyReferrals functions. --- shared/lib/citizenship-workflow.ts | 3 ++- shared/lib/referral.ts | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/shared/lib/citizenship-workflow.ts b/shared/lib/citizenship-workflow.ts index 9ba9351b..03bcc41b 100644 --- a/shared/lib/citizenship-workflow.ts +++ b/shared/lib/citizenship-workflow.ts @@ -790,7 +790,8 @@ export async function getPendingApprovalsForReferrer( let referrerSS58 = ''; try { if (appData.referrer) { - referrerSS58 = encodeAddress(appData.referrer as string, 42); + const ss58Prefix = api.registry.chainSS58 ?? 42; + referrerSS58 = encodeAddress(appData.referrer as string, ss58Prefix); } } catch { referrerSS58 = appData.referrer?.toString() ?? ''; diff --git a/shared/lib/referral.ts b/shared/lib/referral.ts index 87fbda40..9d16ac67 100644 --- a/shared/lib/referral.ts +++ b/shared/lib/referral.ts @@ -166,7 +166,7 @@ export async function getReferralInfo( // toJSON() returns hex for AccountId, convert to SS58 let referrerSS58 = data.referrer ?? ''; try { - if (data.referrer) referrerSS58 = encodeAddress(data.referrer, 42); + if (data.referrer) referrerSS58 = encodeAddress(data.referrer, api.registry.chainSS58 ?? 42); } catch { /* keep hex as fallback */ } return { referrer: referrerSS58, @@ -274,7 +274,7 @@ export async function getMyReferrals( // toJSON() returns hex for AccountId, convert to SS58 for comparison let refSS58 = ''; try { - if (data.referrer) refSS58 = encodeAddress(data.referrer, 42); + if (data.referrer) refSS58 = encodeAddress(data.referrer, api.registry.chainSS58 ?? 42); } catch { refSS58 = data.referrer ?? ''; }