Skip to content

feat: add dispute resolution window configuration#218

Merged
nafiuishaaq merged 3 commits into
MentoNest:mainfrom
ScriptedBro:feature/dispute-resolution-window
Apr 29, 2026
Merged

feat: add dispute resolution window configuration#218
nafiuishaaq merged 3 commits into
MentoNest:mainfrom
ScriptedBro:feature/dispute-resolution-window

Conversation

@ScriptedBro
Copy link
Copy Markdown
Contributor

Add Dispute Resolution Window Configuration

Overview

This PR implements configurable dispute resolution time windows, allowing admins to adjust the period during which disputes can be raised after session completion.

Changes

New Features

  • set_dispute_window(window_ledgers: u32): Admin-only function to configure the dispute resolution window

    • Validates window is between 10 and 100,000 ledgers
    • Emits DisputeWindowUpdated event on successful update
    • Requires admin authorization and checks if contract is paused
  • get_dispute_window() -> u32: View function to retrieve the current dispute window

    • Returns the configured window in ledgers
    • Defaults to 1000 ledgers if not explicitly set
  • DisputeWindowUpdated Event: New event emitted when dispute window is updated

    • Contains old_window_ledgers and new_window_ledgers
    • Includes updated_by (admin address) and timestamp

Implementation Details

  • Default dispute window: 1000 ledgers (DEFAULT_DISPUTE_WINDOW_LEDGERS)
  • Minimum allowed: 10 ledgers (DISPUTE_WINDOW_MIN_LEDGERS)
  • Maximum allowed: 100,000 ledgers (DISPUTE_WINDOW_MAX_LEDGERS)
  • Updated dispute window logic to use ledger-based timing instead of seconds
  • Modified init() function to accept dispute_window_ledgers: u32 parameter
  • Updated lock_funds() to calculate dispute deadline using ledger sequences
  • Updated auto_refund() to check dispute window using ledger sequences

Testing

Added comprehensive test coverage:

  • test_get_dispute_window_returns_default - Verifies default value
  • test_set_dispute_window_updates_value - Tests successful update
  • test_set_dispute_window_emits_event - Verifies event emission
  • test_set_dispute_window_rejects_too_small - Validates minimum constraint
  • test_set_dispute_window_rejects_too_large - Validates maximum constraint
  • test_set_dispute_window_requires_admin - Ensures admin-only access
  • test_set_dispute_window_accepts_minimum_value - Tests boundary condition
  • test_set_dispute_window_accepts_maximum_value - Tests boundary condition
  • test_dispute_window_persists_across_calls - Verifies persistence

Files Modified

  • crates/contracts/core/src/events.rs - Added DisputeWindowUpdated event
  • crates/contracts/core/src/lib.rs - Implemented dispute window functions and updated logic
  • crates/contracts/core/src/oracle.rs - Fixed error type references
  • crates/contracts/core/src/test.rs - Added comprehensive test suite

Acceptance Criteria

  • set_dispute_window(window_ledgers: u32) function implemented
  • get_dispute_window() view function implemented
  • Default window value = 1000 ledgers
  • Emits DisputeWindowUpdated event
  • Admin-only access control enforced

Breaking Changes

⚠️ Breaking Change: The init() function signature has changed:

  • Before: init(env, admin, platform_fee_bps, treasury_address, dispute_window_secs: u64)
  • After: init(env, admin, platform_fee_bps, treasury_address, dispute_window_ledgers: u32)

Existing deployments will need to update initialization calls to use ledgers instead of seconds.

Build Status

✅ Release build successful
✅ All new tests passing

Related Issues

Closes #121

Checklist

  • Code follows project conventions
  • Tests added and passing
  • Documentation updated (inline comments)
  • Breaking changes documented
  • Admin-only access control implemented
  • Event emission verified
  • Input validation implemented

- Add set_dispute_window(window_ledgers: u32) function with admin-only access
- Add get_dispute_window() view function returning u32 ledgers
- Set default window value to 1000 ledgers (DEFAULT_DISPUTE_WINDOW_LEDGERS)
- Add DisputeWindowUpdated event with old/new window values and admin info
- Update dispute window logic to use ledger-based timing instead of seconds
- Add validation for dispute window range (10-100,000 ledgers)
- Add comprehensive tests for dispute window configuration
- Update init function to accept dispute_window_ledgers parameter
- Export DisputeWindowUpdated event from events module
Resolved conflicts:
- Updated dispute window logic to use ledger-based timing across all modules
- Fixed type mismatches between u32 (ledgers) and u64 (timestamps)
- Integrated new upstream error codes and features
- Maintained dispute window configuration functionality
Resolved conflicts:
- Maintained ledger-based dispute window logic across all modules
- Fixed duplicate module declarations
- Removed duplicate code in acquire_lock function
- Kept DisputeWindowUpdated event and configuration functionality
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 29, 2026

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

@nafiuishaaq nafiuishaaq merged commit 97f5010 into MentoNest:main Apr 29, 2026
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.

Dispute window configuration

2 participants