mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 18:01:03 +00:00
FRAME: Unity Balance Conversion for Different IDs of Native Asset (#3659)
Introduce types to define 1:1 balance conversion for different relative
asset ids/locations of native asset.
Examples:
native asset on Asset Hub presented as `VersionedLocatableAsset` type in
the context of Relay Chain is
```
{
`location`: (0, Parachain(1000)),
`asset_id`: (1, Here),
}
```
and it's balance should be converted 1:1 by implementations of
`ConversionToAssetBalance` trait.
---------
Co-authored-by: Branislav Kontur <bkontur@gmail.com>
This commit is contained in:
@@ -322,6 +322,29 @@ impl<ParaId: IsSystem + From<u32>> Contains<Location> for IsChildSystemParachain
|
||||
}
|
||||
}
|
||||
|
||||
/// Matches if the given location is a system-level sibling parachain.
|
||||
pub struct IsSiblingSystemParachain<ParaId, SelfParaId>(PhantomData<(ParaId, SelfParaId)>);
|
||||
impl<ParaId: IsSystem + From<u32> + Eq, SelfParaId: Get<ParaId>> Contains<Location>
|
||||
for IsSiblingSystemParachain<ParaId, SelfParaId>
|
||||
{
|
||||
fn contains(l: &Location) -> bool {
|
||||
matches!(
|
||||
l.unpack(),
|
||||
(1, [Junction::Parachain(id)])
|
||||
if SelfParaId::get() != ParaId::from(*id) && ParaId::from(*id).is_system(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// Matches if the given location contains only the specified amount of parents and no interior
|
||||
/// junctions.
|
||||
pub struct IsParentsOnly<Count>(PhantomData<Count>);
|
||||
impl<Count: Get<u8>> Contains<Location> for IsParentsOnly<Count> {
|
||||
fn contains(t: &Location) -> bool {
|
||||
t.contains_parents_only(Count::get())
|
||||
}
|
||||
}
|
||||
|
||||
/// Allows only messages if the generic `ResponseHandler` expects them via `expecting_response`.
|
||||
pub struct AllowKnownQueryResponses<ResponseHandler>(PhantomData<ResponseHandler>);
|
||||
impl<ResponseHandler: OnResponse> ShouldExecute for AllowKnownQueryResponses<ResponseHandler> {
|
||||
|
||||
@@ -37,8 +37,8 @@ mod barriers;
|
||||
pub use barriers::{
|
||||
AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, AllowSubscriptionsFrom,
|
||||
AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, DenyReserveTransferToRelayChain,
|
||||
DenyThenTry, IsChildSystemParachain, RespectSuspension, TakeWeightCredit, TrailingSetTopicAsId,
|
||||
WithComputedOrigin,
|
||||
DenyThenTry, IsChildSystemParachain, IsParentsOnly, IsSiblingSystemParachain,
|
||||
RespectSuspension, TakeWeightCredit, TrailingSetTopicAsId, WithComputedOrigin,
|
||||
};
|
||||
|
||||
mod controller;
|
||||
|
||||
Reference in New Issue
Block a user