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:
@@ -50,8 +50,9 @@ pub struct AccountIdConverter;
|
||||
impl xcm_executor::traits::ConvertLocation<u64> for AccountIdConverter {
|
||||
fn convert_location(ml: &Location) -> Option<u64> {
|
||||
match ml.unpack() {
|
||||
(0, [Junction::AccountId32 { id, .. }]) =>
|
||||
Some(<u64 as codec::Decode>::decode(&mut &*id.to_vec()).unwrap()),
|
||||
(0, [Junction::AccountId32 { id, .. }]) => {
|
||||
Some(<u64 as codec::Decode>::decode(&mut &*id.to_vec()).unwrap())
|
||||
},
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,8 +82,9 @@ where
|
||||
};
|
||||
|
||||
match input {
|
||||
IXcmCalls::send(_) | IXcmCalls::execute(_) if env.is_read_only() =>
|
||||
Err(Error::Error(pezpallet_revive::Error::<Self::T>::StateChangeDenied.into())),
|
||||
IXcmCalls::send(_) | IXcmCalls::execute(_) if env.is_read_only() => {
|
||||
Err(Error::Error(pezpallet_revive::Error::<Self::T>::StateChangeDenied.into()))
|
||||
},
|
||||
IXcmCalls::send(IXcm::sendCall { destination, message }) => {
|
||||
let _ = env.charge(<Runtime as Config>::WeightInfo::send())?;
|
||||
|
||||
|
||||
@@ -671,8 +671,9 @@ mod benchmarks {
|
||||
// remove `network` from inner `AccountId32` for easier matching of automatic AccountId ->
|
||||
// Location conversions.
|
||||
let origin_location: VersionedLocation = match origin_location.unpack() {
|
||||
(0, [AccountId32 { network: _, id }]) =>
|
||||
Location::new(0, [AccountId32 { network: None, id: *id }]).into(),
|
||||
(0, [AccountId32 { network: _, id }]) => {
|
||||
Location::new(0, [AccountId32 { network: None, id: *id }]).into()
|
||||
},
|
||||
_ => {
|
||||
tracing::error!(
|
||||
target: "xcm::benchmarking::pezpallet_xcm::remove_authorized_alias",
|
||||
|
||||
@@ -1075,8 +1075,9 @@ pub mod pezpallet {
|
||||
timeout,
|
||||
maybe_match_querier: Some(Location::here().into()),
|
||||
},
|
||||
VersionNotifier { origin, is_active } =>
|
||||
QueryStatus::VersionNotifier { origin, is_active },
|
||||
VersionNotifier { origin, is_active } => {
|
||||
QueryStatus::VersionNotifier { origin, is_active }
|
||||
},
|
||||
Ready { response, at } => QueryStatus::Ready { response, at },
|
||||
}
|
||||
}
|
||||
@@ -1714,16 +1715,17 @@ pub mod pezpallet {
|
||||
ensure!(origin_location != new_aliaser, Error::<T>::BadLocation);
|
||||
// remove `network` from inner `AccountId32` for easier matching
|
||||
let origin_location = match origin_location.unpack() {
|
||||
(0, [AccountId32 { network: _, id }]) =>
|
||||
Location::new(0, [AccountId32 { network: None, id: *id }]),
|
||||
(0, [AccountId32 { network: _, id }]) => {
|
||||
Location::new(0, [AccountId32 { network: None, id: *id }])
|
||||
},
|
||||
_ => return Err(Error::<T>::InvalidOrigin.into()),
|
||||
};
|
||||
tracing::debug!(target: "xcm::pezpallet_xcm::add_authorized_alias", ?origin_location, ?new_aliaser, ?expires);
|
||||
ensure!(origin_location != new_aliaser, Error::<T>::BadLocation);
|
||||
if let Some(expiry) = expires {
|
||||
ensure!(
|
||||
expiry >
|
||||
pezframe_system::Pezpallet::<T>::current_block_number()
|
||||
expiry
|
||||
> pezframe_system::Pezpallet::<T>::current_block_number()
|
||||
.saturated_into::<u64>(),
|
||||
Error::<T>::ExpiresInPast
|
||||
);
|
||||
@@ -1797,8 +1799,9 @@ pub mod pezpallet {
|
||||
ensure!(origin_location != to_remove, Error::<T>::BadLocation);
|
||||
// remove `network` from inner `AccountId32` for easier matching
|
||||
let origin_location = match origin_location.unpack() {
|
||||
(0, [AccountId32 { network: _, id }]) =>
|
||||
Location::new(0, [AccountId32 { network: None, id: *id }]),
|
||||
(0, [AccountId32 { network: _, id }]) => {
|
||||
Location::new(0, [AccountId32 { network: None, id: *id }])
|
||||
},
|
||||
_ => return Err(Error::<T>::InvalidOrigin.into()),
|
||||
};
|
||||
tracing::debug!(target: "xcm::pezpallet_xcm::remove_authorized_alias", ?origin_location, ?to_remove);
|
||||
@@ -1847,8 +1850,9 @@ pub mod pezpallet {
|
||||
let origin_location: Location = T::ExecuteXcmOrigin::ensure_origin(origin)?;
|
||||
// remove `network` from inner `AccountId32` for easier matching
|
||||
let origin_location = match origin_location.unpack() {
|
||||
(0, [AccountId32 { network: _, id }]) =>
|
||||
Location::new(0, [AccountId32 { network: None, id: *id }]),
|
||||
(0, [AccountId32 { network: _, id }]) => {
|
||||
Location::new(0, [AccountId32 { network: None, id: *id }])
|
||||
},
|
||||
_ => return Err(Error::<T>::InvalidOrigin.into()),
|
||||
};
|
||||
tracing::debug!(target: "xcm::pezpallet_xcm::remove_all_authorized_aliases", ?origin_location);
|
||||
@@ -2236,8 +2240,9 @@ impl<T: Config> Pezpallet<T> {
|
||||
fees,
|
||||
weight_limit,
|
||||
)?,
|
||||
TransferType::RemoteReserve(_) =>
|
||||
return Err(Error::<T>::InvalidAssetUnsupportedReserve.into()),
|
||||
TransferType::RemoteReserve(_) => {
|
||||
return Err(Error::<T>::InvalidAssetUnsupportedReserve.into())
|
||||
},
|
||||
};
|
||||
FeesHandling::Separate { local_xcm, remote_xcm }
|
||||
};
|
||||
@@ -3460,13 +3465,13 @@ impl<T: Config> Pezpallet<T> {
|
||||
Ok(Self::authorized_aliasers(target)?.into_iter().any(|aliaser| {
|
||||
// `aliasers` and `origin` have already been transformed to `desired_version`, we
|
||||
// can just directly compare them.
|
||||
aliaser.location == origin &&
|
||||
aliaser
|
||||
aliaser.location == origin
|
||||
&& aliaser
|
||||
.expiry
|
||||
.map(|expiry| {
|
||||
pezframe_system::Pezpallet::<T>::current_block_number()
|
||||
.saturated_into::<u64>() <
|
||||
expiry
|
||||
.saturated_into::<u64>()
|
||||
< expiry
|
||||
})
|
||||
.unwrap_or(true)
|
||||
}))
|
||||
@@ -3631,8 +3636,8 @@ impl<T: Config> Pezpallet<T> {
|
||||
// check `RemoteLockedFungibles`
|
||||
ensure!(
|
||||
!RemoteLockedFungibles::<T>::iter()
|
||||
.any(|(key, data)| key.needs_migration(minimal_allowed_xcm_version) ||
|
||||
data.needs_migration(minimal_allowed_xcm_version)),
|
||||
.any(|(key, data)| key.needs_migration(minimal_allowed_xcm_version)
|
||||
|| data.needs_migration(minimal_allowed_xcm_version)),
|
||||
TryRuntimeError::Other(
|
||||
"`RemoteLockedFungibles` data should be migrated to the higher xcm version!"
|
||||
)
|
||||
@@ -3966,11 +3971,12 @@ impl<T: Config> ClaimAssets for Pezpallet<T> {
|
||||
) -> bool {
|
||||
let mut versioned = VersionedAssets::from(assets.clone());
|
||||
match ticket.unpack() {
|
||||
(0, [GeneralIndex(i)]) =>
|
||||
(0, [GeneralIndex(i)]) => {
|
||||
versioned = match versioned.into_version(*i as u32) {
|
||||
Ok(v) => v,
|
||||
Err(()) => return false,
|
||||
},
|
||||
}
|
||||
},
|
||||
(0, []) => (),
|
||||
_ => return false,
|
||||
};
|
||||
@@ -3996,15 +4002,17 @@ impl<T: Config> OnResponse for Pezpallet<T> {
|
||||
querier: Option<&Location>,
|
||||
) -> bool {
|
||||
match Queries::<T>::get(query_id) {
|
||||
Some(QueryStatus::Pending { responder, maybe_match_querier, .. }) =>
|
||||
Location::try_from(responder).map_or(false, |r| origin == &r) &&
|
||||
maybe_match_querier.map_or(true, |match_querier| {
|
||||
Some(QueryStatus::Pending { responder, maybe_match_querier, .. }) => {
|
||||
Location::try_from(responder).map_or(false, |r| origin == &r)
|
||||
&& maybe_match_querier.map_or(true, |match_querier| {
|
||||
Location::try_from(match_querier).map_or(false, |match_querier| {
|
||||
querier.map_or(false, |q| q == &match_querier)
|
||||
})
|
||||
}),
|
||||
Some(QueryStatus::VersionNotifier { origin: r, .. }) =>
|
||||
Location::try_from(r).map_or(false, |r| origin == &r),
|
||||
})
|
||||
},
|
||||
Some(QueryStatus::VersionNotifier { origin: r, .. }) => {
|
||||
Location::try_from(r).map_or(false, |r| origin == &r)
|
||||
},
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
@@ -4285,12 +4293,13 @@ where
|
||||
|
||||
fn try_origin(outer: O) -> Result<Self::Success, O> {
|
||||
match outer.caller().try_into() {
|
||||
Ok(Origin::Xcm(ref location)) =>
|
||||
Ok(Origin::Xcm(ref location)) => {
|
||||
if let Ok(location) = location.clone().try_into() {
|
||||
if F::contains(&location) {
|
||||
return Ok(location);
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
_ => (),
|
||||
}
|
||||
|
||||
|
||||
@@ -80,16 +80,19 @@ pub mod data {
|
||||
|
||||
fn needs_migration(&self, minimal_allowed_xcm_version: XcmVersion) -> bool {
|
||||
match &self {
|
||||
QueryStatus::Pending { responder, maybe_match_querier, .. } =>
|
||||
responder.identify_version() < minimal_allowed_xcm_version ||
|
||||
maybe_match_querier
|
||||
QueryStatus::Pending { responder, maybe_match_querier, .. } => {
|
||||
responder.identify_version() < minimal_allowed_xcm_version
|
||||
|| maybe_match_querier
|
||||
.as_ref()
|
||||
.map(|v| v.identify_version() < minimal_allowed_xcm_version)
|
||||
.unwrap_or(false),
|
||||
QueryStatus::VersionNotifier { origin, .. } =>
|
||||
origin.identify_version() < minimal_allowed_xcm_version,
|
||||
QueryStatus::Ready { response, .. } =>
|
||||
response.identify_version() < minimal_allowed_xcm_version,
|
||||
.unwrap_or(false)
|
||||
},
|
||||
QueryStatus::VersionNotifier { origin, .. } => {
|
||||
origin.identify_version() < minimal_allowed_xcm_version
|
||||
},
|
||||
QueryStatus::Ready { response, .. } => {
|
||||
response.identify_version() < minimal_allowed_xcm_version
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,8 +134,8 @@ pub mod data {
|
||||
type MigratedData = Self;
|
||||
|
||||
fn needs_migration(&self, minimal_allowed_xcm_version: XcmVersion) -> bool {
|
||||
self.0 < minimal_allowed_xcm_version ||
|
||||
self.2.identify_version() < minimal_allowed_xcm_version
|
||||
self.0 < minimal_allowed_xcm_version
|
||||
|| self.2.identify_version() < minimal_allowed_xcm_version
|
||||
}
|
||||
|
||||
fn try_migrate(self, to_xcm_version: XcmVersion) -> Result<Option<Self::MigratedData>, ()> {
|
||||
@@ -152,8 +155,8 @@ pub mod data {
|
||||
type MigratedData = Self;
|
||||
|
||||
fn needs_migration(&self, minimal_allowed_xcm_version: XcmVersion) -> bool {
|
||||
self.owner.identify_version() < minimal_allowed_xcm_version ||
|
||||
self.locker.identify_version() < minimal_allowed_xcm_version
|
||||
self.owner.identify_version() < minimal_allowed_xcm_version
|
||||
|| self.locker.identify_version() < minimal_allowed_xcm_version
|
||||
}
|
||||
|
||||
fn try_migrate(self, to_xcm_version: XcmVersion) -> Result<Option<Self::MigratedData>, ()> {
|
||||
@@ -177,8 +180,9 @@ pub mod data {
|
||||
type MigratedData = (VersionedLocation, AuthorizedAliasesEntry<TicketOf<T>, M>);
|
||||
|
||||
fn needs_migration(&self, required_version: XcmVersion) -> bool {
|
||||
self.0.identify_version() != required_version ||
|
||||
self.1
|
||||
self.0.identify_version() != required_version
|
||||
|| self
|
||||
.1
|
||||
.aliasers
|
||||
.iter()
|
||||
.any(|alias| alias.location.identify_version() != required_version)
|
||||
|
||||
@@ -77,9 +77,9 @@ impl<T: Config> Pezpallet<T> {
|
||||
// is being attempted.
|
||||
let is_reserve_transfer = matches!(
|
||||
transfer_type,
|
||||
TransferType::LocalReserve |
|
||||
TransferType::DestinationReserve |
|
||||
TransferType::RemoteReserve(_)
|
||||
TransferType::LocalReserve
|
||||
| TransferType::DestinationReserve
|
||||
| TransferType::RemoteReserve(_)
|
||||
);
|
||||
|
||||
if !is_reserve_transfer {
|
||||
@@ -122,9 +122,9 @@ impl<T: Config> Pezpallet<T> {
|
||||
NetworkId::Pezkuwi | NetworkId::Kusama => true,
|
||||
NetworkId::ByGenesis(genesis_hash) => {
|
||||
// Check if this is Zagros by genesis hash
|
||||
*genesis_hash == xcm::v5::ZAGROS_GENESIS_HASH ||
|
||||
*genesis_hash == PASEO_GENESIS_HASH ||
|
||||
*genesis_hash == xcm::v5::PEZKUWICHAIN_GENESIS_HASH // Used in tests.
|
||||
*genesis_hash == xcm::v5::ZAGROS_GENESIS_HASH
|
||||
|| *genesis_hash == PASEO_GENESIS_HASH
|
||||
|| *genesis_hash == xcm::v5::PEZKUWICHAIN_GENESIS_HASH // Used in tests.
|
||||
},
|
||||
_ => false,
|
||||
};
|
||||
@@ -144,9 +144,9 @@ impl<T: Config> Pezpallet<T> {
|
||||
NetworkId::Pezkuwi | NetworkId::Kusama => true,
|
||||
NetworkId::ByGenesis(genesis_hash) => {
|
||||
// Check if this is Zagros by genesis hash
|
||||
*genesis_hash == xcm::v5::ZAGROS_GENESIS_HASH ||
|
||||
*genesis_hash == PASEO_GENESIS_HASH ||
|
||||
*genesis_hash == xcm::v5::PEZKUWICHAIN_GENESIS_HASH // Used in tests.
|
||||
*genesis_hash == xcm::v5::ZAGROS_GENESIS_HASH
|
||||
|| *genesis_hash == PASEO_GENESIS_HASH
|
||||
|| *genesis_hash == xcm::v5::PEZKUWICHAIN_GENESIS_HASH // Used in tests.
|
||||
},
|
||||
_ => false,
|
||||
};
|
||||
|
||||
@@ -261,7 +261,7 @@ fn convert_variant_to_method(
|
||||
let method_name = syn::Ident::new(method_name_string, variant_name.span());
|
||||
let docs = get_doc_comments(variant);
|
||||
let method = match &variant.fields {
|
||||
Fields::Unit =>
|
||||
Fields::Unit => {
|
||||
if let Some(return_type) = maybe_return_type {
|
||||
quote! {
|
||||
pub fn #method_name(self) -> #return_type {
|
||||
@@ -280,7 +280,8 @@ fn convert_variant_to_method(
|
||||
self
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
Fields::Unnamed(fields) => {
|
||||
let arg_names: Vec<_> = fields
|
||||
.unnamed
|
||||
|
||||
@@ -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
@@ -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,
|
||||
|
||||
@@ -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(()),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
@@ -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(()),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
@@ -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
@@ -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(()),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
@@ -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(|_| ())?,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -238,10 +238,12 @@ impl AssetsInHolding {
|
||||
/// Returns `true` if `asset` is contained within `self`.
|
||||
pub fn contains_asset(&self, asset: &Asset) -> bool {
|
||||
match asset {
|
||||
Asset { fun: Fungible(amount), id } =>
|
||||
self.fungible.get(id).map_or(false, |a| a >= amount),
|
||||
Asset { fun: NonFungible(instance), id } =>
|
||||
self.non_fungible.contains(&(id.clone(), *instance)),
|
||||
Asset { fun: Fungible(amount), id } => {
|
||||
self.fungible.get(id).map_or(false, |a| a >= amount)
|
||||
},
|
||||
Asset { fun: NonFungible(instance), id } => {
|
||||
self.non_fungible.contains(&(id.clone(), *instance))
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,8 +257,8 @@ impl AssetsInHolding {
|
||||
assets
|
||||
.fungible
|
||||
.iter()
|
||||
.all(|(k, v)| self.fungible.get(k).map_or(false, |a| a >= v)) &&
|
||||
self.non_fungible.is_superset(&assets.non_fungible)
|
||||
.all(|(k, v)| self.fungible.get(k).map_or(false, |a| a >= v))
|
||||
&& self.non_fungible.is_superset(&assets.non_fungible)
|
||||
}
|
||||
|
||||
/// Returns an error unless all `assets` are contained in `self`. In the case of an error, the
|
||||
@@ -303,8 +305,9 @@ impl AssetsInHolding {
|
||||
match mask {
|
||||
AssetFilter::Wild(All) | AssetFilter::Wild(AllCounted(_)) => match maybe_limit {
|
||||
None => return Ok(self.swapped(AssetsInHolding::new())),
|
||||
Some(limit) if self.len() <= limit =>
|
||||
return Ok(self.swapped(AssetsInHolding::new())),
|
||||
Some(limit) if self.len() <= limit => {
|
||||
return Ok(self.swapped(AssetsInHolding::new()))
|
||||
},
|
||||
Some(0) => return Ok(AssetsInHolding::new()),
|
||||
Some(limit) => {
|
||||
let fungible = mem::replace(&mut self.fungible, Default::default());
|
||||
@@ -325,15 +328,16 @@ impl AssetsInHolding {
|
||||
});
|
||||
},
|
||||
},
|
||||
AssetFilter::Wild(AllOfCounted { fun: WildFungible, id, .. }) |
|
||||
AssetFilter::Wild(AllOf { fun: WildFungible, id }) =>
|
||||
AssetFilter::Wild(AllOfCounted { fun: WildFungible, id, .. })
|
||||
| AssetFilter::Wild(AllOf { fun: WildFungible, id }) => {
|
||||
if maybe_limit.map_or(true, |l| l >= 1) {
|
||||
if let Some((id, amount)) = self.fungible.remove_entry(&id) {
|
||||
taken.fungible.insert(id, amount);
|
||||
}
|
||||
},
|
||||
AssetFilter::Wild(AllOfCounted { fun: WildNonFungible, id, .. }) |
|
||||
AssetFilter::Wild(AllOf { fun: WildNonFungible, id }) => {
|
||||
}
|
||||
},
|
||||
AssetFilter::Wild(AllOfCounted { fun: WildNonFungible, id, .. })
|
||||
| AssetFilter::Wild(AllOf { fun: WildNonFungible, id }) => {
|
||||
let non_fungible = mem::replace(&mut self.non_fungible, Default::default());
|
||||
non_fungible.into_iter().for_each(|(c, instance)| {
|
||||
if c == id && maybe_limit.map_or(true, |l| taken.len() < l) {
|
||||
@@ -417,12 +421,13 @@ impl AssetsInHolding {
|
||||
}
|
||||
Ok(self)
|
||||
},
|
||||
NonFungible(instance) =>
|
||||
NonFungible(instance) => {
|
||||
if self.non_fungible.remove(&(asset.id, instance)) {
|
||||
Ok(self)
|
||||
} else {
|
||||
Err(self)
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -469,14 +474,14 @@ impl AssetsInHolding {
|
||||
}
|
||||
}
|
||||
},
|
||||
AssetFilter::Wild(AllOfCounted { fun: WildFungible, id, .. }) |
|
||||
AssetFilter::Wild(AllOf { fun: WildFungible, id }) => {
|
||||
AssetFilter::Wild(AllOfCounted { fun: WildFungible, id, .. })
|
||||
| AssetFilter::Wild(AllOf { fun: WildFungible, id }) => {
|
||||
if let Some(&amount) = self.fungible.get(&id) {
|
||||
masked.fungible.insert(id.clone(), amount);
|
||||
}
|
||||
},
|
||||
AssetFilter::Wild(AllOfCounted { fun: WildNonFungible, id, .. }) |
|
||||
AssetFilter::Wild(AllOf { fun: WildNonFungible, id }) => {
|
||||
AssetFilter::Wild(AllOfCounted { fun: WildNonFungible, id, .. })
|
||||
| AssetFilter::Wild(AllOf { fun: WildNonFungible, id }) => {
|
||||
for (c, instance) in self.non_fungible.iter() {
|
||||
if c == id {
|
||||
masked.non_fungible.insert((c.clone(), *instance));
|
||||
@@ -486,7 +491,7 @@ impl AssetsInHolding {
|
||||
}
|
||||
}
|
||||
},
|
||||
AssetFilter::Definite(assets) =>
|
||||
AssetFilter::Definite(assets) => {
|
||||
for asset in assets.inner().iter() {
|
||||
match asset {
|
||||
Asset { fun: Fungible(amount), id } => {
|
||||
@@ -501,7 +506,8 @@ impl AssetsInHolding {
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
masked
|
||||
}
|
||||
|
||||
@@ -540,8 +540,8 @@ impl<Config: config::Config> XcmExecutor<Config> {
|
||||
);
|
||||
if current_surplus.any_gt(Weight::zero()) {
|
||||
if let Some(w) = self.trader.refund_weight(current_surplus, &self.context) {
|
||||
if !self.holding.contains_asset(&(w.id.clone(), 1).into()) &&
|
||||
self.ensure_can_subsume_assets(1).is_err()
|
||||
if !self.holding.contains_asset(&(w.id.clone(), 1).into())
|
||||
&& self.ensure_can_subsume_assets(1).is_err()
|
||||
{
|
||||
let _ = self
|
||||
.trader
|
||||
@@ -890,10 +890,11 @@ impl<Config: config::Config> XcmExecutor<Config> {
|
||||
});
|
||||
}
|
||||
},
|
||||
Err(ref mut error) =>
|
||||
Err(ref mut error) => {
|
||||
if let Ok(x) = Config::Weigher::instr_weight(&mut instr) {
|
||||
error.weight.saturating_accrue(x)
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
result
|
||||
|
||||
@@ -40,9 +40,8 @@ impl From<LockError> for XcmError {
|
||||
match e {
|
||||
NotApplicable => XcmError::AssetNotFound,
|
||||
BadOrigin => XcmError::BadOrigin,
|
||||
WouldClobber | NotLocked | NotEnoughLocked | Unimplemented | NotTrusted |
|
||||
BadOwner | UnknownAsset | AssetNotOwned | NoResources | UnexpectedState | InUse =>
|
||||
XcmError::LockError,
|
||||
WouldClobber | NotLocked | NotEnoughLocked | Unimplemented | NotTrusted | BadOwner
|
||||
| UnknownAsset | AssetNotOwned | NoResources | UnexpectedState | InUse => XcmError::LockError,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,8 +66,8 @@ pub trait XcmAssetTransfers {
|
||||
|
||||
// try to determine reserve location based on asset id/location
|
||||
let asset_location = asset.id.0.chain_location();
|
||||
if asset_location == Location::here() ||
|
||||
Self::IsTeleporter::contains(asset, &asset_location)
|
||||
if asset_location == Location::here()
|
||||
|| Self::IsTeleporter::contains(asset, &asset_location)
|
||||
{
|
||||
// if the asset is local, then it's a local reserve
|
||||
// it's also a local reserve if the asset's location is not `here` but it's a location
|
||||
|
||||
@@ -68,8 +68,9 @@ impl From<Error> for XcmError {
|
||||
match e {
|
||||
Error::AssetNotHandled => XcmError::AssetNotFound,
|
||||
Error::AccountIdConversionFailed => FailedToTransactAsset("AccountIdConversionFailed"),
|
||||
Error::AmountToBalanceConversionFailed =>
|
||||
FailedToTransactAsset("AmountToBalanceConversionFailed"),
|
||||
Error::AmountToBalanceConversionFailed => {
|
||||
FailedToTransactAsset("AmountToBalanceConversionFailed")
|
||||
},
|
||||
Error::AssetIdConversionFailed => FailedToTransactAsset("AssetIdConversionFailed"),
|
||||
Error::InstanceConversionFailed => FailedToTransactAsset("InstanceConversionFailed"),
|
||||
}
|
||||
|
||||
@@ -159,13 +159,13 @@ pub type TeyrchainPalletXcm = pezpallet_xcm::Pezpallet<teyrchain::Runtime>;
|
||||
// We check XCM messages recursively for blocklisted messages
|
||||
fn recursively_matches_blocklisted_messages(message: &Instruction<()>) -> bool {
|
||||
match message {
|
||||
DepositReserveAsset { xcm, .. } |
|
||||
ExportMessage { xcm, .. } |
|
||||
InitiateReserveWithdraw { xcm, .. } |
|
||||
InitiateTeleport { xcm, .. } |
|
||||
TransferReserveAsset { xcm, .. } |
|
||||
SetErrorHandler(xcm) |
|
||||
SetAppendix(xcm) => xcm.iter().any(recursively_matches_blocklisted_messages),
|
||||
DepositReserveAsset { xcm, .. }
|
||||
| ExportMessage { xcm, .. }
|
||||
| InitiateReserveWithdraw { xcm, .. }
|
||||
| InitiateTeleport { xcm, .. }
|
||||
| TransferReserveAsset { xcm, .. }
|
||||
| SetErrorHandler(xcm)
|
||||
| SetAppendix(xcm) => xcm.iter().any(recursively_matches_blocklisted_messages),
|
||||
// The blocklisted message is the Transact instruction.
|
||||
m => matches!(m, Transact { .. }),
|
||||
}
|
||||
|
||||
@@ -238,8 +238,9 @@ pub mod mock_msg_queue {
|
||||
max_weight,
|
||||
Weight::zero(),
|
||||
) {
|
||||
Outcome::Error(InstructionError { error, .. }) =>
|
||||
(Err(error), Event::Fail(Some(hash), error)),
|
||||
Outcome::Error(InstructionError { error, .. }) => {
|
||||
(Err(error), Event::Fail(Some(hash), error))
|
||||
},
|
||||
Outcome::Complete { used } => (Ok(used), Event::Success(Some(hash))),
|
||||
// As far as the caller is concerned, this was dispatched without error, so
|
||||
// we just report the weight used.
|
||||
|
||||
@@ -108,10 +108,12 @@ pub mod pezpallet {
|
||||
max_weight,
|
||||
Weight::zero(),
|
||||
) {
|
||||
Outcome::Error(InstructionError { error, .. }) =>
|
||||
(Err(error), Event::Fail { message_id: Some(hash), error }),
|
||||
Outcome::Complete { used } =>
|
||||
(Ok(used), Event::Success { message_id: Some(hash) }),
|
||||
Outcome::Error(InstructionError { error, .. }) => {
|
||||
(Err(error), Event::Fail { message_id: Some(hash), error })
|
||||
},
|
||||
Outcome::Complete { used } => {
|
||||
(Ok(used), Event::Success { message_id: Some(hash) })
|
||||
},
|
||||
// As far as the caller is concerned, this was dispatched without error, so
|
||||
// we just report the weight used.
|
||||
Outcome::Incomplete {
|
||||
@@ -167,8 +169,9 @@ pub mod pezpallet {
|
||||
Self::deposit_event(Event::InvalidFormat { message_id: id });
|
||||
},
|
||||
Ok(versioned) => match Xcm::try_from(versioned) {
|
||||
Err(()) =>
|
||||
Self::deposit_event(Event::UnsupportedVersion { message_id: id }),
|
||||
Err(()) => {
|
||||
Self::deposit_event(Event::UnsupportedVersion { message_id: id })
|
||||
},
|
||||
Ok(x) => {
|
||||
let outcome = T::XcmExecutor::prepare_and_execute(
|
||||
Parent,
|
||||
|
||||
@@ -186,8 +186,8 @@ type Weigher = FixedWeightBounds<BaseXcmWeight, RuntimeCall, MaxInstructions>;
|
||||
pub struct NativeTokenToAssetHub;
|
||||
impl ContainsPair<Asset, Location> for NativeTokenToAssetHub {
|
||||
fn contains(asset: &Asset, origin: &Location) -> bool {
|
||||
matches!(asset.id.0.unpack(), (0, [])) &&
|
||||
matches!(origin.unpack(), (1, [Teyrchain(ASSET_HUB_PARA_ID)]))
|
||||
matches!(asset.id.0.unpack(), (0, []))
|
||||
&& matches!(origin.unpack(), (1, [Teyrchain(ASSET_HUB_PARA_ID)]))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -428,8 +428,9 @@ where
|
||||
{
|
||||
fn try_convert(origin: RuntimeOrigin) -> Result<Location, RuntimeOrigin> {
|
||||
origin.try_with_caller(|caller| match caller.try_into() {
|
||||
Ok(SystemRawOrigin::Signed(who)) =>
|
||||
Ok(Junction::AccountIndex64 { network: None, index: who.into() }.into()),
|
||||
Ok(SystemRawOrigin::Signed(who)) => {
|
||||
Ok(Junction::AccountIndex64 { network: None, index: who.into() }.into())
|
||||
},
|
||||
Ok(other) => Err(other.into()),
|
||||
Err(other) => Err(other),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user