You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -306,15 +311,25 @@ The defult value of `Status` is `Status::NotPaused`.
306
311
307
312
Putting a toggle on a message (or any code section of your choosing) is as easy as calling `FeatureToggle::require_not_paused()`. For example if we have a `Redeem` message in our contract, and we initialized the feature as `Features::Redeem`:
@@ -324,7 +339,16 @@ If the status of the `Features::Redeem` feature is `Paused`, the contract will e
324
339
325
340
Firstly, we will need to add `Pause` and `Unpause` messages in our `HandleMsg` enum. We can simply use `FeatureToggle::FeatureToggleHandleMsg` - it's an enum that contains default messages that `FeatureToggle` also has default implementation for:
The `FeatureToggle` struct contains a default implementation for triggering (pausing/unpausing) a feature, so you can just call it from your `execute()` function:
FeatureToggleHandleMsg::Pause { features } => FeatureToggle::handle_pause(deps, env, features),
355
-
FeatureToggleHandleMsg::Unpause { features } => FeatureToggle::handle_unpause(deps, env, features),
401
+
FeatureToggleHandleMsg::Pause { features } =>FeatureToggle::handle_pause(deps, &info, features),
402
+
FeatureToggleHandleMsg::Unpause { features } =>FeatureToggle::handle_unpause(deps, &info, features),
403
+
// `SetPauser` and `RemovePauser` go here too
404
+
# _=>Ok(Response::new())
356
405
},
357
406
}
358
407
}
@@ -368,7 +417,29 @@ Note: you should only add `Features(FeatureToggleHandleMsg)` to the `HandleMsg`
368
417
369
418
`FeatureToggle` provides with default implementation for these too, but you can wrap it with your own logic like requiring the caller to be admin, etc.:
0 commit comments