-
Notifications
You must be signed in to change notification settings - Fork 1.6k
XCM: Remove & replace XCM Convert
trait
#7329
Conversation
Convert
traitConvert
trait
}; | ||
#[allow(deprecated)] | ||
pub use super::{Identity, JustTry}; |
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.
Are we going to continue exporting these types after deprecation by re-exporting from sp_runtime? What's the plan otherwise?
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.
We'll remove them eventually (hence deeprecation), but they're here to minimise breaking changes.
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.
LGTM, just some clippy issues
Co-authored-by: Muharem Ismailov <[email protected]>
Co-authored-by: Liam Aharon <[email protected]>
Co-authored-by: Liam Aharon <[email protected]>
Co-authored-by: Liam Aharon <[email protected]>
Co-authored-by: Liam Aharon <[email protected]>
Co-authored-by: Liam Aharon <[email protected]>
Co-authored-by: Liam Aharon <[email protected]>
bot merge |
This pull request has been mentioned on Polkadot Forum. There might be relevant details there: https://forum.polkadot.network/t/multichain-friendly-account-abstraction/1298/20 |
This pull request has been mentioned on Polkadot Forum. There might be relevant details there: https://forum.polkadot.network/t/multichain-friendly-account-abstraction/1298/21 |
Cumulus Companion: paritytech/cumulus#2688
The
Convert
trait had a name collision with a similar trait in Substrate causing confusion; the trait itself was used for 4 things, each quite different and was better replaced by using more job-specific traits and more general conversion traits from Substrate.API changes
xcm_executor::traits::Convert
removed.xcm_executor::traits::{Encoded, Decoded}
removed.xcm_executor::traits::{JustTry, Identity}
deprecated (usesp_runtime
equivalents instead).xcm_executor::traits::ConvertLocation
added.xcm_builder::location_conversion::DescribeLocation
added.xcm_builder::location_conversion::HashedDescription
and family added, which should be used to replace usages ofForeignChainAliasAccount
.ForeignChainAliasAccount
deprecated.Origin Conversion
EnsureXcmOrigin
:Conversion
bound changes fromxcm_executor::traits::Convert<RuntimeOrigin, MultiLocation>
toTryConvert<RuntimeOrigin, MultiLocation>
.Location Conversion
LocationConverter
bound changes fromxcm_executor::traits::Convert<MultiLocation, RuntimeOrigin::AccountId>
toConvertLocation<RuntimeOrigin::AccountId>
.AccountIdConverter
bound changes fromxcm_executor::traits::Convert<MultiLocation, AccountId>
toConvertLocation<AccountId>
.pallet_xcm::Config::SovereignAccountOf
bound changes fromxcm_executor::traits::Convert<MultiLocation, Self::AccountId>
toConvertLocation<Self::AccountId>
.Asset Conversion
ConvertClassId
bound changes fromxcm_executor::traits::Convert<[u8; 32], ClassId>
toMaybeEquivalence<[u8; 32], ClassId>
(same forAssetId
).ConvertInstanceId
bound changes fromxcm_executor::traits::Convert<AssetInstance, InstanceId>
toMaybeEquivalence<AssetInstance, InstanceId>
.ConvertBalance
bound changes fromxcm_executor::traits::Convert<u128, Balance>
toMaybeEquivalence<u128, Balance>
.Migrating code
Since almost all trait-implementors have also been changed in line with the bounds, there should be a good degree of compatibility for runtime maintainers. However, if there are custom implementations of the
xcm_executor::traits::Convert
trait, then these will need to be altered into an implementation of eitherConvertLocation
,MaybeEquivalence
orTryConvert
(depending on what kind of conversion it is performing).The functions provided in the new traits are slightly different; if the
xcm_executor::traits::Convert
was being used directly (e.g. in tests) then the code will need to be adapted. Theimpl Borrow
parameter types are not used in any of the new traits, instead favouring simpler pass-by-value (TryConvert
) or pass-by-reference (ConvertLocation
,MaybeEquivalence
). The return types used in the new location conversion and asset conversion traits areOption
, notResult
(as was the case inxcm_executor::traits::Convert
. Naming is also slightly different;convert_location
is called instead ofconvert
for location conversion.convert_ref
andreverse_ref
becomeconvert
andconvert_back
for asset conversion. For origin conversion,convert
becomestry_convert
.This PR deprecates
ForeignChainAliasAccount
; if it is already in production usage in your runtime, it may be replaced withHashedDescription<AccountId, LegacyDescribeForeignChainAccount>
. If not already in use, you are encouraged to useHashedDescription
with the modules appropriate to your expected usage, such asHashedDescription<AccountId, DescribeFamily<DescribeAllTerminal>>
.