style: Migrate to stable-only rustfmt configuration
- Remove nightly-only features from .rustfmt.toml and vendor/ss58-registry/rustfmt.toml - Removed features: imports_granularity, wrap_comments, comment_width, reorder_impl_items, spaces_around_ranges, binop_separator, match_arm_blocks, trailing_semicolon, trailing_comma - Format all 898 affected files with stable rustfmt - Ensures long-term reliability without nightly toolchain dependency
This commit is contained in:
@@ -41,8 +41,8 @@ impl<
|
||||
let prefix = Prefix::get();
|
||||
let latest_prefix: Location = prefix.try_into().ok()?;
|
||||
let latest_id: Location = (*id).clone().try_into().ok()?;
|
||||
if latest_prefix.parent_count() != latest_id.parent_count() ||
|
||||
latest_prefix
|
||||
if latest_prefix.parent_count() != latest_id.parent_count()
|
||||
|| latest_prefix
|
||||
.interior()
|
||||
.iter()
|
||||
.enumerate()
|
||||
@@ -149,8 +149,9 @@ impl<
|
||||
{
|
||||
fn matches_nonfungibles(a: &Asset) -> result::Result<(ClassId, InstanceId), MatchError> {
|
||||
let (instance, class) = match (&a.fun, &a.id) {
|
||||
(NonFungible(ref instance), AssetId(ref class)) if MatchClassId::contains(class) =>
|
||||
(instance, class),
|
||||
(NonFungible(ref instance), AssetId(ref class)) if MatchClassId::contains(class) => {
|
||||
(instance, class)
|
||||
},
|
||||
_ => return Err(MatchError::AssetNotHandled),
|
||||
};
|
||||
let what = ConvertClassId::convert(class).ok_or(MatchError::AssetIdConversionFailed)?;
|
||||
|
||||
@@ -188,7 +188,9 @@ impl MaybeEquivalence<Location, NativeOrWithId<u32>> for LocationToAssetId {
|
||||
match location.unpack() {
|
||||
(0, [PalletInstance(instance), GeneralIndex(index)])
|
||||
if *instance == pezpallet_instance =>
|
||||
Some(NativeOrWithId::WithId(*index as u32)),
|
||||
{
|
||||
Some(NativeOrWithId::WithId(*index as u32))
|
||||
},
|
||||
(0, []) => Some(NativeOrWithId::Native),
|
||||
_ => None,
|
||||
}
|
||||
@@ -197,8 +199,9 @@ impl MaybeEquivalence<Location, NativeOrWithId<u32>> for LocationToAssetId {
|
||||
fn convert_back(asset_id: &NativeOrWithId<u32>) -> Option<Location> {
|
||||
let pezpallet_instance = TrustBackedAssetsPalletIndex::get();
|
||||
Some(match asset_id {
|
||||
NativeOrWithId::WithId(id) =>
|
||||
Location::new(0, [PalletInstance(pezpallet_instance), GeneralIndex((*id).into())]),
|
||||
NativeOrWithId::WithId(id) => {
|
||||
Location::new(0, [PalletInstance(pezpallet_instance), GeneralIndex((*id).into())])
|
||||
},
|
||||
NativeOrWithId::Native => Location::new(0, []),
|
||||
})
|
||||
}
|
||||
@@ -282,8 +285,9 @@ where
|
||||
{
|
||||
fn try_convert(o: RuntimeOrigin) -> Result<Location, RuntimeOrigin> {
|
||||
o.try_with_caller(|caller| match caller.try_into() {
|
||||
Ok(pezframe_system::RawOrigin::Signed(who)) =>
|
||||
Ok(Junction::AccountIndex64 { network: Network::get(), index: who.into() }.into()),
|
||||
Ok(pezframe_system::RawOrigin::Signed(who)) => {
|
||||
Ok(Junction::AccountIndex64 { network: Network::get(), index: who.into() }.into())
|
||||
},
|
||||
Ok(other) => Err(other.into()),
|
||||
Err(other) => Err(other),
|
||||
})
|
||||
|
||||
@@ -88,21 +88,22 @@ impl<T: Contains<Location>> ShouldExecute for AllowTopLevelPaidExecutionFrom<T>
|
||||
instructions[..end]
|
||||
.matcher()
|
||||
.match_next_inst(|inst| match inst {
|
||||
WithdrawAsset(ref assets) |
|
||||
ReceiveTeleportedAsset(ref assets) |
|
||||
ReserveAssetDeposited(ref assets) |
|
||||
ClaimAsset { ref assets, .. } =>
|
||||
WithdrawAsset(ref assets)
|
||||
| ReceiveTeleportedAsset(ref assets)
|
||||
| ReserveAssetDeposited(ref assets)
|
||||
| ClaimAsset { ref assets, .. } => {
|
||||
if assets.len() <= MAX_ASSETS_FOR_BUY_EXECUTION {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(ProcessMessageError::BadFormat)
|
||||
},
|
||||
}
|
||||
},
|
||||
_ => Err(ProcessMessageError::BadFormat),
|
||||
})?
|
||||
.skip_inst_while(|inst| {
|
||||
matches!(inst, ClearOrigin | AliasOrigin(..)) ||
|
||||
matches!(inst, DescendOrigin(child) if child != &Here) ||
|
||||
matches!(inst, SetHints { .. })
|
||||
matches!(inst, ClearOrigin | AliasOrigin(..))
|
||||
|| matches!(inst, DescendOrigin(child) if child != &Here)
|
||||
|| matches!(inst, SetHints { .. })
|
||||
})?
|
||||
.match_next_inst(|inst| match inst {
|
||||
BuyExecution { weight_limit: Limited(ref mut weight), .. }
|
||||
@@ -343,12 +344,12 @@ impl<T: Contains<Location>, Aliasers: ContainsPair<Location, Location>> ShouldEx
|
||||
// We skip set hints and all types of asset transfer instructions.
|
||||
.match_next_inst_while(
|
||||
|inst| {
|
||||
processed.get() < instructions_to_process &&
|
||||
matches!(
|
||||
processed.get() < instructions_to_process
|
||||
&& matches!(
|
||||
inst,
|
||||
ReceiveTeleportedAsset(_) |
|
||||
ReserveAssetDeposited(_) | WithdrawAsset(_) |
|
||||
SetHints { .. }
|
||||
ReceiveTeleportedAsset(_)
|
||||
| ReserveAssetDeposited(_)
|
||||
| WithdrawAsset(_) | SetHints { .. }
|
||||
)
|
||||
},
|
||||
|_| {
|
||||
@@ -367,12 +368,13 @@ impl<T: Contains<Location>, Aliasers: ContainsPair<Location, Location>> ShouldEx
|
||||
// to know the origin to know if it's allowed unpaid execution.
|
||||
return Err(ProcessMessageError::Unsupported);
|
||||
},
|
||||
AliasOrigin(target) =>
|
||||
AliasOrigin(target) => {
|
||||
if Aliasers::contains(&actual_origin, &target) {
|
||||
actual_origin = target.clone();
|
||||
} else {
|
||||
return Err(ProcessMessageError::Unsupported);
|
||||
},
|
||||
}
|
||||
},
|
||||
DescendOrigin(child) if child != &Here => {
|
||||
let Ok(_) = actual_origin.append_with(child.clone()) else {
|
||||
return Err(ProcessMessageError::Unsupported);
|
||||
@@ -454,7 +456,9 @@ impl<ResponseHandler: OnResponse> ShouldExecute for AllowKnownQueryResponses<Res
|
||||
.match_next_inst(|inst| match inst {
|
||||
QueryResponse { query_id, querier, .. }
|
||||
if ResponseHandler::expecting_response(origin, *query_id, querier.as_ref()) =>
|
||||
Ok(()),
|
||||
{
|
||||
Ok(())
|
||||
},
|
||||
_ => Err(ProcessMessageError::BadFormat),
|
||||
})?;
|
||||
Ok(())
|
||||
@@ -514,9 +518,9 @@ impl ShouldExecute for AllowHrmpNotificationsFromRelayChain {
|
||||
.matcher()
|
||||
.assert_remaining_insts(1)?
|
||||
.match_next_inst(|inst| match inst {
|
||||
HrmpNewChannelOpenRequest { .. } |
|
||||
HrmpChannelAccepted { .. } |
|
||||
HrmpChannelClosing { .. } => Ok(()),
|
||||
HrmpNewChannelOpenRequest { .. }
|
||||
| HrmpChannelAccepted { .. }
|
||||
| HrmpChannelClosing { .. } => Ok(()),
|
||||
_ => Err(ProcessMessageError::BadFormat),
|
||||
})?;
|
||||
Ok(())
|
||||
@@ -561,9 +565,9 @@ impl DenyExecution for DenyReserveTransferToRelayChain {
|
||||
InitiateReserveWithdraw {
|
||||
reserve: Location { parents: 1, interior: Here },
|
||||
..
|
||||
} |
|
||||
DepositReserveAsset { dest: Location { parents: 1, interior: Here }, .. } |
|
||||
TransferReserveAsset { dest: Location { parents: 1, interior: Here }, .. } => {
|
||||
}
|
||||
| DepositReserveAsset { dest: Location { parents: 1, interior: Here }, .. }
|
||||
| TransferReserveAsset { dest: Location { parents: 1, interior: Here }, .. } => {
|
||||
Err(ProcessMessageError::Unsupported) // Deny
|
||||
},
|
||||
|
||||
@@ -665,9 +669,9 @@ impl<Inner: DenyExecution> DenyExecution for DenyRecursively<Inner> {
|
||||
instructions.matcher().match_next_inst_while(
|
||||
|_| true,
|
||||
|inst| match inst {
|
||||
SetAppendix(nested_xcm) |
|
||||
SetErrorHandler(nested_xcm) |
|
||||
ExecuteWithOrigin { xcm: nested_xcm, .. } => Self::deny_recursively::<RuntimeCall>(
|
||||
SetAppendix(nested_xcm)
|
||||
| SetErrorHandler(nested_xcm)
|
||||
| ExecuteWithOrigin { xcm: nested_xcm, .. } => Self::deny_recursively::<RuntimeCall>(
|
||||
origin, nested_xcm, max_weight, properties,
|
||||
),
|
||||
_ => Ok(ControlFlow::Continue(())),
|
||||
|
||||
@@ -151,10 +151,12 @@ impl<
|
||||
let amount: Currency::Balance =
|
||||
Matcher::matches_fungible(what).ok_or(Error::AssetNotHandled)?;
|
||||
match CheckedAccount::get() {
|
||||
Some((checked_account, MintLocation::Local)) =>
|
||||
Self::can_reduce_checked(checked_account, amount),
|
||||
Some((checked_account, MintLocation::NonLocal)) =>
|
||||
Self::can_accrue_checked(checked_account, amount),
|
||||
Some((checked_account, MintLocation::Local)) => {
|
||||
Self::can_reduce_checked(checked_account, amount)
|
||||
},
|
||||
Some((checked_account, MintLocation::NonLocal)) => {
|
||||
Self::can_accrue_checked(checked_account, amount)
|
||||
},
|
||||
None => Ok(()),
|
||||
}
|
||||
}
|
||||
@@ -163,10 +165,12 @@ impl<
|
||||
tracing::trace!(target: "xcm::currency_adapter", ?origin, ?what, "check_in origin");
|
||||
if let Some(amount) = Matcher::matches_fungible(what) {
|
||||
match CheckedAccount::get() {
|
||||
Some((checked_account, MintLocation::Local)) =>
|
||||
Self::reduce_checked(checked_account, amount),
|
||||
Some((checked_account, MintLocation::NonLocal)) =>
|
||||
Self::accrue_checked(checked_account, amount),
|
||||
Some((checked_account, MintLocation::Local)) => {
|
||||
Self::reduce_checked(checked_account, amount)
|
||||
},
|
||||
Some((checked_account, MintLocation::NonLocal)) => {
|
||||
Self::accrue_checked(checked_account, amount)
|
||||
},
|
||||
None => (),
|
||||
}
|
||||
}
|
||||
@@ -176,10 +180,12 @@ impl<
|
||||
tracing::trace!(target: "xcm::currency_adapter", ?dest, ?what, "can_check_out");
|
||||
let amount = Matcher::matches_fungible(what).ok_or(Error::AssetNotHandled)?;
|
||||
match CheckedAccount::get() {
|
||||
Some((checked_account, MintLocation::Local)) =>
|
||||
Self::can_accrue_checked(checked_account, amount),
|
||||
Some((checked_account, MintLocation::NonLocal)) =>
|
||||
Self::can_reduce_checked(checked_account, amount),
|
||||
Some((checked_account, MintLocation::Local)) => {
|
||||
Self::can_accrue_checked(checked_account, amount)
|
||||
},
|
||||
Some((checked_account, MintLocation::NonLocal)) => {
|
||||
Self::can_reduce_checked(checked_account, amount)
|
||||
},
|
||||
None => Ok(()),
|
||||
}
|
||||
}
|
||||
@@ -188,10 +194,12 @@ impl<
|
||||
tracing::trace!(target: "xcm::currency_adapter", ?dest, ?what, "check_out");
|
||||
if let Some(amount) = Matcher::matches_fungible(what) {
|
||||
match CheckedAccount::get() {
|
||||
Some((checked_account, MintLocation::Local)) =>
|
||||
Self::accrue_checked(checked_account, amount),
|
||||
Some((checked_account, MintLocation::NonLocal)) =>
|
||||
Self::reduce_checked(checked_account, amount),
|
||||
Some((checked_account, MintLocation::Local)) => {
|
||||
Self::accrue_checked(checked_account, amount)
|
||||
},
|
||||
Some((checked_account, MintLocation::NonLocal)) => {
|
||||
Self::reduce_checked(checked_account, amount)
|
||||
},
|
||||
None => (),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,10 +140,12 @@ impl<
|
||||
// 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),
|
||||
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(()),
|
||||
}
|
||||
}
|
||||
@@ -156,10 +158,12 @@ impl<
|
||||
);
|
||||
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),
|
||||
Some((checking_account, MintLocation::Local)) => {
|
||||
Self::reduce_checked(checking_account, amount)
|
||||
},
|
||||
Some((checking_account, MintLocation::NonLocal)) => {
|
||||
Self::accrue_checked(checking_account, amount)
|
||||
},
|
||||
None => (),
|
||||
}
|
||||
}
|
||||
@@ -174,10 +178,12 @@ impl<
|
||||
);
|
||||
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),
|
||||
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(()),
|
||||
}
|
||||
}
|
||||
@@ -191,10 +197,12 @@ impl<
|
||||
);
|
||||
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),
|
||||
Some((checking_account, MintLocation::Local)) => {
|
||||
Self::accrue_checked(checking_account, amount)
|
||||
},
|
||||
Some((checking_account, MintLocation::NonLocal)) => {
|
||||
Self::reduce_checked(checking_account, amount)
|
||||
},
|
||||
None => (),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,8 +58,9 @@ pub struct DescribePalletTerminal;
|
||||
impl DescribeLocation for DescribePalletTerminal {
|
||||
fn describe_location(l: &Location) -> Option<Vec<u8>> {
|
||||
match l.unpack() {
|
||||
(0, [PalletInstance(i)]) =>
|
||||
Some((b"Pezpallet", Compact::<u32>::from(*i as u32)).encode()),
|
||||
(0, [PalletInstance(i)]) => {
|
||||
Some((b"Pezpallet", Compact::<u32>::from(*i as u32)).encode())
|
||||
},
|
||||
_ => return None,
|
||||
}
|
||||
}
|
||||
@@ -92,8 +93,9 @@ pub struct DescribeTreasuryVoiceTerminal;
|
||||
impl DescribeLocation for DescribeTreasuryVoiceTerminal {
|
||||
fn describe_location(location: &Location) -> Option<Vec<u8>> {
|
||||
match location.unpack() {
|
||||
(0, [Plurality { id: BodyId::Treasury, part: BodyPart::Voice }]) =>
|
||||
Some((b"Treasury", b"Voice").encode()),
|
||||
(0, [Plurality { id: BodyId::Treasury, part: BodyPart::Voice }]) => {
|
||||
Some((b"Treasury", b"Voice").encode())
|
||||
},
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@@ -161,24 +163,29 @@ impl DescribeLocation for LegacyDescribeForeignChainAccount {
|
||||
fn describe_location(location: &Location) -> Option<Vec<u8>> {
|
||||
Some(match location.unpack() {
|
||||
// Used on the relay chain for sending paras that use 32 byte accounts
|
||||
(0, [Teyrchain(para_id), AccountId32 { id, .. }]) =>
|
||||
LegacyDescribeForeignChainAccount::from_para_32(para_id, id, 0),
|
||||
(0, [Teyrchain(para_id), AccountId32 { id, .. }]) => {
|
||||
LegacyDescribeForeignChainAccount::from_para_32(para_id, id, 0)
|
||||
},
|
||||
|
||||
// Used on the relay chain for sending paras that use 20 byte accounts
|
||||
(0, [Teyrchain(para_id), AccountKey20 { key, .. }]) =>
|
||||
LegacyDescribeForeignChainAccount::from_para_20(para_id, key, 0),
|
||||
(0, [Teyrchain(para_id), AccountKey20 { key, .. }]) => {
|
||||
LegacyDescribeForeignChainAccount::from_para_20(para_id, key, 0)
|
||||
},
|
||||
|
||||
// Used on para-chain for sending paras that use 32 byte accounts
|
||||
(1, [Teyrchain(para_id), AccountId32 { id, .. }]) =>
|
||||
LegacyDescribeForeignChainAccount::from_para_32(para_id, id, 1),
|
||||
(1, [Teyrchain(para_id), AccountId32 { id, .. }]) => {
|
||||
LegacyDescribeForeignChainAccount::from_para_32(para_id, id, 1)
|
||||
},
|
||||
|
||||
// Used on para-chain for sending paras that use 20 byte accounts
|
||||
(1, [Teyrchain(para_id), AccountKey20 { key, .. }]) =>
|
||||
LegacyDescribeForeignChainAccount::from_para_20(para_id, key, 1),
|
||||
(1, [Teyrchain(para_id), AccountKey20 { key, .. }]) => {
|
||||
LegacyDescribeForeignChainAccount::from_para_20(para_id, key, 1)
|
||||
},
|
||||
|
||||
// Used on para-chain for sending from the relay chain
|
||||
(1, [AccountId32 { id, .. }]) =>
|
||||
LegacyDescribeForeignChainAccount::from_relay_32(id, 1),
|
||||
(1, [AccountId32 { id, .. }]) => {
|
||||
LegacyDescribeForeignChainAccount::from_relay_32(id, 1)
|
||||
},
|
||||
|
||||
// No other conversions provided
|
||||
_ => return None,
|
||||
@@ -343,8 +350,9 @@ impl<TreasuryAccount: Get<AccountId>, AccountId: From<[u8; 32]> + Into<[u8; 32]>
|
||||
{
|
||||
fn convert_location(location: &Location) -> Option<AccountId> {
|
||||
match location.unpack() {
|
||||
(0, [Plurality { id: BodyId::Treasury, part: BodyPart::Voice }]) =>
|
||||
Some((TreasuryAccount::get().into() as [u8; 32]).into()),
|
||||
(0, [Plurality { id: BodyId::Treasury, part: BodyPart::Voice }]) => {
|
||||
Some((TreasuryAccount::get().into() as [u8; 32]).into())
|
||||
},
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@@ -447,8 +455,9 @@ impl<UniversalLocation: Get<InteriorLocation>, AccountId: From<[u8; 32]> + Clone
|
||||
let (remote_network, remote_location) = devolved;
|
||||
|
||||
match remote_location.as_slice() {
|
||||
[Teyrchain(remote_network_para_id)] =>
|
||||
Some(AccountId::from(Self::from_params(&remote_network, &remote_network_para_id))),
|
||||
[Teyrchain(remote_network_para_id)] => {
|
||||
Some(AccountId::from(Self::from_params(&remote_network, &remote_network_para_id)))
|
||||
},
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@@ -492,16 +501,18 @@ impl<UniversalLocation: Get<InteriorLocation>, AccountId: From<[u8; 32]> + Clone
|
||||
// equivalent to `EthereumLocationsConverterFor`
|
||||
[] => (b"ethereum-chain", chain_id).using_encoded(blake2_256).into(),
|
||||
// equivalent to `EthereumLocationsConverterFor`
|
||||
[AccountKey20 { network: _, key }] =>
|
||||
(b"ethereum-chain", chain_id, *key).using_encoded(blake2_256).into(),
|
||||
[AccountKey20 { network: _, key }] => {
|
||||
(b"ethereum-chain", chain_id, *key).using_encoded(blake2_256).into()
|
||||
},
|
||||
// extends `EthereumLocationsConverterFor`
|
||||
tail => (b"ethereum-chain", chain_id, tail).using_encoded(blake2_256).into(),
|
||||
}
|
||||
} else {
|
||||
match remote_location.as_slice() {
|
||||
// equivalent to `GlobalConsensusTeyrchainConvertsFor`
|
||||
[Teyrchain(para_id)] =>
|
||||
(b"glblcnsnss/prchn_", remote_network, para_id).using_encoded(blake2_256).into(),
|
||||
[Teyrchain(para_id)] => {
|
||||
(b"glblcnsnss/prchn_", remote_network, para_id).using_encoded(blake2_256).into()
|
||||
},
|
||||
// converts everything else based on hash of encoded location tail
|
||||
tail => (b"glblcnsnss", remote_network, tail).using_encoded(blake2_256).into(),
|
||||
}
|
||||
|
||||
@@ -32,7 +32,8 @@ impl<T: Get<L>, L: TryInto<Location> + Clone> Contains<L> for StartsWith<T, L> {
|
||||
} else {
|
||||
return false;
|
||||
};
|
||||
let latest_t = if let Ok(location) = T::get().try_into() { location } else { return false };
|
||||
let latest_t =
|
||||
if let Ok(location) = T::get().try_into() { location } else { return false };
|
||||
latest_location.starts_with(&latest_t)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,8 +142,9 @@ where
|
||||
let instance = Matcher::matches_nonfungible(what).ok_or(MatchError::AssetNotHandled)?;
|
||||
match CheckingAccount::get() {
|
||||
// We track this asset's teleports to ensure no more come in than have gone out.
|
||||
Some((checking_account, MintLocation::Local)) =>
|
||||
Self::can_reduce_checked(checking_account, instance),
|
||||
Some((checking_account, MintLocation::Local)) => {
|
||||
Self::can_reduce_checked(checking_account, instance)
|
||||
},
|
||||
// We track this asset's teleports to ensure no more go out than have come in.
|
||||
Some((_, MintLocation::NonLocal)) => Self::can_accrue_checked(instance),
|
||||
_ => Ok(()),
|
||||
@@ -163,8 +164,9 @@ where
|
||||
// We track this asset's teleports to ensure no more come in than have gone out.
|
||||
Some((_, MintLocation::Local)) => Self::reduce_checked(instance),
|
||||
// We track this asset's teleports to ensure no more go out than have come in.
|
||||
Some((checking_account, MintLocation::NonLocal)) =>
|
||||
Self::accrue_checked(checking_account, instance),
|
||||
Some((checking_account, MintLocation::NonLocal)) => {
|
||||
Self::accrue_checked(checking_account, instance)
|
||||
},
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
@@ -184,8 +186,9 @@ where
|
||||
// We track this asset's teleports to ensure no more come in than have gone out.
|
||||
Some((_, MintLocation::Local)) => Self::can_accrue_checked(instance),
|
||||
// We track this asset's teleports to ensure no more go out than have come in.
|
||||
Some((checking_account, MintLocation::NonLocal)) =>
|
||||
Self::can_reduce_checked(checking_account, instance),
|
||||
Some((checking_account, MintLocation::NonLocal)) => {
|
||||
Self::can_reduce_checked(checking_account, instance)
|
||||
},
|
||||
_ => Ok(()),
|
||||
}
|
||||
}
|
||||
@@ -201,8 +204,9 @@ where
|
||||
if let Some(instance) = Matcher::matches_nonfungible(what) {
|
||||
match CheckingAccount::get() {
|
||||
// We track this asset's teleports to ensure no more come in than have gone out.
|
||||
Some((checking_account, MintLocation::Local)) =>
|
||||
Self::accrue_checked(checking_account, instance),
|
||||
Some((checking_account, MintLocation::Local)) => {
|
||||
Self::accrue_checked(checking_account, instance)
|
||||
},
|
||||
// We track this asset's teleports to ensure no more go out than have come in.
|
||||
Some((_, MintLocation::NonLocal)) => Self::reduce_checked(instance),
|
||||
_ => (),
|
||||
|
||||
@@ -32,8 +32,8 @@ impl<Prefix: Contains<Location>> ContainsPair<Location, Location>
|
||||
if let (prefix, Some(account_id @ AccountId32 { .. })) =
|
||||
origin.clone().split_last_interior()
|
||||
{
|
||||
return Prefix::contains(&prefix) &&
|
||||
*target == Location { parents: 0, interior: [account_id].into() };
|
||||
return Prefix::contains(&prefix)
|
||||
&& *target == Location { parents: 0, interior: [account_id].into() };
|
||||
}
|
||||
false
|
||||
}
|
||||
@@ -60,9 +60,9 @@ where
|
||||
fn contains(origin: &Location, target: &Location) -> bool {
|
||||
// check that `origin` is a root location
|
||||
match origin.unpack() {
|
||||
(1, [Teyrchain(_)]) |
|
||||
(2, [GlobalConsensus(_)]) |
|
||||
(2, [GlobalConsensus(_), Teyrchain(_)]) => (),
|
||||
(1, [Teyrchain(_)])
|
||||
| (2, [GlobalConsensus(_)])
|
||||
| (2, [GlobalConsensus(_), Teyrchain(_)]) => (),
|
||||
_ => return false,
|
||||
};
|
||||
// check that `origin` matches `Origin` and `target` matches `Filter`
|
||||
|
||||
@@ -84,7 +84,9 @@ impl<ParaId: IsSystem + From<u32>, RuntimeOrigin: OriginTrait> ConvertOrigin<Run
|
||||
match (kind, origin.unpack()) {
|
||||
(OriginKind::Superuser, (0, [Junction::Teyrchain(id)]))
|
||||
if ParaId::from(*id).is_system() =>
|
||||
Ok(RuntimeOrigin::root()),
|
||||
{
|
||||
Ok(RuntimeOrigin::root())
|
||||
},
|
||||
_ => Err(origin),
|
||||
}
|
||||
}
|
||||
@@ -109,7 +111,9 @@ impl<ParaId: IsSystem + From<u32>, RuntimeOrigin: OriginTrait> ConvertOrigin<Run
|
||||
match (kind, origin.unpack()) {
|
||||
(OriginKind::Superuser, (1, [Junction::Teyrchain(id)]))
|
||||
if ParaId::from(*id).is_system() =>
|
||||
Ok(RuntimeOrigin::root()),
|
||||
{
|
||||
Ok(RuntimeOrigin::root())
|
||||
},
|
||||
_ => Err(origin),
|
||||
}
|
||||
}
|
||||
@@ -128,8 +132,9 @@ impl<TeyrchainOrigin: From<u32>, RuntimeOrigin: From<TeyrchainOrigin>> ConvertOr
|
||||
let origin = origin.into();
|
||||
tracing::trace!(target: "xcm::origin_conversion", ?origin, ?kind, "ChildTeyrchainAsNative");
|
||||
match (kind, origin.unpack()) {
|
||||
(OriginKind::Native, (0, [Junction::Teyrchain(id)])) =>
|
||||
Ok(RuntimeOrigin::from(TeyrchainOrigin::from(*id))),
|
||||
(OriginKind::Native, (0, [Junction::Teyrchain(id)])) => {
|
||||
Ok(RuntimeOrigin::from(TeyrchainOrigin::from(*id)))
|
||||
},
|
||||
_ => Err(origin),
|
||||
}
|
||||
}
|
||||
@@ -152,8 +157,9 @@ impl<TeyrchainOrigin: From<u32>, RuntimeOrigin: From<TeyrchainOrigin>> ConvertOr
|
||||
"SiblingTeyrchainAsNative",
|
||||
);
|
||||
match (kind, origin.unpack()) {
|
||||
(OriginKind::Native, (1, [Junction::Teyrchain(id)])) =>
|
||||
Ok(RuntimeOrigin::from(TeyrchainOrigin::from(*id))),
|
||||
(OriginKind::Native, (1, [Junction::Teyrchain(id)])) => {
|
||||
Ok(RuntimeOrigin::from(TeyrchainOrigin::from(*id)))
|
||||
},
|
||||
_ => Err(origin),
|
||||
}
|
||||
}
|
||||
@@ -199,7 +205,9 @@ where
|
||||
match (kind, origin.unpack()) {
|
||||
(OriginKind::Native, (0, [Junction::AccountId32 { id, network }]))
|
||||
if matches!(network, None) || *network == Network::get() =>
|
||||
Ok(RuntimeOrigin::signed((*id).into())),
|
||||
{
|
||||
Ok(RuntimeOrigin::signed((*id).into()))
|
||||
},
|
||||
_ => Err(origin),
|
||||
}
|
||||
}
|
||||
@@ -226,7 +234,9 @@ where
|
||||
match (kind, origin.unpack()) {
|
||||
(OriginKind::Native, (0, [Junction::AccountKey20 { key, network }]))
|
||||
if (matches!(network, None) || *network == Network::get()) =>
|
||||
Ok(RuntimeOrigin::signed((*key).into())),
|
||||
{
|
||||
Ok(RuntimeOrigin::signed((*key).into()))
|
||||
},
|
||||
_ => Err(origin),
|
||||
}
|
||||
}
|
||||
@@ -279,8 +289,9 @@ where
|
||||
{
|
||||
fn try_convert(o: RuntimeOrigin) -> Result<Location, RuntimeOrigin> {
|
||||
o.try_with_caller(|caller| match caller.try_into() {
|
||||
Ok(SystemRawOrigin::Signed(who)) =>
|
||||
Ok(Junction::AccountId32 { network: Network::get(), id: who.into() }.into()),
|
||||
Ok(SystemRawOrigin::Signed(who)) => {
|
||||
Ok(Junction::AccountId32 { network: Network::get(), id: who.into() }.into())
|
||||
},
|
||||
Ok(other) => Err(other.into()),
|
||||
Err(other) => Err(other),
|
||||
})
|
||||
@@ -353,8 +364,9 @@ impl<WhitelistedSuperuserLocations: Contains<Location>, RuntimeOrigin: OriginTra
|
||||
"LocationAsSuperuser",
|
||||
);
|
||||
match (kind, &origin) {
|
||||
(OriginKind::Superuser, loc) if WhitelistedSuperuserLocations::contains(loc) =>
|
||||
Ok(RuntimeOrigin::root()),
|
||||
(OriginKind::Superuser, loc) if WhitelistedSuperuserLocations::contains(loc) => {
|
||||
Ok(RuntimeOrigin::root())
|
||||
},
|
||||
_ => Err(origin),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -930,12 +930,13 @@ fn deny_then_try_works() {
|
||||
instructions.matcher().match_next_inst_while(
|
||||
|_| true,
|
||||
|inst| match inst {
|
||||
ClearOrigin { .. } =>
|
||||
ClearOrigin { .. } => {
|
||||
if origin.clone() == Here.into_location() {
|
||||
Err(ProcessMessageError::BadFormat)
|
||||
} else {
|
||||
Ok(ControlFlow::Continue(()))
|
||||
},
|
||||
}
|
||||
},
|
||||
_ => Ok(ControlFlow::Continue(())),
|
||||
},
|
||||
)?;
|
||||
|
||||
@@ -80,19 +80,19 @@ impl Dispatchable for TestCall {
|
||||
fn dispatch(self, origin: Self::RuntimeOrigin) -> DispatchResultWithPostInfo {
|
||||
let mut post_info = PostDispatchInfo::default();
|
||||
let maybe_actual = match self {
|
||||
TestCall::OnlyRoot(_, maybe_actual) |
|
||||
TestCall::OnlySigned(_, maybe_actual, _) |
|
||||
TestCall::OnlyTeyrchain(_, maybe_actual, _) |
|
||||
TestCall::Any(_, maybe_actual) => maybe_actual,
|
||||
TestCall::OnlyRoot(_, maybe_actual)
|
||||
| TestCall::OnlySigned(_, maybe_actual, _)
|
||||
| TestCall::OnlyTeyrchain(_, maybe_actual, _)
|
||||
| TestCall::Any(_, maybe_actual) => maybe_actual,
|
||||
};
|
||||
post_info.actual_weight = maybe_actual;
|
||||
if match (&origin, &self) {
|
||||
(TestOrigin::Teyrchain(i), TestCall::OnlyTeyrchain(_, _, Some(j))) => i == j,
|
||||
(TestOrigin::Signed(i), TestCall::OnlySigned(_, _, Some(j))) => i == j,
|
||||
(TestOrigin::Root, TestCall::OnlyRoot(..)) |
|
||||
(TestOrigin::Teyrchain(_), TestCall::OnlyTeyrchain(_, _, None)) |
|
||||
(TestOrigin::Signed(_), TestCall::OnlySigned(_, _, None)) |
|
||||
(_, TestCall::Any(..)) => true,
|
||||
(TestOrigin::Root, TestCall::OnlyRoot(..))
|
||||
| (TestOrigin::Teyrchain(_), TestCall::OnlyTeyrchain(_, _, None))
|
||||
| (TestOrigin::Signed(_), TestCall::OnlySigned(_, _, None))
|
||||
| (_, TestCall::Any(..)) => true,
|
||||
_ => false,
|
||||
} {
|
||||
Ok(post_info)
|
||||
@@ -105,10 +105,10 @@ impl Dispatchable for TestCall {
|
||||
impl GetDispatchInfo for TestCall {
|
||||
fn get_dispatch_info(&self) -> DispatchInfo {
|
||||
let call_weight = *match self {
|
||||
TestCall::OnlyRoot(estimate, ..) |
|
||||
TestCall::OnlyTeyrchain(estimate, ..) |
|
||||
TestCall::OnlySigned(estimate, ..) |
|
||||
TestCall::Any(estimate, ..) => estimate,
|
||||
TestCall::OnlyRoot(estimate, ..)
|
||||
| TestCall::OnlyTeyrchain(estimate, ..)
|
||||
| TestCall::OnlySigned(estimate, ..)
|
||||
| TestCall::Any(estimate, ..) => estimate,
|
||||
};
|
||||
DispatchInfo { call_weight, ..Default::default() }
|
||||
}
|
||||
@@ -617,12 +617,15 @@ pub struct TestTicket(LockTraceItem);
|
||||
impl Enact for TestTicket {
|
||||
fn enact(self) -> Result<(), LockError> {
|
||||
match &self.0 {
|
||||
LockTraceItem::Lock { unlocker, asset, owner } =>
|
||||
allow_unlock(unlocker.clone(), asset.clone(), owner.clone()),
|
||||
LockTraceItem::Unlock { unlocker, asset, owner } =>
|
||||
disallow_unlock(unlocker.clone(), asset.clone(), owner.clone()),
|
||||
LockTraceItem::Reduce { locker, asset, owner } =>
|
||||
disallow_request_unlock(locker.clone(), asset.clone(), owner.clone()),
|
||||
LockTraceItem::Lock { unlocker, asset, owner } => {
|
||||
allow_unlock(unlocker.clone(), asset.clone(), owner.clone())
|
||||
},
|
||||
LockTraceItem::Unlock { unlocker, asset, owner } => {
|
||||
disallow_unlock(unlocker.clone(), asset.clone(), owner.clone())
|
||||
},
|
||||
LockTraceItem::Reduce { locker, asset, owner } => {
|
||||
disallow_request_unlock(locker.clone(), asset.clone(), owner.clone())
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
LOCK_TRACE.with(move |l| l.borrow_mut().push(self.0));
|
||||
|
||||
@@ -163,8 +163,9 @@ impl MaybeEquivalence<Location, AssetIdForAssets>
|
||||
match value.unpack() {
|
||||
(0, []) => Some(0 as AssetIdForAssets),
|
||||
(1, []) => Some(1 as AssetIdForAssets),
|
||||
(0, [PalletInstance(1), GeneralIndex(index)]) if ![0, 1].contains(index) =>
|
||||
Some(*index as AssetIdForAssets),
|
||||
(0, [PalletInstance(1), GeneralIndex(index)]) if ![0, 1].contains(index) => {
|
||||
Some(*index as AssetIdForAssets)
|
||||
},
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@@ -173,8 +174,9 @@ impl MaybeEquivalence<Location, AssetIdForAssets>
|
||||
match value {
|
||||
0u128 => Some(Location { parents: 1, interior: Here }),
|
||||
1u128 => Some(Location { parents: 0, interior: Here }),
|
||||
para_id @ 1..=1000 =>
|
||||
Some(Location { parents: 1, interior: [Teyrchain(*para_id as u32)].into() }),
|
||||
para_id @ 1..=1000 => {
|
||||
Some(Location { parents: 1, interior: [Teyrchain(*para_id as u32)].into() })
|
||||
},
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@@ -262,8 +264,9 @@ pub struct TreasuryToAccount;
|
||||
impl ConvertLocation<AccountId> for TreasuryToAccount {
|
||||
fn convert_location(location: &Location) -> Option<AccountId> {
|
||||
match location.unpack() {
|
||||
(1, [Teyrchain(42), Plurality { id: BodyId::Treasury, part: BodyPart::Voice }]) =>
|
||||
Some(TreasuryAccountId::get()), // Hardcoded test treasury account id
|
||||
(1, [Teyrchain(42), Plurality { id: BodyId::Treasury, part: BodyPart::Voice }]) => {
|
||||
Some(TreasuryAccountId::get())
|
||||
}, // Hardcoded test treasury account id
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,8 +229,9 @@ impl<T: Get<Vec<NetworkExportTableItem>>> ExporterFor for NetworkExportTable<T>
|
||||
T::get()
|
||||
.into_iter()
|
||||
.find(|item| {
|
||||
&item.remote_network == network &&
|
||||
item.remote_location_filter
|
||||
&item.remote_network == network
|
||||
&& item
|
||||
.remote_location_filter
|
||||
.as_ref()
|
||||
.map(|filters| filters.iter().any(|filter| filter == remote_location))
|
||||
.unwrap_or(true)
|
||||
|
||||
@@ -103,14 +103,16 @@ impl<T: Get<Weight>, C: Decode + GetDispatchInfo, M> FixedWeightBounds<T, C, M>
|
||||
weight_limit: Weight,
|
||||
) -> Result<Weight, XcmError> {
|
||||
let instruction_weight = match instruction {
|
||||
Transact { ref mut call, .. } =>
|
||||
Transact { ref mut call, .. } => {
|
||||
call.ensure_decoded()
|
||||
.map_err(|_| XcmError::FailedToDecode)?
|
||||
.get_dispatch_info()
|
||||
.call_weight,
|
||||
SetErrorHandler(xcm) | SetAppendix(xcm) | ExecuteWithOrigin { xcm, .. } =>
|
||||
.call_weight
|
||||
},
|
||||
SetErrorHandler(xcm) | SetAppendix(xcm) | ExecuteWithOrigin { xcm, .. } => {
|
||||
Self::weight_with_limit(xcm, instructions_left, weight_limit)
|
||||
.map_err(|outcome_error| outcome_error.error)?,
|
||||
.map_err(|outcome_error| outcome_error.error)?
|
||||
},
|
||||
_ => Weight::zero(),
|
||||
};
|
||||
let total_weight = T::get().checked_add(&instruction_weight).ok_or(XcmError::Overflow)?;
|
||||
@@ -197,14 +199,16 @@ where
|
||||
weight_limit: Weight,
|
||||
) -> Result<Weight, XcmError> {
|
||||
let instruction_weight = match instruction {
|
||||
Transact { ref mut call, .. } =>
|
||||
Transact { ref mut call, .. } => {
|
||||
call.ensure_decoded()
|
||||
.map_err(|_| XcmError::FailedToDecode)?
|
||||
.get_dispatch_info()
|
||||
.call_weight,
|
||||
SetErrorHandler(xcm) | SetAppendix(xcm) =>
|
||||
.call_weight
|
||||
},
|
||||
SetErrorHandler(xcm) | SetAppendix(xcm) => {
|
||||
Self::weight_with_limit(xcm, instructions_left, weight_limit)
|
||||
.map_err(|outcome_error| outcome_error.error)?,
|
||||
.map_err(|outcome_error| outcome_error.error)?
|
||||
},
|
||||
_ => Weight::zero(),
|
||||
};
|
||||
let total_weight = instruction
|
||||
@@ -254,9 +258,9 @@ impl<T: Get<(AssetId, u128, u128)>, R: TakeRevenue> WeightTrader for FixedRateOf
|
||||
?id, ?weight, ?payment, ?context,
|
||||
"FixedRateOfFungible::buy_weight",
|
||||
);
|
||||
let amount = (units_per_second * (weight.ref_time() as u128) /
|
||||
(WEIGHT_REF_TIME_PER_SECOND as u128)) +
|
||||
(units_per_mb * (weight.proof_size() as u128) / (WEIGHT_PROOF_SIZE_PER_MB as u128));
|
||||
let amount = (units_per_second * (weight.ref_time() as u128)
|
||||
/ (WEIGHT_REF_TIME_PER_SECOND as u128))
|
||||
+ (units_per_mb * (weight.proof_size() as u128) / (WEIGHT_PROOF_SIZE_PER_MB as u128));
|
||||
if amount == 0 {
|
||||
return Ok(payment);
|
||||
}
|
||||
@@ -273,9 +277,9 @@ impl<T: Get<(AssetId, u128, u128)>, R: TakeRevenue> WeightTrader for FixedRateOf
|
||||
let (id, units_per_second, units_per_mb) = T::get();
|
||||
tracing::trace!(target: "xcm::weight", ?id, ?weight, ?context, "FixedRateOfFungible::refund_weight");
|
||||
let weight = weight.min(self.0);
|
||||
let amount = (units_per_second * (weight.ref_time() as u128) /
|
||||
(WEIGHT_REF_TIME_PER_SECOND as u128)) +
|
||||
(units_per_mb * (weight.proof_size() as u128) / (WEIGHT_PROOF_SIZE_PER_MB as u128));
|
||||
let amount = (units_per_second * (weight.ref_time() as u128)
|
||||
/ (WEIGHT_REF_TIME_PER_SECOND as u128))
|
||||
+ (units_per_mb * (weight.proof_size() as u128) / (WEIGHT_PROOF_SIZE_PER_MB as u128));
|
||||
self.0 -= weight;
|
||||
self.1 = self.1.saturating_sub(amount);
|
||||
if amount > 0 {
|
||||
|
||||
Reference in New Issue
Block a user