Repository navigation
feat(security): implement pause_transfers emergency circuit breaker (#2) - #190
Open
rupesh-kumar-sah wants to merge 1 commit into
Open
rupesh-kumar-sah wants to merge 1 commit into
rupesh-kumar-sah wants to merge 1 commit into
Conversation
- Add DataKey::IsPaused boolean to contract storage - Implement pause_transfers and resume_transfers admin-guarded functions with events - Assert transfer execution is blocked when transfers are paused - Preserve mint_asset capability during transfer pauses for administrative operations - Add 6 comprehensive unit tests in src/test.rs verifying full circuit breaker lifecycle Closes Raegis-RWA#2
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
This PR implements an administrative emergency circuit breaker allowing authorized administrators to temporarily halt secondary market asset transfers (
pause_transfers/resume_transfers) without disrupting administrative minting and issuance operations.Key Changes
src/lib.rs):DataKey::IsPausedboolean flag to track transfer-specific pause state.src/admin.rs):pause_transfers(env, admin): Asserts admin authentication, prevents duplicate pause invocations, recordsDataKey::IsPaused = true, and emitstransfers_pausedevent.resume_transfers(env, admin): Asserts admin authentication, verifies currently paused, restoresDataKey::IsPaused = false, and emitstransfers_resumedevent.is_transfers_paused(env): Query helper reporting whether secondary market transfers are halted.src/asset.rs):transferfunction to assert!is_transfers_paused(&env)before balance mutations.mint_assetremains operational during transfer halts for administrative continuity.src/test.rs):test_pause_transfers_succeeds_for_admin: Validates admin pause flow.test_pause_transfers_reverts_for_non_admin: Confirms unauthorized callers are rejected.test_pause_transfers_reverts_when_already_paused: Confirms idempotency guard (Error::AlreadyPaused).test_resume_transfers_succeeds_for_admin: Validates resumption flow.test_resume_transfers_reverts_when_not_paused: Confirms guard (Error::NotPaused).test_transfer_blocked_and_mint_allowed_when_transfers_paused: Verifies transfers revert withError::ContractPausedwhilemint_assetproceeds successfully.Verification Proof
cargo test --lib: 227/227 tests passing 100% green.Closes #2