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

[stable2409] Backport #7893 #7920

Open
wants to merge 8 commits into
base: stable2409
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
47 changes: 41 additions & 6 deletions cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ use xcm::latest::prelude::{
};
use xcm::{
latest::prelude::{AssetId, BodyId},
Version as XcmVersion, VersionedAsset, VersionedAssetId, VersionedAssets, VersionedLocation,
VersionedXcm,
Version as XcmVersion, VersionedAssetId, VersionedAssets, VersionedLocation, VersionedXcm,
};
use xcm_runtime_apis::{
dry_run::{CallDryRunEffects, Error as XcmDryRunApiError, XcmDryRunEffects},
Expand Down Expand Up @@ -1468,6 +1467,7 @@ impl_runtime_apis! {
config: frame_benchmarking::BenchmarkConfig
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
use frame_benchmarking::{Benchmarking, BenchmarkBatch, BenchmarkError};
use frame_support::assert_ok;
use sp_storage::TrackedStorageKey;

use frame_system_benchmarking::Pallet as SystemBench;
Expand Down Expand Up @@ -1591,9 +1591,27 @@ impl_runtime_apis! {
}

fn get_asset() -> Asset {
use frame_benchmarking::whitelisted_caller;
use frame_support::traits::tokens::fungible::{Inspect, Mutate};
let account = whitelisted_caller();
assert_ok!(<Balances as Mutate<_>>::mint_into(
&account,
<Balances as Inspect<_>>::minimum_balance(),
));
let asset_id = 1984;
assert_ok!(Assets::force_create(
RuntimeOrigin::root(),
asset_id.into(),
account.into(),
true,
1u128,
));
let amount = 1_000_000u128;
let asset_location = Location::new(0, [PalletInstance(50), GeneralIndex(u32::from(asset_id).into())]);

Asset {
id: AssetId(Location::parent()),
fun: Fungible(ExistentialDeposit::get()),
id: AssetId(asset_location),
fun: Fungible(amount),
}
}
}
Expand Down Expand Up @@ -1687,9 +1705,26 @@ impl_runtime_apis! {
type TrustedReserve = TrustedReserve;

fn get_asset() -> Asset {
use frame_support::traits::tokens::fungible::{Inspect, Mutate};
let (account, _) = pallet_xcm_benchmarks::account_and_location::<Runtime>(1);
assert_ok!(<Balances as Mutate<_>>::mint_into(
&account,
<Balances as Inspect<_>>::minimum_balance(),
));
let asset_id = 1984;
assert_ok!(Assets::force_create(
RuntimeOrigin::root(),
asset_id.into(),
account.clone().into(),
true,
1u128,
));
let amount = 1_000_000u128;
let asset_location = Location::new(0, [PalletInstance(50), GeneralIndex(u32::from(asset_id).into())]);

Asset {
id: AssetId(TokenLocation::get()),
fun: Fungible(UNITS),
id: AssetId(asset_location),
fun: Fungible(amount),
}
}
}
Expand Down
Loading
Loading