mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 14:01:02 +00:00
Introduce Tinkernet multisig XCM configs to Kusama/Rococo through xcm-builder (#7165)
* Introduce Tinkernet multisig XCM configs * fmt fix * overflow handling, comments, clippy fixes * Adding Tinkernet XCM configs to xcm-builder * switching spaces to tab * remove derivation.rs in favor of location_conversion.rs * replace hardcoded literals with constants * autoformat * Fix for the unit test * replacing expect with an error and renaming constants * Resolving clippy warning --------- Co-authored-by: parity-processbot <>
This commit is contained in:
committed by
GitHub
parent
3a10a29df5
commit
af99520569
@@ -16,8 +16,12 @@
|
||||
|
||||
//! Various implementations for `ConvertOrigin`.
|
||||
|
||||
use crate::location_conversion::{
|
||||
derive_tinkernet_multisig, KUSAMA_TINKERNET_MULTISIG_PALLET, KUSAMA_TINKERNET_PARA_ID,
|
||||
};
|
||||
use frame_support::traits::{EnsureOrigin, Get, GetBacking, OriginTrait};
|
||||
use frame_system::RawOrigin as SystemRawOrigin;
|
||||
use parity_scale_codec::Decode;
|
||||
use polkadot_parachain::primitives::IsSystem;
|
||||
use sp_runtime::traits::TryConvert;
|
||||
use sp_std::marker::PhantomData;
|
||||
@@ -241,6 +245,37 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
/// Convert a Tinkernet Multisig `MultiLocation` value into a `Signed` origin.
|
||||
pub struct TinkernetMultisigAsNative<RuntimeOrigin>(PhantomData<RuntimeOrigin>);
|
||||
impl<RuntimeOrigin: OriginTrait> ConvertOrigin<RuntimeOrigin>
|
||||
for TinkernetMultisigAsNative<RuntimeOrigin>
|
||||
where
|
||||
RuntimeOrigin::AccountId: Decode,
|
||||
{
|
||||
fn convert_origin(
|
||||
origin: impl Into<MultiLocation>,
|
||||
kind: OriginKind,
|
||||
) -> Result<RuntimeOrigin, MultiLocation> {
|
||||
let origin = origin.into();
|
||||
match (kind, origin) {
|
||||
(
|
||||
OriginKind::Native,
|
||||
MultiLocation {
|
||||
parents: _,
|
||||
interior:
|
||||
X3(
|
||||
Junction::Parachain(KUSAMA_TINKERNET_PARA_ID),
|
||||
Junction::PalletInstance(KUSAMA_TINKERNET_MULTISIG_PALLET),
|
||||
// Index from which the multisig account is derived.
|
||||
Junction::GeneralIndex(id),
|
||||
),
|
||||
},
|
||||
) => Ok(RuntimeOrigin::signed(derive_tinkernet_multisig(id).map_err(|_| origin)?)),
|
||||
(_, origin) => Err(origin),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// `EnsureOrigin` barrier to convert from dispatch origin to XCM origin, if one exists.
|
||||
pub struct EnsureXcmOrigin<RuntimeOrigin, Conversion>(PhantomData<(RuntimeOrigin, Conversion)>);
|
||||
impl<RuntimeOrigin: OriginTrait + Clone, Conversion: TryConvert<RuntimeOrigin, MultiLocation>>
|
||||
|
||||
Reference in New Issue
Block a user