mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-01 05:41:03 +00:00
XCM: Utility struct for AccountId conversion (#7321)
* XCM: Utility struct for AccountId conversion * Update conversion.rs
This commit is contained in:
@@ -237,18 +237,11 @@ impl<Network: Get<Option<NetworkId>>, AccountId: From<[u8; 32]> + Into<[u8; 32]>
|
|||||||
/// network (provided by `Network`) and the `AccountId`'s `[u8; 32]` datum for the `id`.
|
/// network (provided by `Network`) and the `AccountId`'s `[u8; 32]` datum for the `id`.
|
||||||
pub struct AliasesIntoAccountId32<Network, AccountId>(PhantomData<(Network, AccountId)>);
|
pub struct AliasesIntoAccountId32<Network, AccountId>(PhantomData<(Network, AccountId)>);
|
||||||
impl<'a, Network: Get<Option<NetworkId>>, AccountId: Clone + Into<[u8; 32]> + Clone>
|
impl<'a, Network: Get<Option<NetworkId>>, AccountId: Clone + Into<[u8; 32]> + Clone>
|
||||||
Convert<&'a AccountId, MultiLocation> for AliasesIntoAccountId32<Network, AccountId>
|
sp_runtime::traits::Convert<&'a AccountId, MultiLocation>
|
||||||
|
for AliasesIntoAccountId32<Network, AccountId>
|
||||||
{
|
{
|
||||||
fn convert(who: &AccountId) -> Result<MultiLocation, &'a AccountId> {
|
fn convert(who: &AccountId) -> MultiLocation {
|
||||||
Ok(AccountId32 { network: Network::get(), id: who.clone().into() }.into())
|
AccountId32 { network: Network::get(), id: who.clone().into() }.into()
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<Network: Get<Option<NetworkId>>, AccountId: Into<[u8; 32]> + Clone>
|
|
||||||
Convert<AccountId, MultiLocation> for AliasesIntoAccountId32<Network, AccountId>
|
|
||||||
{
|
|
||||||
fn convert(who: AccountId) -> Result<MultiLocation, AccountId> {
|
|
||||||
Ok(AccountId32 { network: Network::get(), id: who.into() }.into())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -313,7 +306,8 @@ impl<UniversalLocation: Get<InteriorMultiLocation>, AccountId: From<[u8; 32]> +
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn reverse_ref(_: impl Borrow<AccountId>) -> Result<MultiLocation, ()> {
|
fn reverse_ref(_: impl Borrow<AccountId>) -> Result<MultiLocation, ()> {
|
||||||
// if this will be needed, we could implement some kind of guessing, if we have configuration for supported networkId+paraId
|
// if this is ever be needed, we could implement some kind of guessing, if we have
|
||||||
|
// configuration for supported networkId+paraId
|
||||||
Err(())
|
Err(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,8 +28,11 @@ use xcm_executor::traits::{QueryHandler, QueryResponseStatus};
|
|||||||
/// Implementation of the `frame_support::traits::tokens::Pay` trait, to allow
|
/// Implementation of the `frame_support::traits::tokens::Pay` trait, to allow
|
||||||
/// for XCM-based payments of a given `Balance` of some asset ID existing on some chain under
|
/// for XCM-based payments of a given `Balance` of some asset ID existing on some chain under
|
||||||
/// ownership of some `Interior` location of the local chain to a particular `Beneficiary`. The
|
/// ownership of some `Interior` location of the local chain to a particular `Beneficiary`. The
|
||||||
/// `AssetKind` value can be converted into both the XCM `AssetId` (via and `Into` bound) and the
|
/// `AssetKind` value is not itself bounded (to avoid the issue of needing to wrap some preexisting
|
||||||
/// the destination chain's location, via the `AssetKindToLocatableAsset` type parameter.
|
/// datatype), however a converter type `AssetKindToLocatableAsset` must be provided in order to
|
||||||
|
/// translate it into a `LocatableAsset`, which comprises both an XCM `MultiLocation` describing
|
||||||
|
/// the XCM endpoint on which the asset to be paid resides and an XCM `AssetId` to identify the
|
||||||
|
/// specific asset at that endpoint.
|
||||||
///
|
///
|
||||||
/// This relies on the XCM `TransferAsset` instruction. A trait `BeneficiaryRefToLocation` must be
|
/// This relies on the XCM `TransferAsset` instruction. A trait `BeneficiaryRefToLocation` must be
|
||||||
/// provided in order to convert the `Beneficiary` reference into a location usable by
|
/// provided in order to convert the `Beneficiary` reference into a location usable by
|
||||||
@@ -200,6 +203,3 @@ impl<Location: Get<MultiLocation>, AssetKind: Into<AssetId>> Convert<AssetKind,
|
|||||||
LocatableAssetId { asset_id: value.into(), location: Location::get() }
|
LocatableAssetId { asset_id: value.into(), location: Location::get() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn it_builds() {}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user