Skip to content

Commit

Permalink
docs(erc20): improve docs for ERC20Burnable (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
bidzyyys committed Apr 9, 2024
1 parent 43e4341 commit 907e6da
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
14 changes: 11 additions & 3 deletions contracts/src/erc20/extensions/burnable.rs
Original file line number Diff line number Diff line change
@@ -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}

Check warning on line 10 in contracts/src/erc20/extensions/burnable.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] contracts/src/erc20/extensions/burnable.rs#L10

warning: item in documentation is missing backticks --> contracts/src/erc20/extensions/burnable.rs:10:7 | 10 | /// * alloy_primitives::{Address, U256} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown help: try | 10 | /// * `alloy_primitives::{Address`, U256} | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Raw output
contracts/src/erc20/extensions/burnable.rs:10:7:w:warning: item in documentation is missing backticks
  --> contracts/src/erc20/extensions/burnable.rs:10:7
   |
10 | /// * alloy_primitives::{Address, U256}
   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown
help: try
   |
10 | /// * `alloy_primitives::{Address`, U256}
   |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~


__END__
/// * contracts::erc20::{Error, ERC20}

Check warning on line 11 in contracts/src/erc20/extensions/burnable.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] contracts/src/erc20/extensions/burnable.rs#L11

warning: item in documentation is missing backticks --> contracts/src/erc20/extensions/burnable.rs:11:7 | 11 | /// * contracts::erc20::{Error, ERC20} | ^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown help: try | 11 | /// * `contracts::erc20::{Error`, ERC20} | ~~~~~~~~~~~~~~~~~~~~~~~~~~
Raw output
contracts/src/erc20/extensions/burnable.rs:11:7:w:warning: item in documentation is missing backticks
  --> contracts/src/erc20/extensions/burnable.rs:11:7
   |
11 | /// * contracts::erc20::{Error, ERC20}
   |       ^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown
help: try
   |
11 | /// * `contracts::erc20::{Error`, ERC20}
   |       ~~~~~~~~~~~~~~~~~~~~~~~~~~


__END__
/// * stylus_sdk::msg

Check warning on line 12 in contracts/src/erc20/extensions/burnable.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] contracts/src/erc20/extensions/burnable.rs#L12

warning: item in documentation is missing backticks --> contracts/src/erc20/extensions/burnable.rs:12:7 | 12 | /// * stylus_sdk::msg | ^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown help: try | 12 | /// * `stylus_sdk::msg` | ~~~~~~~~~~~~~~~~~
Raw output
contracts/src/erc20/extensions/burnable.rs:12:7:w:warning: item in documentation is missing backticks
  --> contracts/src/erc20/extensions/burnable.rs:12:7
   |
12 | /// * stylus_sdk::msg
   |       ^^^^^^^^^^^^^^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown
help: try
   |
12 | /// * `stylus_sdk::msg`
   |       ~~~~~~~~~~~~~~~~~


__END__
macro_rules! impl_erc20_burnable {

Check warning on line 13 in contracts/src/erc20/extensions/burnable.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] contracts/src/erc20/extensions/burnable.rs#L13

warning: item name ends with its containing module's name --> contracts/src/erc20/extensions/burnable.rs:13:14 | 13 | macro_rules! impl_erc20_burnable { | ^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#module_name_repetitions = note: `#[warn(clippy::module_name_repetitions)]` implied by `#[warn(clippy::pedantic)]`
Raw output
contracts/src/erc20/extensions/burnable.rs:13:14:w:warning: item name ends with its containing module's name
  --> contracts/src/erc20/extensions/burnable.rs:13:14
   |
13 | macro_rules! impl_erc20_burnable {
   |              ^^^^^^^^^^^^^^^^^^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#module_name_repetitions
   = note: `#[warn(clippy::module_name_repetitions)]` implied by `#[warn(clippy::pedantic)]`


__END__
() => {
/// Destroys a `value` amount of tokens from the caller.
/// lowering the total supply.
Expand Down Expand Up @@ -74,7 +82,7 @@ mod tests {
#[external]
#[inherit(ERC20)]
impl TestERC20Burnable {
derive_erc20_burnable!();
impl_erc20_burnable!();
}

impl Default for TestERC20Burnable {
Expand Down
23 changes: 14 additions & 9 deletions examples/erc20/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
Expand Down

0 comments on commit 907e6da

Please sign in to comment.