Skip to content

Commit

Permalink
Rename Pauseable to Pausable
Browse files Browse the repository at this point in the history
  • Loading branch information
kpob committed Mar 27, 2024
1 parent a6b3c2d commit 2c8012e
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 55 deletions.
2 changes: 1 addition & 1 deletion docusaurus/docs/examples/using-odra-modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ Ownership can be transferred in a two-step process by using `transfer_ownership(

### Security

#### Pauseable
#### Pausable
A module allowing to implement an emergency stop mechanism that can be triggered by any account.

[Installation guide]: ../getting-started/installation.md
Expand Down
22 changes: 11 additions & 11 deletions docusaurus/docs/tutorials/pauseable.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
sidebar_position: 5
---

# Pauseable
# Pausable

The `Pauseable` module is like your smart contract's safety switch. It lets authorized users temporarily pause certain features if needed. It's a great way to boost security, but it's not meant to be used on its own. Think of it as an extra tool in your access control toolbox, giving you more control to manage your smart contract safely and efficiently.
The `Pausable` module is like your smart contract's safety switch. It lets authorized users temporarily pause certain features if needed. It's a great way to boost security, but it's not meant to be used on its own. Think of it as an extra tool in your access control toolbox, giving you more control to manage your smart contract safely and efficiently.

## Code

Expand Down Expand Up @@ -51,7 +51,7 @@ use odra::Var;
...

#[odra::module(events = [Paused, Unpaused])]
pub struct Pauseable {
pub struct Pausable {
is_paused: Var<bool>
}
```
Expand All @@ -61,7 +61,7 @@ pub struct Pauseable {
Now, let's move to state checks and guards.

```rust title=pauseable.rs showLineNumbers
impl Pauseable {
impl Pausable {
pub fn is_paused(&self) -> bool {
self.is_paused.get_or_default()
}
Expand Down Expand Up @@ -89,7 +89,7 @@ impl Pauseable {
Finally, we will add the ability to switch the module state.

```rust title=pauseable.rs showLineNumbers
impl Pauseable {
impl Pausable {
pub fn pause(&mut self) {
self.require_not_paused();
self.is_paused.set(true);
Expand All @@ -113,23 +113,23 @@ impl Pauseable {
`pause()` and `unpause()` functions do three things: ensure the contract is the right state (unpaused for `pause()`, not paused for `unpause()`), updates the state, and finally emits events (`Paused`/`Unpaused`).


## Pauseable counter
## Pausable counter

In the end, let's use the module in a contract. For this purpose, we will implement a mock contract called `PauseableCounter`. The contract consists of a Var `value` and a `Pauseable` module. The counter can only be incremented if the contract is in a normal state (is not paused).
In the end, let's use the module in a contract. For this purpose, we will implement a mock contract called `PausableCounter`. The contract consists of a Var `value` and a `Pausable` module. The counter can only be incremented if the contract is in a normal state (is not paused).

```rust title=pauseable.rs showLineNumbers
...
use odra::SubModule;
...

#[odra::module]
pub struct PauseableCounter {
pub struct PausableCounter {
value: Var<u32>,
pauseable: SubModule<Pauseable>
pauseable: SubModule<Pausable>
}

#[odra::module]
impl PauseableCounter {
impl PausableCounter {
pub fn increment(&mut self) {
self.pauseable.require_not_paused();

Expand Down Expand Up @@ -158,7 +158,7 @@ mod test {
#[test]
fn increment_only_if_unpaused() {
let test_env = odra_test::env();
let mut contract = PauseableCounterHostRef::deploy(&test_env, NoArgs);
let mut contract = PausableCounterHostRef::deploy(&test_env, NoArgs);
contract.increment();
contract.pause();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,5 +158,5 @@ Ownership can be transferred in a two-step process by using `transfer_ownership(

### Security

#### Pauseable
#### Pausable
A module allowing to implement an emergency stop mechanism that can be triggered by any account.
Original file line number Diff line number Diff line change
Expand Up @@ -158,5 +158,5 @@ Ownership can be transferred in a two-step process by using `transfer_ownership(

### Security

#### Pauseable
#### Pausable
A module allowing to implement an emergency stop mechanism that can be triggered by any account.
Original file line number Diff line number Diff line change
Expand Up @@ -158,5 +158,5 @@ Ownership can be transferred in a two-step process by using `transfer_ownership(

### Security

#### Pauseable
#### Pausable
A module allowing to implement an emergency stop mechanism that can be triggered by any account.
Original file line number Diff line number Diff line change
Expand Up @@ -158,5 +158,5 @@ Ownership can be transferred in a two-step process by using `transfer_ownership(

### Security

#### Pauseable
#### Pausable
A module allowing to implement an emergency stop mechanism that can be triggered by any account.
Original file line number Diff line number Diff line change
Expand Up @@ -158,5 +158,5 @@ Ownership can be transferred in a two-step process by using `transfer_ownership(

### Security

#### Pauseable
#### Pausable
A module allowing to implement an emergency stop mechanism that can be triggered by any account.
Original file line number Diff line number Diff line change
Expand Up @@ -158,5 +158,5 @@ Ownership can be transferred in a two-step process by using `transfer_ownership(

### Security

#### Pauseable
#### Pausable
A module allowing to implement an emergency stop mechanism that can be triggered by any account.
26 changes: 13 additions & 13 deletions docusaurus/versioned_docs/version-0.7.0/tutorials/pauseable.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
sidebar_position: 5
---

# Pauseable
# Pausable

The `Pauseable` module is like your smart contract's safety switch. It lets authorized users temporarily pause certain features if needed. It's a great way to boost security, but it's not meant to be used on its own. Think of it as an extra tool in your access control toolbox, giving you more control to manage your smart contract safely and efficiently.
The `Pausable` module is like your smart contract's safety switch. It lets authorized users temporarily pause certain features if needed. It's a great way to boost security, but it's not meant to be used on its own. Think of it as an extra tool in your access control toolbox, giving you more control to manage your smart contract safely and efficiently.

## Code

Expand Down Expand Up @@ -47,7 +47,7 @@ The module storage is extremely simple - has a single `Variable` of type bool, t

```rust showLineNumbers
#[odra::module]
pub struct Pauseable {
pub struct Pausable {
is_paused: Variable<bool>
}
```
Expand All @@ -57,7 +57,7 @@ pub struct Pauseable {
Now, let's move to state checks and guards.

```rust title=pauseable.rs showLineNumbers
impl Pauseable {
impl Pausable {
pub fn is_paused(&self) -> bool {
self.is_paused.get_or_default()
}
Expand Down Expand Up @@ -85,7 +85,7 @@ impl Pauseable {
Finally, we will add the ability to switch the module state.

```rust showLineNumbers
impl Pauseable {
impl Pausable {
pub fn pause(&mut self) {
self.require_not_paused();
self.is_paused.set(true);
Expand All @@ -111,22 +111,22 @@ impl Pauseable {
`pause()` and `unpause()` functions do three things: ensure the contract is the right state (unpaused for `pause()`, not paused for `unpause()`), updates the state, and finally emits events (`Paused`/`Unpaused`).


## Pauseable counter
## Pausable counter

In the end, let's use the module in a contract. For this purpose, we will implement a mock contract called `PauseableCounter`. The contract consists of a Variable `value` and a `Pauseable` module. The counter can only be incremented if the contract is in a normal state (is not paused).
In the end, let's use the module in a contract. For this purpose, we will implement a mock contract called `PausableCounter`. The contract consists of a Variable `value` and a `Pausable` module. The counter can only be incremented if the contract is in a normal state (is not paused).

```rust showLineNumbers
use odra::Variable;
use odra_modules::security::Pauseable;
use odra_modules::security::Pausable;

#[odra::module]
pub struct PauseableCounter {
pub struct PausableCounter {
value: Variable<u32>,
pauseable: Pauseable
pauseable: Pausable
}

#[odra::module]
impl PauseableCounter {
impl PausableCounter {
pub fn increment(&mut self) {
self.pauseable.require_not_paused();

Expand All @@ -149,12 +149,12 @@ impl PauseableCounter {

#[cfg(test)]
mod test {
use super::PauseableCounterDeployer;
use super::PausableCounterDeployer;
use odra_modules::security::errors::Error;

#[test]
fn increment_only_if_unpaused() {
let mut contract = PauseableCounterDeployer::default();
let mut contract = PausableCounterDeployer::default();
assert_eq!(contract.get_value(), 0);

contract.increment();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ Ownership can be transferred in a two-step process by using `transfer_ownership(

### Security

#### Pauseable
#### Pausable
A module allowing to implement an emergency stop mechanism that can be triggered by any account.

[Installation guide]: ../getting-started/installation.md
Expand Down
22 changes: 11 additions & 11 deletions docusaurus/versioned_docs/version-0.8.0/tutorials/pauseable.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
sidebar_position: 5
---

# Pauseable
# Pausable

The `Pauseable` module is like your smart contract's safety switch. It lets authorized users temporarily pause certain features if needed. It's a great way to boost security, but it's not meant to be used on its own. Think of it as an extra tool in your access control toolbox, giving you more control to manage your smart contract safely and efficiently.
The `Pausable` module is like your smart contract's safety switch. It lets authorized users temporarily pause certain features if needed. It's a great way to boost security, but it's not meant to be used on its own. Think of it as an extra tool in your access control toolbox, giving you more control to manage your smart contract safely and efficiently.

## Code

Expand Down Expand Up @@ -51,7 +51,7 @@ use odra::Var;
...

#[odra::module(events = [Paused, Unpaused])]
pub struct Pauseable {
pub struct Pausable {
is_paused: Var<bool>
}
```
Expand All @@ -61,7 +61,7 @@ pub struct Pauseable {
Now, let's move to state checks and guards.

```rust title=pauseable.rs showLineNumbers
impl Pauseable {
impl Pausable {
pub fn is_paused(&self) -> bool {
self.is_paused.get_or_default()
}
Expand Down Expand Up @@ -89,7 +89,7 @@ impl Pauseable {
Finally, we will add the ability to switch the module state.

```rust title=pauseable.rs showLineNumbers
impl Pauseable {
impl Pausable {
pub fn pause(&mut self) {
self.require_not_paused();
self.is_paused.set(true);
Expand All @@ -113,23 +113,23 @@ impl Pauseable {
`pause()` and `unpause()` functions do three things: ensure the contract is the right state (unpaused for `pause()`, not paused for `unpause()`), updates the state, and finally emits events (`Paused`/`Unpaused`).


## Pauseable counter
## Pausable counter

In the end, let's use the module in a contract. For this purpose, we will implement a mock contract called `PauseableCounter`. The contract consists of a Var `value` and a `Pauseable` module. The counter can only be incremented if the contract is in a normal state (is not paused).
In the end, let's use the module in a contract. For this purpose, we will implement a mock contract called `PausableCounter`. The contract consists of a Var `value` and a `Pausable` module. The counter can only be incremented if the contract is in a normal state (is not paused).

```rust title=pauseable.rs showLineNumbers
...
use odra::SubModule;
...

#[odra::module]
pub struct PauseableCounter {
pub struct PausableCounter {
value: Var<u32>,
pauseable: SubModule<Pauseable>
pauseable: SubModule<Pausable>
}

#[odra::module]
impl PauseableCounter {
impl PausableCounter {
pub fn increment(&mut self) {
self.pauseable.require_not_paused();

Expand Down Expand Up @@ -158,7 +158,7 @@ mod test {
#[test]
fn increment_only_if_unpaused() {
let test_env = odra_test::env();
let mut contract = PauseableCounterHostRef::deploy(&test_env, NoArgs);
let mut contract = PausableCounterHostRef::deploy(&test_env, NoArgs);
contract.increment();
contract.pause();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ Ownership can be transferred in a two-step process by using `transfer_ownership(

### Security

#### Pauseable
#### Pausable
A module allowing to implement an emergency stop mechanism that can be triggered by any account.

[Installation guide]: ../getting-started/installation.md
Expand Down
22 changes: 11 additions & 11 deletions docusaurus/versioned_docs/version-0.8.1/tutorials/pauseable.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
sidebar_position: 5
---

# Pauseable
# Pausable

The `Pauseable` module is like your smart contract's safety switch. It lets authorized users temporarily pause certain features if needed. It's a great way to boost security, but it's not meant to be used on its own. Think of it as an extra tool in your access control toolbox, giving you more control to manage your smart contract safely and efficiently.
The `Pausable` module is like your smart contract's safety switch. It lets authorized users temporarily pause certain features if needed. It's a great way to boost security, but it's not meant to be used on its own. Think of it as an extra tool in your access control toolbox, giving you more control to manage your smart contract safely and efficiently.

## Code

Expand Down Expand Up @@ -51,7 +51,7 @@ use odra::Var;
...

#[odra::module(events = [Paused, Unpaused])]
pub struct Pauseable {
pub struct Pausable {
is_paused: Var<bool>
}
```
Expand All @@ -61,7 +61,7 @@ pub struct Pauseable {
Now, let's move to state checks and guards.

```rust title=pauseable.rs showLineNumbers
impl Pauseable {
impl Pausable {
pub fn is_paused(&self) -> bool {
self.is_paused.get_or_default()
}
Expand Down Expand Up @@ -89,7 +89,7 @@ impl Pauseable {
Finally, we will add the ability to switch the module state.

```rust title=pauseable.rs showLineNumbers
impl Pauseable {
impl Pausable {
pub fn pause(&mut self) {
self.require_not_paused();
self.is_paused.set(true);
Expand All @@ -113,23 +113,23 @@ impl Pauseable {
`pause()` and `unpause()` functions do three things: ensure the contract is the right state (unpaused for `pause()`, not paused for `unpause()`), updates the state, and finally emits events (`Paused`/`Unpaused`).


## Pauseable counter
## Pausable counter

In the end, let's use the module in a contract. For this purpose, we will implement a mock contract called `PauseableCounter`. The contract consists of a Var `value` and a `Pauseable` module. The counter can only be incremented if the contract is in a normal state (is not paused).
In the end, let's use the module in a contract. For this purpose, we will implement a mock contract called `PausableCounter`. The contract consists of a Var `value` and a `Pausable` module. The counter can only be incremented if the contract is in a normal state (is not paused).

```rust title=pauseable.rs showLineNumbers
...
use odra::SubModule;
...

#[odra::module]
pub struct PauseableCounter {
pub struct PausableCounter {
value: Var<u32>,
pauseable: SubModule<Pauseable>
pauseable: SubModule<Pausable>
}

#[odra::module]
impl PauseableCounter {
impl PausableCounter {
pub fn increment(&mut self) {
self.pauseable.require_not_paused();

Expand Down Expand Up @@ -158,7 +158,7 @@ mod test {
#[test]
fn increment_only_if_unpaused() {
let test_env = odra_test::env();
let mut contract = PauseableCounterHostRef::deploy(&test_env, NoArgs);
let mut contract = PausableCounterHostRef::deploy(&test_env, NoArgs);
contract.increment();
contract.pause();

Expand Down

0 comments on commit 2c8012e

Please sign in to comment.