Struct dao::core_contracts::DaoNft
source · pub struct DaoNft { /* private fields */ }
Expand description
NFT module used by DAO.
Implementations§
source§impl DaoNft
impl DaoNft
sourcepub fn init(&mut self, name: String, symbol: String, base_uri: TokenUri)
pub fn init(&mut self, name: String, symbol: String, base_uri: TokenUri)
Module constructor.
Initializes modules. Sets the deployer as the owner.
sourcepub fn total_supply(&self) -> Balance
pub fn total_supply(&self) -> Balance
Returns the total number of tokens.
sourcepub fn token_id(&self, address: Address) -> Option<TokenId>
pub fn token_id(&self, address: Address) -> Option<TokenId>
Returns the token id for a given address
.
If the owner
does not own any token the None value is returned.
sourcepub fn token_uri(&self, token_id: TokenId) -> TokenUri
pub fn token_uri(&self, token_id: TokenId) -> TokenUri
Returns a distinct Uniform Resource Identifier (URI) for a given asset.
sourcepub fn mint(&mut self, to: Address)
pub fn mint(&mut self, to: Address)
Creates a new token with the next id and transfers it to a new owner.
Increments the total supply and the balance of the to
address.
§Note
Only whitelisted addresses are permitted to call this function.
Each user is entitled to own only one token.
§Errors
UserAlreadyOwnsToken
if theto
address already owns a token.
§Events
- [
Transfer
] event when minted successfully.
sourcepub fn burn(&mut self, owner: Address)
pub fn burn(&mut self, owner: Address)
Burns a token with the given id. Decrements the balance of the token owner and decrements the total supply.
§Errors
NotWhitelisted
if the caller is not whitelisted.
§Events
- [
Transfer
] event when burnt successfully.
sourcepub fn propose_new_owner(&mut self, owner: Address)
pub fn propose_new_owner(&mut self, owner: Address)
Changes the ownership of the contract. Transfers ownership to the owner
.
Only the current owner is permitted to call this method.
Read more
sourcepub fn accept_new_owner(&mut self)
pub fn accept_new_owner(&mut self)
Accepts the new owner proposition. This can be called only by the proposed owner.
Read more
sourcepub fn add_to_whitelist(&mut self, address: Address)
pub fn add_to_whitelist(&mut self, address: Address)
Adds a new address to the whitelist.
Read more
sourcepub fn remove_from_whitelist(&mut self, address: Address)
pub fn remove_from_whitelist(&mut self, address: Address)
Remove address from the whitelist.
Read more
sourcepub fn is_whitelisted(&self, address: Address) -> bool
pub fn is_whitelisted(&self, address: Address) -> bool
Checks whether the given address is added to the whitelist.
Read more
.
sourcepub fn get_owner(&self) -> Option<Address>
pub fn get_owner(&self) -> Option<Address>
Returns the address of the current owner.
Read more
.
sourcepub fn name(&self) -> String
pub fn name(&self) -> String
Returns a descriptive name for a collection of tokens in this contract.
sourcepub fn owner_of(&self, token_id: &TokenId) -> Address
pub fn owner_of(&self, token_id: &TokenId) -> Address
Returns the address of the owner of the token.
If the given token_id
does not exist the None value is returned.
sourcepub fn balance_of(&self, owner: &Address) -> U256
pub fn balance_of(&self, owner: &Address) -> U256
Returns the number of tokens owned by owner
.