Skip to content

feat: connect invoice-token transfer lock to escrow settlement/refund#52

Merged
Jayrodri088 merged 6 commits into
StellarState:mainfrom
KevinMB0220:feat/transfer-lock-escrow-lifecycle-27
Mar 25, 2026
Merged

feat: connect invoice-token transfer lock to escrow settlement/refund#52
Jayrodri088 merged 6 commits into
StellarState:mainfrom
KevinMB0220:feat/transfer-lock-escrow-lifecycle-27

Conversation

@KevinMB0220

Copy link
Copy Markdown
Contributor

Closes #27

Summary

  • invoice-token: set_transfer_locked now accepts an explicit caller: Address parameter. Both admin and minter (the escrow contract) are authorised to change the lock state; any other caller returns Error::Unauthorized.
  • invoice-escrow: record_payment and refund call set_transfer_locked(false) on the invoice token (via the escrow's minter authority) after the status transition. Tokens are locked during Created/Funded and unlocked on Settled/Refunded.
  • Tests: existing token tests updated for the new signature; two new token unit tests (test_set_transfer_locked_by_minter, test_set_transfer_locked_unauthorized_fails); escrow integration tests assert lock state before and after each lifecycle transition; new dedicated test test_integration_token_locked_during_active_escrow.
  • Docs: docs/lifecycle.md updated with unlock behaviour and a Transfer Lock Policy table.

Transfer Lock Policy

Escrow State transfer_locked Who Can Transfer
Created true Admin only
Funded true Admin only
Settled false All holders
Refunded false All holders

Test plan

  • cargo fmt --check passes (no formatting issues)
  • cargo clippy -- -D warnings passes (no lints)
  • cargo test — all tests pass (18 token unit tests, 11 escrow unit tests, 3 escrow integration tests)
  • Lock is true immediately after fund_escrow
  • Lock becomes false after record_payment (settlement)
  • Lock becomes false after refund
  • Buyer can transfer invoice tokens freely after unlock
  • Unauthorized caller to set_transfer_locked gets Error::Unauthorized
  • Minter (escrow) can call set_transfer_locked directly

🤖 Generated with Claude Code

@drips-wave

drips-wave Bot commented Mar 25, 2026

Copy link
Copy Markdown

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

@Jayrodri088

Copy link
Copy Markdown
Contributor

@KevinMB0220 Please merge conflicts

KevinMB0220 and others added 5 commits March 25, 2026 11:04
set_transfer_locked now accepts an explicit `caller: Address` param.
Both admin and minter (escrow contract) are authorised to change the
lock state; any other caller returns Error::Unauthorized.

This is the token-side prerequisite that lets the escrow contract
unlock transfers at the end of an invoice lifecycle.

Closes StellarState#27

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
record_payment and refund now call set_transfer_locked(false) on the
invoice-token contract (using the escrow's minter authority) after
updating the escrow status.  Token transfers are blocked while the
invoice is active (Created/Funded) and unlocked once the lifecycle
ends (Settled/Refunded).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Pass explicit admin/minter caller in all existing set_transfer_locked calls
- Add test_set_transfer_locked_by_minter: minter can lock/unlock
- Add test_set_transfer_locked_unauthorized_fails: stranger gets Unauthorized

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…fund

- MockInvoiceToken: add set_transfer_locked no-op so unit tests compile
- integration happy path: assert token is locked while active, unlocked
  after settlement, and buyer can transfer tokens freely post-settlement
- integration refund: assert token is unlocked after refund
- New test_integration_token_locked_during_active_escrow: full
  Created → Funded (locked) → Settled (unlocked) flow with transfer
  assertion before and after unlock

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Update Settlement and Refund sections to reflect that the escrow
contract now unlocks invoice token transfers as part of those
operations.  Add a Transfer Lock Policy table showing transfer_locked
state per escrow status and the access-control rules.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@KevinMB0220 KevinMB0220 force-pushed the feat/transfer-lock-escrow-lifecycle-27 branch from be89a46 to 047315a Compare March 25, 2026 17:19
@KevinMB0220

KevinMB0220 commented Mar 25, 2026

Copy link
Copy Markdown
Contributor Author

@KevinMB0220 Please merge conflicts

Done can you review please

@Jayrodri088 Jayrodri088 merged commit 0756fb3 into StellarState:main Mar 25, 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.

[Feature] Make invoice-token transfer lock follow escrow settlement/refund

2 participants