Skip to content

[Wave 150pts] Fix: GET /wallets/balances returns 404 — update path to /users/wallet/balances in lib/api/wallet.ts #166

@portableDD

Description

@portableDD

Summary

The wallet balance API call is hitting the wrong URL and returning 404 on every request. This is the highest-priority frontend bug identified in the API audit because it causes WithdrawalForm.tsx to display an error banner on every load for every authenticated user.

Root Cause

lib/api/wallet.ts calls /wallets/balances but the correct backend path is /users/wallet/balances. Live probe confirmed:

  • GET /v1/wallets/balances404 Not Found ("Cannot GET /v1/wallets/balances")
  • GET /v1/users/wallet/balances401 Unauthorized (route exists and is protected)

Impact

  • WithdrawalForm.tsx calls getBalances() on mount. Because getBalances() always throws (404), the component lands on its error state and shows "Unable to load currencies or balances. Please try again." for every authenticated user — the form is unusable.
  • components/dashboard/account-overview.tsx has a TODO comment to wire up getBalances() once this path is fixed. Once this issue is resolved, that wiring can proceed (tracked in a separate issue).

What Needs to Be Done

File: lib/api/wallet.ts

Change:

const data = await apiClient<any>("/wallets/balances", {

To:

const data = await apiClient<any>("/users/wallet/balances", {

Also check whether useProxy should be true (routed via /api/proxy) or false (direct call). All other authenticated calls in lib/api/users.ts use useProxy: false — verify with the backend team which pattern applies here and update accordingly.

Acceptance Criteria

  • lib/api/wallet.ts calls /users/wallet/balances
  • getBalances() no longer throws a 404 when called with a valid token
  • WithdrawalForm.tsx no longer shows the error banner on load for authenticated users
  • useProxy value is confirmed and documented in a code comment

Constraints

  • Do not change WithdrawalForm.tsx logic in this PR — the path fix in lib/api/wallet.ts is the only required change
  • Complexity: Low — 150 points

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions