fix(distribute): mount orphaned pause module, unify StorageKey::Pause… - #1356
Open
Ahmad12developer wants to merge 2 commits into
Open
Ahmad12developer wants to merge 2 commits into
Ahmad12developer wants to merge 2 commits into
Conversation
CalloraOrg#1175) Problem ------- distribute/src/pause.rs was declared in the crate but not referenced in lib.rs, leaving it as dead code. Worse, lib.rs wrote the pause flag via a bare Symbol("paused") string key while pause.rs read/wrote via the StorageKey::Paused enum variant. These two keys serialize to different on-ledger entries, making the circuit-breaker silently inoperative if the module were ever wired in. Changes ------- contracts/distribute/src/lib.rs - Rename contract struct to CalloraDistribute (pub use alias Distribute kept for test backwards-compat); fixes CalloraDistributeClient export. - Declare pub mod pause and replace every Symbol(PAUSED_KEY) storage read/write with calls to pause::is_paused / pause::set_paused / pause::require_not_paused, so there is exactly one storage key. - Remove bare PAUSED_KEY string constant (now dead). - Migrate all other inline Symbol string keys (Admin, PendingAdmin, Usdc, MaxDistribute, ContractVersion) to use StorageKey enum variants so the entire storage layout is defined in one place. - Add BatchItem contracttype struct to fix the Soroban generics-on-tuple restriction in batch_distribute; Vec<BatchItem> replaces Vec<(Address,i128)>. - Add Severity enum and broadcast entrypoint referenced by auth_snap tests. - Re-export CalloraDistributeClient as DistributeClient for test compat. contracts/distribute/src/pause.rs - Refactor to three thin primitives: is_paused, set_paused, require_not_paused. - Auth checks and event emission remain in CalloraDistribute::pause/unpause (separation of concerns). - Replace catch_unwind-based unit tests (incompatible with Soroban Env's UnsafeCell interior mutability) with env.as_contract() scoped tests. - Add no_symbol_key_alias test: explicitly asserts no Symbol("paused") string key exists after set_paused, proving a single key invariant. contracts/distribute/src/limits.rs - Add Usdc, MaxDistribute, PendingAdmin variants to StorageKey so lib.rs can centralise all storage layout in the enum. contracts/distribute/src/events.rs - Fix event_version_v1: "callora.v1" → "callora_v1" (period is not a valid Symbol character in Soroban; previously caused a runtime InvalidInput). - Add event_broadcast for the new broadcast entrypoint. contracts/distribute/src/test.rs - Update event topic index assertions: topics are now (event_name, callora_v1, address) — Address moved from index 1 to index 2. - Fix require_auth_on_all_state_changing_functions: mock_all_auths only during setup (init + mint), then set_auths(&[]) for the auth checks. contracts/distribute/tests/auth_snap.rs - Rewrite for the actual CalloraDistribute API (previous version tested set_global_cap/open/close/get_account_count that don't exist in this contract). - Add pause_and_unpause_single_key_invariant: verifies is_paused() and get_paused() both reflect the same StorageKey::Paused value. Acceptance criteria ------------------- [x] Only one pause storage key exists (StorageKey::Paused) [x] No undeclared .rs files remain in distribute/src [x] Pause tests pass against the chosen key [x] Pause/unpause emit the same pause_set event regardless of path Validation: cargo test -p callora-distribute pause → 17 passed, 0 failed Full suite: cargo test -p callora-distribute → 73 passed, 0 failed Closes CalloraOrg#1175
|
@Ahmad12developer 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! 🚀 |
Contributor
|
Thanks for the contribution! We reviewed this PR while merging the open queue and couldn't merge it yet. Here's what needs fixing:
This branch also has merge conflicts with |
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.
…d (#1175)
Problem
distribute/src/pause.rs was declared in the crate but not referenced in lib.rs, leaving it as dead code. Worse, lib.rs wrote the pause flag via a bare Symbol("paused") string key while pause.rs read/wrote via the StorageKey::Paused enum variant. These two keys serialize to different on-ledger entries, making the circuit-breaker silently inoperative if the module were ever wired in.
Changes
contracts/distribute/src/lib.rs
contracts/distribute/src/pause.rs
contracts/distribute/src/limits.rs
contracts/distribute/src/events.rs
contracts/distribute/src/test.rs
contracts/distribute/tests/auth_snap.rs
Acceptance criteria
[x] Only one pause storage key exists (StorageKey::Paused)
[x] No undeclared .rs files remain in distribute/src
[x] Pause tests pass against the chosen key
[x] Pause/unpause emit the same pause_set event regardless of path
Validation: cargo test -p callora-distribute pause → 17 passed, 0 failed
Full suite: cargo test -p callora-distribute → 73 passed, 0 failed
Closes #1175