fix(frontend): missing useTokenBalance hook causes /trade tab to crash after clean node_modules reinstall #231
Labels
No labels
agent:fix_bugfix
agent:fix_conflicts
agent:fix_security
agent:gap_analysis
agent:implement
agent:implement
agent:implement
agent:open_issues
agent:ready
agent:research
agent:security_audit
agent:verify
architecture
backend
blocker:hybrid
blocker:launch
blocker:limit-orders
blocker:v2
block:log_only
block:security
bug
ci
contracts
correctness
deploy
dev
devops
docs
documentation
duplicate
e2e
enhancement
epic
feature
frontend
functional-completion
gas
good first issue
governance
help wanted
high-risk
hooks
hybrid
indexer
infra
infrastructure
integrators
invalid
launch-blocker
limit-orders
localnet
localterra
low priority
missing-implementation
needs-design
ops
performance
priority
high
priority
medium
product
qa
QA
question
ready
ready
research
scripts
security
security-hardening
smartcontracts
tech-debt
testing
ux
UX
v2
verification
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
code/cl8y-dex-terraclassic#231
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Issue Summary
The
/tradepage fails to load with a Vite import resolution error after runningrm -rf node_modules && npm install. The import@/hooks/useTokenBalancereferenced inuseLimitLadderPlaceGates.tspoints to a file that does not exist anywhere in the repository.Reproduction Steps
308a04a3c310a8f02e11bc3bb03a67ecff01b5f5rm -rf node_modules && npm installVITE_NETWORK=local npm run dev/tradetabExpected Behavior
The
/tradepage loads without errors.Actual Behavior
Vite throws a pre-transform error and the page fails to render:
The entire
/tradetab is broken. Other tabs are unaffected.Root Cause
useLimitLadderPlaceGates.tswas introduced in commit8685909with an import ofuseTokenBalancethat was never created. The filesrc/hooks/useTokenBalance.tshas no entry in git history at any point. The hookuseLimitOrderEscrowBalancealready exists with the same signature(walletAddress, tokenAddr)and the same query key shape — it is the likely intended dependency.Why It Only Surfaced After
rm -rf node_modulesThe error was silently masked until a clean
npm installforced Vite to fully re-resolve all module imports from scratch. Prior runs with an existingnode_modulescache did not trigger the transform for that specific module path.Suggested Fix
Either create
src/hooks/useTokenBalance.tsas a wrapper or re-export ofuseLimitOrderEscrowBalance, or update the import inuseLimitLadderPlaceGates.tsto useuseLimitOrderEscrowBalancedirectly.Environment Details
localterra(local Docker)VITE_NETWORK=local npm run dev308a04a3c310a8f02e11bc3bb03a67ecff01b5f58685909Wallet / Device Details
/tradeonlySeverity / Impact
dev environment blocker. The
/tradetab is completely non-functional after any clean install. The error is not visible untilnode_modulesis wiped, so it could silently persist in CI or on a fresh machine checkout. Fix is low-effort: wire the existinguseLimitOrderEscrowBalancehook in place of the missing one.cc: @PlasticDigits
mentioned in commit
543ca7008aFix landed on
main(543ca70)Summary:
useLimitLadderPlaceGatesnow importsuseLimitOrderEscrowBalancedirectly (the hook that was always intended for limit escrow CW20 balance).useTokenBalanceis a re-export only — no duplicateduseQuerylogic — so a cleanrm -rf node_modules && npm installcannot hit a missing@/hooks/useTokenBalancemodule again.Docs / agent playbooks: Invariants and cross-links added in
docs/limit-orders.md,docs/frontend.md, andskills/AGENTS_LIMIT_ORDER_BATCH_LADDER.md(GitLab #231).Regression test:
frontend-dapp/src/hooks/__tests__/useTokenBalance.test.tsassertsuseTokenBalance === useLimitOrderEscrowBalance.Verification checklist
cd frontend-dapp && rm -rf node_modules && npm cinpm test -- useTokenBalance limitOrderLaddernpm run build(ortsc -b && vite build) completes with noFailed to resolve import "@/hooks/useTokenBalance"VITE_NETWORK=local npm run dev— open/limits, expand Ladder panel; page loads without Vite pre-transform errorstokenBalancecache with retail limit on/tradeand/limits)@brouie — please run the checklist above on a fresh checkout of
mainand confirm #231 is resolved. Leaving this issue open until verified./cc @PlasticDigits
Verification checklist
cd frontend-dapp && rm -rf node_modules && npm cinpm test -- useTokenBalance limitOrderLaddernpm run build(ortsc -b && vite build) completes with noFailed to resolve import "@/hooks/useTokenBalance"VITE_NETWORK=local npm run dev— open/limits, expand Ladder panel; page loads without Vite pre-transform errorstokenBalancecache with retail limit on/tradeand/limits)Good to go , looks clean to go
mentioned in issue #233
mentioned in issue #268