0x0::supply_domain

Module of collection SupplyDomain

A Collection with a defined SupplyDomain has a regulated supply. Collections can have a ceiling on the maximum supply and keep track of the current supply, whilst unregulated policies have no supply constraints nor they keep track of the number of minted objects.

Regulated policies are enforced by

Structs

supply_domain::SupplyDomain<C> has store

Fields:

Name Type Description
supply supply::Supply

supply_domain::Witness has drop

Witness used to authenticate witness protected endpoints

Methods

public fun supply<C>(
    collection: &collection::Collection<C>,
): &supply::Supply

Borrows Supply from Collection

Panics

Panics if SupplyDomain is not registered on Collection.

public fun is_regulated<C>(
    collection: &collection::Collection<C>,
): bool

Returns whether Collection supply is regulated

public fun regulate<C, W>(
    witness: &W,
    collection: &mut collection::Collection<C>,
    max: u64,
    frozen: bool,
)

Regulate the supply of Collection

Panics

Panics if collection is already regulated.

public fun deregulate<C>(
    _witness: witness::Witness<C>,
    collection: &mut collection::Collection<C>,
)

Deregulate the supply of Collection

Panics

Panics if collection is unregulated or supply is non-zero or frozen.

public fun freeze_supply<C>(
    _witness: witness::Witness<C>,
    collection: &mut collection::Collection<C>,
)

Freeze the supply of Collection

Panics

Panics if collection is unregulated or supply was already frozen.

public fun delegate<C>(
    mint_cap: &mint_cap::MintCap<C>,
    collection: &mut collection::Collection<C>,
    value: u64,
    ctx: &mut tx_context::TxContext,
): mint_cap::RegulatedMintCap<C>

Delegate partial DelegatedSupply<C> for use in composing an Inventory.

The extend value is used as the maximum supply for the new RegulatedMintCap, while the current supply of the existing supply is incremented by the value.

Requires that collection supply is frozen.

Panics

Panics if collection is unregulated, supply is not frozen, or if there is no excess supply to delegate a supply of value.

public entry fun delegate_and_transfer<C>(
    mint_cap: &mint_cap::MintCap<C>,
    collection: &mut collection::Collection<C>,
    value: u64,
    receiver: address,
    ctx: &mut tx_context::TxContext,
)

Delegate partial DelegatedSupply<C> for use in composing an Inventory and transfer to transaction sender.

The extend value is used as the maximum supply for the new RegulatedMintCap, while the current supply of the existing supply is incremented by the value.

Requires that collection supply is frozen.

Panics

Panics if collection is unregulated, supply is not frozen, or if there is no excess supply to delegate a supply of value.

public entry fun merge_delegated<C>(
    collection: &mut collection::Collection<C>,
    delegated: mint_cap::RegulatedMintCap<C>,
)

Merge delegated RegulatedMintCap

Any excess supply on the merged RegulatedMintCap will be decremented from the original Supply.

Panics

Panics if collection is unregulated.

public fun delegate_unregulated<C>(
    mint_cap: &mint_cap::MintCap<C>,
    collection: &collection::Collection<C>,
    ctx: &mut tx_context::TxContext,
): mint_cap::UnregulatedMintCap<C>

Delegate unregulated mint permission for use in composing a Factory.

Requires that collection supply is unregulated, therefore must not be called if you intend to register a SupplyDomain in the future.

Panics

Panics if collection is regulated.

public entry fun delegate_unregulated_and_transfer<C>(
    mint_cap: &mint_cap::MintCap<C>,
    collection: &collection::Collection<C>,
    receiver: address,
    ctx: &mut tx_context::TxContext,
)

Delegate unregulated mint permission for use in composing a Factory and transfer to transaction sender.

Requires that collection supply is unregulated, therefore must not be called if you intend to register a SupplyDomain in the future.

Panics

Panics if collection is regulated.

public entry fun increase_max_supply<C>(
    collection: &mut collection::Collection<C>,
    _mint_cap: &mint_cap::MintCap<C>,
    value: u64,
)

Increases maximum supply

Panics

Panics if collection is unregulated or supply is frozen.

public entry fun decrease_max_supply<C>(
    collection: &mut collection::Collection<C>,
    _mint_cap: &mint_cap::MintCap<C>,
    value: u64,
)

Decreases maximum supply

Panics

Panics if collection is unregulated, supply is frozen, or if new maximum supply is smaller than current supply.

public fun increment_supply<C>(
    collection: &mut collection::Collection<C>,
    _mint_cap: &mint_cap::MintCap<C>,
    value: u64,
)

Increments current supply

Panics

Panics if collection is unregulated or supply exceeds maximum.

public fun decrement_supply<C>(
    collection: &mut collection::Collection<C>,
    _mint_cap: &mint_cap::MintCap<C>,
    value: u64,
)

Increments current supply

Panics

Panics if collection is unregulated.

public fun assert_regulated<C>(
    collection: &collection::Collection<C>,
)

Assert that the Collection supply is regulated

public fun assert_unregulated<C>(
    collection: &collection::Collection<C>,
)

Assert that the Collection supply is not regulated