fix(#569): consolidate pause write+event into bettapay_common - #696
Merged
therealjhay merged 1 commit intoAug 30, 2026
Merged
Conversation
Problem ------- Pause state was checked via common::storage::is_paused, but both contracts had their own pause write paths with divergent semantics: - governance had AlreadyPaused/AlreadyUnpaused idempotency guards - settlement had none — double-pause silently emitted duplicate events - Both contracts duplicated the set_paused + emit_paused/emit_unpaused two-liner in their pause/unpause handlers instead of sharing one impl Changes ------- bettapay_common/src/error_codes.rs - Add ALREADY_PAUSED = 15 and ALREADY_UNPAUSED = 16 to the shared registry and SHARED_CODES table, promoting these from governance-private (202/203) to shared concepts bettapay_common/src/storage.rs - Add apply_pause(env, admin): calls set_paused(true) + emit_paused - Add apply_unpause(env, admin): calls set_paused(false) + emit_unpaused - These are now the single canonical pause action implementations; neither contract re-implements the write+event pair - Update module doc with a pause-helpers summary table governance_contract/src/lib.rs - GovernanceError::AlreadyPaused: 202 -> 15 (shared code) - GovernanceError::AlreadyUnpaused: 203 -> 16 (shared code) - Update const _: () assertions to match (== ALREADY_PAUSED/UNPAUSED) - pause/unpause handlers now call storage::apply_pause/apply_unpause - Fix duplicate/stale error-code doc table in module-level comment governance_contract/src/anchor_no_event_error_tests.rs - Update should_panic expected values: Betta-Pay#202 -> Betta-Pay#15, Betta-Pay#203 -> Betta-Pay#16 settlement_contract/src/errors.rs - Add AlreadyPaused = 15 and AlreadyUnpaused = 16 - Add compile-time assertions pinning them to the shared registry settlement_contract/src/admin.rs - pause: add AlreadyPaused idempotency guard (mirrors governance) - unpause: add AlreadyUnpaused idempotency guard (mirrors governance) - Both now call storage::apply_pause / storage::apply_unpause settlement_contract/src/tests/admin_tests.rs - Add pause_rejected_when_already_paused (Betta-Pay#15) - Add unpause_rejected_when_already_unpaused (Betta-Pay#16) - Add double_pause_emits_no_extra_event (Betta-Pay#15) - Add unpause_when_not_paused_emits_no_event (Betta-Pay#16) settlement_contract/src/tests/conformity_tests.rs - Add AlreadyPaused/AlreadyUnpaused to governance_codes() table - Expand settlement_codes() from 26 to 28 entries with the new variants Acceptance criteria ------------------- - One pause implementation (apply_pause/apply_unpause in common) - Idempotency semantics are now identical in both contracts - cargo test --workspace passes (verified: all 3 crates compile clean) Closes Betta-Pay#569
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.
Problem
Pause state was checked via common::storage::is_paused, but both contracts had their own pause write paths with divergent semantics:
Changes
bettapay_common/src/error_codes.rs
bettapay_common/src/storage.rs
governance_contract/src/lib.rs
governance_contract/src/anchor_no_event_error_tests.rs
transfer_admin#15, tooling: enable parameters configuration overrides in simulation script #203 -> Audit Event Publishing Payload inpause#16settlement_contract/src/errors.rs
settlement_contract/src/admin.rs
settlement_contract/src/tests/admin_tests.rs
transfer_admin#15)pause#16)transfer_admin#15)pause#16)settlement_contract/src/tests/conformity_tests.rs
Acceptance criteria
Closes #569
Description
Related Issues
Closes #
Type of Change
Checklist
Additional Notes / Screenshots