Skip to content

Fix two pre-existing type errors breaking next build on main - #246

Open
Bryandero98 wants to merge 2 commits into
SmartDropLabs:mainfrom
Bryandero98:fix/pool-history-type-and-missing-account-import
Open

Fix two pre-existing type errors breaking next build on main#246
Bryandero98 wants to merge 2 commits into
SmartDropLabs:mainfrom
Bryandero98:fix/pool-history-type-and-missing-account-import

Conversation

@Bryandero98

Copy link
Copy Markdown

Unrelated to any feature work — found while investigating why PR #215's CI kept failing. Confirmed on a clean checkout of main with no other changes: npm run build / npx tsc --noEmit currently fail before this fix.

The two fixes

  1. getPoolHistory's return type was missing []. Declared as Promise<{ 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's setData(history) surfaces this as Type error: Argument of type '{...}' is not assignable to parameter of type 'SetStateAction<TvlDataPoint[]>'. Existing tests in soroban.service.test.ts already assert array results (.resolves.toEqual([...])), so this is a pure type-annotation fix with no behavior change.
  2. Account (from @stellar/stellar-sdk) is used in 4 places in soroban.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 --noEmit still reports one more, unrelated error: useLeaderboard.ts:24 calls sorobanService.getLeaderboard(offset, limit, sortKey, search) with a 4th argument, but getLeaderboard only accepts 3. The frontend search UI (debounced input, searchQuery state) 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 the useLeaderboard.ts error 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 in getLeaderboard's boostUtilization assertions, unrelated to either fix here — confirmed by running the same suite against untouched main).

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.
@netlify

netlify Bot commented Aug 25, 2026

Copy link
Copy Markdown

Deploy Preview for spiffy-melomakarona-eb1e8a failed.

Name Link
🔨 Latest commit cf7b635
🔍 Latest deploy log https://app.netlify.com/projects/spiffy-melomakarona-eb1e8a/deploys/6a8dff3737df1e0008324edc

@netlify

netlify Bot commented Aug 25, 2026

Copy link
Copy Markdown

Deploy Preview for smart-drop failed.

Name Link
🔨 Latest commit cf7b635
🔍 Latest deploy log https://app.netlify.com/projects/smart-drop/deploys/6a8dff377ca3dc00098390ef

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.
@Bryandero98

Copy link
Copy Markdown
Author

Update + a transparency note on the Netlify failures:

Pushed a fix for the third pre-existing bug this PR originally flagged but left alone: useLeaderboard.ts was already calling sorobanService.getLeaderboard(offset, limit, sortKey, search) with a search argument that getLeaderboard() didn't accept (next build type-checks the whole app, so this alone was enough to fail the build regardless of the other two fixes). Added search to getLeaderboard, threaded through to both the API path (as a search query param) and the event-scan fallback (case-insensitive substring filter on address, applied before pagination). Added test coverage for both paths. next build now passes locally end-to-end.

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 deploy GitHub Actions job (publishing to gh-pages), and that log is public. It fails at the npm ci step, before any build/type-check runs:

npm error `npm ci` can only install packages when your package.json and package-lock.json ... are in sync.
npm error Missing: @next/bundle-analyzer@15.5.24 from lock file
npm error Missing: webpack-bundle-analyzer@4.10.1 from lock file
... (11 more missing transitive deps)

This reproduces on main itself, not just this branch — package-lock.json is out of sync with package.json (missing the @next/bundle-analyzer subtree) repo-wide. Given the ~25s fail time on Netlify's own checks for this PR (too fast to be a real build), I'm confident this is the same root cause there.

I didn't fix the lockfile myself: I only have npm 11 / Node 24 locally, and regenerating package-lock.json with a newer toolchain than CI's (npm 10.8.2 / Node 20.20.2, per the Actions log) produced a much larger diff than the missing packages alone would explain — not something I want to commit without verifying against the same npm/Node version CI actually uses. Flagging it here with the exact missing packages so whoever has that environment can run a plain npm install and commit the refreshed lock file — that should unblock both this PR's Netlify preview and main's own deploy.

Bryandero98 added a commit to Bryandero98/smartdrop-frontend that referenced this pull request Aug 26, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant