Skip to content

Commit

Permalink
feat(erc20): add ERC20Burnable to example
Browse files Browse the repository at this point in the history
  • Loading branch information
bidzyyys committed Apr 9, 2024
1 parent c4f2ed0 commit 43e4341
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions contracts/src/erc20/extensions/burnable.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//! 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 {

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

View workflow job for this annotation

GitHub Actions / clippy

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

warning: item name ends with its containing module's name --> contracts/src/erc20/extensions/burnable.rs:5:14 | 5 | macro_rules! derive_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:5:14:w:warning: item name ends with its containing module's name
 --> contracts/src/erc20/extensions/burnable.rs:5:14
  |
5 | macro_rules! derive_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.
Expand Down
3 changes: 2 additions & 1 deletion examples/erc20/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ publish = false
version = "0.0.0"

[dependencies]
contracts = { path = "../../contracts", features = ["erc20", "erc20_metadata"] }
contracts = { path = "../../contracts", features = ["erc20_metadata", "erc20_burnable"] }
alloy-primitives.workspace = true
stylus-sdk.workspace = true
stylus-proc.workspace = true
mini-alloc.workspace = true
Expand Down
13 changes: 11 additions & 2 deletions examples/erc20/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@ extern crate alloc;

use alloc::string::String;

use contracts::erc20::{extensions::Metadata, ERC20};
use stylus_sdk::prelude::{entrypoint, external, sol_storage};
use alloy_primitives::{Address, U256};
use contracts::{
derive_erc20_burnable,
erc20::{extensions::Metadata, Error, ERC20},
};
use stylus_sdk::{
msg,
prelude::{entrypoint, external, sol_storage},
};

const DECIMALS: u8 = 10;

Expand All @@ -21,6 +28,8 @@ sol_storage! {
#[external]
#[inherit(ERC20, Metadata)]
impl Token {
derive_erc20_burnable!();

pub fn constructor(&mut self, name: String, symbol: String) {
self.metadata.constructor(name, symbol);
}
Expand Down

0 comments on commit 43e4341

Please sign in to comment.