mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-06-13 05:31:01 +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 = '';
|
let referrerSS58 = '';
|
||||||
try {
|
try {
|
||||||
if (appData.referrer) {
|
if (appData.referrer) {
|
||||||
referrerSS58 = encodeAddress(appData.referrer as string, 42);
|
const ss58Prefix = api.registry.chainSS58 ?? 42;
|
||||||
|
referrerSS58 = encodeAddress(appData.referrer as string, ss58Prefix);
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
referrerSS58 = appData.referrer?.toString() ?? '';
|
referrerSS58 = appData.referrer?.toString() ?? '';
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ export async function getReferralInfo(
|
|||||||
// toJSON() returns hex for AccountId, convert to SS58
|
// toJSON() returns hex for AccountId, convert to SS58
|
||||||
let referrerSS58 = data.referrer ?? '';
|
let referrerSS58 = data.referrer ?? '';
|
||||||
try {
|
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 */ }
|
} catch { /* keep hex as fallback */ }
|
||||||
return {
|
return {
|
||||||
referrer: referrerSS58,
|
referrer: referrerSS58,
|
||||||
@@ -274,7 +274,7 @@ export async function getMyReferrals(
|
|||||||
// toJSON() returns hex for AccountId, convert to SS58 for comparison
|
// toJSON() returns hex for AccountId, convert to SS58 for comparison
|
||||||
let refSS58 = '';
|
let refSS58 = '';
|
||||||
try {
|
try {
|
||||||
if (data.referrer) refSS58 = encodeAddress(data.referrer, 42);
|
if (data.referrer) refSS58 = encodeAddress(data.referrer, api.registry.chainSS58 ?? 42);
|
||||||
} catch {
|
} catch {
|
||||||
refSS58 = data.referrer ?? '';
|
refSS58 = data.referrer ?? '';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user