Skip to content

Commit 09c38b1

Browse files
committed
make AH staking work via XCM
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
1 parent a401219 commit 09c38b1

File tree

2 files changed

+128
-2
lines changed

2 files changed

+128
-2
lines changed

system-parachains/asset-hubs/asset-hub-kusama/src/xcm_config.rs

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ impl xcm_executor::Config for XcmConfig {
438438
type MessageExporter = ();
439439
type UniversalAliases = (bridging::to_polkadot::UniversalAliases,);
440440
type CallDispatcher = RuntimeCall;
441-
type SafeCallFilter = Everything;
441+
type SafeCallFilter = SafeCallFilter;
442442
type Aliasers = TrustedAliasers;
443443
type TransactionalProcessor = FrameTransactionalProcessor;
444444
type HrmpNewChannelOpenRequestHandler = ();
@@ -447,6 +447,69 @@ impl xcm_executor::Config for XcmConfig {
447447
type XcmEventEmitter = PolkadotXcm;
448448
}
449449

450+
pub struct SafeCallFilter;
451+
impl Contains<RuntimeCall> for SafeCallFilter {
452+
fn contains(call: &RuntimeCall) -> bool {
453+
match call {
454+
RuntimeCall::Balances(pallet_balances::Call::transfer_keep_alive { .. }) => true,
455+
// Foreign assets instance
456+
RuntimeCall::ForeignAssets(pallet_assets::Call::<
457+
Runtime,
458+
crate::ForeignAssetsInstance,
459+
>::create {
460+
..
461+
}) => true,
462+
RuntimeCall::ForeignAssets(pallet_assets::Call::<
463+
Runtime,
464+
crate::ForeignAssetsInstance,
465+
>::force_set_metadata {
466+
..
467+
}) => true,
468+
RuntimeCall::ForeignAssets(pallet_assets::Call::<
469+
Runtime,
470+
crate::ForeignAssetsInstance,
471+
>::set_metadata {
472+
..
473+
}) => true,
474+
RuntimeCall::ForeignAssets(pallet_assets::Call::<
475+
Runtime,
476+
crate::ForeignAssetsInstance,
477+
>::set_team {
478+
..
479+
}) => true,
480+
RuntimeCall::ForeignAssets(pallet_assets::Call::<
481+
Runtime,
482+
crate::ForeignAssetsInstance,
483+
>::touch {
484+
..
485+
}) => true,
486+
RuntimeCall::Nfts(pallet_nfts::Call::create { .. }) => true,
487+
RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_subscribe_version_notify {
488+
..
489+
}) => true,
490+
RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) => true,
491+
// Allow staking stuff through XCM
492+
RuntimeCall::Staking(pallet_staking_async::Call::bond_extra { .. }) => true,
493+
RuntimeCall::Staking(pallet_staking_async::Call::rebond { .. }) => true,
494+
RuntimeCall::Staking(pallet_staking_async::Call::unbond { .. }) => true,
495+
RuntimeCall::Staking(pallet_staking_async::Call::withdraw_unbonded { .. }) => true,
496+
RuntimeCall::System(frame_system::Call::authorize_upgrade { .. }) => true,
497+
RuntimeCall::System(frame_system::Call::set_storage { .. }) => true,
498+
RuntimeCall::ToPolkadotXcmRouter(pallet_xcm_bridge_hub_router::Call::<
499+
Runtime,
500+
crate::ToPolkadotXcmRouterInstance,
501+
>::report_bridge_status {
502+
..
503+
}) => true,
504+
RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) => true,
505+
RuntimeCall::Utility(pallet_utility::Call::batch_all { .. }) => true,
506+
RuntimeCall::Utility(pallet_utility::Call::force_batch { .. }) => true,
507+
RuntimeCall::Whitelist(pallet_whitelist::Call::whitelist_call { .. }) => true,
508+
_ => false,
509+
}
510+
}
511+
}
512+
450513
parameter_types! {
451514
// StakingAdmin pluralistic body.
452515
pub const StakingAdminBodyId: BodyId = BodyId::Defense;

system-parachains/asset-hubs/asset-hub-polkadot/src/xcm_config.rs

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ impl xcm_executor::Config for XcmConfig {
512512
type UniversalAliases =
513513
(bridging::to_kusama::UniversalAliases, bridging::to_ethereum::UniversalAliases);
514514
type CallDispatcher = RuntimeCall;
515-
type SafeCallFilter = Everything;
515+
type SafeCallFilter = SafeCallFilter;
516516
type Aliasers = TrustedAliasers;
517517
type TransactionalProcessor = FrameTransactionalProcessor;
518518
type HrmpNewChannelOpenRequestHandler = ();
@@ -521,6 +521,69 @@ impl xcm_executor::Config for XcmConfig {
521521
type XcmEventEmitter = PolkadotXcm;
522522
}
523523

524+
pub struct SafeCallFilter;
525+
impl Contains<RuntimeCall> for SafeCallFilter {
526+
fn contains(call: &RuntimeCall) -> bool {
527+
match call {
528+
RuntimeCall::Balances(pallet_balances::Call::transfer_keep_alive { .. }) => true,
529+
// Foreign assets instance
530+
RuntimeCall::ForeignAssets(pallet_assets::Call::<
531+
Runtime,
532+
crate::ForeignAssetsInstance,
533+
>::create {
534+
..
535+
}) => true,
536+
RuntimeCall::ForeignAssets(pallet_assets::Call::<
537+
Runtime,
538+
crate::ForeignAssetsInstance,
539+
>::force_set_metadata {
540+
..
541+
}) => true,
542+
RuntimeCall::ForeignAssets(pallet_assets::Call::<
543+
Runtime,
544+
crate::ForeignAssetsInstance,
545+
>::set_metadata {
546+
..
547+
}) => true,
548+
RuntimeCall::ForeignAssets(pallet_assets::Call::<
549+
Runtime,
550+
crate::ForeignAssetsInstance,
551+
>::set_team {
552+
..
553+
}) => true,
554+
RuntimeCall::ForeignAssets(pallet_assets::Call::<
555+
Runtime,
556+
crate::ForeignAssetsInstance,
557+
>::touch {
558+
..
559+
}) => true,
560+
RuntimeCall::Nfts(pallet_nfts::Call::create { .. }) => true,
561+
RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_subscribe_version_notify {
562+
..
563+
}) => true,
564+
RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) => true,
565+
// Allow staking stuff through XCM
566+
RuntimeCall::Staking(pallet_staking_async::Call::bond_extra { .. }) => true,
567+
RuntimeCall::Staking(pallet_staking_async::Call::rebond { .. }) => true,
568+
RuntimeCall::Staking(pallet_staking_async::Call::unbond { .. }) => true,
569+
RuntimeCall::Staking(pallet_staking_async::Call::withdraw_unbonded { .. }) => true,
570+
RuntimeCall::System(frame_system::Call::authorize_upgrade { .. }) => true,
571+
RuntimeCall::System(frame_system::Call::set_storage { .. }) => true,
572+
RuntimeCall::ToKusamaXcmRouter(pallet_xcm_bridge_hub_router::Call::<
573+
Runtime,
574+
crate::ToKusamaXcmRouterInstance,
575+
>::report_bridge_status {
576+
..
577+
}) => true,
578+
RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) => true,
579+
RuntimeCall::Utility(pallet_utility::Call::batch_all { .. }) => true,
580+
RuntimeCall::Utility(pallet_utility::Call::force_batch { .. }) => true,
581+
RuntimeCall::Whitelist(pallet_whitelist::Call::whitelist_call { .. }) => true,
582+
_ => false,
583+
}
584+
}
585+
}
586+
524587
parameter_types! {
525588
// `GeneralAdmin` pluralistic body.
526589
pub const GeneralAdminBodyId: BodyId = BodyId::Administration;

0 commit comments

Comments
 (0)