Repository navigation
feat(contracts): emit dedicated ProtocolPaused events on pause toggle… - #1608
Open
timiturn3r wants to merge 3 commits into
Open
timiturn3r wants to merge 3 commits into
timiturn3r wants to merge 3 commits into
Conversation
…LabsCrypt#1517) - Add ProtocolPausedEvent struct and emit_protocol_paused function in events.rs - Invoke emit_protocol_paused inside set_protocol_pause and expose set_emergency_pause in lib.rs - Emit event with topics ["FlowFi", "ProtocolPaused"] containing admin and is_paused status - Add unit tests verifying event emission on pause and unpause - Align storage stream field count and error variants for contract compilation
This branch has not been deployed
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.
Description
This pull request introduces dedicated Soroban contract events when toggling emergency protocol pause state in
stream_contract. Previously, setting or clearing the protocol pause state updated storage without emitting a dedicated standard event subscribed to by external indexers and monitoring agents.With this change:
ProtocolPausedEventand helper functionemit_protocol_pausedhave been introduced inevents.rs.["FlowFi", "ProtocolPaused"]and contain the caller/admin address and boolean pause state (is_paused).set_protocol_pauseinvokesemit_protocol_paused, and an alias entrypointset_emergency_pausehas been exposed inlib.rs.Type of Change
Related Issues
Closes #1517
Changes Made
contracts/stream_contract/src/events.rs):ProtocolPausedEventcontract type withadmin: Addressandis_paused: bool.emit_protocol_paused(env: &Env, admin: &Address, is_paused: bool)publishing under topics(Symbol::new(env, "FlowFi"), Symbol::new(env, "ProtocolPaused")).contracts/stream_contract/src/lib.rs):emit_protocol_paused(&env, &caller, paused)insideset_protocol_pause.set_emergency_pause(env: Env, admin: Address, paused: bool) -> Result<(), StreamError>entrypoint delegating toset_protocol_pause.protocol_pause_statusevent for backward compatibility.contracts/stream_contract/src/test.rs):test_protocol_pause_and_unpause_emit_dedicated_eventtesting both pause (is_paused: true) and unpause (is_paused: false) viaset_protocol_pause.test_set_emergency_pause_emits_dedicated_eventvalidating event emission viaset_emergency_pause.STREAM_FIELD_COUNT = 17instorage.rsmatching currentStreamfields.StreamStillActive,StreamNotActive,ArithmeticOverflow) toStreamError.Testing
Test Coverage
Test Steps
contracts/:cd contractscargo test cargo fmt --all -- --check cargo clippy --all-targets -- -D warningsBreaking Changes
None. Existing storage layouts and entrypoints are preserved, and the existing
protocol_pause_statusevent remains published alongside the new dedicated event.Screenshots/Demo
N/A (Smart Contract backend changes)
Checklist
backend/docs/observability/Additional Notes
All 224 unit and property tests in
stream_contractpass with 0 warnings oncargo clippy --all-targets -- -D warningsand cleancargo fmt.