diff --git a/runtime/kreivo/src/xcm_config.rs b/runtime/kreivo/src/xcm_config.rs index 8a8a25b1..57e85388 100644 --- a/runtime/kreivo/src/xcm_config.rs +++ b/runtime/kreivo/src/xcm_config.rs @@ -34,7 +34,7 @@ use plurality_community::*; parameter_types! { pub const RelayLocation: MultiLocation = MultiLocation::parent(); - pub const RelayNetwork: Option = None; + pub const RelayNetwork: Option = Some(NetworkId::Kusama); pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into(); pub CheckAccount: (AccountId, MintLocation) = (PolkadotXcm::check_account(), MintLocation::Local); pub CheckingAccount: AccountId = PolkadotXcm::check_account(); @@ -58,6 +58,8 @@ pub type LocationToAccountId = ( SiblingParachainConvertsVia, // Plurality origins convert to community AccountId via the `Communities::community_account`. PluralityConvertsToCommunityAccountId, + // For incoming relay `Account32` origins, alias directly to `AccountId`. + AccountId32FromRelay, // Straight up local `AccountId32` origins just alias directly to `AccountId`. AccountId32Aliases, ); diff --git a/runtime/kreivo/src/xcm_config/plurality_community.rs b/runtime/kreivo/src/xcm_config/plurality_community.rs index 78ac43d5..975ad902 100644 --- a/runtime/kreivo/src/xcm_config/plurality_community.rs +++ b/runtime/kreivo/src/xcm_config/plurality_community.rs @@ -8,7 +8,6 @@ use xcm_executor::traits::ConvertLocation; pub struct PluralityConvertsToCommunityAccountId; impl ConvertLocation for PluralityConvertsToCommunityAccountId { fn convert_location(location: &MultiLocation) -> Option { - log::trace!("Attempting to convert {:?} into AccountId if plurality", location); match location { MultiLocation { parents: 0, @@ -20,3 +19,24 @@ impl ConvertLocation for PluralityConvertsToCommunityAccountId { } } } + +pub struct AccountId32FromRelay(PhantomData<(Network, AccountId)>); +impl>, AccountId: From<[u8; 32]> + Into<[u8; 32]> + Clone> ConvertLocation + for AccountId32FromRelay +{ + fn convert_location(location: &MultiLocation) -> Option { + let id = match location { + MultiLocation { + parents: 1, + interior: X1(AccountId32 { id, network: None }), + } => id, + MultiLocation { + parents: 1, + interior: X1(AccountId32 { id, network }), + } if *network == Network::get() => id, + _ => return None, + }; + + Some((*id).into()) + } +}