Skip to content

feat(cntr): implement dispute window checker and cancellation policy enforcer#1046

Open
RennyThompson wants to merge 1 commit into
DistinctCodes:mainfrom
RennyThompson:feat/ct-05-ct-16-dispute-window-cancellation-policy
Open

feat(cntr): implement dispute window checker and cancellation policy enforcer#1046
RennyThompson wants to merge 1 commit into
DistinctCodes:mainfrom
RennyThompson:feat/ct-05-ct-16-dispute-window-cancellation-policy

Conversation

@RennyThompson
Copy link
Copy Markdown
Contributor

Summary

Resolves two open issues by adding pure-Rust utility modules to contracts/cntr/src/.


[CT-05] Dispute Window Checker — closes #1022

File: contracts/cntr/src/dispute_window.rs

  • is_within_dispute_window(checkout_timestamp, current_timestamp, window_seconds) -> bool
  • dispute_window_expires_at(checkout_timestamp, window_seconds) -> u64
  • Default constant: DEFAULT_DISPUTE_WINDOW_SECONDS = 172_800 (48 h)
  • 5 unit tests: inside window, outside window, exactly at boundary, at checkout moment, expiry timestamp

[CT-16] Cancellation Policy Enforcer — closes #1033

File: contracts/cntr/src/cancellation_policy.rs

  • CancellationPolicy enum deriving Debug, PartialEq, Clone with variants Flexible, Moderate, Strict
  • apply_policy(policy, hours_before_start, amount_stroops) -> i128
    • Flexible: always 100% refund
    • Moderate: 100% ≥ 48 h, 50% 24–47 h, 0% < 24 h
    • Strict: 100% ≥ 96 h, 0% otherwise
  • Integer arithmetic only, no floating point
  • 9 unit tests (3 per policy)

Other

  • Cleaned up duplicate pub mod entries in lib.rs and registered both new modules.

- Add dispute_window.rs: is_within_dispute_window and dispute_window_expires_at
  with 5 unit tests (closes DistinctCodes#1022)
- Add cancellation_policy.rs: CancellationPolicy enum (Flexible/Moderate/Strict)
  with apply_policy and 9 unit tests (closes DistinctCodes#1033)
- Register both modules in lib.rs, remove duplicate entries
@vercel
Copy link
Copy Markdown

vercel Bot commented May 30, 2026

@RennyThompson is attempting to deploy a commit to the naijabuz's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 30, 2026

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

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