Skip to content

Commit

Permalink
".git/.scripts/commands/fmt/fmt.sh"
Browse files Browse the repository at this point in the history
  • Loading branch information
command-bot committed Jan 16, 2024
1 parent b619d25 commit c933a23
Show file tree
Hide file tree
Showing 11 changed files with 81 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,11 @@ fn pay_xcm_fee_with_some_asset_swapped_for_native() {
let asset_native = asset_hub_rococo_runtime::xcm_config::TokenLocationV3::get();
let asset_one = xcm::v3::Location {
parents: 0,
interior: [xcm::v3::Junction::PalletInstance(ASSETS_PALLET_ID), xcm::v3::Junction::GeneralIndex(ASSET_ID.into())].into(),
interior: [
xcm::v3::Junction::PalletInstance(ASSETS_PALLET_ID),
xcm::v3::Junction::GeneralIndex(ASSET_ID.into()),
]
.into(),
};
let penpal = AssetHubRococo::sovereign_account_id_of(AssetHubRococo::sibling_location_of(
PenpalA::para_id(),
Expand Down Expand Up @@ -370,8 +374,7 @@ fn pay_xcm_fee_with_some_asset_swapped_for_native() {
let penpal_root = <PenpalA as Chain>::RuntimeOrigin::root();
let fee_amount = 4_000_000_000_000u128;
let asset_one =
([PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())], fee_amount)
.into();
([PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())], fee_amount).into();
let asset_hub_location = PenpalA::sibling_location_of(AssetHubRococo::para_id()).into();
let xcm = xcm_transact_paid_execution(
call,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,11 @@ fn pay_xcm_fee_with_some_asset_swapped_for_native() {
let asset_native = asset_hub_westend_runtime::xcm_config::WestendLocationV3::get();
let asset_one = xcm::v3::Location {
parents: 0,
interior: [xcm::v3::Junction::PalletInstance(ASSETS_PALLET_ID), xcm::v3::Junction::GeneralIndex(ASSET_ID.into())].into(),
interior: [
xcm::v3::Junction::PalletInstance(ASSETS_PALLET_ID),
xcm::v3::Junction::GeneralIndex(ASSET_ID.into()),
]
.into(),
};
let penpal = AssetHubWestend::sovereign_account_id_of(AssetHubWestend::sibling_location_of(
PenpalB::para_id(),
Expand Down Expand Up @@ -365,8 +369,7 @@ fn pay_xcm_fee_with_some_asset_swapped_for_native() {
let penpal_root = <PenpalB as Chain>::RuntimeOrigin::root();
let fee_amount = 4_000_000_000_000u128;
let asset_one =
([PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())], fee_amount)
.into();
([PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())], fee_amount).into();
let asset_hub_location = PenpalB::sibling_location_of(AssetHubWestend::para_id()).into();
let xcm = xcm_transact_paid_execution(
call,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ use assets_common::{
};
use frame_support::{
parameter_types,
traits::{tokens::imbalance::ResolveAssetTo, ConstU32, Contains, Equals, Everything, Nothing, PalletInfoAccess},
traits::{
tokens::imbalance::ResolveAssetTo, ConstU32, Contains, Equals, Everything, Nothing,
PalletInfoAccess,
},
};
use frame_system::EnsureRoot;
use pallet_xcm::XcmPassthrough;
Expand Down
34 changes: 25 additions & 9 deletions cumulus/parachains/runtimes/assets/asset-hub-rococo/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,18 @@
use asset_hub_rococo_runtime::{
xcm_config,
xcm_config::{bridging, ForeignCreatorsSovereignAccountOf, LocationToAccountId, TokenLocation, TokenLocationV3},
xcm_config::{
bridging, ForeignCreatorsSovereignAccountOf, LocationToAccountId, TokenLocation,
TokenLocationV3,
},
AllPalletsWithoutSystem, MetadataDepositBase, MetadataDepositPerByte, RuntimeCall,
RuntimeEvent, ToWestendXcmRouterInstance, XcmpQueue,
};
pub use asset_hub_rococo_runtime::{
xcm_config::{CheckingAccount, TrustBackedAssetsPalletLocation, TrustBackedAssetsPalletLocationV3, XcmConfig},
xcm_config::{
CheckingAccount, TrustBackedAssetsPalletLocation, TrustBackedAssetsPalletLocationV3,
XcmConfig,
},
AssetConversion, AssetDeposit, Assets, Balances, CollatorSelection, ExistentialDeposit,
ForeignAssets, ForeignAssetsInstance, ParachainSystem, Runtime, SessionKeys, System,
TrustBackedAssetsInstance,
Expand All @@ -48,10 +54,10 @@ use parachains_common::{
AccountId, AssetIdForTrustBackedAssets, AuraId, Balance,
};
use sp_runtime::traits::MaybeEquivalence;
use std::convert::Into;
use xcm::latest::prelude::{Assets as XcmAssets, *};
use xcm_builder::V4V3LocationConverter;
use xcm_executor::traits::{JustTry, WeightTrader};
use std::convert::Into;

const ALICE: [u8; 32] = [1u8; 32];
const SOME_ASSET_ADMIN: [u8; 32] = [5u8; 32];
Expand Down Expand Up @@ -201,8 +207,10 @@ fn test_buy_and_refund_weight_with_swap_local_asset_xcm_trader() {
trader.buy_weight(weight, payment.into(), &ctx).expect("Expected Ok");

// assert.
let unused_amount =
unused_asset.fungible.get(&asset_1_location_latest.clone().into()).map_or(0, |a| *a);
let unused_amount = unused_asset
.fungible
.get(&asset_1_location_latest.clone().into())
.map_or(0, |a| *a);
assert_eq!(unused_amount, extra_amount);
assert_eq!(Assets::total_issuance(asset_1), asset_total_issuance + asset_fee);

Expand Down Expand Up @@ -246,8 +254,14 @@ fn test_buy_and_refund_weight_with_swap_foreign_asset_xcm_trader() {
let bob: AccountId = SOME_ASSET_ADMIN.into();
let staking_pot = CollatorSelection::account_id();
let native_location = TokenLocationV3::get();
let foreign_location =
xcm::v3::Location { parents: 1, interior: (xcm::v3::Junction::Parachain(1234), xcm::v3::Junction::GeneralIndex(12345)).into() };
let foreign_location = xcm::v3::Location {
parents: 1,
interior: (
xcm::v3::Junction::Parachain(1234),
xcm::v3::Junction::GeneralIndex(12345),
)
.into(),
};
// bob's initial balance for native and `asset1` assets.
let initial_balance = 200 * UNITS;
// liquidity for both arms of (native, asset1) pool.
Expand Down Expand Up @@ -303,8 +317,10 @@ fn test_buy_and_refund_weight_with_swap_foreign_asset_xcm_trader() {
trader.buy_weight(weight, payment.into(), &ctx).expect("Expected Ok");

// assert.
let unused_amount =
unused_asset.fungible.get(&foreign_location_latest.clone().into()).map_or(0, |a| *a);
let unused_amount = unused_asset
.fungible
.get(&foreign_location_latest.clone().into())
.map_or(0, |a| *a);
assert_eq!(unused_amount, extra_amount);
assert_eq!(
ForeignAssets::total_issuance(foreign_location),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ use assets_common::{
};
use frame_support::{
parameter_types,
traits::{tokens::imbalance::ResolveAssetTo, ConstU32, Contains, Equals, Everything, Nothing, PalletInfoAccess},
traits::{
tokens::imbalance::ResolveAssetTo, ConstU32, Contains, Equals, Everything, Nothing,
PalletInfoAccess,
},
};
use frame_system::EnsureRoot;
use pallet_xcm::XcmPassthrough;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@
use asset_hub_westend_runtime::{
xcm_config,
xcm_config::{
bridging, ForeignCreatorsSovereignAccountOf, LocationToAccountId, WestendLocation, WestendLocationV3,
bridging, ForeignCreatorsSovereignAccountOf, LocationToAccountId, WestendLocation,
WestendLocationV3,
},
AllPalletsWithoutSystem, MetadataDepositBase, MetadataDepositPerByte, PolkadotXcm, RuntimeCall,
RuntimeEvent, RuntimeOrigin, ToRococoXcmRouterInstance, XcmpQueue,
};
pub use asset_hub_westend_runtime::{
xcm_config::{CheckingAccount, TrustBackedAssetsPalletLocation, TrustBackedAssetsPalletLocationV3, XcmConfig},
xcm_config::{
CheckingAccount, TrustBackedAssetsPalletLocation, TrustBackedAssetsPalletLocationV3,
XcmConfig,
},
AssetConversion, AssetDeposit, Assets, Balances, CollatorSelection, ExistentialDeposit,
ForeignAssets, ForeignAssetsInstance, ParachainSystem, Runtime, SessionKeys, System,
TrustBackedAssetsInstance,
Expand Down Expand Up @@ -203,8 +207,10 @@ fn test_buy_and_refund_weight_with_swap_local_asset_xcm_trader() {
trader.buy_weight(weight, payment.into(), &ctx).expect("Expected Ok");

// assert.
let unused_amount =
unused_asset.fungible.get(&asset_1_location_latest.clone().into()).map_or(0, |a| *a);
let unused_amount = unused_asset
.fungible
.get(&asset_1_location_latest.clone().into())
.map_or(0, |a| *a);
assert_eq!(unused_amount, extra_amount);
assert_eq!(Assets::total_issuance(asset_1), asset_total_issuance + asset_fee);

Expand Down Expand Up @@ -248,8 +254,14 @@ fn test_buy_and_refund_weight_with_swap_foreign_asset_xcm_trader() {
let bob: AccountId = SOME_ASSET_ADMIN.into();
let staking_pot = CollatorSelection::account_id();
let native_location = WestendLocationV3::get();
let foreign_location =
xcm::v3::Location { parents: 1, interior: (xcm::v3::Junction::Parachain(1234), xcm::v3::Junction::GeneralIndex(12345)).into() };
let foreign_location = xcm::v3::Location {
parents: 1,
interior: (
xcm::v3::Junction::Parachain(1234),
xcm::v3::Junction::GeneralIndex(12345),
)
.into(),
};
// bob's initial balance for native and `asset1` assets.
let initial_balance = 200 * UNITS;
// liquidity for both arms of (native, asset1) pool.
Expand Down Expand Up @@ -305,8 +317,10 @@ fn test_buy_and_refund_weight_with_swap_foreign_asset_xcm_trader() {
trader.buy_weight(weight, payment.into(), &ctx).expect("Expected Ok");

// assert.
let unused_amount =
unused_asset.fungible.get(&foreign_location_latest.clone().into()).map_or(0, |a| *a);
let unused_amount = unused_asset
.fungible
.get(&foreign_location_latest.clone().into())
.map_or(0, |a| *a);
assert_eq!(unused_amount, extra_amount);
assert_eq!(
ForeignAssets::total_issuance(foreign_location),
Expand Down
5 changes: 1 addition & 4 deletions cumulus/parachains/runtimes/assets/common/src/matching.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
// limitations under the License.

use cumulus_primitives_core::ParaId;
use frame_support::{
pallet_prelude::Get,
traits::ContainsPair,
};
use frame_support::{pallet_prelude::Get, traits::ContainsPair};
use xcm::prelude::*;

use xcm_builder::ensure_is_remote;
Expand Down
2 changes: 1 addition & 1 deletion cumulus/parachains/runtimes/assets/test-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,5 @@ std = [
"sp-std/std",
"xcm-builder/std",
"xcm-executor/std",
"xcm/std"
"xcm/std",
]
6 changes: 4 additions & 2 deletions cumulus/primitives/utility/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ use sp_runtime::{
use sp_std::{marker::PhantomData, prelude::*};
use xcm::{latest::prelude::*, WrapVersion};
use xcm_builder::TakeRevenue;
use xcm_executor::AssetsInHolding;
use xcm_executor::traits::{MatchesFungibles, TransactAsset, WeightTrader};
use xcm_executor::{
traits::{MatchesFungibles, TransactAsset, WeightTrader},
AssetsInHolding,
};

#[cfg(test)]
mod tests;
Expand Down
16 changes: 7 additions & 9 deletions cumulus/primitives/utility/src/tests/swap_first.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,7 @@ fn empty_holding_asset() {
#[test]
fn fails_to_match_holding_asset() {
let mut trader = Trader::new();
let holding_asset =
Asset { id: AssetId(Location::new(1, [Parachain(1)])), fun: Fungible(10) };
let holding_asset = Asset { id: AssetId(Location::new(1, [Parachain(1)])), fun: Fungible(10) };
assert_eq!(
trader
.buy_weight(Weight::from_all(10), holding_asset.into(), &xcm_context())
Expand Down Expand Up @@ -539,13 +538,12 @@ pub mod mock {
a: &Asset,
) -> core::result::Result<(AssetId, Balance), xcm_executor::traits::Error> {
match a {
Asset {
fun: Fungible(amount),
id: AssetId(inner_location),
} => match inner_location.unpack() {
(0, [Junction::GeneralIndex(id)]) => Ok(((*id).try_into().unwrap(), *amount)),
_ => Err(xcm_executor::traits::Error::AssetNotHandled),
},
Asset { fun: Fungible(amount), id: AssetId(inner_location) } =>
match inner_location.unpack() {
(0, [Junction::GeneralIndex(id)]) =>
Ok(((*id).try_into().unwrap(), *amount)),
_ => Err(xcm_executor::traits::Error::AssetNotHandled),
},
_ => Err(xcm_executor::traits::Error::AssetNotHandled),
}
}
Expand Down
5 changes: 1 addition & 4 deletions polkadot/runtime/parachains/src/coretime/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,7 @@ mod v_coretime {

for message in messages {
send_xcm::<SendXcm>(
Location::new(
0,
Junction::Parachain(T::BrokerId::get()),
),
Location::new(0, Junction::Parachain(T::BrokerId::get())),
message,
)?;
}
Expand Down

0 comments on commit c933a23

Please sign in to comment.