diff --git a/contracts/src/erc20/extensions/burnable.rs b/contracts/src/erc20/extensions/burnable.rs index 11ef9ec7f..86e338b12 100644 --- a/contracts/src/erc20/extensions/burnable.rs +++ b/contracts/src/erc20/extensions/burnable.rs @@ -1,8 +1,16 @@ //! Optional Burnable extension of the ERC-20 standard. + #[macro_export] /// This macro provides implementation of ERC-20 Burnable extension. -/// It adds `burn` and `burn_from` function. -macro_rules! derive_erc20_burnable { +/// +/// It adds `burn` and `burn_from` function +/// to a custom token that contains `ERC20 erc20` attribute. +/// +/// Requires import of: +/// * alloy_primitives::{Address, U256} +/// * contracts::erc20::{Error, ERC20} +/// * stylus_sdk::msg +macro_rules! impl_erc20_burnable { () => { /// Destroys a `value` amount of tokens from the caller. /// lowering the total supply. @@ -74,7 +82,7 @@ mod tests { #[external] #[inherit(ERC20)] impl TestERC20Burnable { - derive_erc20_burnable!(); + impl_erc20_burnable!(); } impl Default for TestERC20Burnable { diff --git a/examples/erc20/src/lib.rs b/examples/erc20/src/lib.rs index f63d74202..84d157b9b 100644 --- a/examples/erc20/src/lib.rs +++ b/examples/erc20/src/lib.rs @@ -3,15 +3,18 @@ extern crate alloc; use alloc::string::String; +// Import required by ERC20Burnable extension. use alloy_primitives::{Address, U256}; -use contracts::{ - derive_erc20_burnable, - erc20::{extensions::Metadata, Error, ERC20}, -}; -use stylus_sdk::{ - msg, - prelude::{entrypoint, external, sol_storage}, -}; +// Import Metadata extension. +use contracts::erc20::extensions::Metadata; +// Import ERC20 token and its Errors. +use contracts::erc20::{Error, ERC20}; +// Import implementation of ERC20Burnable extension. +use contracts::impl_erc20_burnable; +// Import required by ERC20Burnable extension. +use stylus_sdk::msg; +// Stylus imports to build a smart contract. +use stylus_sdk::prelude::{entrypoint, external, sol_storage}; const DECIMALS: u8 = 10; @@ -28,7 +31,9 @@ sol_storage! { #[external] #[inherit(ERC20, Metadata)] impl Token { - derive_erc20_burnable!(); + // This macro implements ERC20Burnable functions -- `burn` and `burn_from`. + // Uses `erc20` Token's attribute. + impl_erc20_burnable!(); pub fn constructor(&mut self, name: String, symbol: String) { self.metadata.constructor(name, symbol);