Skip to content

test(buy): reject buys once the global deadline ledger has passed (#737) - #744

Merged
Chucks1093 merged 1 commit into
accesslayerorg:mainfrom
Yunusabdul38:test/global-deadline-buy-rejection-737
Aug 25, 2026
Merged

test(buy): reject buys once the global deadline ledger has passed (#737)#744
Chucks1093 merged 1 commit into
accesslayerorg:mainfrom
Yunusabdul38:test/global-deadline-buy-rejection-737

Conversation

@Yunusabdul38

@Yunusabdul38 Yunusabdul38 commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Description

Closes #737
Closes #736
Closes #738
Closes #739

Scope note

The contract had no global deadline of any kind (grep -i deadline creator-keys/src came back empty), so there was nothing for the requested test to exercise. This PR adds the smallest mechanism the issue describes alongside the test rather than testing behaviour that does not exist.

Contract changes

  • set_global_deadline(admin, Option<u32>) — admin only. Pins the ledger from which buys are rejected; None clears it and reopens buying. Emits a dl_set event.
  • get_global_deadline() -> Option<u32> — reads it back.
  • buy_key / buy_key_with_referrer now fail with ContractError::DeadlinePassed once ledger >= deadline. The boundary is exclusive: the last ledger that still trades is deadline - 1, so a buy submitted at the deadline is already too late.
  • The guard sits alongside the existing pause and blacklist checks, before any state is read or written, so a rejected buy cannot move supply, holder count or balances.

Following the ABI stability rules documented on the error enum, DeadlinePassed is appended as variant 40 and GlobalDeadlineLedger is appended to DataKey — no existing discriminant shifts.

…cesslayerorg#737)

Buys had no time gate, so a stale order could execute long after a sale
window was meant to close. There was also no global deadline in the
contract for the requested integration test to exercise, so this adds the
smallest mechanism the issue describes alongside the test.

- `set_global_deadline` (admin only) pins the ledger from which buys are
  rejected, and clears it when passed `None`; `get_global_deadline` reads it
  back.
- `buy_key` now fails with `DeadlinePassed` once
  `ledger >= deadline`. The boundary is exclusive: the last ledger that
  still trades is `deadline - 1`.
- The guard runs before any state is touched, so a rejected buy leaves
  supply, holder count and balances untouched.

`DeadlinePassed` is appended as variant 40 and `GlobalDeadlineLedger`
appended to `DataKey`, per the ABI stability rules on the error enum.

The integration test covers the rejection at and past the deadline, the
accepted buy on the last ledger before it, the unchanged state after a
blocked buy, the no-deadline and cleared-deadline paths, and admin-only
access to the setter.

Closes accesslayerorg#737
@drips-wave

drips-wave Bot commented Aug 25, 2026

Copy link
Copy Markdown

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

@Yunusabdul38
Yunusabdul38 marked this pull request as draft August 25, 2026 10:57
@Yunusabdul38
Yunusabdul38 marked this pull request as ready for review August 25, 2026 11:48
@Chucks1093
Chucks1093 merged commit 5ee8183 into accesslayerorg:main Aug 25, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment