Introduce Tinkernet multisig XCM configs to Kusama/Rococo through xcm-builder #7165
Changes from 11 commits
f69e787
4d9a361
10226a2
80c088e
47ecaea
0ab325f
b0026e6
bf06aba
4d71b17
c1b6885
1c9ec34
08d2b3d
138d4b6
59a9be5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,8 +16,12 @@ | |
|
||
//! Various implementations for `ConvertOrigin`. | ||
|
||
use crate::location_conversion::{ | ||
derive_tinkernet_multisig, TINKERNET_MULTISIG_PALLET, 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>); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similarly, I think from an organization perspective, it is more correct for this configuration to be placed in the kusama runtime, as it is the only user of it. But I see that it is more "convenient" to do it like this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Kusama is not the only user of these converters, parachains will also import these into their xcm configurations from xcm-builder. I believe this also responds the previous comment. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. About the previous comment: the |
||
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(TINKERNET_PARA_ID), | ||
Junction::PalletInstance(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>> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is assuming your kusama para-id, right? it should be in the kusama runtime file, not in XCM-builder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed the constants to include the KUSAMA_ prefix.