Skip to content

Commit 981f908

Browse files
authored
enable new evm foreign assets in moonriver and moonbeam (#3051)
1 parent 35a89ac commit 981f908

File tree

2 files changed

+44
-10
lines changed

2 files changed

+44
-10
lines changed

runtime/moonbeam/src/xcm_config.rs

+22-5
Original file line numberDiff line numberDiff line change
@@ -672,14 +672,31 @@ impl sp_runtime::traits::Convert<AccountId, H160> for AccountIdToH160 {
672672
}
673673
}
674674

675+
pub struct EvmForeignAssetIdFilter;
676+
impl frame_support::traits::Contains<AssetId> for EvmForeignAssetIdFilter {
677+
fn contains(asset_id: &AssetId) -> bool {
678+
use xcm_primitives::AssetTypeGetter as _;
679+
// We should return true only if the AssetId doesn't exist in AssetManager
680+
AssetManager::get_asset_type(*asset_id).is_none()
681+
}
682+
}
683+
684+
pub type ForeignAssetManagerOrigin = EitherOfDiverse<
685+
EnsureRoot<AccountId>,
686+
EitherOfDiverse<
687+
pallet_collective::EnsureProportionMoreThan<AccountId, OpenTechCommitteeInstance, 5, 9>,
688+
governance::custom_origins::FastGeneralAdmin,
689+
>,
690+
>;
691+
675692
impl pallet_moonbeam_foreign_assets::Config for Runtime {
676693
type AccountIdToH160 = AccountIdToH160;
677-
type AssetIdFilter = Nothing;
694+
type AssetIdFilter = EvmForeignAssetIdFilter;
678695
type EvmRunner = EvmRunnerPrecompileOrEthXcm<MoonbeamCall, Self>;
679-
type ForeignAssetCreatorOrigin = frame_system::EnsureNever<AccountId>;
680-
type ForeignAssetFreezerOrigin = frame_system::EnsureNever<AccountId>;
681-
type ForeignAssetModifierOrigin = frame_system::EnsureNever<AccountId>;
682-
type ForeignAssetUnfreezerOrigin = frame_system::EnsureNever<AccountId>;
696+
type ForeignAssetCreatorOrigin = ForeignAssetManagerOrigin;
697+
type ForeignAssetFreezerOrigin = ForeignAssetManagerOrigin;
698+
type ForeignAssetModifierOrigin = ForeignAssetManagerOrigin;
699+
type ForeignAssetUnfreezerOrigin = ForeignAssetManagerOrigin;
683700
type OnForeignAssetCreated = ();
684701
type MaxForeignAssets = ConstU32<256>;
685702
type RuntimeEvent = RuntimeEvent;

runtime/moonriver/src/xcm_config.rs

+22-5
Original file line numberDiff line numberDiff line change
@@ -685,14 +685,31 @@ impl sp_runtime::traits::Convert<AccountId, H160> for AccountIdToH160 {
685685
}
686686
}
687687

688+
pub struct EvmForeignAssetIdFilter;
689+
impl frame_support::traits::Contains<AssetId> for EvmForeignAssetIdFilter {
690+
fn contains(asset_id: &AssetId) -> bool {
691+
use xcm_primitives::AssetTypeGetter as _;
692+
// We should return true only if the AssetId doesn't exist in AssetManager
693+
AssetManager::get_asset_type(*asset_id).is_none()
694+
}
695+
}
696+
697+
pub type ForeignAssetManagerOrigin = EitherOfDiverse<
698+
EnsureRoot<AccountId>,
699+
EitherOfDiverse<
700+
pallet_collective::EnsureProportionMoreThan<AccountId, OpenTechCommitteeInstance, 5, 9>,
701+
governance::custom_origins::FastGeneralAdmin,
702+
>,
703+
>;
704+
688705
impl pallet_moonbeam_foreign_assets::Config for Runtime {
689706
type AccountIdToH160 = AccountIdToH160;
690-
type AssetIdFilter = Nothing;
707+
type AssetIdFilter = EvmForeignAssetIdFilter;
691708
type EvmRunner = EvmRunnerPrecompileOrEthXcm<MoonbeamCall, Self>;
692-
type ForeignAssetCreatorOrigin = frame_system::EnsureNever<AccountId>;
693-
type ForeignAssetFreezerOrigin = frame_system::EnsureNever<AccountId>;
694-
type ForeignAssetModifierOrigin = frame_system::EnsureNever<AccountId>;
695-
type ForeignAssetUnfreezerOrigin = frame_system::EnsureNever<AccountId>;
709+
type ForeignAssetCreatorOrigin = ForeignAssetManagerOrigin;
710+
type ForeignAssetFreezerOrigin = ForeignAssetManagerOrigin;
711+
type ForeignAssetModifierOrigin = ForeignAssetManagerOrigin;
712+
type ForeignAssetUnfreezerOrigin = ForeignAssetManagerOrigin;
696713
type OnForeignAssetCreated = ();
697714
type MaxForeignAssets = ConstU32<256>;
698715
type RuntimeEvent = RuntimeEvent;

0 commit comments

Comments
 (0)