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:
2025-12-22 17:12:58 +03:00
parent 65b7f5e640
commit 4c8f281051
898 changed files with 8671 additions and 6432 deletions
+15 -11
View File
@@ -320,8 +320,9 @@ impl<'a> TryFrom<&'a Junction> for BoundedSlice<'a, u8, ConstU32<32>> {
type Error = ();
fn try_from(key: &'a Junction) -> Result<Self, ()> {
match key {
Junction::GeneralKey { length, data } =>
BoundedSlice::try_from(&data[..data.len().min(*length as usize)]).map_err(|_| ()),
Junction::GeneralKey { length, data } => {
BoundedSlice::try_from(&data[..data.len().min(*length as usize)]).map_err(|_| ())
},
_ => Err(()),
}
}
@@ -352,12 +353,15 @@ impl TryFrom<NewJunction> for Junction {
use NewJunction::*;
Ok(match value {
Teyrchain(id) => Self::Teyrchain(id),
AccountId32 { network: maybe_network, id } =>
Self::AccountId32 { network: maybe_network.map(|network| network.into()), id },
AccountIndex64 { network: maybe_network, index } =>
Self::AccountIndex64 { network: maybe_network.map(|network| network.into()), index },
AccountKey20 { network: maybe_network, key } =>
Self::AccountKey20 { network: maybe_network.map(|network| network.into()), key },
AccountId32 { network: maybe_network, id } => {
Self::AccountId32 { network: maybe_network.map(|network| network.into()), id }
},
AccountIndex64 { network: maybe_network, index } => {
Self::AccountIndex64 { network: maybe_network.map(|network| network.into()), index }
},
AccountKey20 { network: maybe_network, key } => {
Self::AccountKey20 { network: maybe_network.map(|network| network.into()), key }
},
PalletInstance(index) => Self::PalletInstance(index),
GeneralIndex(id) => Self::GeneralIndex(id),
GeneralKey { length, data } => Self::GeneralKey { length, data },
@@ -395,9 +399,9 @@ impl Junction {
pub fn remove_network_id(&mut self) {
use Junction::*;
match self {
AccountId32 { ref mut network, .. } |
AccountIndex64 { ref mut network, .. } |
AccountKey20 { ref mut network, .. } => *network = None,
AccountId32 { ref mut network, .. }
| AccountIndex64 { ref mut network, .. }
| AccountKey20 { ref mut network, .. } => *network = None,
_ => {},
}
}
+117 -78
View File
@@ -328,8 +328,9 @@ impl TryFrom<NewResponse> for Response {
Ok(match new {
Null => Self::Null,
Assets(assets) => Self::Assets(assets.try_into()?),
ExecutionResult(result) =>
Self::ExecutionResult(result.map(|(num, old_error)| (num, old_error.into()))),
ExecutionResult(result) => {
Self::ExecutionResult(result.map(|(num, old_error)| (num, old_error.into())))
},
Version(version) => Self::Version(version),
PalletsInfo(pezpallet_info) => {
let inner = pezpallet_info
@@ -340,8 +341,9 @@ impl TryFrom<NewResponse> for Response {
BoundedVec::<PalletInfo, MaxPalletsInfo>::try_from(inner).map_err(|_| ())?,
)
},
DispatchResult(maybe_error) =>
Self::DispatchResult(maybe_error.try_into().map_err(|_| ())?),
DispatchResult(maybe_error) => {
Self::DispatchResult(maybe_error.try_into().map_err(|_| ())?)
},
})
}
}
@@ -1150,24 +1152,30 @@ impl<Call> Instruction<Call> {
WithdrawAsset(assets) => WithdrawAsset(assets),
ReserveAssetDeposited(assets) => ReserveAssetDeposited(assets),
ReceiveTeleportedAsset(assets) => ReceiveTeleportedAsset(assets),
QueryResponse { query_id, response, max_weight, querier } =>
QueryResponse { query_id, response, max_weight, querier },
QueryResponse { query_id, response, max_weight, querier } => {
QueryResponse { query_id, response, max_weight, querier }
},
TransferAsset { assets, beneficiary } => TransferAsset { assets, beneficiary },
TransferReserveAsset { assets, dest, xcm } =>
TransferReserveAsset { assets, dest, xcm },
HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity } =>
HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity },
TransferReserveAsset { assets, dest, xcm } => {
TransferReserveAsset { assets, dest, xcm }
},
HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity } => {
HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity }
},
HrmpChannelAccepted { recipient } => HrmpChannelAccepted { recipient },
HrmpChannelClosing { initiator, sender, recipient } =>
HrmpChannelClosing { initiator, sender, recipient },
Transact { origin_kind, require_weight_at_most, call } =>
Transact { origin_kind, require_weight_at_most, call: call.into() },
HrmpChannelClosing { initiator, sender, recipient } => {
HrmpChannelClosing { initiator, sender, recipient }
},
Transact { origin_kind, require_weight_at_most, call } => {
Transact { origin_kind, require_weight_at_most, call: call.into() }
},
ReportError(response_info) => ReportError(response_info),
DepositAsset { assets, beneficiary } => DepositAsset { assets, beneficiary },
DepositReserveAsset { assets, dest, xcm } => DepositReserveAsset { assets, dest, xcm },
ExchangeAsset { give, want, maximal } => ExchangeAsset { give, want, maximal },
InitiateReserveWithdraw { assets, reserve, xcm } =>
InitiateReserveWithdraw { assets, reserve, xcm },
InitiateReserveWithdraw { assets, reserve, xcm } => {
InitiateReserveWithdraw { assets, reserve, xcm }
},
InitiateTeleport { assets, dest, xcm } => InitiateTeleport { assets, dest, xcm },
ReportHolding { response_info, assets } => ReportHolding { response_info, assets },
BuyExecution { fees, weight_limit } => BuyExecution { fees, weight_limit },
@@ -1179,23 +1187,27 @@ impl<Call> Instruction<Call> {
ClearError => ClearError,
ClaimAsset { assets, ticket } => ClaimAsset { assets, ticket },
Trap(code) => Trap(code),
SubscribeVersion { query_id, max_response_weight } =>
SubscribeVersion { query_id, max_response_weight },
SubscribeVersion { query_id, max_response_weight } => {
SubscribeVersion { query_id, max_response_weight }
},
UnsubscribeVersion => UnsubscribeVersion,
BurnAsset(assets) => BurnAsset(assets),
ExpectAsset(assets) => ExpectAsset(assets),
ExpectOrigin(origin) => ExpectOrigin(origin),
ExpectError(error) => ExpectError(error),
ExpectTransactStatus(transact_status) => ExpectTransactStatus(transact_status),
QueryPallet { module_name, response_info } =>
QueryPallet { module_name, response_info },
ExpectPallet { index, name, module_name, crate_major, min_crate_minor } =>
ExpectPallet { index, name, module_name, crate_major, min_crate_minor },
QueryPallet { module_name, response_info } => {
QueryPallet { module_name, response_info }
},
ExpectPallet { index, name, module_name, crate_major, min_crate_minor } => {
ExpectPallet { index, name, module_name, crate_major, min_crate_minor }
},
ReportTransactStatus(response_info) => ReportTransactStatus(response_info),
ClearTransactStatus => ClearTransactStatus,
UniversalOrigin(j) => UniversalOrigin(j),
ExportMessage { network, destination, xcm } =>
ExportMessage { network, destination, xcm },
ExportMessage { network, destination, xcm } => {
ExportMessage { network, destination, xcm }
},
LockAsset { asset, unlocker } => LockAsset { asset, unlocker },
UnlockAsset { asset, target } => UnlockAsset { asset, target },
NoteUnlockable { asset, owner } => NoteUnlockable { asset, owner },
@@ -1204,8 +1216,9 @@ impl<Call> Instruction<Call> {
SetTopic(topic) => SetTopic(topic),
ClearTopic => ClearTopic,
AliasOrigin(location) => AliasOrigin(location),
UnpaidExecution { weight_limit, check_origin } =>
UnpaidExecution { weight_limit, check_origin },
UnpaidExecution { weight_limit, check_origin } => {
UnpaidExecution { weight_limit, check_origin }
},
}
}
}
@@ -1218,27 +1231,34 @@ impl<Call, W: XcmWeightInfo<Call>> GetWeight<W> for Instruction<Call> {
WithdrawAsset(assets) => W::withdraw_asset(assets),
ReserveAssetDeposited(assets) => W::reserve_asset_deposited(assets),
ReceiveTeleportedAsset(assets) => W::receive_teleported_asset(assets),
QueryResponse { query_id, response, max_weight, querier } =>
W::query_response(query_id, response, max_weight, querier),
QueryResponse { query_id, response, max_weight, querier } => {
W::query_response(query_id, response, max_weight, querier)
},
TransferAsset { assets, beneficiary } => W::transfer_asset(assets, beneficiary),
TransferReserveAsset { assets, dest, xcm } =>
W::transfer_reserve_asset(&assets, dest, xcm),
Transact { origin_kind, require_weight_at_most, call } =>
W::transact(origin_kind, require_weight_at_most, call),
HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity } =>
W::hrmp_new_channel_open_request(sender, max_message_size, max_capacity),
TransferReserveAsset { assets, dest, xcm } => {
W::transfer_reserve_asset(&assets, dest, xcm)
},
Transact { origin_kind, require_weight_at_most, call } => {
W::transact(origin_kind, require_weight_at_most, call)
},
HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity } => {
W::hrmp_new_channel_open_request(sender, max_message_size, max_capacity)
},
HrmpChannelAccepted { recipient } => W::hrmp_channel_accepted(recipient),
HrmpChannelClosing { initiator, sender, recipient } =>
W::hrmp_channel_closing(initiator, sender, recipient),
HrmpChannelClosing { initiator, sender, recipient } => {
W::hrmp_channel_closing(initiator, sender, recipient)
},
ClearOrigin => W::clear_origin(),
DescendOrigin(who) => W::descend_origin(who),
ReportError(response_info) => W::report_error(&response_info),
DepositAsset { assets, beneficiary } => W::deposit_asset(assets, beneficiary),
DepositReserveAsset { assets, dest, xcm } =>
W::deposit_reserve_asset(assets, dest, xcm),
DepositReserveAsset { assets, dest, xcm } => {
W::deposit_reserve_asset(assets, dest, xcm)
},
ExchangeAsset { give, want, maximal } => W::exchange_asset(give, want, maximal),
InitiateReserveWithdraw { assets, reserve, xcm } =>
W::initiate_reserve_withdraw(assets, reserve, xcm),
InitiateReserveWithdraw { assets, reserve, xcm } => {
W::initiate_reserve_withdraw(assets, reserve, xcm)
},
InitiateTeleport { assets, dest, xcm } => W::initiate_teleport(assets, dest, xcm),
ReportHolding { response_info, assets } => W::report_holding(&response_info, &assets),
BuyExecution { fees, weight_limit } => W::buy_execution(fees, weight_limit),
@@ -1248,23 +1268,27 @@ impl<Call, W: XcmWeightInfo<Call>> GetWeight<W> for Instruction<Call> {
ClearError => W::clear_error(),
ClaimAsset { assets, ticket } => W::claim_asset(assets, ticket),
Trap(code) => W::trap(code),
SubscribeVersion { query_id, max_response_weight } =>
W::subscribe_version(query_id, max_response_weight),
SubscribeVersion { query_id, max_response_weight } => {
W::subscribe_version(query_id, max_response_weight)
},
UnsubscribeVersion => W::unsubscribe_version(),
BurnAsset(assets) => W::burn_asset(assets),
ExpectAsset(assets) => W::expect_asset(assets),
ExpectOrigin(origin) => W::expect_origin(origin),
ExpectError(error) => W::expect_error(error),
ExpectTransactStatus(transact_status) => W::expect_transact_status(transact_status),
QueryPallet { module_name, response_info } =>
W::query_pallet(module_name, response_info),
ExpectPallet { index, name, module_name, crate_major, min_crate_minor } =>
W::expect_pallet(index, name, module_name, crate_major, min_crate_minor),
QueryPallet { module_name, response_info } => {
W::query_pallet(module_name, response_info)
},
ExpectPallet { index, name, module_name, crate_major, min_crate_minor } => {
W::expect_pallet(index, name, module_name, crate_major, min_crate_minor)
},
ReportTransactStatus(response_info) => W::report_transact_status(response_info),
ClearTransactStatus => W::clear_transact_status(),
UniversalOrigin(j) => W::universal_origin(j),
ExportMessage { network, destination, xcm } =>
W::export_message(network, destination, xcm),
ExportMessage { network, destination, xcm } => {
W::export_message(network, destination, xcm)
},
LockAsset { asset, unlocker } => W::lock_asset(asset, unlocker),
UnlockAsset { asset, target } => W::unlock_asset(asset, target),
NoteUnlockable { asset, owner } => W::note_unlockable(asset, owner),
@@ -1273,8 +1297,9 @@ impl<Call, W: XcmWeightInfo<Call>> GetWeight<W> for Instruction<Call> {
SetTopic(topic) => W::set_topic(topic),
ClearTopic => W::clear_topic(),
AliasOrigin(location) => W::alias_origin(location),
UnpaidExecution { weight_limit, check_origin } =>
W::unpaid_execution(weight_limit, check_origin),
UnpaidExecution { weight_limit, check_origin } => {
W::unpaid_execution(weight_limit, check_origin)
},
}
}
}
@@ -1306,20 +1331,22 @@ impl<Call> TryFrom<NewInstruction<Call>> for Instruction<Call> {
WithdrawAsset(assets) => Self::WithdrawAsset(assets.try_into()?),
ReserveAssetDeposited(assets) => Self::ReserveAssetDeposited(assets.try_into()?),
ReceiveTeleportedAsset(assets) => Self::ReceiveTeleportedAsset(assets.try_into()?),
QueryResponse { query_id, response, max_weight, querier: Some(querier) } =>
QueryResponse { query_id, response, max_weight, querier: Some(querier) } => {
Self::QueryResponse {
query_id,
querier: querier.try_into()?,
response: response.try_into()?,
max_weight,
},
QueryResponse { query_id, response, max_weight, querier: None } =>
}
},
QueryResponse { query_id, response, max_weight, querier: None } => {
Self::QueryResponse {
query_id,
querier: None,
response: response.try_into()?,
max_weight,
},
}
},
TransferAsset { assets, beneficiary } => Self::TransferAsset {
assets: assets.try_into()?,
beneficiary: beneficiary.try_into()?,
@@ -1329,13 +1356,16 @@ impl<Call> TryFrom<NewInstruction<Call>> for Instruction<Call> {
dest: dest.try_into()?,
xcm: xcm.try_into()?,
},
HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity } =>
Self::HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity },
HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity } => {
Self::HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity }
},
HrmpChannelAccepted { recipient } => Self::HrmpChannelAccepted { recipient },
HrmpChannelClosing { initiator, sender, recipient } =>
Self::HrmpChannelClosing { initiator, sender, recipient },
Transact { origin_kind, require_weight_at_most, call } =>
Self::Transact { origin_kind, require_weight_at_most, call: call.into() },
HrmpChannelClosing { initiator, sender, recipient } => {
Self::HrmpChannelClosing { initiator, sender, recipient }
},
Transact { origin_kind, require_weight_at_most, call } => {
Self::Transact { origin_kind, require_weight_at_most, call: call.into() }
},
ReportError(response_info) => Self::ReportError(QueryResponseInfo {
query_id: response_info.query_id,
destination: response_info.destination.try_into().map_err(|_| ())?,
@@ -1396,21 +1426,26 @@ impl<Call> TryFrom<NewInstruction<Call>> for Instruction<Call> {
Self::ClaimAsset { assets, ticket }
},
Trap(code) => Self::Trap(code),
SubscribeVersion { query_id, max_response_weight } =>
Self::SubscribeVersion { query_id, max_response_weight },
SubscribeVersion { query_id, max_response_weight } => {
Self::SubscribeVersion { query_id, max_response_weight }
},
UnsubscribeVersion => Self::UnsubscribeVersion,
BurnAsset(assets) => Self::BurnAsset(assets.try_into()?),
ExpectAsset(assets) => Self::ExpectAsset(assets.try_into()?),
ExpectOrigin(maybe_origin) =>
Self::ExpectOrigin(maybe_origin.map(|origin| origin.try_into()).transpose()?),
ExpectOrigin(maybe_origin) => {
Self::ExpectOrigin(maybe_origin.map(|origin| origin.try_into()).transpose()?)
},
ExpectError(maybe_error) => Self::ExpectError(maybe_error),
ExpectTransactStatus(maybe_error_code) => Self::ExpectTransactStatus(maybe_error_code),
QueryPallet { module_name, response_info } =>
Self::QueryPallet { module_name, response_info: response_info.try_into()? },
ExpectPallet { index, name, module_name, crate_major, min_crate_minor } =>
Self::ExpectPallet { index, name, module_name, crate_major, min_crate_minor },
ReportTransactStatus(response_info) =>
Self::ReportTransactStatus(response_info.try_into()?),
QueryPallet { module_name, response_info } => {
Self::QueryPallet { module_name, response_info: response_info.try_into()? }
},
ExpectPallet { index, name, module_name, crate_major, min_crate_minor } => {
Self::ExpectPallet { index, name, module_name, crate_major, min_crate_minor }
},
ReportTransactStatus(response_info) => {
Self::ReportTransactStatus(response_info.try_into()?)
},
ClearTransactStatus => Self::ClearTransactStatus,
UniversalOrigin(junction) => Self::UniversalOrigin(junction.try_into()?),
ExportMessage { network, destination, xcm } => Self::ExportMessage {
@@ -1418,14 +1453,18 @@ impl<Call> TryFrom<NewInstruction<Call>> for Instruction<Call> {
destination: destination.try_into()?,
xcm: xcm.try_into()?,
},
LockAsset { asset, unlocker } =>
Self::LockAsset { asset: asset.try_into()?, unlocker: unlocker.try_into()? },
UnlockAsset { asset, target } =>
Self::UnlockAsset { asset: asset.try_into()?, target: target.try_into()? },
NoteUnlockable { asset, owner } =>
Self::NoteUnlockable { asset: asset.try_into()?, owner: owner.try_into()? },
RequestUnlock { asset, locker } =>
Self::RequestUnlock { asset: asset.try_into()?, locker: locker.try_into()? },
LockAsset { asset, unlocker } => {
Self::LockAsset { asset: asset.try_into()?, unlocker: unlocker.try_into()? }
},
UnlockAsset { asset, target } => {
Self::UnlockAsset { asset: asset.try_into()?, target: target.try_into()? }
},
NoteUnlockable { asset, owner } => {
Self::NoteUnlockable { asset: asset.try_into()?, owner: owner.try_into()? }
},
RequestUnlock { asset, locker } => {
Self::RequestUnlock { asset: asset.try_into()?, locker: locker.try_into()? }
},
SetFeesMode { jit_withdraw } => Self::SetFeesMode { jit_withdraw },
SetTopic(topic) => Self::SetTopic(topic),
ClearTopic => Self::ClearTopic,
+18 -11
View File
@@ -284,8 +284,9 @@ impl Decode for Fungibility {
match UncheckedFungibility::decode(input)? {
UncheckedFungibility::Fungible(a) if a != 0 => Ok(Self::Fungible(a)),
UncheckedFungibility::NonFungible(i) => Ok(Self::NonFungible(i)),
UncheckedFungibility::Fungible(_) =>
Err("Fungible asset of zero amount is not allowed".into()),
UncheckedFungibility::Fungible(_) => {
Err("Fungible asset of zero amount is not allowed".into())
},
}
}
}
@@ -628,8 +629,9 @@ impl From<Vec<MultiAsset>> for MultiAssets {
(
MultiAsset { fun: Fungibility::NonFungible(a_instance), id: a_id },
MultiAsset { fun: Fungibility::NonFungible(b_instance), id: b_id },
) if a_id == b_id && a_instance == b_instance =>
MultiAsset { fun: Fungibility::NonFungible(a_instance), id: a_id },
) if a_id == b_id && a_instance == b_instance => {
MultiAsset { fun: Fungibility::NonFungible(a_instance), id: a_id }
},
(to_push, to_remember) => {
res.push(to_push);
to_remember
@@ -710,7 +712,9 @@ impl MultiAssets {
},
(Fungibility::NonFungible(inst1), Fungibility::NonFungible(inst2))
if inst1 == inst2 =>
return,
{
return
},
_ => (),
}
}
@@ -818,8 +822,9 @@ impl TryFrom<NewWildMultiAsset> for WildMultiAsset {
use NewWildMultiAsset::*;
Ok(match new {
AllOf { id, fun } => Self::AllOf { id: id.try_into()?, fun: fun.try_into()? },
AllOfCounted { id, fun, count } =>
Self::AllOfCounted { id: id.try_into()?, fun: fun.try_into()?, count },
AllOfCounted { id, fun, count } => {
Self::AllOfCounted { id: id.try_into()?, fun: fun.try_into()?, count }
},
All => Self::All,
AllCounted(count) => Self::AllCounted(count),
})
@@ -832,8 +837,9 @@ impl WildMultiAsset {
use WildMultiAsset::*;
match self {
AllOfCounted { count: 0, .. } | AllCounted(0) => false,
AllOf { fun, id } | AllOfCounted { id, fun, .. } =>
inner.fun.is_kind(*fun) && &inner.id == id,
AllOf { fun, id } | AllOfCounted { id, fun, .. } => {
inner.fun.is_kind(*fun) && &inner.id == id
},
All | AllCounted(_) => true,
}
}
@@ -856,8 +862,9 @@ impl WildMultiAsset {
) -> Result<(), ()> {
use WildMultiAsset::*;
match self {
AllOf { ref mut id, .. } | AllOfCounted { ref mut id, .. } =>
id.reanchor(target, context),
AllOf { ref mut id, .. } | AllOfCounted { ref mut id, .. } => {
id.reanchor(target, context)
},
All | AllCounted(_) => Ok(()),
}
}
+3 -2
View File
@@ -224,8 +224,9 @@ impl TryFrom<NewError> for Error {
impl From<SendError> for Error {
fn from(e: SendError) -> Self {
match e {
SendError::NotApplicable | SendError::Unroutable | SendError::MissingArgument =>
Error::Unroutable,
SendError::NotApplicable | SendError::Unroutable | SendError::MissingArgument => {
Error::Unroutable
},
SendError::Transport(s) => Error::Transport(s),
SendError::DestinationUnsupported => Error::DestinationUnsupported,
SendError::ExceedsMaxMessageSize => Error::ExceedsMaxMessageSize,
+21 -13
View File
@@ -313,8 +313,9 @@ impl Decode for Fungibility {
match UncheckedFungibility::decode(input)? {
UncheckedFungibility::Fungible(a) if a != 0 => Ok(Self::Fungible(a)),
UncheckedFungibility::NonFungible(i) => Ok(Self::NonFungible(i)),
UncheckedFungibility::Fungible(_) =>
Err("Fungible asset of zero amount is not allowed".into()),
UncheckedFungibility::Fungible(_) => {
Err("Fungible asset of zero amount is not allowed".into())
},
}
}
}
@@ -677,8 +678,9 @@ impl From<Vec<Asset>> for Assets {
(
Asset { fun: Fungibility::NonFungible(a_instance), id: a_id },
Asset { fun: Fungibility::NonFungible(b_instance), id: b_id },
) if a_id == b_id && a_instance == b_instance =>
Asset { fun: Fungibility::NonFungible(a_instance), id: a_id },
) if a_id == b_id && a_instance == b_instance => {
Asset { fun: Fungibility::NonFungible(a_instance), id: a_id }
},
(to_push, to_remember) => {
res.push(to_push);
to_remember
@@ -758,7 +760,9 @@ impl Assets {
},
(Fungibility::NonFungible(inst1), Fungibility::NonFungible(inst2))
if inst1 == inst2 =>
return,
{
return
},
_ => (),
}
}
@@ -868,8 +872,9 @@ impl TryFrom<OldWildAsset> for WildAsset {
Ok(match old {
AllOf { id, fun } => Self::AllOf { id: id.try_into()?, fun: fun.try_into()? },
All => Self::All,
AllOfCounted { id, fun, count } =>
Self::AllOfCounted { id: id.try_into()?, fun: fun.try_into()?, count },
AllOfCounted { id, fun, count } => {
Self::AllOfCounted { id: id.try_into()?, fun: fun.try_into()?, count }
},
AllCounted(count) => Self::AllCounted(count),
})
}
@@ -881,8 +886,9 @@ impl TryFrom<NewWildAsset> for WildAsset {
use NewWildAsset::*;
Ok(match new {
AllOf { id, fun } => Self::AllOf { id: id.try_into()?, fun: fun.try_into()? },
AllOfCounted { id, fun, count } =>
Self::AllOfCounted { id: id.try_into()?, fun: fun.try_into()?, count },
AllOfCounted { id, fun, count } => {
Self::AllOfCounted { id: id.try_into()?, fun: fun.try_into()?, count }
},
All => Self::All,
AllCounted(count) => Self::AllCounted(count),
})
@@ -895,8 +901,9 @@ impl WildAsset {
use WildAsset::*;
match self {
AllOfCounted { count: 0, .. } | AllCounted(0) => false,
AllOf { fun, id } | AllOfCounted { id, fun, .. } =>
inner.fun.is_kind(*fun) && &inner.id == id,
AllOf { fun, id } | AllOfCounted { id, fun, .. } => {
inner.fun.is_kind(*fun) && &inner.id == id
},
All | AllCounted(_) => true,
}
}
@@ -915,8 +922,9 @@ impl WildAsset {
pub fn reanchor(&mut self, target: &Location, context: &InteriorLocation) -> Result<(), ()> {
use WildAsset::*;
match self {
AllOf { ref mut id, .. } | AllOfCounted { ref mut id, .. } =>
id.reanchor(target, context),
AllOf { ref mut id, .. } | AllOfCounted { ref mut id, .. } => {
id.reanchor(target, context)
},
All | AllCounted(_) => Ok(()),
}
}
+24 -17
View File
@@ -230,8 +230,9 @@ impl<'a> TryFrom<&'a Junction> for BoundedSlice<'a, u8, ConstU32<32>> {
type Error = ();
fn try_from(key: &'a Junction) -> Result<Self, ()> {
match key {
Junction::GeneralKey { length, data } =>
BoundedSlice::try_from(&data[..data.len().min(*length as usize)]).map_err(|_| ()),
Junction::GeneralKey { length, data } => {
BoundedSlice::try_from(&data[..data.len().min(*length as usize)]).map_err(|_| ())
},
_ => Err(()),
}
}
@@ -261,12 +262,15 @@ impl TryFrom<OldJunction> for Junction {
use OldJunction::*;
Ok(match value {
Teyrchain(id) => Self::Teyrchain(id),
AccountId32 { network: maybe_network, id } =>
Self::AccountId32 { network: maybe_network.map(|network| network.into()), id },
AccountIndex64 { network: maybe_network, index } =>
Self::AccountIndex64 { network: maybe_network.map(|network| network.into()), index },
AccountKey20 { network: maybe_network, key } =>
Self::AccountKey20 { network: maybe_network.map(|network| network.into()), key },
AccountId32 { network: maybe_network, id } => {
Self::AccountId32 { network: maybe_network.map(|network| network.into()), id }
},
AccountIndex64 { network: maybe_network, index } => {
Self::AccountIndex64 { network: maybe_network.map(|network| network.into()), index }
},
AccountKey20 { network: maybe_network, key } => {
Self::AccountKey20 { network: maybe_network.map(|network| network.into()), key }
},
PalletInstance(index) => Self::PalletInstance(index),
GeneralIndex(id) => Self::GeneralIndex(id),
GeneralKey { length, data } => Self::GeneralKey { length, data },
@@ -284,12 +288,15 @@ impl TryFrom<NewJunction> for Junction {
use NewJunction::*;
Ok(match value {
Teyrchain(id) => Self::Teyrchain(id),
AccountId32 { network: maybe_network, id } =>
Self::AccountId32 { network: maybe_network.map(|network| network.into()), id },
AccountIndex64 { network: maybe_network, index } =>
Self::AccountIndex64 { network: maybe_network.map(|network| network.into()), index },
AccountKey20 { network: maybe_network, key } =>
Self::AccountKey20 { network: maybe_network.map(|network| network.into()), key },
AccountId32 { network: maybe_network, id } => {
Self::AccountId32 { network: maybe_network.map(|network| network.into()), id }
},
AccountIndex64 { network: maybe_network, index } => {
Self::AccountIndex64 { network: maybe_network.map(|network| network.into()), index }
},
AccountKey20 { network: maybe_network, key } => {
Self::AccountKey20 { network: maybe_network.map(|network| network.into()), key }
},
PalletInstance(index) => Self::PalletInstance(index),
GeneralIndex(id) => Self::GeneralIndex(id),
GeneralKey { length, data } => Self::GeneralKey { length, data },
@@ -327,9 +334,9 @@ impl Junction {
pub fn remove_network_id(&mut self) {
use Junction::*;
match self {
AccountId32 { ref mut network, .. } |
AccountIndex64 { ref mut network, .. } |
AccountKey20 { ref mut network, .. } => *network = None,
AccountId32 { ref mut network, .. }
| AccountIndex64 { ref mut network, .. }
| AccountKey20 { ref mut network, .. } => *network = None,
_ => {},
}
}
+145 -98
View File
@@ -313,8 +313,9 @@ impl TryFrom<OldResponse> for Response {
Ok(match old {
Null => Self::Null,
Assets(assets) => Self::Assets(assets.try_into()?),
ExecutionResult(result) =>
Self::ExecutionResult(result.map(|(num, old_error)| (num, old_error.into()))),
ExecutionResult(result) => {
Self::ExecutionResult(result.map(|(num, old_error)| (num, old_error.into())))
},
Version(version) => Self::Version(version),
PalletsInfo(pezpallet_info) => {
let inner = pezpallet_info
@@ -354,8 +355,9 @@ impl TryFrom<NewResponse> for Response {
BoundedVec::<PalletInfo, MaxPalletsInfo>::try_from(inner).map_err(|_| ())?,
)
},
DispatchResult(maybe_error) =>
Self::DispatchResult(maybe_error.try_into().map_err(|_| ())?),
DispatchResult(maybe_error) => {
Self::DispatchResult(maybe_error.try_into().map_err(|_| ())?)
},
})
}
}
@@ -1111,24 +1113,30 @@ impl<Call> Instruction<Call> {
WithdrawAsset(assets) => WithdrawAsset(assets),
ReserveAssetDeposited(assets) => ReserveAssetDeposited(assets),
ReceiveTeleportedAsset(assets) => ReceiveTeleportedAsset(assets),
QueryResponse { query_id, response, max_weight, querier } =>
QueryResponse { query_id, response, max_weight, querier },
QueryResponse { query_id, response, max_weight, querier } => {
QueryResponse { query_id, response, max_weight, querier }
},
TransferAsset { assets, beneficiary } => TransferAsset { assets, beneficiary },
TransferReserveAsset { assets, dest, xcm } =>
TransferReserveAsset { assets, dest, xcm },
HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity } =>
HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity },
TransferReserveAsset { assets, dest, xcm } => {
TransferReserveAsset { assets, dest, xcm }
},
HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity } => {
HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity }
},
HrmpChannelAccepted { recipient } => HrmpChannelAccepted { recipient },
HrmpChannelClosing { initiator, sender, recipient } =>
HrmpChannelClosing { initiator, sender, recipient },
Transact { origin_kind, require_weight_at_most, call } =>
Transact { origin_kind, require_weight_at_most, call: call.into() },
HrmpChannelClosing { initiator, sender, recipient } => {
HrmpChannelClosing { initiator, sender, recipient }
},
Transact { origin_kind, require_weight_at_most, call } => {
Transact { origin_kind, require_weight_at_most, call: call.into() }
},
ReportError(response_info) => ReportError(response_info),
DepositAsset { assets, beneficiary } => DepositAsset { assets, beneficiary },
DepositReserveAsset { assets, dest, xcm } => DepositReserveAsset { assets, dest, xcm },
ExchangeAsset { give, want, maximal } => ExchangeAsset { give, want, maximal },
InitiateReserveWithdraw { assets, reserve, xcm } =>
InitiateReserveWithdraw { assets, reserve, xcm },
InitiateReserveWithdraw { assets, reserve, xcm } => {
InitiateReserveWithdraw { assets, reserve, xcm }
},
InitiateTeleport { assets, dest, xcm } => InitiateTeleport { assets, dest, xcm },
ReportHolding { response_info, assets } => ReportHolding { response_info, assets },
BuyExecution { fees, weight_limit } => BuyExecution { fees, weight_limit },
@@ -1140,23 +1148,27 @@ impl<Call> Instruction<Call> {
ClearError => ClearError,
ClaimAsset { assets, ticket } => ClaimAsset { assets, ticket },
Trap(code) => Trap(code),
SubscribeVersion { query_id, max_response_weight } =>
SubscribeVersion { query_id, max_response_weight },
SubscribeVersion { query_id, max_response_weight } => {
SubscribeVersion { query_id, max_response_weight }
},
UnsubscribeVersion => UnsubscribeVersion,
BurnAsset(assets) => BurnAsset(assets),
ExpectAsset(assets) => ExpectAsset(assets),
ExpectOrigin(origin) => ExpectOrigin(origin),
ExpectError(error) => ExpectError(error),
ExpectTransactStatus(transact_status) => ExpectTransactStatus(transact_status),
QueryPallet { module_name, response_info } =>
QueryPallet { module_name, response_info },
ExpectPallet { index, name, module_name, crate_major, min_crate_minor } =>
ExpectPallet { index, name, module_name, crate_major, min_crate_minor },
QueryPallet { module_name, response_info } => {
QueryPallet { module_name, response_info }
},
ExpectPallet { index, name, module_name, crate_major, min_crate_minor } => {
ExpectPallet { index, name, module_name, crate_major, min_crate_minor }
},
ReportTransactStatus(response_info) => ReportTransactStatus(response_info),
ClearTransactStatus => ClearTransactStatus,
UniversalOrigin(j) => UniversalOrigin(j),
ExportMessage { network, destination, xcm } =>
ExportMessage { network, destination, xcm },
ExportMessage { network, destination, xcm } => {
ExportMessage { network, destination, xcm }
},
LockAsset { asset, unlocker } => LockAsset { asset, unlocker },
UnlockAsset { asset, target } => UnlockAsset { asset, target },
NoteUnlockable { asset, owner } => NoteUnlockable { asset, owner },
@@ -1165,8 +1177,9 @@ impl<Call> Instruction<Call> {
SetTopic(topic) => SetTopic(topic),
ClearTopic => ClearTopic,
AliasOrigin(location) => AliasOrigin(location),
UnpaidExecution { weight_limit, check_origin } =>
UnpaidExecution { weight_limit, check_origin },
UnpaidExecution { weight_limit, check_origin } => {
UnpaidExecution { weight_limit, check_origin }
},
}
}
}
@@ -1179,27 +1192,34 @@ impl<Call, W: XcmWeightInfo<Call>> GetWeight<W> for Instruction<Call> {
WithdrawAsset(assets) => W::withdraw_asset(assets),
ReserveAssetDeposited(assets) => W::reserve_asset_deposited(assets),
ReceiveTeleportedAsset(assets) => W::receive_teleported_asset(assets),
QueryResponse { query_id, response, max_weight, querier } =>
W::query_response(query_id, response, max_weight, querier),
QueryResponse { query_id, response, max_weight, querier } => {
W::query_response(query_id, response, max_weight, querier)
},
TransferAsset { assets, beneficiary } => W::transfer_asset(assets, beneficiary),
TransferReserveAsset { assets, dest, xcm } =>
W::transfer_reserve_asset(&assets, dest, xcm),
Transact { origin_kind, require_weight_at_most, call } =>
W::transact(origin_kind, require_weight_at_most, call),
HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity } =>
W::hrmp_new_channel_open_request(sender, max_message_size, max_capacity),
TransferReserveAsset { assets, dest, xcm } => {
W::transfer_reserve_asset(&assets, dest, xcm)
},
Transact { origin_kind, require_weight_at_most, call } => {
W::transact(origin_kind, require_weight_at_most, call)
},
HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity } => {
W::hrmp_new_channel_open_request(sender, max_message_size, max_capacity)
},
HrmpChannelAccepted { recipient } => W::hrmp_channel_accepted(recipient),
HrmpChannelClosing { initiator, sender, recipient } =>
W::hrmp_channel_closing(initiator, sender, recipient),
HrmpChannelClosing { initiator, sender, recipient } => {
W::hrmp_channel_closing(initiator, sender, recipient)
},
ClearOrigin => W::clear_origin(),
DescendOrigin(who) => W::descend_origin(who),
ReportError(response_info) => W::report_error(&response_info),
DepositAsset { assets, beneficiary } => W::deposit_asset(assets, beneficiary),
DepositReserveAsset { assets, dest, xcm } =>
W::deposit_reserve_asset(assets, dest, xcm),
DepositReserveAsset { assets, dest, xcm } => {
W::deposit_reserve_asset(assets, dest, xcm)
},
ExchangeAsset { give, want, maximal } => W::exchange_asset(give, want, maximal),
InitiateReserveWithdraw { assets, reserve, xcm } =>
W::initiate_reserve_withdraw(assets, reserve, xcm),
InitiateReserveWithdraw { assets, reserve, xcm } => {
W::initiate_reserve_withdraw(assets, reserve, xcm)
},
InitiateTeleport { assets, dest, xcm } => W::initiate_teleport(assets, dest, xcm),
ReportHolding { response_info, assets } => W::report_holding(&response_info, &assets),
BuyExecution { fees, weight_limit } => W::buy_execution(fees, weight_limit),
@@ -1209,23 +1229,27 @@ impl<Call, W: XcmWeightInfo<Call>> GetWeight<W> for Instruction<Call> {
ClearError => W::clear_error(),
ClaimAsset { assets, ticket } => W::claim_asset(assets, ticket),
Trap(code) => W::trap(code),
SubscribeVersion { query_id, max_response_weight } =>
W::subscribe_version(query_id, max_response_weight),
SubscribeVersion { query_id, max_response_weight } => {
W::subscribe_version(query_id, max_response_weight)
},
UnsubscribeVersion => W::unsubscribe_version(),
BurnAsset(assets) => W::burn_asset(assets),
ExpectAsset(assets) => W::expect_asset(assets),
ExpectOrigin(origin) => W::expect_origin(origin),
ExpectError(error) => W::expect_error(error),
ExpectTransactStatus(transact_status) => W::expect_transact_status(transact_status),
QueryPallet { module_name, response_info } =>
W::query_pallet(module_name, response_info),
ExpectPallet { index, name, module_name, crate_major, min_crate_minor } =>
W::expect_pallet(index, name, module_name, crate_major, min_crate_minor),
QueryPallet { module_name, response_info } => {
W::query_pallet(module_name, response_info)
},
ExpectPallet { index, name, module_name, crate_major, min_crate_minor } => {
W::expect_pallet(index, name, module_name, crate_major, min_crate_minor)
},
ReportTransactStatus(response_info) => W::report_transact_status(response_info),
ClearTransactStatus => W::clear_transact_status(),
UniversalOrigin(j) => W::universal_origin(j),
ExportMessage { network, destination, xcm } =>
W::export_message(network, destination, xcm),
ExportMessage { network, destination, xcm } => {
W::export_message(network, destination, xcm)
},
LockAsset { asset, unlocker } => W::lock_asset(asset, unlocker),
UnlockAsset { asset, target } => W::unlock_asset(asset, target),
NoteUnlockable { asset, owner } => W::note_unlockable(asset, owner),
@@ -1234,8 +1258,9 @@ impl<Call, W: XcmWeightInfo<Call>> GetWeight<W> for Instruction<Call> {
SetTopic(topic) => W::set_topic(topic),
ClearTopic => W::clear_topic(),
AliasOrigin(location) => W::alias_origin(location),
UnpaidExecution { weight_limit, check_origin } =>
W::unpaid_execution(weight_limit, check_origin),
UnpaidExecution { weight_limit, check_origin } => {
W::unpaid_execution(weight_limit, check_origin)
},
}
}
}
@@ -1275,20 +1300,22 @@ impl<Call: Decode + GetDispatchInfo> TryFrom<NewInstruction<Call>> for Instructi
WithdrawAsset(assets) => Self::WithdrawAsset(assets.try_into()?),
ReserveAssetDeposited(assets) => Self::ReserveAssetDeposited(assets.try_into()?),
ReceiveTeleportedAsset(assets) => Self::ReceiveTeleportedAsset(assets.try_into()?),
QueryResponse { query_id, response, max_weight, querier: Some(querier) } =>
QueryResponse { query_id, response, max_weight, querier: Some(querier) } => {
Self::QueryResponse {
query_id,
querier: querier.try_into()?,
response: response.try_into()?,
max_weight,
},
QueryResponse { query_id, response, max_weight, querier: None } =>
}
},
QueryResponse { query_id, response, max_weight, querier: None } => {
Self::QueryResponse {
query_id,
querier: None,
response: response.try_into()?,
max_weight,
},
}
},
TransferAsset { assets, beneficiary } => Self::TransferAsset {
assets: assets.try_into()?,
beneficiary: beneficiary.try_into()?,
@@ -1298,11 +1325,13 @@ impl<Call: Decode + GetDispatchInfo> TryFrom<NewInstruction<Call>> for Instructi
dest: dest.try_into()?,
xcm: xcm.try_into()?,
},
HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity } =>
Self::HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity },
HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity } => {
Self::HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity }
},
HrmpChannelAccepted { recipient } => Self::HrmpChannelAccepted { recipient },
HrmpChannelClosing { initiator, sender, recipient } =>
Self::HrmpChannelClosing { initiator, sender, recipient },
HrmpChannelClosing { initiator, sender, recipient } => {
Self::HrmpChannelClosing { initiator, sender, recipient }
},
Transact { origin_kind, mut call, fallback_max_weight } => {
// We first try to decode the call, if we can't, we use the fallback weight,
// if there's no fallback, we just return `Weight::MAX`.
@@ -1381,13 +1410,15 @@ impl<Call: Decode + GetDispatchInfo> TryFrom<NewInstruction<Call>> for Instructi
Self::ClaimAsset { assets, ticket }
},
Trap(code) => Self::Trap(code),
SubscribeVersion { query_id, max_response_weight } =>
Self::SubscribeVersion { query_id, max_response_weight },
SubscribeVersion { query_id, max_response_weight } => {
Self::SubscribeVersion { query_id, max_response_weight }
},
UnsubscribeVersion => Self::UnsubscribeVersion,
BurnAsset(assets) => Self::BurnAsset(assets.try_into()?),
ExpectAsset(assets) => Self::ExpectAsset(assets.try_into()?),
ExpectOrigin(maybe_origin) =>
Self::ExpectOrigin(maybe_origin.map(|origin| origin.try_into()).transpose()?),
ExpectOrigin(maybe_origin) => {
Self::ExpectOrigin(maybe_origin.map(|origin| origin.try_into()).transpose()?)
},
ExpectError(maybe_error) => Self::ExpectError(
maybe_error
.map(|(num, new_error)| (num, new_error.try_into()))
@@ -1395,12 +1426,15 @@ impl<Call: Decode + GetDispatchInfo> TryFrom<NewInstruction<Call>> for Instructi
.transpose()?,
),
ExpectTransactStatus(maybe_error_code) => Self::ExpectTransactStatus(maybe_error_code),
QueryPallet { module_name, response_info } =>
Self::QueryPallet { module_name, response_info: response_info.try_into()? },
ExpectPallet { index, name, module_name, crate_major, min_crate_minor } =>
Self::ExpectPallet { index, name, module_name, crate_major, min_crate_minor },
ReportTransactStatus(response_info) =>
Self::ReportTransactStatus(response_info.try_into()?),
QueryPallet { module_name, response_info } => {
Self::QueryPallet { module_name, response_info: response_info.try_into()? }
},
ExpectPallet { index, name, module_name, crate_major, min_crate_minor } => {
Self::ExpectPallet { index, name, module_name, crate_major, min_crate_minor }
},
ReportTransactStatus(response_info) => {
Self::ReportTransactStatus(response_info.try_into()?)
},
ClearTransactStatus => Self::ClearTransactStatus,
UniversalOrigin(junction) => Self::UniversalOrigin(junction.try_into()?),
ExportMessage { network, destination, xcm } => Self::ExportMessage {
@@ -1408,14 +1442,18 @@ impl<Call: Decode + GetDispatchInfo> TryFrom<NewInstruction<Call>> for Instructi
destination: destination.try_into()?,
xcm: xcm.try_into()?,
},
LockAsset { asset, unlocker } =>
Self::LockAsset { asset: asset.try_into()?, unlocker: unlocker.try_into()? },
UnlockAsset { asset, target } =>
Self::UnlockAsset { asset: asset.try_into()?, target: target.try_into()? },
NoteUnlockable { asset, owner } =>
Self::NoteUnlockable { asset: asset.try_into()?, owner: owner.try_into()? },
RequestUnlock { asset, locker } =>
Self::RequestUnlock { asset: asset.try_into()?, locker: locker.try_into()? },
LockAsset { asset, unlocker } => {
Self::LockAsset { asset: asset.try_into()?, unlocker: unlocker.try_into()? }
},
UnlockAsset { asset, target } => {
Self::UnlockAsset { asset: asset.try_into()?, target: target.try_into()? }
},
NoteUnlockable { asset, owner } => {
Self::NoteUnlockable { asset: asset.try_into()?, owner: owner.try_into()? }
},
RequestUnlock { asset, locker } => {
Self::RequestUnlock { asset: asset.try_into()?, locker: locker.try_into()? }
},
SetFeesMode { jit_withdraw } => Self::SetFeesMode { jit_withdraw },
SetTopic(topic) => Self::SetTopic(topic),
ClearTopic => Self::ClearTopic,
@@ -1424,10 +1462,10 @@ impl<Call: Decode + GetDispatchInfo> TryFrom<NewInstruction<Call>> for Instructi
weight_limit,
check_origin: check_origin.map(|origin| origin.try_into()).transpose()?,
},
InitiateTransfer { .. } |
PayFees { .. } |
SetHints { .. } |
ExecuteWithOrigin { .. } => {
InitiateTransfer { .. }
| PayFees { .. }
| SetHints { .. }
| ExecuteWithOrigin { .. } => {
tracing::debug!(target: "xcm::versions::v5tov4", ?new_instruction, "not supported by v4");
return Err(());
},
@@ -1444,20 +1482,22 @@ impl<Call> TryFrom<OldInstruction<Call>> for Instruction<Call> {
WithdrawAsset(assets) => Self::WithdrawAsset(assets.try_into()?),
ReserveAssetDeposited(assets) => Self::ReserveAssetDeposited(assets.try_into()?),
ReceiveTeleportedAsset(assets) => Self::ReceiveTeleportedAsset(assets.try_into()?),
QueryResponse { query_id, response, max_weight, querier: Some(querier) } =>
QueryResponse { query_id, response, max_weight, querier: Some(querier) } => {
Self::QueryResponse {
query_id,
querier: querier.try_into()?,
response: response.try_into()?,
max_weight,
},
QueryResponse { query_id, response, max_weight, querier: None } =>
}
},
QueryResponse { query_id, response, max_weight, querier: None } => {
Self::QueryResponse {
query_id,
querier: None,
response: response.try_into()?,
max_weight,
},
}
},
TransferAsset { assets, beneficiary } => Self::TransferAsset {
assets: assets.try_into()?,
beneficiary: beneficiary.try_into()?,
@@ -1467,13 +1507,16 @@ impl<Call> TryFrom<OldInstruction<Call>> for Instruction<Call> {
dest: dest.try_into()?,
xcm: xcm.try_into()?,
},
HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity } =>
Self::HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity },
HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity } => {
Self::HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity }
},
HrmpChannelAccepted { recipient } => Self::HrmpChannelAccepted { recipient },
HrmpChannelClosing { initiator, sender, recipient } =>
Self::HrmpChannelClosing { initiator, sender, recipient },
Transact { origin_kind, require_weight_at_most, call } =>
Self::Transact { origin_kind, require_weight_at_most, call: call.into() },
HrmpChannelClosing { initiator, sender, recipient } => {
Self::HrmpChannelClosing { initiator, sender, recipient }
},
Transact { origin_kind, require_weight_at_most, call } => {
Self::Transact { origin_kind, require_weight_at_most, call: call.into() }
},
ReportError(response_info) => Self::ReportError(QueryResponseInfo {
query_id: response_info.query_id,
destination: response_info.destination.try_into().map_err(|_| ())?,
@@ -1532,8 +1575,9 @@ impl<Call> TryFrom<OldInstruction<Call>> for Instruction<Call> {
Self::ClaimAsset { assets, ticket }
},
Trap(code) => Self::Trap(code),
SubscribeVersion { query_id, max_response_weight } =>
Self::SubscribeVersion { query_id, max_response_weight },
SubscribeVersion { query_id, max_response_weight } => {
Self::SubscribeVersion { query_id, max_response_weight }
},
UnsubscribeVersion => Self::UnsubscribeVersion,
BurnAsset(assets) => Self::BurnAsset(assets.try_into()?),
ExpectAsset(assets) => Self::ExpectAsset(assets.try_into()?),
@@ -1548,13 +1592,16 @@ impl<Call> TryFrom<OldInstruction<Call>> for Instruction<Call> {
module_name,
response_info: response_info.try_into().map_err(|_| ())?,
},
ExpectPallet { index, name, module_name, crate_major, min_crate_minor } =>
Self::ExpectPallet { index, name, module_name, crate_major, min_crate_minor },
ReportTransactStatus(response_info) =>
Self::ReportTransactStatus(response_info.try_into().map_err(|_| ())?),
ExpectPallet { index, name, module_name, crate_major, min_crate_minor } => {
Self::ExpectPallet { index, name, module_name, crate_major, min_crate_minor }
},
ReportTransactStatus(response_info) => {
Self::ReportTransactStatus(response_info.try_into().map_err(|_| ())?)
},
ClearTransactStatus => Self::ClearTransactStatus,
UniversalOrigin(junction) =>
Self::UniversalOrigin(junction.try_into().map_err(|_| ())?),
UniversalOrigin(junction) => {
Self::UniversalOrigin(junction.try_into().map_err(|_| ())?)
},
ExportMessage { network, destination, xcm } => Self::ExportMessage {
network: network.into(),
destination: destination.try_into().map_err(|_| ())?,
+18 -11
View File
@@ -280,8 +280,9 @@ impl Decode for Fungibility {
match UncheckedFungibility::decode(input)? {
UncheckedFungibility::Fungible(a) if a != 0 => Ok(Self::Fungible(a)),
UncheckedFungibility::NonFungible(i) => Ok(Self::NonFungible(i)),
UncheckedFungibility::Fungible(_) =>
Err("Fungible asset of zero amount is not allowed".into()),
UncheckedFungibility::Fungible(_) => {
Err("Fungible asset of zero amount is not allowed".into())
},
}
}
}
@@ -603,8 +604,9 @@ impl From<Vec<Asset>> for Assets {
(
Asset { fun: Fungibility::NonFungible(a_instance), id: a_id },
Asset { fun: Fungibility::NonFungible(b_instance), id: b_id },
) if a_id == b_id && a_instance == b_instance =>
Asset { fun: Fungibility::NonFungible(a_instance), id: a_id },
) if a_id == b_id && a_instance == b_instance => {
Asset { fun: Fungibility::NonFungible(a_instance), id: a_id }
},
(to_push, to_remember) => {
res.push(to_push);
to_remember
@@ -684,7 +686,9 @@ impl Assets {
},
(Fungibility::NonFungible(inst1), Fungibility::NonFungible(inst2))
if inst1 == inst2 =>
return,
{
return
},
_ => (),
}
}
@@ -794,8 +798,9 @@ impl TryFrom<OldWildAsset> for WildAsset {
Ok(match old {
AllOf { id, fun } => Self::AllOf { id: id.try_into()?, fun: fun.try_into()? },
All => Self::All,
AllOfCounted { id, fun, count } =>
Self::AllOfCounted { id: id.try_into()?, fun: fun.try_into()?, count },
AllOfCounted { id, fun, count } => {
Self::AllOfCounted { id: id.try_into()?, fun: fun.try_into()?, count }
},
AllCounted(count) => Self::AllCounted(count),
})
}
@@ -807,8 +812,9 @@ impl WildAsset {
use WildAsset::*;
match self {
AllOfCounted { count: 0, .. } | AllCounted(0) => false,
AllOf { fun, id } | AllOfCounted { id, fun, .. } =>
inner.fun.is_kind(*fun) && &inner.id == id,
AllOf { fun, id } | AllOfCounted { id, fun, .. } => {
inner.fun.is_kind(*fun) && &inner.id == id
},
All | AllCounted(_) => true,
}
}
@@ -827,8 +833,9 @@ impl WildAsset {
pub fn reanchor(&mut self, target: &Location, context: &InteriorLocation) -> Result<(), ()> {
use WildAsset::*;
match self {
AllOf { ref mut id, .. } | AllOfCounted { ref mut id, .. } =>
id.reanchor(target, context),
AllOf { ref mut id, .. } | AllOfCounted { ref mut id, .. } => {
id.reanchor(target, context)
},
All | AllCounted(_) => Ok(()),
}
}
+15 -11
View File
@@ -217,8 +217,9 @@ impl<'a> TryFrom<&'a Junction> for BoundedSlice<'a, u8, ConstU32<32>> {
type Error = ();
fn try_from(key: &'a Junction) -> Result<Self, ()> {
match key {
Junction::GeneralKey { length, data } =>
BoundedSlice::try_from(&data[..data.len().min(*length as usize)]).map_err(|_| ()),
Junction::GeneralKey { length, data } => {
BoundedSlice::try_from(&data[..data.len().min(*length as usize)]).map_err(|_| ())
},
_ => Err(()),
}
}
@@ -248,12 +249,15 @@ impl TryFrom<OldJunction> for Junction {
use OldJunction::*;
Ok(match value {
Teyrchain(id) => Self::Teyrchain(id),
AccountId32 { network: maybe_network, id } =>
Self::AccountId32 { network: maybe_network.map(|network| network.into()), id },
AccountIndex64 { network: maybe_network, index } =>
Self::AccountIndex64 { network: maybe_network.map(|network| network.into()), index },
AccountKey20 { network: maybe_network, key } =>
Self::AccountKey20 { network: maybe_network.map(|network| network.into()), key },
AccountId32 { network: maybe_network, id } => {
Self::AccountId32 { network: maybe_network.map(|network| network.into()), id }
},
AccountIndex64 { network: maybe_network, index } => {
Self::AccountIndex64 { network: maybe_network.map(|network| network.into()), index }
},
AccountKey20 { network: maybe_network, key } => {
Self::AccountKey20 { network: maybe_network.map(|network| network.into()), key }
},
PalletInstance(index) => Self::PalletInstance(index),
GeneralIndex(id) => Self::GeneralIndex(id),
GeneralKey { length, data } => Self::GeneralKey { length, data },
@@ -291,9 +295,9 @@ impl Junction {
pub fn remove_network_id(&mut self) {
use Junction::*;
match self {
AccountId32 { ref mut network, .. } |
AccountIndex64 { ref mut network, .. } |
AccountKey20 { ref mut network, .. } => *network = None,
AccountId32 { ref mut network, .. }
| AccountIndex64 { ref mut network, .. }
| AccountKey20 { ref mut network, .. } => *network = None,
_ => {},
}
}
+105 -70
View File
@@ -1179,24 +1179,30 @@ impl<Call> Instruction<Call> {
WithdrawAsset(assets) => WithdrawAsset(assets),
ReserveAssetDeposited(assets) => ReserveAssetDeposited(assets),
ReceiveTeleportedAsset(assets) => ReceiveTeleportedAsset(assets),
QueryResponse { query_id, response, max_weight, querier } =>
QueryResponse { query_id, response, max_weight, querier },
QueryResponse { query_id, response, max_weight, querier } => {
QueryResponse { query_id, response, max_weight, querier }
},
TransferAsset { assets, beneficiary } => TransferAsset { assets, beneficiary },
TransferReserveAsset { assets, dest, xcm } =>
TransferReserveAsset { assets, dest, xcm },
HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity } =>
HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity },
TransferReserveAsset { assets, dest, xcm } => {
TransferReserveAsset { assets, dest, xcm }
},
HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity } => {
HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity }
},
HrmpChannelAccepted { recipient } => HrmpChannelAccepted { recipient },
HrmpChannelClosing { initiator, sender, recipient } =>
HrmpChannelClosing { initiator, sender, recipient },
Transact { origin_kind, call, fallback_max_weight } =>
Transact { origin_kind, call: call.into(), fallback_max_weight },
HrmpChannelClosing { initiator, sender, recipient } => {
HrmpChannelClosing { initiator, sender, recipient }
},
Transact { origin_kind, call, fallback_max_weight } => {
Transact { origin_kind, call: call.into(), fallback_max_weight }
},
ReportError(response_info) => ReportError(response_info),
DepositAsset { assets, beneficiary } => DepositAsset { assets, beneficiary },
DepositReserveAsset { assets, dest, xcm } => DepositReserveAsset { assets, dest, xcm },
ExchangeAsset { give, want, maximal } => ExchangeAsset { give, want, maximal },
InitiateReserveWithdraw { assets, reserve, xcm } =>
InitiateReserveWithdraw { assets, reserve, xcm },
InitiateReserveWithdraw { assets, reserve, xcm } => {
InitiateReserveWithdraw { assets, reserve, xcm }
},
InitiateTeleport { assets, dest, xcm } => InitiateTeleport { assets, dest, xcm },
ReportHolding { response_info, assets } => ReportHolding { response_info, assets },
BuyExecution { fees, weight_limit } => BuyExecution { fees, weight_limit },
@@ -1209,23 +1215,27 @@ impl<Call> Instruction<Call> {
SetHints { hints } => SetHints { hints },
ClaimAsset { assets, ticket } => ClaimAsset { assets, ticket },
Trap(code) => Trap(code),
SubscribeVersion { query_id, max_response_weight } =>
SubscribeVersion { query_id, max_response_weight },
SubscribeVersion { query_id, max_response_weight } => {
SubscribeVersion { query_id, max_response_weight }
},
UnsubscribeVersion => UnsubscribeVersion,
BurnAsset(assets) => BurnAsset(assets),
ExpectAsset(assets) => ExpectAsset(assets),
ExpectOrigin(origin) => ExpectOrigin(origin),
ExpectError(error) => ExpectError(error),
ExpectTransactStatus(transact_status) => ExpectTransactStatus(transact_status),
QueryPallet { module_name, response_info } =>
QueryPallet { module_name, response_info },
ExpectPallet { index, name, module_name, crate_major, min_crate_minor } =>
ExpectPallet { index, name, module_name, crate_major, min_crate_minor },
QueryPallet { module_name, response_info } => {
QueryPallet { module_name, response_info }
},
ExpectPallet { index, name, module_name, crate_major, min_crate_minor } => {
ExpectPallet { index, name, module_name, crate_major, min_crate_minor }
},
ReportTransactStatus(response_info) => ReportTransactStatus(response_info),
ClearTransactStatus => ClearTransactStatus,
UniversalOrigin(j) => UniversalOrigin(j),
ExportMessage { network, destination, xcm } =>
ExportMessage { network, destination, xcm },
ExportMessage { network, destination, xcm } => {
ExportMessage { network, destination, xcm }
},
LockAsset { asset, unlocker } => LockAsset { asset, unlocker },
UnlockAsset { asset, target } => UnlockAsset { asset, target },
NoteUnlockable { asset, owner } => NoteUnlockable { asset, owner },
@@ -1234,13 +1244,16 @@ impl<Call> Instruction<Call> {
SetTopic(topic) => SetTopic(topic),
ClearTopic => ClearTopic,
AliasOrigin(location) => AliasOrigin(location),
UnpaidExecution { weight_limit, check_origin } =>
UnpaidExecution { weight_limit, check_origin },
UnpaidExecution { weight_limit, check_origin } => {
UnpaidExecution { weight_limit, check_origin }
},
PayFees { asset } => PayFees { asset },
InitiateTransfer { destination, remote_fees, preserve_origin, assets, remote_xcm } =>
InitiateTransfer { destination, remote_fees, preserve_origin, assets, remote_xcm },
ExecuteWithOrigin { descendant_origin, xcm } =>
ExecuteWithOrigin { descendant_origin, xcm: xcm.into() },
InitiateTransfer { destination, remote_fees, preserve_origin, assets, remote_xcm } => {
InitiateTransfer { destination, remote_fees, preserve_origin, assets, remote_xcm }
},
ExecuteWithOrigin { descendant_origin, xcm } => {
ExecuteWithOrigin { descendant_origin, xcm: xcm.into() }
},
}
}
}
@@ -1253,27 +1266,34 @@ impl<Call, W: XcmWeightInfo<Call>> GetWeight<W> for Instruction<Call> {
WithdrawAsset(assets) => W::withdraw_asset(assets),
ReserveAssetDeposited(assets) => W::reserve_asset_deposited(assets),
ReceiveTeleportedAsset(assets) => W::receive_teleported_asset(assets),
QueryResponse { query_id, response, max_weight, querier } =>
W::query_response(query_id, response, max_weight, querier),
QueryResponse { query_id, response, max_weight, querier } => {
W::query_response(query_id, response, max_weight, querier)
},
TransferAsset { assets, beneficiary } => W::transfer_asset(assets, beneficiary),
TransferReserveAsset { assets, dest, xcm } =>
W::transfer_reserve_asset(&assets, dest, xcm),
Transact { origin_kind, fallback_max_weight, call } =>
W::transact(origin_kind, fallback_max_weight, call),
HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity } =>
W::hrmp_new_channel_open_request(sender, max_message_size, max_capacity),
TransferReserveAsset { assets, dest, xcm } => {
W::transfer_reserve_asset(&assets, dest, xcm)
},
Transact { origin_kind, fallback_max_weight, call } => {
W::transact(origin_kind, fallback_max_weight, call)
},
HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity } => {
W::hrmp_new_channel_open_request(sender, max_message_size, max_capacity)
},
HrmpChannelAccepted { recipient } => W::hrmp_channel_accepted(recipient),
HrmpChannelClosing { initiator, sender, recipient } =>
W::hrmp_channel_closing(initiator, sender, recipient),
HrmpChannelClosing { initiator, sender, recipient } => {
W::hrmp_channel_closing(initiator, sender, recipient)
},
ClearOrigin => W::clear_origin(),
DescendOrigin(who) => W::descend_origin(who),
ReportError(response_info) => W::report_error(&response_info),
DepositAsset { assets, beneficiary } => W::deposit_asset(assets, beneficiary),
DepositReserveAsset { assets, dest, xcm } =>
W::deposit_reserve_asset(assets, dest, xcm),
DepositReserveAsset { assets, dest, xcm } => {
W::deposit_reserve_asset(assets, dest, xcm)
},
ExchangeAsset { give, want, maximal } => W::exchange_asset(give, want, maximal),
InitiateReserveWithdraw { assets, reserve, xcm } =>
W::initiate_reserve_withdraw(assets, reserve, xcm),
InitiateReserveWithdraw { assets, reserve, xcm } => {
W::initiate_reserve_withdraw(assets, reserve, xcm)
},
InitiateTeleport { assets, dest, xcm } => W::initiate_teleport(assets, dest, xcm),
ReportHolding { response_info, assets } => W::report_holding(&response_info, &assets),
BuyExecution { fees, weight_limit } => W::buy_execution(fees, weight_limit),
@@ -1284,23 +1304,27 @@ impl<Call, W: XcmWeightInfo<Call>> GetWeight<W> for Instruction<Call> {
SetHints { hints } => W::set_hints(hints),
ClaimAsset { assets, ticket } => W::claim_asset(assets, ticket),
Trap(code) => W::trap(code),
SubscribeVersion { query_id, max_response_weight } =>
W::subscribe_version(query_id, max_response_weight),
SubscribeVersion { query_id, max_response_weight } => {
W::subscribe_version(query_id, max_response_weight)
},
UnsubscribeVersion => W::unsubscribe_version(),
BurnAsset(assets) => W::burn_asset(assets),
ExpectAsset(assets) => W::expect_asset(assets),
ExpectOrigin(origin) => W::expect_origin(origin),
ExpectError(error) => W::expect_error(error),
ExpectTransactStatus(transact_status) => W::expect_transact_status(transact_status),
QueryPallet { module_name, response_info } =>
W::query_pallet(module_name, response_info),
ExpectPallet { index, name, module_name, crate_major, min_crate_minor } =>
W::expect_pallet(index, name, module_name, crate_major, min_crate_minor),
QueryPallet { module_name, response_info } => {
W::query_pallet(module_name, response_info)
},
ExpectPallet { index, name, module_name, crate_major, min_crate_minor } => {
W::expect_pallet(index, name, module_name, crate_major, min_crate_minor)
},
ReportTransactStatus(response_info) => W::report_transact_status(response_info),
ClearTransactStatus => W::clear_transact_status(),
UniversalOrigin(j) => W::universal_origin(j),
ExportMessage { network, destination, xcm } =>
W::export_message(network, destination, xcm),
ExportMessage { network, destination, xcm } => {
W::export_message(network, destination, xcm)
},
LockAsset { asset, unlocker } => W::lock_asset(asset, unlocker),
UnlockAsset { asset, target } => W::unlock_asset(asset, target),
NoteUnlockable { asset, owner } => W::note_unlockable(asset, owner),
@@ -1309,13 +1333,16 @@ impl<Call, W: XcmWeightInfo<Call>> GetWeight<W> for Instruction<Call> {
SetTopic(topic) => W::set_topic(topic),
ClearTopic => W::clear_topic(),
AliasOrigin(location) => W::alias_origin(location),
UnpaidExecution { weight_limit, check_origin } =>
W::unpaid_execution(weight_limit, check_origin),
UnpaidExecution { weight_limit, check_origin } => {
W::unpaid_execution(weight_limit, check_origin)
},
PayFees { asset } => W::pay_fees(asset),
InitiateTransfer { destination, remote_fees, preserve_origin, assets, remote_xcm } =>
W::initiate_transfer(destination, remote_fees, preserve_origin, assets, remote_xcm),
ExecuteWithOrigin { descendant_origin, xcm } =>
W::execute_with_origin(descendant_origin, xcm),
InitiateTransfer { destination, remote_fees, preserve_origin, assets, remote_xcm } => {
W::initiate_transfer(destination, remote_fees, preserve_origin, assets, remote_xcm)
},
ExecuteWithOrigin { descendant_origin, xcm } => {
W::execute_with_origin(descendant_origin, xcm)
},
}
}
}
@@ -1347,20 +1374,22 @@ impl<Call> TryFrom<OldInstruction<Call>> for Instruction<Call> {
WithdrawAsset(assets) => Self::WithdrawAsset(assets.try_into()?),
ReserveAssetDeposited(assets) => Self::ReserveAssetDeposited(assets.try_into()?),
ReceiveTeleportedAsset(assets) => Self::ReceiveTeleportedAsset(assets.try_into()?),
QueryResponse { query_id, response, max_weight, querier: Some(querier) } =>
QueryResponse { query_id, response, max_weight, querier: Some(querier) } => {
Self::QueryResponse {
query_id,
querier: querier.try_into()?,
response: response.try_into()?,
max_weight,
},
QueryResponse { query_id, response, max_weight, querier: None } =>
}
},
QueryResponse { query_id, response, max_weight, querier: None } => {
Self::QueryResponse {
query_id,
querier: None,
response: response.try_into()?,
max_weight,
},
}
},
TransferAsset { assets, beneficiary } => Self::TransferAsset {
assets: assets.try_into()?,
beneficiary: beneficiary.try_into()?,
@@ -1370,11 +1399,13 @@ impl<Call> TryFrom<OldInstruction<Call>> for Instruction<Call> {
dest: dest.try_into()?,
xcm: xcm.try_into()?,
},
HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity } =>
Self::HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity },
HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity } => {
Self::HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity }
},
HrmpChannelAccepted { recipient } => Self::HrmpChannelAccepted { recipient },
HrmpChannelClosing { initiator, sender, recipient } =>
Self::HrmpChannelClosing { initiator, sender, recipient },
HrmpChannelClosing { initiator, sender, recipient } => {
Self::HrmpChannelClosing { initiator, sender, recipient }
},
Transact { origin_kind, require_weight_at_most, call } => Self::Transact {
origin_kind,
call: call.into(),
@@ -1438,8 +1469,9 @@ impl<Call> TryFrom<OldInstruction<Call>> for Instruction<Call> {
Self::ClaimAsset { assets, ticket }
},
Trap(code) => Self::Trap(code),
SubscribeVersion { query_id, max_response_weight } =>
Self::SubscribeVersion { query_id, max_response_weight },
SubscribeVersion { query_id, max_response_weight } => {
Self::SubscribeVersion { query_id, max_response_weight }
},
UnsubscribeVersion => Self::UnsubscribeVersion,
BurnAsset(assets) => Self::BurnAsset(assets.try_into()?),
ExpectAsset(assets) => Self::ExpectAsset(assets.try_into()?),
@@ -1458,13 +1490,16 @@ impl<Call> TryFrom<OldInstruction<Call>> for Instruction<Call> {
module_name,
response_info: response_info.try_into().map_err(|_| ())?,
},
ExpectPallet { index, name, module_name, crate_major, min_crate_minor } =>
Self::ExpectPallet { index, name, module_name, crate_major, min_crate_minor },
ReportTransactStatus(response_info) =>
Self::ReportTransactStatus(response_info.try_into().map_err(|_| ())?),
ExpectPallet { index, name, module_name, crate_major, min_crate_minor } => {
Self::ExpectPallet { index, name, module_name, crate_major, min_crate_minor }
},
ReportTransactStatus(response_info) => {
Self::ReportTransactStatus(response_info.try_into().map_err(|_| ())?)
},
ClearTransactStatus => Self::ClearTransactStatus,
UniversalOrigin(junction) =>
Self::UniversalOrigin(junction.try_into().map_err(|_| ())?),
UniversalOrigin(junction) => {
Self::UniversalOrigin(junction.try_into().map_err(|_| ())?)
},
ExportMessage { network, destination, xcm } => Self::ExportMessage {
network: network.into(),
destination: destination.try_into().map_err(|_| ())?,
+3 -2
View File
@@ -230,8 +230,9 @@ impl TryFrom<OldError> for Error {
impl From<SendError> for Error {
fn from(e: SendError) -> Self {
match e {
SendError::NotApplicable | SendError::Unroutable | SendError::MissingArgument =>
Error::Unroutable,
SendError::NotApplicable | SendError::Unroutable | SendError::MissingArgument => {
Error::Unroutable
},
SendError::Transport(s) => Error::Transport(s),
SendError::DestinationUnsupported => Error::DestinationUnsupported,
SendError::ExceedsMaxMessageSize => Error::ExceedsMaxMessageSize,