mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-04-22 02:07:55 +00:00
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.
This commit is contained in:
@@ -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() ?? '';
|
||||
|
||||
@@ -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 ?? '';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user