test(buy): reject buys once the global deadline ledger has passed (#737) - #744
Merged
Chucks1093 merged 1 commit intoAug 25, 2026
Conversation
…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
|
@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! 🚀 |
Yunusabdul38
marked this pull request as draft
August 25, 2026 10:57
Yunusabdul38
marked this pull request as ready for review
August 25, 2026 11:48
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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/srccame 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;Noneclears it and reopens buying. Emits adl_setevent.get_global_deadline() -> Option<u32>— reads it back.buy_key/buy_key_with_referrernow fail withContractError::DeadlinePassedonceledger >= deadline. The boundary is exclusive: the last ledger that still trades isdeadline - 1, so a buy submitted at the deadline is already too late.Following the ABI stability rules documented on the error enum,
DeadlinePassedis appended as variant 40 andGlobalDeadlineLedgeris appended toDataKey— no existing discriminant shifts.