Skip to content

feat: add cross-package transaction readiness engine with typed states and stages (Closes #21) - #79

Merged
El-swaggerito merged 1 commit into
Axionvera:mainfrom
deepak0x:feature/issue-21-readiness-engine
Jul 28, 2026
Merged

feat: add cross-package transaction readiness engine with typed states and stages (Closes #21)#79
El-swaggerito merged 1 commit into
Axionvera:mainfrom
deepak0x:feature/issue-21-readiness-engine

Conversation

@deepak0x

Copy link
Copy Markdown
Contributor

Description

Implements a cross-package Stellar transaction readiness engine (issue #21) — a single reusable surface that validates account state, asset, amount, memo, network mode, and submission safety before any transaction is built. Testnet-first; never submits real payments.

What changed

  • packages/types/src/index.ts:
    • Added ReadinessState (ready | warnings | unsafe-network | blocked) — a typed aggregate outcome.
    • Added ReadinessStage ({ id, label, status, warnings }) — per-stage result.
    • Extended TransactionReadiness with state and stages (backward-compatible: ready/warnings/summary retained).
  • packages/stellar-kit/src/intent.ts:
    • Refactored estimateTransactionReadinessSync to run 7 discrete, reportable stages (account-source, account-dest, asset, amount, memo, network, balance) instead of one flat warning list.
    • getReadinessState(warnings) derives the typed ReadinessState.
    • mapReadinessToErrorCode(warnings) returns the first error code for logging/branching.
    • estimateTransactionReadiness (async) unchanged signature; now returns richer result.
  • packages/stellar-kit/test/readiness.test.ts (new) — 11 tests: ready, warnings (same src/dest), blocked (bad asset/amount), unsafe-network (mainnet disabled), unfunded, insufficient-funds, plus helper tests for getReadinessState/mapReadinessToErrorCode.
  • examples/payment-readiness.example.json — deterministic intent + expected state/stages.
  • apps/web/app/payments/page.tsx — readiness panel now shows the typed state badge (Ready / Ready with warnings / Unsafe network / Blocked) and a per-stage status grid; submission stays disabled unless state is ready/warnings.
  • docs/transaction-readiness.md — engine reference, lifecycle, stages, API, safety notes.

Verification

  • packages/stellar-kit full suite: 149 tests passing (11 new for readiness).
  • packages/stellar-kit builds; web app typechecks clean.

Acceptance criteria

  • Transaction readiness engine implemented (typed, cross-package).
  • Account, asset, amount, memo, and network checks included (plus balance/funding).
  • Readiness states are typed (ReadinessState).
  • Web payment page uses the shared engine (badge + stage grid).
  • Tests cover valid, invalid, unfunded, and unsafe-network scenarios.
  • Documentation explains the readiness lifecycle.

Notes

  • The engine only validates; it never builds or submits a transaction.
  • Mainnet is disabled by default → MAINNET_DISABLED warning yields unsafe-network state.

@El-swaggerito
El-swaggerito merged commit 9f928a8 into Axionvera:main Jul 28, 2026
1 check passed
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