Fix two pre-existing type errors breaking next build on main - #246
Fix two pre-existing type errors breaking next build on main#246Bryandero98 wants to merge 2 commits into
Conversation
getPoolHistory's declared return type was a single object (Promise<{date,tvl,truncated?}>) while every actual return path (the success-path Array.from(...).map(...) and the catch-all []) is an array — the annotation was just missing its []. TvlChart.tsx's setData(history) call surfaced this as a real type error.
soroban.ts also uses the Account type (Promise<Account>, Map<string,{account:Account,...}>) in 4 places without importing it from @stellar/stellar-sdk.
Found while investigating why PR SmartDropLabs#215's CI was failing - main itself does not currently pass 'next build' or 'tsc --noEmit', independent of that PR. A third, unrelated error remains after these two fixes: useLeaderboard.ts calls sorobanService.getLeaderboard(offset, limit, sortKey, search) with a 4th argument that method doesn't accept - the frontend search UI (debounce, state) is fully wired up but the backend method was never extended to filter by it. That's incomplete feature work, not a typo, so it's left for whoever owns that feature to finish rather than guessed at here.
❌ Deploy Preview for spiffy-melomakarona-eb1e8a failed.
|
❌ Deploy Preview for smart-drop failed.
|
useLeaderboard.ts already called sorobanService.getLeaderboard() with a 4th `search` argument, but the method only accepted 3 params — this was issue SmartDropLabs#3 flagged (and deliberately left unfixed) in this PR's original description, and it's what's failing Netlify's preview build/deploy for this PR: `next build` type-checks the whole app, and the extra argument is a TS2345 error regardless of the two fixes already in this branch. - API path (fetchLeaderboardFromApi): forwards `search` as a `search` query param, same pattern as offset/limit/sort. - Event-scan fallback (fetchLeaderboardFromEvents): filters the aggregated rows by a case-insensitive substring match on address, applied before pagination so `total` reflects the filtered count.
|
Update + a transparency note on the Netlify failures: Pushed a fix for the third pre-existing bug this PR originally flagged but left alone: Separately, I dug into why Netlify itself was still failing even after that fix. I don't have dashboard access to Netlify's actual build logs, but the same commit also triggers a This reproduces on I didn't fix the lockfile myself: I only have npm 11 / Node 24 locally, and regenerating |
Unrelated to this PR's env-validation change, but next build type-checks the whole app, so these also block this branch's own Netlify preview: - getPoolHistory's return type was missing the array brackets - the implementation always returns an array (via .map(...) on success or [] on catch), so every caller consuming it as a single object was wrong. - Account was used (accountCache/inflightAccount maps) but never imported from @stellar/stellar-sdk. Same root-cause fix as PR SmartDropLabs#246 (opened separately against main, since these bugs pre-date this branch); applying it here directly too so this PR's own Netlify checks aren't blocked on SmartDropLabs#246 landing first.
Unrelated to any feature work — found while investigating why PR #215's CI kept failing. Confirmed on a clean checkout of
mainwith no other changes:npm run build/npx tsc --noEmitcurrently fail before this fix.The two fixes
getPoolHistory's return type was missing[]. Declared asPromise<{ date: string; tvl: string; truncated?: boolean }>(a single object), but every real return path — the success path (Array.from(dailyMap.entries())...map(...)) and the catch-all[]— is an array.TvlChart.tsx'ssetData(history)surfaces this asType error: Argument of type '{...}' is not assignable to parameter of type 'SetStateAction<TvlDataPoint[]>'. Existing tests insoroban.service.test.tsalready assert array results (.resolves.toEqual([...])), so this is a pure type-annotation fix with no behavior change.Account(from@stellar/stellar-sdk) is used in 4 places insoroban.ts(Promise<Account>,Map<string, { account: Account; ... }>) but was never imported —error TS2304: Cannot find name 'Account'.What's left (not fixed here, on purpose)
After these two,
tsc --noEmitstill reports one more, unrelated error:useLeaderboard.ts:24callssorobanService.getLeaderboard(offset, limit, sortKey, search)with a 4th argument, butgetLeaderboardonly accepts 3. The frontend search UI (debounced input,searchQuerystate) is fully built expecting this to work — it's incomplete backend feature work, not a typo, so I didn't guess at the filtering semantics. Flagging it here so it doesn't get lost; happy to take a stab at it in a follow-up if someone can confirm what "search" should match against (address? nothing else obviously identifies an entry).Testing
npx tsc --noEmit: down to just theuseLeaderboard.tserror above.npx vitest run src/lib/soroban.service.test.ts src/lib/soroban.test.ts: same pass/fail counts before and after this change (3 pre-existing failures ingetLeaderboard'sboostUtilizationassertions, unrelated to either fix here — confirmed by running the same suite against untouchedmain).