mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 15:11:02 +00:00
Vstam1/xcm admin origin (#6928)
* Ensure for a configurable origin in XCM (#6442), cherry picked from 5ae05e1a957857c449a43d8759a21292d03fd049 Add new associated type, AdminOrigin, bounded by EnsureOrigin trait in XCM pallet. Replace ensure_root() with ensure_origin() from a EnsureOrigin trait. Set AdminOrigin as EnsureRoot<AccountId> in xcm configs. * cargo fmt * small stylistic change --------- Co-authored-by: serkul <serkul@pop-os.localdomain>
This commit is contained in:
@@ -231,6 +231,9 @@ pub mod pallet {
|
||||
/// `pallet_xcm::CurrentXcmVersion`.
|
||||
type AdvertisedXcmVersion: Get<XcmVersion>;
|
||||
|
||||
/// The origin that is allowed to call privileged operations on the XCM pallet
|
||||
type AdminOrigin: EnsureOrigin<<Self as SysConfig>::RuntimeOrigin>;
|
||||
|
||||
/// The assets which we consider a given origin is trusted if they claim to have placed a
|
||||
/// lock.
|
||||
type TrustedLockers: ContainsPair<MultiLocation, MultiAsset>;
|
||||
@@ -915,7 +918,7 @@ pub mod pallet {
|
||||
location: Box<MultiLocation>,
|
||||
xcm_version: XcmVersion,
|
||||
) -> DispatchResult {
|
||||
ensure_root(origin)?;
|
||||
T::AdminOrigin::ensure_origin(origin)?;
|
||||
let location = *location;
|
||||
SupportedVersion::<T>::insert(
|
||||
XCM_VERSION,
|
||||
@@ -937,7 +940,7 @@ pub mod pallet {
|
||||
origin: OriginFor<T>,
|
||||
maybe_xcm_version: Option<XcmVersion>,
|
||||
) -> DispatchResult {
|
||||
ensure_root(origin)?;
|
||||
T::AdminOrigin::ensure_origin(origin)?;
|
||||
SafeXcmVersion::<T>::set(maybe_xcm_version);
|
||||
Ok(())
|
||||
}
|
||||
@@ -952,7 +955,7 @@ pub mod pallet {
|
||||
origin: OriginFor<T>,
|
||||
location: Box<VersionedMultiLocation>,
|
||||
) -> DispatchResult {
|
||||
ensure_root(origin)?;
|
||||
T::AdminOrigin::ensure_origin(origin)?;
|
||||
let location: MultiLocation =
|
||||
(*location).try_into().map_err(|()| Error::<T>::BadLocation)?;
|
||||
Self::request_version_notify(location).map_err(|e| {
|
||||
@@ -976,7 +979,7 @@ pub mod pallet {
|
||||
origin: OriginFor<T>,
|
||||
location: Box<VersionedMultiLocation>,
|
||||
) -> DispatchResult {
|
||||
ensure_root(origin)?;
|
||||
T::AdminOrigin::ensure_origin(origin)?;
|
||||
let location: MultiLocation =
|
||||
(*location).try_into().map_err(|()| Error::<T>::BadLocation)?;
|
||||
Self::unrequest_version_notify(location).map_err(|e| {
|
||||
|
||||
@@ -20,6 +20,7 @@ use frame_support::{
|
||||
traits::{ConstU32, Everything, Nothing},
|
||||
weights::Weight,
|
||||
};
|
||||
use frame_system::EnsureRoot;
|
||||
use polkadot_parachain::primitives::Id as ParaId;
|
||||
use polkadot_runtime_parachains::origin;
|
||||
use sp_core::H256;
|
||||
@@ -344,6 +345,7 @@ impl pallet_xcm::Config for Test {
|
||||
type WeightInfo = TestWeightInfo;
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
type ReachableDest = ReachableDest;
|
||||
type AdminOrigin = EnsureRoot<AccountId>;
|
||||
}
|
||||
|
||||
impl origin::Config for Test {}
|
||||
|
||||
Reference in New Issue
Block a user