style: Migrate to stable-only rustfmt configuration

- Remove nightly-only features from .rustfmt.toml and vendor/ss58-registry/rustfmt.toml
- Removed features: imports_granularity, wrap_comments, comment_width,
  reorder_impl_items, spaces_around_ranges, binop_separator,
  match_arm_blocks, trailing_semicolon, trailing_comma
- Format all 898 affected files with stable rustfmt
- Ensures long-term reliability without nightly toolchain dependency
This commit is contained in:
2025-12-22 17:12:58 +03:00
parent 3208f208c0
commit abc4c3989b
898 changed files with 8671 additions and 6432 deletions
@@ -174,8 +174,8 @@ where
// we are only interested in associated pezpallet submissions
let Some(update) = maybe_update else { return };
// we are only interested in failed or unneeded transactions
let has_failed = has_failed ||
!SubmitTeyrchainHeadsHelper::<T, TeyrchainsInstance>::was_successful(&update);
let has_failed = has_failed
|| !SubmitTeyrchainHeadsHelper::<T, TeyrchainsInstance>::was_successful(&update);
if !has_failed {
return;
+2 -2
View File
@@ -240,8 +240,8 @@ impl MessageDispatch for DummyMessageDispatch {
type LaneId = TestLaneIdType;
fn is_active(lane: Self::LaneId) -> bool {
pezframe_support::storage::unhashed::take::<bool>(&(b"inactive", lane).encode()[..]) !=
Some(false)
pezframe_support::storage::unhashed::take::<bool>(&(b"inactive", lane).encode()[..])
!= Some(false)
}
fn dispatch_weight(
+3 -3
View File
@@ -240,9 +240,9 @@ mod tests {
let mut header = ChainBuilder::new(20).append_finalized_header().to_header();
header.customize_signatures(|signatures| {
let first_signature_idx = signatures.iter().position(Option::is_some).unwrap();
let last_signature_idx = signatures.len() -
signatures.iter().rev().position(Option::is_some).unwrap() -
1;
let last_signature_idx = signatures.len()
- signatures.iter().rev().position(Option::is_some).unwrap()
- 1;
signatures[first_signature_idx] = signatures[last_signature_idx].clone();
});
assert_noop!(
+3 -2
View File
@@ -248,8 +248,9 @@ pub trait CallSubType<T: Config<I, RuntimeCall = Self>, I: 'static>:
let result = SubmitFinalityProofHelper::<T, I>::check_obsolete_from_extension(&call_info);
match result {
Ok(improved_by) =>
Ok(Some(VerifiedSubmitFinalityProofInfo { base: call_info, improved_by })),
Ok(improved_by) => {
Ok(Some(VerifiedSubmitFinalityProofInfo { base: call_info, improved_by }))
},
Err(Error::<T, I>::OldHeader) => Err(InvalidTransaction::Stale.into()),
Err(_) => Err(InvalidTransaction::Call.into()),
}
@@ -196,8 +196,8 @@ mod benchmarks {
//
fn max_msgs<T: Config<I>, I: 'static>() -> u32 {
T::BridgedChain::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX as u32 -
ReceiveMessagesProofSetup::<T, I>::LATEST_RECEIVED_NONCE as u32
T::BridgedChain::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX as u32
- ReceiveMessagesProofSetup::<T, I>::LATEST_RECEIVED_NONCE as u32
}
// Benchmark `receive_messages_proof` extrinsic with single minimal-weight message and following
+4 -4
View File
@@ -53,8 +53,8 @@ impl<T: Config<I>, I: 'static> CallHelper<T, I> {
// `is_obsolete` and every relayer has delivered at least one message,
// so if relayer slots are released, then message slots are also
// released
return post_occupation.free_message_slots >
info.unrewarded_relayers.free_message_slots;
return post_occupation.free_message_slots
> info.unrewarded_relayers.free_message_slots;
}
inbound_lane_data.last_delivered_nonce() == *info.base.bundled_range.end()
@@ -154,8 +154,8 @@ impl<
// confirmation. Because of that, we can't assume that our state has been confirmed
// to the bridged chain. So we are accepting any proof that brings new
// confirmations.
bundled_range: outbound_lane_data.latest_received_nonce + 1..=
relayers_state.last_delivered_nonce,
bundled_range: outbound_lane_data.latest_received_nonce + 1
..=relayers_state.last_delivered_nonce,
best_stored_nonce: outbound_lane_data.latest_received_nonce,
}));
}
+7 -7
View File
@@ -223,8 +223,8 @@ pub mod pezpallet {
// reject transactions that are declaring too many messages
ensure!(
MessageNonce::from(messages_count) <=
BridgedChainOf::<T, I>::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX,
MessageNonce::from(messages_count)
<= BridgedChainOf::<T, I>::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX,
Error::<T, I>::TooManyMessagesInTheProof
);
@@ -320,9 +320,9 @@ pub mod pezpallet {
valid_messages += 1;
dispatch_result.unspent_weight
},
ReceptionResult::InvalidNonce |
ReceptionResult::TooManyUnrewardedRelayers |
ReceptionResult::TooManyUnconfirmedMessages => message_dispatch_weight,
ReceptionResult::InvalidNonce
| ReceptionResult::TooManyUnrewardedRelayers
| ReceptionResult::TooManyUnconfirmedMessages => message_dispatch_weight,
};
messages_received_status.push(message.key.nonce, receival_result);
@@ -733,8 +733,8 @@ where
/// Ensure that the pezpallet is in normal operational mode.
fn ensure_normal_operating_mode<T: Config<I>, I: 'static>() -> Result<(), Error<T, I>> {
if PalletOperatingMode::<T, I>::get() ==
MessagesOperatingMode::Basic(BasicOperatingMode::Normal)
if PalletOperatingMode::<T, I>::get()
== MessagesOperatingMode::Basic(BasicOperatingMode::Normal)
{
return Ok(());
}
@@ -78,12 +78,13 @@ where
for (i, nonce) in message_nonces.into_iter().enumerate() {
let message_key = MessageKey { lane_id: lane, nonce };
let message_payload = match encode_message(nonce, &generate_message(nonce)) {
Some(message_payload) =>
Some(message_payload) => {
if i == 0 {
grow_storage_value(message_payload, &proof_params)
} else {
message_payload
},
}
},
None => continue,
};
let storage_key = storage_keys::message_key(
@@ -411,8 +411,8 @@ pub trait WeightInfoExt: WeightInfo {
/// is less than that cost).
fn storage_proof_size_overhead(proof_size: u32) -> Weight {
let proof_size_in_bytes = proof_size;
let byte_weight = Self::receive_single_n_bytes_message_proof(2) -
Self::receive_single_n_bytes_message_proof(1);
let byte_weight = Self::receive_single_n_bytes_message_proof(2)
- Self::receive_single_n_bytes_message_proof(1);
proof_size_in_bytes * byte_weight
}
@@ -109,8 +109,9 @@ where
calls.next().transpose()?.and_then(|c| c.submit_finality_proof_info());
Ok(match (total_calls, relay_finality_call, msgs_call) {
(2, Some(relay_finality_call), Some(msgs_call)) =>
Some(ExtensionCallInfo::RelayFinalityAndMsgs(relay_finality_call, msgs_call)),
(2, Some(relay_finality_call), Some(msgs_call)) => {
Some(ExtensionCallInfo::RelayFinalityAndMsgs(relay_finality_call, msgs_call))
},
(1, None, Some(msgs_call)) => Some(ExtensionCallInfo::Msgs(msgs_call)),
_ => None,
})
@@ -129,8 +130,8 @@ where
call_data: &mut ExtensionCallData,
relayer: &R::AccountId,
) -> bool {
verify_submit_finality_proof_succeeded::<Self, GI>(call_info, call_data, relayer) &&
verify_messages_call_succeeded::<Self>(call_info, call_data, relayer)
verify_submit_finality_proof_succeeded::<Self, GI>(call_info, call_data, relayer)
&& verify_messages_call_succeeded::<Self>(call_info, call_data, relayer)
}
}
@@ -407,11 +407,12 @@ where
"Has registered reward"
);
},
RelayerAccountAction::Slash(relayer, slash_account) =>
RelayerAccountAction::Slash(relayer, slash_account) => {
RelayersPallet::<R, C::BridgeRelayersPalletInstance>::slash_and_deregister(
&relayer,
ExplicitOrAccountParams::Params(slash_account),
),
)
},
}
Ok(Weight::zero())
@@ -676,8 +677,8 @@ mod tests {
test_lane_id(),
)
.unwrap()
.last_delivered_nonce() +
1,
.last_delivered_nonce()
+ 1,
nonces_end: best_message,
}),
messages_count: 1,
@@ -98,9 +98,9 @@ mod integrity_tests {
let priority_with_tip = estimate_priority(1, tip);
const ERROR_MARGIN: TransactionPriority = 5; // 5%
if priority_with_boost.abs_diff(priority_with_tip).saturating_mul(100) /
priority_with_tip >
ERROR_MARGIN
if priority_with_boost.abs_diff(priority_with_tip).saturating_mul(100)
/ priority_with_tip
> ERROR_MARGIN
{
panic!(
"The {param_name} value ({}) must be fixed to: {}",
@@ -122,14 +122,16 @@ where
let relay_finality_call =
calls.next().transpose()?.and_then(|c| c.submit_finality_proof_info());
Ok(match (total_calls, relay_finality_call, para_finality_call, msgs_call) {
(3, Some(relay_finality_call), Some(para_finality_call), Some(msgs_call)) =>
(3, Some(relay_finality_call), Some(para_finality_call), Some(msgs_call)) => {
Some(ExtensionCallInfo::AllFinalityAndMsgs(
relay_finality_call,
para_finality_call,
msgs_call,
)),
(2, None, Some(para_finality_call), Some(msgs_call)) =>
Some(ExtensionCallInfo::TeyrchainFinalityAndMsgs(para_finality_call, msgs_call)),
))
},
(2, None, Some(para_finality_call), Some(msgs_call)) => {
Some(ExtensionCallInfo::TeyrchainFinalityAndMsgs(para_finality_call, msgs_call))
},
(1, None, None, Some(msgs_call)) => Some(ExtensionCallInfo::Msgs(msgs_call)),
_ => None,
})
@@ -151,8 +153,8 @@ where
) -> bool {
verify_submit_finality_proof_succeeded::<Self, R::BridgesGrandpaPalletInstance>(
call_info, call_data, relayer,
) && verify_submit_teyrchain_head_succeeded::<Self, PI>(call_info, call_data, relayer) &&
verify_messages_call_succeeded::<Self>(call_info, call_data, relayer)
) && verify_submit_teyrchain_head_succeeded::<Self, PI>(call_info, call_data, relayer)
&& verify_messages_call_succeeded::<Self>(call_info, call_data, relayer)
}
}
+2 -2
View File
@@ -381,8 +381,8 @@ impl MessageDispatch for DummyMessageDispatch {
type LaneId = TestLaneIdType;
fn is_active(lane: Self::LaneId) -> bool {
pezframe_support::storage::unhashed::take::<bool>(&(b"inactive", lane).encode()[..]) !=
Some(false)
pezframe_support::storage::unhashed::take::<bool>(&(b"inactive", lane).encode()[..])
!= Some(false)
}
fn dispatch_weight(
@@ -158,12 +158,13 @@ impl<T: Config<I>, I: 'static> SubmitTeyrchainHeadsHelper<T, I> {
/// Check if the `SubmitTeyrchainHeads` was successfully executed.
pub fn was_successful(update: &SubmitTeyrchainHeadsInfo) -> bool {
match crate::ParasInfo::<T, I>::get(update.para_id) {
Some(stored_best_head) =>
stored_best_head.best_head_hash ==
BestParaHeadHash {
Some(stored_best_head) => {
stored_best_head.best_head_hash
== BestParaHeadHash {
at_relay_block_number: update.at_relay_block.0,
head_hash: update.para_head_hash,
},
}
},
None => false,
}
}
+8 -6
View File
@@ -526,14 +526,16 @@ pub mod pezpallet {
let update_result: Result<_, ()> =
ParasInfo::<T, I>::try_mutate(teyrchain, |stored_best_head| {
let is_free = teyrchain_head_size <
T::ParaStoredHeaderDataBuilder::max_free_head_size() as usize &&
match stored_best_head {
let is_free = teyrchain_head_size
< T::ParaStoredHeaderDataBuilder::max_free_head_size() as usize
&& match stored_best_head {
Some(ref best_head)
if at_relay_block.0.saturating_sub(
best_head.best_head_hash.at_relay_block_number,
) >= free_headers_interval =>
true,
{
true
},
Some(_) => false,
None => true,
};
@@ -699,8 +701,8 @@ pub mod pezpallet {
at_relay_block_number: new_at_relay_block.0,
head_hash: new_head_hash,
},
next_imported_hash_position: (next_imported_hash_position + 1) %
T::HeadsToKeep::get(),
next_imported_hash_position: (next_imported_hash_position + 1)
% T::HeadsToKeep::get(),
};
ImportedParaHashes::<T, I>::insert(
teyrchain,
@@ -104,9 +104,9 @@ pub trait WeightInfoExt: WeightInfo {
/// Returns weight that needs to be accounted when storage proof of given size is received.
fn storage_proof_size_overhead(extra_proof_bytes: u32) -> Weight {
let extra_byte_weight = (Self::submit_teyrchain_heads_with_16kb_proof() -
Self::submit_teyrchain_heads_with_1kb_proof()) /
(15 * 1024);
let extra_byte_weight = (Self::submit_teyrchain_heads_with_16kb_proof()
- Self::submit_teyrchain_heads_with_1kb_proof())
/ (15 * 1024);
extra_byte_weight.saturating_mul(extra_proof_bytes as u64)
}
}
@@ -279,7 +279,9 @@ impl<T: Config<I>, I: 'static> ExporterFor for Pezpallet<T, I> {
match T::Bridges::exporter_for(network, remote_location, message) {
Some((bridge_hub_location, maybe_payment))
if bridge_hub_location.eq(&T::SiblingBridgeHubLocation::get()) =>
(bridge_hub_location, maybe_payment),
{
(bridge_hub_location, maybe_payment)
},
_ => {
tracing::trace!(
target: LOG_TARGET,
@@ -504,8 +506,8 @@ mod tests {
Bridge::<TestRuntime, ()>::put(uncongested_bridge(initial_fee_factor));
// it should eventually decrease to one
while XcmBridgeHubRouter::bridge().delivery_fee_factor >
Pezpallet::<TestRuntime, ()>::MIN_FEE_FACTOR
while XcmBridgeHubRouter::bridge().delivery_fee_factor
> Pezpallet::<TestRuntime, ()>::MIN_FEE_FACTOR
{
XcmBridgeHubRouter::on_initialize(One::one());
}
@@ -637,10 +639,10 @@ mod tests {
let factor = FixedU128::from_rational(125, 100);
Bridge::<TestRuntime, ()>::put(uncongested_bridge(factor));
let expected_fee =
(FixedU128::saturating_from_integer(BASE_FEE + BYTE_FEE * (msg_size as u128)) *
factor)
.into_inner() / FixedU128::DIV +
HRMP_FEE;
(FixedU128::saturating_from_integer(BASE_FEE + BYTE_FEE * (msg_size as u128))
* factor)
.into_inner() / FixedU128::DIV
+ HRMP_FEE;
assert_eq!(
XcmBridgeHubRouter::validate(&mut Some(dest), &mut Some(xcm)).unwrap().1.get(0),
Some(&(BridgeFeeAsset::get(), expected_fee).into()),
+3 -2
View File
@@ -767,8 +767,9 @@ pub mod pezpallet {
let lane_id = match maybe_lane_id {
Some(lane_id) => *lane_id,
None =>
locations.calculate_lane_id(xcm::latest::VERSION).expect("Valid locations"),
None => {
locations.calculate_lane_id(xcm::latest::VERSION).expect("Valid locations")
},
};
Pezpallet::<T, I>::do_open_bridge(locations, lane_id, true)
@@ -643,8 +643,8 @@ impl MessageDispatch for TestMessageDispatch {
type LaneId = TestLaneIdType;
fn is_active(lane: Self::LaneId) -> bool {
pezframe_support::storage::unhashed::take::<bool>(&(b"inactive", lane).encode()[..]) !=
Some(false)
pezframe_support::storage::unhashed::take::<bool>(&(b"inactive", lane).encode()[..])
!= Some(false)
}
fn dispatch_weight(
@@ -242,8 +242,8 @@ trait JustificationVerifier<Header: HeaderT> {
justification: &GrandpaJustification<Header>,
) -> Result<(), Error> {
// ensure that it is justification for the expected header
if (justification.commit.target_hash, justification.commit.target_number) !=
finalized_target
if (justification.commit.target_hash, justification.commit.target_number)
!= finalized_target
{
return Err(Error::InvalidJustificationTarget);
}
@@ -434,8 +434,8 @@ mod tests {
#[test]
fn max_expected_submit_finality_proof_arguments_size_respects_mandatory_argument() {
assert!(
max_expected_submit_finality_proof_arguments_size::<TestChain>(true, 100) >
max_expected_submit_finality_proof_arguments_size::<TestChain>(false, 100),
max_expected_submit_finality_proof_arguments_size::<TestChain>(true, 100)
> max_expected_submit_finality_proof_arguments_size::<TestChain>(false, 100),
);
}
+3 -2
View File
@@ -291,8 +291,9 @@ impl<RelayerId> InboundLaneData<RelayerId> {
pub fn total_unrewarded_messages(&self) -> MessageNonce {
let relayers = &self.relayers;
match (relayers.front(), relayers.back()) {
(Some(front), Some(back)) =>
(front.messages.begin..=back.messages.end).saturating_len(),
(Some(front), Some(back)) => {
(front.messages.begin..=back.messages.end).saturating_len()
},
_ => 0,
}
}
@@ -183,7 +183,9 @@ where
match call.is_sub_type() {
Some(UtilityCall::<Runtime>::batch_all { ref calls })
if calls.len() <= max_packed_calls as usize =>
calls.iter().collect(),
{
calls.iter().collect()
},
Some(_) => vec![],
None => vec![call],
}
@@ -71,8 +71,9 @@ impl<AccountId: Decode + Encode, LaneId: Decode + Encode> IdentifyAccount
fn into_account(self) -> Self::AccountId {
match self {
ExplicitOrAccountParams::Explicit(account_id) => account_id,
ExplicitOrAccountParams::Params(params) =>
PayRewardFromAccount::<(), AccountId, LaneId, ()>::rewards_account(params),
ExplicitOrAccountParams::Params(params) => {
PayRewardFromAccount::<(), AccountId, LaneId, ()>::rewards_account(params)
},
}
}
}
+6 -4
View File
@@ -44,8 +44,9 @@ impl<ChainCall: Clone + Codec> EncodedOrDecodedCall<ChainCall> {
/// Returns decoded call.
pub fn to_decoded(&self) -> Result<ChainCall, codec::Error> {
match self {
Self::Encoded(ref encoded_call) =>
ChainCall::decode(&mut &encoded_call[..]).map_err(Into::into),
Self::Encoded(ref encoded_call) => {
ChainCall::decode(&mut &encoded_call[..]).map_err(Into::into)
},
Self::Decoded(ref decoded_call) => Ok(decoded_call.clone()),
}
}
@@ -53,8 +54,9 @@ impl<ChainCall: Clone + Codec> EncodedOrDecodedCall<ChainCall> {
/// Converts self to decoded call.
pub fn into_decoded(self) -> Result<ChainCall, codec::Error> {
match self {
Self::Encoded(encoded_call) =>
ChainCall::decode(&mut &encoded_call[..]).map_err(Into::into),
Self::Encoded(encoded_call) => {
ChainCall::decode(&mut &encoded_call[..]).map_err(Into::into)
},
Self::Decoded(decoded_call) => Ok(decoded_call),
}
}
+7 -5
View File
@@ -311,10 +311,10 @@ pub trait StorageDoubleMapKeyProvider {
let storage_prefix_hashed = pezframe_support::Twox128::hash(Self::MAP_NAME.as_bytes());
let mut final_key = Vec::with_capacity(
pezpallet_prefix_hashed.len() +
storage_prefix_hashed.len() +
key1_hashed.as_ref().len() +
key2_hashed.as_ref().len(),
pezpallet_prefix_hashed.len()
+ storage_prefix_hashed.len()
+ key1_hashed.as_ref().len()
+ key2_hashed.as_ref().len(),
);
final_key.extend_from_slice(&pezpallet_prefix_hashed[..]);
@@ -398,7 +398,9 @@ pub trait OwnedBridgeModule<T: pezframe_system::Config> {
Ok(RawOrigin::Root) => Ok(()),
Ok(RawOrigin::Signed(ref signer))
if Self::OwnerStorage::get().as_ref() == Some(signer) =>
Ok(()),
{
Ok(())
},
_ => Err(BadOrigin),
}
}
@@ -173,8 +173,9 @@ impl<C: Chain> RpcClient<C> {
// same and we need to abort if actual version is > than expected
let actual = SimpleRuntimeVersion::from_runtime_version(&env.runtime_version().await?);
match actual.spec_version.cmp(&expected.spec_version) {
Ordering::Less =>
Err(Error::WaitingForRuntimeUpgrade { chain: C::NAME.into(), expected, actual }),
Ordering::Less => {
Err(Error::WaitingForRuntimeUpgrade { chain: C::NAME.into(), expected, actual })
},
Ordering::Equal => Ok(()),
Ordering::Greater => {
tracing::error!(
@@ -126,8 +126,8 @@ impl<C: Chain, Clnt: Client<C>, V: FloatStorageValue> StandaloneMetric
.await?;
self.value_converter.decode(maybe_storage_value).map(|maybe_fixed_point_value| {
maybe_fixed_point_value.map(|fixed_point_value| {
fixed_point_value.into_inner().unique_saturated_into() as f64 /
V::Value::DIV.unique_saturated_into() as f64
fixed_point_value.into_inner().unique_saturated_into() as f64
/ V::Value::DIV.unique_saturated_into() as f64
})
})
}
@@ -121,10 +121,12 @@ impl<C: Chain, E: Environment<C>> TransactionTracker<C, E> {
(TrackedTransactionStatus::Lost, None)
},
Either::Right((invalidation_status, _)) => match invalidation_status {
InvalidationStatus::Finalized(at_block) =>
(TrackedTransactionStatus::Finalized(at_block), Some(invalidation_status)),
InvalidationStatus::Invalid =>
(TrackedTransactionStatus::Lost, Some(invalidation_status)),
InvalidationStatus::Finalized(at_block) => {
(TrackedTransactionStatus::Finalized(at_block), Some(invalidation_status))
},
InvalidationStatus::Invalid => {
(TrackedTransactionStatus::Lost, Some(invalidation_status))
},
InvalidationStatus::Lost => {
// wait for the rest of stall timeout - this way we'll be sure that the
// transaction is actually dead if it has been crafted properly
@@ -228,9 +230,9 @@ async fn watch_transaction_status<
);
return InvalidationStatus::Invalid;
},
Some(TransactionStatusOf::<C>::Future) |
Some(TransactionStatusOf::<C>::Ready) |
Some(TransactionStatusOf::<C>::Broadcast(_)) => {
Some(TransactionStatusOf::<C>::Future)
| Some(TransactionStatusOf::<C>::Ready)
| Some(TransactionStatusOf::<C>::Broadcast(_)) => {
// nothing important (for us) has happened
},
Some(TransactionStatusOf::<C>::InBlock(block_hash)) => {
@@ -39,8 +39,9 @@ impl<P: EquivocationDetectionPipeline> ReadSyncedHeaders<P> {
target_client: &mut TC,
) -> Result<ReadContext<P>, Self> {
match target_client.synced_headers_finality_info(self.target_block_num).await {
Ok(synced_headers) =>
Ok(ReadContext { target_block_num: self.target_block_num, synced_headers }),
Ok(synced_headers) => {
Ok(ReadContext { target_block_num: self.target_block_num, synced_headers })
},
Err(e) => {
tracing::error!(
target: "bridge",
@@ -127,13 +128,14 @@ impl<P: EquivocationDetectionPipeline> FindEquivocations<P> {
&synced_header.finality_proof,
finality_proofs_buf.buf().as_slice(),
) {
Ok(equivocations) =>
Ok(equivocations) => {
if !equivocations.is_empty() {
result.push(ReportEquivocations {
source_block_hash: self.context.synced_header_hash,
equivocations,
})
},
}
},
Err(e) => {
tracing::error!(
target: "bridge",
@@ -272,23 +274,23 @@ mod tests {
impl PartialEq for ReadContext<TestEquivocationDetectionPipeline> {
fn eq(&self, other: &Self) -> bool {
self.target_block_num == other.target_block_num &&
self.synced_headers == other.synced_headers
self.target_block_num == other.target_block_num
&& self.synced_headers == other.synced_headers
}
}
impl PartialEq for FindEquivocations<TestEquivocationDetectionPipeline> {
fn eq(&self, other: &Self) -> bool {
self.target_block_num == other.target_block_num &&
self.synced_headers == other.synced_headers &&
self.context == other.context
self.target_block_num == other.target_block_num
&& self.synced_headers == other.synced_headers
&& self.context == other.context
}
}
impl PartialEq for ReportEquivocations<TestEquivocationDetectionPipeline> {
fn eq(&self, other: &Self) -> bool {
self.source_block_hash == other.source_block_hash &&
self.equivocations == other.equivocations
self.source_block_hash == other.source_block_hash
&& self.equivocations == other.equivocations
}
}
@@ -289,11 +289,11 @@ impl<P: FinalitySyncPipeline, SC: SourceClient<P>, TC: TargetClient<P>> Finality
let (prev_time, prev_best_number_at_target) = self.progress;
let now = Instant::now();
let needs_update = now - prev_time > Duration::from_secs(10) ||
prev_best_number_at_target
let needs_update = now - prev_time > Duration::from_secs(10)
|| prev_best_number_at_target
.map(|prev_best_number_at_target| {
info.best_number_at_target.saturating_sub(prev_best_number_at_target) >
10.into()
info.best_number_at_target.saturating_sub(prev_best_number_at_target)
> 10.into()
})
.unwrap_or(true);
+10 -8
View File
@@ -128,8 +128,9 @@ impl<P: FinalitySyncPipeline> JustifiedHeaderSelector<P> {
) -> Option<JustifiedHeader<P>> {
let (unjustified_headers, maybe_justified_header) = match self {
JustifiedHeaderSelector::Mandatory(justified_header) => return Some(justified_header),
JustifiedHeaderSelector::Regular(unjustified_headers, justified_header) =>
(unjustified_headers, Some(justified_header)),
JustifiedHeaderSelector::Regular(unjustified_headers, justified_header) => {
(unjustified_headers, Some(justified_header))
},
JustifiedHeaderSelector::None(unjustified_headers) => (unjustified_headers, None),
};
@@ -194,14 +195,15 @@ fn need_to_relay<P: FinalitySyncPipeline>(
match headers_to_relay {
HeadersToRelay::All => true,
HeadersToRelay::Mandatory => header.is_mandatory(),
HeadersToRelay::Free =>
header.is_mandatory() ||
free_headers_interval
HeadersToRelay::Free => {
header.is_mandatory()
|| free_headers_interval
.map(|free_headers_interval| {
header.number().saturating_sub(info.best_number_at_target) >=
free_headers_interval
header.number().saturating_sub(info.best_number_at_target)
>= free_headers_interval
})
.unwrap_or(false),
.unwrap_or(false)
},
}
}
@@ -213,13 +213,14 @@ where
let max_messages_size_in_single_batch = P::TargetChain::max_extrinsic_size() / 3;
let limits = match params.limits {
Some(limits) => limits,
None =>
None => {
select_delivery_transaction_limits_rpc(
&params,
P::TargetChain::max_extrinsic_weight(),
P::SourceChain::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX,
)
.await?,
.await?
},
};
let (max_messages_in_single_batch, max_messages_weight_in_single_batch) =
(limits.max_messages_in_single_batch / 2, limits.max_messages_weight_in_single_batch / 2);
@@ -706,8 +707,9 @@ mod tests {
impl From<MockUtilityCall<RuntimeCall>> for RuntimeCall {
fn from(value: MockUtilityCall<RuntimeCall>) -> RuntimeCall {
match value {
MockUtilityCall::batch_all(calls) =>
RuntimeCall::Utility(UtilityCall::<RuntimeCall>::batch_all(calls)),
MockUtilityCall::batch_all(calls) => {
RuntimeCall::Utility(UtilityCall::<RuntimeCall>::batch_all(calls))
},
}
}
}
@@ -197,8 +197,9 @@ where
let storage_value: Option<ParaStoredHeaderData> =
self.target_client.storage_value(at_block.hash(), storage_key).await?;
let para_head_number = match storage_value {
Some(para_head_data) =>
para_head_data.decode_teyrchain_head_data::<P::SourceTeyrchain>()?.number,
Some(para_head_data) => {
para_head_data.decode_teyrchain_head_data::<P::SourceTeyrchain>()?.number
},
None => return Ok(None),
};
@@ -1068,8 +1068,8 @@ pub(crate) mod tests {
data.source_state.best_finalized_self = data.source_state.best_self;
// syncing target headers -> source chain
if let Some(last_requirement) = data.target_to_source_header_requirements.last() {
if *last_requirement !=
data.source_state.best_finalized_peer_at_best_self.unwrap()
if *last_requirement
!= data.source_state.best_finalized_peer_at_best_self.unwrap()
{
data.source_state.best_finalized_peer_at_best_self =
Some(*last_requirement);
@@ -1091,8 +1091,8 @@ pub(crate) mod tests {
data.target_state.best_finalized_self = data.target_state.best_self;
// syncing source headers -> target chain
if let Some(last_requirement) = data.source_to_target_header_requirements.last() {
if *last_requirement !=
data.target_state.best_finalized_peer_at_best_self.unwrap()
if *last_requirement
!= data.target_state.best_finalized_peer_at_best_self.unwrap()
{
data.target_state.best_finalized_peer_at_best_self =
Some(*last_requirement);
@@ -1148,15 +1148,15 @@ pub(crate) mod tests {
// headers relay must only be started when we need new target headers at source node
if data.target_to_source_header_required.is_some() {
assert!(
data.source_state.best_finalized_peer_at_best_self.unwrap().0 <
data.target_state.best_self.0
data.source_state.best_finalized_peer_at_best_self.unwrap().0
< data.target_state.best_self.0
);
data.target_to_source_header_required = None;
}
// syncing target headers -> source chain
if let Some(last_requirement) = data.target_to_source_header_requirements.last() {
if *last_requirement !=
data.source_state.best_finalized_peer_at_best_self.unwrap()
if *last_requirement
!= data.source_state.best_finalized_peer_at_best_self.unwrap()
{
data.source_state.best_finalized_peer_at_best_self =
Some(*last_requirement);
@@ -1172,15 +1172,15 @@ pub(crate) mod tests {
// headers relay must only be started when we need new source headers at target node
if data.source_to_target_header_required.is_some() {
assert!(
data.target_state.best_finalized_peer_at_best_self.unwrap().0 <
data.source_state.best_self.0
data.target_state.best_finalized_peer_at_best_self.unwrap().0
< data.source_state.best_self.0
);
data.source_to_target_header_required = None;
}
// syncing source headers -> target chain
if let Some(last_requirement) = data.source_to_target_header_requirements.last() {
if *last_requirement !=
data.target_state.best_finalized_peer_at_best_self.unwrap()
if *last_requirement
!= data.target_state.best_finalized_peer_at_best_self.unwrap()
{
data.target_state.best_finalized_peer_at_best_self =
Some(*last_requirement);
@@ -411,10 +411,10 @@ where
// "unrewarded relayers" set. If we are unable to prove new rewards to the target node, then
// we should wait for confirmations race.
let unrewarded_limit_reached =
target_nonces.nonces_data.unrewarded_relayers.unrewarded_relayer_entries >=
self.max_unrewarded_relayer_entries_at_target ||
target_nonces.nonces_data.unrewarded_relayers.total_messages >=
self.max_unconfirmed_nonces_at_target;
target_nonces.nonces_data.unrewarded_relayers.unrewarded_relayer_entries
>= self.max_unrewarded_relayer_entries_at_target
|| target_nonces.nonces_data.unrewarded_relayers.total_messages
>= self.max_unconfirmed_nonces_at_target;
if unrewarded_limit_reached {
// so there are already too many unrewarded relayer entries in the set
//
@@ -422,8 +422,8 @@ where
// be paid
let number_of_rewards_being_proved =
latest_confirmed_nonce_at_source.saturating_sub(latest_confirmed_nonce_at_target);
let enough_rewards_being_proved = number_of_rewards_being_proved >=
target_nonces.nonces_data.unrewarded_relayers.messages_in_oldest_entry;
let enough_rewards_being_proved = number_of_rewards_being_proved
>= target_nonces.nonces_data.unrewarded_relayers.messages_in_oldest_entry;
if !enough_rewards_being_proved {
return None;
}
@@ -114,7 +114,9 @@ impl MessageRaceLimits {
Some(new_selected_weight)
if new_selected_weight
.all_lte(reference.max_messages_weight_in_single_batch) =>
new_selected_weight,
{
new_selected_weight
},
new_selected_weight if selected_count == 0 => {
tracing::warn!(
target: "bridge",
@@ -132,7 +134,9 @@ impl MessageRaceLimits {
let new_selected_size = match relay_reference.selected_size.checked_add(details.size) {
Some(new_selected_size)
if new_selected_size <= reference.max_messages_size_in_single_batch =>
new_selected_size,
{
new_selected_size
},
new_selected_size if selected_count == 0 => {
tracing::warn!(
target: "bridge",
@@ -221,8 +221,9 @@ where
fn best_at_source(&self) -> Option<MessageNonce> {
let best_in_queue = self.source_queue.back().map(|(_, range)| range.end());
match (best_in_queue, self.best_target_nonce) {
(Some(best_in_queue), Some(best_target_nonce)) if best_in_queue > best_target_nonce =>
Some(best_in_queue),
(Some(best_in_queue), Some(best_target_nonce)) if best_in_queue > best_target_nonce => {
Some(best_in_queue)
},
(_, Some(best_target_nonce)) => Some(best_target_nonce),
(_, None) => None,
}
@@ -359,8 +359,8 @@ where
// find last free relay chain header in the range that we are interested in
let scan_range_begin = relay_of_head_at_target.number();
let scan_range_end = best_finalized_relay_block_at_target.number();
if scan_range_end.saturating_sub(scan_range_begin) <
free_source_relay_headers_interval
if scan_range_end.saturating_sub(scan_range_begin)
< free_source_relay_headers_interval
{
// there are no new **free** relay chain headers in the range
tracing::trace!(
@@ -647,7 +647,9 @@ impl<P: TeyrchainsPipeline> SubmittedHeadsTracker<P> {
let is_head_updated = match (self.submitted_head, head_at_target) {
(AvailableHeader::Available(submitted_head), Some(head_at_target))
if head_at_target.number() >= submitted_head.number() =>
true,
{
true
},
(AvailableHeader::Missing, None) => true,
_ => false,
};
@@ -669,8 +671,9 @@ impl<P: TeyrchainsPipeline> SubmittedHeadsTracker<P> {
// then restart our sync
let transaction_tracker = self.transaction_tracker.clone();
match poll!(transaction_tracker) {
Poll::Ready(TrackedTransactionStatus::Lost) =>
return SubmittedHeadStatus::Final(TrackedTransactionStatus::Lost),
Poll::Ready(TrackedTransactionStatus::Lost) => {
return SubmittedHeadStatus::Final(TrackedTransactionStatus::Lost)
},
Poll::Ready(TrackedTransactionStatus::Finalized(_)) => {
// so we are here and our transaction is mined+finalized, but some of heads were not
// updated => we're considering our loop as stalled
@@ -54,9 +54,9 @@ impl<T: Config> Pezpallet<T> {
}
fn check_log_match(log: &Log, receipt_log: &AlloyLog) -> bool {
let equal = receipt_log.data.data.0 == log.data &&
receipt_log.address.0 == log.address.0 &&
receipt_log.topics().len() == log.topics.len();
let equal = receipt_log.data.data.0 == log.data
&& receipt_log.address.0 == log.address.0
&& receipt_log.topics().len() == log.topics.len();
if !equal {
return false;
}
@@ -317,8 +317,8 @@ pub mod pezpallet {
// Verify update does not skip a sync committee period.
ensure!(
update.signature_slot > update.attested_header.slot &&
update.attested_header.slot >= update.finalized_header.slot,
update.signature_slot > update.attested_header.slot
&& update.attested_header.slot >= update.finalized_header.slot,
Error::<T>::InvalidUpdateSlot
);
// Retrieve latest finalized state.
@@ -339,12 +339,12 @@ pub mod pezpallet {
// Verify update is relevant.
let update_attested_period = compute_period(update.attested_header.slot);
let update_finalized_period = compute_period(update.finalized_header.slot);
let update_has_next_sync_committee = !<NextSyncCommittee<T>>::exists() &&
(update.next_sync_committee_update.is_some() &&
update_attested_period == store_period);
let update_has_next_sync_committee = !<NextSyncCommittee<T>>::exists()
&& (update.next_sync_committee_update.is_some()
&& update_attested_period == store_period);
ensure!(
update.attested_header.slot > latest_finalized_state.slot ||
update_has_next_sync_committee,
update.attested_header.slot > latest_finalized_state.slot
|| update_has_next_sync_committee,
Error::<T>::IrrelevantUpdate
);
@@ -354,8 +354,8 @@ pub mod pezpallet {
ensure!(
latest_finalized_state
.slot
.saturating_add(config::SLOTS_PER_HISTORICAL_ROOT as u64) >=
update.finalized_header.slot,
.saturating_add(config::SLOTS_PER_HISTORICAL_ROOT as u64)
>= update.finalized_header.slot,
Error::<T>::InvalidFinalizedHeaderGap
);
@@ -706,8 +706,8 @@ pub mod pezpallet {
// If the latest finalized header is larger than the minimum slot interval, the header
// import transaction is free.
if update.finalized_header.slot >=
latest_slot.saturating_add(T::FreeHeadersInterval::get() as u64)
if update.finalized_header.slot
>= latest_slot.saturating_add(T::FreeHeadersInterval::get() as u64)
{
return Pays::No;
}
@@ -210,10 +210,12 @@ pub mod pezpallet {
XcmpSendError::NotApplicable => Error::<T>::Send(SendError::NotApplicable),
XcmpSendError::Unroutable => Error::<T>::Send(SendError::NotRoutable),
XcmpSendError::Transport(_) => Error::<T>::Send(SendError::Transport),
XcmpSendError::DestinationUnsupported =>
Error::<T>::Send(SendError::DestinationUnsupported),
XcmpSendError::ExceedsMaxMessageSize =>
Error::<T>::Send(SendError::ExceedsMaxMessageSize),
XcmpSendError::DestinationUnsupported => {
Error::<T>::Send(SendError::DestinationUnsupported)
},
XcmpSendError::ExceedsMaxMessageSize => {
Error::<T>::Send(SendError::ExceedsMaxMessageSize)
},
XcmpSendError::MissingArgument => Error::<T>::Send(SendError::MissingArgument),
XcmpSendError::Fees => Error::<T>::Send(SendError::Fees),
}
@@ -182,8 +182,8 @@ impl StaticLookup for MockChannelLookup {
type Target = Channel;
fn lookup(channel_id: Self::Source) -> Option<Self::Target> {
if channel_id !=
hex!("c173fac324158e77fb5840738a1a541f633cbec8884c6a601c567d2b376a0539").into()
if channel_id
!= hex!("c173fac324158e77fb5840738a1a541f633cbec8884c6a601c567d2b376a0539").into()
{
return None;
}
@@ -308,8 +308,8 @@ pub mod pezpallet {
// Yield if the maximum number of messages has been processed this block.
// This ensures that the weight of `on_finalize` has a known maximum bound.
ensure!(
MessageLeaves::<T>::decode_len().unwrap_or(0) <
T::MaxMessagesPerBlock::get() as usize,
MessageLeaves::<T>::decode_len().unwrap_or(0)
< T::MaxMessagesPerBlock::get() as usize,
Yield
);
@@ -80,8 +80,9 @@ pub struct AccountIdConverter;
impl xcm_executor::traits::ConvertLocation<AccountId> for AccountIdConverter {
fn convert_location(ml: &Location) -> Option<AccountId> {
match ml.unpack() {
(0, [Junction::AccountId32 { id, .. }]) =>
Some(<AccountId as codec::Decode>::decode(&mut &*id.to_vec()).unwrap()),
(0, [Junction::AccountId32 { id, .. }]) => {
Some(<AccountId as codec::Decode>::decode(&mut &*id.to_vec()).unwrap())
},
(1, [Teyrchain(id)]) => Some(ParaId::from(*id).into_account_truncating()),
_ => None,
}
@@ -7,8 +7,9 @@ use pezsp_std::prelude::*;
pub fn verify_receipt_proof(receipts_root: H256, values: &[Vec<u8>]) -> Option<ReceiptEnvelope> {
match apply_merkle_proof(values) {
Some((root, data)) if root == receipts_root =>
ReceiptEnvelope::decode(&mut data.as_slice()).ok(),
Some((root, data)) if root == receipts_root => {
ReceiptEnvelope::decode(&mut data.as_slice()).ok()
},
Some((_, _)) => None,
None => None,
}
@@ -412,41 +412,49 @@ pub enum VersionedExecutionPayloadHeader {
impl VersionedExecutionPayloadHeader {
pub fn hash_tree_root(&self) -> Result<H256, SimpleSerializeError> {
match self {
VersionedExecutionPayloadHeader::Capella(execution_payload_header) =>
VersionedExecutionPayloadHeader::Capella(execution_payload_header) => {
hash_tree_root::<SSZExecutionPayloadHeader>(
execution_payload_header.clone().try_into()?,
),
VersionedExecutionPayloadHeader::Deneb(execution_payload_header) =>
)
},
VersionedExecutionPayloadHeader::Deneb(execution_payload_header) => {
hash_tree_root::<crate::ssz::deneb::SSZExecutionPayloadHeader>(
execution_payload_header.clone().try_into()?,
),
)
},
}
}
pub fn block_hash(&self) -> H256 {
match self {
VersionedExecutionPayloadHeader::Capella(execution_payload_header) =>
execution_payload_header.block_hash,
VersionedExecutionPayloadHeader::Deneb(execution_payload_header) =>
execution_payload_header.block_hash,
VersionedExecutionPayloadHeader::Capella(execution_payload_header) => {
execution_payload_header.block_hash
},
VersionedExecutionPayloadHeader::Deneb(execution_payload_header) => {
execution_payload_header.block_hash
},
}
}
pub fn block_number(&self) -> u64 {
match self {
VersionedExecutionPayloadHeader::Capella(execution_payload_header) =>
execution_payload_header.block_number,
VersionedExecutionPayloadHeader::Deneb(execution_payload_header) =>
execution_payload_header.block_number,
VersionedExecutionPayloadHeader::Capella(execution_payload_header) => {
execution_payload_header.block_number
},
VersionedExecutionPayloadHeader::Deneb(execution_payload_header) => {
execution_payload_header.block_number
},
}
}
pub fn receipts_root(&self) -> H256 {
match self {
VersionedExecutionPayloadHeader::Capella(execution_payload_header) =>
execution_payload_header.receipts_root,
VersionedExecutionPayloadHeader::Deneb(execution_payload_header) =>
execution_payload_header.receipts_root,
VersionedExecutionPayloadHeader::Capella(execution_payload_header) => {
execution_payload_header.receipts_root
},
VersionedExecutionPayloadHeader::Deneb(execution_payload_header) => {
execution_payload_header.receipts_root
},
}
}
}
@@ -83,15 +83,19 @@ impl DescribeLocation for DescribeTokenTerminal {
// Pezpallet
[PalletInstance(instance)] => Some((b"PalletInstance", *instance).encode()),
[PalletInstance(instance), GeneralIndex(index)] =>
Some((b"PalletInstance", *instance, b"GeneralIndex", *index).encode()),
[PalletInstance(instance), GeneralKey { data, .. }] =>
Some((b"PalletInstance", *instance, b"GeneralKey", *data).encode()),
[PalletInstance(instance), GeneralIndex(index)] => {
Some((b"PalletInstance", *instance, b"GeneralIndex", *index).encode())
},
[PalletInstance(instance), GeneralKey { data, .. }] => {
Some((b"PalletInstance", *instance, b"GeneralKey", *data).encode())
},
[PalletInstance(instance), AccountKey20 { key, .. }] =>
Some((b"PalletInstance", *instance, b"AccountKey20", *key).encode()),
[PalletInstance(instance), AccountId32 { id, .. }] =>
Some((b"PalletInstance", *instance, b"AccountId32", *id).encode()),
[PalletInstance(instance), AccountKey20 { key, .. }] => {
Some((b"PalletInstance", *instance, b"AccountKey20", *key).encode())
},
[PalletInstance(instance), AccountId32 { id, .. }] => {
Some((b"PalletInstance", *instance, b"AccountId32", *id).encode())
},
// Reject all other locations
_ => None,
@@ -20,10 +20,12 @@ where
{
fn convert_location(location: &Location) -> Option<AccountId> {
match location.unpack() {
(2, [GlobalConsensus(Ethereum { chain_id })]) =>
Some(Self::from_chain_id(chain_id).into()),
(2, [GlobalConsensus(Ethereum { chain_id }), AccountKey20 { network: _, key }]) =>
Some(Self::from_chain_id_with_key(chain_id, *key).into()),
(2, [GlobalConsensus(Ethereum { chain_id })]) => {
Some(Self::from_chain_id(chain_id).into())
},
(2, [GlobalConsensus(Ethereum { chain_id }), AccountKey20 { network: _, key }]) => {
Some(Self::from_chain_id_with_key(chain_id, *key).into())
},
_ => None,
}
}
@@ -185,10 +185,12 @@ where
use Command::*;
use VersionedMessage::*;
match message {
V1(MessageV1 { chain_id, command: RegisterToken { token, fee } }) =>
Ok(Self::convert_register_token(message_id, chain_id, token, fee)),
V1(MessageV1 { chain_id, command: SendToken { token, destination, amount, fee } }) =>
Ok(Self::convert_send_token(message_id, chain_id, token, destination, amount, fee)),
V1(MessageV1 { chain_id, command: RegisterToken { token, fee } }) => {
Ok(Self::convert_register_token(message_id, chain_id, token, fee))
},
V1(MessageV1 { chain_id, command: SendToken { token, destination, amount, fee } }) => {
Ok(Self::convert_send_token(message_id, chain_id, token, destination, amount, fee))
},
V1(MessageV1 {
chain_id,
command: SendNativeToken { token_id, destination, amount, fee },
@@ -309,8 +311,9 @@ where
let (dest_para_id, beneficiary, dest_para_fee) = match destination {
// Final destination is a 32-byte account on AssetHub
Destination::AccountId32 { id } =>
(None, Location::new(0, [AccountId32 { network: None, id }]), 0),
Destination::AccountId32 { id } => {
(None, Location::new(0, [AccountId32 { network: None, id }]), 0)
},
// Final destination is a 32-byte account on a sibling of AssetHub
Destination::ForeignAccountId32 { para_id, id, fee } => (
Some(para_id),
@@ -416,8 +419,9 @@ where
let beneficiary = match destination {
// Final destination is a 32-byte account on AssetHub
Destination::AccountId32 { id } =>
Ok(Location::new(0, [AccountId32 { network: None, id }])),
Destination::AccountId32 { id } => {
Ok(Location::new(0, [AccountId32 { network: None, id }]))
},
// Forwarding to a destination teyrchain is not allowed for PNA and is validated on the
// Ethereum side. https://github.com/Snowfork/snowbridge/blob/e87ddb2215b513455c844463a25323bb9c01ff36/contracts/src/Assets.sol#L216-L224
_ => Err(ConvertMessageError::InvalidDestination),
@@ -290,8 +290,9 @@ where
Asset { id: AssetId(inner_location), fun: Fungible(amount) } => {
match inner_location.unpack() {
// Get the ERC20 contract address of the token.
(0, [AccountKey20 { network, key }]) if self.network_matches(network) =>
Some((H160(*key), *amount)),
(0, [AccountKey20 { network, key }]) if self.network_matches(network) => {
Some((H160(*key), *amount))
},
// If there is no ERC20 contract address in the location then signal to the
// gateway that is a native Ether transfer by using
// `0x0000000000000000000000000000000000000000` as the token address.
@@ -403,8 +404,9 @@ where
}
let (asset_id, amount) = match reserve_asset {
Asset { id: AssetId(inner_location), fun: Fungible(amount) } =>
Some((inner_location.clone(), *amount)),
Asset { id: AssetId(inner_location), fun: Fungible(amount) } => {
Some((inner_location.clone(), *amount))
},
_ => None,
}
.ok_or(AssetResolutionFailed)?;
@@ -152,14 +152,16 @@ impl Command {
Token::FixedBytes(agent_id.as_bytes().to_owned()),
Token::Bytes(command.abi_encode()),
])]),
Command::Upgrade { impl_address, impl_code_hash, initializer, .. } =>
Command::Upgrade { impl_address, impl_code_hash, initializer, .. } => {
ethabi::encode(&[Token::Tuple(vec![
Token::Address(*impl_address),
Token::FixedBytes(impl_code_hash.as_bytes().to_owned()),
initializer.clone().map_or(Token::Bytes(vec![]), |i| Token::Bytes(i.params)),
])]),
Command::SetOperatingMode { mode } =>
ethabi::encode(&[Token::Tuple(vec![Token::Uint(U256::from((*mode) as u64))])]),
])])
},
Command::SetOperatingMode { mode } => {
ethabi::encode(&[Token::Tuple(vec![Token::Uint(U256::from((*mode) as u64))])])
},
Command::SetTokenTransferFees {
create_asset_xcm,
transfer_asset_xcm,
@@ -169,32 +171,36 @@ impl Command {
Token::Uint(U256::from(*transfer_asset_xcm)),
Token::Uint(*register_token),
])]),
Command::SetPricingParameters { exchange_rate, delivery_cost, multiplier } =>
Command::SetPricingParameters { exchange_rate, delivery_cost, multiplier } => {
ethabi::encode(&[Token::Tuple(vec![
Token::Uint(exchange_rate.clone().into_inner()),
Token::Uint(U256::from(*delivery_cost)),
Token::Uint(multiplier.clone().into_inner()),
])]),
Command::UnlockNativeToken { agent_id, token, recipient, amount } =>
])])
},
Command::UnlockNativeToken { agent_id, token, recipient, amount } => {
ethabi::encode(&[Token::Tuple(vec![
Token::FixedBytes(agent_id.as_bytes().to_owned()),
Token::Address(*token),
Token::Address(*recipient),
Token::Uint(U256::from(*amount)),
])]),
Command::RegisterForeignToken { token_id, name, symbol, decimals } =>
])])
},
Command::RegisterForeignToken { token_id, name, symbol, decimals } => {
ethabi::encode(&[Token::Tuple(vec![
Token::FixedBytes(token_id.as_bytes().to_owned()),
Token::String(name.to_owned()),
Token::String(symbol.to_owned()),
Token::Uint(U256::from(*decimals)),
])]),
Command::MintForeignToken { token_id, recipient, amount } =>
])])
},
Command::MintForeignToken { token_id, recipient, amount } => {
ethabi::encode(&[Token::Tuple(vec![
Token::FixedBytes(token_id.as_bytes().to_owned()),
Token::Address(*recipient),
Token::Uint(U256::from(*amount)),
])]),
])])
},
}
}
}
@@ -133,8 +133,9 @@ where
let (token, amount) = match ena {
Asset { id: AssetId(inner_location), fun: Fungible(amount) } => {
match inner_location.unpack() {
(0, [AccountKey20 { network, key }]) if self.network_matches(network) =>
Ok((H160(*key), amount)),
(0, [AccountKey20 { network, key }]) if self.network_matches(network) => {
Ok((H160(*key), amount))
},
// To allow ether
(0, []) => Ok((H160([0; 20]), amount)),
_ => Err(AssetResolutionFailed),
@@ -214,23 +214,26 @@ impl Command {
initParams: Bytes::from(initializer.params.clone()),
}
.abi_encode(),
Command::SetOperatingMode { mode } =>
SetOperatingModeParams { mode: (*mode) as u8 }.abi_encode(),
Command::UnlockNativeToken { token, recipient, amount, .. } =>
Command::SetOperatingMode { mode } => {
SetOperatingModeParams { mode: (*mode) as u8 }.abi_encode()
},
Command::UnlockNativeToken { token, recipient, amount, .. } => {
UnlockNativeTokenParams {
token: Address::from(token.as_fixed_bytes()),
recipient: Address::from(recipient.as_fixed_bytes()),
amount: *amount,
}
.abi_encode(),
Command::RegisterForeignToken { token_id, name, symbol, decimals } =>
.abi_encode()
},
Command::RegisterForeignToken { token_id, name, symbol, decimals } => {
RegisterForeignTokenParams {
foreignTokenID: FixedBytes::from(token_id.as_fixed_bytes()),
name: Bytes::from(name.to_vec()),
symbol: Bytes::from(symbol.to_vec()),
decimals: *decimals,
}
.abi_encode(),
.abi_encode()
},
Command::MintForeignToken { token_id, recipient, amount } => MintForeignTokenParams {
foreignTokenID: FixedBytes::from(token_id.as_fixed_bytes()),
recipient: Address::from(recipient.as_fixed_bytes()),