Skip to content

Commit

Permalink
refactor asset-hub-rococo
Browse files Browse the repository at this point in the history
  • Loading branch information
EleisonC committed Jan 27, 2025
1 parent 04ba860 commit 7617aa6
Showing 1 changed file with 20 additions and 24 deletions.
44 changes: 20 additions & 24 deletions cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1712,48 +1712,42 @@ impl_runtime_apis! {
ExistentialDeposit::get()
).into());
pub const RandomParaId: ParaId = ParaId::new(43211234);
pub RandomParaLocation: Location = ParentThen(Parachain(RandomParaId::get().into()).into()).into();
}

use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
impl pallet_xcm::benchmarking::Config for Runtime {
type DeliveryHelper = (
cumulus_primitives_utility::ToParentDeliveryHelper<
xcm_config::XcmConfig,
ExistentialDepositAsset,
xcm_config::PriceForParentDelivery,
>,
polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper<
type DeliveryHelper = polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper<
xcm_config::XcmConfig,
ExistentialDepositAsset,
PriceForSiblingParachainDelivery,
RandomParaId,
ParachainSystem,
>
);
>;

fn reachable_dest() -> Option<Location> {
Some(Parent.into())
Some(RandomParaLocation::get())
}

fn teleportable_asset_and_dest() -> Option<(Asset, Location)> {
// Relay/native token can be teleported between AH and Relay.
Some((
Asset {
fun: Fungible(ExistentialDeposit::get()),
id: AssetId(Parent.into())
id: AssetId(TokenLocation::get())
},
Parent.into(),
RandomParaLocation::get(),
))
}

fn reserve_transferable_asset_and_dest() -> Option<(Asset, Location)> {
Some((
Asset {
fun: Fungible(ExistentialDeposit::get()),
id: AssetId(Parent.into())
id: AssetId(TokenLocation::get())
},
// AH can reserve transfer native token to some random parachain.
ParentThen(Parachain(RandomParaId::get().into()).into()).into(),
RandomParaLocation::get(),
))
}

Expand All @@ -1762,10 +1756,10 @@ impl_runtime_apis! {
// Transfer to Relay some local AH asset (local-reserve-transfer) while paying
// fees using teleported native token.
// (We don't care that Relay doesn't accept incoming unknown AH local asset)
let dest = Parent.into();
let dest = RandomParaLocation::get();

let fee_amount = EXISTENTIAL_DEPOSIT;
let fee_asset: Asset = (Location::parent(), fee_amount).into();
let fee_asset: Asset = (TokenLocation::get(), fee_amount).into();

let who = frame_benchmarking::whitelisted_caller();
// Give some multiple of the existential deposit
Expand Down Expand Up @@ -1808,7 +1802,7 @@ impl_runtime_apis! {

fn get_asset() -> Asset {
Asset {
id: AssetId(Location::parent()),
id: AssetId(TokenLocation::get()),
fun: Fungible(ExistentialDeposit::get()),
}
}
Expand Down Expand Up @@ -1849,13 +1843,15 @@ impl_runtime_apis! {
impl pallet_xcm_benchmarks::Config for Runtime {
type XcmConfig = xcm_config::XcmConfig;
type AccountIdConverter = xcm_config::LocationToAccountId;
type DeliveryHelper = cumulus_primitives_utility::ToParentDeliveryHelper<
xcm_config::XcmConfig,
ExistentialDepositAsset,
xcm_config::PriceForParentDelivery,
>;
type DeliveryHelper = polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper<
xcm_config::XcmConfig,
ExistentialDepositAsset,
PriceForSiblingParachainDelivery,
RandomParaId,
ParachainSystem,
>;
fn valid_destination() -> Result<Location, BenchmarkError> {
Ok(TokenLocation::get())
Ok(RandomParaLocation::get())
}
fn worst_case_holding(depositable_count: u32) -> XcmAssets {
// A mix of fungible, non-fungible, and concrete assets.
Expand All @@ -1882,7 +1878,7 @@ impl_runtime_apis! {

parameter_types! {
pub const TrustedTeleporter: Option<(Location, Asset)> = Some((
TokenLocation::get(),
RandomParaLocation::get(),
Asset { fun: Fungible(UNITS), id: AssetId(TokenLocation::get()) },
));
pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None;
Expand Down

0 comments on commit 7617aa6

Please sign in to comment.