diff --git a/pallets/attestation/src/benchmarking.rs b/pallets/attestation/src/benchmarking.rs index 35ba6309b..971d0d525 100644 --- a/pallets/attestation/src/benchmarking.rs +++ b/pallets/attestation/src/benchmarking.rs @@ -18,8 +18,7 @@ use frame_benchmarking::{account, benchmarks}; use frame_support::traits::{fungible::Mutate, Get}; -use frame_system::pallet_prelude::BlockNumberFor; -use frame_system::RawOrigin; +use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin}; use sp_runtime::traits::Hash; use ctype::CtypeEntryOf; diff --git a/pallets/pallet-asset-switch/src/lib.rs b/pallets/pallet-asset-switch/src/lib.rs index 85ee4c791..ce8615b39 100644 --- a/pallets/pallet-asset-switch/src/lib.rs +++ b/pallets/pallet-asset-switch/src/lib.rs @@ -481,11 +481,11 @@ pub mod pallet { weight_limit: WeightLimit::Unlimited, fees: remote_asset_fee_v4.clone(), }, + SetAppendix(appendix), TransferAsset { assets: (asset_id_v4, remote_asset_amount_as_u128).into(), beneficiary: beneficiary_v4, }, - SetAppendix(appendix), ] .into(); let xcm_ticket = diff --git a/runtimes/spiritnet/src/lib.rs b/runtimes/spiritnet/src/lib.rs index 905511074..429e43557 100644 --- a/runtimes/spiritnet/src/lib.rs +++ b/runtimes/spiritnet/src/lib.rs @@ -109,7 +109,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("kilt-spiritnet"), impl_name: create_runtime_str!("kilt-spiritnet"), authoring_version: 1, - spec_version: 11401, + spec_version: 11402, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 9, diff --git a/runtimes/spiritnet/src/xcm_config.rs b/runtimes/spiritnet/src/xcm_config.rs index b5de4ce14..20da61355 100644 --- a/runtimes/spiritnet/src/xcm_config.rs +++ b/runtimes/spiritnet/src/xcm_config.rs @@ -17,8 +17,9 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org use crate::{ - AccountId, AllPalletsWithSystem, Balances, MessageQueue, ParachainInfo, ParachainSystem, PolkadotXcm, Runtime, - RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmpQueue, + AccountId, AllPalletsWithSystem, Balances, CheckingAccount, Fungibles, KiltToEKiltSwitchPallet, MessageQueue, + ParachainInfo, ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, Treasury, + WeightToFee, XcmpQueue, }; use cumulus_primitives_core::{AggregateMessageOrigin, ParaId}; @@ -27,6 +28,10 @@ use frame_support::{ traits::{Contains, EnqueueWithOrigin, Everything, Nothing, TransformOrigin}, }; use frame_system::EnsureRoot; +use pallet_asset_switch::xcm::{ + IsSwitchPairRemoteAsset, IsSwitchPairXcmFeeAsset, MatchesSwitchPairXcmFeeFungibleAsset, + SwitchPairRemoteAssetTransactor, UsingComponentsForSwitchPairRemoteAsset, UsingComponentsForXcmFeeAsset, +}; use pallet_xcm::XcmPassthrough; use parachains_common::message_queue::{NarrowOriginToSibling, ParaIdToSibling}; use polkadot_runtime_common::xcm_sender::NoPriceForMessageDelivery; @@ -35,9 +40,9 @@ use sp_std::prelude::ToOwned; use xcm::v4::prelude::*; use xcm_builder::{ AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, - EnsureXcmOrigin, FixedWeightBounds, FrameTransactionalProcessor, NativeAsset, RelayChainAsNative, - SiblingParachainAsNative, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, - TakeWeightCredit, TrailingSetTopicAsId, UsingComponents, WithComputedOrigin, + EnsureXcmOrigin, FixedWeightBounds, FrameTransactionalProcessor, FungiblesAdapter, NativeAsset, NoChecking, + RelayChainAsNative, SiblingParachainAsNative, SignedAccountId32AsNative, SignedToAccountId32, + SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents, WithComputedOrigin, }; use xcm_executor::{traits::WithOriginFilter, XcmExecutor}; @@ -163,15 +168,40 @@ impl Contains for SafeCallFilter { } } +parameter_types! { + pub TreasuryAccountId: AccountId = Treasury::account_id(); +} + pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { type RuntimeCall = RuntimeCall; // How we send Xcm messages. type XcmSender = XcmRouter; // How to withdraw and deposit an asset. - type AssetTransactor = LocalAssetTransactor; + // Until fixed, `LocalAssetTransactor` must be last since it returns an error if + // the operation does not go through, i.e., it cannot be chained with other + // transactors. + type AssetTransactor = ( + // Allow the asset from the other side of the pool to be "deposited" into the current system. + SwitchPairRemoteAssetTransactor, + // Allow the asset to pay for remote XCM fees to be deposited into the current system. + FungiblesAdapter< + Fungibles, + MatchesSwitchPairXcmFeeFungibleAsset, + LocationToAccountIdConverter, + AccountId, + NoChecking, + CheckingAccount, + >, + // Transactor for fungibles matching the "Here" location. + LocalAssetTransactor, + ); type OriginConverter = XcmOriginToTransactDispatchOrigin; - type IsReserve = NativeAsset; + type IsReserve = ( + NativeAsset, + IsSwitchPairRemoteAsset, + IsSwitchPairXcmFeeAsset, + ); // Teleporting is disabled. type IsTeleporter = (); type UniversalLocation = UniversalLocation; @@ -183,8 +213,20 @@ impl xcm_executor::Config for XcmConfig { // How weight is transformed into fees. The fees are not taken out of the // Balances pallet here. Balances is only used if fees are dropped without being // used. In that case they are put into the treasury. - type Trader = - UsingComponents, HereLocation, AccountId, Balances, SendDustAndFeesToTreasury>; + + type Trader = ( + // Can pay for fees with the remote XCM asset fee (when sending it into this system). + UsingComponentsForXcmFeeAsset>, + // Can pay for the remote asset of the switch pair (when "depositing" it into this system). + UsingComponentsForSwitchPairRemoteAsset< + Runtime, + KiltToEKiltSwitchPallet, + WeightToFee, + TreasuryAccountId, + >, + // Can pay with the fungible that matches the "Here" location. + UsingComponents, HereLocation, AccountId, Balances, SendDustAndFeesToTreasury>, + ); type ResponseHandler = PolkadotXcm; // What happens with assets that are left in the register after the XCM message // was processed. PolkadotXcm has an AssetTrap that stores a hash of the asset