Skip to content

Conversation

@r-near
Copy link
Contributor

@r-near r-near commented Feb 25, 2025

Replaces the single manager_roles attribute with separate pause_roles and unpause_roles attributes in the Pausable plugin. This enables assigning different permissions for pausing and unpausing features.

Implementation

  • Modified pausable.rs trait and implementation to support separate role specifications
  • Updated test contracts and tests
  • Added migration documentation and CHANGELOG entry

Usage

// Before
#[pausable(manager_roles(Role::PauseManager))]

// After
#[pausable(
    pause_roles(Role::PauseManager),
    unpause_roles(Role::UnpauseManager)
)]

Impact

Breaking change that requires code updates when upgrading. This enables more granular security policies, particularly in scenarios where emergency pausing should be available to more accounts than unpausing.

@r-near r-near requested a review from a team February 26, 2025 19:05
@r-near r-near enabled auto-merge (squash) March 1, 2025 09:00
@r-near r-near merged commit ad57fd8 into master Mar 4, 2025
2 checks passed
@r-near r-near deleted the pausable branch March 4, 2025 11:52
#[serde(crate = "near_sdk::serde")]
pub enum Role {
// Previous role that could both pause and unpause
// PauseManager,
Copy link
Collaborator

@mitinarseny mitinarseny Mar 5, 2025

Choose a reason for hiding this comment

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

You should never remove a variant or add one more in the middle of enums with #[derive(AccessControlRole)], since it uses bitflags to store permissions for each AccountId.
Please, fix the migration guide.

Copy link
Collaborator

Choose a reason for hiding this comment

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

You should never remove a variant or add one more in the middle of enums with #[derive(AccessControlRole)], since it uses bitflags to store permissions for each AccountId.
Please, fix the migration guide.

@r-near can you please also add a migration test for this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

cc @r-near

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@karim-en PR here: #163

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.

Split pause and unpause roles Pausable: add pause & unpause roles

5 participants