Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fungibles methods do not consume AssetId #4224

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions cumulus/parachains/common/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ where
Assets: fungibles::Inspect<AccountId>,
{
fn contains(id: &<Assets as fungibles::Inspect<AccountId>>::AssetId) -> bool {
!Assets::total_issuance(id.clone()).is_zero()
!Assets::total_issuance(id).is_zero()
}
}

Expand All @@ -118,7 +118,7 @@ where
Assets: fungibles::Inspect<AccountId>,
{
fn contains(id: &<Assets as fungibles::Inspect<AccountId>>::AssetId) -> bool {
Assets::asset_exists(id.clone())
Assets::asset_exists(id)
}
}

Expand Down
4 changes: 2 additions & 2 deletions cumulus/parachains/common/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ where
>,
{
fn charge_weight_in_fungibles(
asset_id: <pallet_assets::Pallet<Runtime, AssetInstance> as Inspect<
asset_id: &<pallet_assets::Pallet<Runtime, AssetInstance> as Inspect<
AccountIdOf<Runtime>,
>>::AssetId,
weight: Weight,
Expand All @@ -58,7 +58,7 @@ where
let amount = WeightToFee::weight_to_fee(&weight);
// If the amount gotten is not at least the ED, then make it be the ED of the asset
// This is to avoid burning assets and decreasing the supply
let asset_amount = BalanceConverter::to_asset_balance(amount, asset_id)
let asset_amount = BalanceConverter::to_asset_balance(amount, asset_id.clone())
.map_err(|_| XcmError::TooExpensive)?;
Ok(asset_amount)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ macro_rules! impl_assets_helpers_for_system_parachain {
]
);

assert!(<Self as [<$chain ParaPallet>]>::Assets::asset_exists(id.clone().into()));
assert!(<Self as [<$chain ParaPallet>]>::Assets::asset_exists(&id));
});
}
}
Expand Down Expand Up @@ -717,7 +717,7 @@ macro_rules! impl_assets_helpers_for_parachain {
min_balance,
)
);
assert!(<Self as [<$chain ParaPallet>]>::Assets::asset_exists(id.clone()));
assert!(<Self as [<$chain ParaPallet>]>::Assets::asset_exists(&id));
type RuntimeEvent<N> = <$chain<N> as $crate::impls::Chain>::RuntimeEvent;
$crate::impls::assert_expected_events!(
Self,
Expand Down Expand Up @@ -819,7 +819,7 @@ macro_rules! impl_foreign_assets_helpers_for_parachain {
min_balance,
)
);
assert!(<Self as [<$chain ParaPallet>]>::ForeignAssets::asset_exists(id.clone()));
assert!(<Self as [<$chain ParaPallet>]>::ForeignAssets::asset_exists(&id));
type RuntimeEvent<N> = <$chain<N> as $crate::impls::Chain>::RuntimeEvent;
$crate::impls::assert_expected_events!(
Self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,17 +224,17 @@ fn transfer_foreign_assets_from_asset_hub_to_para() {
let sender_wnds_before = AssetHubRococo::execute_with(|| {
type ForeignAssets = <AssetHubRococo as AssetHubRococoPallet>::ForeignAssets;
<ForeignAssets as Inspect<_>>::balance(
wnd_at_rococo_parachains.clone().try_into().unwrap(),
&wnd_at_rococo_parachains.clone().try_into().unwrap(),
&sender,
)
});
let receiver_assets_before = PenpalA::execute_with(|| {
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
<ForeignAssets as Inspect<_>>::balance(native_asset_location.clone(), &receiver)
<ForeignAssets as Inspect<_>>::balance(&native_asset_location.clone(), &receiver)
});
let receiver_wnds_before = PenpalA::execute_with(|| {
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
<ForeignAssets as Inspect<_>>::balance(wnd_at_rococo_parachains.clone(), &receiver)
<ForeignAssets as Inspect<_>>::balance(&wnd_at_rococo_parachains.clone(), &receiver)
});

// Set assertions and dispatchables
Expand All @@ -248,17 +248,17 @@ fn transfer_foreign_assets_from_asset_hub_to_para() {
let sender_wnds_after = AssetHubRococo::execute_with(|| {
type ForeignAssets = <AssetHubRococo as AssetHubRococoPallet>::ForeignAssets;
<ForeignAssets as Inspect<_>>::balance(
wnd_at_rococo_parachains.clone().try_into().unwrap(),
&wnd_at_rococo_parachains.clone().try_into().unwrap(),
&sender,
)
});
let receiver_assets_after = PenpalA::execute_with(|| {
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
<ForeignAssets as Inspect<_>>::balance(native_asset_location, &receiver)
<ForeignAssets as Inspect<_>>::balance(&native_asset_location, &receiver)
});
let receiver_wnds_after = PenpalA::execute_with(|| {
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
<ForeignAssets as Inspect<_>>::balance(wnd_at_rococo_parachains, &receiver)
<ForeignAssets as Inspect<_>>::balance(&wnd_at_rococo_parachains, &receiver)
});

// Sender's balance is reduced by amount sent plus delivery fees
Expand Down Expand Up @@ -377,17 +377,17 @@ fn transfer_foreign_assets_from_para_to_asset_hub() {
// Query initial balances
let sender_native_before = PenpalA::execute_with(|| {
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
<ForeignAssets as Inspect<_>>::balance(native_asset_location.clone(), &sender)
<ForeignAssets as Inspect<_>>::balance(&native_asset_location.clone(), &sender)
});
let sender_wnds_before = PenpalA::execute_with(|| {
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
<ForeignAssets as Inspect<_>>::balance(wnd_at_rococo_parachains.clone(), &sender)
<ForeignAssets as Inspect<_>>::balance(&wnd_at_rococo_parachains.clone(), &sender)
});
let receiver_native_before = test.receiver.balance;
let receiver_wnds_before = AssetHubRococo::execute_with(|| {
type ForeignAssets = <AssetHubRococo as AssetHubRococoPallet>::ForeignAssets;
<ForeignAssets as Inspect<_>>::balance(
wnd_at_rococo_parachains.clone().try_into().unwrap(),
&wnd_at_rococo_parachains.clone().try_into().unwrap(),
&receiver,
)
});
Expand All @@ -401,17 +401,17 @@ fn transfer_foreign_assets_from_para_to_asset_hub() {
// Query final balances
let sender_native_after = PenpalA::execute_with(|| {
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
<ForeignAssets as Inspect<_>>::balance(native_asset_location, &sender)
<ForeignAssets as Inspect<_>>::balance(&native_asset_location, &sender)
});
let sender_wnds_after = PenpalA::execute_with(|| {
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
<ForeignAssets as Inspect<_>>::balance(wnd_at_rococo_parachains.clone(), &sender)
<ForeignAssets as Inspect<_>>::balance(&wnd_at_rococo_parachains.clone(), &sender)
});
let receiver_native_after = test.receiver.balance;
let receiver_wnds_after = AssetHubRococo::execute_with(|| {
type ForeignAssets = <AssetHubRococo as AssetHubRococoPallet>::ForeignAssets;
<ForeignAssets as Inspect<_>>::balance(
wnd_at_rococo_parachains.try_into().unwrap(),
&wnd_at_rococo_parachains.try_into().unwrap(),
&receiver,
)
});
Expand Down Expand Up @@ -536,18 +536,18 @@ fn transfer_foreign_assets_from_para_to_para_through_asset_hub() {
// Query initial balances
let sender_rocs_before = PenpalA::execute_with(|| {
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
<ForeignAssets as Inspect<_>>::balance(roc_location.clone(), &sender)
<ForeignAssets as Inspect<_>>::balance(&roc_location.clone(), &sender)
});
let sender_wnds_before = PenpalA::execute_with(|| {
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
<ForeignAssets as Inspect<_>>::balance(wnd_at_rococo_parachains.clone(), &sender)
<ForeignAssets as Inspect<_>>::balance(&wnd_at_rococo_parachains.clone(), &sender)
});
let rocs_in_sender_reserve_on_ahr_before =
<AssetHubRococo as Chain>::account_data_of(sov_of_sender_on_ah.clone()).free;
let wnds_in_sender_reserve_on_ahr_before = AssetHubRococo::execute_with(|| {
type Assets = <AssetHubRococo as AssetHubRococoPallet>::ForeignAssets;
<Assets as Inspect<_>>::balance(
wnd_at_rococo_parachains.clone().try_into().unwrap(),
&wnd_at_rococo_parachains.clone().try_into().unwrap(),
&sov_of_sender_on_ah,
)
});
Expand All @@ -556,17 +556,17 @@ fn transfer_foreign_assets_from_para_to_para_through_asset_hub() {
let wnds_in_receiver_reserve_on_ahr_before = AssetHubRococo::execute_with(|| {
type Assets = <AssetHubRococo as AssetHubRococoPallet>::ForeignAssets;
<Assets as Inspect<_>>::balance(
wnd_at_rococo_parachains.clone().try_into().unwrap(),
&wnd_at_rococo_parachains.clone().try_into().unwrap(),
&sov_of_receiver_on_ah,
)
});
let receiver_rocs_before = PenpalB::execute_with(|| {
type ForeignAssets = <PenpalB as PenpalBPallet>::ForeignAssets;
<ForeignAssets as Inspect<_>>::balance(roc_location.clone(), &receiver)
<ForeignAssets as Inspect<_>>::balance(&roc_location.clone(), &receiver)
});
let receiver_wnds_before = PenpalB::execute_with(|| {
type ForeignAssets = <PenpalB as PenpalBPallet>::ForeignAssets;
<ForeignAssets as Inspect<_>>::balance(wnd_at_rococo_parachains.clone(), &receiver)
<ForeignAssets as Inspect<_>>::balance(&wnd_at_rococo_parachains.clone(), &receiver)
});

// Set assertions and dispatchables
Expand All @@ -579,16 +579,16 @@ fn transfer_foreign_assets_from_para_to_para_through_asset_hub() {
// Query final balances
let sender_rocs_after = PenpalA::execute_with(|| {
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
<ForeignAssets as Inspect<_>>::balance(roc_location.clone(), &sender)
<ForeignAssets as Inspect<_>>::balance(&roc_location.clone(), &sender)
});
let sender_wnds_after = PenpalA::execute_with(|| {
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
<ForeignAssets as Inspect<_>>::balance(wnd_at_rococo_parachains.clone(), &sender)
<ForeignAssets as Inspect<_>>::balance(&wnd_at_rococo_parachains.clone(), &sender)
});
let wnds_in_sender_reserve_on_ahr_after = AssetHubRococo::execute_with(|| {
type Assets = <AssetHubRococo as AssetHubRococoPallet>::ForeignAssets;
<Assets as Inspect<_>>::balance(
wnd_at_rococo_parachains.clone().try_into().unwrap(),
&wnd_at_rococo_parachains.clone().try_into().unwrap(),
&sov_of_sender_on_ah,
)
});
Expand All @@ -597,19 +597,19 @@ fn transfer_foreign_assets_from_para_to_para_through_asset_hub() {
let wnds_in_receiver_reserve_on_ahr_after = AssetHubRococo::execute_with(|| {
type Assets = <AssetHubRococo as AssetHubRococoPallet>::ForeignAssets;
<Assets as Inspect<_>>::balance(
wnd_at_rococo_parachains.clone().try_into().unwrap(),
&wnd_at_rococo_parachains.clone().try_into().unwrap(),
&sov_of_receiver_on_ah,
)
});
let rocs_in_receiver_reserve_on_ahr_after =
<AssetHubRococo as Chain>::account_data_of(sov_of_receiver_on_ah).free;
let receiver_rocs_after = PenpalB::execute_with(|| {
type ForeignAssets = <PenpalB as PenpalBPallet>::ForeignAssets;
<ForeignAssets as Inspect<_>>::balance(roc_location, &receiver)
<ForeignAssets as Inspect<_>>::balance(&roc_location, &receiver)
});
let receiver_wnds_after = PenpalB::execute_with(|| {
type ForeignAssets = <PenpalB as PenpalBPallet>::ForeignAssets;
<ForeignAssets as Inspect<_>>::balance(wnd_at_rococo_parachains, &receiver)
<ForeignAssets as Inspect<_>>::balance(&wnd_at_rococo_parachains, &receiver)
});

// Sender's balance is reduced by amount sent plus delivery fees
Expand Down Expand Up @@ -682,7 +682,7 @@ fn transfer_native_asset_from_relay_to_para_through_asset_hub() {
});
let receiver_assets_before = PenpalA::execute_with(|| {
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
<ForeignAssets as Inspect<_>>::balance(relay_native_asset_location.clone(), &receiver)
<ForeignAssets as Inspect<_>>::balance(&relay_native_asset_location, &receiver)
});

fn relay_assertions(t: RelayToParaThroughAHTest) {
Expand Down Expand Up @@ -795,7 +795,7 @@ fn transfer_native_asset_from_relay_to_para_through_asset_hub() {
});
let receiver_assets_after = PenpalA::execute_with(|| {
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
<ForeignAssets as Inspect<_>>::balance(relay_native_asset_location, &receiver)
<ForeignAssets as Inspect<_>>::balance(&relay_native_asset_location, &receiver)
});

// Sender's balance is reduced by amount sent plus delivery fees
Expand Down
Loading
Loading