Enum xcm::v0::prelude::MultiAsset

source ·
pub enum MultiAsset {
    None,
    All,
    AllFungible,
    AllNonFungible,
    AllAbstractFungible {
        id: Vec<u8>,
    },
    AllAbstractNonFungible {
        class: Vec<u8>,
    },
    AllConcreteFungible {
        id: MultiLocation,
    },
    AllConcreteNonFungible {
        class: MultiLocation,
    },
    AbstractFungible {
        id: Vec<u8>,
        amount: u128,
    },
    AbstractNonFungible {
        class: Vec<u8>,
        instance: AssetInstance,
    },
    ConcreteFungible {
        id: MultiLocation,
        amount: u128,
    },
    ConcreteNonFungible {
        class: MultiLocation,
        instance: AssetInstance,
    },
}
Expand description

A single general identifier for an asset.

Represents both fungible and non-fungible assets. May only be used to represent a single asset class.

Wildcards may or may not be allowed by the interpreting context.

Assets classes may be identified in one of two ways: either an abstract identifier or a concrete identifier. Implementations may support only one of these. A single asset may be referenced from multiple asset identifiers, though will tend to have only a single preferred identifier.

Abstract identifiers

Abstract identifiers are absolute identifiers that represent a notional asset which can exist within multiple consensus systems. These tend to be simpler to deal with since their broad meaning is unchanged regardless stay of the consensus system in which it is interpreted.

However, in the attempt to provide uniformity across consensus systems, they may conflate different instantiations of some notional asset (e.g. the reserve asset and a local reserve-backed derivative of it) under the same name, leading to confusion. It also implies that one notional asset is accounted for locally in only one way. This may not be the case, e.g. where there are multiple bridge instances each providing a bridged “BTC” token yet none being fungible between the others.

Since they are meant to be absolute and universal, a global registry is needed to ensure that name collisions do not occur.

An abstract identifier is represented as a simple variable-size byte string. As of writing, no global registry exists and no proposals have been put forth for asset labeling.

Concrete identifiers

Concrete identifiers are relative identifiers that specifically identify a single asset through its location in a consensus system relative to the context interpreting. Use of a MultiLocation ensures that similar but non fungible variants of the same underlying asset can be properly distinguished, and obviates the need for any kind of central registry.

The limitation is that the asset identifier cannot be trivially copied between consensus systems and must instead be “re-anchored” whenever being moved to a new consensus system, using the two systems’ relative paths.

Throughout XCM, messages are authored such that when interpreted from the receiver’s point of view they will have the desired meaning/effect. This means that relative paths should always by constructed to be read from the point of view of the receiving system, which may be have a completely different meaning in the authoring system.

Concrete identifiers are the preferred way of identifying an asset since they are entirely unambiguous.

A concrete identifier is represented by a MultiLocation. If a system has an unambiguous primary asset (such as Bitcoin with BTC or Ethereum with ETH), then it will conventionally be identified as the chain itself. Alternative and more specific ways of referring to an asset within a system include:

  • <chain>/PalletInstance(<id>) for a Frame chain with a single-asset pallet instance (such as an instance of the Balances pallet).
  • <chain>/PalletInstance(<id>)/GeneralIndex(<index>) for a Frame chain with an indexed multi-asset pallet instance (such as an instance of the Assets pallet).
  • <chain>/AccountId32 for an ERC-20-style single-asset smart-contract on a Frame-based contracts chain.
  • <chain>/AccountKey20 for an ERC-20-style single-asset smart-contract on an Ethereum-like chain.

Variants§

§

None

No assets. Rarely used.

§

All

All assets. Typically used for the subset of assets to be used for an Order, and in that context means “all assets currently in holding”.

§

AllFungible

All fungible assets. Typically used for the subset of assets to be used for an Order, and in that context means “all fungible assets currently in holding”.

§

AllNonFungible

All non-fungible assets. Typically used for the subset of assets to be used for an Order, and in that context means “all non-fungible assets currently in holding”.

§

AllAbstractFungible

Fields

§id: Vec<u8>

All fungible assets of a given abstract asset identifier.

§

AllAbstractNonFungible

Fields

§class: Vec<u8>

All non-fungible assets of a given abstract asset class.

§

AllConcreteFungible

Fields

All fungible assets of a given concrete asset identifier.

§

AllConcreteNonFungible

Fields

All non-fungible assets of a given concrete asset class.

§

AbstractFungible

Fields

§id: Vec<u8>
§amount: u128

Some specific amount of the fungible asset identified by an abstract id.

§

AbstractNonFungible

Fields

§class: Vec<u8>
§instance: AssetInstance

Some specific instance of the non-fungible asset whose class is identified abstractly.

§

ConcreteFungible

Fields

§amount: u128

Some specific amount of the fungible asset identified by an concrete id.

§

ConcreteNonFungible

Fields

§instance: AssetInstance

Some specific instance of the non-fungible asset whose class is identified concretely.

Implementations§

Returns true if the MultiAsset is a wildcard and can refer to classes of assets, instead of just one.

Typically can also be inferred by the name starting with All.

Returns true if self is a super-set of the given inner.

Typically, any wildcard is never contained in anything else, and a wildcard can contain any other non-wildcard. For more details, see the implementation and tests.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Attempt to deserialise the value from input.
Attempt to skip the encoded value from input. Read more
Returns the fixed encoded size of the type. Read more
Convert self to a slice and append it to the destination.
If possible give a hint of expected size of the encoding. Read more
Convert self to an owned vector.
Convert self to a slice and then invoke the given closure with it.
Calculates the encoded size. Read more
Converts to this type from the input type.
This method returns an Ordering between self and other. Read more
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. 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 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 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 type identifying for which type info is provided. Read more
Returns the static type identifier for Self.

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
Converts self into T using Into<T>. Read more
Decode Self and consume all of the given input data. Read more
Decode Self and consume all of the given input data. Read more
Decode Self with the given maximum recursion depth and advance input by the number of bytes consumed. 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
Compare self to key and return true if they are equal.
Causes self to use its Binary implementation when Debug-formatted. Read more
Causes self to use its Display implementation when Debug-formatted. Read more
Causes self to use its LowerExp implementation when Debug-formatted. Read more
Causes self to use its LowerHex implementation when Debug-formatted. Read more
Causes self to use its Octal implementation when Debug-formatted. Read more
Causes self to use its Pointer implementation when Debug-formatted. Read more
Causes self to use its UpperExp implementation when Debug-formatted. Read more
Causes self to use its UpperHex implementation when Debug-formatted. Read more
Formats each item in a sequence. Read more

Returns the argument unchanged.

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

Calls U::from(self).

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

Get a reference to the inner from the outer.

Get a mutable reference to the inner from the outer.

Return an encoding of Self prepended by given slice.
Pipes by value. This is generally the method you want to use. Read more
Borrows self and passes that borrow into the pipe function. Read more
Mutably borrows self and passes that borrow into the pipe function. Read more
Borrows self, then passes self.borrow() into the pipe function. Read more
Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Borrows self, then passes self.as_ref() into the pipe function.
Mutably borrows self, then passes self.as_mut() into the pipe function. Read more
Borrows self, then passes self.deref() into the pipe function.
Mutably borrows self, then passes self.deref_mut() into the pipe function. Read more
The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. 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
Immutable access to a value. Read more
Mutable access to a value. Read more
Immutable access to the Borrow<B> of a value. Read more
Mutable access to the BorrowMut<B> of a value. Read more
Immutable access to the AsRef<R> view of a value. Read more
Mutable access to the AsMut<R> view of a value. Read more
Immutable access to the Deref::Target of a value. Read more
Mutable access to the Deref::Target of a value. Read more
Calls .tap() only in debug builds, and is erased in release builds.
Calls .tap_mut() only in debug builds, and is erased in release builds. Read more
Calls .tap_borrow() only in debug builds, and is erased in release builds. Read more
Calls .tap_borrow_mut() only in debug builds, and is erased in release builds. Read more
Calls .tap_ref() only in debug builds, and is erased in release builds. Read more
Calls .tap_ref_mut() only in debug builds, and is erased in release builds. Read more
Calls .tap_deref() only in debug builds, and is erased in release builds. Read more
Calls .tap_deref_mut() only in debug builds, and is erased in release builds. Read more
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Attempts to convert self into T using TryInto<T>. 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.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more