feat(creator-keys): protocol fee bounds, key price, and buy_key payment tests#17
Merged
Merged
Conversation
- Added `PROTOCOL_BPS_MAX` constant to cap protocol fee settings at 50%. - Introduced `assert_valid_fee_bps` function to validate fee configurations. - Updated `buy_key` function to check for sufficient payment against the set key price. - Implemented `set_key_price` function for setting the price of keys. - Added tests for key purchase scenarios, including insufficient payment and unregistered creators. - Created tests for setting fee configurations, including validation for maximum protocol basis points.
Contributor
Author
|
@Chucks1093 kindly review |
|
@Jagadeeshftw 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! 🚀 |
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.
Summary
Implements explicit validation for configurable protocol fee bounds and adds contract integration tests for invalid creator and insufficient payment paths on
buy_key. Closes the scoped work for fee guardrails and marketplace edge-case coverage.Related issues
Changes
Protocol fee bounds (#13)
fee::PROTOCOL_BPS_MAX(5000 bps / 50%) as the maximum allowed configured protocol share.fee::assert_valid_fee_bps(creator_bps, protocol_bps):checked_addfor the bps sumcreator_bps + protocol_bps == BPS_MAXprotocol_bps <= PROTOCOL_BPS_MAXset_fee_confignow delegates toassert_valid_fee_bpsso all admin fee updates share one validation path.fee::compute_fee_splitis unchanged; only stored fee configuration is capped.Buy flow: price and payment (#16)
DataKey::KeyPriceandset_key_price(admin, price)(pricemust be positive, admin auth).buy_keynow takespayment: i128and requires a set key price; rejectspayment < pricewithinsufficient payment.creator not registered(now covered by tests).Tests
fee_split.rs: success at max protocol bps (5000/5000); panic when protocol bps exceeds cap.buy_key.rs: unregistered creator; insufficient payment; happy path with sufficient payment.Breaking changes
buy_keysignature: callers must passpayment: i128.set_key_pricebeforebuy_key(or invocations will panic withkey price not set).Update any scripts, clients, or docs that invoke
buy_keywithout the new argument or without initializing key price.Verification
cargo fmt --all -- --check cargo clippy --workspace --all-targets -- -D warnings cargo test --workspaceCloses #13
Closes #16