diff --git a/contracts/src/token/erc20/extensions/burnable.rs b/contracts/src/token/erc20/extensions/burnable.rs index fce7fe9a3..a6eaa4c10 100644 --- a/contracts/src/token/erc20/extensions/burnable.rs +++ b/contracts/src/token/erc20/extensions/burnable.rs @@ -9,7 +9,7 @@ use crate::token::erc20::{Erc20, Error}; /// their own tokens and those that they have an allowance for, /// in a way that can be recognized off-chain (via event analysis). pub trait IErc20Burnable { - /// The error type associated to this ERC-20 Burnable trait implementation. + /// The error type associated to the trait implementation. type Error: Into>; /// Destroys a `value` amount of tokens from the caller. lowering the total diff --git a/contracts/src/token/erc20/extensions/capped.rs b/contracts/src/token/erc20/extensions/capped.rs index 40fdea927..14308c19c 100644 --- a/contracts/src/token/erc20/extensions/capped.rs +++ b/contracts/src/token/erc20/extensions/capped.rs @@ -1,4 +1,4 @@ -//! Capped Contract. +//! Optional Capped Contract. //! //! Extension of ERC-20 standard that adds a cap to the supply of tokens. //! @@ -43,10 +43,21 @@ sol_storage! { } } +/// Extension of [`Erc-20`] that adds a cap to the supply of tokens. +pub trait IErc20Capped { + /// The error type associated to the trait implementation. + type Error: Into>; + + /// Returns the cap on the token's total supply. + fn cap(&self) -> U256; +} + #[public] -impl Capped { +impl IErc20Capped for Capped { + type Error = Error; + /// Returns the cap on the token's total supply. - pub fn cap(&self) -> U256 { + fn cap(&self) -> U256 { self._cap.get() } } @@ -55,7 +66,7 @@ impl Capped { mod tests { use alloy_primitives::uint; - use super::Capped; + use super::{Capped, IErc20Capped}; #[motsu::test] fn cap_works(contract: Capped) { diff --git a/contracts/src/token/erc20/extensions/mod.rs b/contracts/src/token/erc20/extensions/mod.rs index beaa80ecb..467f3dc4f 100644 --- a/contracts/src/token/erc20/extensions/mod.rs +++ b/contracts/src/token/erc20/extensions/mod.rs @@ -5,6 +5,6 @@ pub mod metadata; pub mod permit; pub use burnable::IErc20Burnable; -pub use capped::Capped; +pub use capped::{Capped, IErc20Capped}; pub use metadata::{Erc20Metadata, IErc20Metadata}; pub use permit::Erc20Permit; diff --git a/examples/erc20/src/lib.rs b/examples/erc20/src/lib.rs index 4d8ab3e05..0c421c5b4 100644 --- a/examples/erc20/src/lib.rs +++ b/examples/erc20/src/lib.rs @@ -6,7 +6,9 @@ use alloc::vec::Vec; use alloy_primitives::{Address, FixedBytes, U256}; use openzeppelin_stylus::{ token::erc20::{ - extensions::{capped, Capped, Erc20Metadata, IErc20Burnable}, + extensions::{ + capped, Capped, Erc20Metadata, IErc20Burnable, IErc20Capped, + }, Erc20, IErc20, }, utils::{introspection::erc165::IErc165, Pausable},