fix: use getAllScoresWithFallback in Dashboard.tsx

Both AccountBalance.tsx and Dashboard.tsx now use the same
frontend fallback for trust score calculation until runtime upgrade.
This commit is contained in:
2026-02-07 01:48:06 +03:00
parent e787eaac15
commit e12d08d356
3 changed files with 6 additions and 97 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 684 KiB

-91
View File
@@ -1,91 +0,0 @@
import { ApiPromise, WsProvider } from '@pezkuwi/api';
async function checkAllPools() {
const provider = new WsProvider('wss://asset-hub-rpc.pezkuwichain.io');
const api = await ApiPromise.create({ provider });
console.log('Connected to Asset Hub\n');
const userAddress = '5CyuFfbF95rzBxru7c9yEsX4XmQXUxpLUcbj9RLg9K1cGiiF';
// Get all pools
const poolKeys = await api.query.assetConversion.pools.keys();
console.log('=== ALL POOLS ===');
console.log('Total pools found:', poolKeys.length, '\n');
for (const key of poolKeys) {
const poolPair = key.args[0];
console.log('Pool key:', JSON.stringify(poolPair.toHuman()));
const poolInfo = await api.query.assetConversion.pools(poolPair);
if (!poolInfo.isEmpty) {
const poolData = poolInfo.unwrap().toJSON();
console.log('LP Token ID:', poolData.lpToken);
// Get LP supply
const lpAsset = await api.query.poolAssets.asset(poolData.lpToken);
if (lpAsset.isSome) {
const supply = lpAsset.unwrap().toJSON().supply;
console.log('Total LP Supply:', Number(BigInt(supply)) / 1e12);
}
// Get user's LP balance
const userLp = await api.query.poolAssets.account(poolData.lpToken, userAddress);
if (userLp.isSome) {
const balance = userLp.unwrap().toJSON().balance;
console.log('User LP Balance:', Number(BigInt(balance)) / 1e12);
} else {
console.log('User LP Balance: 0');
}
// Try to get price
try {
const asset1 = poolPair[0];
const asset2 = poolPair[1];
const oneUnit = BigInt(1e12);
const quote = await api.call.assetConversionApi.quotePriceExactTokensForTokens(
asset1,
asset2,
oneUnit.toString(),
true
);
if (quote && !quote.isNone) {
console.log('Price (1 asset1 -> asset2):', Number(BigInt(quote.unwrap().toString())) / 1e12);
}
} catch {
// Try with 6 decimals for USDT
try {
const asset1 = poolPair[0];
const asset2 = poolPair[1];
const oneUnit = BigInt(1e12);
const quote = await api.call.assetConversionApi.quotePriceExactTokensForTokens(
asset1,
asset2,
oneUnit.toString(),
true
);
if (quote && !quote.isNone) {
console.log('Price (1 asset1 -> asset2):', Number(BigInt(quote.unwrap().toString())) / 1e6, 'USDT');
}
} catch {
console.log('Could not get price');
}
}
}
console.log('---');
}
// Check all LP token balances for user
console.log('\n=== USER LP TOKEN BALANCES ===');
for (let lpId = 0; lpId < 5; lpId++) {
const userLp = await api.query.poolAssets.account(lpId, userAddress);
if (userLp.isSome) {
const balance = userLp.unwrap().toJSON().balance;
console.log(`LP Token ${lpId}: ${Number(BigInt(balance)) / 1e12}`);
}
}
await api.disconnect();
}
checkAllPools().catch(console.error);
+6 -6
View File
@@ -10,7 +10,7 @@ import { supabase } from '@/lib/supabase';
import { User, Mail, Phone, Globe, MapPin, Calendar, Shield, AlertCircle, ArrowLeft, Award, Users, TrendingUp, UserMinus, Play, Loader2 } from 'lucide-react';
import { useToast } from '@/hooks/use-toast';
import { fetchUserTikis, getPrimaryRole, getTikiDisplayName, getTikiColor, getTikiEmoji, getUserRoleCategories, getAllTikiNFTDetails, generateCitizenNumber, type TikiNFTDetails } from '@pezkuwi/lib/tiki';
import { getAllScores, getStakingScoreStatus, startScoreTracking, type UserScores, type StakingScoreStatus, formatDuration } from '@pezkuwi/lib/scores';
import { getAllScoresWithFallback, getStakingScoreStatus, startScoreTracking, type UserScores, type StakingScoreStatus, formatDuration } from '@pezkuwi/lib/scores';
import { web3FromAddress } from '@pezkuwi/extension-dapp';
import { getKycStatus } from '@pezkuwi/lib/kyc';
import { ReferralDashboard } from '@/components/referral/ReferralDashboard';
@@ -108,10 +108,10 @@ export default function Dashboard() {
setLoadingScores(true);
try {
// Fetch all scores from blockchain (includes trust, referral, staking, tiki)
// - Trust, referral, tiki, stakingScore: People Chain
// - Staking amount: Relay Chain (staking.ledger)
const allScores = await getAllScores(peopleApi, selectedAccount.address, api);
// Fetch all scores with frontend fallback (until runtime upgrade)
// - Trust, referral, tiki: People Chain (on-chain)
// - Staking: Relay Chain with frontend fallback
const allScores = await getAllScoresWithFallback(peopleApi, api, selectedAccount.address);
setScores(allScores);
// Fetch staking score tracking status
@@ -452,7 +452,7 @@ export default function Dashboard() {
{loadingScores ? '...' : scores.trustScore}
</div>
<p className="text-xs text-muted-foreground">
From pallet_trust
Frontend calculation
</p>
</CardContent>
</Card>