Skip to content

Commit

Permalink
ref: add IPausable trait
Browse files Browse the repository at this point in the history
Refers #336
  • Loading branch information
bidzyyys committed Oct 15, 2024
1 parent 4106d03 commit bb8696b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
5 changes: 1 addition & 4 deletions contracts/src/token/erc20/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -580,10 +580,7 @@ mod tests {
use stylus_sdk::msg;

use super::{Erc20, Error, IErc20};
use crate::{
token::erc721::{Erc721, IErc721},
utils::introspection::erc165::IErc165,
};
use crate::utils::introspection::erc165::IErc165;

#[motsu::test]
fn reads_balance(contract: Erc20) {
Expand Down
16 changes: 13 additions & 3 deletions contracts/src/utils/pausable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,23 @@ sol_storage! {
}
}

#[public]
impl Pausable {
/// Required interface of a [`Pausable`] compliant contract.
pub trait IPausable {
/// The error type associated to the trait implementation.
type Error: Into<alloc::vec::Vec<u8>>;

/// Returns true if the contract is paused, and false otherwise.
///
/// # Arguments
///
/// * `&self` - Read access to the contract's state.
fn paused(&self) -> bool;
}

#[public]
impl IPausable for Pausable {
type Error = Error;

fn paused(&self) -> bool {
self._paused.get()
}
Expand Down Expand Up @@ -147,7 +157,7 @@ impl Pausable {

#[cfg(all(test, feature = "std"))]
mod tests {
use crate::utils::pausable::{Error, Pausable};
use crate::utils::pausable::{Error, IPausable, Pausable};

#[motsu::test]
fn paused_works(contract: Pausable) {
Expand Down

0 comments on commit bb8696b

Please sign in to comment.