Skip to content

Commit b0b7472

Browse files
[xcm-builder] Replaced deprecated CurrencyAdapter with FungibleAdapter (#3287)
I found out during the cleanup of this deprecation message in the `polkadot-fellows` repository that we deprecated `CurrencyAdapter` without making the recommended changes. ## TODO - [ ] fix `polkadot-fellows` bump to 1.6.0 polkadot-fellows/runtimes#159 --------- Co-authored-by: Francisco Aguirre <franciscoaguirreperez@gmail.com>
1 parent eff548e commit b0b7472

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

polkadot/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,16 @@ benchmarks_instance_pallet! {
6464
transfer_asset {
6565
let (sender_account, sender_location) = account_and_location::<T>(1);
6666
let asset = T::get_asset();
67-
let assets: Assets = vec![ asset.clone() ].into();
67+
let assets: Assets = vec![asset.clone()].into();
6868
// this xcm doesn't use holding
6969

7070
let dest_location = T::valid_destination()?;
7171
let dest_account = T::AccountIdConverter::convert_location(&dest_location).unwrap();
7272

7373
<AssetTransactorOf<T>>::deposit_asset(&asset, &sender_location, None).unwrap();
74+
// We deposit the asset twice so we have enough for ED after transferring
75+
<AssetTransactorOf<T>>::deposit_asset(&asset, &sender_location, None).unwrap();
76+
let sender_account_balance_before = T::TransactAsset::balance(&sender_account);
7477
assert!(T::TransactAsset::balance(&dest_account).is_zero());
7578

7679
let mut executor = new_executor::<T>(sender_location);
@@ -79,7 +82,7 @@ benchmarks_instance_pallet! {
7982
}: {
8083
executor.bench_process(xcm)?;
8184
} verify {
82-
assert!(T::TransactAsset::balance(&sender_account).is_zero());
85+
assert!(T::TransactAsset::balance(&sender_account) < sender_account_balance_before);
8386
assert!(!T::TransactAsset::balance(&dest_account).is_zero());
8487
}
8588

@@ -93,11 +96,12 @@ benchmarks_instance_pallet! {
9396
&dest_location,
9497
FeeReason::TransferReserveAsset
9598
);
96-
let sender_account_balance_before = T::TransactAsset::balance(&sender_account);
9799

98100
let asset = T::get_asset();
99101
<AssetTransactorOf<T>>::deposit_asset(&asset, &sender_location, None).unwrap();
100-
assert!(T::TransactAsset::balance(&sender_account) > sender_account_balance_before);
102+
// We deposit the asset twice so we have enough for ED after transferring
103+
<AssetTransactorOf<T>>::deposit_asset(&asset, &sender_location, None).unwrap();
104+
let sender_account_balance_before = T::TransactAsset::balance(&sender_account);
101105
let assets: Assets = vec![asset].into();
102106
assert!(T::TransactAsset::balance(&dest_account).is_zero());
103107

polkadot/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ impl xcm_executor::traits::MatchesFungible<u64> for MatchAnyFungible {
103103
}
104104

105105
// Use balances as the asset transactor.
106-
#[allow(deprecated)]
107-
pub type AssetTransactor = xcm_builder::CurrencyAdapter<
106+
pub type AssetTransactor = xcm_builder::FungibleAdapter<
108107
Balances,
109108
MatchAnyFungible,
110109
AccountIdConverter,
@@ -192,8 +191,7 @@ impl xcm_balances_benchmark::Config for Test {
192191
type TrustedReserve = TrustedReserve;
193192

194193
fn get_asset() -> Asset {
195-
let amount =
196-
<Balances as frame_support::traits::fungible::Inspect<u64>>::minimum_balance() as u128;
194+
let amount = 1_000_000_000_000;
197195
Asset { id: AssetId(Here.into()), fun: Fungible(amount) }
198196
}
199197
}

0 commit comments

Comments
 (0)