feat: add key supply view, zero-amount validation, payment helper, and event tests#23
Merged
Chucks1093 merged 1 commit intoMar 26, 2026
Conversation
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.
Closes #18
Closes #20
Closes #21
Closes #22
Summary
Adds a read-only key supply view method, zero-amount purchase validation with a shared helper, and comprehensive event payload tests.
Changes
get_total_key_supplyview method (#18)u32supply for a creator0for unregistered creators (no panic)Zero-amount purchase validation (#20)
buy_key()now explicitly rejectspayment <= 0before any other checks"payment amount must be positive"for zero or negative amountsShared payment amount helper (#21)
assert_positive_amount(amount: i128)— reusable validationbuy_key()andset_key_price()(replaces inline check)set_key_priceEvent payload tests (#22)
test_register_creator_emits_event— verifies "register" topictest_register_creator_event_fires_once— exactly one eventtest_buy_key_emits_event_with_correct_topics— verifies "buy" topic + creator + buyer addressestest_buy_key_event_data_is_new_supply— supply=1 then supply=2test_buy_key_event_present_after_purchase— buy event in logTest Results
30 tests passing (14 new + 16 existing), 0 failures
How to test
cargo test --workspace