fix(rwallet): show all chains with activity, fix chain filter stats
- Backend: detect chains where Safe has transaction history even if current balance is zero (queries all-transactions?limit=1) - Frontend: stats (Total Value, Tokens) now update when clicking chain filter buttons instead of always showing all-chain totals Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
d7c1501d4f
commit
6d20a275ff
|
|
@ -3285,8 +3285,8 @@ class FolkWalletViewer extends HTMLElement {
|
||||||
private renderDashboard(): string {
|
private renderDashboard(): string {
|
||||||
if (!this.hasData()) return "";
|
if (!this.hasData()) return "";
|
||||||
|
|
||||||
// Aggregate stats across ALL chains (ignoring filter)
|
// Stats reflect current filter (all chains when no filter active)
|
||||||
const allBalances = this.getUnifiedBalances(true);
|
const allBalances = this.getUnifiedBalances();
|
||||||
const totalUSD = allBalances.reduce((sum, b) => sum + parseFloat(b.fiatBalance || "0"), 0);
|
const totalUSD = allBalances.reduce((sum, b) => sum + parseFloat(b.fiatBalance || "0"), 0);
|
||||||
const totalTokens = allBalances.filter((b) => {
|
const totalTokens = allBalances.filter((b) => {
|
||||||
const fiat = parseFloat(b.fiatBalance || "0");
|
const fiat = parseFloat(b.fiatBalance || "0");
|
||||||
|
|
|
||||||
|
|
@ -702,6 +702,21 @@ routes.get("/api/safe/:address/all-balances", async (c) => {
|
||||||
if (chainBalances.length > 0) {
|
if (chainBalances.length > 0) {
|
||||||
const enriched = await enrichWithPrices(chainBalances, chainId, { filterSpam: true });
|
const enriched = await enrichWithPrices(chainBalances, chainId, { filterSpam: true });
|
||||||
results.push({ chainId, chainName: info.name, balances: enriched });
|
results.push({ chainId, chainName: info.name, balances: enriched });
|
||||||
|
} else {
|
||||||
|
// Safe exists on this chain (API returned 200) but has zero balance.
|
||||||
|
// Check if there are any historical transactions (>$0 activity).
|
||||||
|
try {
|
||||||
|
const txRes = await fetch(
|
||||||
|
`${safeApiBase(info.prefix)}/safes/${address}/all-transactions/?limit=1&executed=true`,
|
||||||
|
{ signal: AbortSignal.timeout(5000) },
|
||||||
|
);
|
||||||
|
if (txRes.ok) {
|
||||||
|
const txData = await txRes.json() as { count?: number; results?: any[] };
|
||||||
|
if (txData.results && txData.results.length > 0) {
|
||||||
|
results.push({ chainId, chainName: info.name, balances: [] });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch {}
|
||||||
}
|
}
|
||||||
} catch {}
|
} catch {}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue