fix: Complete snowbridge pezpallet rebrand and critical bug fixes

- snowbridge-pezpallet-* → pezsnowbridge-pezpallet-* (201 refs)
- pallet/ directories → pezpallet/ (4 locations)
- Fixed pezpallet.rs self-include recursion bug
- Fixed sc-chain-spec hardcoded crate name in derive macro
- Reverted .pezpallet_by_name() to .pallet_by_name() (subxt API)
- Added BizinikiwiConfig type alias for zombienet tests
- Deleted obsolete session state files

Verified: pezsnowbridge-pezpallet-*, pezpallet-staking,
pezpallet-staking-async, pezframe-benchmarking-cli all pass cargo check
This commit is contained in:
2025-12-16 09:57:23 +03:00
parent eea003e14d
commit 3139ffa25e
3022 changed files with 42157 additions and 23579 deletions
@@ -25,7 +25,7 @@ mod benchmarks {
#[benchmark]
fn register_candidate() {
// --- SETUP ---
Pallet::<T>::initiate_election(
Pezpallet::<T>::initiate_election(
RawOrigin::Root.into(),
ElectionType::Parliamentary,
None,
@@ -52,7 +52,7 @@ mod benchmarks {
fn cast_vote() {
// --- SETUP ---
// 1. Prepare election and candidates
Pallet::<T>::initiate_election(
Pezpallet::<T>::initiate_election(
RawOrigin::Root.into(),
ElectionType::Parliamentary,
None,
@@ -70,7 +70,7 @@ mod benchmarks {
// KYC check is already bypassed in test environment
Pallet::<T>::register_candidate(
Pezpallet::<T>::register_candidate(
RawOrigin::Signed(candidate.clone()).into(),
0,
None,
@@ -80,7 +80,7 @@ mod benchmarks {
// 2. Advance to voting period
let election = ActiveElections::<T>::get(0).unwrap();
pezframe_system::Pallet::<T>::set_block_number(election.voting_start);
pezframe_system::Pezpallet::<T>::set_block_number(election.voting_start);
let candidates_to_vote_for = vec![candidate];
@@ -94,7 +94,7 @@ mod benchmarks {
fn finalize_election() {
// --- SETUP ---
// 1. Prepare election, candidate and a vote
Pallet::<T>::initiate_election(
Pezpallet::<T>::initiate_election(
RawOrigin::Root.into(),
ElectionType::Parliamentary,
None,
@@ -111,7 +111,7 @@ mod benchmarks {
// KYC check is already bypassed in test environment
Pallet::<T>::register_candidate(
Pezpallet::<T>::register_candidate(
RawOrigin::Signed(candidate.clone()).into(),
0,
None,
@@ -120,12 +120,12 @@ mod benchmarks {
.unwrap();
let election = ActiveElections::<T>::get(0).unwrap();
pezframe_system::Pallet::<T>::set_block_number(election.voting_start);
Pallet::<T>::cast_vote(RawOrigin::Signed(voter.clone()).into(), 0, vec![candidate], None)
pezframe_system::Pezpallet::<T>::set_block_number(election.voting_start);
Pezpallet::<T>::cast_vote(RawOrigin::Signed(voter.clone()).into(), 0, vec![candidate], None)
.unwrap();
// 2. Advance to election end time
pezframe_system::Pallet::<T>::set_block_number(election.end_block + 1u32.into());
pezframe_system::Pezpallet::<T>::set_block_number(election.end_block + 1u32.into());
#[extrinsic_call]
finalize_election(RawOrigin::Root, 0);
@@ -175,7 +175,7 @@ mod benchmarks {
CurrentOfficials::<T>::insert(GovernmentPosition::Serok, nominator.clone());
// Use a different role (Dozger) to avoid conflicts with nominate_official benchmark
Pallet::<T>::nominate_official(
Pezpallet::<T>::nominate_official(
RawOrigin::Signed(nominator).into(),
nominee.clone(),
OfficialRole::Dozger,
@@ -265,7 +265,7 @@ mod benchmarks {
let title = b"Test Proposal".to_vec().try_into().unwrap();
let description = b"Test proposal description".to_vec().try_into().unwrap();
Pallet::<T>::submit_proposal(
Pezpallet::<T>::submit_proposal(
RawOrigin::Signed(proposer).into(),
title,
description,
@@ -276,7 +276,7 @@ mod benchmarks {
.unwrap();
let proposal = ActiveProposals::<T>::get(0).unwrap();
pezframe_system::Pallet::<T>::set_block_number(proposal.voting_starts_at + 1u32.into());
pezframe_system::Pezpallet::<T>::set_block_number(proposal.voting_starts_at + 1u32.into());
let rationale = Some(b"Test vote rationale".to_vec().try_into().unwrap());
@@ -298,7 +298,7 @@ mod benchmarks {
}
impl_benchmark_test_suite!(
Pallet,
Pezpallet,
crate::mock::ExtBuilder::default().build(),
crate::mock::Test
);
@@ -1,13 +1,13 @@
#![cfg_attr(not(feature = "std"), no_std)]
//! # Welati (Governance) Pallet
//! # Welati (Governance) Pezpallet
//!
//! A comprehensive governance pallet implementing elections, voting, and government structure
//! A comprehensive governance pezpallet implementing elections, voting, and government structure
//! management.
//!
//! ## Overview
//!
//! The Welati pallet provides complete governance infrastructure including:
//! The Welati pezpallet provides complete governance infrastructure including:
//! - **Presidential Elections**: Direct democratic election of Serok (President)
//! - **Parliamentary Elections**: District-based representation in parliament
//! - **Cabinet Formation**: Prime Minister selection and ministerial appointments
@@ -136,7 +136,7 @@
//! }
//! ```
pub use pallet::*;
pub use pezpallet::*;
pub mod migrations;
pub mod types;
pub mod weights; // Storage migrations
@@ -150,7 +150,7 @@ mod tests;
use crate::types::*;
/// Weight functions trait for this pallet.
/// Weight functions trait for this pezpallet.
pub trait WeightInfo {
fn initiate_election() -> Weight;
fn register_candidate() -> Weight;
@@ -208,15 +208,15 @@ pub trait CitizenInfo {
fn citizen_count() -> u32;
}
#[pezframe_support::pallet]
pub mod pallet {
#[pezframe_support::pezpallet]
pub mod pezpallet {
use super::*;
#[pallet::pallet]
#[pallet::storage_version(migrations::STORAGE_VERSION)]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
#[pezpallet::storage_version(migrations::STORAGE_VERSION)]
pub struct Pezpallet<T>(_);
#[pallet::config]
#[pezpallet::config]
pub trait Config:
pezframe_system::Config
+ pezpallet_tiki::Config
@@ -237,21 +237,21 @@ pub mod pallet {
type CitizenSource: CitizenInfo;
type KycSource: KycStatus<Self::AccountId>;
#[pallet::constant]
#[pezpallet::constant]
type ParliamentSize: Get<u32>;
#[pallet::constant]
#[pezpallet::constant]
type DiwanSize: Get<u32>;
#[pallet::constant]
#[pezpallet::constant]
type ElectionPeriod: Get<BlockNumberFor<Self>>;
#[pallet::constant]
#[pezpallet::constant]
type CandidacyPeriod: Get<BlockNumberFor<Self>>;
#[pallet::constant]
#[pezpallet::constant]
type CampaignPeriod: Get<BlockNumberFor<Self>>;
#[pallet::constant]
#[pezpallet::constant]
type ElectoralDistricts: Get<u32>;
#[pallet::constant]
#[pezpallet::constant]
type CandidacyDeposit: Get<u128>;
#[pallet::constant]
#[pezpallet::constant]
type PresidentialEndorsements: Get<u32>;
type ParliamentaryEndorsements: Get<u32>;
}
@@ -259,48 +259,48 @@ pub mod pallet {
// --- CORE GOVERNANCE STORAGE ---
/// Storage holding current government positions
#[pallet::storage]
#[pallet::getter(fn current_officials)]
#[pezpallet::storage]
#[pezpallet::getter(fn current_officials)]
pub type CurrentOfficials<T: Config> =
StorageMap<_, Blake2_128Concat, GovernmentPosition, T::AccountId, OptionQuery>;
/// Storage holding current ministers
#[pallet::storage]
#[pallet::getter(fn current_ministers)]
#[pezpallet::storage]
#[pezpallet::getter(fn current_ministers)]
pub type CurrentMinisters<T: Config> =
StorageMap<_, Blake2_128Concat, MinisterRole, T::AccountId, OptionQuery>;
/// Storage holding parliament members
#[pallet::storage]
#[pallet::getter(fn parliament_members)]
#[pezpallet::storage]
#[pezpallet::getter(fn parliament_members)]
pub type ParliamentMembers<T: Config> =
StorageValue<_, BoundedVec<ParliamentMember<T>, T::ParliamentSize>, ValueQuery>;
/// Storage holding Diwan members
#[pallet::storage]
#[pallet::getter(fn diwan_members)]
#[pezpallet::storage]
#[pezpallet::getter(fn diwan_members)]
pub type DiwanMembers<T: Config> =
StorageValue<_, BoundedVec<DiwanMember<T>, T::DiwanSize>, ValueQuery>;
/// Storage holding appointed government officials (OfficialRole)
#[pallet::storage]
#[pallet::getter(fn appointed_officials)]
#[pezpallet::storage]
#[pezpallet::getter(fn appointed_officials)]
pub type AppointedOfficials<T: Config> =
StorageMap<_, Blake2_128Concat, OfficialRole, T::AccountId, OptionQuery>;
// --- ELECTION SYSTEM STORAGE ---
/// Storage holding active elections
#[pallet::storage]
#[pezpallet::storage]
pub type ActiveElections<T: Config> =
StorageMap<_, Blake2_128Concat, u32, ElectionInfo<T>, OptionQuery>;
/// Next election ID
#[pallet::storage]
#[pezpallet::storage]
pub type NextElectionId<T: Config> = StorageValue<_, u32, ValueQuery>;
/// Storage holding election candidates
#[pallet::storage]
#[pezpallet::storage]
pub type ElectionCandidates<T: Config> = StorageDoubleMap<
_,
Blake2_128Concat,
@@ -312,7 +312,7 @@ pub mod pallet {
>;
/// Storage holding election votes
#[pallet::storage]
#[pezpallet::storage]
pub type ElectionVotes<T: Config> = StorageDoubleMap<
_,
Blake2_128Concat,
@@ -324,19 +324,19 @@ pub mod pallet {
>;
/// Storage holding election results
#[pallet::storage]
#[pezpallet::storage]
pub type ElectionResults<T: Config> =
StorageMap<_, Blake2_128Concat, u32, ElectionResult<T>, OptionQuery>;
/// Storage holding electoral districts
#[pallet::storage]
#[pezpallet::storage]
pub type ElectoralDistrictConfig<T: Config> =
StorageMap<_, Blake2_128Concat, u32, ElectoralDistrict, ValueQuery>;
// --- APPOINTMENT SYSTEM STORAGE ---
/// Storage holding pending nominations
#[pallet::storage]
#[pezpallet::storage]
pub type PendingNominations<T: Config> = StorageDoubleMap<
_,
Blake2_128Concat,
@@ -348,27 +348,27 @@ pub mod pallet {
>;
/// Storage holding appointment processes
#[pallet::storage]
#[pezpallet::storage]
pub type AppointmentProcesses<T: Config> =
StorageMap<_, Blake2_128Concat, u32, AppointmentProcess<T>, OptionQuery>;
/// Next appointment process ID
#[pallet::storage]
#[pezpallet::storage]
pub type NextAppointmentId<T: Config> = StorageValue<_, u32, ValueQuery>;
// --- COLLECTIVE DECISION STORAGE ---
/// Storage holding active proposals
#[pallet::storage]
#[pezpallet::storage]
pub type ActiveProposals<T: Config> =
StorageMap<_, Blake2_128Concat, u32, CollectiveProposal<T>, OptionQuery>;
/// Next proposal ID
#[pallet::storage]
#[pezpallet::storage]
pub type NextProposalId<T: Config> = StorageValue<_, u32, ValueQuery>;
/// Storage holding collective votes
#[pallet::storage]
#[pezpallet::storage]
pub type CollectiveVotes<T: Config> = StorageDoubleMap<
_,
Blake2_128Concat,
@@ -380,12 +380,12 @@ pub mod pallet {
>;
/// Storage holding governance metrics
#[pallet::storage]
#[pezpallet::storage]
pub type GovernanceStats<T: Config> = StorageValue<_, GovernanceMetrics<T>, OptionQuery>;
// --- Events ---
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
#[pezpallet::event]
#[pezpallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
// --- ELECTION EVENTS ---
/// Election started
@@ -481,7 +481,7 @@ pub mod pallet {
},
}
#[pallet::error]
#[pezpallet::error]
pub enum Error<T> {
// General errors
InsufficientTrustScore,
@@ -531,11 +531,11 @@ pub mod pallet {
}
// --- Extrinsics ---
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pezpallet::call]
impl<T: Config> Pezpallet<T> {
/// Initiates a new election
#[pallet::call_index(0)]
#[pallet::weight(<T as pallet::Config>::WeightInfo::initiate_election())]
#[pezpallet::call_index(0)]
#[pezpallet::weight(<T as pezpallet::Config>::WeightInfo::initiate_election())]
pub fn initiate_election(
origin: OriginFor<T>,
election_type: ElectionType,
@@ -547,7 +547,7 @@ pub mod pallet {
let election_id = NextElectionId::<T>::get();
NextElectionId::<T>::put(election_id.saturating_add(1));
let current_block = <pezframe_system::Pallet<T>>::block_number();
let current_block = <pezframe_system::Pezpallet<T>>::block_number();
let candidacy_deadline;
let campaign_start;
@@ -628,8 +628,8 @@ pub mod pallet {
}
/// Register as election candidate
#[pallet::call_index(1)]
#[pallet::weight(<T as pallet::Config>::WeightInfo::register_candidate())]
#[pezpallet::call_index(1)]
#[pezpallet::weight(<T as pezpallet::Config>::WeightInfo::register_candidate())]
pub fn register_candidate(
origin: OriginFor<T>,
election_id: u32,
@@ -641,7 +641,7 @@ pub mod pallet {
let mut election =
ActiveElections::<T>::get(election_id).ok_or(Error::<T>::ElectionNotFound)?;
let current_block = pezframe_system::Pallet::<T>::block_number();
let current_block = pezframe_system::Pezpallet::<T>::block_number();
ensure!(
current_block <= election.candidacy_deadline,
Error::<T>::CandidacyPeriodExpired
@@ -651,7 +651,7 @@ pub mod pallet {
#[cfg(not(any(test, feature = "runtime-benchmarks")))]
{
ensure!(
<pezpallet_identity_kyc::Pallet<T> as KycStatus<T::AccountId>>::get_kyc_status(
<pezpallet_identity_kyc::Pezpallet<T> as KycStatus<T::AccountId>>::get_kyc_status(
&candidate
) == KycLevel::Approved,
Error::<T>::NotACitizen
@@ -684,7 +684,7 @@ pub mod pallet {
{
for endorser in &endorsers {
ensure!(
<pezpallet_identity_kyc::Pallet<T> as KycStatus<T::AccountId>>::get_kyc_status(
<pezpallet_identity_kyc::Pezpallet<T> as KycStatus<T::AccountId>>::get_kyc_status(
endorser
) == KycLevel::Approved,
Error::<T>::NotACitizen
@@ -729,8 +729,8 @@ pub mod pallet {
}
/// Cast vote
#[pallet::call_index(2)]
#[pallet::weight(<T as pallet::Config>::WeightInfo::cast_vote())]
#[pezpallet::call_index(2)]
#[pezpallet::weight(<T as pezpallet::Config>::WeightInfo::cast_vote())]
pub fn cast_vote(
origin: OriginFor<T>,
election_id: u32,
@@ -742,7 +742,7 @@ pub mod pallet {
let mut election =
ActiveElections::<T>::get(election_id).ok_or(Error::<T>::ElectionNotFound)?;
let current_block = pezframe_system::Pallet::<T>::block_number();
let current_block = pezframe_system::Pezpallet::<T>::block_number();
ensure!(
current_block >= election.voting_start && current_block <= election.end_block,
Error::<T>::VotingPeriodNotStarted
@@ -752,7 +752,7 @@ pub mod pallet {
#[cfg(not(any(test, feature = "runtime-benchmarks")))]
{
ensure!(
<pezpallet_identity_kyc::Pallet<T> as KycStatus<T::AccountId>>::get_kyc_status(
<pezpallet_identity_kyc::Pezpallet<T> as KycStatus<T::AccountId>>::get_kyc_status(
&voter
) == KycLevel::Approved,
Error::<T>::NotACitizen
@@ -805,15 +805,15 @@ pub mod pallet {
}
/// Finalizes election and determines winners
#[pallet::call_index(3)]
#[pallet::weight(<T as pallet::Config>::WeightInfo::finalize_election())]
#[pezpallet::call_index(3)]
#[pezpallet::weight(<T as pezpallet::Config>::WeightInfo::finalize_election())]
pub fn finalize_election(origin: OriginFor<T>, election_id: u32) -> DispatchResult {
ensure_root(origin)?;
let mut election =
ActiveElections::<T>::get(election_id).ok_or(Error::<T>::ElectionNotFound)?;
let current_block = pezframe_system::Pallet::<T>::block_number();
let current_block = pezframe_system::Pezpallet::<T>::block_number();
ensure!(current_block > election.end_block, Error::<T>::ElectionNotActive);
ensure!(
@@ -869,12 +869,12 @@ pub mod pallet {
Ok(())
}
#[pallet::call_index(10)]
#[pallet::weight(<T as pallet::Config>::WeightInfo::nominate_official())]
#[pallet::feeless_if(|origin: &OriginFor<T>, _nominee: &T::AccountId, _role: &OfficialRole, _justification: &BoundedVec<u8, ConstU32<1000>>| -> bool {
#[pezpallet::call_index(10)]
#[pezpallet::weight(<T as pezpallet::Config>::WeightInfo::nominate_official())]
#[pezpallet::feeless_if(|origin: &OriginFor<T>, _nominee: &T::AccountId, _role: &OfficialRole, _justification: &BoundedVec<u8, ConstU32<1000>>| -> bool {
// Governance members are exempt from fees when performing official duties
match ensure_signed(origin.clone()) {
Ok(who) => Pallet::<T>::is_governance_member(&who),
Ok(who) => Pezpallet::<T>::is_governance_member(&who),
Err(_) => false,
}
})]
@@ -908,7 +908,7 @@ pub mod pallet {
let process_id = NextAppointmentId::<T>::get();
NextAppointmentId::<T>::mutate(|id| *id = id.saturating_add(1));
let current_block = pezframe_system::Pallet::<T>::block_number();
let current_block = pezframe_system::Pezpallet::<T>::block_number();
let deadline = current_block + BlockNumberFor::<T>::from(14400u32 * 7u32); // 7 days
// Create nomination info
@@ -949,12 +949,12 @@ pub mod pallet {
Ok(())
}
#[pallet::call_index(11)]
#[pallet::weight(<T as pallet::Config>::WeightInfo::approve_appointment())]
#[pallet::feeless_if(|origin: &OriginFor<T>, _process_id: &u32| -> bool {
#[pezpallet::call_index(11)]
#[pezpallet::weight(<T as pezpallet::Config>::WeightInfo::approve_appointment())]
#[pezpallet::feeless_if(|origin: &OriginFor<T>, _process_id: &u32| -> bool {
// Serok (President) is exempt from fees when approving appointments
match ensure_signed(origin.clone()) {
Ok(who) => Pallet::<T>::is_serok(&who),
Ok(who) => Pezpallet::<T>::is_serok(&who),
Err(_) => false,
}
})]
@@ -981,7 +981,7 @@ pub mod pallet {
.ok_or(Error::<T>::NominationNotFound)?;
// Update nomination
let current_block = pezframe_system::Pallet::<T>::block_number();
let current_block = pezframe_system::Pezpallet::<T>::block_number();
nomination.approved = true;
nomination.approver = Some(approver.clone());
nomination.approved_at = Some(current_block);
@@ -1007,12 +1007,12 @@ pub mod pallet {
Ok(())
}
#[pallet::call_index(20)]
#[pallet::weight(<T as pallet::Config>::WeightInfo::submit_proposal())]
#[pallet::feeless_if(|origin: &OriginFor<T>, _title: &BoundedVec<u8, ConstU32<100>>, _description: &BoundedVec<u8, ConstU32<1000>>, _decision_type: &CollectiveDecisionType, _priority: &ProposalPriority, _call: &Option<Box<<T as pezframe_system::Config>::RuntimeCall>>| -> bool {
#[pezpallet::call_index(20)]
#[pezpallet::weight(<T as pezpallet::Config>::WeightInfo::submit_proposal())]
#[pezpallet::feeless_if(|origin: &OriginFor<T>, _title: &BoundedVec<u8, ConstU32<100>>, _description: &BoundedVec<u8, ConstU32<1000>>, _decision_type: &CollectiveDecisionType, _priority: &ProposalPriority, _call: &Option<Box<<T as pezframe_system::Config>::RuntimeCall>>| -> bool {
// Governance members are exempt from fees when submitting proposals
match ensure_signed(origin.clone()) {
Ok(who) => Pallet::<T>::is_governance_member(&who),
Ok(who) => Pezpallet::<T>::is_governance_member(&who),
Err(_) => false,
}
})]
@@ -1033,7 +1033,7 @@ pub mod pallet {
let proposal_id = NextProposalId::<T>::get();
NextProposalId::<T>::put(proposal_id.saturating_add(1));
let current_block = <pezframe_system::Pallet<T>>::block_number();
let current_block = <pezframe_system::Pezpallet<T>>::block_number();
let voting_starts_at = current_block + 14400u32.into();
let expires_at = voting_starts_at + T::ElectionPeriod::get();
@@ -1068,12 +1068,12 @@ pub mod pallet {
Ok(())
}
#[pallet::call_index(21)]
#[pallet::weight(<T as pallet::Config>::WeightInfo::vote_on_proposal())]
#[pallet::feeless_if(|origin: &OriginFor<T>, _proposal_id: &u32, _vote: &VoteChoice, _rationale: &Option<BoundedVec<u8, ConstU32<500>>>| -> bool {
#[pezpallet::call_index(21)]
#[pezpallet::weight(<T as pezpallet::Config>::WeightInfo::vote_on_proposal())]
#[pezpallet::feeless_if(|origin: &OriginFor<T>, _proposal_id: &u32, _vote: &VoteChoice, _rationale: &Option<BoundedVec<u8, ConstU32<500>>>| -> bool {
// Governance members are exempt from fees when voting
match ensure_signed(origin.clone()) {
Ok(who) => Pallet::<T>::is_governance_member(&who),
Ok(who) => Pezpallet::<T>::is_governance_member(&who),
Err(_) => false,
}
})]
@@ -1116,7 +1116,7 @@ pub mod pallet {
voter: voter.clone(),
proposal_id,
vote,
voted_at: pezframe_system::Pallet::<T>::block_number(),
voted_at: pezframe_system::Pezpallet::<T>::block_number(),
rationale,
};
@@ -1142,7 +1142,7 @@ pub mod pallet {
}
// ====== PUBLIC GETTERS FOR TESTS ======
impl<T: Config> Pallet<T> {
impl<T: Config> Pezpallet<T> {
pub fn active_elections(election_id: u32) -> Option<ElectionInfo<T>> {
ActiveElections::<T>::get(election_id)
}
@@ -1194,7 +1194,7 @@ pub mod pallet {
}
// ====== HELPER FUNCTIONS ======
impl<T: Config> Pallet<T> {
impl<T: Config> Pezpallet<T> {
/// Serok origin check
pub fn ensure_serok(origin: OriginFor<T>) -> Result<T::AccountId, DispatchError> {
let who = ensure_signed(origin)?;
@@ -1354,7 +1354,7 @@ pub mod pallet {
CurrentOfficials::<T>::insert(GovernmentPosition::Serok, winner);
},
ElectionType::Parliamentary => {
let current_block = pezframe_system::Pallet::<T>::block_number();
let current_block = pezframe_system::Pezpallet::<T>::block_number();
let term_end = current_block +
BlockNumberFor::<T>::from(4u32 * 365u32 * 24u32 * 60u32 * 10u32);
@@ -1433,7 +1433,7 @@ pub mod pallet {
/// For Serok origin check
pub struct EnsureSerok<T>(pezsp_std::marker::PhantomData<T>);
impl<T: pallet::Config> EnsureOrigin<<T as pezframe_system::Config>::RuntimeOrigin>
impl<T: pezpallet::Config> EnsureOrigin<<T as pezframe_system::Config>::RuntimeOrigin>
for EnsureSerok<T>
{
type Success = T::AccountId;
@@ -1444,7 +1444,7 @@ impl<T: pallet::Config> EnsureOrigin<<T as pezframe_system::Config>::RuntimeOrig
match o.clone().into() {
Ok(pezframe_system::RawOrigin::Signed(who)) => {
if let Some(current_serok) =
pallet::Pallet::<T>::current_officials(GovernmentPosition::Serok)
pezpallet::Pezpallet::<T>::current_officials(GovernmentPosition::Serok)
{
if who == current_serok {
return Ok(who);
@@ -1459,7 +1459,7 @@ impl<T: pallet::Config> EnsureOrigin<<T as pezframe_system::Config>::RuntimeOrig
#[cfg(feature = "runtime-benchmarks")]
fn try_successful_origin() -> Result<<T as pezframe_system::Config>::RuntimeOrigin, ()> {
let serok_account: T::AccountId = pezframe_benchmarking::account("serok", 0, 0);
pallet::CurrentOfficials::<T>::insert(GovernmentPosition::Serok, serok_account.clone());
pezpallet::CurrentOfficials::<T>::insert(GovernmentPosition::Serok, serok_account.clone());
Ok(pezframe_system::RawOrigin::Signed(serok_account).into())
}
}
@@ -1467,7 +1467,7 @@ impl<T: pallet::Config> EnsureOrigin<<T as pezframe_system::Config>::RuntimeOrig
/// For Parliament member origin check
pub struct EnsureParlementer<T>(pezsp_std::marker::PhantomData<T>);
impl<T: pallet::Config> EnsureOrigin<<T as pezframe_system::Config>::RuntimeOrigin>
impl<T: pezpallet::Config> EnsureOrigin<<T as pezframe_system::Config>::RuntimeOrigin>
for EnsureParlementer<T>
{
type Success = T::AccountId;
@@ -1477,7 +1477,7 @@ impl<T: pallet::Config> EnsureOrigin<<T as pezframe_system::Config>::RuntimeOrig
) -> Result<Self::Success, <T as pezframe_system::Config>::RuntimeOrigin> {
match o.clone().into() {
Ok(pezframe_system::RawOrigin::Signed(who)) => {
let parliament_members = pallet::Pallet::<T>::parliament_members();
let parliament_members = pezpallet::Pezpallet::<T>::parliament_members();
if parliament_members.iter().any(|member| member.account == who) {
return Ok(who);
}
@@ -1508,7 +1508,7 @@ impl<T: pallet::Config> EnsureOrigin<<T as pezframe_system::Config>::RuntimeOrig
/// For Diwan origin check
pub struct EnsureDiwan<T>(pezsp_std::marker::PhantomData<T>);
impl<T: pallet::Config> EnsureOrigin<<T as pezframe_system::Config>::RuntimeOrigin>
impl<T: pezpallet::Config> EnsureOrigin<<T as pezframe_system::Config>::RuntimeOrigin>
for EnsureDiwan<T>
{
type Success = T::AccountId;
@@ -1518,7 +1518,7 @@ impl<T: pallet::Config> EnsureOrigin<<T as pezframe_system::Config>::RuntimeOrig
) -> Result<Self::Success, <T as pezframe_system::Config>::RuntimeOrigin> {
match o.clone().into() {
Ok(pezframe_system::RawOrigin::Signed(who)) => {
let diwan_members = pallet::Pallet::<T>::diwan_members();
let diwan_members = pezpallet::Pezpallet::<T>::diwan_members();
if diwan_members.iter().any(|member| member.account == who) {
return Ok(who);
}
@@ -1548,7 +1548,7 @@ impl<T: pallet::Config> EnsureOrigin<<T as pezframe_system::Config>::RuntimeOrig
// ====== HELPER FUNCTIONS FOR FEE EXEMPTION ======
impl<T: Config> Pallet<T> {
impl<T: Config> Pezpallet<T> {
/// Check if an account is any type of governance member
/// Used for fee exemption in governance-related transactions
pub fn is_governance_member(who: &T::AccountId) -> bool {
@@ -19,7 +19,7 @@ pub mod v1 {
impl<T: Config> OnRuntimeUpgrade for MigrateToV1<T> {
fn on_runtime_upgrade() -> Weight {
let current = Pallet::<T>::on_chain_storage_version();
let current = Pezpallet::<T>::on_chain_storage_version();
log::info!(
"🔄 Running migration for pezpallet-welati from {:?} to {:?}",
@@ -43,7 +43,7 @@ pub mod v1 {
migrated = officials_count + ministers_count + elections_count + proposals_count;
// Update storage version
STORAGE_VERSION.put::<Pallet<T>>();
STORAGE_VERSION.put::<Pezpallet<T>>();
log::info!("✅ Migrated {} entries in pezpallet-welati", migrated);
log::info!(
@@ -71,7 +71,7 @@ pub mod v1 {
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<pezsp_std::vec::Vec<u8>, pezsp_runtime::TryRuntimeError> {
let current = Pallet::<T>::on_chain_storage_version();
let current = Pezpallet::<T>::on_chain_storage_version();
log::info!("🔍 Pre-upgrade check for pezpallet-welati");
log::info!(" Current version: {:?}", current);
@@ -152,7 +152,7 @@ pub mod v1 {
log::info!("🔍 Post-upgrade check for pezpallet-welati");
// Verify storage version was updated
let current_version = Pallet::<T>::on_chain_storage_version();
let current_version = Pezpallet::<T>::on_chain_storage_version();
assert_eq!(current_version, STORAGE_VERSION, "Storage version not updated correctly");
log::info!("✅ Storage version updated to {:?}", current_version);
@@ -309,7 +309,7 @@ pub mod v2 {
impl<T: Config> OnRuntimeUpgrade for MigrateToV2<T> {
fn on_runtime_upgrade() -> Weight {
let current = Pallet::<T>::on_chain_storage_version();
let current = Pezpallet::<T>::on_chain_storage_version();
if current < StorageVersion::new(2) {
log::info!("🔄 Running migration for pezpallet-welati to v2");
@@ -321,7 +321,7 @@ pub mod v2 {
// 4. Update version
// For now, this is just a template
StorageVersion::new(2).put::<Pallet<T>>();
StorageVersion::new(2).put::<Pezpallet<T>>();
log::info!("✅ Completed migration to pezpallet-welati v2");
@@ -356,13 +356,13 @@ mod tests {
fn test_migration_v1() {
ExtBuilder::default().build().execute_with(|| {
// Set initial storage version to 0
StorageVersion::new(0).put::<Pallet<Test>>();
StorageVersion::new(0).put::<Pezpallet<Test>>();
// Run migration
let weight = v1::MigrateToV1::<Test>::on_runtime_upgrade();
// Verify version was updated
assert_eq!(Pallet::<Test>::on_chain_storage_version(), STORAGE_VERSION);
assert_eq!(Pezpallet::<Test>::on_chain_storage_version(), STORAGE_VERSION);
// Verify weight is non-zero
assert!(weight != Weight::zero());
@@ -373,7 +373,7 @@ mod tests {
fn test_migration_idempotent() {
ExtBuilder::default().build().execute_with(|| {
// Set current version
STORAGE_VERSION.put::<Pallet<Test>>();
STORAGE_VERSION.put::<Pezpallet<Test>>();
// Run migration again
let weight = v1::MigrateToV1::<Test>::on_runtime_upgrade();
@@ -1311,7 +1311,7 @@ fn proposal_id_increments_correctly() {
#[test]
fn multiple_elections_different_types() {
ExtBuilder::default().build().execute_with(|| {
pezframe_system::Pallet::<Test>::set_block_number(1);
pezframe_system::Pezpallet::<Test>::set_block_number(1);
// Start presidential election
assert_ok!(Welati::initiate_election(
@@ -1348,7 +1348,7 @@ fn multiple_elections_different_types() {
#[test]
fn sequential_elections_id_increment() {
ExtBuilder::default().build().execute_with(|| {
pezframe_system::Pallet::<Test>::set_block_number(1);
pezframe_system::Pezpallet::<Test>::set_block_number(1);
// Initial ID should be 0
assert_eq!(Welati::next_election_id(), 0);
@@ -1382,7 +1382,7 @@ fn sequential_elections_id_increment() {
#[test]
fn proposal_and_election_storage_independent() {
ExtBuilder::default().build().execute_with(|| {
pezframe_system::Pallet::<Test>::set_block_number(1);
pezframe_system::Pezpallet::<Test>::set_block_number(1);
add_parliament_member(1);
// Create a proposal
@@ -28,7 +28,7 @@
// ./target/release/frame-omni-bencher
// v1
// benchmark
// pallet
// pezpallet
// --runtime
// target/release/wbuild/people-pezkuwichain-runtime/people_pezkuwichain_runtime.compact.compressed.wasm
// --pallets