Add a batch transfer function allowing holders to send keys to multiple recipients in a single transaction - #814
Closed
teethaking wants to merge 28 commits into
Closed
Add a batch transfer function allowing holders to send keys to multiple recipients in a single transaction#814teethaking wants to merge 28 commits into
teethaking wants to merge 28 commits into
Conversation
Add batch_transfer_keys(creator, from, transfers: Vec<(Address, u32)>) allowing a holder to send keys to up to 10 recipients in a single atomic transaction. Changes: - ContractError: append BatchTransferSizeExceeded = 51, InvalidRecipient = 52 - Add MAX_BATCH_TRANSFER_SIZE = 10 constant - Implement batch_transfer_keys with pre-flight validation pass then apply pass, matching the two-pass pattern used by airdrop_keys; dividend checkpoints settled for sender and each recipient before balance changes - events.rs: add BATCH_TRANSFER_COMPLETED_EVENT_NAME, BatchTransferCompletedEvent struct, and batch_transfer_completed_topics helper - tests/batch_transfer_keys.rs: 11 integration tests covering balance updates, supply invariant, holder count, and all error paths - tests/batch_transfer_event_fields.rs: 7 event-field unit tests Closes accesslayerorg#799
feat: add batch_transfer_keys entrypoint (accesslayerorg#799)
|
@teethaking 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! 🚀 |
…get_curve_exponent (accesslayerorg#755 accesslayerorg#756) Implement five missing entrypoints referenced by test_issues.rs: - ContractError: append BatchSizeExceeded=53, InvalidExponent=54, RoyaltyExceedsLimit=55 - BatchBuyResult contracttype struct (creator, quantity, price_paid) - batch_buy(buyer, orders: Vec<(Address,u32)>): 1-5 orders, calls buy_key quantity times per creator at current quote price; BatchSizeExceeded on empty or >MAX_BATCH_BUY_SIZE orders - set_royalty(creator, buy_fee_bps, sell_fee_bps): creator-auth, validates <= MAX_ROYALTY_BPS (500), stores RoyaltyConfig, emits RoyaltyUpdatedEvent - get_royalty_config(creator) -> Option<RoyaltyConfig>: read-only view - migrate_curve(admin, exponent, key_ids): admin-auth, exponent 1-5, writes CurveExponent per creator, emits CurveMigratedEvent - get_curve_exponent(creator) -> Option<u32>: read-only view
test_issues.rs: add missing 7th &None (whitelist param) to all 6 direct client.register_creator calls that were written before whitelist was added. test_new_features.rs: replace non-existent client.initialize(&admin, &treasury, &price) with the actual setup sequence: set_protocol_admin + set_key_price + set_fee_config + set_treasury_address. Also add 2 missing &None args to the register_creator helper.
…ix test arg counts DataKey: add ProtocolFeeBps, LockupDurationSecs, RoyaltyConfig, CurveExponent, HolderCapBps, LastBuyTimestamp variants (referenced in lib.rs but absent from enum). constants::storage: add holder_cap_bps, last_buy_timestamp helpers and PROTOCOL_FEE_BPS, LOCKUP_DURATION_SECS constants; remove duplicate royalty_config/curve_exponent definitions. ContractError: append MaxHoldingExceeded=56, LockupPeriodActive=57, InvalidHolderCap=58 (referenced throughout lib.rs but never defined). events.rs: add FeeCollectedEvent + fee_collected_topics (used by collect_protocol_trade_fee) and LockupBlockedEvent + lockup_blocked_topics (used by sell_key lockup enforcement path). test_issues.rs: revert erroneous extra &None contract register_creator takes params + 6 optional args (7 total), tests correctly pass 6 options. test_new_features.rs: register_creator helper had 5 &None, needs 6.
Member
❌ CI Failed —
|
Member
|
Fix CI and MC |
Contributor
Author
|
alright on it
…On Fri, Sep 4, 2026, 4:41 PM Sebastian Anioke ***@***.***> wrote:
*Chucks1093* left a comment (accesslayerorg/accesslayer-contracts#814)
<#814 (comment)>
Fix CI and MC
—
Reply to this email directly, view it on GitHub
<#814?email_source=notifications&email_token=BD2MJO7QGMFOKZX4SA64BTT5NLPEHA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTKNJUGI4TCMRYGQZKM4TFMFZW63VGMF2XI2DPOKSWK5TFNZ2KYZTPN52GK4S7MNWGSY3L#issuecomment-5542912842>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BD2MJO7WIKQTILKXRNJFRZL5NLPEHAVCNFSNUABGKJSXA33TNF2G64TZHMYTCOBRGYYTEMRVGQ5US43TOVSTWNJSGY4TGNJXHEZDJILWAI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
The first of two duplicate `last_buy_timestamp` functions inside `constants::storage` was missing its closing brace, which caused `cargo fmt` to fail with an unclosed delimiter error at EOL. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
…n events.rs Same pattern as lib.rs: duplicate FeeCollectedEvent and LockupBlockedEvent structs where the first copy of each was missing its closing brace, plus a duplicate LOCKUP_BLOCKED_EVENT_NAME constant. Removed the incomplete first copies and the extra constant. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
Two-space indent changed to four-space to match surrounding enum variants and satisfy cargo fmt. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
…rors Merge conflicts introduced duplicate variants for ProtocolFeeBps, HolderCapBps, LockupDurationSecs, RoyaltyConfig, CurveExponent, and LastBuyTimestamp. The derive macros (PartialEq, Debug) and contracttype macro cannot handle duplicates, causing E0004 non-exhaustive patterns and 85 total compilation errors. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
Remove duplicate DataKey variants (RoyaltyConfig, CurveExponent), duplicate constants::storage functions (royalty_config, curve_exponent, last_buy_timestamp), and duplicate contract methods (batch_buy, set_royalty, get_royalty_config, migrate_curve, get_curve_exponent) that were introduced by failed merge conflict resolution. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
The dedup script missed royalty_config, curve_exponent, and last_buy_timestamp in constants::storage (8-space indent) because the regex only matched 4-space depth. These 3 duplicates caused 71 compilation errors from duplicate name definitions. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
Three ContractError variants (MaxHoldingExceeded, LockupPeriodActive, InvalidHolderCap) appeared twice with different discriminant values, and 8 other variants had colliding values. Removed the 3 duplicates, renumbered the 7 unique second-block variants to 59-65, and shifted trailing variants to 66-69. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
Merge conflict left two definitions with different symbol values (lck_blk vs lk_blk). Removed the second occurrence to fix E0428. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
Merge conflict left two identical definitions. Removed the second occurrence to prevent E0428 duplicate definition error. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
Remove duplicate checked_sub/saturating_sub in burn function and replace manual subtraction with saturating_sub in fee computation. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
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
Closes #799
Adds
batch_transfer_keys(creator, from, transfers: Vec<(Address, u32)>)— a new entrypoint that lets any holder distribute keys to up to 10 recipients in one signed, atomic transaction.Changes
creator-keys/src/lib.rsContractError: appendBatchTransferSizeExceeded = 51andInvalidRecipient = 52(ABI-safe, end-of-enum)MAX_BATCH_TRANSFER_SIZE = 10constantbatch_transfer_keysimplementation:from.require_auth()+assert_not_pausedguardsbalance < total_quantityBatchTransferCompletedEventcreator-keys/src/events.rsBATCH_TRANSFER_COMPLETED_EVENT_NAME = symbol_short!("bat_xfer")BatchTransferCompletedEvent { creator_id, from, transfers, total_transferred, ledger }batch_transfer_completed_topics(creator, from)helperTests
tests/batch_transfer_keys.rs— 11 integration tests:BatchTransferSizeExceededon 11 entries; succeeds on exactly 10InsufficientBalance+ state unchanged when total > balanceInvalidRecipientwhen any recipient == senderZeroTransferAmountwhen any entry has qty == 0NotRegisteredfor unregistered creatortests/batch_transfer_event_fields.rs— 7 event-field unit tests:creator_id,from,total_transferred,transfers.len(), per-entry(address, qty),ledgerfields