mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-04-22 13:37:59 +00:00
fix: query nominators from Asset Hub, treasury balances from both chains
NetworkStats now queries staking.nominators from Asset Hub instead of Relay Chain (staking migrated to AH). Treasury hook fetches HEZ from RC and PEZ from AH (asset 1) for accurate balance display.
This commit is contained in:
@@ -81,15 +81,17 @@ export const NetworkStats: React.FC = () => {
|
||||
if (import.meta.env.DEV) console.warn('Failed to fetch People Chain collators', err);
|
||||
}
|
||||
|
||||
// 3. Count Nominators
|
||||
// 3. Count Nominators from Asset Hub (staking migrated to AH)
|
||||
let nCount = 0;
|
||||
try {
|
||||
const nominators = await api.query.staking?.nominators.entries();
|
||||
if (nominators) {
|
||||
nCount = nominators.length;
|
||||
if (isAssetHubReady && assetHubApi?.query.staking?.nominators) {
|
||||
const nominators = await assetHubApi.query.staking.nominators.entries();
|
||||
if (nominators) {
|
||||
nCount = nominators.length;
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
if (import.meta.env.DEV) console.warn('Staking pallet not available, nominators = 0');
|
||||
if (import.meta.env.DEV) console.warn('Staking pallet not available on AH, nominators = 0');
|
||||
}
|
||||
|
||||
setValidatorCount(vCount);
|
||||
|
||||
@@ -77,7 +77,7 @@ export const TreasuryOverview: React.FC = () => {
|
||||
{t('treasury.liveData')}
|
||||
</Badge>
|
||||
<span className="text-sm text-muted-foreground">
|
||||
{t('treasury.activeProposals', { count: proposals.length })} • {t('treasury.hezInTreasury', { amount: metrics.totalBalance.toFixed(2) })}
|
||||
{t('treasury.activeProposals', { count: proposals.length })} • {metrics.pezBalance.toLocaleString(undefined, { maximumFractionDigits: 2 })} PEZ • {metrics.hezBalance.toLocaleString(undefined, { maximumFractionDigits: 4 })} HEZ
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -117,7 +117,8 @@ export const TreasuryOverview: React.FC = () => {
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<p className="text-sm text-muted-foreground">{t('treasury.totalBalance')}</p>
|
||||
<p className="text-2xl font-bold">${(metrics.totalBalance / 1000000).toFixed(2)}M</p>
|
||||
<p className="text-lg font-bold">{metrics.pezBalance.toLocaleString(undefined, { maximumFractionDigits: 2 })} PEZ</p>
|
||||
<p className="text-sm font-semibold text-muted-foreground">{metrics.hezBalance.toLocaleString(undefined, { maximumFractionDigits: 4 })} HEZ</p>
|
||||
<p className="text-xs text-green-500 flex items-center mt-1">
|
||||
<ArrowUpRight className="h-3 w-3 mr-1" />
|
||||
{t('treasury.thisMonth', { percent: '12.5' })}
|
||||
|
||||
Reference in New Issue
Block a user