Skip to content

refactor(contract): comprehensive milestone and event improvements - #347

Merged
ALLEN-AYODEJI merged 2 commits into
Trellis-Ecosystem:masterfrom
psamist001:fix/comprehensive-contract-improvements
Aug 28, 2026
Merged

refactor(contract): comprehensive milestone and event improvements#347
ALLEN-AYODEJI merged 2 commits into
Trellis-Ecosystem:masterfrom
psamist001:fix/comprehensive-contract-improvements

Conversation

@psamist001

Copy link
Copy Markdown
Contributor

Summary

This PR implements four interconnected improvements to the Trellis contract and tests:

#224: Remove Dead-Weight Milestone.id Field

The Milestone.id field was stored but never validated or read, wasting storage. Removed it entirely and updated both contract and frontend types.

#225: Add Missing Authorization Tests

Implemented comprehensive authorization testing to verify that:

  • Payee cannot call payer-only functions (lock_funds, approve_and_release, cancel_unfunded)
  • Payer cannot call payee-only functions (submit_work)
  • Non-resolvers cannot call resolve_dispute
  • Read-only functions (get_agreement) are accessible to anyone

#226: Emit On-Chain Event for extend_agreement_ttl

Added keeper audit trail by emitting ttl_extended events when agreements are extended. This allows off-chain monitoring to track which services are keeping agreements alive.

#227: Add Dispute Payee-Award Path Coverage

Previously only the refund path was tested. Now tests verify the complete payee-award path (refund_to_payer=false) including:

  • Correct token transfer to payee
  • Status transition to Completed
  • Proper balance movements

Testing

All changes include comprehensive tests verifying state transitions, token movements, and event emissions.

Closes #224
Closes #225
Closes #226
Closes #227

Closes Trellis-Ecosystem#224: Remove dead-weight Milestone.id field
- Removed unused id field from Milestone struct that was never validated or read
- Updated frontend type definition in soroban.ts
- Updated all test data to remove id field constructions
- Removed assertion checking milestone.id since field no longer exists

Closes Trellis-Ecosystem#225: Add comprehensive authorization tests
- Added test_payer_only_functions_reject_payee: verify payee cannot call payer-only functions
- Added test_payee_only_functions_reject_payer: verify payer cannot call payee-only functions
- Added test_resolver_only_functions_reject_others: verify non-resolvers cannot resolve disputes
- Added test_get_agreement_callable_by_anyone: verify read-only access has no auth requirement

Closes Trellis-Ecosystem#226: Emit on-chain event for extend_agreement_ttl
- Added new ttl_extended event variant with caller address for keeper audit trail
- Updated events.rs with new "trlls_ttle" topic symbol (9 chars, symbol_short!)
- Modified extend_agreement_ttl to accept caller parameter and emit event
- Added test_extend_agreement_ttl_emits_event to verify event emission

Closes Trellis-Ecosystem#227: Add comprehensive dispute resolution test coverage for payee-award path
- Added test_dispute_and_release_to_payee to test the refund_to_payer=false path
- Verifies token transfer to payee (not payer) when resolver awards to payee
- Verifies milestone status transitions to Completed (not Refunded)
- Validates balances of both payer and payee after resolution

All tests verify the complete state transitions and token movements for each scenario.
@drips-wave

drips-wave Bot commented Aug 27, 2026

Copy link
Copy Markdown

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

@ALLEN-AYODEJI
ALLEN-AYODEJI merged commit 182ebda into Trellis-Ecosystem:master Aug 28, 2026
1 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

2 participants