Skip to content

feat: implement admin module and update contract test snapshots#611

Open
Oluwasuyi-Timilehin wants to merge 7 commits into
Pulsefy:mainfrom
Oluwasuyi-Timilehin:feat/sc-pause-reason-codes
Open

feat: implement admin module and update contract test snapshots#611
Oluwasuyi-Timilehin wants to merge 7 commits into
Pulsefy:mainfrom
Oluwasuyi-Timilehin:feat/sc-pause-reason-codes

Conversation

@Oluwasuyi-Timilehin

Copy link
Copy Markdown

#closes #569

Pull Request: Diagnostic Pause Reason Codes & Structured Events

This PR improves the debuggability and auditability of the QuickEx contract when operations are paused. It introduces explicit reason codes for global and feature-specific pauses, exposes read-only getters for backends/clients, and emits structured events whenever pause states transition or block an operation.

Key Changes

1. Stable Reason Codes & Storage Mapping

  • Introduced the PauseReason enum in types.rs containing stable discriminant values for common pause contexts (SystemMaintenance = 1, SecurityEmergency = 2, FeatureUpgrade = 3, RegulatoryCompliance = 4, OperatorIntervention = 5).
  • Added persistent storage mappings for the global pause reason code (GlobalPauseReason) and granular feature-specific pause reasons (FeaturePauseReasons) in storage.rs.

2. Structured Transition & Enforcement Events

Registered three new event schemas in the canonical catalog EVENT_SCHEMAS in events.rs:

  • PauseEnabled: Emitted when a pause state is enabled globally or locally on a feature, recording the admin authorizer, whether it is global, the target feature flag, and the reason code.
  • PauseDisabled: Emitted when a pause state is lifted.
  • PauseEnforced: Emitted inline right before a blocked operation returns a pause error, containing the caller address, blocked action symbol, and the reason code.

3. Administrative Interface & Entrypoint Updates

  • Modified administrative functions set_paused, pause_features, and unpause_features in admin.rs to accept the new reason: u32 code argument, persist it, and publish the transition events.
  • Exposed view methods get_global_pause_reason(env) and get_feature_pause_reason(env, flag) in lib.rs for clients and backends.
  • Hooked all operation pause-checks in lib.rs to emit PauseEnforced events containing the exact active reason code.

4. Tests Modification

  • Updated all unit, storage, stealth, role, and upgrade test files to provide reason codes for administrative calls.
  • Extended the schema catalog size assertion in test.rs from 21 to 24 schemas.
  • Added integration test test_pause_reason_codes_and_events to verify the new get/set flow.
  • Refactored test_event_snapshot_contract_paused_schema to search specifically for the ContractPaused topic, preventing mismatch failures from the co-emitted PauseEnabled event.
    #closes

@drips-wave

drips-wave Bot commented Jun 26, 2026

Copy link
Copy Markdown

@Oluwasuyi-Timilehin 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! 🚀

Learn more about application limits

@Cedarich

Copy link
Copy Markdown
Contributor

@Oluwasuyi-Timilehin fix workflow

@Oluwasuyi-Timilehin

Copy link
Copy Markdown
Author

Okay will do

@Oluwasuyi-Timilehin

Copy link
Copy Markdown
Author

@Cedarich I already fixed it

@Cedarich

Copy link
Copy Markdown
Contributor

@Oluwasuyi-Timilehin

@Oluwasuyi-Timilehin

Copy link
Copy Markdown
Author

@Cedarich sorry, it has been fiixed now

@Cedarich

Copy link
Copy Markdown
Contributor

@Oluwasuyi-Timilehin

@Oluwasuyi-Timilehin

Copy link
Copy Markdown
Author

@Cedarich it has been fixed

@Cedarich Cedarich left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello 👋 please review this PR the changes made are too much 3000+

@Oluwasuyi-Timilehin

Copy link
Copy Markdown
Author

@Cedarich the ci was failing cause of the formatting, and after formatting those were the files changed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SC-W6-08: Pause Reason Codes + Events

2 participants