Struct odra_modules::cep78::token::Cep78ContractRef

source ·
pub struct Cep78ContractRef { /* private fields */ }
Expand description

Cep78 Contract Ref.

Implementations§

source§

impl Cep78ContractRef

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

pub fn is_approved_for_all( &mut self, token_owner: Address, operator: Address ) -> bool

Returns if an account is operator for a token owner

source

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.

source

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.

source

pub fn metadata( &self, token_id: Maybe<u64>, token_hash: Maybe<String> ) -> String

Returns the metadata associated with the provided token_id

source

pub fn set_token_metadata( &mut self, token_id: Maybe<u64>, token_hash: Maybe<String>, token_meta_data: String )

Updates the metadata if valid.

source

pub fn balance_of(&mut self, token_owner: Address) -> u64

Returns number of owned tokens associated with the provided token holder

source

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.

source

pub fn is_whitelisted(&self, address: &Address) -> bool

source

pub fn get_whitelist_mode(&self) -> WhitelistMode

source

pub fn get_collection_name(&self) -> String

source

pub fn get_collection_symbol(&self) -> String

source

pub fn is_minting_allowed(&self) -> bool

source

pub fn is_operator_burn_mode(&self) -> bool

source

pub fn get_total_supply(&self) -> u64

source

pub fn get_minting_mode(&self) -> MintingMode

source

pub fn get_holder_mode(&self) -> NFTHolderMode

source

pub fn get_number_of_minted_tokens(&self) -> u64

source

pub fn get_metadata_by_kind( &self, kind: NFTMetadataKind, token_id: Maybe<u64>, token_hash: Maybe<String> ) -> String

source

pub fn get_token_issuer( &self, token_id: Maybe<u64>, token_hash: Maybe<String> ) -> Address

source

pub fn token_burned( &self, token_id: Maybe<u64>, token_hash: Maybe<String> ) -> bool

Trait Implementations§

source§

impl ContractRef for Cep78ContractRef

source§

fn new(env: Rc<ContractEnv>, address: Address) -> Self

Creates a new instance of the Contract Ref.
source§

fn address(&self) -> &Address

Returns the address of the contract.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.