Skip to content

feat: comprehensive error handling, storage optimization, event enhancement, and deployment scripts - #28

Merged
Levi-Ojukwu merged 11 commits into
mainfrom
fix/comprehensive-improvements
Jul 11, 2026
Merged

Levi-Ojukwu merged 11 commits into
mainfrom
fix/comprehensive-improvements

Conversation

@Levi-Ojukwu

Copy link
Copy Markdown
Member

Summary

This PR addresses issues #14, #15, #16, and #17 with comprehensive improvements to the StellFlow escrow smart contract.
closes #14 : Comprehensive Error Handling and Validation

  • Expanded EscrowError enum with 12 new specific variants: UnauthorizedAction, MilestoneAmountMismatch, MilestoneCountMismatch, MilestoneAlreadyReleased, CannotReleaseUnapprovedMilestone, CannotSubmitAlreadySubmittedMilestone, ZeroMilestones, EscrowAlreadyReleased, EscrowAlreadyRefunded, InvalidDeadlineTransition, TreasuryNotConfigured, CannotSetFeeExceedingMax
  • All error paths now return specific, descriptive error variants instead of generic errors
  • Added milestone-specific validation (zero milestones, count mismatch, amount mismatch)
    closes Optimize storage usage and TTL management #15 : Optimize Storage Usage and TTL Management
  • Added configurable TTL with set_escrow_ttl/get_escrow_ttl functions (bounds: 1M-7.7M ledger increments)
  • Added cleanup_expired_escrows function for terminal escrow cleanup
  • Replaced hardcoded ESCROW_TTL constant with dynamic storage configuration
  • Added EscrowTTL to DataKey enum for persistent TTL storage
    closes Add events for all state transitions #16 : Events for All State Transitions
  • Enhanced all events with actor address, timestamp, and relevant amounts
  • New events: ESCROW_DEADLINE_SET, ESCROW_TIMEOUT, FEE_UPDATED
  • resolve_dispute now emits released_amount and refunded_amount
  • emit_escrow_modified includes new_amount and new_freelancer details
    closes Create deployment scripts and testnet configuration #17 : Deployment Scripts and Testnet Configuration
  • Enhanced deploy.sh with pre-flight CLI checks, TTL configuration, and contract verification
  • Enhanced verify.sh with multi-step verification including TTL and admin checks
  • Support for DEFAULT_FEE_PERCENT, TREASURY_ADDRESS, and ESCROW_TTL environment variables
    Test Results
    All 95 tests pass across 8 test files:
  • cancel_escrow_tests: 11 tests
  • create_escrow_tests: 12 tests
  • dispute_resolution_tests: 16 tests
  • fund_escrow_tests: 6 tests
  • integration_tests: 10 tests
  • modify_escrow_tests: 13 tests
  • release_refund_tests: 14 tests
  • timeout_tests: 13 tests
    Files Changed

File Description

1 escrow/contracts/escrow/src/errors.rs Expanded error enum with 12 new variants
2 escrow/contracts/escrow/src/contract.rs Enhanced validation and admin functions
3 escrow/contracts/escrow/src/events.rs Detailed state transition events
4 escrow/contracts/escrow/src/storage.rs Configurable TTL and cleanup
5 escrow/contracts/escrow/src/types.rs Added EscrowTTL DataKey
6 escrow/contracts/escrow/src/lib.rs Fixed duplicate module declaration
7 escrow/contracts/escrow/src/testutils.rs Fixed test utilities
8 escrow/contracts/escrow/tests/create_escrow_tests.rs Updated test calls
9 scripts/deploy.sh Enhanced deployment script
10 scripts/verify.sh Enhanced verification script
11 escrow/Cargo.lock Updated dependencies

Add 12 new error variants for comprehensive error handling:
- UnauthorizedAction, MilestoneAmountMismatch, MilestoneCountMismatch
- MilestoneAlreadyReleased, CannotReleaseUnapprovedMilestone
- CannotSubmitAlreadySubmittedMilestone, ZeroMilestones
- EscrowAlreadyReleased, EscrowAlreadyRefunded
- InvalidDeadlineTransition, TreasuryNotConfigured, CannotSetFeeExceedingMax

Issue #14: Comprehensive error handling and validation
…ions

- Use specific error variants (UnauthorizedAction, EscrowAlreadyReleased, etc.)
- Add milestone-specific error checks (ZeroMilestones, MilestoneCountMismatch)
- Update all events to include actor address and timestamp
- Add set_escrow_ttl, get_escrow_ttl, cleanup_expired_escrows functions
- Add fee_updated event for set_fee operation

Issues #14, #15, #16: Error handling, storage optimization, events
- Add actor address, timestamp, and amounts to all events
- New events: ESCROW_DEADLINE_SET, ESCROW_TIMEOUT, FEE_UPDATED
- Include from_state/to_state info in dispute resolution events
- Add released_amount and refunded_amount to resolve_dispute events

Issue #16: Events for all state transitions
- Add get_escrow_ttl/set_escrow_ttl for configurable TTL (MIN/MAX bounds)
- Add cleanup_expired_escrows function for terminal escrow cleanup
- Replace hardcoded ESCROW_TTL with dynamic configuration
- Add EscrowTTL to DataKey enum

Issue #15: Optimize storage usage and TTL management
- Add EscrowTTL variant for configurable storage TTL management

Issue #15: Optimize storage usage and TTL management
- Fix duplicate 'pub mod contract' line
- Expose errors, events, storage, types, and testutils as public modules
- Enable comprehensive API access for downstream consumers

Issue #14: Comprehensive error handling and validation
- Use env.register_contract and client pattern for test utilities
- Add deadline parameter to create_funded_escrow helper
- Fix compilation error in test utilities

Issue #14: Comprehensive error handling and validation
- Update all create_escrow calls to include &None deadline parameter
- Ensure tests align with updated contract API

Issue #14: Comprehensive error handling and validation
…L config

- Add pre-flight checks for soroban and cargo CLI
- Add contract verification step after deployment
- Support configurable TTL, default fee, and treasury setup
- Add comprehensive deployment status output

Issue #17: Create deployment scripts and testnet configuration
- Add TTL configuration verification step
- Add multi-step verification process
- Improve output formatting for verification results

Issue #17: Create deployment scripts and testnet configuration
- Update lock file to reflect dependency resolution
- Ensures reproducible builds across environments
@Levi-Ojukwu
Levi-Ojukwu merged commit a469610 into main Jul 11, 2026
2 of 4 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

1 participant