Enum xcm::v0::prelude::MultiAsset [−][src]
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
No assets. Rarely used.
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”.
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”.
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”.
All fungible assets of a given abstract asset id
entifier.
All non-fungible assets of a given abstract asset class
.
All fungible assets of a given concrete asset id
entifier.
Fields of AllConcreteFungible
id: MultiLocation
All non-fungible assets of a given concrete asset class
.
Fields of AllConcreteNonFungible
class: MultiLocation
Some specific amount
of the fungible asset identified by an abstract id
.
Some specific instance
of the non-fungible asset whose class
is identified abstractly.
Fields of AbstractNonFungible
class: Vec<u8>
instance: AssetInstance
Some specific amount
of the fungible asset identified by an concrete id
.
Fields of ConcreteFungible
id: MultiLocation
amount: u128
Some specific instance
of the non-fungible asset whose class
is identified concretely.
Fields of ConcreteNonFungible
class: MultiLocation
instance: AssetInstance
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
Performs the conversion.
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
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
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Auto Trait Implementations
impl RefUnwindSafe for MultiAsset
impl Send for MultiAsset
impl Sync for MultiAsset
impl Unpin for MultiAsset
impl UnwindSafe for MultiAsset
Blanket Implementations
Mutably borrows from an owned value. Read more
Causes self
to use its Binary
implementation when Debug
-formatted.
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.
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
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.
fn pipe_as_ref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
Self: AsRef<T>,
T: 'a,
R: 'a,
fn pipe_as_ref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
Self: AsRef<T>,
T: 'a,
R: 'a,
Pipes a trait borrow into a function that cannot normally be called in suffix position. Read more
fn pipe_borrow<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
Self: Borrow<T>,
T: 'a,
R: 'a,
fn pipe_borrow<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
Self: Borrow<T>,
T: 'a,
R: 'a,
Pipes a trait borrow into a function that cannot normally be called in suffix position. Read more
fn pipe_deref<'a, R>(&'a self, func: impl FnOnce(&'a Self::Target) -> R) -> R where
Self: Deref,
R: 'a,
fn pipe_deref<'a, R>(&'a self, func: impl FnOnce(&'a Self::Target) -> R) -> R where
Self: Deref,
R: 'a,
Pipes a dereference into a function that cannot normally be called in suffix position. Read more
Pipes a reference into a function that cannot ordinarily be called in suffix position. 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
Provides immutable access to the reference for inspection.
Calls tap_ref
in debug builds, and does nothing in release builds.
Provides mutable access to the reference for modification.
Calls tap_ref_mut
in debug builds, and does nothing in release builds.
Provides immutable access to the borrow for inspection. Read more
Calls tap_borrow
in debug builds, and does nothing in release builds.
fn tap_borrow_mut<F, R>(self, func: F) -> Self where
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R,
fn tap_borrow_mut<F, R>(self, func: F) -> Self where
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R,
Provides mutable access to the borrow for modification.
Immutably dereferences self
for inspection.
fn tap_deref_dbg<F, R>(self, func: F) -> Self where
Self: Deref,
F: FnOnce(&Self::Target) -> R,
fn tap_deref_dbg<F, R>(self, func: F) -> Self where
Self: Deref,
F: FnOnce(&Self::Target) -> R,
Calls tap_deref
in debug builds, and does nothing in release builds.
fn tap_deref_mut<F, R>(self, func: F) -> Self where
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R,
fn tap_deref_mut<F, R>(self, func: F) -> Self where
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R,
Mutably dereferences self
for modification.