Skip to content

feat: Stellar transfer lifecycle state machine#661

Open
michaelvic123 wants to merge 2 commits into
MDTechLabs:mainfrom
michaelvic123:feat/stellar-transfer-state-machine
Open

feat: Stellar transfer lifecycle state machine#661
michaelvic123 wants to merge 2 commits into
MDTechLabs:mainfrom
michaelvic123:feat/stellar-transfer-state-machine

Conversation

@michaelvic123

@michaelvic123 michaelvic123 commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Closes #517


Summary

Implements a guarded state machine for Soroban bridge transfer lifecycle management at src/transfers/state-machine/stellar/.

Problem

Transfer states were handled inconsistently — callers could set any status directly with no transition validation, leading to unreachable or invalid states.

Solution

A NestJS service that holds per-transfer state machines in memory and enforces valid transitions at every step.

Transfer States

pending → locked → validated → submitted → confirmed → completed
                ↘              ↘
               failed ──────────────────────────────→ refunded

Endpoints

  • POST /transfers/state-machine/stellar/:transferId — create lifecycle for a transfer
  • GET /transfers/state-machine/stellar/:transferId — get current state + history
  • POST /transfers/state-machine/stellar/:transferId/transition — move to next state (guarded)
  • POST /transfers/state-machine/stellar/:transferId/recover — recovery path: failed → refunded

Files

  • transfer-state-machine.types.tsTransferState, TransitionRecord, TransferLifecycle
  • transfer-state-machine.service.tscreate/get/transition/recover with guards, exports service
  • transfer-state-machine.controller.ts — REST + Swagger
  • transfer-state-machine.module.ts — NestJS module
  • app.module.ts — registers TransferStateMachineModule

Verified

  • All 5 files pass TypeScript diagnostics with zero errors
  • Invalid transitions throw 400 BadRequestException with clear message
  • Service is exported from module for injection by other modules

michaelvic123 and others added 2 commits June 25, 2026 23:34
Implements a guarded state machine for Soroban bridge transfer
lifecycle management under src/transfers/state-machine/stellar/.

States: pending -> locked -> validated -> submitted -> confirmed -> completed
Recovery: failed -> refunded (via /recover endpoint)

- transfer-state-machine.types.ts: TransferState, TransitionRecord, TransferLifecycle
- transfer-state-machine.service.ts: create/get/transition/recover with transition guards
- transfer-state-machine.controller.ts: REST endpoints with Swagger
- transfer-state-machine.module.ts: NestJS module, exports service for reuse
- app.module.ts: registers TransferStateMachineModule
@drips-wave

drips-wave Bot commented Jun 25, 2026

Copy link
Copy Markdown

@michaelvic123 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

@mijinummi

Copy link
Copy Markdown
Collaborator

Hello @michaelvic123 kindly fix the run build errors

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.

Implement Soroban Transfer State Machine

2 participants