MCPcopy Create free account
hub / github.com/AmazingAng/PolyWorld / fetchBal

Function fetchBal

src/components/WalletButton.tsx:303–316  ·  view source on GitHub ↗
(force = false)

Source from the content-addressed store, hash-verified

301 let seq = 0;
302
303 const fetchBal = async (force = false) => {
304 const mySeq = ++seq;
305 try {
306 // Public GET endpoint — no auth required, reads on-chain USDC.e balance
307 const url = `/api/trade/balance?address=${proxyAddr}${force ? "&force=1" : ""}`;
308 const res = await fetch(url);
309 if (!res.ok) return;
310 const data = await res.json();
311 if (!cancelled && mySeq === seq && data.balance !== undefined) {
312 setPolyBalance(data.balance);
313 try { sessionStorage.setItem("pw:balance", String(data.balance)); } catch {}
314 }
315 } catch { /* ignore */ }
316 };
317
318 const fetchPortfolio = async () => {
319 try {

Callers 2

WalletButtonFunction · 0.85
onRefreshEvFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected