From 63027314f6f8926727182f99cf4804e8d3222b27 Mon Sep 17 00:00:00 2001 From: Kurdistan Tech Ministry Date: Sat, 1 Nov 2025 11:30:58 +0300 Subject: [PATCH] feat: Add real-time trust score display in Wallet Dashboard - Fetch trust score from blockchain via api.query.trust.trustScores - Display trust score in AccountBalance component (Account Info card) - Show between Address and Source fields with Award icon - Use purple-cyan gradient styling for visual consistency Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/components/AccountBalance.tsx | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/components/AccountBalance.tsx b/src/components/AccountBalance.tsx index b390db6c..10d0921a 100644 --- a/src/components/AccountBalance.tsx +++ b/src/components/AccountBalance.tsx @@ -1,7 +1,7 @@ import React, { useEffect, useState } from 'react'; import { usePolkadot } from '@/contexts/PolkadotContext'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; -import { Wallet, TrendingUp, ArrowUpRight, ArrowDownRight, RefreshCw } from 'lucide-react'; +import { Wallet, TrendingUp, ArrowUpRight, ArrowDownRight, RefreshCw, Award } from 'lucide-react'; import { Button } from '@/components/ui/button'; export const AccountBalance: React.FC = () => { @@ -16,6 +16,7 @@ export const AccountBalance: React.FC = () => { total: '0', }); const [pezBalance, setPezBalance] = useState('0'); + const [trustScore, setTrustScore] = useState('-'); const [isLoading, setIsLoading] = useState(false); const fetchBalance = async () => { @@ -69,6 +70,24 @@ export const AccountBalance: React.FC = () => { useEffect(() => { fetchBalance(); + // Fetch Trust Score + const fetchTrustScore = async () => { + if (!api || !isApiReady || !selectedAccount?.address) { + setTrustScore('-'); + return; + } + + try { + const score = await api.query.trust.trustScores(selectedAccount.address); + setTrustScore(score.toString()); + } catch (err) { + console.error('Failed to fetch trust score:', err); + setTrustScore('-'); + } + }; + + fetchTrustScore(); + // Subscribe to HEZ balance updates let unsubscribeHez: () => void; let unsubscribePez: () => void; @@ -235,6 +254,15 @@ export const AccountBalance: React.FC = () => { {selectedAccount.address.slice(0, 8)}...{selectedAccount.address.slice(-8)} +
+ + + Trust Score + + + {trustScore} + +