Struct pallet_uniques::pallet::Pallet[][src]

pub struct Pallet<T, I = ()>(_);
Expand description

The pallet implementing the on-chain logic.

Implementations

Get the owner of the asset instance, if the asset exists.

Issue a new class of non-fungible assets from a public origin.

This new asset class has no assets initially and its owner is the origin.

The origin must be Signed and the sender must have sufficient funds free.

AssetDeposit funds of sender are reserved.

Parameters:

  • class: The identifier of the new asset class. This must not be currently in use.
  • admin: The admin of this class of assets. The admin is the initial address of each member of the asset class’s admin team.

Emits Created event when successful.

Weight: O(1)

Issue a new class of non-fungible assets from a privileged origin.

This new asset class has no assets initially.

The origin must conform to ForceOrigin.

Unlike create, no funds are reserved.

  • class: The identifier of the new asset. This must not be currently in use.
  • owner: The owner of this class of assets. The owner has full superuser permissions over this asset, but may later change and configure the permissions using transfer_ownership and set_team.

Emits ForceCreated event when successful.

Weight: O(1)

Destroy a class of fungible assets.

The origin must conform to ForceOrigin or must be Signed and the sender must be the owner of the asset class.

  • class: The identifier of the asset class to be destroyed.
  • witness: Information on the instances minted in the asset class. This must be correct.

Emits Destroyed event when successful.

Weight: O(n + m) where:

  • n = witness.instances
  • m = witness.instance_metadatas
  • a = witness.attributes

Mint an asset instance of a particular class.

The origin must be Signed and the sender must be the Issuer of the asset class.

  • class: The class of the asset to be minted.
  • instance: The instance value of the asset to be minted.
  • beneficiary: The initial owner of the minted asset.

Emits Issued event when successful.

Weight: O(1)

Destroy a single asset instance.

Origin must be Signed and the sender should be the Admin of the asset class.

  • class: The class of the asset to be burned.
  • instance: The instance of the asset to be burned.
  • check_owner: If Some then the operation will fail with WrongOwner unless the asset is owned by this value.

Emits Burned with the actual amount burned.

Weight: O(1) Modes: check_owner.is_some().

Move an asset from the sender account to another.

Origin must be Signed and the signing account must be either:

  • the Admin of the asset class;
  • the Owner of the asset instance;
  • the approved delegate for the asset instance (in this case, the approval is reset).

Arguments:

  • class: The class of the asset to be transferred.
  • instance: The instance of the asset to be transferred.
  • dest: The account to receive ownership of the asset.

Emits Transferred.

Weight: O(1)

Reevaluate the deposits on some assets.

Origin must be Signed and the sender should be the Owner of the asset class.

  • class: The class of the asset to be frozen.
  • instances: The instances of the asset class whose deposits will be reevaluated.

NOTE: This exists as a best-effort function. Any asset instances which are unknown or in the case that the owner account does not have reservable funds to pay for a deposit increase are ignored. Generally the owner isn’t going to call this on instances whose existing deposit is less than the refreshed deposit as it would only cost them, so it’s of little consequence.

It will still return an error in the case that the class is unknown of the signer is not permitted to call it.

Weight: O(instances.len())

Disallow further unprivileged transfer of an asset instance.

Origin must be Signed and the sender should be the Freezer of the asset class.

  • class: The class of the asset to be frozen.
  • instance: The instance of the asset to be frozen.

Emits Frozen.

Weight: O(1)

Re-allow unprivileged transfer of an asset instance.

Origin must be Signed and the sender should be the Freezer of the asset class.

  • class: The class of the asset to be thawed.
  • instance: The instance of the asset to be thawed.

Emits Thawed.

Weight: O(1)

Disallow further unprivileged transfers for a whole asset class.

Origin must be Signed and the sender should be the Freezer of the asset class.

  • class: The asset class to be frozen.

Emits ClassFrozen.

Weight: O(1)

Re-allow unprivileged transfers for a whole asset class.

Origin must be Signed and the sender should be the Admin of the asset class.

  • class: The class to be thawed.

Emits ClassThawed.

Weight: O(1)

Change the Owner of an asset class.

Origin must be Signed and the sender should be the Owner of the asset class.

  • class: The asset class whose owner should be changed.
  • owner: The new Owner of this asset class.

Emits OwnerChanged.

Weight: O(1)

Change the Issuer, Admin and Freezer of an asset class.

Origin must be Signed and the sender should be the Owner of the asset class.

  • class: The asset class whose team should be changed.
  • issuer: The new Issuer of this asset class.
  • admin: The new Admin of this asset class.
  • freezer: The new Freezer of this asset class.

Emits TeamChanged.

Weight: O(1)

Approve an instance to be transferred by a delegated third-party account.

Origin must be Signed and must be the owner of the asset instance.

  • class: The class of the asset to be approved for delegated transfer.
  • instance: The instance of the asset to be approved for delegated transfer.
  • delegate: The account to delegate permission to transfer the asset.

Emits ApprovedTransfer on success.

Weight: O(1)

Cancel the prior approval for the transfer of an asset by a delegate.

Origin must be either:

  • the Force origin;
  • Signed with the signer being the Admin of the asset class;
  • Signed with the signer being the Owner of the asset instance;

Arguments:

  • class: The class of the asset of whose approval will be cancelled.
  • instance: The instance of the asset of whose approval will be cancelled.
  • maybe_check_delegate: If Some will ensure that the given account is the one to which permission of transfer is delegated.

Emits ApprovalCancelled on success.

Weight: O(1)

Alter the attributes of a given asset.

Origin must be ForceOrigin.

  • class: The identifier of the asset.
  • owner: The new Owner of this asset.
  • issuer: The new Issuer of this asset.
  • admin: The new Admin of this asset.
  • freezer: The new Freezer of this asset.
  • free_holding: Whether a deposit is taken for holding an instance of this asset class.
  • is_frozen: Whether this asset class is frozen except for permissioned/admin instructions.

Emits AssetStatusChanged with the identity of the asset.

Weight: O(1)

Set an attribute for an asset class or instance.

Origin must be either ForceOrigin or Signed and the sender should be the Owner of the asset class.

If the origin is Signed, then funds of signer are reserved according to the formula: MetadataDepositBase + DepositPerByte * (key.len + value.len) taking into account any already reserved funds.

  • class: The identifier of the asset class whose instance’s metadata to set.
  • maybe_instance: The identifier of the asset instance whose metadata to set.
  • key: The key of the attribute.
  • value: The value to which to set the attribute.

Emits AttributeSet.

Weight: O(1)

Set an attribute for an asset class or instance.

Origin must be either ForceOrigin or Signed and the sender should be the Owner of the asset class.

If the origin is Signed, then funds of signer are reserved according to the formula: MetadataDepositBase + DepositPerByte * (key.len + value.len) taking into account any already reserved funds.

  • class: The identifier of the asset class whose instance’s metadata to set.
  • instance: The identifier of the asset instance whose metadata to set.
  • key: The key of the attribute.
  • value: The value to which to set the attribute.

Emits AttributeSet.

Weight: O(1)

Set the metadata for an asset instance.

Origin must be either ForceOrigin or Signed and the sender should be the Owner of the asset class.

If the origin is Signed, then funds of signer are reserved according to the formula: MetadataDepositBase + DepositPerByte * data.len taking into account any already reserved funds.

  • class: The identifier of the asset class whose instance’s metadata to set.
  • instance: The identifier of the asset instance whose metadata to set.
  • data: The general information of this asset. Limited in length by StringLimit.
  • is_frozen: Whether the metadata should be frozen against further changes.

Emits MetadataSet.

Weight: O(1)

Clear the metadata for an asset instance.

Origin must be either ForceOrigin or Signed and the sender should be the Owner of the asset instance.

Any deposit is freed for the asset class owner.

  • class: The identifier of the asset class whose instance’s metadata to clear.
  • instance: The identifier of the asset instance whose metadata to clear.

Emits MetadataCleared.

Weight: O(1)

Set the metadata for an asset class.

Origin must be either ForceOrigin or Signed and the sender should be the Owner of the asset class.

If the origin is Signed, then funds of signer are reserved according to the formula: MetadataDepositBase + DepositPerByte * data.len taking into account any already reserved funds.

  • class: The identifier of the asset whose metadata to update.
  • data: The general information of this asset. Limited in length by StringLimit.
  • is_frozen: Whether the metadata should be frozen against further changes.

Emits ClassMetadataSet.

Weight: O(1)

Clear the metadata for an asset class.

Origin must be either ForceOrigin or Signed and the sender should be the Owner of the asset class.

Any deposit is freed for the asset class owner.

  • class: The identifier of the asset class whose metadata to clear.

Emits ClassMetadataCleared.

Weight: O(1)

Trait Implementations

Get the benchmarks available for this pallet. Generally there is one benchmark per extrinsic, so these are sometimes just called “extrinsics”. Read more

Run the benchmarks for this pallet.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Create a class of nonfungible assets to be owned by who and managed by admin.

Formats the value using the given formatter. Read more

Returns the current storage version as supported by the pallet.

Returns the on-chain storage version of the pallet as stored in the storage.

The block is being finalized. Implement to have something happen.

This will be run when the block is being finalized (before on_finalize). Implement to have something happen using the remaining weight. Will not fire if the remaining weight is 0. Return the weight used, the hook will subtract it from current weight used and pass the result to the next on_idle hook if it exists. Read more

The block is being initialized. Implement to have something happen. Read more

Perform a module upgrade. Read more

Execute some pre-checks prior to a runtime upgrade. Read more

Execute some post-checks after a runtime upgrade. Read more

Implementing this function on a module allows you to perform long-running tasks that make (by default) validators generate transactions that feed results of those long-running computations back on chain. Read more

Run integrity test. Read more

Returns the attribute value of instance of class corresponding to key.

When key is empty, we return the instance metadata value.

By default this is None; no attributes are defined.

Returns the attribute value of instance of class corresponding to key.

When key is empty, we return the instance metadata value.

By default this is None; no attributes are defined.

Returns true if the asset instance of class may be transferred.

Default implementation is that all assets are transferable.

Type for identifying an asset instance.

Type for identifying an asset class (an identifier for an independent collection of asset instances). Read more

Returns the owner of asset instance of class, or None if the asset doesn’t exist (or somehow has no owner). Read more

Returns the owner of the asset class, if there is one. For many NFTs this may not make any sense, so users of this API should not be surprised to find an asset class results in None here. Read more

Returns the strongly-typed attribute value of instance of class corresponding to key. Read more

Returns the strongly-typed attribute value of class corresponding to key. Read more

Returns an iterator of the asset classes in existence.

NOTE: iterating this list invokes a storage read per item.

Returns an iterator of the instances of an asset class in existence.

NOTE: iterating this list invokes a storage read per item.

Returns an iterator of the asset instances of all classes owned by who.

NOTE: iterating this list invokes a storage read per item.

Returns an iterator of the asset instances of class owned by who.

NOTE: iterating this list invokes a storage read per item.

Run integrity test. Read more

Mint some asset instance of class to be owned by who. Read more

Burn some asset instance of class. Read more

Set attribute value of asset instance of class’s key. Read more

Attempt to set the strongly-typed attribute value of instance of class’s key. Read more

Set attribute value of asset class’s key. Read more

Attempt to set the strongly-typed attribute value of class’s key. Read more

This function is being called after every block import (when fully synced). Read more

The block is being finalized. Implement to have something happen. Read more

Something that should happen at genesis.

The block is being finalized. Implement to have something happen in case there is leftover weight. Check the passed remaining_weight to make sure it is high enough to allow for your pallet’s extra computation. Read more

The block is being initialized. Implement to have something happen. Read more

Perform a module upgrade. Read more

Execute some pre-checks prior to a runtime upgrade. Read more

Execute some post-checks after a runtime upgrade. Read more

Index of the pallet as configured in the runtime.

Name of the pallet as configured in the runtime.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Transfer asset instance of class into destination account.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Convert from a value of T into an equivalent instance of Option<Self>. Read more

Consume self to return Some equivalent value of Option<T>. Read more

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait. Read more

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s. Read more

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s. Read more

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

Cast reference.

Cast reference.

Cast mutable reference.

Cast mutable reference.

Get a reference to the inner from the outer.

Get a mutable reference to the inner from the outer.

Generate a storage key unique to this runtime upgrade. Read more

Get temporary storage data written by Self::set_temp_storage. Read more

Write some temporary data to a specific storage that can be read (potentially in post-upgrade hook) via Self::get_temp_storage. Read more

Should always be Self

Convert from a value of T into an equivalent instance of Self. Read more

Consume self to return an equivalent value of T. Read more

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more

Checks if self is actually part of its subset T (and can be converted to it).

Use with care! Same as self.to_subset but without any property checks. Always succeeds.

The inclusion map: converts self to the equivalent element of its superset.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The counterpart to unchecked_from.

Consume self to return an equivalent value of T.