mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 01:41:03 +00:00
Add FungibleAdapter (#2684)
In the move from the old `Currency` traits to the new `fungible/s` family of traits, we already had the `FungiblesAdapter` and `NonFungiblesAdapter` for multiple fungible and non fungible assets respectively. However, for handling only one fungible asset, we were missing a `FungibleAdapter`, and so used the old `CurrencyAdapter` instead. This PR aims to fill in that gap, and provide the new adapter for more updated examples. I marked the old `CurrencyAdapter` as deprecated as part of this PR, and I'll change it to the new `FungibleAdapter` in a following PR. The two stages are separated so as to not bloat this PR with some name fixes in tests. --------- Co-authored-by: command-bot <>
This commit is contained in:
committed by
GitHub
parent
3e4e8c0bd1
commit
10a91f821e
@@ -30,7 +30,9 @@ use sp_runtime::{
|
||||
BuildStorage,
|
||||
};
|
||||
use xcm::prelude::*;
|
||||
use xcm_builder::{CurrencyAdapter, FixedWeightBounds, IsConcrete, NativeAsset, ParentIsPreset};
|
||||
#[allow(deprecated)]
|
||||
use xcm_builder::CurrencyAdapter;
|
||||
use xcm_builder::{FixedWeightBounds, IsConcrete, NativeAsset, ParentIsPreset};
|
||||
use xcm_executor::traits::ConvertOrigin;
|
||||
|
||||
type Block = frame_system::mocking::MockBlock<Test>;
|
||||
@@ -130,6 +132,7 @@ parameter_types! {
|
||||
}
|
||||
|
||||
/// Means for transacting assets on this chain.
|
||||
#[allow(deprecated)]
|
||||
pub type LocalAssetTransactor = CurrencyAdapter<
|
||||
// Use this currency:
|
||||
Balances,
|
||||
|
||||
@@ -12,13 +12,15 @@ use pallet_xcm::XcmPassthrough;
|
||||
use polkadot_parachain_primitives::primitives::Sibling;
|
||||
use polkadot_runtime_common::impls::ToAuthor;
|
||||
use xcm::latest::prelude::*;
|
||||
#[allow(deprecated)]
|
||||
use xcm_builder::CurrencyAdapter;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowTopLevelPaidExecutionFrom,
|
||||
CurrencyAdapter, DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin,
|
||||
FixedWeightBounds, IsConcrete, NativeAsset, ParentIsPreset, RelayChainAsNative,
|
||||
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
|
||||
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId,
|
||||
UsingComponents, WithComputedOrigin, WithUniqueTopic,
|
||||
DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, FixedWeightBounds, IsConcrete,
|
||||
NativeAsset, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
|
||||
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
|
||||
SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents,
|
||||
WithComputedOrigin, WithUniqueTopic,
|
||||
};
|
||||
use xcm_executor::XcmExecutor;
|
||||
|
||||
@@ -42,6 +44,7 @@ pub type LocationToAccountId = (
|
||||
);
|
||||
|
||||
/// Means for transacting assets on this chain.
|
||||
#[allow(deprecated)]
|
||||
pub type LocalAssetTransactor = CurrencyAdapter<
|
||||
// Use this currency:
|
||||
Balances,
|
||||
|
||||
@@ -41,17 +41,18 @@ use polkadot_parachain_primitives::primitives::Sibling;
|
||||
use polkadot_runtime_common::xcm_sender::ExponentialPrice;
|
||||
use sp_runtime::traits::{AccountIdConversion, ConvertInto};
|
||||
use xcm::latest::prelude::*;
|
||||
#[allow(deprecated)]
|
||||
use xcm_builder::CurrencyAdapter;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
|
||||
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter,
|
||||
DenyReserveTransferToRelayChain, DenyThenTry, DescribeAllTerminal, DescribeFamily,
|
||||
EnsureXcmOrigin, FungiblesAdapter, GlobalConsensusParachainConvertsFor, HashedDescription,
|
||||
IsConcrete, LocalMint, NetworkExportTableItem, NoChecking, ParentAsSuperuser, ParentIsPreset,
|
||||
RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
|
||||
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, StartsWith,
|
||||
StartsWithExplicitGlobalConsensus, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents,
|
||||
WeightInfoBounds, WithComputedOrigin, WithUniqueTopic, XcmFeeManagerFromComponents,
|
||||
XcmFeeToAccount,
|
||||
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, DenyReserveTransferToRelayChain,
|
||||
DenyThenTry, DescribeAllTerminal, DescribeFamily, EnsureXcmOrigin, FungiblesAdapter,
|
||||
GlobalConsensusParachainConvertsFor, HashedDescription, IsConcrete, LocalMint,
|
||||
NetworkExportTableItem, NoChecking, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
|
||||
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
|
||||
SignedToAccountId32, SovereignSignedViaLocation, StartsWith, StartsWithExplicitGlobalConsensus,
|
||||
TakeWeightCredit, TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin,
|
||||
WithUniqueTopic, XcmFeeManagerFromComponents, XcmFeeToAccount,
|
||||
};
|
||||
use xcm_executor::{traits::WithOriginFilter, XcmExecutor};
|
||||
|
||||
@@ -95,6 +96,7 @@ pub type LocationToAccountId = (
|
||||
);
|
||||
|
||||
/// Means for transacting the native currency on this chain.
|
||||
#[allow(deprecated)]
|
||||
pub type CurrencyTransactor = CurrencyAdapter<
|
||||
// Use this currency:
|
||||
Balances,
|
||||
|
||||
@@ -41,17 +41,18 @@ use polkadot_parachain_primitives::primitives::Sibling;
|
||||
use polkadot_runtime_common::xcm_sender::ExponentialPrice;
|
||||
use sp_runtime::traits::{AccountIdConversion, ConvertInto};
|
||||
use xcm::latest::prelude::*;
|
||||
#[allow(deprecated)]
|
||||
use xcm_builder::CurrencyAdapter;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
|
||||
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter,
|
||||
DenyReserveTransferToRelayChain, DenyThenTry, DescribeFamily, DescribePalletTerminal,
|
||||
EnsureXcmOrigin, FungiblesAdapter, GlobalConsensusParachainConvertsFor, HashedDescription,
|
||||
IsConcrete, LocalMint, NetworkExportTableItem, NoChecking, ParentAsSuperuser, ParentIsPreset,
|
||||
RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
|
||||
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, StartsWith,
|
||||
StartsWithExplicitGlobalConsensus, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents,
|
||||
WeightInfoBounds, WithComputedOrigin, WithUniqueTopic, XcmFeeManagerFromComponents,
|
||||
XcmFeeToAccount,
|
||||
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, DenyReserveTransferToRelayChain,
|
||||
DenyThenTry, DescribeFamily, DescribePalletTerminal, EnsureXcmOrigin, FungiblesAdapter,
|
||||
GlobalConsensusParachainConvertsFor, HashedDescription, IsConcrete, LocalMint,
|
||||
NetworkExportTableItem, NoChecking, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
|
||||
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
|
||||
SignedToAccountId32, SovereignSignedViaLocation, StartsWith, StartsWithExplicitGlobalConsensus,
|
||||
TakeWeightCredit, TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin,
|
||||
WithUniqueTopic, XcmFeeManagerFromComponents, XcmFeeToAccount,
|
||||
};
|
||||
use xcm_executor::{traits::WithOriginFilter, XcmExecutor};
|
||||
|
||||
@@ -95,6 +96,7 @@ pub type LocationToAccountId = (
|
||||
);
|
||||
|
||||
/// Means for transacting the native currency on this chain.
|
||||
#[allow(deprecated)]
|
||||
pub type CurrencyTransactor = CurrencyAdapter<
|
||||
// Use this currency:
|
||||
Balances,
|
||||
|
||||
@@ -45,11 +45,13 @@ use sp_core::Get;
|
||||
use sp_runtime::traits::AccountIdConversion;
|
||||
use sp_std::marker::PhantomData;
|
||||
use xcm::latest::prelude::*;
|
||||
#[allow(deprecated)]
|
||||
use xcm_builder::CurrencyAdapter;
|
||||
use xcm_builder::{
|
||||
deposit_or_burn_fee, AccountId32Aliases, AllowExplicitUnpaidExecutionFrom,
|
||||
AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom,
|
||||
CurrencyAdapter, DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, HandleFee,
|
||||
IsConcrete, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
|
||||
DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, HandleFee, IsConcrete,
|
||||
ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
|
||||
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
|
||||
SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents,
|
||||
WeightInfoBounds, WithComputedOrigin, WithUniqueTopic, XcmFeeManagerFromComponents,
|
||||
@@ -85,6 +87,7 @@ pub type LocationToAccountId = (
|
||||
);
|
||||
|
||||
/// Means for transacting the native currency on this chain.
|
||||
#[allow(deprecated)]
|
||||
pub type CurrencyTransactor = CurrencyAdapter<
|
||||
// Use this currency:
|
||||
Balances,
|
||||
|
||||
@@ -38,11 +38,13 @@ use polkadot_parachain_primitives::primitives::Sibling;
|
||||
use polkadot_runtime_common::xcm_sender::ExponentialPrice;
|
||||
use sp_runtime::traits::AccountIdConversion;
|
||||
use xcm::latest::prelude::*;
|
||||
#[allow(deprecated)]
|
||||
use xcm_builder::CurrencyAdapter;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
|
||||
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter,
|
||||
DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, IsConcrete, ParentAsSuperuser,
|
||||
ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
|
||||
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, DenyReserveTransferToRelayChain,
|
||||
DenyThenTry, EnsureXcmOrigin, IsConcrete, ParentAsSuperuser, ParentIsPreset,
|
||||
RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
|
||||
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
|
||||
TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
|
||||
XcmFeeManagerFromComponents, XcmFeeToAccount,
|
||||
@@ -74,6 +76,7 @@ pub type LocationToAccountId = (
|
||||
);
|
||||
|
||||
/// Means for transacting the native currency on this chain.
|
||||
#[allow(deprecated)]
|
||||
pub type CurrencyTransactor = CurrencyAdapter<
|
||||
// Use this currency:
|
||||
Balances,
|
||||
|
||||
@@ -36,15 +36,17 @@ use polkadot_parachain_primitives::primitives::Sibling;
|
||||
use polkadot_runtime_common::xcm_sender::ExponentialPrice;
|
||||
use westend_runtime_constants::xcm as xcm_constants;
|
||||
use xcm::latest::prelude::*;
|
||||
#[allow(deprecated)]
|
||||
use xcm_builder::CurrencyAdapter;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
|
||||
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter,
|
||||
DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, FixedWeightBounds, IsConcrete,
|
||||
LocatableAssetId, OriginToPluralityVoice, ParentAsSuperuser, ParentIsPreset,
|
||||
RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
|
||||
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
|
||||
TrailingSetTopicAsId, UsingComponents, WithComputedOrigin, WithUniqueTopic,
|
||||
XcmFeeManagerFromComponents, XcmFeeToAccount,
|
||||
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, DenyReserveTransferToRelayChain,
|
||||
DenyThenTry, EnsureXcmOrigin, FixedWeightBounds, IsConcrete, LocatableAssetId,
|
||||
OriginToPluralityVoice, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
|
||||
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
|
||||
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId,
|
||||
UsingComponents, WithComputedOrigin, WithUniqueTopic, XcmFeeManagerFromComponents,
|
||||
XcmFeeToAccount,
|
||||
};
|
||||
use xcm_executor::{traits::WithOriginFilter, XcmExecutor};
|
||||
|
||||
@@ -84,6 +86,7 @@ pub type LocationToAccountId = (
|
||||
);
|
||||
|
||||
/// Means for transacting the native currency on this chain.
|
||||
#[allow(deprecated)]
|
||||
pub type CurrencyTransactor = CurrencyAdapter<
|
||||
// Use this currency:
|
||||
Balances,
|
||||
|
||||
@@ -37,14 +37,16 @@ use polkadot_parachain_primitives::primitives::Sibling;
|
||||
use polkadot_runtime_common::xcm_sender::ExponentialPrice;
|
||||
use sp_runtime::traits::AccountIdConversion;
|
||||
use xcm::latest::prelude::*;
|
||||
#[allow(deprecated)]
|
||||
use xcm_builder::CurrencyAdapter;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
|
||||
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter,
|
||||
DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, FixedWeightBounds, IsConcrete,
|
||||
NativeAsset, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
|
||||
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
|
||||
SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents,
|
||||
WithComputedOrigin, WithUniqueTopic, XcmFeeManagerFromComponents, XcmFeeToAccount,
|
||||
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, DenyReserveTransferToRelayChain,
|
||||
DenyThenTry, EnsureXcmOrigin, FixedWeightBounds, IsConcrete, NativeAsset, ParentAsSuperuser,
|
||||
ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
|
||||
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
|
||||
TrailingSetTopicAsId, UsingComponents, WithComputedOrigin, WithUniqueTopic,
|
||||
XcmFeeManagerFromComponents, XcmFeeToAccount,
|
||||
};
|
||||
use xcm_executor::XcmExecutor;
|
||||
|
||||
@@ -77,6 +79,7 @@ pub type LocationToAccountId = (
|
||||
);
|
||||
|
||||
/// Means for transacting the native currency on this chain.
|
||||
#[allow(deprecated)]
|
||||
pub type CurrencyTransactor = CurrencyAdapter<
|
||||
// Use this currency:
|
||||
Balances,
|
||||
|
||||
@@ -44,15 +44,16 @@ use polkadot_parachain_primitives::primitives::Sibling;
|
||||
use polkadot_runtime_common::impls::ToAuthor;
|
||||
use sp_runtime::traits::Zero;
|
||||
use xcm::latest::prelude::*;
|
||||
#[allow(deprecated)]
|
||||
use xcm_builder::CurrencyAdapter;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
|
||||
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, AsPrefixedGeneralIndex,
|
||||
ConvertedConcreteId, CurrencyAdapter, DenyReserveTransferToRelayChain, DenyThenTry,
|
||||
EnsureXcmOrigin, FixedWeightBounds, FungiblesAdapter, IsConcrete, LocalMint, NativeAsset,
|
||||
ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
|
||||
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
|
||||
SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents,
|
||||
WithComputedOrigin, WithUniqueTopic,
|
||||
ConvertedConcreteId, DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin,
|
||||
FixedWeightBounds, FungiblesAdapter, IsConcrete, LocalMint, NativeAsset, ParentAsSuperuser,
|
||||
ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
|
||||
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
|
||||
TrailingSetTopicAsId, UsingComponents, WithComputedOrigin, WithUniqueTopic,
|
||||
};
|
||||
use xcm_executor::{traits::JustTry, XcmExecutor};
|
||||
|
||||
@@ -76,6 +77,7 @@ pub type LocationToAccountId = (
|
||||
);
|
||||
|
||||
/// Means for transacting assets on this chain.
|
||||
#[allow(deprecated)]
|
||||
pub type CurrencyTransactor = CurrencyAdapter<
|
||||
// Use this currency:
|
||||
Balances,
|
||||
|
||||
@@ -83,12 +83,14 @@ use xcm_executor::traits::JustTry;
|
||||
use pallet_xcm::{EnsureXcm, IsMajorityOfBody, XcmPassthrough};
|
||||
use polkadot_parachain_primitives::primitives::Sibling;
|
||||
use xcm::latest::prelude::*;
|
||||
#[allow(deprecated)]
|
||||
use xcm_builder::CurrencyAdapter;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowTopLevelPaidExecutionFrom,
|
||||
CurrencyAdapter, EnsureXcmOrigin, FixedWeightBounds, IsConcrete, NativeAsset,
|
||||
ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
|
||||
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
|
||||
SovereignSignedViaLocation, TakeWeightCredit, UsingComponents,
|
||||
EnsureXcmOrigin, FixedWeightBounds, IsConcrete, NativeAsset, ParentAsSuperuser, ParentIsPreset,
|
||||
RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
|
||||
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
|
||||
UsingComponents,
|
||||
};
|
||||
use xcm_executor::XcmExecutor;
|
||||
|
||||
@@ -345,6 +347,7 @@ pub type LocationToAccountId = (
|
||||
);
|
||||
|
||||
/// Means for transacting assets on this chain.
|
||||
#[allow(deprecated)]
|
||||
pub type CurrencyTransactor = CurrencyAdapter<
|
||||
// Use this currency:
|
||||
Balances,
|
||||
|
||||
@@ -36,15 +36,16 @@ use runtime_common::{
|
||||
};
|
||||
use sp_core::ConstU32;
|
||||
use xcm::latest::prelude::*;
|
||||
#[allow(deprecated)]
|
||||
use xcm_builder::CurrencyAdapter as XcmCurrencyAdapter;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
|
||||
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, ChildParachainAsNative,
|
||||
ChildParachainConvertsVia, CurrencyAdapter as XcmCurrencyAdapter, DescribeBodyTerminal,
|
||||
DescribeFamily, FixedWeightBounds, HashedDescription, IsChildSystemParachain, IsConcrete,
|
||||
MintLocation, OriginToPluralityVoice, SignedAccountId32AsNative, SignedToAccountId32,
|
||||
SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents,
|
||||
WeightInfoBounds, WithComputedOrigin, WithUniqueTopic, XcmFeeManagerFromComponents,
|
||||
XcmFeeToAccount,
|
||||
ChildParachainConvertsVia, DescribeBodyTerminal, DescribeFamily, FixedWeightBounds,
|
||||
HashedDescription, IsChildSystemParachain, IsConcrete, MintLocation, OriginToPluralityVoice,
|
||||
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
|
||||
TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
|
||||
XcmFeeManagerFromComponents, XcmFeeToAccount,
|
||||
};
|
||||
use xcm_executor::XcmExecutor;
|
||||
|
||||
@@ -70,6 +71,7 @@ pub type LocationConverter = (
|
||||
/// point of view of XCM-only concepts like `MultiLocation` and `MultiAsset`.
|
||||
///
|
||||
/// Ours is only aware of the Balances pallet, which is mapped to `RocLocation`.
|
||||
#[allow(deprecated)]
|
||||
pub type LocalAssetTransactor = XcmCurrencyAdapter<
|
||||
// Use this currency:
|
||||
Balances,
|
||||
|
||||
@@ -39,14 +39,16 @@ use westend_runtime_constants::{
|
||||
xcm::body::{FELLOWSHIP_ADMIN_INDEX, TREASURER_INDEX},
|
||||
};
|
||||
use xcm::latest::prelude::*;
|
||||
#[allow(deprecated)]
|
||||
use xcm_builder::CurrencyAdapter as XcmCurrencyAdapter;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
|
||||
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, ChildParachainAsNative,
|
||||
ChildParachainConvertsVia, CurrencyAdapter as XcmCurrencyAdapter, DescribeBodyTerminal,
|
||||
DescribeFamily, HashedDescription, IsConcrete, MintLocation, OriginToPluralityVoice,
|
||||
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
|
||||
TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
|
||||
XcmFeeManagerFromComponents, XcmFeeToAccount,
|
||||
ChildParachainConvertsVia, DescribeBodyTerminal, DescribeFamily, HashedDescription, IsConcrete,
|
||||
MintLocation, OriginToPluralityVoice, SignedAccountId32AsNative, SignedToAccountId32,
|
||||
SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents,
|
||||
WeightInfoBounds, WithComputedOrigin, WithUniqueTopic, XcmFeeManagerFromComponents,
|
||||
XcmFeeToAccount,
|
||||
};
|
||||
use xcm_executor::XcmExecutor;
|
||||
|
||||
@@ -72,6 +74,7 @@ pub type LocationConverter = (
|
||||
HashedDescription<AccountId, DescribeFamily<DescribeBodyTerminal>>,
|
||||
);
|
||||
|
||||
#[allow(deprecated)]
|
||||
pub type LocalAssetTransactor = XcmCurrencyAdapter<
|
||||
// Use this currency:
|
||||
Balances,
|
||||
|
||||
@@ -103,6 +103,7 @@ impl xcm_executor::traits::MatchesFungible<u64> for MatchAnyFungible {
|
||||
}
|
||||
|
||||
// Use balances as the asset transactor.
|
||||
#[allow(deprecated)]
|
||||
pub type AssetTransactor = xcm_builder::CurrencyAdapter<
|
||||
Balances,
|
||||
MatchAnyFungible,
|
||||
|
||||
@@ -32,13 +32,15 @@ pub use sp_std::{
|
||||
cell::RefCell, collections::btree_map::BTreeMap, fmt::Debug, marker::PhantomData,
|
||||
};
|
||||
use xcm::prelude::*;
|
||||
#[allow(deprecated)]
|
||||
use xcm_builder::CurrencyAdapter as XcmCurrencyAdapter;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom,
|
||||
AllowTopLevelPaidExecutionFrom, Case, ChildParachainAsNative, ChildParachainConvertsVia,
|
||||
ChildSystemParachainAsSuperuser, CurrencyAdapter as XcmCurrencyAdapter, DescribeAllTerminal,
|
||||
FixedRateOfFungible, FixedWeightBounds, FungiblesAdapter, HashedDescription, IsConcrete,
|
||||
MatchedConvertedConcreteId, NoChecking, SignedAccountId32AsNative, SignedToAccountId32,
|
||||
SovereignSignedViaLocation, TakeWeightCredit, XcmFeeManagerFromComponents, XcmFeeToAccount,
|
||||
ChildSystemParachainAsSuperuser, DescribeAllTerminal, FixedRateOfFungible, FixedWeightBounds,
|
||||
FungiblesAdapter, HashedDescription, IsConcrete, MatchedConvertedConcreteId, NoChecking,
|
||||
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
|
||||
XcmFeeManagerFromComponents, XcmFeeToAccount,
|
||||
};
|
||||
use xcm_executor::{
|
||||
traits::{Identity, JustTry},
|
||||
@@ -428,6 +430,7 @@ pub type ForeignAssetsConvertedConcreteId = MatchedConvertedConcreteId<
|
||||
JustTry,
|
||||
>;
|
||||
|
||||
#[allow(deprecated)]
|
||||
pub type AssetTransactors = (
|
||||
XcmCurrencyAdapter<Balances, IsConcrete<RelayLocation>, SovereignAccountOf, AccountId, ()>,
|
||||
FungiblesAdapter<
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
//! Adapters to work with `frame_support::traits::Currency` through XCM.
|
||||
|
||||
#![allow(deprecated)]
|
||||
|
||||
use super::MintLocation;
|
||||
use frame_support::traits::{ExistenceRequirement::AllowDeath, Get, WithdrawReasons};
|
||||
use sp_runtime::traits::CheckedSub;
|
||||
@@ -85,6 +87,7 @@ impl From<Error> for XcmError {
|
||||
/// CheckingAccount,
|
||||
/// >;
|
||||
/// ```
|
||||
#[deprecated = "Use `FungibleAdapter` instead"]
|
||||
pub struct CurrencyAdapter<Currency, Matcher, AccountIdConverter, AccountId, CheckedAccount>(
|
||||
PhantomData<(Currency, Matcher, AccountIdConverter, AccountId, CheckedAccount)>,
|
||||
);
|
||||
|
||||
@@ -0,0 +1,317 @@
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// This file is part of Polkadot.
|
||||
|
||||
// Polkadot is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Polkadot is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Adapters to work with [`frame_support::traits::fungible`] through XCM.
|
||||
|
||||
use super::MintLocation;
|
||||
use frame_support::traits::{
|
||||
tokens::{
|
||||
fungible, Fortitude::Polite, Precision::Exact, Preservation::Preserve, Provenance::Minted,
|
||||
},
|
||||
Get,
|
||||
};
|
||||
use sp_std::{marker::PhantomData, prelude::*, result};
|
||||
use xcm::latest::prelude::*;
|
||||
use xcm_executor::traits::{ConvertLocation, Error as MatchError, MatchesFungible, TransactAsset};
|
||||
|
||||
/// [`TransactAsset`] implementation that allows the use of a [`fungible`] implementation for
|
||||
/// handling an asset in the XCM executor.
|
||||
/// Only works for transfers.
|
||||
pub struct FungibleTransferAdapter<Fungible, Matcher, AccountIdConverter, AccountId>(
|
||||
PhantomData<(Fungible, Matcher, AccountIdConverter, AccountId)>,
|
||||
);
|
||||
impl<
|
||||
Fungible: fungible::Mutate<AccountId>,
|
||||
Matcher: MatchesFungible<Fungible::Balance>,
|
||||
AccountIdConverter: ConvertLocation<AccountId>,
|
||||
AccountId: Eq + Clone,
|
||||
> TransactAsset for FungibleTransferAdapter<Fungible, Matcher, AccountIdConverter, AccountId>
|
||||
{
|
||||
fn internal_transfer_asset(
|
||||
what: &MultiAsset,
|
||||
from: &MultiLocation,
|
||||
to: &MultiLocation,
|
||||
_context: &XcmContext,
|
||||
) -> result::Result<xcm_executor::Assets, XcmError> {
|
||||
log::trace!(
|
||||
target: "xcm::fungible_adapter",
|
||||
"internal_transfer_asset what: {:?}, from: {:?}, to: {:?}",
|
||||
what, from, to
|
||||
);
|
||||
// Check we handle the asset
|
||||
let amount = Matcher::matches_fungible(what).ok_or(MatchError::AssetNotHandled)?;
|
||||
let source = AccountIdConverter::convert_location(from)
|
||||
.ok_or(MatchError::AccountIdConversionFailed)?;
|
||||
let dest = AccountIdConverter::convert_location(to)
|
||||
.ok_or(MatchError::AccountIdConversionFailed)?;
|
||||
Fungible::transfer(&source, &dest, amount, Preserve)
|
||||
.map_err(|error| XcmError::FailedToTransactAsset(error.into()))?;
|
||||
Ok(what.clone().into())
|
||||
}
|
||||
}
|
||||
|
||||
/// [`TransactAsset`] implementation that allows the use of a [`fungible`] implementation for
|
||||
/// handling an asset in the XCM executor.
|
||||
/// Works for everything but transfers.
|
||||
pub struct FungibleMutateAdapter<Fungible, Matcher, AccountIdConverter, AccountId, CheckingAccount>(
|
||||
PhantomData<(Fungible, Matcher, AccountIdConverter, AccountId, CheckingAccount)>,
|
||||
);
|
||||
|
||||
impl<
|
||||
Fungible: fungible::Mutate<AccountId>,
|
||||
Matcher: MatchesFungible<Fungible::Balance>,
|
||||
AccountIdConverter: ConvertLocation<AccountId>,
|
||||
AccountId: Eq + Clone,
|
||||
CheckingAccount: Get<Option<(AccountId, MintLocation)>>,
|
||||
> FungibleMutateAdapter<Fungible, Matcher, AccountIdConverter, AccountId, CheckingAccount>
|
||||
{
|
||||
fn can_accrue_checked(checking_account: AccountId, amount: Fungible::Balance) -> XcmResult {
|
||||
Fungible::can_deposit(&checking_account, amount, Minted)
|
||||
.into_result()
|
||||
.map_err(|_| XcmError::NotDepositable)
|
||||
}
|
||||
|
||||
fn can_reduce_checked(checking_account: AccountId, amount: Fungible::Balance) -> XcmResult {
|
||||
Fungible::can_withdraw(&checking_account, amount)
|
||||
.into_result(false)
|
||||
.map_err(|_| XcmError::NotWithdrawable)
|
||||
.map(|_| ())
|
||||
}
|
||||
|
||||
fn accrue_checked(checking_account: AccountId, amount: Fungible::Balance) {
|
||||
let ok = Fungible::mint_into(&checking_account, amount).is_ok();
|
||||
debug_assert!(ok, "`can_accrue_checked` must have returned `true` immediately prior; qed");
|
||||
}
|
||||
|
||||
fn reduce_checked(checking_account: AccountId, amount: Fungible::Balance) {
|
||||
let ok = Fungible::burn_from(&checking_account, amount, Exact, Polite).is_ok();
|
||||
debug_assert!(ok, "`can_reduce_checked` must have returned `true` immediately prior; qed");
|
||||
}
|
||||
}
|
||||
|
||||
impl<
|
||||
Fungible: fungible::Mutate<AccountId>,
|
||||
Matcher: MatchesFungible<Fungible::Balance>,
|
||||
AccountIdConverter: ConvertLocation<AccountId>,
|
||||
AccountId: Eq + Clone,
|
||||
CheckingAccount: Get<Option<(AccountId, MintLocation)>>,
|
||||
> TransactAsset
|
||||
for FungibleMutateAdapter<Fungible, Matcher, AccountIdConverter, AccountId, CheckingAccount>
|
||||
{
|
||||
fn can_check_in(
|
||||
_origin: &MultiLocation,
|
||||
what: &MultiAsset,
|
||||
_context: &XcmContext,
|
||||
) -> XcmResult {
|
||||
log::trace!(
|
||||
target: "xcm::fungible_adapter",
|
||||
"can_check_in origin: {:?}, what: {:?}",
|
||||
_origin, what
|
||||
);
|
||||
// Check we handle this asset
|
||||
let amount = Matcher::matches_fungible(what).ok_or(MatchError::AssetNotHandled)?;
|
||||
match CheckingAccount::get() {
|
||||
Some((checking_account, MintLocation::Local)) =>
|
||||
Self::can_reduce_checked(checking_account, amount),
|
||||
Some((checking_account, MintLocation::NonLocal)) =>
|
||||
Self::can_accrue_checked(checking_account, amount),
|
||||
None => Ok(()),
|
||||
}
|
||||
}
|
||||
|
||||
fn check_in(_origin: &MultiLocation, what: &MultiAsset, _context: &XcmContext) {
|
||||
log::trace!(
|
||||
target: "xcm::fungible_adapter",
|
||||
"check_in origin: {:?}, what: {:?}",
|
||||
_origin, what
|
||||
);
|
||||
if let Some(amount) = Matcher::matches_fungible(what) {
|
||||
match CheckingAccount::get() {
|
||||
Some((checking_account, MintLocation::Local)) =>
|
||||
Self::reduce_checked(checking_account, amount),
|
||||
Some((checking_account, MintLocation::NonLocal)) =>
|
||||
Self::accrue_checked(checking_account, amount),
|
||||
None => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn can_check_out(_dest: &MultiLocation, what: &MultiAsset, _context: &XcmContext) -> XcmResult {
|
||||
log::trace!(
|
||||
target: "xcm::fungible_adapter",
|
||||
"check_out dest: {:?}, what: {:?}",
|
||||
_dest,
|
||||
what
|
||||
);
|
||||
let amount = Matcher::matches_fungible(what).ok_or(MatchError::AssetNotHandled)?;
|
||||
match CheckingAccount::get() {
|
||||
Some((checking_account, MintLocation::Local)) =>
|
||||
Self::can_accrue_checked(checking_account, amount),
|
||||
Some((checking_account, MintLocation::NonLocal)) =>
|
||||
Self::can_reduce_checked(checking_account, amount),
|
||||
None => Ok(()),
|
||||
}
|
||||
}
|
||||
|
||||
fn check_out(_dest: &MultiLocation, what: &MultiAsset, _context: &XcmContext) {
|
||||
log::trace!(
|
||||
target: "xcm::fungible_adapter",
|
||||
"check_out dest: {:?}, what: {:?}",
|
||||
_dest,
|
||||
what
|
||||
);
|
||||
if let Some(amount) = Matcher::matches_fungible(what) {
|
||||
match CheckingAccount::get() {
|
||||
Some((checking_account, MintLocation::Local)) =>
|
||||
Self::accrue_checked(checking_account, amount),
|
||||
Some((checking_account, MintLocation::NonLocal)) =>
|
||||
Self::reduce_checked(checking_account, amount),
|
||||
None => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn deposit_asset(
|
||||
what: &MultiAsset,
|
||||
who: &MultiLocation,
|
||||
_context: Option<&XcmContext>,
|
||||
) -> XcmResult {
|
||||
log::trace!(
|
||||
target: "xcm::fungible_adapter",
|
||||
"deposit_asset what: {:?}, who: {:?}",
|
||||
what, who,
|
||||
);
|
||||
let amount = Matcher::matches_fungible(what).ok_or(MatchError::AssetNotHandled)?;
|
||||
let who = AccountIdConverter::convert_location(who)
|
||||
.ok_or(MatchError::AccountIdConversionFailed)?;
|
||||
Fungible::mint_into(&who, amount)
|
||||
.map_err(|error| XcmError::FailedToTransactAsset(error.into()))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn withdraw_asset(
|
||||
what: &MultiAsset,
|
||||
who: &MultiLocation,
|
||||
_context: Option<&XcmContext>,
|
||||
) -> result::Result<xcm_executor::Assets, XcmError> {
|
||||
log::trace!(
|
||||
target: "xcm::fungible_adapter",
|
||||
"deposit_asset what: {:?}, who: {:?}",
|
||||
what, who,
|
||||
);
|
||||
let amount = Matcher::matches_fungible(what).ok_or(MatchError::AssetNotHandled)?;
|
||||
let who = AccountIdConverter::convert_location(who)
|
||||
.ok_or(MatchError::AccountIdConversionFailed)?;
|
||||
Fungible::burn_from(&who, amount, Exact, Polite)
|
||||
.map_err(|error| XcmError::FailedToTransactAsset(error.into()))?;
|
||||
Ok(what.clone().into())
|
||||
}
|
||||
}
|
||||
|
||||
/// [`TransactAsset`] implementation that allows the use of a [`fungible`] implementation for
|
||||
/// handling an asset in the XCM executor.
|
||||
/// Works for everything, transfers and teleport bookkeeping.
|
||||
pub struct FungibleAdapter<Fungible, Matcher, AccountIdConverter, AccountId, CheckingAccount>(
|
||||
PhantomData<(Fungible, Matcher, AccountIdConverter, AccountId, CheckingAccount)>,
|
||||
);
|
||||
impl<
|
||||
Fungible: fungible::Mutate<AccountId>,
|
||||
Matcher: MatchesFungible<Fungible::Balance>,
|
||||
AccountIdConverter: ConvertLocation<AccountId>,
|
||||
AccountId: Eq + Clone,
|
||||
CheckingAccount: Get<Option<(AccountId, MintLocation)>>,
|
||||
> TransactAsset
|
||||
for FungibleAdapter<Fungible, Matcher, AccountIdConverter, AccountId, CheckingAccount>
|
||||
{
|
||||
fn can_check_in(origin: &MultiLocation, what: &MultiAsset, context: &XcmContext) -> XcmResult {
|
||||
FungibleMutateAdapter::<
|
||||
Fungible,
|
||||
Matcher,
|
||||
AccountIdConverter,
|
||||
AccountId,
|
||||
CheckingAccount,
|
||||
>::can_check_in(origin, what, context)
|
||||
}
|
||||
|
||||
fn check_in(origin: &MultiLocation, what: &MultiAsset, context: &XcmContext) {
|
||||
FungibleMutateAdapter::<
|
||||
Fungible,
|
||||
Matcher,
|
||||
AccountIdConverter,
|
||||
AccountId,
|
||||
CheckingAccount,
|
||||
>::check_in(origin, what, context)
|
||||
}
|
||||
|
||||
fn can_check_out(dest: &MultiLocation, what: &MultiAsset, context: &XcmContext) -> XcmResult {
|
||||
FungibleMutateAdapter::<
|
||||
Fungible,
|
||||
Matcher,
|
||||
AccountIdConverter,
|
||||
AccountId,
|
||||
CheckingAccount,
|
||||
>::can_check_out(dest, what, context)
|
||||
}
|
||||
|
||||
fn check_out(dest: &MultiLocation, what: &MultiAsset, context: &XcmContext) {
|
||||
FungibleMutateAdapter::<
|
||||
Fungible,
|
||||
Matcher,
|
||||
AccountIdConverter,
|
||||
AccountId,
|
||||
CheckingAccount,
|
||||
>::check_out(dest, what, context)
|
||||
}
|
||||
|
||||
fn deposit_asset(
|
||||
what: &MultiAsset,
|
||||
who: &MultiLocation,
|
||||
context: Option<&XcmContext>,
|
||||
) -> XcmResult {
|
||||
FungibleMutateAdapter::<
|
||||
Fungible,
|
||||
Matcher,
|
||||
AccountIdConverter,
|
||||
AccountId,
|
||||
CheckingAccount,
|
||||
>::deposit_asset(what, who, context)
|
||||
}
|
||||
|
||||
fn withdraw_asset(
|
||||
what: &MultiAsset,
|
||||
who: &MultiLocation,
|
||||
maybe_context: Option<&XcmContext>,
|
||||
) -> result::Result<xcm_executor::Assets, XcmError> {
|
||||
FungibleMutateAdapter::<
|
||||
Fungible,
|
||||
Matcher,
|
||||
AccountIdConverter,
|
||||
AccountId,
|
||||
CheckingAccount,
|
||||
>::withdraw_asset(what, who, maybe_context)
|
||||
}
|
||||
|
||||
fn internal_transfer_asset(
|
||||
what: &MultiAsset,
|
||||
from: &MultiLocation,
|
||||
to: &MultiLocation,
|
||||
context: &XcmContext,
|
||||
) -> result::Result<xcm_executor::Assets, XcmError> {
|
||||
FungibleTransferAdapter::<Fungible, Matcher, AccountIdConverter, AccountId>::internal_transfer_asset(
|
||||
what, from, to, context
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -65,6 +65,7 @@ mod process_xcm_message;
|
||||
pub use process_xcm_message::ProcessXcmMessage;
|
||||
|
||||
mod currency_adapter;
|
||||
#[allow(deprecated)]
|
||||
pub use currency_adapter::CurrencyAdapter;
|
||||
|
||||
mod fee_handling;
|
||||
@@ -72,6 +73,9 @@ pub use fee_handling::{
|
||||
deposit_or_burn_fee, HandleFee, XcmFeeManagerFromComponents, XcmFeeToAccount,
|
||||
};
|
||||
|
||||
mod fungible_adapter;
|
||||
pub use fungible_adapter::{FungibleAdapter, FungibleMutateAdapter, FungibleTransferAdapter};
|
||||
|
||||
mod fungibles_adapter;
|
||||
pub use fungibles_adapter::{
|
||||
AssetChecking, DualMint, FungiblesAdapter, FungiblesMutateAdapter, FungiblesTransferAdapter,
|
||||
|
||||
@@ -32,12 +32,14 @@ use xcm_executor::XcmExecutor;
|
||||
|
||||
use staging_xcm_builder as xcm_builder;
|
||||
|
||||
#[allow(deprecated)]
|
||||
use xcm_builder::CurrencyAdapter as XcmCurrencyAdapter;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom,
|
||||
ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser,
|
||||
CurrencyAdapter as XcmCurrencyAdapter, FixedRateOfFungible, FixedWeightBounds,
|
||||
IsChildSystemParachain, IsConcrete, MintLocation, RespectSuspension, SignedAccountId32AsNative,
|
||||
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
|
||||
FixedRateOfFungible, FixedWeightBounds, IsChildSystemParachain, IsConcrete, MintLocation,
|
||||
RespectSuspension, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation,
|
||||
TakeWeightCredit,
|
||||
};
|
||||
|
||||
pub type AccountId = AccountId32;
|
||||
@@ -143,6 +145,7 @@ parameter_types! {
|
||||
pub type SovereignAccountOf =
|
||||
(ChildParachainConvertsVia<ParaId, AccountId>, AccountId32Aliases<KusamaNetwork, AccountId>);
|
||||
|
||||
#[allow(deprecated)]
|
||||
pub type LocalCurrencyAdapter = XcmCurrencyAdapter<
|
||||
Balances,
|
||||
IsConcrete<KsmLocation>,
|
||||
|
||||
@@ -40,10 +40,9 @@ use polkadot_parachain_primitives::primitives::{
|
||||
use xcm::{latest::prelude::*, VersionedXcm};
|
||||
use xcm_builder::{
|
||||
Account32Hash, AccountId32Aliases, AllowUnpaidExecutionFrom, ConvertedConcreteId,
|
||||
CurrencyAdapter as XcmCurrencyAdapter, EnsureXcmOrigin, FixedRateOfFungible, FixedWeightBounds,
|
||||
IsConcrete, NativeAsset, NoChecking, NonFungiblesAdapter, ParentIsPreset,
|
||||
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
|
||||
SovereignSignedViaLocation,
|
||||
EnsureXcmOrigin, FixedRateOfFungible, FixedWeightBounds, FungibleAdapter, IsConcrete,
|
||||
NativeAsset, NoChecking, NonFungiblesAdapter, ParentIsPreset, SiblingParachainConvertsVia,
|
||||
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation,
|
||||
};
|
||||
use xcm_executor::{
|
||||
traits::{ConvertLocation, JustTry},
|
||||
@@ -202,7 +201,7 @@ parameter_types! {
|
||||
}
|
||||
|
||||
pub type LocalAssetTransactor = (
|
||||
XcmCurrencyAdapter<Balances, IsConcrete<KsmLocation>, LocationToAccountId, AccountId, ()>,
|
||||
FungibleAdapter<Balances, IsConcrete<KsmLocation>, LocationToAccountId, AccountId, ()>,
|
||||
NonFungiblesAdapter<
|
||||
ForeignUniques,
|
||||
ConvertedConcreteId<MultiLocation, AssetInstance, JustTry, JustTry>,
|
||||
|
||||
@@ -36,9 +36,9 @@ use xcm::latest::prelude::*;
|
||||
use xcm_builder::{
|
||||
Account32Hash, AccountId32Aliases, AllowUnpaidExecutionFrom, AsPrefixedGeneralIndex,
|
||||
ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser,
|
||||
ConvertedConcreteId, CurrencyAdapter as XcmCurrencyAdapter, FixedRateOfFungible,
|
||||
FixedWeightBounds, IsConcrete, NoChecking, NonFungiblesAdapter, SignedAccountId32AsNative,
|
||||
SignedToAccountId32, SovereignSignedViaLocation,
|
||||
ConvertedConcreteId, FixedRateOfFungible, FixedWeightBounds, FungibleAdapter, IsConcrete,
|
||||
NoChecking, NonFungiblesAdapter, SignedAccountId32AsNative, SignedToAccountId32,
|
||||
SovereignSignedViaLocation,
|
||||
};
|
||||
use xcm_executor::{traits::JustTry, Config, XcmExecutor};
|
||||
|
||||
@@ -141,7 +141,7 @@ pub type LocationToAccountId = (
|
||||
);
|
||||
|
||||
pub type LocalAssetTransactor = (
|
||||
XcmCurrencyAdapter<Balances, IsConcrete<TokenLocation>, LocationToAccountId, AccountId, ()>,
|
||||
FungibleAdapter<Balances, IsConcrete<TokenLocation>, LocationToAccountId, AccountId, ()>,
|
||||
NonFungiblesAdapter<
|
||||
Uniques,
|
||||
ConvertedConcreteId<u32, u32, AsPrefixedGeneralIndex<(), u32, JustTry>, JustTry>,
|
||||
|
||||
@@ -37,11 +37,12 @@ use polkadot_parachain_primitives::primitives::{
|
||||
DmpMessageHandler, Id as ParaId, Sibling, XcmpMessageFormat, XcmpMessageHandler,
|
||||
};
|
||||
use xcm::{latest::prelude::*, VersionedXcm};
|
||||
#[allow(deprecated)]
|
||||
use xcm_builder::CurrencyAdapter as XcmCurrencyAdapter;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowUnpaidExecutionFrom, CurrencyAdapter as XcmCurrencyAdapter,
|
||||
EnsureXcmOrigin, FixedRateOfFungible, FixedWeightBounds, IsConcrete, NativeAsset,
|
||||
ParentIsPreset, SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
|
||||
SovereignSignedViaLocation,
|
||||
AccountId32Aliases, AllowUnpaidExecutionFrom, EnsureXcmOrigin, FixedRateOfFungible,
|
||||
FixedWeightBounds, IsConcrete, NativeAsset, ParentIsPreset, SiblingParachainConvertsVia,
|
||||
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation,
|
||||
};
|
||||
use xcm_executor::{Config, XcmExecutor};
|
||||
|
||||
@@ -132,6 +133,7 @@ parameter_types! {
|
||||
pub const MaxAssetsIntoHolding: u32 = 64;
|
||||
}
|
||||
|
||||
#[allow(deprecated)]
|
||||
pub type LocalAssetTransactor =
|
||||
XcmCurrencyAdapter<Balances, IsConcrete<KsmLocation>, LocationToAccountId, AccountId, ()>;
|
||||
|
||||
|
||||
@@ -33,11 +33,13 @@ use polkadot_runtime_parachains::{
|
||||
origin, shared,
|
||||
};
|
||||
use xcm::latest::prelude::*;
|
||||
#[allow(deprecated)]
|
||||
use xcm_builder::CurrencyAdapter as XcmCurrencyAdapter;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowUnpaidExecutionFrom, ChildParachainAsNative,
|
||||
ChildParachainConvertsVia, ChildSystemParachainAsSuperuser,
|
||||
CurrencyAdapter as XcmCurrencyAdapter, FixedRateOfFungible, FixedWeightBounds, IsConcrete,
|
||||
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation,
|
||||
ChildParachainConvertsVia, ChildSystemParachainAsSuperuser, FixedRateOfFungible,
|
||||
FixedWeightBounds, IsConcrete, SignedAccountId32AsNative, SignedToAccountId32,
|
||||
SovereignSignedViaLocation,
|
||||
};
|
||||
use xcm_executor::{Config, XcmExecutor};
|
||||
|
||||
@@ -114,6 +116,7 @@ parameter_types! {
|
||||
pub type SovereignAccountOf =
|
||||
(ChildParachainConvertsVia<ParaId, AccountId>, AccountId32Aliases<ThisNetwork, AccountId>);
|
||||
|
||||
#[allow(deprecated)]
|
||||
pub type LocalAssetTransactor =
|
||||
XcmCurrencyAdapter<Balances, IsConcrete<TokenLocation>, SovereignAccountOf, AccountId, ()>;
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
title: Add XCM FungibleAdapter
|
||||
|
||||
doc:
|
||||
- audience: Runtime Dev
|
||||
description: |
|
||||
A new AssetTransactor has been added to xcm-builder: FungibleAdapter.
|
||||
It's meant to be used instead of the old CurrencyAdapter for configuring the XCM executor
|
||||
to handle only one asset.
|
||||
|
||||
crates:
|
||||
- name: "xcm-builder"
|
||||
|
||||
migrations: []
|
||||
host_functions: []
|
||||
@@ -37,12 +37,13 @@ use sp_runtime::traits::{Get, IdentityLookup, MaybeEquivalence};
|
||||
|
||||
use sp_std::prelude::*;
|
||||
use xcm::latest::prelude::*;
|
||||
#[allow(deprecated)]
|
||||
use xcm_builder::CurrencyAdapter as XcmCurrencyAdapter;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowTopLevelPaidExecutionFrom,
|
||||
ConvertedConcreteId, CurrencyAdapter as XcmCurrencyAdapter, EnsureXcmOrigin,
|
||||
FixedRateOfFungible, FixedWeightBounds, FungiblesAdapter, IsConcrete, NativeAsset, NoChecking,
|
||||
ParentAsSuperuser, ParentIsPreset, SignedAccountId32AsNative, SignedToAccountId32,
|
||||
SovereignSignedViaLocation, WithComputedOrigin,
|
||||
ConvertedConcreteId, EnsureXcmOrigin, FixedRateOfFungible, FixedWeightBounds, FungiblesAdapter,
|
||||
IsConcrete, NativeAsset, NoChecking, ParentAsSuperuser, ParentIsPreset,
|
||||
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, WithComputedOrigin,
|
||||
};
|
||||
use xcm_executor::{traits::JustTry, Config, XcmExecutor};
|
||||
|
||||
@@ -183,6 +184,7 @@ pub fn estimate_fee_for_weight(weight: Weight) -> u128 {
|
||||
units_per_mb * (weight.proof_size() as u128) / (WEIGHT_PROOF_SIZE_PER_MB as u128)
|
||||
}
|
||||
|
||||
#[allow(deprecated)]
|
||||
pub type LocalBalancesTransactor =
|
||||
XcmCurrencyAdapter<Balances, IsConcrete<TokenLocation>, SovereignAccountOf, AccountId, ()>;
|
||||
|
||||
|
||||
@@ -29,12 +29,14 @@ use sp_runtime::traits::IdentityLookup;
|
||||
use polkadot_parachain_primitives::primitives::Id as ParaId;
|
||||
use polkadot_runtime_parachains::{configuration, origin, shared};
|
||||
use xcm::latest::prelude::*;
|
||||
#[allow(deprecated)]
|
||||
use xcm_builder::CurrencyAdapter as XcmCurrencyAdapter;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowSubscriptionsFrom,
|
||||
AllowTopLevelPaidExecutionFrom, ChildParachainAsNative, ChildParachainConvertsVia,
|
||||
ChildSystemParachainAsSuperuser, CurrencyAdapter as XcmCurrencyAdapter, DescribeAllTerminal,
|
||||
DescribeFamily, FixedRateOfFungible, FixedWeightBounds, HashedDescription, IsConcrete,
|
||||
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, WithComputedOrigin,
|
||||
ChildSystemParachainAsSuperuser, DescribeAllTerminal, DescribeFamily, FixedRateOfFungible,
|
||||
FixedWeightBounds, HashedDescription, IsConcrete, SignedAccountId32AsNative,
|
||||
SignedToAccountId32, SovereignSignedViaLocation, WithComputedOrigin,
|
||||
};
|
||||
use xcm_executor::{Config, XcmExecutor};
|
||||
|
||||
@@ -116,6 +118,7 @@ pub type SovereignAccountOf = (
|
||||
ChildParachainConvertsVia<ParaId, AccountId>,
|
||||
);
|
||||
|
||||
#[allow(deprecated)]
|
||||
pub type LocalBalancesTransactor =
|
||||
XcmCurrencyAdapter<Balances, IsConcrete<TokenLocation>, SovereignAccountOf, AccountId, ()>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user