Skip to content

Fix Horizon client config reactivity and placeOrder balance pre-validation - #162

Merged
akargi merged 3 commits into
Chulilee:mainfrom
akargi:feature/akargi-horizon-preflight
Nov 9, 2026
Merged

akargi merged 3 commits into
Chulilee:mainfrom
akargi:feature/akargi-horizon-preflight

Conversation

@akargi

@akargi akargi commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Implements issue #70 (pre-flight balance checks in placeOrder) and issue #71 (Horizon client singleton reacting to config changes) as two focused commits on one feature branch.

Issue #71 — Horizon client (src/lib/stellar/horizon.ts, src/lib/stellar/dex.ts)

  • Replaced the module-load singleton with getHorizonClient() that caches by stellarConfig.horizonUrl and recreates the client when the URL changes
  • Added
    esetHorizonClient() for tests / config reloads; kept the deprecated horizon Proxy export (delegates to the getter) so existing import { horizon } callers keep working but never see a stale endpoint
  • Internal callers (�ccountExists, getBalances, submitTransaction, DEX builders) now go through getHorizonClient(); documents that stellarConfig is static after startup

Issue #70 — placeOrder pre-validation (src/services/tradeService.ts)

  • Early param validation (amount/price/address) before any network call
  • Pre-flight checks via checkOrderBalance before trustline/offer construction: XLM for buy (amount*price + fees) and asset + XLM-for-fees for sell, with clear per-side error messages including shortfalls
  • checkOrderBalance now returns the fetched �alances so placeOrder reuses them instead of fetching twice; no trustline/offer tx is built or signed for doomed orders

Closes #70
Closes #71

getter recreates client on horizonUrl change, reset for tests. Closes Chulilee#71
Early param validation, XLM and asset checks, clear per-side errors, no tx building for doomed orders. Closes Chulilee#70
@vercel

vercel Bot commented Nov 9, 2026

Copy link
Copy Markdown

@akargi is attempting to deploy a commit to the Akargi Team on Vercel.

A member of the Team first needs to authorize it.

@vercel

vercel Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
inter-changabletrade-fricks Ready Ready Preview Nov 9, 2026 5:25am UTC

@akargi
akargi merged commit afa54ff into Chulilee:main Nov 9, 2026
3 checks passed

This branch was successfully deployed

1 active deployment
Preview — f3e632a1 Deployed Nov 9, 2026 by vercel[bot]
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.

Fix: Horizon client singleton doesn't react to config changes Fix: placeOrder doesn't pre-validate user balance before submission

1 participant