From 2d9c6bbbaee4408482bbbe6db68598693de6685a Mon Sep 17 00:00:00 2001 From: Bryan Chen Date: Fri, 7 Nov 2025 20:57:16 +1300 Subject: [PATCH 1/2] avoid mint/burn --- xcm-support/src/currency_adapter.rs | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/xcm-support/src/currency_adapter.rs b/xcm-support/src/currency_adapter.rs index 7a00cf72c..7db5e8123 100644 --- a/xcm-support/src/currency_adapter.rs +++ b/xcm-support/src/currency_adapter.rs @@ -111,6 +111,7 @@ pub struct MultiCurrencyAdapter< CurrencyId, CurrencyIdConvert, DepositFailureHandler, + CheckingAccount, >( PhantomData<( MultiCurrency, @@ -121,6 +122,7 @@ pub struct MultiCurrencyAdapter< CurrencyId, CurrencyIdConvert, DepositFailureHandler, + CheckingAccount, )>, ); @@ -133,6 +135,7 @@ impl< CurrencyId: FullCodec + Eq + PartialEq + Copy + MaybeSerializeDeserialize + Debug, CurrencyIdConvert: Convert>, DepositFailureHandler: OnDepositFail, + CheckingAccount: Get, > TransactAsset for MultiCurrencyAdapter< MultiCurrency, @@ -143,6 +146,7 @@ impl< CurrencyId, CurrencyIdConvert, DepositFailureHandler, + CheckingAccount, > { fn deposit_asset(asset: &Asset, location: &Location, _context: Option<&XcmContext>) -> Result { @@ -152,8 +156,14 @@ impl< Match::matches_fungible(asset), ) { // known asset - (Some(who), Some(currency_id), Some(amount)) => MultiCurrency::deposit(currency_id, &who, amount) - .or_else(|err| DepositFailureHandler::on_deposit_currency_fail(err, currency_id, &who, amount)), + (Some(who), Some(currency_id), Some(amount)) => MultiCurrency::transfer( + currency_id, + &CheckingAccount::get(), + &who, + amount, + ExistenceRequirement::KeepAlive, + ) + .or_else(|err| DepositFailureHandler::on_deposit_currency_fail(err, currency_id, &who, amount)), // unknown asset _ => UnknownAsset::deposit(asset, location) .or_else(|err| DepositFailureHandler::on_deposit_unknown_asset_fail(err, asset, location)), @@ -173,8 +183,14 @@ impl< let amount: MultiCurrency::Balance = Match::matches_fungible(asset) .ok_or_else(|| XcmError::from(Error::FailedToMatchFungible))? .saturated_into(); - MultiCurrency::withdraw(currency_id, &who, amount, ExistenceRequirement::AllowDeath) - .map_err(|e| XcmError::FailedToTransactAsset(e.into())) + MultiCurrency::transfer( + currency_id, + &who, + &CheckingAccount::get(), + amount, + ExistenceRequirement::AllowDeath, + ) + .map_err(|e| XcmError::FailedToTransactAsset(e.into())) })?; Ok(asset.clone().into()) From 00ed148567edf4ebca2365cfe880d81a18f40757 Mon Sep 17 00:00:00 2001 From: Bryan Chen Date: Fri, 7 Nov 2025 21:01:35 +1300 Subject: [PATCH 2/2] allow death --- xcm-support/src/currency_adapter.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xcm-support/src/currency_adapter.rs b/xcm-support/src/currency_adapter.rs index 7db5e8123..3ede559bd 100644 --- a/xcm-support/src/currency_adapter.rs +++ b/xcm-support/src/currency_adapter.rs @@ -161,7 +161,7 @@ impl< &CheckingAccount::get(), &who, amount, - ExistenceRequirement::KeepAlive, + ExistenceRequirement::AllowDeath, ) .or_else(|err| DepositFailureHandler::on_deposit_currency_fail(err, currency_id, &who, amount)), // unknown asset