Skip to content

mock transaction - #161

Merged
Marvell69 merged 2 commits into
OracleDesk:developfrom
Ghoost-404:feat/mock-transaction
Oct 17, 2026
Merged

Marvell69 merged 2 commits into
OracleDesk:developfrom
Ghoost-404:feat/mock-transaction

Conversation

@Ghoost-404

Copy link
Copy Markdown
Contributor

Closes #7
Closes #8
Closes #9
Closes #10

Summary of Changes

  1. Fee and Reserve Model (lib/stellar/fees.ts & lib/stellar/units.ts):

    • Implemented feeBreakdown extracting inclusion fee, resource fee, total fee (stroops as strictly bigint), and Soroban footprint metrics.
    • Implemented spendableXlm calculating spendable native balance via CAP-33 sponsored reserve rules (minBalance = (2 + numSubEntries + numSponsoring - numSponsored) * baseReserve; spendable = balance - minBalance - sellingLiabilities, floored at 0).
    • Dynamic network base reserve reader fetchBaseReserve with fallback to DEFAULT_BASE_RESERVE = 5_000_000n.
    • Added formatXlm in units.ts generalizing formatFixed to 7-decimal stroops while preserving formatUsdc behavior and test cases byte-for-byte.
    • Extended DescribedError in errors.ts with "insufficient-xlm" for op_low_reserve and txInsufficientBalance without breaking USDC balance error matching.
  2. Transaction Lifecycle Runner (lib/stellar/tx-lifecycle.ts):

    • Replaced opaque signAndSend() with TxLifecycle driving explicit, observable phases:
      building → simulating → awaiting-signature → submitting (hash available) → pending (polling with backoff) → confirmed | failed | expired.
    • Expiration derived from RPC latestLedgerCloseTime against transaction time bounds, avoiding client clock skew.
    • Added describeSubmission for mapping SendTransactionResponse statuses (PENDING, DUPLICATE, TRY_AGAIN_LATER, ERROR, txBadSeq, etc.).
    • Write hooks (useBuy, useSell, useRedeem, useUsdcTransfer) retain their return shapes and query invalidations while exposing reactive phase state surviving component unmounts.
  3. Transaction Session Tracker & Toasts (lib/stellar/tx-tracker* & components/ui/tx-toast.tsx):

    • Created TransactionTrackerProvider mounted inside WalletProvider.
    • Serializes pending transactions to sessionStorage (oracledesk_pending_txs) with bigint serialized as decimal strings, automatically resuming polling upon page reload.
    • Uses BroadcastChannel("oracledesk-tx") for multi-tab election to avoid duplicate RPC polling.
    • Shared tradeInvalidationKeys ensures React Query invalidation runs identically upon confirmation.
    • Created accessible TxToastContainer announcing state transitions via role="status" and aria-live="polite", with support for resuming premium daily pass activation (unlockDailyPass).
  4. Checkout Surfaces & Fee Preview:

    • Quick-View (app/markets/quick-view/page.tsx):
      • Pre-sign fee preview under quote: Network fee ≈ X XLM · spendable Y XLM with tooltip fallback note "assumes the network base reserve of 0.5 XLM".
      • Distinct message "Fund this account with XLM first." for unfunded accounts.
      • Blocking warning "You need about X more XLM to pay the network fee." disabling the Buy button when spendable XLM is insufficient.
      • Replaced fixed status strings with live phase copy and explorer link as soon as a hash exists.
    • Copy-Trade (app/copy-trade/page.tsx):
      • Fee preview row placed next to slippage output.
      • Blocking warnings and button disabled when spendable XLM is insufficient or account is unfunded.
      • Phase-based progress messages with explorer links.
    • Premium (app/premium/page.tsx):
      • Added usePrepareUsdcTransfer fee preview above pay button with blocking warnings.
      • Passes followUp: { type: "unlock-daily-pass", traceId, amountRaw } to the tracker.
  5. Real /tx Route & Demo Screen Cleanup:

    • Implemented real transaction inspector route at app/tx/page.tsx reading ?hash=<64-hex>, querying rpcServer().getTransaction(hash), displaying confirmed/failed status, ledger, fee charged in XLM, decoded return value, and fallback to Stellar Expert.
    • Replaced timer-driven mock screens (transaction-status, transaction-success, transaction-failed) with redirects to /tx.
  6. Documentation & Validation:

    • Updated docs/manual-test.md with step 11 covering low-XLM and reserve checks.
    • Added "Write path and transaction lifecycle" to docs/architecture.md.
    • Test suites: 7/7 test files passed (49/49 unit tests).
    • npm run typecheck, npm run lint, and npm run build all pass with 0 errors.

@drips-wave

drips-wave Bot commented Oct 17, 2026

Copy link
Copy Markdown

@Ghoost-404 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@vercel

vercel Bot commented Oct 17, 2026

Copy link
Copy Markdown

@Ghoost-404 is attempting to deploy a commit to the Marvel's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Marvell69
Marvell69 merged commit cf146a9 into OracleDesk:develop Oct 17, 2026
1 check failed
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.

2 participants