ERC-1155 Supply

The OpenZeppelin ERC-1155 Supply extension that adds tracking of total supply per token id. Useful for scenarios where Fungible and Non-fungible tokens have to be clearly identified.

Usage

In order to make an ERC-1155 token with Supply flavour, you need to reexport all the supply-related functions. Make sure to apply the #[selector(name = "totalSupply")] attribute to the total_supply_all function! You need to create the specified contract as follows:

use openzeppelin_stylus::{
    token::erc1155::{
        extensions::{Erc1155Supply, IErc1155Supply},
        Erc1155,
    },
    utils::introspection::erc165::IErc165,
};

#[entrypoint]
#[storage]
struct Erc1155Example {
    #[borrow]
    erc1155_supply: Erc1155Supply,
}

#[public]
#[inherit(Erc1155Supply)]
impl Erc1155Example {
    fn total_supply(&self, id: U256) -> U256 {
        self.erc1155_supply.total_supply(id)
    }

    #[selector(name = "totalSupply")]
    fn total_supply_all(&self) -> U256 {
        self.erc1155_supply.total_supply_all()
    }

    fn exists(&self, id: U256) -> bool {
        self.erc1155_supply.exists(id)
    }

    fn supports_interface(interface_id: FixedBytes<4>) -> bool {
        Erc1155::supports_interface(interface_id)
    }

    // ...
}