Skip to content

Add account lock detector, metadata validator, simulation diff comparator, and reconciliation engine - #600

Merged
Kingsman-99 merged 5 commits into
Stellar-split:mainfrom
CHEF-SAVY:feat/issues-532-535-stellar-wave
Jul 30, 2026
Merged

Add account lock detector, metadata validator, simulation diff comparator, and reconciliation engine#600
Kingsman-99 merged 5 commits into
Stellar-split:mainfrom
CHEF-SAVY:feat/issues-532-535-stellar-wave

Conversation

@CHEF-SAVY

Copy link
Copy Markdown
Contributor

Summary

Implements four Stellar Wave issues, each in its own commit:

  • Account Freeze and Lock State Detector #532 — Account Freeze and Lock State Detector: src/accountStateDetector.ts adds detectLockState() / assertAccountUnlocked(), which read a recipient's trustline (is_authorized, is_authorized_to_maintain_liabilities) and the issuer's auth_revocable / auth_immutable flags via Horizon to report AccountLockState. src/preflightChecker.ts gains checkRecipientsUnlocked(), which calls the detector for each recipient and throws AccountFrozenError / AccountLockedError (new in src/errors.ts) before a payment is built.
  • Invoice Metadata JSON Schema Validator #533 — Invoice Metadata JSON Schema Validator: src/validators/invoiceMetadataValidator.ts wraps ajv (added as a new dependency) behind InvoiceMetadataValidator, compiled once from StellarSplitClientConfig.metadataSchema. StellarSplitClient compiles it in the constructor and calls validate() on CreateInvoiceParams.metadata (new optional field) at the top of createInvoice(), throwing the new MetadataValidationError when metadataThrowOnInvalid (default true) and the schema doesn't match.
  • Simulation Result Diff Comparator #534 — Simulation Result Diff Comparator: src/simulationDiff.ts adds compareSimulations(baseline, revised) and formatDiffSummary(diff) alongside the existing diffSimulations(). Returns cpuDelta, memDelta (combined read+write byte delta — this SDK's SorobanDataBuilder resources don't expose a separate memBytes), feeDelta, footprintAdded/footprintRemoved (LedgerKey XDR base64 diffs), and authChanged.
  • Asset Balance Reconciliation Engine #535 — Asset Balance Reconciliation Engine: src/reconciliationEngine.ts adds ReconciliationEngine.reconcile(accountId, assetCode, dateRange), which compares an internal Payment[] ledger against actual outgoing payments fetched from Horizon (Server.payments().forAccount()) and returns per-payment ReconciliationFindings (info / warning / critical) plus isBalanced.

Implementation notes / deviations from the issue text

The issues described a slightly different codebase state than what's actually on main; to keep this minimal and avoid inventing new stable-looking APIs, a few call sites were adapted rather than followed literally:

  • Invoice Metadata JSON Schema Validator #533/Asset Balance Reconciliation Engine #535 reference updateInvoice() and src/recorder.ts's PaymentRecord[], neither of which exist in this codebase (recorder.ts is an unrelated RPC session recorder, and there is no updateInvoice method — only updateInvoiceStatus). Metadata validation is wired into createInvoice() only; the reconciliation engine takes an injected Payment[] (the SDK's actual per-invoice payment ledger) instead.
  • Simulation Result Diff Comparator #534 asked for SimulationDiff/ResourceDelta types with different fields than the ones already exported by src/simulationDiff.ts for the pre-existing diffSimulations(). To avoid a breaking rename, the new comparator uses distinct type names (SimulationComparison/SimulationComparisonNotComparable) instead of colliding with the existing exports. profiler.ts integration was skipped — that module profiles StellarSplitClient method timings, not Soroban simulations, so there's nothing there to diff.
  • Account Freeze and Lock State Detector #532 field names (authorized, authorized_to_maintain_liabilities) don't match the installed @stellar/stellar-sdk typings (is_authorized, is_authorized_to_maintain_liabilities); the implementation uses the actual SDK field names.

Verification

  • npx tsc --noEmit — no new errors (115 pre-existing errors on main, unchanged after these commits).
  • npx vitest run test/simulationDiff.test.ts test/client.test.ts — 71/71 passing.
  • No new unit tests were added for the new modules per "no reliable way to run tests right now, prioritize clean, correct, minimal code" — happy to add them in a follow-up if the test runner is stabilized.

Closes #532
Closes #533
Closes #534
Closes #535

@drips-wave

drips-wave Bot commented Jul 30, 2026

Copy link
Copy Markdown

@CHEF-SAVY 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

@Kingsman-99
Kingsman-99 merged commit 8e16558 into Stellar-split:main Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants