From f96da6f3c37318568a1a662f39511afa76c13791 Mon Sep 17 00:00:00 2001 From: Dhiraj Sah Date: Mon, 10 Feb 2025 21:40:47 +0530 Subject: [PATCH] transfer function Preservation is changed to Expendable (#7243) # Description Fixes #7039 The Preservation of transfer method of fungible and fungibles adapters is changed from Preserve to Expendable. So the behavior of the TransferAsset will be consistent with the WithdrawAsset function, as in [fungible](https://github.com/paritytech/polkadot-sdk/blob/f3ab3854e1df9e0498599f01ba4f9f152426432a/polkadot/xcm/xcm-builder/src/fungible_adapter.rs#L217) and [fungibles](https://github.com/paritytech/polkadot-sdk/issues/url) adapter. This pull request includes changes to the `fungible_adapter.rs` and `fungibles_adapter.rs` files in the `polkadot/xcm/xcm-builder` directory. The main change involves modifying the transfer method to use the `Expendable` strategy instead of the `Preserve` strategy. Changes to transfer strategy: * [`polkadot/xcm/xcm-builder/src/fungible_adapter.rs`](diffhunk://#diff-6ebd77385441f2c8b023c480e818a01c4b43ae892c73ca30144cd64ee960bd66L67-R67): Changed the transfer method to use `Expendable` instead of `Preserve`. * [`polkadot/xcm/xcm-builder/src/fungibles_adapter.rs`](diffhunk://#diff-82221429de4c4c88be3d2976ece6475ef4fa56a32abc70290911bd47191f8e17L61-R61): Changed the transfer method to use `Expendable` instead of `Preserve`. --------- Co-authored-by: Francisco Aguirre Co-authored-by: Adrian Catangiu --- polkadot/xcm/xcm-builder/src/fungible_adapter.rs | 8 ++------ polkadot/xcm/xcm-builder/src/fungibles_adapter.rs | 7 ++----- prdoc/pr_7243.prdoc | 13 +++++++++++++ 3 files changed, 17 insertions(+), 11 deletions(-) create mode 100644 prdoc/pr_7243.prdoc diff --git a/polkadot/xcm/xcm-builder/src/fungible_adapter.rs b/polkadot/xcm/xcm-builder/src/fungible_adapter.rs index 25a705a39eb73..2da772deb0ed7 100644 --- a/polkadot/xcm/xcm-builder/src/fungible_adapter.rs +++ b/polkadot/xcm/xcm-builder/src/fungible_adapter.rs @@ -20,11 +20,7 @@ use super::MintLocation; use core::{marker::PhantomData, result}; use frame_support::traits::{ tokens::{ - fungible, - Fortitude::Polite, - Precision::Exact, - Preservation::{Expendable, Preserve}, - Provenance::Minted, + fungible, Fortitude::Polite, Precision::Exact, Preservation::Expendable, Provenance::Minted, }, Get, }; @@ -64,7 +60,7 @@ impl< .ok_or(MatchError::AccountIdConversionFailed)?; let dest = AccountIdConverter::convert_location(to) .ok_or(MatchError::AccountIdConversionFailed)?; - Fungible::transfer(&source, &dest, amount, Preserve) + Fungible::transfer(&source, &dest, amount, Expendable) .map_err(|error| XcmError::FailedToTransactAsset(error.into()))?; Ok(what.clone().into()) } diff --git a/polkadot/xcm/xcm-builder/src/fungibles_adapter.rs b/polkadot/xcm/xcm-builder/src/fungibles_adapter.rs index a259afc6e6825..59b4ccb13d0c5 100644 --- a/polkadot/xcm/xcm-builder/src/fungibles_adapter.rs +++ b/polkadot/xcm/xcm-builder/src/fungibles_adapter.rs @@ -19,10 +19,7 @@ use core::{marker::PhantomData, result}; use frame_support::traits::{ tokens::{ - fungibles, - Fortitude::Polite, - Precision::Exact, - Preservation::{Expendable, Preserve}, + fungibles, Fortitude::Polite, Precision::Exact, Preservation::Expendable, Provenance::Minted, }, Contains, Get, @@ -58,7 +55,7 @@ impl< .ok_or(MatchError::AccountIdConversionFailed)?; let dest = AccountIdConverter::convert_location(to) .ok_or(MatchError::AccountIdConversionFailed)?; - Assets::transfer(asset_id, &source, &dest, amount, Preserve) + Assets::transfer(asset_id, &source, &dest, amount, Expendable) .map_err(|e| XcmError::FailedToTransactAsset(e.into()))?; Ok(what.clone().into()) } diff --git a/prdoc/pr_7243.prdoc b/prdoc/pr_7243.prdoc new file mode 100644 index 0000000000000..c04017c29ce43 --- /dev/null +++ b/prdoc/pr_7243.prdoc @@ -0,0 +1,13 @@ +# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 +# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json + +title: 'transfer function Preservation is changed to Expendable in fungible and fungibles adapter' + +doc: + - audience: Runtime Dev + description: | + The Preservation of transfer method of fungible and fungibles adapters is changed from Preserve to Expendable. So the behavior of the TransferAsset will be consistent with the WithdrawAsset function, as in fungible and fungibles adapter. + +crates: +- name: staging-xcm-builder + bump: patch \ No newline at end of file