Skip to content

feat: add explicit asset contract verification in create_escrow - #291

Merged
chizzy192 merged 3 commits into
StellarState:devfrom
sudo-robi:feature/invoice-escrow-token-verification
Jul 30, 2026
Merged

feat: add explicit asset contract verification in create_escrow#291
chizzy192 merged 3 commits into
StellarState:devfrom
sudo-robi:feature/invoice-escrow-token-verification

Conversation

@sudo-robi

Copy link
Copy Markdown
Contributor

closes #92

Summary

Adds explicit verification that payment_token and invoice_token are valid, distinct token contracts in the create_escrow function.

Changes

  • errors.rs: Added InvalidPaymentToken (18), InvalidInvoiceToken (19), IdenticalTokens (20) error variants. Fixed pre-existing InvalidPayer/Paused duplicate discriminant ([Docs] Rename Readme.md to README.md #15).
  • lib.rs: Added verify_token_contract helper using try_invoke_contract on the balance function. Updated create_escrow to validate: (1) tokens are different, (2) payment token is a valid contract, (3) invoice token is a valid contract. Added ensure_not_paused check to create_escrow. Fixed funder_opt.into_val compilation error in record_payment/refund.
  • test.rs: Added balance method to MockInvoiceToken. Updated 10 tests to use real token contracts instead of Address::generate.

@drips-wave

drips-wave Bot commented Jul 28, 2026

Copy link
Copy Markdown

@sudo-robi 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

@chizzy192
chizzy192 changed the base branch from main to dev July 29, 2026 15:13
@chizzy192 chizzy192 closed this Jul 29, 2026
@chizzy192 chizzy192 reopened this Jul 29, 2026
- Added error variants: InvalidPaymentToken, InvalidInvoiceToken, IdenticalTokens
- Added verify_token_contract helper using try_invoke_contract on balance
- create_escrow now validates: different tokens, valid payment token, valid invoice token
- Added balance method to MockInvoiceToken for test support
- Updated 10 tests to use real token contracts instead of Address::generate
- Fixed pre-existing InvalidPayer/Paused duplicate discriminant (StellarState#15)
- Fixed funder_opt.into_val compilation error in record_payment/refund
- Added ensure_not_paused check to create_escrow
- All 59 tests pass, clippy clean, fmt clean
@chizzy192

Copy link
Copy Markdown
Contributor

Hi @sudo-robi, please rebase your branch on dev to resolve merge conflicts in contracts/invoice-escrow/src/lib.rs. Ensure your asset verification check raises the explicit EscrowError::InvalidAsset error code when an unverified address is passed.

@chizzy192 chizzy192 closed this Jul 30, 2026
@chizzy192 chizzy192 reopened this Jul 30, 2026
- test_initialize_not_authorized: update should_panic expected string to match
  actual HostError(Error(Auth, InvalidAction)) from require_auth()
- test_create_escrow_requires_seller_auth: use mock_all_auths + real token contracts
- test_update_platform_fee_requires_admin_auth: add mock_all_auths, assert success
- test_set_paused_requires_admin_auth: add mock_all_auths, assert success
- payment-distributor integration tests: replace env.auths() invocation checks
  with distributor state verification (env.invoke_contract sub-calls not
  recorded in auth framework)
- payment-distributor test.rs: fix variable name compilation errors
- Regenerated all test snapshot files to match fixed test behavior
@sudo-robi
sudo-robi force-pushed the feature/invoice-escrow-token-verification branch from 205ed7b to 68aa62e Compare July 30, 2026 15:40
@chizzy192
chizzy192 merged commit 2bb178f into StellarState:dev Jul 30, 2026
2 of 5 checks 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.

[CONTRACTS] Invoice Escrow: Enforce Explicit Asset Contract Verification

2 participants