style: fix formatting, regenerate umbrella, taplo format

This commit is contained in:
2026-03-22 20:17:58 +03:00
parent 288978c088
commit 9f4c9b4d19
14 changed files with 47 additions and 83 deletions
@@ -185,8 +185,7 @@ pub mod pezpallet {
/// Ensures no two accounts can register with the same identity hash
#[pezpallet::storage]
#[pezpallet::getter(fn identity_hash_owner)]
pub type IdentityHashToAccount<T: Config> =
StorageMap<_, Blake2_128Concat, H256, T::AccountId>;
pub type IdentityHashToAccount<T: Config> = StorageMap<_, Blake2_128Concat, H256, T::AccountId>;
/// Referrer of approved citizens (for direct responsibility tracking)
/// Kept permanently for penalty system even after application is removed
@@ -377,12 +377,7 @@ fn complete_course_with_max_allowed_points() {
assert_ok!(PerwerdePallet::enroll(RuntimeOrigin::signed(student), 0));
// Complete with maximum allowed points (MaxPointsPerCourse = 1000)
assert_ok!(PerwerdePallet::complete_course(
RuntimeOrigin::signed(admin),
student,
0,
1000
));
assert_ok!(PerwerdePallet::complete_course(RuntimeOrigin::signed(admin), student, 0, 1000));
let enrollment = crate::Enrollments::<Test>::get((student, 0)).unwrap();
assert_eq!(enrollment.points_earned, 1000);
@@ -612,8 +612,7 @@ pub mod pezpallet {
// Calculate unclaimed amount: total allocated - total claimed
let total_claimed = EpochTotalClaimed::<T>::get(epoch_index);
let unclaimed_amount =
reward_pool.total_reward_pool.saturating_sub(total_claimed);
let unclaimed_amount = reward_pool.total_reward_pool.saturating_sub(total_claimed);
let incentive_pot = Self::incentive_pot_account_id();
let clawback_recipient = <T as Config>::ClawbackRecipient::get();
@@ -360,8 +360,8 @@ pub mod pezpallet {
}
pub fn do_monthly_release() -> DispatchResult {
let start_block = TreasuryStartBlock::<T>::get()
.ok_or(Error::<T>::TreasuryNotInitialized)?;
let start_block =
TreasuryStartBlock::<T>::get().ok_or(Error::<T>::TreasuryNotInitialized)?;
let current_block = pezframe_system::Pezpallet::<T>::block_number();
let next_month = NextReleaseMonth::<T>::get();
@@ -99,5 +99,9 @@ mod benchmarks {
// The weight functions `ping(s)` and `pong(s)` in weights.rs account for the
// payload size variable and provide conservative estimates.
impl_benchmark_test_suite!(Pezpallet, super::super::mock::new_bench_ext(), super::super::mock::Test);
impl_benchmark_test_suite!(
Pezpallet,
super::super::mock::new_bench_ext(),
super::super::mock::Test
);
}
@@ -83,11 +83,7 @@ fn start_rejects_too_many_targets() {
new_test_ext().execute_with(|| {
// MaxTeyrchains is 100.
for i in 0..100u32 {
assert_ok!(Ping::start(
RuntimeOrigin::root(),
ParaId::from(2000 + i),
vec![0u8; 4],
));
assert_ok!(Ping::start(RuntimeOrigin::root(), ParaId::from(2000 + i), vec![0u8; 4],));
}
// 101st should fail.
@@ -144,12 +140,7 @@ fn start_many_respects_max_targets() {
fn start_many_rejects_payload_too_large() {
new_test_ext().execute_with(|| {
assert_noop!(
Ping::start_many(
RuntimeOrigin::root(),
ParaId::from(2000u32),
1,
vec![0u8; 1025],
),
Ping::start_many(RuntimeOrigin::root(), ParaId::from(2000u32), 1, vec![0u8; 1025],),
Error::<Test>::PayloadTooLarge
);
});
@@ -256,9 +247,7 @@ fn ping_from_sibling_para_works() {
assert_ok!(Ping::ping(origin, 1, vec![42u8; 8]));
// Should have deposited a Pinged event.
System::assert_has_event(
Event::<Test>::Pinged(para_id, 1, vec![42u8; 8]).into(),
);
System::assert_has_event(Event::<Test>::Pinged(para_id, 1, vec![42u8; 8]).into());
});
}
@@ -295,9 +284,7 @@ fn pong_processes_known_ping() {
assert!(Pings::<Test>::get(42u32).is_none());
// Should emit Ponged event with the round-trip time.
System::assert_has_event(
Event::<Test>::Ponged(para_id, 42, vec![0u8; 4], 0u64).into(),
);
System::assert_has_event(Event::<Test>::Ponged(para_id, 42, vec![0u8; 4], 0u64).into());
});
}
@@ -310,9 +297,7 @@ fn pong_handles_unknown_pong() {
// No ping entry for seq 99.
assert_ok!(Ping::pong(origin, 99, vec![0u8; 4]));
System::assert_has_event(
Event::<Test>::UnknownPong(para_id, 99, vec![0u8; 4]).into(),
);
System::assert_has_event(Event::<Test>::UnknownPong(para_id, 99, vec![0u8; 4]).into());
});
}
@@ -347,14 +332,7 @@ fn on_finalize_sends_pings_to_targets() {
// Should have emitted PingSent event (MockXcmSender always succeeds).
System::assert_has_event(
Event::<Test>::PingSent(
para,
1,
vec![7u8; 4],
[0u8; 32],
Assets::new(),
)
.into(),
Event::<Test>::PingSent(para, 1, vec![7u8; 4], [0u8; 32], Assets::new()).into(),
);
});
}
@@ -931,7 +931,13 @@ pub mod pezpallet {
// Cannot cancel presales that are already finalized, failed, or cancelled
ensure!(
matches!(presale.status, PresaleStatus::Active | PresaleStatus::Pending | PresaleStatus::Paused | PresaleStatus::Successful),
matches!(
presale.status,
PresaleStatus::Active
| PresaleStatus::Pending
| PresaleStatus::Paused
| PresaleStatus::Successful
),
Error::<T>::AlreadyFinalized,
);
@@ -968,8 +974,7 @@ pub mod pezpallet {
let treasury = Self::presale_account_id(presale_id);
let contributors = Contributors::<T>::get(presale_id);
let end_index =
start_index.saturating_add(batch_size).min(contributors.len() as u32);
let end_index = start_index.saturating_add(batch_size).min(contributors.len() as u32);
let mut refunded_count = 0u32;
let mut total_refunded = 0u128;
@@ -1008,8 +1013,7 @@ pub mod pezpallet {
})?;
refunded_count += 1;
total_refunded =
total_refunded.saturating_add(contribution_info.amount);
total_refunded = total_refunded.saturating_add(contribution_info.amount);
Self::deposit_event(Event::Refunded {
presale_id,
@@ -1129,22 +1133,17 @@ pub mod pezpallet {
) -> DispatchResult {
ensure_signed(origin)?; // Anyone can trigger
let mut presale =
Presales::<T>::get(presale_id).ok_or(Error::<T>::PresaleNotFound)?;
let mut presale = Presales::<T>::get(presale_id).ok_or(Error::<T>::PresaleNotFound)?;
// Only works on SUCCESSFUL presales (soft cap reached, not yet finalized)
ensure!(
presale.status == PresaleStatus::Successful,
Error::<T>::PresaleNotSuccessful,
);
ensure!(presale.status == PresaleStatus::Successful, Error::<T>::PresaleNotSuccessful,);
let total_raised = TotalRaised::<T>::get(presale_id);
let treasury = Self::presale_account_id(presale_id);
let contributors = Contributors::<T>::get(presale_id);
// Calculate end index (don't exceed array length)
let end_index =
start_index.saturating_add(batch_size).min(contributors.len() as u32);
let end_index = start_index.saturating_add(batch_size).min(contributors.len() as u32);
let mut distributed_count = 0u32;
let mut total_distributed = 0u128;
@@ -1229,10 +1228,7 @@ pub mod pezpallet {
presale.status = PresaleStatus::Finalized;
Presales::<T>::insert(presale_id, &presale);
Self::deposit_event(Event::PresaleFinalized {
presale_id,
total_raised,
});
Self::deposit_event(Event::PresaleFinalized { presale_id, total_raised });
}
Self::deposit_event(Event::BatchDistributionCompleted {
@@ -24,8 +24,8 @@ pezsp-runtime = { workspace = true }
pezcumulus-primitives-core = { workspace = true }
[dev-dependencies]
pezsp-io = { workspace = true }
pezsp-core = { workspace = true }
pezsp-io = { workspace = true }
[features]
default = ["std"]
@@ -34,6 +34,8 @@ std = [
"pezcumulus-primitives-core/std",
"pezframe-support/std",
"pezframe-system/std",
"pezsp-core/std",
"pezsp-io/std",
"pezsp-runtime/std",
"scale-info/std",
]
@@ -47,6 +49,7 @@ runtime-benchmarks = [
"pezcumulus-primitives-core/runtime-benchmarks",
"pezframe-support/runtime-benchmarks",
"pezframe-system/runtime-benchmarks",
"pezsp-io/runtime-benchmarks",
"pezsp-runtime/runtime-benchmarks",
]
serde = []
@@ -18,8 +18,8 @@
use crate::mock::*;
use crate::pezpallet::Pezpallet;
use pezframe_support::traits::Get;
use pezcumulus_primitives_core::ParaId;
use pezframe_support::traits::Get;
#[test]
fn genesis_default_teyrchain_id_is_100() {
@@ -780,7 +780,10 @@ pub trait TikiProvider<AccountId> {
impl<T: Config> TikiScoreProvider<T::AccountId> for Pezpallet<T> {
fn get_tiki_score(who: &T::AccountId) -> u32 {
let tikis = Self::user_tikis(who);
tikis.iter().map(Self::get_bonus_for_tiki).fold(0u32, |acc, x| acc.saturating_add(x))
tikis
.iter()
.map(Self::get_bonus_for_tiki)
.fold(0u32, |acc, x| acc.saturating_add(x))
}
}
@@ -401,7 +401,7 @@ pub mod pezpallet {
.saturating_add(tiki_u128.saturating_mul(300));
// Safe: both operands are derived from u32 scores, product fits in u128
let final_score_u128 = staking_u128
let final_score_u128 = staking_u128
.saturating_mul(weighted_sum)
.checked_div(base)
.ok_or(Error::<T>::CalculationOverflow)?;
@@ -653,10 +653,7 @@ pub mod pezpallet {
// H7 fix: Validate endorsers count early, before any storage reads,
// to prevent large Vecs from consuming excessive weight.
ensure!(
endorsers.len() as u32 <= T::MaxEndorsers::get(),
Error::<T>::TooManyEndorsers
);
ensure!(endorsers.len() as u32 <= T::MaxEndorsers::get(), Error::<T>::TooManyEndorsers);
let mut election =
ActiveElections::<T>::get(election_id).ok_or(Error::<T>::ElectionNotFound)?;
@@ -860,8 +857,8 @@ pub mod pezpallet {
let total_citizen_count = Self::get_total_citizen_count();
let turnout_percentage = if total_citizen_count > 0 {
((election.total_votes as u64).saturating_mul(100) / total_citizen_count as u64)
as u8
((election.total_votes as u64).saturating_mul(100)
/ total_citizen_count as u64) as u8
} else {
0
};
@@ -1140,18 +1137,12 @@ pub mod pezpallet {
CollectiveDecisionType::ConstitutionalReview
| CollectiveDecisionType::ConstitutionalUnanimous => {
// Diwan members only
ensure!(
Self::is_diwan_member(&voter),
Error::<T>::NotAuthorizedToVote,
);
ensure!(Self::is_diwan_member(&voter), Error::<T>::NotAuthorizedToVote,);
},
CollectiveDecisionType::ExecutiveDecision => {
// Serok (President) only
let serok = CurrentOfficials::<T>::get(GovernmentPosition::Serok);
ensure!(
serok.as_ref() == Some(&voter),
Error::<T>::NotAuthorizedToVote,
);
ensure!(serok.as_ref() == Some(&voter), Error::<T>::NotAuthorizedToVote,);
},
CollectiveDecisionType::HybridDecision => {
// Parliament members OR Serok
@@ -1159,10 +1150,7 @@ pub mod pezpallet {
let is_parliament = members.iter().any(|m| m.account == voter);
let serok = CurrentOfficials::<T>::get(GovernmentPosition::Serok);
let is_serok = serok.as_ref() == Some(&voter);
ensure!(
is_parliament || is_serok,
Error::<T>::NotAuthorizedToVote,
);
ensure!(is_parliament || is_serok, Error::<T>::NotAuthorizedToVote,);
},
}
+2 -2
View File
@@ -370,10 +370,10 @@ pub mod pezpallet {
// - SelectionHistory::mutate per selected validator
let pool_size = Self::pool_size();
weight = weight.saturating_add(
T::DbWeight::get().reads(pool_size as u64 * 2) // iter + history per member
T::DbWeight::get().reads(pool_size as u64 * 2), // iter + history per member
);
weight = weight.saturating_add(
T::DbWeight::get().writes(3 + pool_size as u64) // era state + history updates
T::DbWeight::get().writes(3 + pool_size as u64), // era state + history updates
);
// Trigger new era if enough time has passed
-1
View File
@@ -1,6 +1,5 @@
[package]
name = "pezkuwi-sdk"
version = "0.0.0"
description = "Pezkuwi SDK umbrella crate."
license = "Apache-2.0"