From 96d6277a0f9714bd7fa8ce57b4216adc16d6f47b Mon Sep 17 00:00:00 2001 From: Kurdistan Tech Ministry Date: Sat, 1 Nov 2025 10:44:17 +0300 Subject: [PATCH] feat: Add real-time trust score to wallet dashboard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fetch trust score from pallet_trust via API - Display score in WalletModal with Award icon - Shows user's current trust score from blockchain - Gradient styling (purple to cyan) for visual appeal - Fallback to '-' when API not ready or score unavailable 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/components/wallet/WalletModal.tsx | 50 ++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 8 deletions(-) diff --git a/src/components/wallet/WalletModal.tsx b/src/components/wallet/WalletModal.tsx index b378e7af..9252c96b 100644 --- a/src/components/wallet/WalletModal.tsx +++ b/src/components/wallet/WalletModal.tsx @@ -1,5 +1,5 @@ -import React, { useState } from 'react'; -import { Wallet, Chrome, ExternalLink, Copy, Check, LogOut } from 'lucide-react'; +import React, { useState, useEffect } from 'react'; +import { Wallet, Chrome, ExternalLink, Copy, Check, LogOut, Award } from 'lucide-react'; import { Dialog, DialogContent, @@ -17,16 +17,19 @@ interface WalletModalProps { } export const WalletModal: React.FC = ({ isOpen, onClose }) => { - const { - accounts, - selectedAccount, + const { + accounts, + selectedAccount, setSelectedAccount, - connectWallet, + connectWallet, disconnectWallet, - error + api, + isApiReady, + error } = usePolkadot(); - + const [copied, setCopied] = useState(false); + const [trustScore, setTrustScore] = useState('-'); const handleCopyAddress = () => { if (selectedAccount?.address) { @@ -50,6 +53,27 @@ export const WalletModal: React.FC = ({ isOpen, onClose }) => onClose(); }; + // Fetch trust score from blockchain + useEffect(() => { + const fetchTrustScore = async () => { + if (!api || !isApiReady || !selectedAccount?.address) { + setTrustScore('-'); + return; + } + + try { + const score = await api.query.trust.trustScoreOf(selectedAccount.address); + setTrustScore(score.toString()); + console.log('✅ Trust score fetched:', score.toString()); + } catch (err) { + console.warn('Failed to fetch trust score:', err); + setTrustScore('-'); + } + }; + + fetchTrustScore(); + }, [api, isApiReady, selectedAccount]); + return ( @@ -125,6 +149,16 @@ export const WalletModal: React.FC = ({ isOpen, onClose }) => +
+
Trust Score
+
+ + + {trustScore} + +
+
+
Source