Struct pallet_assets::pallet::Pallet[][src]

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

The pallet implementing the on-chain logic.

Implementations

Return the extra “sid-car” data for id/who, or None if the account doesn’t exist.

Get the asset id balance of who.

Get the total supply of an asset id.

Issue a new class of 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.

Funds of sender are reserved by AssetDeposit.

Parameters:

  • id: The identifier of the new asset. This must not be currently in use to identify an existing asset.
  • admin: The admin of this class of assets. The admin is the initial address of each member of the asset class’s admin team.
  • min_balance: The minimum balance of this new asset that any single account must have. If an account’s balance is reduced below this, then it collapses to zero.

Emits Created event when successful.

Weight: O(1)

Issue a new class of 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.

  • id: The identifier of the new asset. This must not be currently in use to identify an existing asset.
  • 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.
  • min_balance: The minimum balance of this new asset that any single account must have. If an account’s balance is reduced below this, then it collapses to zero.

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 id.

  • id: The identifier of the asset to be destroyed. This must identify an existing asset.

Emits Destroyed event when successful.

NOTE: It can be helpful to first freeze an asset before destroying it so that you can provide accurate witness information and prevent users from manipulating state in a way that can make it harder to destroy.

Weight: O(c + p + a) where:

  • c = (witness.accounts - witness.sufficients)
  • s = witness.sufficients
  • a = witness.approvals

Mint assets of a particular class.

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

  • id: The identifier of the asset to have some amount minted.
  • beneficiary: The account to be credited with the minted assets.
  • amount: The amount of the asset to be minted.

Emits Issued event when successful.

Weight: O(1) Modes: Pre-existing balance of beneficiary; Account pre-existence of beneficiary.

Reduce the balance of who by as much as possible up to amount assets of id.

Origin must be Signed and the sender should be the Manager of the asset id.

Bails with BalanceZero if the who is already dead.

  • id: The identifier of the asset to have some amount burned.
  • who: The account to be debited from.
  • amount: The maximum amount by which who’s balance should be reduced.

Emits Burned with the actual amount burned. If this takes the balance to below the minimum for the asset, then the amount burned is increased to take it to zero.

Weight: O(1) Modes: Post-existence of who; Pre & post Zombie-status of who.

Move some assets from the sender account to another.

Origin must be Signed.

  • id: The identifier of the asset to have some amount transferred.
  • target: The account to be credited.
  • amount: The amount by which the sender’s balance of assets should be reduced and target’s balance increased. The amount actually transferred may be slightly greater in the case that the transfer would otherwise take the sender balance above zero but below the minimum balance. Must be greater than zero.

Emits Transferred with the actual amount transferred. If this takes the source balance to below the minimum for the asset, then the amount transferred is increased to take it to zero.

Weight: O(1) Modes: Pre-existence of target; Post-existence of sender; Account pre-existence of target.

Move some assets from the sender account to another, keeping the sender account alive.

Origin must be Signed.

  • id: The identifier of the asset to have some amount transferred.
  • target: The account to be credited.
  • amount: The amount by which the sender’s balance of assets should be reduced and target’s balance increased. The amount actually transferred may be slightly greater in the case that the transfer would otherwise take the sender balance above zero but below the minimum balance. Must be greater than zero.

Emits Transferred with the actual amount transferred. If this takes the source balance to below the minimum for the asset, then the amount transferred is increased to take it to zero.

Weight: O(1) Modes: Pre-existence of target; Post-existence of sender; Account pre-existence of target.

Move some assets from one account to another.

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

  • id: The identifier of the asset to have some amount transferred.
  • source: The account to be debited.
  • dest: The account to be credited.
  • amount: The amount by which the source’s balance of assets should be reduced and dest’s balance increased. The amount actually transferred may be slightly greater in the case that the transfer would otherwise take the source balance above zero but below the minimum balance. Must be greater than zero.

Emits Transferred with the actual amount transferred. If this takes the source balance to below the minimum for the asset, then the amount transferred is increased to take it to zero.

Weight: O(1) Modes: Pre-existence of dest; Post-existence of source; Account pre-existence of dest.

Disallow further unprivileged transfers from an account.

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

  • id: The identifier of the asset to be frozen.
  • who: The account to be frozen.

Emits Frozen.

Weight: O(1)

Allow unprivileged transfers from an account again.

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

  • id: The identifier of the asset to be frozen.
  • who: The account to be unfrozen.

Emits Thawed.

Weight: O(1)

Disallow further unprivileged transfers for the asset class.

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

  • id: The identifier of the asset to be frozen.

Emits Frozen.

Weight: O(1)

Allow unprivileged transfers for the asset again.

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

  • id: The identifier of the asset to be thawed.

Emits Thawed.

Weight: O(1)

Change the Owner of an asset.

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

  • id: The identifier of the asset.
  • owner: The new Owner of this asset.

Emits OwnerChanged.

Weight: O(1)

Change the Issuer, Admin and Freezer of an asset.

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

  • id: The identifier of the asset to be frozen.
  • issuer: The new Issuer of this asset.
  • admin: The new Admin of this asset.
  • freezer: The new Freezer of this asset.

Emits TeamChanged.

Weight: O(1)

Set the metadata for an asset.

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

Funds of sender are reserved according to the formula: MetadataDepositBase + MetadataDepositPerByte * (name.len + symbol.len) taking into account any already reserved funds.

  • id: The identifier of the asset to update.
  • name: The user friendly name of this asset. Limited in length by StringLimit.
  • symbol: The exchange symbol for this asset. Limited in length by StringLimit.
  • decimals: The number of decimals this asset uses to represent one unit.

Emits MetadataSet.

Weight: O(1)

Clear the metadata for an asset.

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

Any deposit is freed for the asset owner.

  • id: The identifier of the asset to clear.

Emits MetadataCleared.

Weight: O(1)

Force the metadata for an asset to some value.

Origin must be ForceOrigin.

Any deposit is left alone.

  • id: The identifier of the asset to update.
  • name: The user friendly name of this asset. Limited in length by StringLimit.
  • symbol: The exchange symbol for this asset. Limited in length by StringLimit.
  • decimals: The number of decimals this asset uses to represent one unit.

Emits MetadataSet.

Weight: O(N + S) where N and S are the length of the name and symbol respectively.

Clear the metadata for an asset.

Origin must be ForceOrigin.

Any deposit is returned.

  • id: The identifier of the asset to clear.

Emits MetadataCleared.

Weight: O(1)

Alter the attributes of a given asset.

Origin must be ForceOrigin.

  • id: 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.
  • min_balance: The minimum balance of this new asset that any single account must have. If an account’s balance is reduced below this, then it collapses to zero.
  • is_sufficient: Whether a non-zero balance of this asset is deposit of sufficient value to account for the state bloat associated with its balance storage. If set to true, then non-zero balances may be stored without a consumer reference (and thus an ED in the Balances pallet or whatever else is used to control user-account state growth).
  • is_frozen: Whether this asset class is frozen except for permissioned/admin instructions.

Emits AssetStatusChanged with the identity of the asset.

Weight: O(1)

Approve an amount of asset for transfer by a delegated third-party account.

Origin must be Signed.

Ensures that ApprovalDeposit worth of Currency is reserved from signing account for the purpose of holding the approval. If some non-zero amount of assets is already approved from signing account to delegate, then it is topped up or unreserved to meet the right value.

NOTE: The signing account does not need to own amount of assets at the point of making this call.

  • id: The identifier of the asset.
  • delegate: The account to delegate permission to transfer asset.
  • amount: The amount of asset that may be transferred by delegate. If there is already an approval in place, then this acts additively.

Emits ApprovedTransfer on success.

Weight: O(1)

Cancel all of some asset approved for delegated transfer by a third-party account.

Origin must be Signed and there must be an approval in place between signer and delegate.

Unreserves any deposit previously reserved by approve_transfer for the approval.

  • id: The identifier of the asset.
  • delegate: The account delegated permission to transfer asset.

Emits ApprovalCancelled on success.

Weight: O(1)

Cancel all of some asset approved for delegated transfer by a third-party account.

Origin must be either ForceOrigin or Signed origin with the signer being the Admin account of the asset id.

Unreserves any deposit previously reserved by approve_transfer for the approval.

  • id: The identifier of the asset.
  • delegate: The account delegated permission to transfer asset.

Emits ApprovalCancelled on success.

Weight: O(1)

Transfer some asset balance from a previously delegated account to some third-party account.

Origin must be Signed and there must be an approval in place by the owner to the signer.

If the entire amount approved for transfer is transferred, then any deposit previously reserved by approve_transfer is unreserved.

  • id: The identifier of the asset.
  • owner: The account which previously approved for a transfer of at least amount and from which the asset balance will be withdrawn.
  • destination: The account to which the asset balance of amount will be transferred.
  • amount: The amount of assets to transfer.

Emits TransferredApproved on success.

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

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

Means of identifying one asset class from another.

Scalar type for representing balance of an account.

The total amount of issuance in the system.

The minimum balance any single account may have.

Get the asset balance of who.

Get the maximum amount of asset that who can withdraw/transfer successfully.

Returns true if the asset balance of who may be increased by amount.

Returns Failed if the asset balance of who may not be decreased by amount, otherwise the consequence. Read more

Run integrity test. Read more

Attempt to increase the asset balance of who by amount. Read more

Attempt to reduce the asset balance of who by amount. Read more

Attempt to reduce the asset balance of who by as much as possible up to amount, and possibly slightly more due to minimum_balance requirements. If no decrease is possible then an Err is returned and nothing is changed. If successful, the amount of tokens reduced is returned. Read more

Transfer funds from one account into another. The default implementation uses mint_into and burn_from and may generate unwanted events. 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 !=.

Get the item, or its default if it doesn’t yet exist; we make no distinction between the two. Read more

Maybe mutate the item only if an Ok value is returned from f. Do nothing if an Err is returned. It is removed or reset to default value if it has been mutated to None Read more

Mutate the item.

Mutate the item, removing or resetting to default value if it has been mutated to None. Read more

Set the item to something new.

Remove the item or otherwise replace it with its default value; we don’t care which.

Transfer funds from one account into another.

Set the asset balance of who to amount. If this cannot be done for some reason (e.g. because the account cannot be created or an overflow) then an Err is returned. Read more

Set the total issuance of asset to amount.

Reduce the asset balance of who by amount. If it cannot be reduced by that amount for some reason, return Err and don’t reduce it at all. If Ok, return the imbalance. Read more

Reduce the asset balance of who by the most that is possible, up to amount. Read more

Increase the asset balance of who by amount. If it cannot be increased by that amount for some reason, return Err and don’t increase it at all. If Ok, return the imbalance. Read more

Increase the asset balance of who by the most that is possible, up to amount. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

The type for managing what happens when an instance of Credit is dropped without being used. Read more

The type for managing what happens when an instance of Debt is dropped without being used.

Reduce the total issuance by amount and return the according imbalance. The imbalance will typically be used to reduce an account by the same amount with e.g. settle. Read more

Increase the total issuance by amount and return the according imbalance. The imbalance will typically be used to increase an account by the same amount with e.g. resolve_into_existing or resolve_creating. Read more

Deducts up to value from the combined balance of who, preferring to deduct from the free balance. This function cannot fail. Read more

Mints exactly value into the asset account of who. Read more

Removes value free asset balance from who account if possible. Read more

Produce a pair of imbalances that cancel each other out exactly. Read more

The balance of who is increased in order to counter credit. If the whole of credit cannot be countered, then nothing is changed and the original credit is returned in an Err. Read more

The balance of who is decreased in order to counter debt. If the whole of debt cannot be countered, then nothing is changed and the original debt is returned in an Err. 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.