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