Skip to content

feat(contract): add cancellation window constraints#105

Merged
thlpkee20-wq merged 3 commits into
Chronopay-Org:mainfrom
lycantho:feature/sc-020
Apr 1, 2026
Merged

feat(contract): add cancellation window constraints#105
thlpkee20-wq merged 3 commits into
Chronopay-Org:mainfrom
lycantho:feature/sc-020

Conversation

@lycantho

Copy link
Copy Markdown

[SC-020] Add Cancellation Window Constraints

Description

This PR addresses issue #20 by implementing cancellation window constraints for time slot tokens in the ChronoPay smart contract, ensuring buyers are prevented from cancelling a time slot too close to the start time.

Core Changes

  • New storage keys: CancelWindowSecs, SlotBuyer(u32), and SlotStartTime(u32) to keep track of slot configuration, buyer records, and scheduled start times.
  • buy_time_slot: A robust handler complementing the old stub, registering the buyer for a slot.
  • set_cancel_window: Allows the contract owner to configure the allowed cancellation window prior to start time (defaulting to 3600 seconds/1 hour).
  • cancel_time_slot: Enables a buyer to cancel their reservation if requested before the designated cancellation window starts. If called too late, or for non-existent/unsold slots, the transaction panics. Safely resets the slot status to Available upon success.

Testing

  • Wrote 8 exhaustive unit tests rigorously evaluating expected behaviors and explicit panic! conditions (e.g., zero windows, cancelling post-deadline, cancelling unassigned slots).
  • Achieved ~100% test coverage for all new conditions and failure modes under touched modules.

Security and Architecture Notes

  • Storage manipulation efficiently restricts status modifications and handles default fallback states securely without overriding bounds logic.

Closes #20.

@drips-wave

drips-wave Bot commented Mar 27, 2026

Copy link
Copy Markdown

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

@lycantho

Copy link
Copy Markdown
Author

@thlpkee20-wq please merge

@lycantho

Copy link
Copy Markdown
Author

@thlpkee20-wq

1 similar comment
@lycantho

Copy link
Copy Markdown
Author

@thlpkee20-wq

@thlpkee20-wq thlpkee20-wq merged commit 50845b2 into Chronopay-Org:main Apr 1, 2026
0 of 3 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.

[SC-020] Add Cancellation Window Constraints

3 participants