Struct odra_modules::cep78::token::Cep78ContractRef
source · pub struct Cep78ContractRef { /* private fields */ }Expand description
Cep78 Contract Ref.
Implementations§
source§impl Cep78ContractRef
impl Cep78ContractRef
sourcepub fn init(
&mut self,
collection_name: String,
collection_symbol: String,
total_token_supply: u64,
ownership_mode: OwnershipMode,
nft_kind: NFTKind,
identifier_mode: NFTIdentifierMode,
nft_metadata_kind: NFTMetadataKind,
metadata_mutability: MetadataMutability,
receipt_name: String,
allow_minting: Maybe<bool>,
minting_mode: Maybe<MintingMode>,
holder_mode: Maybe<NFTHolderMode>,
whitelist_mode: Maybe<WhitelistMode>,
acl_whitelist: Maybe<Vec<Address>>,
json_schema: Maybe<String>,
burn_mode: Maybe<BurnMode>,
operator_burn_mode: Maybe<bool>,
owner_reverse_lookup_mode: Maybe<OwnerReverseLookupMode>,
events_mode: Maybe<EventsMode>,
transfer_filter_contract_contract: Maybe<Address>,
additional_required_metadata: Maybe<Vec<NFTMetadataKind>>,
optional_metadata: Maybe<Vec<NFTMetadataKind>>
)
pub fn init( &mut self, collection_name: String, collection_symbol: String, total_token_supply: u64, ownership_mode: OwnershipMode, nft_kind: NFTKind, identifier_mode: NFTIdentifierMode, nft_metadata_kind: NFTMetadataKind, metadata_mutability: MetadataMutability, receipt_name: String, allow_minting: Maybe<bool>, minting_mode: Maybe<MintingMode>, holder_mode: Maybe<NFTHolderMode>, whitelist_mode: Maybe<WhitelistMode>, acl_whitelist: Maybe<Vec<Address>>, json_schema: Maybe<String>, burn_mode: Maybe<BurnMode>, operator_burn_mode: Maybe<bool>, owner_reverse_lookup_mode: Maybe<OwnerReverseLookupMode>, events_mode: Maybe<EventsMode>, transfer_filter_contract_contract: Maybe<Address>, additional_required_metadata: Maybe<Vec<NFTMetadataKind>>, optional_metadata: Maybe<Vec<NFTMetadataKind>> )
Initializes the module.
sourcepub fn set_variables(
&mut self,
allow_minting: Maybe<bool>,
acl_whitelist: Maybe<Vec<Address>>,
operator_burn_mode: Maybe<bool>
)
pub fn set_variables( &mut self, allow_minting: Maybe<bool>, acl_whitelist: Maybe<Vec<Address>>, operator_burn_mode: Maybe<bool> )
Exposes all variables that can be changed by managing account post
installation. Meant to be called by the managing account (Installer)
if a variable needs to be changed.
By switching allow_minting to false minting is paused.
sourcepub fn mint(
&mut self,
token_owner: Address,
token_meta_data: String,
token_hash: Maybe<String>
) -> MintReceipt
pub fn mint( &mut self, token_owner: Address, token_meta_data: String, token_hash: Maybe<String> ) -> MintReceipt
Mints a new token with provided metadata.
Reverts with CEP78Error::MintingIsPaused error if allow_minting is false.
When a token is minted, the calling account is listed as its owner and the token is
automatically assigned an u64 ID equal to the current number_of_minted_tokens.
Before minting, the token checks if number_of_minted_tokens
exceeds the total_token_supply. If so, it reverts the minting with an error
CEP78Error::TokenSupplyDepleted. The mint function also checks whether the calling account
is the managing account (the installer) If not, and if public_minting is set to
false, it reverts with the error CEP78Error::InvalidAccount.
After minting is successful the number_of_minted_tokens is incremented by one.
sourcepub fn burn(&mut self, token_id: Maybe<u64>, token_hash: Maybe<String>)
pub fn burn(&mut self, token_id: Maybe<u64>, token_hash: Maybe<String>)
Burns the token with provided token_id argument, after which it is no
longer possible to transfer it.
Looks up the owner of the supplied token_id arg. If caller is not owner we revert with
error CEP78Error::InvalidTokenOwner. If the token id is invalid (e.g. out of bounds) it reverts
with error CEP78Error::InvalidTokenIdentifier. If the token is listed as already burnt we revert with
error CEP78Error::PreviouslyBurntToken. If not the token is then registered as burnt.
sourcepub fn transfer(
&mut self,
token_id: Maybe<u64>,
token_hash: Maybe<String>,
source_key: Address,
target_key: Address
) -> TransferReceipt
pub fn transfer( &mut self, token_id: Maybe<u64>, token_hash: Maybe<String>, source_key: Address, target_key: Address ) -> TransferReceipt
Transfers ownership of the token from one account to another.
It looks up the owner of the supplied token_id arg. Reverts if the token is already burnt,
token_id is invalid, or if caller is not owner nor an approved account nor operator.
If token id is invalid it reverts with error CEP78Error::InvalidTokenIdentifier.
sourcepub fn approve(
&mut self,
spender: Address,
token_id: Maybe<u64>,
token_hash: Maybe<String>
)
pub fn approve( &mut self, spender: Address, token_id: Maybe<u64>, token_hash: Maybe<String> )
Approves another token holder (an approved account) to transfer tokens. It reverts if token_id is invalid, if caller is not the owner nor operator, if token has already been burnt, or if caller tries to approve themselves as an approved account.
sourcepub fn revoke(&mut self, token_id: Maybe<u64>, token_hash: Maybe<String>)
pub fn revoke(&mut self, token_id: Maybe<u64>, token_hash: Maybe<String>)
Revokes an approved account to transfer tokens. It reverts if token_id is invalid, if caller is not the owner, if token has already been burnt, if caller tries to approve itself.
sourcepub fn set_approval_for_all(&mut self, approve_all: bool, operator: Address)
pub fn set_approval_for_all(&mut self, approve_all: bool, operator: Address)
Approves all tokens owned by the caller and future to another token holder (an operator) to transfer tokens. It reverts if token_id is invalid, if caller is not the owner, if caller tries to approve itself as an operator.
sourcepub fn is_approved_for_all(
&mut self,
token_owner: Address,
operator: Address
) -> bool
pub fn is_approved_for_all( &mut self, token_owner: Address, operator: Address ) -> bool
Returns if an account is operator for a token owner
sourcepub fn owner_of(
&self,
token_id: Maybe<u64>,
token_hash: Maybe<String>
) -> Address
pub fn owner_of( &self, token_id: Maybe<u64>, token_hash: Maybe<String> ) -> Address
Returns the token owner given a token_id. It reverts if token_id is invalid. A burnt token still has an associated owner.
sourcepub fn get_approved(
&mut self,
token_id: Maybe<u64>,
token_hash: Maybe<String>
) -> Option<Address>
pub fn get_approved( &mut self, token_id: Maybe<u64>, token_hash: Maybe<String> ) -> Option<Address>
Returns the approved account (if any) associated with the provided token_id Reverts if token has been burnt.
sourcepub fn metadata(
&self,
token_id: Maybe<u64>,
token_hash: Maybe<String>
) -> String
pub fn metadata( &self, token_id: Maybe<u64>, token_hash: Maybe<String> ) -> String
Returns the metadata associated with the provided token_id
sourcepub fn set_token_metadata(
&mut self,
token_id: Maybe<u64>,
token_hash: Maybe<String>,
token_meta_data: String
)
pub fn set_token_metadata( &mut self, token_id: Maybe<u64>, token_hash: Maybe<String>, token_meta_data: String )
Updates the metadata if valid.
sourcepub fn balance_of(&mut self, token_owner: Address) -> u64
pub fn balance_of(&mut self, token_owner: Address) -> u64
Returns number of owned tokens associated with the provided token holder
sourcepub fn register_owner(&mut self, token_owner: Maybe<Address>) -> String
pub fn register_owner(&mut self, token_owner: Maybe<Address>) -> String
This entrypoint allows users to register with a give CEP-78 instance, allocating the necessary page table to enable the reverse lookup functionality and allowing users to pay the upfront cost of allocation resulting in more stable gas costs when minting and transferring Note: This entrypoint MUST be invoked if the reverse lookup is enabled in order to own NFTs.