diff --git a/src/components/HeroSection.tsx b/src/components/HeroSection.tsx index cb7cdf5b..b871622e 100644 --- a/src/components/HeroSection.tsx +++ b/src/components/HeroSection.tsx @@ -1,10 +1,48 @@ -import React from 'react'; +import React, { useState, useEffect } from 'react'; import { useTranslation } from 'react-i18next'; import { ChevronRight, Cpu, GitBranch, Shield } from 'lucide-react'; import { NetworkStats } from './NetworkStats'; +import { usePolkadot } from '../contexts/PolkadotContext'; +import { formatBalance } from '../lib/wallet'; const HeroSection: React.FC = () => { const { t } = useTranslation(); + const { api, isApiReady } = usePolkadot(); + const [stats, setStats] = useState({ + activeProposals: 0, + totalVoters: 0, + tokensStaked: '0', + trustScore: 0 + }); + + useEffect(() => { + const fetchStats = async () => { + if (!api || !isApiReady) return; + + try { + // Fetch active referenda + let activeProposals = 0; + try { + const referendaCount = await api.query.referenda.referendumCount(); + activeProposals = referendaCount.toNumber(); + } catch (err) { + console.warn('Failed to fetch referenda:', err); + } + + // Update stats + setStats({ + activeProposals, + totalVoters: 0, // TODO: Calculate from conviction voting + tokensStaked: '0', // TODO: Get from staking pallet + trustScore: 0 // TODO: Calculate trust score + }); + } catch (error) { + console.error('Failed to fetch hero stats:', error); + } + }; + + fetchStats(); + }, [api, isApiReady]); return (
@@ -43,19 +81,19 @@ const HeroSection: React.FC = () => {
-
127
+
{stats.activeProposals}
{t('hero.stats.activeProposals')}
-
3,482
+
{stats.totalVoters || '-'}
{t('hero.stats.totalVoters')}
-
2.1M
+
{stats.tokensStaked || '-'}
{t('hero.stats.tokensStaked')}
-
95%
+
{stats.trustScore ? `${stats.trustScore}%` : '-'}
{t('hero.stats.trustScore')}