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:
@@ -13,14 +13,14 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! The pallet benchmarks.
|
||||
//! The pezpallet benchmarks.
|
||||
|
||||
use super::{Pallet as CollectiveContent, *};
|
||||
use super::{Pezpallet as CollectiveContent, *};
|
||||
use pezframe_benchmarking::v2::*;
|
||||
use pezframe_support::traits::EnsureOrigin;
|
||||
|
||||
fn assert_last_event<T: Config<I>, I: 'static>(generic_event: <T as Config<I>>::RuntimeEvent) {
|
||||
pezframe_system::Pallet::<T>::assert_last_event(generic_event.into());
|
||||
pezframe_system::Pezpallet::<T>::assert_last_event(generic_event.into());
|
||||
}
|
||||
|
||||
/// returns CID hash of 68 bytes of given `i`.
|
||||
@@ -50,7 +50,7 @@ mod benchmarks {
|
||||
#[benchmark]
|
||||
fn announce() -> Result<(), BenchmarkError> {
|
||||
let expire_at = DispatchTime::<_>::At(10u32.into());
|
||||
let now = pezframe_system::Pallet::<T>::block_number();
|
||||
let now = pezframe_system::Pezpallet::<T>::block_number();
|
||||
let cid: OpaqueCid = create_cid(1);
|
||||
let origin = T::AnnouncementOrigin::try_successful_origin()
|
||||
.map_err(|_| BenchmarkError::Weightless)?;
|
||||
|
||||
@@ -13,22 +13,22 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Managed Collective Content Pallet
|
||||
//! Managed Collective Content Pezpallet
|
||||
//!
|
||||
//! The pallet provides the functionality to store different types of content. This would typically
|
||||
//! The pezpallet provides the functionality to store different types of content. This would typically
|
||||
//! be used by an on-chain collective, such as the Pezkuwi Alliance or Ambassador Program.
|
||||
//!
|
||||
//! The pallet stores content as an [OpaqueCid], which should correspond to some off-chain hosting
|
||||
//! The pezpallet stores content as an [OpaqueCid], which should correspond to some off-chain hosting
|
||||
//! service, such as IPFS, and contain any type of data. Each type of content has its own origin
|
||||
//! from which it can be managed. The origins are configurable in the runtime. Storing content does
|
||||
//! not require a deposit, as it is expected to be managed by a trusted collective.
|
||||
//!
|
||||
//! Content types:
|
||||
//!
|
||||
//! - Collective [charter](pallet::Charter): A single document (`OpaqueCid`) managed by
|
||||
//! [CharterOrigin](pallet::Config::CharterOrigin).
|
||||
//! - Collective [announcements](pallet::Announcements): A list of announcements managed by
|
||||
//! [AnnouncementOrigin](pallet::Config::AnnouncementOrigin).
|
||||
//! - Collective [charter](pezpallet::Charter): A single document (`OpaqueCid`) managed by
|
||||
//! [CharterOrigin](pezpallet::Config::CharterOrigin).
|
||||
//! - Collective [announcements](pezpallet::Announcements): A list of announcements managed by
|
||||
//! [AnnouncementOrigin](pezpallet::Config::AnnouncementOrigin).
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
@@ -41,7 +41,7 @@ mod tests;
|
||||
mod benchmarking;
|
||||
pub mod weights;
|
||||
|
||||
pub use pallet::*;
|
||||
pub use pezpallet::*;
|
||||
pub use weights::WeightInfo;
|
||||
|
||||
use pezframe_support::{traits::schedule::DispatchTime, BoundedVec};
|
||||
@@ -51,8 +51,8 @@ use pezsp_core::ConstU32;
|
||||
// Worst case 2 bytes base and codec, 2 bytes hash type and size, 64 bytes hash digest.
|
||||
pub type OpaqueCid = BoundedVec<u8, ConstU32<68>>;
|
||||
|
||||
#[pezframe_support::pallet]
|
||||
pub mod pallet {
|
||||
#[pezframe_support::pezpallet]
|
||||
pub mod pezpallet {
|
||||
use super::*;
|
||||
use pezframe_support::{ensure, pezpallet_prelude::*};
|
||||
use pezframe_system::pezpallet_prelude::*;
|
||||
@@ -61,12 +61,12 @@ pub mod pallet {
|
||||
/// The in-code storage version.
|
||||
const STORAGE_VERSION: StorageVersion = StorageVersion::new(0);
|
||||
|
||||
#[pallet::pallet]
|
||||
#[pallet::storage_version(STORAGE_VERSION)]
|
||||
pub struct Pallet<T, I = ()>(PhantomData<(T, I)>);
|
||||
#[pezpallet::pezpallet]
|
||||
#[pezpallet::storage_version(STORAGE_VERSION)]
|
||||
pub struct Pezpallet<T, I = ()>(PhantomData<(T, I)>);
|
||||
|
||||
/// The module configuration trait.
|
||||
#[pallet::config]
|
||||
#[pezpallet::config]
|
||||
pub trait Config<I: 'static = ()>: pezframe_system::Config {
|
||||
/// The overarching event type.
|
||||
#[allow(deprecated)]
|
||||
@@ -80,17 +80,17 @@ pub mod pallet {
|
||||
type AnnouncementOrigin: EnsureOrigin<Self::RuntimeOrigin>;
|
||||
|
||||
/// Maximum number of announcements in the storage.
|
||||
#[pallet::constant]
|
||||
#[pezpallet::constant]
|
||||
type MaxAnnouncements: Get<u32>;
|
||||
|
||||
/// The origin to control the collective charter.
|
||||
type CharterOrigin: EnsureOrigin<Self::RuntimeOrigin>;
|
||||
|
||||
/// Weight information needed for the pallet.
|
||||
/// Weight information needed for the pezpallet.
|
||||
type WeightInfo: WeightInfo;
|
||||
}
|
||||
|
||||
#[pallet::error]
|
||||
#[pezpallet::error]
|
||||
pub enum Error<T, I = ()> {
|
||||
/// The announcement is not found.
|
||||
MissingAnnouncement,
|
||||
@@ -100,8 +100,8 @@ pub mod pallet {
|
||||
InvalidExpiration,
|
||||
}
|
||||
|
||||
#[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<I>, I: 'static = ()> {
|
||||
/// A new charter has been set.
|
||||
NewCharterSet { cid: OpaqueCid },
|
||||
@@ -112,23 +112,23 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
/// The collective charter.
|
||||
#[pallet::storage]
|
||||
#[pezpallet::storage]
|
||||
pub type Charter<T: Config<I>, I: 'static = ()> = StorageValue<_, OpaqueCid, OptionQuery>;
|
||||
|
||||
/// The collective announcements.
|
||||
#[pallet::storage]
|
||||
#[pezpallet::storage]
|
||||
pub type Announcements<T: Config<I>, I: 'static = ()> =
|
||||
CountedStorageMap<_, Blake2_128Concat, OpaqueCid, BlockNumberFor<T>, OptionQuery>;
|
||||
|
||||
#[pallet::call]
|
||||
impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
#[pezpallet::call]
|
||||
impl<T: Config<I>, I: 'static> Pezpallet<T, I> {
|
||||
/// Set the collective charter.
|
||||
///
|
||||
/// Parameters:
|
||||
/// - `origin`: Must be the [Config::CharterOrigin].
|
||||
/// - `cid`: [CID](super::OpaqueCid) of the IPFS document of the collective charter.
|
||||
#[pallet::call_index(0)]
|
||||
#[pallet::weight(T::WeightInfo::set_charter())]
|
||||
#[pezpallet::call_index(0)]
|
||||
#[pezpallet::weight(T::WeightInfo::set_charter())]
|
||||
pub fn set_charter(origin: OriginFor<T>, cid: OpaqueCid) -> DispatchResult {
|
||||
T::CharterOrigin::ensure_origin(origin)?;
|
||||
|
||||
@@ -146,8 +146,8 @@ pub mod pallet {
|
||||
/// - `maybe_expire`: Expiration block of the announcement. If `None`
|
||||
/// [`Config::AnnouncementLifetime`]
|
||||
/// used as a default.
|
||||
#[pallet::call_index(1)]
|
||||
#[pallet::weight(T::WeightInfo::announce())]
|
||||
#[pezpallet::call_index(1)]
|
||||
#[pezpallet::weight(T::WeightInfo::announce())]
|
||||
pub fn announce(
|
||||
origin: OriginFor<T>,
|
||||
cid: OpaqueCid,
|
||||
@@ -155,7 +155,7 @@ pub mod pallet {
|
||||
) -> DispatchResult {
|
||||
T::AnnouncementOrigin::ensure_origin(origin)?;
|
||||
|
||||
let now = pezframe_system::Pallet::<T>::block_number();
|
||||
let now = pezframe_system::Pezpallet::<T>::block_number();
|
||||
let expire_at = maybe_expire
|
||||
.map_or(now.saturating_add(T::AnnouncementLifetime::get()), |e| e.evaluate(now));
|
||||
ensure!(expire_at > now, Error::<T, I>::InvalidExpiration);
|
||||
@@ -178,8 +178,8 @@ pub mod pallet {
|
||||
/// - `origin`: Must be the [Config::AnnouncementOrigin] or signed for expired
|
||||
/// announcements.
|
||||
/// - `cid`: [CID](super::OpaqueCid) of the IPFS document to remove.
|
||||
#[pallet::call_index(2)]
|
||||
#[pallet::weight(T::WeightInfo::remove_announcement())]
|
||||
#[pezpallet::call_index(2)]
|
||||
#[pezpallet::weight(T::WeightInfo::remove_announcement())]
|
||||
pub fn remove_announcement(
|
||||
origin: OriginFor<T>,
|
||||
cid: OpaqueCid,
|
||||
@@ -190,7 +190,7 @@ pub mod pallet {
|
||||
};
|
||||
let expire_at = <Announcements<T, I>>::get(cid.clone())
|
||||
.ok_or(Error::<T, I>::MissingAnnouncement)?;
|
||||
let now = pezframe_system::Pallet::<T>::block_number();
|
||||
let now = pezframe_system::Pezpallet::<T>::block_number();
|
||||
ensure!(maybe_who.is_none() || now >= expire_at, BadOrigin);
|
||||
|
||||
<Announcements<T, I>>::remove(cid.clone());
|
||||
|
||||
@@ -54,7 +54,7 @@ fn set_charter_works() {
|
||||
#[test]
|
||||
fn announce_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let now = pezframe_system::Pallet::<Test>::block_number();
|
||||
let now = pezframe_system::Pezpallet::<Test>::block_number();
|
||||
// wrong origin.
|
||||
let origin = RuntimeOrigin::signed(SomeAccount::get());
|
||||
let cid = create_cid(1);
|
||||
|
||||
@@ -13,11 +13,11 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! The pallet weight info trait and its unit implementation.
|
||||
//! The pezpallet weight info trait and its unit implementation.
|
||||
|
||||
use pezframe_support::weights::Weight;
|
||||
|
||||
/// Weights information needed for the pallet.
|
||||
/// Weights information needed for the pezpallet.
|
||||
pub trait WeightInfo {
|
||||
/// Returns the weight of the set_charter extrinsic.
|
||||
fn set_charter() -> Weight;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#![cfg(feature = "runtime-benchmarks")]
|
||||
|
||||
use super::*;
|
||||
use crate::Pallet as IdentityKyc;
|
||||
use crate::Pezpallet as IdentityKyc;
|
||||
use pezframe_benchmarking::v2::*;
|
||||
use pezframe_support::traits::Currency;
|
||||
use pezframe_system::RawOrigin;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
//! # Identity & KYC Pallet - TRUSTLESS MODEL
|
||||
//! # Identity & KYC Pezpallet - TRUSTLESS MODEL
|
||||
//!
|
||||
//! A privacy-preserving, decentralized citizenship verification system.
|
||||
//!
|
||||
//! ## Overview
|
||||
//!
|
||||
//! This pallet implements a **TRUSTLESS** citizenship verification where:
|
||||
//! This pezpallet implements a **TRUSTLESS** citizenship verification where:
|
||||
//! - NO personal data is stored on-chain (only hash)
|
||||
//! - NO central authority/bot approves applications
|
||||
//! - Existing citizens vouch for new applicants (referral-based)
|
||||
@@ -95,7 +95,7 @@
|
||||
//! }
|
||||
//! ```
|
||||
|
||||
pub use pallet::*;
|
||||
pub use pezpallet::*;
|
||||
pub mod types;
|
||||
use types::*;
|
||||
pub mod weights;
|
||||
@@ -115,14 +115,14 @@ use pezframe_support::{pezpallet_prelude::*, traits::ReservableCurrency};
|
||||
use pezframe_system::pezpallet_prelude::*;
|
||||
use pezsp_core::H256;
|
||||
|
||||
#[pezframe_support::pallet]
|
||||
pub mod pallet {
|
||||
#[pezframe_support::pezpallet]
|
||||
pub mod pezpallet {
|
||||
use super::*;
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T>(_);
|
||||
#[pezpallet::pezpallet]
|
||||
pub struct Pezpallet<T>(_);
|
||||
|
||||
#[pallet::config]
|
||||
#[pezpallet::config]
|
||||
pub trait Config: pezframe_system::Config {
|
||||
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
|
||||
type Currency: ReservableCurrency<Self::AccountId>;
|
||||
@@ -132,25 +132,25 @@ pub mod pallet {
|
||||
|
||||
type WeightInfo: WeightInfo;
|
||||
|
||||
/// Hook called when citizenship is approved - used by referral pallet
|
||||
/// Hook called when citizenship is approved - used by referral pezpallet
|
||||
type OnKycApproved: crate::types::OnKycApproved<Self::AccountId>;
|
||||
|
||||
/// Hook called when citizenship is revoked - used by referral pallet for penalty
|
||||
/// Hook called when citizenship is revoked - used by referral pezpallet for penalty
|
||||
type OnCitizenshipRevoked: crate::types::OnCitizenshipRevoked<Self::AccountId>;
|
||||
|
||||
/// Provider for minting citizen NFTs - used by tiki pallet
|
||||
/// Provider for minting citizen NFTs - used by tiki pezpallet
|
||||
type CitizenNftProvider: crate::types::CitizenNftProvider<Self::AccountId>;
|
||||
|
||||
/// Deposit required to apply (spam prevention, returned on approval)
|
||||
#[pallet::constant]
|
||||
#[pezpallet::constant]
|
||||
type KycApplicationDeposit: Get<BalanceOf<Self>>;
|
||||
|
||||
/// Max string length for legacy storage
|
||||
#[pallet::constant]
|
||||
#[pezpallet::constant]
|
||||
type MaxStringLength: Get<u32>;
|
||||
|
||||
/// Max CID length for legacy storage
|
||||
#[pallet::constant]
|
||||
#[pezpallet::constant]
|
||||
type MaxCidLength: Get<u32>;
|
||||
}
|
||||
|
||||
@@ -162,39 +162,39 @@ pub mod pallet {
|
||||
|
||||
/// Citizenship applications (applicant -> application)
|
||||
/// PRIVACY: Only hash stored, no personal data
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn applications)]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::getter(fn applications)]
|
||||
pub type Applications<T: Config> =
|
||||
StorageMap<_, Blake2_128Concat, T::AccountId, CitizenshipApplication<T::AccountId>>;
|
||||
|
||||
/// Current citizenship status per account
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn kyc_status_of)]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::getter(fn kyc_status_of)]
|
||||
pub type KycStatuses<T: Config> =
|
||||
StorageMap<_, Blake2_128Concat, T::AccountId, KycLevel, ValueQuery>;
|
||||
|
||||
/// Identity hashes of approved citizens (for verification)
|
||||
/// Can be used to prove citizenship without revealing identity
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn identity_hash_of)]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::getter(fn identity_hash_of)]
|
||||
pub type IdentityHashes<T: Config> = StorageMap<_, Blake2_128Concat, T::AccountId, H256>;
|
||||
|
||||
/// Referrer of approved citizens (for direct responsibility tracking)
|
||||
/// Kept permanently for penalty system even after application is removed
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn citizen_referrer)]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::getter(fn citizen_referrer)]
|
||||
pub type CitizenReferrers<T: Config> =
|
||||
StorageMap<_, Blake2_128Concat, T::AccountId, T::AccountId>;
|
||||
|
||||
// ============= LEGACY STORAGE (for migration) =============
|
||||
|
||||
/// Legacy: Identity info storage (deprecated, kept for migration)
|
||||
#[pallet::storage]
|
||||
#[pezpallet::storage]
|
||||
pub type Identities<T: Config> =
|
||||
StorageMap<_, Blake2_128Concat, T::AccountId, IdentityInfo<T::MaxStringLength>>;
|
||||
|
||||
/// Legacy: Pending KYC applications (deprecated, kept for migration)
|
||||
#[pallet::storage]
|
||||
#[pezpallet::storage]
|
||||
pub type PendingKycApplications<T: Config> = StorageMap<
|
||||
_,
|
||||
Blake2_128Concat,
|
||||
@@ -206,7 +206,7 @@ pub mod pallet {
|
||||
|
||||
/// Genesis configuration for bootstrapping initial citizens
|
||||
/// BOOTSTRAP: Solves chicken-egg problem - first citizens need to exist for others to join
|
||||
#[pallet::genesis_config]
|
||||
#[pezpallet::genesis_config]
|
||||
#[derive(pezframe_support::DefaultNoBound)]
|
||||
pub struct GenesisConfig<T: Config> {
|
||||
/// List of founding citizens (AccountId, IdentityHash)
|
||||
@@ -216,7 +216,7 @@ pub mod pallet {
|
||||
pub _phantom: core::marker::PhantomData<T>,
|
||||
}
|
||||
|
||||
#[pallet::genesis_build]
|
||||
#[pezpallet::genesis_build]
|
||||
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
|
||||
fn build(&self) {
|
||||
// Initialize founding citizens with Approved status
|
||||
@@ -231,8 +231,8 @@ pub mod pallet {
|
||||
|
||||
// ============= 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> {
|
||||
/// New citizenship application submitted
|
||||
CitizenshipApplied { applicant: T::AccountId, referrer: T::AccountId, identity_hash: H256 },
|
||||
@@ -250,7 +250,7 @@ pub mod pallet {
|
||||
|
||||
// ============= ERRORS =============
|
||||
|
||||
#[pallet::error]
|
||||
#[pezpallet::error]
|
||||
pub enum Error<T> {
|
||||
/// Application already exists for this account
|
||||
ApplicationAlreadyExists,
|
||||
@@ -276,8 +276,8 @@ pub mod pallet {
|
||||
|
||||
// ============= EXTRINSICS =============
|
||||
|
||||
#[pallet::call]
|
||||
impl<T: Config> Pallet<T> {
|
||||
#[pezpallet::call]
|
||||
impl<T: Config> Pezpallet<T> {
|
||||
/// Apply for citizenship with identity hash and referrer
|
||||
///
|
||||
/// TRUSTLESS: No admin involved, referrer vouches for applicant
|
||||
@@ -292,8 +292,8 @@ pub mod pallet {
|
||||
/// 2. Deposit is reserved (spam prevention)
|
||||
/// 3. Status becomes PendingReferral
|
||||
/// 4. Referrer must call approve_referral
|
||||
#[pallet::call_index(0)]
|
||||
#[pallet::weight(T::WeightInfo::apply_for_citizenship())]
|
||||
#[pezpallet::call_index(0)]
|
||||
#[pezpallet::weight(T::WeightInfo::apply_for_citizenship())]
|
||||
pub fn apply_for_citizenship(
|
||||
origin: OriginFor<T>,
|
||||
identity_hash: H256,
|
||||
@@ -342,8 +342,8 @@ pub mod pallet {
|
||||
/// # Requirements
|
||||
/// - Caller must be the referrer specified in the application
|
||||
/// - Application must be in PendingReferral state
|
||||
#[pallet::call_index(1)]
|
||||
#[pallet::weight(T::WeightInfo::approve_referral())]
|
||||
#[pezpallet::call_index(1)]
|
||||
#[pezpallet::weight(T::WeightInfo::approve_referral())]
|
||||
pub fn approve_referral(origin: OriginFor<T>, applicant: T::AccountId) -> DispatchResult {
|
||||
let caller = ensure_signed(origin)?;
|
||||
|
||||
@@ -378,8 +378,8 @@ pub mod pallet {
|
||||
/// 3. Status becomes Approved
|
||||
/// 4. Citizen NFT (Welati) is minted
|
||||
/// 5. Referral hooks are triggered
|
||||
#[pallet::call_index(2)]
|
||||
#[pallet::weight(T::WeightInfo::confirm_citizenship())]
|
||||
#[pezpallet::call_index(2)]
|
||||
#[pezpallet::weight(T::WeightInfo::confirm_citizenship())]
|
||||
pub fn confirm_citizenship(origin: OriginFor<T>) -> DispatchResult {
|
||||
let applicant = ensure_signed(origin)?;
|
||||
|
||||
@@ -413,7 +413,7 @@ pub mod pallet {
|
||||
// Don't fail - user is still a citizen
|
||||
}
|
||||
|
||||
// Trigger referral hooks (for referral pallet)
|
||||
// Trigger referral hooks (for referral pezpallet)
|
||||
// Pass referrer parameter to avoid data loss between pallets
|
||||
T::OnKycApproved::on_kyc_approved(&applicant, &application.referrer);
|
||||
|
||||
@@ -424,9 +424,9 @@ pub mod pallet {
|
||||
/// Revoke citizenship (governance only)
|
||||
///
|
||||
/// Used for malicious actors identified by governance
|
||||
/// DIRECT RESPONSIBILITY: Triggers penalty for the referrer via referral pallet
|
||||
#[pallet::call_index(3)]
|
||||
#[pallet::weight(T::WeightInfo::revoke_citizenship())]
|
||||
/// DIRECT RESPONSIBILITY: Triggers penalty for the referrer via referral pezpallet
|
||||
#[pezpallet::call_index(3)]
|
||||
#[pezpallet::weight(T::WeightInfo::revoke_citizenship())]
|
||||
pub fn revoke_citizenship(origin: OriginFor<T>, who: T::AccountId) -> DispatchResult {
|
||||
T::GovernanceOrigin::ensure_origin(origin)?;
|
||||
|
||||
@@ -444,7 +444,7 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
// Trigger direct responsibility penalty for the referrer
|
||||
// This hook notifies the referral pallet to penalize the referrer
|
||||
// This hook notifies the referral pezpallet to penalize the referrer
|
||||
T::OnCitizenshipRevoked::on_citizenship_revoked(&who);
|
||||
|
||||
Self::deposit_event(Event::CitizenshipRevoked { who });
|
||||
@@ -454,8 +454,8 @@ pub mod pallet {
|
||||
/// Renounce citizenship (voluntary exit)
|
||||
///
|
||||
/// Users can freely leave the system
|
||||
#[pallet::call_index(4)]
|
||||
#[pallet::weight(T::WeightInfo::renounce_citizenship())]
|
||||
#[pezpallet::call_index(4)]
|
||||
#[pezpallet::weight(T::WeightInfo::renounce_citizenship())]
|
||||
pub fn renounce_citizenship(origin: OriginFor<T>) -> DispatchResult {
|
||||
let who = ensure_signed(origin)?;
|
||||
|
||||
@@ -478,8 +478,8 @@ pub mod pallet {
|
||||
///
|
||||
/// Useful if referrer is unresponsive or user made a mistake.
|
||||
/// SAFETY: Only works in PendingReferral state (not yet approved)
|
||||
#[pallet::call_index(5)]
|
||||
#[pallet::weight(T::WeightInfo::cancel_application())]
|
||||
#[pezpallet::call_index(5)]
|
||||
#[pezpallet::weight(T::WeightInfo::cancel_application())]
|
||||
pub fn cancel_application(origin: OriginFor<T>) -> DispatchResult {
|
||||
let applicant = ensure_signed(origin)?;
|
||||
|
||||
@@ -509,13 +509,13 @@ pub mod pallet {
|
||||
|
||||
pub use types::KycStatus;
|
||||
|
||||
impl<T: Config> types::KycStatus<T::AccountId> for Pallet<T> {
|
||||
impl<T: Config> types::KycStatus<T::AccountId> for Pezpallet<T> {
|
||||
fn get_kyc_status(who: &T::AccountId) -> KycLevel {
|
||||
KycStatuses::<T>::get(who)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Config> IdentityInfoProvider<T::AccountId, T::MaxStringLength> for Pallet<T> {
|
||||
impl<T: Config> IdentityInfoProvider<T::AccountId, T::MaxStringLength> for Pezpallet<T> {
|
||||
fn get_identity_info(who: &T::AccountId) -> Option<IdentityInfo<T::MaxStringLength>> {
|
||||
// Legacy: Return from old storage if exists
|
||||
Identities::<T>::get(who)
|
||||
@@ -523,7 +523,7 @@ impl<T: Config> IdentityInfoProvider<T::AccountId, T::MaxStringLength> for Palle
|
||||
}
|
||||
|
||||
/// Helper methods for checking citizenship
|
||||
impl<T: Config> Pallet<T> {
|
||||
impl<T: Config> Pezpallet<T> {
|
||||
/// Check if account is a citizen
|
||||
pub fn is_citizen(who: &T::AccountId) -> bool {
|
||||
KycStatuses::<T>::get(who) == KycLevel::Approved
|
||||
@@ -551,12 +551,12 @@ impl<T: Config> Pallet<T> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Trait for trust pallet integration
|
||||
/// Trait for trust pezpallet integration
|
||||
pub trait CitizenshipStatusProvider<AccountId> {
|
||||
fn is_citizen(who: &AccountId) -> bool;
|
||||
}
|
||||
|
||||
impl<T: Config> CitizenshipStatusProvider<T::AccountId> for Pallet<T> {
|
||||
impl<T: Config> CitizenshipStatusProvider<T::AccountId> for Pezpallet<T> {
|
||||
fn is_citizen(who: &T::AccountId) -> bool {
|
||||
KycStatuses::<T>::get(who) == KycLevel::Approved
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ parameter_types! {
|
||||
pub struct MockOnKycApproved;
|
||||
impl crate::types::OnKycApproved<AccountId> for MockOnKycApproved {
|
||||
fn on_kyc_approved(_who: &AccountId, _referrer: &AccountId) {
|
||||
// No-op for tests - in real runtime this triggers referral pallet
|
||||
// No-op for tests - in real runtime this triggers referral pezpallet
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ use pezsp_core::H256;
|
||||
use pezsp_runtime::DispatchError;
|
||||
|
||||
// Kolay erişim için paletimize bir takma ad veriyoruz.
|
||||
type IdentityKycPallet = crate::Pallet<Test>;
|
||||
type IdentityKycPallet = crate::Pezpallet<Test>;
|
||||
|
||||
// ============================================================================
|
||||
// Genesis Config Tests
|
||||
|
||||
@@ -173,7 +173,7 @@ impl<AccountId> OnKycApproved<AccountId> for () {
|
||||
}
|
||||
|
||||
/// Vatandaşlık NFT'si mintlemek için arayüz.
|
||||
/// Bu trait identity-kyc palletinde tanımlanır ve tiki pallet tarafından
|
||||
/// Bu trait identity-kyc palletinde tanımlanır ve tiki pezpallet tarafından
|
||||
/// implement edilir, böylece circular dependency oluşmaz.
|
||||
pub trait CitizenNftProvider<AccountId> {
|
||||
fn mint_citizen_nft(who: &AccountId) -> pezsp_runtime::DispatchResult;
|
||||
@@ -186,7 +186,7 @@ pub trait CitizenNftProvider<AccountId> {
|
||||
}
|
||||
|
||||
/// Hook called when citizenship is revoked (for direct responsibility penalty)
|
||||
/// Defined here to avoid circular dependency, implemented by referral pallet
|
||||
/// Defined here to avoid circular dependency, implemented by referral pezpallet
|
||||
pub trait OnCitizenshipRevoked<AccountId> {
|
||||
fn on_citizenship_revoked(who: &AccountId);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! Benchmarking setup for pezpallet-perwerde
|
||||
#![cfg(feature = "runtime-benchmarks")]
|
||||
|
||||
use super::{Pallet as Perwerde, *};
|
||||
use super::{Pezpallet as Perwerde, *};
|
||||
use pezframe_benchmarking::v2::*;
|
||||
use pezframe_support::{pezpallet_prelude::Get, BoundedVec};
|
||||
use pezframe_system::RawOrigin;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
//! # Perwerde (Education) Pallet
|
||||
//! # Perwerde (Education) Pezpallet
|
||||
//!
|
||||
//! A pallet for managing educational courses, student enrollments, and achievement tracking.
|
||||
//! A pezpallet for managing educational courses, student enrollments, and achievement tracking.
|
||||
//!
|
||||
//! ## Overview
|
||||
//!
|
||||
//! The Perwerde pallet implements an on-chain educational platform where:
|
||||
//! The Perwerde pezpallet implements an on-chain educational platform where:
|
||||
//! - Educators create and manage courses with IPFS-linked content
|
||||
//! - Students enroll in courses and track their progress
|
||||
//! - Course completion earns points that contribute to trust scores
|
||||
@@ -84,7 +84,7 @@
|
||||
//! }
|
||||
//! ```
|
||||
|
||||
pub use pallet::*;
|
||||
pub use pezpallet::*;
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
mod benchmarking;
|
||||
@@ -99,8 +99,8 @@ mod tests;
|
||||
|
||||
pub use weights::WeightInfo;
|
||||
|
||||
#[pezframe_support::pallet]
|
||||
pub mod pallet {
|
||||
#[pezframe_support::pezpallet]
|
||||
pub mod pezpallet {
|
||||
use super::*;
|
||||
use pezframe_support::{
|
||||
dispatch::DispatchResult,
|
||||
@@ -109,27 +109,27 @@ pub mod pallet {
|
||||
};
|
||||
use pezframe_system::pezpallet_prelude::*;
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T>(_);
|
||||
#[pezpallet::pezpallet]
|
||||
pub struct Pezpallet<T>(_);
|
||||
|
||||
#[pallet::config]
|
||||
#[pezpallet::config]
|
||||
pub trait Config: pezframe_system::Config {
|
||||
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
|
||||
type AdminOrigin: EnsureOrigin<Self::RuntimeOrigin, Success = Self::AccountId>;
|
||||
type WeightInfo: WeightInfo;
|
||||
|
||||
#[pallet::constant]
|
||||
#[pezpallet::constant]
|
||||
type MaxCourseNameLength: Get<u32>;
|
||||
#[pallet::constant]
|
||||
#[pezpallet::constant]
|
||||
type MaxCourseDescLength: Get<u32>;
|
||||
#[pallet::constant]
|
||||
#[pezpallet::constant]
|
||||
type MaxCourseLinkLength: Get<u32>;
|
||||
#[pallet::constant]
|
||||
#[pezpallet::constant]
|
||||
type MaxStudentsPerCourse: Get<u32>;
|
||||
|
||||
/// Maximum number of courses a single student can enroll in
|
||||
/// Used for StudentCourses storage bound
|
||||
#[pallet::constant]
|
||||
#[pezpallet::constant]
|
||||
type MaxCoursesPerStudent: Get<u32>;
|
||||
}
|
||||
|
||||
@@ -161,24 +161,24 @@ pub mod pallet {
|
||||
pub points_earned: u32,
|
||||
}
|
||||
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn courses)]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::getter(fn courses)]
|
||||
pub type Courses<T: Config> = StorageMap<_, Blake2_128Concat, u32, Course<T>, OptionQuery>;
|
||||
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn next_course_id)]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::getter(fn next_course_id)]
|
||||
pub type NextCourseId<T: Config> = StorageValue<_, u32, ValueQuery>;
|
||||
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn enrollments)]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::getter(fn enrollments)]
|
||||
pub type Enrollments<T: Config> =
|
||||
StorageMap<_, Blake2_128Concat, (T::AccountId, u32), Enrollment<T>, OptionQuery>;
|
||||
|
||||
/// Per-student list of enrolled course IDs
|
||||
/// UPDATED (Gemini suggestion): Uses MaxCoursesPerStudent instead of MaxStudentsPerCourse
|
||||
/// This is the correct semantic - limits how many courses ONE student can take
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn student_courses)]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::getter(fn student_courses)]
|
||||
pub type StudentCourses<T: Config> = StorageMap<
|
||||
_,
|
||||
Blake2_128Concat,
|
||||
@@ -187,8 +187,8 @@ pub mod pallet {
|
||||
ValueQuery,
|
||||
>;
|
||||
|
||||
#[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> {
|
||||
CourseCreated { course_id: u32, owner: T::AccountId },
|
||||
StudentEnrolled { student: T::AccountId, course_id: u32 },
|
||||
@@ -196,7 +196,7 @@ pub mod pallet {
|
||||
CourseArchived { course_id: u32 },
|
||||
}
|
||||
|
||||
#[pallet::error]
|
||||
#[pezpallet::error]
|
||||
pub enum Error<T> {
|
||||
CourseNotFound,
|
||||
AlreadyEnrolled,
|
||||
@@ -207,10 +207,10 @@ pub mod pallet {
|
||||
TooManyCourses,
|
||||
}
|
||||
|
||||
#[pallet::call]
|
||||
impl<T: Config> Pallet<T> {
|
||||
#[pallet::call_index(0)]
|
||||
#[pallet::weight(T::WeightInfo::create_course())]
|
||||
#[pezpallet::call]
|
||||
impl<T: Config> Pezpallet<T> {
|
||||
#[pezpallet::call_index(0)]
|
||||
#[pezpallet::weight(T::WeightInfo::create_course())]
|
||||
pub fn create_course(
|
||||
origin: OriginFor<T>,
|
||||
name: BoundedVec<u8, T::MaxCourseNameLength>,
|
||||
@@ -228,7 +228,7 @@ pub mod pallet {
|
||||
description,
|
||||
content_link,
|
||||
status: CourseStatus::Active,
|
||||
created_at: pezframe_system::Pallet::<T>::block_number(),
|
||||
created_at: pezframe_system::Pezpallet::<T>::block_number(),
|
||||
};
|
||||
|
||||
Courses::<T>::insert(course_id, course);
|
||||
@@ -238,8 +238,8 @@ pub mod pallet {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[pallet::call_index(1)]
|
||||
#[pallet::weight(T::WeightInfo::enroll())]
|
||||
#[pezpallet::call_index(1)]
|
||||
#[pezpallet::weight(T::WeightInfo::enroll())]
|
||||
pub fn enroll(origin: OriginFor<T>, course_id: u32) -> DispatchResult {
|
||||
let student = ensure_signed(origin)?;
|
||||
let course = Courses::<T>::get(course_id).ok_or(Error::<T>::CourseNotFound)?;
|
||||
@@ -252,7 +252,7 @@ pub mod pallet {
|
||||
let enrollment = Enrollment {
|
||||
student: student.clone(),
|
||||
course_id,
|
||||
enrolled_at: pezframe_system::Pallet::<T>::block_number(),
|
||||
enrolled_at: pezframe_system::Pezpallet::<T>::block_number(),
|
||||
completed_at: None,
|
||||
points_earned: 0,
|
||||
};
|
||||
@@ -268,8 +268,8 @@ pub mod pallet {
|
||||
|
||||
/// Mark a student's course as completed and award points
|
||||
/// SECURITY: Only the course owner can mark completions, not students themselves
|
||||
#[pallet::call_index(2)]
|
||||
#[pallet::weight(T::WeightInfo::complete_course())]
|
||||
#[pezpallet::call_index(2)]
|
||||
#[pezpallet::weight(T::WeightInfo::complete_course())]
|
||||
pub fn complete_course(
|
||||
origin: OriginFor<T>,
|
||||
student: T::AccountId,
|
||||
@@ -288,7 +288,7 @@ pub mod pallet {
|
||||
ensure!(enrollment.completed_at.is_none(), Error::<T>::CourseAlreadyCompleted);
|
||||
|
||||
// Mark completion
|
||||
enrollment.completed_at = Some(pezframe_system::Pallet::<T>::block_number());
|
||||
enrollment.completed_at = Some(pezframe_system::Pezpallet::<T>::block_number());
|
||||
enrollment.points_earned = points;
|
||||
|
||||
Enrollments::<T>::insert((&student, course_id), enrollment);
|
||||
@@ -297,8 +297,8 @@ pub mod pallet {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[pallet::call_index(3)]
|
||||
#[pallet::weight(T::WeightInfo::archive_course())]
|
||||
#[pezpallet::call_index(3)]
|
||||
#[pezpallet::weight(T::WeightInfo::archive_course())]
|
||||
pub fn archive_course(origin: OriginFor<T>, course_id: u32) -> DispatchResult {
|
||||
let caller = T::AdminOrigin::ensure_origin(origin)?;
|
||||
let mut course = Courses::<T>::get(course_id).ok_or(Error::<T>::CourseNotFound)?;
|
||||
@@ -312,7 +312,7 @@ pub mod pallet {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Config> Pallet<T> {
|
||||
impl<T: Config> Pezpallet<T> {
|
||||
pub fn get_perwerde_score(who: &T::AccountId) -> u32 {
|
||||
StudentCourses::<T>::get(who)
|
||||
.iter()
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
#![cfg(feature = "runtime-benchmarks")]
|
||||
|
||||
use super::{BalanceOf, Call, Config};
|
||||
use crate::{Pallet as PezRewards, Pallet};
|
||||
use crate::{Pezpallet as PezRewards, Pezpallet};
|
||||
use pezframe_benchmarking::v2::*;
|
||||
use pezframe_support::traits::{
|
||||
fungibles::{Create, Mutate},
|
||||
Currency, Get,
|
||||
};
|
||||
use pezframe_system::{Pallet as System, RawOrigin};
|
||||
use pezframe_system::{Pezpallet as System, RawOrigin};
|
||||
use pezsp_runtime::traits::{Bounded, Saturating, StaticLookup, Zero}; // AccountIdConversion removed
|
||||
|
||||
const SEED: u32 = 0;
|
||||
@@ -53,7 +53,7 @@ where
|
||||
#[benchmarks(where T: pezpallet_balances::Config, T::Assets: Create<T::AccountId>)]
|
||||
mod benchmarks {
|
||||
use super::*;
|
||||
use pezpallet_balances::Pallet as Balances;
|
||||
use pezpallet_balances::Pezpallet as Balances;
|
||||
|
||||
#[benchmark]
|
||||
fn initialize_rewards_system() {
|
||||
@@ -110,7 +110,7 @@ mod benchmarks {
|
||||
.unwrap_or_else(|_| BalanceOf::<T>::max_value() / 2u32.into());
|
||||
let _ = T::Assets::mint_into(T::PezAssetId::get(), &incentive_pot, large_amount);
|
||||
|
||||
let target_block = System::<T>::block_number() + crate::pallet::BLOCKS_PER_EPOCH.into();
|
||||
let target_block = System::<T>::block_number() + crate::pezpallet::BLOCKS_PER_EPOCH.into();
|
||||
System::<T>::set_block_number(target_block);
|
||||
|
||||
#[extrinsic_call]
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
//! # PEZ Rewards Pallet
|
||||
//! # PEZ Rewards Pezpallet
|
||||
//!
|
||||
//! A pallet for distributing PEZ token rewards based on trust scores with epoch-based mechanics.
|
||||
//! A pezpallet for distributing PEZ token rewards based on trust scores with epoch-based mechanics.
|
||||
//!
|
||||
//! ## Overview
|
||||
//!
|
||||
//! This pallet implements a sophisticated reward distribution system that incentivizes
|
||||
//! This pezpallet implements a sophisticated reward distribution system that incentivizes
|
||||
//! ecosystem participation through trust-based rewards. The system operates in monthly
|
||||
//! epochs with automatic reward calculation, distribution, and clawback mechanisms.
|
||||
//!
|
||||
@@ -68,7 +68,7 @@
|
||||
//!
|
||||
//! ## Dependencies
|
||||
//!
|
||||
//! This pallet requires integration with:
|
||||
//! This pezpallet requires integration with:
|
||||
//! - `pezpallet-trust` - Trust score provider
|
||||
//! - `pezpallet-pez-treasury` - Incentive pot funding source
|
||||
//! - `pezpallet-nfts` - Parliamentary NFT collection (optional)
|
||||
@@ -90,7 +90,7 @@
|
||||
//! }
|
||||
//! ```
|
||||
|
||||
pub use pallet::*;
|
||||
pub use pezpallet::*;
|
||||
|
||||
pub mod weights;
|
||||
pub use weights::WeightInfo;
|
||||
@@ -118,8 +118,8 @@ use pezpallet_trust::TrustScoreProvider;
|
||||
use scale_info::TypeInfo;
|
||||
use pezsp_runtime::traits::{AccountIdConversion, Member, Saturating, Zero};
|
||||
|
||||
#[pezframe_support::pallet]
|
||||
pub mod pallet {
|
||||
#[pezframe_support::pezpallet]
|
||||
pub mod pezpallet {
|
||||
use super::*;
|
||||
use pezframe_support::pezpallet_prelude::*;
|
||||
use pezframe_system::pezpallet_prelude::*;
|
||||
@@ -135,13 +135,13 @@ pub mod pallet {
|
||||
pub const PARLIAMENTARY_NFT_COUNT: u32 = 201;
|
||||
pub const PARLIAMENTARY_REWARD_PERCENT: u32 = 10; // 10% of incentive pool
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T>(_);
|
||||
#[pezpallet::pezpallet]
|
||||
pub struct Pezpallet<T>(_);
|
||||
|
||||
#[pallet::config]
|
||||
#[pezpallet::config]
|
||||
pub trait Config: pezframe_system::Config + pezpallet_trust::Config + TypeInfo {
|
||||
type Assets: Mutate<Self::AccountId>;
|
||||
#[pallet::constant]
|
||||
#[pezpallet::constant]
|
||||
type PezAssetId: Get<<Self::Assets as Inspect<Self::AccountId>>::AssetId>;
|
||||
type WeightInfo: crate::weights::WeightInfo;
|
||||
|
||||
@@ -149,11 +149,11 @@ pub mod pallet {
|
||||
type TrustScoreSource: pezpallet_trust::TrustScoreProvider<Self::AccountId>;
|
||||
|
||||
/// Authority to spend from incentive pot
|
||||
#[pallet::constant]
|
||||
#[pezpallet::constant]
|
||||
type IncentivePotId: Get<PalletId>;
|
||||
|
||||
/// Clawback recipient (Qazi Muhammed)
|
||||
#[pallet::constant]
|
||||
#[pezpallet::constant]
|
||||
type ClawbackRecipient: Get<Self::AccountId>;
|
||||
|
||||
/// Authority check for root origin
|
||||
@@ -168,19 +168,19 @@ pub mod pallet {
|
||||
<<T as Config>::Assets as Inspect<<T as pezframe_system::Config>::AccountId>>::Balance;
|
||||
|
||||
/// Storage holding epoch (period) information
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn epoch_info)]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::getter(fn epoch_info)]
|
||||
pub type EpochInfo<T: Config> = StorageValue<_, EpochData<T>, ValueQuery>;
|
||||
|
||||
/// Storage holding total reward pool for each epoch
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn epoch_reward_pools)]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::getter(fn epoch_reward_pools)]
|
||||
pub type EpochRewardPools<T: Config> =
|
||||
StorageMap<_, Blake2_128Concat, u32, EpochRewardPool<T>, OptionQuery>;
|
||||
|
||||
/// Storage holding user's trust score for a specific epoch
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn user_epoch_scores)]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::getter(fn user_epoch_scores)]
|
||||
pub type UserEpochScores<T: Config> = StorageDoubleMap<
|
||||
_,
|
||||
Blake2_128Concat,
|
||||
@@ -192,8 +192,8 @@ pub mod pallet {
|
||||
>;
|
||||
|
||||
/// Storage tracking whether user has claimed reward from a specific epoch
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn claimed_rewards)]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::getter(fn claimed_rewards)]
|
||||
pub type ClaimedRewards<T: Config> = StorageDoubleMap<
|
||||
_,
|
||||
Blake2_128Concat,
|
||||
@@ -205,14 +205,14 @@ pub mod pallet {
|
||||
>;
|
||||
|
||||
/// Storage holding epoch state (Open, ClaimPeriod, Closed)
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn epoch_status)]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::getter(fn epoch_status)]
|
||||
pub type EpochStatus<T: Config> = StorageMap<_, Blake2_128Concat, u32, EpochState, ValueQuery>;
|
||||
|
||||
/// Parliamentary NFT ID to owner mapping
|
||||
/// This will be populated by governance or runtime integration
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn parliamentary_nft_owners)]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::getter(fn parliamentary_nft_owners)]
|
||||
pub type ParliamentaryNftOwners<T: Config> = StorageMap<
|
||||
_,
|
||||
Blake2_128Concat,
|
||||
@@ -256,8 +256,8 @@ pub mod pallet {
|
||||
|
||||
// Part to be added to Event enum in lib.rs (around line ~174)
|
||||
|
||||
#[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> {
|
||||
/// New epoch started
|
||||
NewEpochStarted { epoch_index: u32, start_block: BlockNumberFor<T> },
|
||||
@@ -290,7 +290,7 @@ pub mod pallet {
|
||||
ParliamentaryOwnerRegistered { nft_id: u32, owner: T::AccountId },
|
||||
}
|
||||
|
||||
#[pallet::error]
|
||||
#[pezpallet::error]
|
||||
pub enum Error<T> {
|
||||
/// Reward system not yet initialized
|
||||
RewardsNotInitialized,
|
||||
@@ -319,7 +319,7 @@ pub mod pallet {
|
||||
* EpochNotFinished already exists in lib.rs as shown in 'help' */
|
||||
}
|
||||
|
||||
#[pallet::genesis_config]
|
||||
#[pezpallet::genesis_config]
|
||||
#[derive(pezframe_support::DefaultNoBound)]
|
||||
pub struct GenesisConfig<T: Config> {
|
||||
pub start_rewards_system: bool,
|
||||
@@ -327,60 +327,60 @@ pub mod pallet {
|
||||
pub _phantom: core::marker::PhantomData<T>,
|
||||
}
|
||||
|
||||
#[pallet::genesis_build]
|
||||
#[pezpallet::genesis_build]
|
||||
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
|
||||
fn build(&self) {
|
||||
if self.start_rewards_system {
|
||||
let _ = Pallet::<T>::do_initialize_rewards_system();
|
||||
let _ = Pezpallet::<T>::do_initialize_rewards_system();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[pallet::call]
|
||||
impl<T: Config> Pallet<T> {
|
||||
#[pezpallet::call]
|
||||
impl<T: Config> Pezpallet<T> {
|
||||
/// Initialize reward system (root only)
|
||||
#[pallet::call_index(0)]
|
||||
#[pallet::weight(<T as Config>::WeightInfo::initialize_rewards_system())]
|
||||
#[pezpallet::call_index(0)]
|
||||
#[pezpallet::weight(<T as Config>::WeightInfo::initialize_rewards_system())]
|
||||
pub fn initialize_rewards_system(origin: OriginFor<T>) -> DispatchResult {
|
||||
<T as Config>::ForceOrigin::ensure_origin(origin)?;
|
||||
Self::do_initialize_rewards_system()
|
||||
}
|
||||
|
||||
/// Record user's current trust score
|
||||
#[pallet::call_index(1)]
|
||||
#[pallet::weight(<T as Config>::WeightInfo::record_trust_score())]
|
||||
#[pezpallet::call_index(1)]
|
||||
#[pezpallet::weight(<T as Config>::WeightInfo::record_trust_score())]
|
||||
pub fn record_trust_score(origin: OriginFor<T>) -> DispatchResult {
|
||||
let who = ensure_signed(origin)?;
|
||||
Self::do_record_trust_score(&who)
|
||||
}
|
||||
|
||||
/// Finalize epoch and calculate reward pool (called by scheduler)
|
||||
#[pallet::call_index(2)]
|
||||
#[pallet::weight(<T as Config>::WeightInfo::finalize_epoch())]
|
||||
#[pezpallet::call_index(2)]
|
||||
#[pezpallet::weight(<T as Config>::WeightInfo::finalize_epoch())]
|
||||
pub fn finalize_epoch(origin: OriginFor<T>) -> DispatchResult {
|
||||
<T as Config>::ForceOrigin::ensure_origin(origin)?;
|
||||
Self::do_finalize_epoch()
|
||||
}
|
||||
|
||||
/// Claim reward
|
||||
#[pallet::call_index(3)]
|
||||
#[pallet::weight(<T as Config>::WeightInfo::claim_reward())]
|
||||
#[pezpallet::call_index(3)]
|
||||
#[pezpallet::weight(<T as Config>::WeightInfo::claim_reward())]
|
||||
pub fn claim_reward(origin: OriginFor<T>, epoch_index: u32) -> DispatchResult {
|
||||
let who = ensure_signed(origin)?;
|
||||
Self::do_claim_reward(&who, epoch_index)
|
||||
}
|
||||
|
||||
/// Close epoch and claw back unclaimed rewards (called by scheduler)
|
||||
#[pallet::call_index(4)]
|
||||
#[pallet::weight(<T as Config>::WeightInfo::close_epoch())]
|
||||
#[pezpallet::call_index(4)]
|
||||
#[pezpallet::weight(<T as Config>::WeightInfo::close_epoch())]
|
||||
pub fn close_epoch(origin: OriginFor<T>, epoch_index: u32) -> DispatchResult {
|
||||
<T as Config>::ForceOrigin::ensure_origin(origin)?;
|
||||
Self::do_close_epoch(epoch_index)
|
||||
}
|
||||
|
||||
/// Register parliamentary NFT owner (governance only)
|
||||
#[pallet::call_index(5)]
|
||||
#[pallet::weight(<T as Config>::WeightInfo::register_parliamentary_nft_owner())]
|
||||
#[pezpallet::call_index(5)]
|
||||
#[pezpallet::weight(<T as Config>::WeightInfo::register_parliamentary_nft_owner())]
|
||||
pub fn register_parliamentary_nft_owner(
|
||||
origin: OriginFor<T>,
|
||||
nft_id: u32,
|
||||
@@ -392,7 +392,7 @@ pub mod pallet {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Config> Pallet<T> {
|
||||
impl<T: Config> Pezpallet<T> {
|
||||
/// Return incentive pot account
|
||||
pub fn incentive_pot_account_id() -> T::AccountId {
|
||||
<T as Config>::IncentivePotId::get().into_account_truncating()
|
||||
@@ -405,7 +405,7 @@ pub mod pallet {
|
||||
return Err(Error::<T>::AlreadyInitialized.into());
|
||||
}
|
||||
|
||||
let current_block = pezframe_system::Pallet::<T>::block_number();
|
||||
let current_block = pezframe_system::Pezpallet::<T>::block_number();
|
||||
|
||||
let epoch_data = EpochData {
|
||||
current_epoch: 0,
|
||||
@@ -453,7 +453,7 @@ pub mod pallet {
|
||||
pub fn do_finalize_epoch() -> DispatchResult {
|
||||
let mut epoch_data = EpochInfo::<T>::get();
|
||||
let current_epoch = epoch_data.current_epoch;
|
||||
let current_block = pezframe_system::Pallet::<T>::block_number();
|
||||
let current_block = pezframe_system::Pezpallet::<T>::block_number();
|
||||
|
||||
// Check if epoch has finished
|
||||
let epoch_duration = current_block.saturating_sub(epoch_data.epoch_start_block);
|
||||
@@ -536,7 +536,7 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
pub fn do_claim_reward(who: &T::AccountId, epoch_index: u32) -> DispatchResult {
|
||||
let current_block = pezframe_system::Pallet::<T>::block_number();
|
||||
let current_block = pezframe_system::Pezpallet::<T>::block_number();
|
||||
|
||||
let epoch_state = EpochStatus::<T>::get(epoch_index);
|
||||
ensure!(epoch_state == EpochState::ClaimPeriod, Error::<T>::ClaimPeriodExpired);
|
||||
@@ -585,7 +585,7 @@ pub mod pallet {
|
||||
|
||||
/// Close epoch and claw back unclaimed rewards
|
||||
pub fn do_close_epoch(epoch_index: u32) -> DispatchResult {
|
||||
let current_block = pezframe_system::Pallet::<T>::block_number();
|
||||
let current_block = pezframe_system::Pezpallet::<T>::block_number();
|
||||
|
||||
let epoch_state = EpochStatus::<T>::get(epoch_index);
|
||||
ensure!(epoch_state == EpochState::ClaimPeriod, Error::<T>::EpochAlreadyClosed);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#![cfg(feature = "runtime-benchmarks")]
|
||||
|
||||
use super::*;
|
||||
use crate::Pallet as PezTreasury;
|
||||
use crate::Pezpallet as PezTreasury;
|
||||
use pezframe_benchmarking::v2::*;
|
||||
use pezframe_support::traits::{
|
||||
fungibles::{Inspect, Mutate},
|
||||
@@ -77,9 +77,9 @@ mod benchmarks {
|
||||
initial_monthly_amount * 10u32.into(),
|
||||
);
|
||||
|
||||
let current_block = pezframe_system::Pallet::<T>::block_number();
|
||||
let current_block = pezframe_system::Pezpallet::<T>::block_number();
|
||||
let target_block = current_block + crate::BLOCKS_PER_MONTH.into() + 1u32.into();
|
||||
pezframe_system::Pallet::<T>::set_block_number(target_block);
|
||||
pezframe_system::Pezpallet::<T>::set_block_number(target_block);
|
||||
|
||||
#[extrinsic_call]
|
||||
release_monthly_funds(RawOrigin::Root);
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
//! # PEZ Treasury Pallet
|
||||
//! # PEZ Treasury Pezpallet
|
||||
//!
|
||||
//! A pallet for managing the PEZ token distribution and treasury with automated halving mechanics.
|
||||
//! A pezpallet for managing the PEZ token distribution and treasury with automated halving mechanics.
|
||||
//!
|
||||
//! ## Overview
|
||||
//!
|
||||
//! This pallet manages the complete lifecycle of PEZ token distribution including:
|
||||
//! This pezpallet manages the complete lifecycle of PEZ token distribution including:
|
||||
//!
|
||||
//! - **Genesis Distribution**: One-time initial distribution to treasury, presale, and founder
|
||||
//! accounts
|
||||
@@ -68,7 +68,7 @@
|
||||
//! }
|
||||
//! ```
|
||||
|
||||
pub use pallet::*;
|
||||
pub use pezpallet::*;
|
||||
pub use weights::WeightInfo;
|
||||
|
||||
pub mod migrations;
|
||||
@@ -95,8 +95,8 @@ use pezframe_system::pezpallet_prelude::BlockNumberFor;
|
||||
use scale_info::TypeInfo;
|
||||
use pezsp_runtime::traits::{AccountIdConversion, Saturating, Zero};
|
||||
|
||||
#[pezframe_support::pallet]
|
||||
pub mod pallet {
|
||||
#[pezframe_support::pezpallet]
|
||||
pub mod pezpallet {
|
||||
use super::*;
|
||||
use pezframe_support::pezpallet_prelude::*;
|
||||
use pezframe_system::pezpallet_prelude::*;
|
||||
@@ -111,31 +111,31 @@ pub mod pallet {
|
||||
pub const PRESALE_ALLOCATION: u128 = 93_750_000 * 1_000_000_000_000; // %1.875
|
||||
pub const FOUNDER_ALLOCATION: u128 = 93_750_000 * 1_000_000_000_000; // %1.875
|
||||
|
||||
#[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 + TypeInfo {
|
||||
type Assets: Mutate<Self::AccountId>;
|
||||
type WeightInfo: weights::WeightInfo;
|
||||
|
||||
#[pallet::constant]
|
||||
#[pezpallet::constant]
|
||||
type PezAssetId: Get<<Self::Assets as Inspect<Self::AccountId>>::AssetId>;
|
||||
|
||||
#[pallet::constant]
|
||||
#[pezpallet::constant]
|
||||
type TreasuryPalletId: Get<PalletId>;
|
||||
|
||||
#[pallet::constant]
|
||||
#[pezpallet::constant]
|
||||
type IncentivePotId: Get<PalletId>;
|
||||
|
||||
#[pallet::constant]
|
||||
#[pezpallet::constant]
|
||||
type GovernmentPotId: Get<PalletId>;
|
||||
|
||||
#[pallet::constant]
|
||||
#[pezpallet::constant]
|
||||
type PresaleAccount: Get<Self::AccountId>;
|
||||
|
||||
#[pallet::constant]
|
||||
#[pezpallet::constant]
|
||||
type FounderAccount: Get<Self::AccountId>;
|
||||
|
||||
type ForceOrigin: EnsureOrigin<Self::RuntimeOrigin>;
|
||||
@@ -144,25 +144,25 @@ pub mod pallet {
|
||||
pub type BalanceOf<T> =
|
||||
<<T as Config>::Assets as Inspect<<T as pezframe_system::Config>::AccountId>>::Balance;
|
||||
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn halving_info)]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::getter(fn halving_info)]
|
||||
pub type HalvingInfo<T: Config> = StorageValue<_, HalvingData<T>, ValueQuery>;
|
||||
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn monthly_releases)]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::getter(fn monthly_releases)]
|
||||
pub type MonthlyReleases<T: Config> =
|
||||
StorageMap<_, Blake2_128Concat, u32, MonthlyRelease<T>, OptionQuery>;
|
||||
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn next_release_month)]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::getter(fn next_release_month)]
|
||||
pub type NextReleaseMonth<T: Config> = StorageValue<_, u32, ValueQuery>;
|
||||
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn treasury_start_block)]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::getter(fn treasury_start_block)]
|
||||
pub type TreasuryStartBlock<T: Config> = StorageValue<_, BlockNumberFor<T>, OptionQuery>;
|
||||
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn genesis_distribution_done)]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::getter(fn genesis_distribution_done)]
|
||||
pub type GenesisDistributionDone<T: Config> = StorageValue<_, bool, ValueQuery>;
|
||||
|
||||
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo, MaxEncodedLen)]
|
||||
@@ -195,8 +195,8 @@ pub mod pallet {
|
||||
}
|
||||
}
|
||||
|
||||
#[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> {
|
||||
TreasuryInitialized {
|
||||
start_block: BlockNumberFor<T>,
|
||||
@@ -219,7 +219,7 @@ pub mod pallet {
|
||||
},
|
||||
}
|
||||
|
||||
#[pallet::error]
|
||||
#[pezpallet::error]
|
||||
pub enum Error<T> {
|
||||
TreasuryAlreadyInitialized,
|
||||
TreasuryNotInitialized,
|
||||
@@ -230,7 +230,7 @@ pub mod pallet {
|
||||
GenesisDistributionAlreadyDone,
|
||||
}
|
||||
|
||||
#[pallet::genesis_config]
|
||||
#[pezpallet::genesis_config]
|
||||
#[derive(pezframe_support::DefaultNoBound)]
|
||||
pub struct GenesisConfig<T: Config> {
|
||||
pub initialize_treasury: bool,
|
||||
@@ -238,40 +238,40 @@ pub mod pallet {
|
||||
pub _phantom: core::marker::PhantomData<T>,
|
||||
}
|
||||
|
||||
#[pallet::genesis_build]
|
||||
#[pezpallet::genesis_build]
|
||||
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
|
||||
fn build(&self) {
|
||||
if self.initialize_treasury {
|
||||
let _ = Pallet::<T>::do_initialize_treasury();
|
||||
let _ = Pezpallet::<T>::do_initialize_treasury();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[pallet::call]
|
||||
impl<T: Config> Pallet<T> {
|
||||
#[pallet::call_index(0)]
|
||||
#[pallet::weight(T::WeightInfo::initialize_treasury())]
|
||||
#[pezpallet::call]
|
||||
impl<T: Config> Pezpallet<T> {
|
||||
#[pezpallet::call_index(0)]
|
||||
#[pezpallet::weight(T::WeightInfo::initialize_treasury())]
|
||||
pub fn initialize_treasury(origin: OriginFor<T>) -> DispatchResult {
|
||||
T::ForceOrigin::ensure_origin(origin)?;
|
||||
Self::do_initialize_treasury()
|
||||
}
|
||||
|
||||
#[pallet::call_index(1)]
|
||||
#[pallet::weight(T::WeightInfo::release_monthly_funds())]
|
||||
#[pezpallet::call_index(1)]
|
||||
#[pezpallet::weight(T::WeightInfo::release_monthly_funds())]
|
||||
pub fn release_monthly_funds(origin: OriginFor<T>) -> DispatchResult {
|
||||
T::ForceOrigin::ensure_origin(origin)?;
|
||||
Self::do_monthly_release()
|
||||
}
|
||||
|
||||
#[pallet::call_index(2)]
|
||||
#[pallet::weight(T::WeightInfo::force_genesis_distribution())]
|
||||
#[pezpallet::call_index(2)]
|
||||
#[pezpallet::weight(T::WeightInfo::force_genesis_distribution())]
|
||||
pub fn force_genesis_distribution(origin: OriginFor<T>) -> DispatchResult {
|
||||
T::ForceOrigin::ensure_origin(origin)?;
|
||||
Self::do_genesis_distribution()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Config> Pallet<T> {
|
||||
impl<T: Config> Pezpallet<T> {
|
||||
pub fn treasury_account_id() -> T::AccountId {
|
||||
T::TreasuryPalletId::get().into_account_truncating()
|
||||
}
|
||||
@@ -327,7 +327,7 @@ pub mod pallet {
|
||||
Error::<T>::TreasuryAlreadyInitialized
|
||||
);
|
||||
|
||||
let current_block = pezframe_system::Pallet::<T>::block_number();
|
||||
let current_block = pezframe_system::Pezpallet::<T>::block_number();
|
||||
|
||||
let treasury_balance = TREASURY_ALLOCATION;
|
||||
let first_period_total =
|
||||
@@ -361,7 +361,7 @@ pub mod pallet {
|
||||
pub fn do_monthly_release() -> DispatchResult {
|
||||
ensure!(TreasuryStartBlock::<T>::get().is_some(), Error::<T>::TreasuryNotInitialized);
|
||||
|
||||
let current_block = pezframe_system::Pallet::<T>::block_number();
|
||||
let current_block = pezframe_system::Pezpallet::<T>::block_number();
|
||||
let start_block = TreasuryStartBlock::<T>::get().unwrap();
|
||||
let next_month = NextReleaseMonth::<T>::get();
|
||||
|
||||
|
||||
@@ -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-pez-treasury from {:?} to {:?}",
|
||||
@@ -47,7 +47,7 @@ pub mod v1 {
|
||||
has_genesis_done;
|
||||
|
||||
// Update storage version
|
||||
STORAGE_VERSION.put::<Pallet<T>>();
|
||||
STORAGE_VERSION.put::<Pezpallet<T>>();
|
||||
|
||||
log::info!("✅ Migrated {} entries in pezpallet-pez-treasury", migrated);
|
||||
log::info!(" MonthlyReleases: {}, HalvingInfo: {}, TreasuryStartBlock: {}, GenesisDistributionDone: {}",
|
||||
@@ -70,7 +70,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-pez-treasury");
|
||||
log::info!(" Current version: {:?}", current);
|
||||
@@ -105,7 +105,7 @@ pub mod v1 {
|
||||
log::info!("🔍 Post-upgrade check for pezpallet-pez-treasury");
|
||||
|
||||
// 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);
|
||||
|
||||
@@ -170,7 +170,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-pez-treasury to v2");
|
||||
@@ -181,7 +181,7 @@ pub mod v2 {
|
||||
// 3. 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-pez-treasury v2");
|
||||
|
||||
@@ -216,13 +216,13 @@ mod tests {
|
||||
fn test_migration_v1() {
|
||||
new_test_ext().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());
|
||||
@@ -233,7 +233,7 @@ mod tests {
|
||||
fn test_migration_idempotent() {
|
||||
new_test_ext().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();
|
||||
|
||||
@@ -544,7 +544,7 @@ fn pot_accounts_are_different() {
|
||||
let incentive = PezTreasury::incentive_pot_account_id();
|
||||
let government = PezTreasury::government_pot_account_id();
|
||||
|
||||
println!("\n=== Account IDs from Pallet ===");
|
||||
println!("\n=== Account IDs from Pezpallet ===");
|
||||
println!("Treasury: {:?}", treasury);
|
||||
println!("Incentive: {:?}", incentive);
|
||||
println!("Government: {:?}", government);
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
// ./target/release/frame-omni-bencher
|
||||
// v1
|
||||
// benchmark
|
||||
// pallet
|
||||
// pezpallet
|
||||
// --runtime
|
||||
// ./target/release/wbuild/asset-hub-pezkuwichain-runtime/asset_hub_pezkuwichain_runtime.wasm
|
||||
// --pallet
|
||||
// --pezpallet
|
||||
// pezpallet_pez_treasury
|
||||
// --extrinsic
|
||||
// *
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Pallet to spam the XCM/UMP.
|
||||
//! Pezpallet to spam the XCM/UMP.
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
@@ -28,24 +28,24 @@ use pezframe_system::Config as SystemConfig;
|
||||
use pezsp_runtime::traits::Saturating;
|
||||
use xcm::latest::prelude::*;
|
||||
|
||||
pub use pallet::*;
|
||||
pub use pezpallet::*;
|
||||
|
||||
parameter_types! {
|
||||
const MaxTeyrchains: u32 = 100;
|
||||
const MaxPayloadSize: u32 = 1024;
|
||||
}
|
||||
|
||||
#[pezframe_support::pallet]
|
||||
pub mod pallet {
|
||||
#[pezframe_support::pezpallet]
|
||||
pub mod pezpallet {
|
||||
use super::*;
|
||||
use pezframe_support::pezpallet_prelude::*;
|
||||
use pezframe_system::pezpallet_prelude::*;
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T>(_);
|
||||
#[pezpallet::pezpallet]
|
||||
pub struct Pezpallet<T>(_);
|
||||
|
||||
/// The module configuration trait.
|
||||
#[pallet::config]
|
||||
#[pezpallet::config]
|
||||
pub trait Config: pezframe_system::Config {
|
||||
/// The overarching event type.
|
||||
#[allow(deprecated)]
|
||||
@@ -61,7 +61,7 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
/// The target teyrchains to ping.
|
||||
#[pallet::storage]
|
||||
#[pezpallet::storage]
|
||||
pub(super) type Targets<T: Config> = StorageValue<
|
||||
_,
|
||||
BoundedVec<(ParaId, BoundedVec<u8, MaxPayloadSize>), MaxTeyrchains>,
|
||||
@@ -69,16 +69,16 @@ pub mod pallet {
|
||||
>;
|
||||
|
||||
/// The total number of pings sent.
|
||||
#[pallet::storage]
|
||||
#[pezpallet::storage]
|
||||
pub(super) type PingCount<T: Config> = StorageValue<_, u32, ValueQuery>;
|
||||
|
||||
/// The sent pings.
|
||||
#[pallet::storage]
|
||||
#[pezpallet::storage]
|
||||
pub(super) type Pings<T: Config> =
|
||||
StorageMap<_, Blake2_128Concat, u32, BlockNumberFor<T>, OptionQuery>;
|
||||
|
||||
#[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> {
|
||||
PingSent(ParaId, u32, Vec<u8>, XcmHash, Assets),
|
||||
Pinged(ParaId, u32, Vec<u8>),
|
||||
@@ -89,7 +89,7 @@ pub mod pallet {
|
||||
UnknownPong(ParaId, u32, Vec<u8>),
|
||||
}
|
||||
|
||||
#[pallet::error]
|
||||
#[pezpallet::error]
|
||||
pub enum Error<T> {
|
||||
/// Too many teyrchains have been added as a target.
|
||||
TooManyTargets,
|
||||
@@ -97,8 +97,8 @@ pub mod pallet {
|
||||
PayloadTooLarge,
|
||||
}
|
||||
|
||||
#[pallet::hooks]
|
||||
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
|
||||
#[pezpallet::hooks]
|
||||
impl<T: Config> Hooks<BlockNumberFor<T>> for Pezpallet<T> {
|
||||
fn on_finalize(n: BlockNumberFor<T>) {
|
||||
for (para, payload) in Targets::<T>::get().into_iter() {
|
||||
let seq = PingCount::<T>::mutate(|seq| {
|
||||
@@ -141,10 +141,10 @@ pub mod pallet {
|
||||
}
|
||||
}
|
||||
|
||||
#[pallet::call]
|
||||
impl<T: Config> Pallet<T> {
|
||||
#[pallet::call_index(0)]
|
||||
#[pallet::weight({0})]
|
||||
#[pezpallet::call]
|
||||
impl<T: Config> Pezpallet<T> {
|
||||
#[pezpallet::call_index(0)]
|
||||
#[pezpallet::weight({0})]
|
||||
pub fn start(origin: OriginFor<T>, para: ParaId, payload: Vec<u8>) -> DispatchResult {
|
||||
ensure_root(origin)?;
|
||||
let payload = BoundedVec::<u8, MaxPayloadSize>::try_from(payload)
|
||||
@@ -155,8 +155,8 @@ pub mod pallet {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[pallet::call_index(1)]
|
||||
#[pallet::weight({0})]
|
||||
#[pezpallet::call_index(1)]
|
||||
#[pezpallet::weight({0})]
|
||||
pub fn start_many(
|
||||
origin: OriginFor<T>,
|
||||
para: ParaId,
|
||||
@@ -175,8 +175,8 @@ pub mod pallet {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[pallet::call_index(2)]
|
||||
#[pallet::weight({0})]
|
||||
#[pezpallet::call_index(2)]
|
||||
#[pezpallet::weight({0})]
|
||||
pub fn stop(origin: OriginFor<T>, para: ParaId) -> DispatchResult {
|
||||
ensure_root(origin)?;
|
||||
Targets::<T>::mutate(|t| {
|
||||
@@ -187,8 +187,8 @@ pub mod pallet {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[pallet::call_index(3)]
|
||||
#[pallet::weight({0})]
|
||||
#[pezpallet::call_index(3)]
|
||||
#[pezpallet::weight({0})]
|
||||
pub fn stop_all(origin: OriginFor<T>, maybe_para: Option<ParaId>) -> DispatchResult {
|
||||
ensure_root(origin)?;
|
||||
if let Some(para) = maybe_para {
|
||||
@@ -199,8 +199,8 @@ pub mod pallet {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[pallet::call_index(4)]
|
||||
#[pallet::weight({0})]
|
||||
#[pezpallet::call_index(4)]
|
||||
#[pezpallet::weight({0})]
|
||||
pub fn ping(origin: OriginFor<T>, seq: u32, payload: Vec<u8>) -> DispatchResult {
|
||||
// Only accept pings from other chains.
|
||||
let para = ensure_sibling_para(<T as Config>::RuntimeOrigin::from(origin))?;
|
||||
@@ -226,8 +226,8 @@ pub mod pallet {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[pallet::call_index(5)]
|
||||
#[pallet::weight({0})]
|
||||
#[pezpallet::call_index(5)]
|
||||
#[pezpallet::weight({0})]
|
||||
pub fn pong(origin: OriginFor<T>, seq: u32, payload: Vec<u8>) -> DispatchResult {
|
||||
// Only accept pings from other chains.
|
||||
let para = ensure_sibling_para(<T as Config>::RuntimeOrigin::from(origin))?;
|
||||
@@ -237,7 +237,7 @@ pub mod pallet {
|
||||
para,
|
||||
seq,
|
||||
payload,
|
||||
pezframe_system::Pallet::<T>::block_number().saturating_sub(sent_at),
|
||||
pezframe_system::Pezpallet::<T>::block_number().saturating_sub(sent_at),
|
||||
));
|
||||
} else {
|
||||
// Pong received for a ping we apparently didn't send?!
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "pezpallet-presale"
|
||||
version = "1.0.0"
|
||||
description = "PEZ token presale pallet - accepts wUSDT, distributes PEZ"
|
||||
description = "PEZ token presale pezpallet - accepts wUSDT, distributes PEZ"
|
||||
authors.workspace = true
|
||||
homepage.workspace = true
|
||||
edition.workspace = true
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
use super::*;
|
||||
#[allow(unused)]
|
||||
use crate::Pallet as Presale;
|
||||
use crate::Pezpallet as Presale;
|
||||
use pezframe_benchmarking::v2::*;
|
||||
use pezframe_support::traits::fungibles::{Create, Mutate};
|
||||
use pezframe_system::RawOrigin;
|
||||
@@ -281,13 +281,13 @@ mod benchmarks {
|
||||
Presale::<T>::contribute(RawOrigin::Signed(caller.clone()).into(), presale_id, amount);
|
||||
|
||||
// Advance blocks past presale end
|
||||
pezframe_system::Pallet::<T>::set_block_number(2000u32.into());
|
||||
pezframe_system::Pezpallet::<T>::set_block_number(2000u32.into());
|
||||
|
||||
// Finalize presale (requires root)
|
||||
let _ = Presale::<T>::finalize_presale(RawOrigin::Root.into(), presale_id);
|
||||
|
||||
// Advance past cliff period
|
||||
pezframe_system::Pallet::<T>::set_block_number(3000u32.into());
|
||||
pezframe_system::Pezpallet::<T>::set_block_number(3000u32.into());
|
||||
|
||||
#[extrinsic_call]
|
||||
claim_vested(RawOrigin::Signed(caller.clone()), presale_id);
|
||||
@@ -369,7 +369,7 @@ mod benchmarks {
|
||||
}
|
||||
|
||||
// Advance blocks past presale end
|
||||
pezframe_system::Pallet::<T>::set_block_number(2000u32.into());
|
||||
pezframe_system::Pezpallet::<T>::set_block_number(2000u32.into());
|
||||
|
||||
#[extrinsic_call]
|
||||
finalize_presale(RawOrigin::Root, presale_id);
|
||||
@@ -435,7 +435,7 @@ mod benchmarks {
|
||||
let _ = T::Assets::mint_into(payment_asset.clone(), &presale_treasury, refund_pool);
|
||||
|
||||
// Advance blocks past presale end
|
||||
pezframe_system::Pallet::<T>::set_block_number(2000u32.into());
|
||||
pezframe_system::Pezpallet::<T>::set_block_number(2000u32.into());
|
||||
|
||||
// Finalize presale (will mark as Failed due to soft cap not reached)
|
||||
let _ = Presale::<T>::finalize_presale(RawOrigin::Root.into(), presale_id);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
//! # Pallet Presale - Multi-Presale Launchpad Platform
|
||||
//! # Pezpallet Presale - Multi-Presale Launchpad Platform
|
||||
//!
|
||||
//! ## Overview
|
||||
//!
|
||||
@@ -26,7 +26,7 @@
|
||||
//! - **Bonus Tiers**: Reward larger contributions
|
||||
//! - **Emergency**: Pause, cancel, withdrawal controls
|
||||
|
||||
pub use pallet::*;
|
||||
pub use pezpallet::*;
|
||||
|
||||
#[cfg(test)]
|
||||
mod mock;
|
||||
@@ -42,8 +42,8 @@ pub use weights::*;
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
#[pezframe_support::pallet]
|
||||
pub mod pallet {
|
||||
#[pezframe_support::pezpallet]
|
||||
pub mod pezpallet {
|
||||
use super::*;
|
||||
use pezframe_support::{
|
||||
dispatch::DispatchResult,
|
||||
@@ -166,10 +166,10 @@ pub mod pallet {
|
||||
pub grace_refund_fee_percent: u8,
|
||||
}
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T>(_);
|
||||
#[pezpallet::pezpallet]
|
||||
pub struct Pezpallet<T>(_);
|
||||
|
||||
#[pallet::config]
|
||||
#[pezpallet::config]
|
||||
pub trait Config: pezframe_system::Config {
|
||||
/// Asset ID type
|
||||
type AssetId: Parameter + Member + Copy + MaybeSerializeDeserialize + MaxEncodedLen;
|
||||
@@ -189,32 +189,32 @@ pub mod pallet {
|
||||
type Assets: Inspect<Self::AccountId, AssetId = Self::AssetId, Balance = Self::Balance>
|
||||
+ Mutate<Self::AccountId>;
|
||||
|
||||
/// The presale pallet id, used for deriving sub-account treasuries
|
||||
#[pallet::constant]
|
||||
/// The presale pezpallet id, used for deriving sub-account treasuries
|
||||
#[pezpallet::constant]
|
||||
type PalletId: Get<PalletId>;
|
||||
|
||||
/// Platform treasury account (receives 50% of platform fee)
|
||||
#[pallet::constant]
|
||||
#[pezpallet::constant]
|
||||
type PlatformTreasury: Get<Self::AccountId>;
|
||||
|
||||
/// Staking reward pool account (receives 25% of platform fee)
|
||||
#[pallet::constant]
|
||||
#[pezpallet::constant]
|
||||
type StakingRewardPool: Get<Self::AccountId>;
|
||||
|
||||
/// Platform fee percentage (e.g., 2 for 2%)
|
||||
#[pallet::constant]
|
||||
#[pezpallet::constant]
|
||||
type PlatformFeePercent: Get<u8>;
|
||||
|
||||
/// Maximum number of contributors per presale
|
||||
#[pallet::constant]
|
||||
#[pezpallet::constant]
|
||||
type MaxContributors: Get<u32>;
|
||||
|
||||
/// Maximum bonus tiers per presale
|
||||
#[pallet::constant]
|
||||
#[pezpallet::constant]
|
||||
type MaxBonusTiers: Get<u32>;
|
||||
|
||||
/// Maximum whitelisted accounts per presale
|
||||
#[pallet::constant]
|
||||
#[pezpallet::constant]
|
||||
type MaxWhitelistedAccounts: Get<u32>;
|
||||
|
||||
/// Origin that can create presales
|
||||
@@ -228,19 +228,19 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
/// Next presale ID
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn next_presale_id)]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::getter(fn next_presale_id)]
|
||||
pub type NextPresaleId<T: Config> = StorageValue<_, PresaleId, ValueQuery>;
|
||||
|
||||
/// Presale configurations
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn presales)]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::getter(fn presales)]
|
||||
pub type Presales<T: Config> =
|
||||
StorageMap<_, Blake2_128Concat, PresaleId, PresaleConfig<T, T::MaxBonusTiers>, OptionQuery>;
|
||||
|
||||
/// Contributions: (presale_id, account) => ContributionInfo
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn contributions)]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::getter(fn contributions)]
|
||||
pub type Contributions<T: Config> = StorageDoubleMap<
|
||||
_,
|
||||
Blake2_128Concat,
|
||||
@@ -252,8 +252,8 @@ pub mod pallet {
|
||||
>;
|
||||
|
||||
/// Contributors list per presale
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn contributors)]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::getter(fn contributors)]
|
||||
pub type Contributors<T: Config> = StorageMap<
|
||||
_,
|
||||
Blake2_128Concat,
|
||||
@@ -263,13 +263,13 @@ pub mod pallet {
|
||||
>;
|
||||
|
||||
/// Total raised per presale
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn total_raised)]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::getter(fn total_raised)]
|
||||
pub type TotalRaised<T: Config> = StorageMap<_, Blake2_128Concat, PresaleId, u128, ValueQuery>;
|
||||
|
||||
/// Whitelist: (presale_id, account) => is_whitelisted
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn whitelisted)]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::getter(fn whitelisted)]
|
||||
pub type WhitelistedAccounts<T: Config> = StorageDoubleMap<
|
||||
_,
|
||||
Blake2_128Concat,
|
||||
@@ -281,8 +281,8 @@ pub mod pallet {
|
||||
>;
|
||||
|
||||
/// Vesting claims: (presale_id, account) => claimed_amount
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn vesting_claimed)]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::getter(fn vesting_claimed)]
|
||||
pub type VestingClaimed<T: Config> = StorageDoubleMap<
|
||||
_,
|
||||
Blake2_128Concat,
|
||||
@@ -294,20 +294,20 @@ pub mod pallet {
|
||||
>;
|
||||
|
||||
/// Platform analytics
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn total_platform_volume)]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::getter(fn total_platform_volume)]
|
||||
pub type TotalPlatformVolume<T: Config> = StorageValue<_, u128, ValueQuery>;
|
||||
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn total_platform_fees)]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::getter(fn total_platform_fees)]
|
||||
pub type TotalPlatformFees<T: Config> = StorageValue<_, u128, ValueQuery>;
|
||||
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn successful_presales)]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::getter(fn successful_presales)]
|
||||
pub type SuccessfulPresales<T: Config> = StorageValue<_, u32, ValueQuery>;
|
||||
|
||||
#[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> {
|
||||
/// Presale created [presale_id, owner, payment_asset, reward_asset]
|
||||
PresaleCreated {
|
||||
@@ -346,7 +346,7 @@ pub mod pallet {
|
||||
},
|
||||
}
|
||||
|
||||
#[pallet::error]
|
||||
#[pezpallet::error]
|
||||
pub enum Error<T> {
|
||||
PresaleNotFound,
|
||||
PresaleNotActive,
|
||||
@@ -377,11 +377,11 @@ pub mod pallet {
|
||||
InvalidSoftCap,
|
||||
}
|
||||
|
||||
#[pallet::call]
|
||||
impl<T: Config> Pallet<T> {
|
||||
#[pezpallet::call]
|
||||
impl<T: Config> Pezpallet<T> {
|
||||
/// Create a new presale
|
||||
#[pallet::call_index(0)]
|
||||
#[pallet::weight(T::PresaleWeightInfo::create_presale())]
|
||||
#[pezpallet::call_index(0)]
|
||||
#[pezpallet::weight(T::PresaleWeightInfo::create_presale())]
|
||||
pub fn create_presale(
|
||||
origin: OriginFor<T>,
|
||||
payment_asset: T::AssetId,
|
||||
@@ -410,7 +410,7 @@ pub mod pallet {
|
||||
ensure!(grace_refund_fee_percent <= 100, Error::<T>::InvalidFeePercent);
|
||||
|
||||
let presale_id = NextPresaleId::<T>::get();
|
||||
let start_block = <pezframe_system::Pallet<T>>::block_number();
|
||||
let start_block = <pezframe_system::Pezpallet<T>>::block_number();
|
||||
|
||||
// Start with empty bonus tiers - can be added later
|
||||
let bounded_bonus_tiers = BoundedVec::<BonusTier, T::MaxBonusTiers>::default();
|
||||
@@ -462,8 +462,8 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
/// Contribute to a presale
|
||||
#[pallet::call_index(1)]
|
||||
#[pallet::weight(T::PresaleWeightInfo::contribute())]
|
||||
#[pezpallet::call_index(1)]
|
||||
#[pezpallet::weight(T::PresaleWeightInfo::contribute())]
|
||||
pub fn contribute(
|
||||
origin: OriginFor<T>,
|
||||
presale_id: PresaleId,
|
||||
@@ -477,7 +477,7 @@ pub mod pallet {
|
||||
ensure!(presale.status == PresaleStatus::Active, Error::<T>::PresaleNotActive);
|
||||
ensure!(amount > 0, Error::<T>::ZeroContribution);
|
||||
|
||||
let current_block = <pezframe_system::Pallet<T>>::block_number();
|
||||
let current_block = <pezframe_system::Pezpallet<T>>::block_number();
|
||||
let end_block = presale.start_block + presale.duration;
|
||||
ensure!(current_block < end_block, Error::<T>::PresaleEnded);
|
||||
|
||||
@@ -574,8 +574,8 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
/// Finalize presale - checks soft cap and sets status to Successful or Failed
|
||||
#[pallet::call_index(2)]
|
||||
#[pallet::weight(T::PresaleWeightInfo::finalize_presale(Contributors::<T>::get(presale_id).len() as u32))]
|
||||
#[pezpallet::call_index(2)]
|
||||
#[pezpallet::weight(T::PresaleWeightInfo::finalize_presale(Contributors::<T>::get(presale_id).len() as u32))]
|
||||
pub fn finalize_presale(origin: OriginFor<T>, presale_id: PresaleId) -> DispatchResult {
|
||||
ensure_root(origin)?;
|
||||
|
||||
@@ -583,7 +583,7 @@ pub mod pallet {
|
||||
|
||||
ensure!(presale.status == PresaleStatus::Active, Error::<T>::PresaleNotActive);
|
||||
|
||||
let current_block = <pezframe_system::Pallet<T>>::block_number();
|
||||
let current_block = <pezframe_system::Pezpallet<T>>::block_number();
|
||||
let end_block = presale.start_block + presale.duration;
|
||||
ensure!(current_block >= end_block, Error::<T>::PresaleNotEnded);
|
||||
|
||||
@@ -688,8 +688,8 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
/// Refund contribution (before presale ends)
|
||||
#[pallet::call_index(3)]
|
||||
#[pallet::weight(T::PresaleWeightInfo::refund())]
|
||||
#[pezpallet::call_index(3)]
|
||||
#[pezpallet::weight(T::PresaleWeightInfo::refund())]
|
||||
pub fn refund(origin: OriginFor<T>, presale_id: PresaleId) -> DispatchResult {
|
||||
let who = ensure_signed(origin)?;
|
||||
|
||||
@@ -697,7 +697,7 @@ pub mod pallet {
|
||||
|
||||
ensure!(presale.status == PresaleStatus::Active, Error::<T>::RefundNotAllowed);
|
||||
|
||||
let current_block = <pezframe_system::Pallet<T>>::block_number();
|
||||
let current_block = <pezframe_system::Pezpallet<T>>::block_number();
|
||||
let end_block = presale.start_block + presale.duration;
|
||||
ensure!(current_block < end_block, Error::<T>::RefundNotAllowed);
|
||||
|
||||
@@ -762,8 +762,8 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
/// Claim vested tokens
|
||||
#[pallet::call_index(4)]
|
||||
#[pallet::weight(T::PresaleWeightInfo::claim_vested())]
|
||||
#[pezpallet::call_index(4)]
|
||||
#[pezpallet::weight(T::PresaleWeightInfo::claim_vested())]
|
||||
pub fn claim_vested(origin: OriginFor<T>, presale_id: PresaleId) -> DispatchResult {
|
||||
let who = ensure_signed(origin)?;
|
||||
|
||||
@@ -778,7 +778,7 @@ pub mod pallet {
|
||||
ensure!(contribution_info.amount > 0, Error::<T>::NoContribution);
|
||||
ensure!(!contribution_info.refunded, Error::<T>::NoContribution);
|
||||
|
||||
let current_block = <pezframe_system::Pallet<T>>::block_number();
|
||||
let current_block = <pezframe_system::Pezpallet<T>>::block_number();
|
||||
let end_block = presale.start_block + presale.duration;
|
||||
let vesting_start = end_block + vesting.cliff_blocks;
|
||||
|
||||
@@ -845,8 +845,8 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
/// Add account to whitelist (presale owner only)
|
||||
#[pallet::call_index(5)]
|
||||
#[pallet::weight(T::PresaleWeightInfo::add_to_whitelist())]
|
||||
#[pezpallet::call_index(5)]
|
||||
#[pezpallet::weight(T::PresaleWeightInfo::add_to_whitelist())]
|
||||
pub fn add_to_whitelist(
|
||||
origin: OriginFor<T>,
|
||||
presale_id: PresaleId,
|
||||
@@ -866,8 +866,8 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
/// Cancel presale (emergency - owner or root)
|
||||
#[pallet::call_index(6)]
|
||||
#[pallet::weight(T::PresaleWeightInfo::cancel_presale())]
|
||||
#[pezpallet::call_index(6)]
|
||||
#[pezpallet::weight(T::PresaleWeightInfo::cancel_presale())]
|
||||
pub fn cancel_presale(origin: OriginFor<T>, presale_id: PresaleId) -> DispatchResult {
|
||||
// Either EmergencyOrigin or Root can cancel
|
||||
if T::EmergencyOrigin::ensure_origin(origin.clone()).is_err() {
|
||||
@@ -886,8 +886,8 @@ pub mod pallet {
|
||||
|
||||
/// Refund all contributors when presale is cancelled
|
||||
/// Auto-refunds everyone with no fees
|
||||
#[pallet::call_index(7)]
|
||||
#[pallet::weight(T::PresaleWeightInfo::refund_cancelled_presale())]
|
||||
#[pezpallet::call_index(7)]
|
||||
#[pezpallet::weight(T::PresaleWeightInfo::refund_cancelled_presale())]
|
||||
pub fn refund_cancelled_presale(
|
||||
origin: OriginFor<T>,
|
||||
presale_id: PresaleId,
|
||||
@@ -902,7 +902,7 @@ pub mod pallet {
|
||||
Error::<T>::PresaleNotFound
|
||||
);
|
||||
|
||||
let current_block = <pezframe_system::Pallet<T>>::block_number();
|
||||
let current_block = <pezframe_system::Pezpallet<T>>::block_number();
|
||||
let treasury = Self::presale_account_id(presale_id);
|
||||
|
||||
// Refund all contributors (treasury fee refunded, burn+stakers portion non-refundable)
|
||||
@@ -957,8 +957,8 @@ pub mod pallet {
|
||||
/// Batch refund for FAILED presales (soft cap not reached)
|
||||
/// Anyone can call this to help refund contributors
|
||||
/// Processes refunds in batches to avoid gas limits
|
||||
#[pallet::call_index(8)]
|
||||
#[pallet::weight(T::PresaleWeightInfo::batch_refund_failed_presale(*batch_size))]
|
||||
#[pezpallet::call_index(8)]
|
||||
#[pezpallet::weight(T::PresaleWeightInfo::batch_refund_failed_presale(*batch_size))]
|
||||
pub fn batch_refund_failed_presale(
|
||||
origin: OriginFor<T>,
|
||||
presale_id: PresaleId,
|
||||
@@ -972,7 +972,7 @@ pub mod pallet {
|
||||
// Only works on FAILED presales (soft cap not reached)
|
||||
ensure!(presale.status == PresaleStatus::Failed, Error::<T>::PresaleNotFailed);
|
||||
|
||||
let current_block = <pezframe_system::Pallet<T>>::block_number();
|
||||
let current_block = <pezframe_system::Pezpallet<T>>::block_number();
|
||||
let treasury = Self::presale_account_id(presale_id);
|
||||
let contributors = Contributors::<T>::get(presale_id);
|
||||
|
||||
@@ -1044,7 +1044,7 @@ pub mod pallet {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Config> Pallet<T> {
|
||||
impl<T: Config> Pezpallet<T> {
|
||||
/// Get presale sub-account treasury
|
||||
pub fn presale_account_id(presale_id: PresaleId) -> T::AccountId {
|
||||
use alloc::vec::Vec;
|
||||
|
||||
@@ -12,7 +12,7 @@ use pezsp_runtime::{
|
||||
|
||||
type Block = pezframe_system::mocking::MockBlock<Test>;
|
||||
|
||||
// Configure a mock runtime to test the pallet.
|
||||
// Configure a mock runtime to test the pezpallet.
|
||||
pezframe_support::construct_runtime!(
|
||||
pub enum Test
|
||||
{
|
||||
@@ -182,7 +182,7 @@ pub fn presale_treasury(presale_id: u32) -> u64 {
|
||||
use pezsp_io::hashing::blake2_256;
|
||||
|
||||
// Create a unique account ID for each presale by hashing pezpallet_id + presale_id
|
||||
// This matches the logic in pezpallet_presale::Pallet::presale_account_id
|
||||
// This matches the logic in pezpallet_presale::Pezpallet::presale_account_id
|
||||
let pezpallet_id = PresalePalletId::get();
|
||||
let mut buf = Vec::new();
|
||||
buf.extend_from_slice(&pezpallet_id.0[..]);
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
// ./target/release/frame-omni-bencher
|
||||
// v1
|
||||
// benchmark
|
||||
// pallet
|
||||
// pezpallet
|
||||
// --runtime
|
||||
// target/release/wbuild/asset-hub-pezkuwichain-runtime/asset_hub_pezkuwichain_runtime.compact.compressed.wasm
|
||||
// --pallets
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#![cfg(feature = "runtime-benchmarks")]
|
||||
|
||||
use super::*;
|
||||
use crate::Pallet as Referral;
|
||||
use crate::Pezpallet as Referral;
|
||||
use pezframe_benchmarking::v2::*;
|
||||
use pezframe_system::RawOrigin;
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
//! # Referral Pallet
|
||||
//! # Referral Pezpallet
|
||||
//!
|
||||
//! A pallet for managing user referrals and tracking network growth through invitation mechanics.
|
||||
//! A pezpallet for managing user referrals and tracking network growth through invitation mechanics.
|
||||
//!
|
||||
//! ## Overview
|
||||
//!
|
||||
//! The Referral pallet implements a referral system that incentivizes user growth by tracking
|
||||
//! The Referral pezpallet implements a referral system that incentivizes user growth by tracking
|
||||
//! and rewarding users who successfully invite others to complete KYC verification. Referral
|
||||
//! counts contribute to trust scores and validator eligibility.
|
||||
//!
|
||||
@@ -86,14 +86,14 @@
|
||||
//! type WeightInfo = pezpallet_referral::weights::BizinikiwiWeight<Runtime>;
|
||||
//! }
|
||||
//!
|
||||
//! // Configure pezpallet-identity-kyc to notify referral pallet
|
||||
//! // Configure pezpallet-identity-kyc to notify referral pezpallet
|
||||
//! impl pezpallet_identity_kyc::Config for Runtime {
|
||||
//! // ...
|
||||
//! type OnKycApproved = Referral; // Hook referral confirmation
|
||||
//! }
|
||||
//! ```
|
||||
|
||||
pub use pallet::*;
|
||||
pub use pezpallet::*;
|
||||
#[cfg(test)]
|
||||
mod mock;
|
||||
pub mod types; // Adding our new types module
|
||||
@@ -107,18 +107,18 @@ mod benchmarking;
|
||||
extern crate alloc;
|
||||
use crate::weights::WeightInfo;
|
||||
|
||||
#[pezframe_support::pallet]
|
||||
pub mod pallet {
|
||||
#[pezframe_support::pezpallet]
|
||||
pub mod pezpallet {
|
||||
use super::*;
|
||||
use crate::types::{InviterProvider, RawScore, ReferralScoreProvider, ReferrerStats};
|
||||
use pezframe_support::pezpallet_prelude::*;
|
||||
use pezframe_system::pezpallet_prelude::*;
|
||||
use pezpallet_identity_kyc::types::{KycStatus, OnCitizenshipRevoked, OnKycApproved};
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T>(_);
|
||||
#[pezpallet::pezpallet]
|
||||
pub struct Pezpallet<T>(_);
|
||||
|
||||
#[pallet::config]
|
||||
#[pezpallet::config]
|
||||
pub trait Config: pezframe_system::Config + pezpallet_identity_kyc::Config + TypeInfo {
|
||||
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
|
||||
type WeightInfo: weights::WeightInfo;
|
||||
@@ -130,7 +130,7 @@ pub mod pallet {
|
||||
/// Penalty score per revoked referral
|
||||
/// DIRECT RESPONSIBILITY: Bad referrals reduce referrer's score
|
||||
/// Default: 3 (each bad referral costs 3x a good referral)
|
||||
#[pallet::constant]
|
||||
#[pezpallet::constant]
|
||||
type PenaltyPerRevocation: Get<u32>;
|
||||
}
|
||||
|
||||
@@ -138,29 +138,29 @@ pub mod pallet {
|
||||
|
||||
/// Holds users awaiting to join system via referral.
|
||||
/// (Referred AccountId -> Referrer AccountId)
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn pending_referrals)]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::getter(fn pending_referrals)]
|
||||
pub type PendingReferrals<T: Config> =
|
||||
StorageMap<_, Blake2_128Concat, T::AccountId, T::AccountId, OptionQuery>;
|
||||
|
||||
/// Holds successfully completed referral count per user.
|
||||
/// (Referrer AccountId -> Count)
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn referral_count)]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::getter(fn referral_count)]
|
||||
pub type ReferralCount<T: Config> =
|
||||
StorageMap<_, Blake2_128Concat, T::AccountId, u32, ValueQuery>;
|
||||
|
||||
/// Holds who a user invited and transaction details.
|
||||
/// (Referred AccountId -> ReferralInfo)
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn referrals)]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::getter(fn referrals)]
|
||||
pub type Referrals<T: Config> =
|
||||
StorageMap<_, Blake2_128Concat, T::AccountId, ReferralInfo<T>, OptionQuery>;
|
||||
|
||||
/// Referrer statistics for direct responsibility tracking
|
||||
/// ACCOUNTABILITY: Tracks good and bad referrals for penalty calculation
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn referrer_stats)]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::getter(fn referrer_stats)]
|
||||
pub type ReferrerStatsStorage<T: Config> =
|
||||
StorageMap<_, Blake2_128Concat, T::AccountId, ReferrerStats, ValueQuery>;
|
||||
|
||||
@@ -171,8 +171,8 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
// --- 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> {
|
||||
/// When a user invites another user.
|
||||
ReferralInitiated { referrer: T::AccountId, referred: T::AccountId },
|
||||
@@ -193,7 +193,7 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
// --- Errors ---
|
||||
#[pallet::error]
|
||||
#[pezpallet::error]
|
||||
pub enum Error<T> {
|
||||
/// A user cannot invite themselves.
|
||||
SelfReferral,
|
||||
@@ -202,11 +202,11 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
// --- Extrinsics ---
|
||||
#[pallet::call]
|
||||
impl<T: Config> Pallet<T> {
|
||||
#[pezpallet::call]
|
||||
impl<T: Config> Pezpallet<T> {
|
||||
/// Initiates a referral record to invite another user to the system.
|
||||
#[pallet::call_index(0)]
|
||||
#[pallet::weight(<T as Config>::WeightInfo::initiate_referral())]
|
||||
#[pezpallet::call_index(0)]
|
||||
#[pezpallet::weight(<T as Config>::WeightInfo::initiate_referral())]
|
||||
pub fn initiate_referral(origin: OriginFor<T>, referred: T::AccountId) -> DispatchResult {
|
||||
let referrer = ensure_signed(origin)?;
|
||||
ensure!(referrer != referred, Error::<T>::SelfReferral);
|
||||
@@ -220,8 +220,8 @@ pub mod pallet {
|
||||
|
||||
/// Sudo-only extrinsic to manually confirm a referral (for fixing historical data).
|
||||
/// This bypasses the normal KYC approval flow and directly confirms the referral.
|
||||
#[pallet::call_index(1)]
|
||||
#[pallet::weight(<T as Config>::WeightInfo::force_confirm_referral())]
|
||||
#[pezpallet::call_index(1)]
|
||||
#[pezpallet::weight(<T as Config>::WeightInfo::force_confirm_referral())]
|
||||
pub fn force_confirm_referral(
|
||||
origin: OriginFor<T>,
|
||||
referrer: T::AccountId,
|
||||
@@ -238,7 +238,7 @@ pub mod pallet {
|
||||
// Create and store referral info
|
||||
let referral_info = ReferralInfo {
|
||||
referrer: referrer.clone(),
|
||||
created_at: pezframe_system::Pallet::<T>::block_number(),
|
||||
created_at: pezframe_system::Pezpallet::<T>::block_number(),
|
||||
};
|
||||
Referrals::<T>::insert(referred.clone(), referral_info);
|
||||
|
||||
@@ -258,11 +258,11 @@ pub mod pallet {
|
||||
|
||||
// --- Trait Implementations ---
|
||||
|
||||
impl<T: Config> OnKycApproved<T::AccountId> for Pallet<T> {
|
||||
impl<T: Config> OnKycApproved<T::AccountId> for Pezpallet<T> {
|
||||
fn on_kyc_approved(who: &T::AccountId, referrer: &T::AccountId) {
|
||||
// Security check: Verify on-chain that the user's KYC status is actually
|
||||
// "Approved" before confirming the referral.
|
||||
if pezpallet_identity_kyc::Pallet::<T>::get_kyc_status(who) ==
|
||||
if pezpallet_identity_kyc::Pezpallet::<T>::get_kyc_status(who) ==
|
||||
pezpallet_identity_kyc::types::KycLevel::Approved
|
||||
{
|
||||
// Check if this referral already exists (prevent double-counting)
|
||||
@@ -289,7 +289,7 @@ pub mod pallet {
|
||||
// Create and store referral info
|
||||
let referral_info = ReferralInfo {
|
||||
referrer: referrer.clone(),
|
||||
created_at: pezframe_system::Pallet::<T>::block_number(),
|
||||
created_at: pezframe_system::Pezpallet::<T>::block_number(),
|
||||
};
|
||||
Referrals::<T>::insert(who.clone(), referral_info);
|
||||
|
||||
@@ -305,7 +305,7 @@ pub mod pallet {
|
||||
|
||||
/// Implementation for direct responsibility penalty system
|
||||
/// Called when a citizen's status is revoked (malicious actor identified)
|
||||
impl<T: Config> OnCitizenshipRevoked<T::AccountId> for Pallet<T> {
|
||||
impl<T: Config> OnCitizenshipRevoked<T::AccountId> for Pezpallet<T> {
|
||||
fn on_citizenship_revoked(who: &T::AccountId) {
|
||||
// Find the referrer of the revoked citizen
|
||||
if let Some(referral_info) = Referrals::<T>::get(who) {
|
||||
@@ -333,7 +333,7 @@ pub mod pallet {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Config> ReferralScoreProvider<T::AccountId> for Pallet<T> {
|
||||
impl<T: Config> ReferralScoreProvider<T::AccountId> for Pezpallet<T> {
|
||||
type Score = RawScore;
|
||||
|
||||
fn get_referral_score(who: &T::AccountId) -> RawScore {
|
||||
@@ -372,7 +372,7 @@ pub mod pallet {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Config> InviterProvider<T::AccountId> for Pallet<T> {
|
||||
impl<T: Config> InviterProvider<T::AccountId> for Pezpallet<T> {
|
||||
fn get_inviter(who: &T::AccountId) -> Option<T::AccountId> {
|
||||
Referrals::<T>::get(who).map(|info| info.referrer)
|
||||
}
|
||||
|
||||
@@ -70,8 +70,8 @@ impl pezpallet_identity_kyc::Config for Test {
|
||||
type Currency = Balances;
|
||||
type GovernanceOrigin = EnsureRoot<AccountId>;
|
||||
type WeightInfo = ();
|
||||
type OnKycApproved = Referral; // Referral pallet handles KYC approval hook
|
||||
type OnCitizenshipRevoked = Referral; // Referral pallet handles revocation penalty
|
||||
type OnKycApproved = Referral; // Referral pezpallet handles KYC approval hook
|
||||
type OnCitizenshipRevoked = Referral; // Referral pezpallet handles revocation penalty
|
||||
type CitizenNftProvider = MockCitizenNftProvider;
|
||||
type KycApplicationDeposit = KycApplicationDepositAmount;
|
||||
type MaxStringLength = MaxStringLen;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
use crate::{
|
||||
mock::*, pallet::ReferralInfo, Error, Event, PendingReferrals, ReferralCount, Referrals,
|
||||
mock::*, pezpallet::ReferralInfo, Error, Event, PendingReferrals, ReferralCount, Referrals,
|
||||
ReferrerStatsStorage,
|
||||
};
|
||||
use pezframe_support::{assert_noop, assert_ok};
|
||||
use pezpallet_identity_kyc::types::{OnCitizenshipRevoked, OnKycApproved};
|
||||
use pezsp_runtime::DispatchError;
|
||||
|
||||
type ReferralPallet = crate::Pallet<Test>;
|
||||
type ReferralPallet = crate::Pezpallet<Test>;
|
||||
|
||||
// ============================================================================
|
||||
// initiate_referral Tests
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! Benchmarking setup for pezpallet-staking-score
|
||||
|
||||
use super::*;
|
||||
use crate::{Config, Pallet, StakingStartBlock};
|
||||
use crate::{Config, Pezpallet, StakingStartBlock};
|
||||
use pezframe_benchmarking::v2::*;
|
||||
use pezframe_system::RawOrigin;
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
//! # Staking Score Pallet
|
||||
//! # Staking Score Pezpallet
|
||||
//!
|
||||
//! A pallet for calculating time-weighted staking scores based on stake amount and duration.
|
||||
//! A pezpallet for calculating time-weighted staking scores based on stake amount and duration.
|
||||
//!
|
||||
//! ## Overview
|
||||
//!
|
||||
//! The Staking Score pallet calculates reputation scores from staking behavior by considering:
|
||||
//! The Staking Score pezpallet calculates reputation scores from staking behavior by considering:
|
||||
//! - **Stake Amount**: How much a user has staked
|
||||
//! - **Stake Duration**: How long tokens have been staked
|
||||
//! - **Nomination Count**: Number of validators nominated
|
||||
@@ -33,7 +33,7 @@
|
||||
//!
|
||||
//! ## Workflow
|
||||
//!
|
||||
//! 1. User stakes tokens via main staking pallet
|
||||
//! 1. User stakes tokens via main staking pezpallet
|
||||
//! 2. User calls `start_score_tracking()` to begin time tracking
|
||||
//! 3. Tracking start block is recorded
|
||||
//! 4. `pezpallet-trust` queries staking score via `StakingScoreProvider` trait
|
||||
@@ -42,8 +42,8 @@
|
||||
//!
|
||||
//! ## Integration with Staking
|
||||
//!
|
||||
//! This pallet does not handle staking operations directly. It:
|
||||
//! - Reads staking data from main staking pallet via `StakingInfoProvider`
|
||||
//! This pezpallet does not handle staking operations directly. It:
|
||||
//! - Reads staking data from main staking pezpallet via `StakingInfoProvider`
|
||||
//! - Tracks when users want to start earning time bonuses
|
||||
//! - Calculates scores on-demand without modifying staking state
|
||||
//!
|
||||
@@ -79,8 +79,8 @@
|
||||
//!
|
||||
//! ## Dependencies
|
||||
//!
|
||||
//! This pallet requires:
|
||||
//! - Main staking pallet implementing `StakingInfoProvider`
|
||||
//! This pezpallet requires:
|
||||
//! - Main staking pezpallet implementing `StakingInfoProvider`
|
||||
//! - `pezpallet-trust` as consumer of staking scores
|
||||
//!
|
||||
//! ## Runtime Integration Example
|
||||
@@ -89,12 +89,12 @@
|
||||
//! impl pezpallet_staking_score::Config for Runtime {
|
||||
//! type RuntimeEvent = RuntimeEvent;
|
||||
//! type Balance = Balance;
|
||||
//! type StakingInfo = Staking; // Main staking pallet
|
||||
//! type StakingInfo = Staking; // Main staking pezpallet
|
||||
//! type WeightInfo = pezpallet_staking_score::weights::BizinikiwiWeight<Runtime>;
|
||||
//! }
|
||||
//! ```
|
||||
|
||||
pub use pallet::*;
|
||||
pub use pezpallet::*;
|
||||
|
||||
// Mock staking info provider for benchmarking - ADD THIS
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
@@ -125,8 +125,8 @@ mod tests;
|
||||
|
||||
pub mod weights;
|
||||
|
||||
#[pezframe_support::pallet]
|
||||
pub mod pallet {
|
||||
#[pezframe_support::pezpallet]
|
||||
pub mod pezpallet {
|
||||
use super::weights::WeightInfo; // Properly importing WeightInfo from parent module.
|
||||
use core::ops::Div;
|
||||
use pezframe_support::pezpallet_prelude::*;
|
||||
@@ -140,10 +140,10 @@ pub mod pallet {
|
||||
pub const MONTH_IN_BLOCKS: u32 = 30 * 24 * 60 * 10;
|
||||
pub const UNITS: u128 = 1_000_000_000_000;
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T>(_);
|
||||
#[pezpallet::pezpallet]
|
||||
pub struct Pezpallet<T>(_);
|
||||
|
||||
#[pallet::config]
|
||||
#[pezpallet::config]
|
||||
pub trait Config: pezframe_system::Config
|
||||
where
|
||||
// Ensuring BlockNumber is convertible from u32.
|
||||
@@ -169,19 +169,19 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
// --- Depolama (Storage) ---
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn staking_start_block)]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::getter(fn staking_start_block)]
|
||||
pub type StakingStartBlock<T: Config> =
|
||||
StorageMap<_, Blake2_128Concat, T::AccountId, BlockNumberFor<T>, OptionQuery>;
|
||||
|
||||
#[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> {
|
||||
/// A user started time-based scoring.
|
||||
ScoreTrackingStarted { who: T::AccountId, start_block: BlockNumberFor<T> },
|
||||
}
|
||||
|
||||
#[pallet::error]
|
||||
#[pezpallet::error]
|
||||
pub enum Error<T> {
|
||||
/// Puan takibini başlatmak için önce stake yapmış olmalısınız.
|
||||
NoStakeFound,
|
||||
@@ -189,12 +189,12 @@ pub mod pallet {
|
||||
TrackingAlreadyStarted,
|
||||
}
|
||||
|
||||
#[pallet::call]
|
||||
impl<T: Config> Pallet<T> {
|
||||
#[pezpallet::call]
|
||||
impl<T: Config> Pezpallet<T> {
|
||||
/// Süreye dayalı puanlamayı manuel olarak aktive eder.
|
||||
/// Bu fonksiyon, her kullanıcı tarafından sadece bir kez çağrılmalıdır.
|
||||
#[pallet::call_index(0)]
|
||||
#[pallet::weight(T::WeightInfo::start_score_tracking())]
|
||||
#[pezpallet::call_index(0)]
|
||||
#[pezpallet::weight(T::WeightInfo::start_score_tracking())]
|
||||
pub fn start_score_tracking(origin: OriginFor<T>) -> DispatchResult {
|
||||
let who = ensure_signed(origin)?;
|
||||
|
||||
@@ -212,7 +212,7 @@ pub mod pallet {
|
||||
ensure!(!details.staked_amount.is_zero(), Error::<T>::NoStakeFound);
|
||||
|
||||
// 3. O anki blok numarasını kaydet.
|
||||
let current_block = pezframe_system::Pallet::<T>::block_number();
|
||||
let current_block = pezframe_system::Pezpallet::<T>::block_number();
|
||||
StakingStartBlock::<T>::insert(&who, current_block);
|
||||
|
||||
Self::deposit_event(Event::ScoreTrackingStarted { who, start_block: current_block });
|
||||
@@ -249,7 +249,7 @@ pub mod pallet {
|
||||
|
||||
// --- Trait Implementasyonu ---
|
||||
|
||||
impl<T: Config> StakingScoreProvider<T::AccountId, BlockNumberFor<T>> for Pallet<T> {
|
||||
impl<T: Config> StakingScoreProvider<T::AccountId, BlockNumberFor<T>> for Pezpallet<T> {
|
||||
fn get_staking_score(who: &T::AccountId) -> (RawScore, BlockNumberFor<T>) {
|
||||
// 1. Staking detaylarını al. Eğer stake yoksa (None) 0 puan döndür.
|
||||
let staking_details = match T::StakingInfo::get_staking_details(who) {
|
||||
@@ -281,7 +281,7 @@ pub mod pallet {
|
||||
{
|
||||
// Eğer kullanıcı `start_score_tracking` çağırdıysa...
|
||||
Some(start_block) => {
|
||||
let current_block = pezframe_system::Pallet::<T>::block_number();
|
||||
let current_block = pezframe_system::Pezpallet::<T>::block_number();
|
||||
let duration_in_blocks = current_block.saturating_sub(start_block);
|
||||
|
||||
let multiplier = if duration_in_blocks >= (12 * MONTH_IN_BLOCKS).into() {
|
||||
@@ -305,7 +305,7 @@ pub mod pallet {
|
||||
// Nihai puanı hesapla ve 100 ile sınırla.
|
||||
let final_score = match StakingStartBlock::<T>::get(who) {
|
||||
Some(start_block) => {
|
||||
let current_block = pezframe_system::Pallet::<T>::block_number();
|
||||
let current_block = pezframe_system::Pezpallet::<T>::block_number();
|
||||
let duration_in_blocks = current_block.saturating_sub(start_block);
|
||||
|
||||
if duration_in_blocks >= (12 * MONTH_IN_BLOCKS).into() {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -14,31 +14,31 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Minimal Pallet that injects a TeyrchainId into Runtime storage from
|
||||
//! Minimal Pezpallet that injects a TeyrchainId into Runtime storage from
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
pub use pallet::*;
|
||||
pub use pezpallet::*;
|
||||
|
||||
#[pezframe_support::pallet]
|
||||
pub mod pallet {
|
||||
#[pezframe_support::pezpallet]
|
||||
pub mod pezpallet {
|
||||
use pezcumulus_primitives_core::ParaId;
|
||||
use pezframe_support::pezpallet_prelude::*;
|
||||
use pezframe_system::pezpallet_prelude::*;
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T>(_);
|
||||
#[pezpallet::pezpallet]
|
||||
pub struct Pezpallet<T>(_);
|
||||
|
||||
#[pallet::config]
|
||||
#[pezpallet::config]
|
||||
pub trait Config: pezframe_system::Config {}
|
||||
|
||||
#[pallet::hooks]
|
||||
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {}
|
||||
#[pezpallet::hooks]
|
||||
impl<T: Config> Hooks<BlockNumberFor<T>> for Pezpallet<T> {}
|
||||
|
||||
#[pallet::call]
|
||||
impl<T: Config> Pallet<T> {}
|
||||
#[pezpallet::call]
|
||||
impl<T: Config> Pezpallet<T> {}
|
||||
|
||||
#[pallet::genesis_config]
|
||||
#[pezpallet::genesis_config]
|
||||
pub struct GenesisConfig<T: Config> {
|
||||
#[serde(skip)]
|
||||
pub _config: core::marker::PhantomData<T>,
|
||||
@@ -51,29 +51,29 @@ pub mod pallet {
|
||||
}
|
||||
}
|
||||
|
||||
#[pallet::genesis_build]
|
||||
#[pezpallet::genesis_build]
|
||||
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
|
||||
fn build(&self) {
|
||||
TeyrchainId::<T>::put(self.teyrchain_id);
|
||||
}
|
||||
}
|
||||
|
||||
#[pallet::type_value]
|
||||
#[pezpallet::type_value]
|
||||
pub(super) fn DefaultForTeyrchainId() -> ParaId {
|
||||
100.into()
|
||||
}
|
||||
|
||||
#[pallet::storage]
|
||||
#[pezpallet::storage]
|
||||
pub(super) type TeyrchainId<T: Config> =
|
||||
StorageValue<_, ParaId, ValueQuery, DefaultForTeyrchainId>;
|
||||
|
||||
impl<T: Config> Get<ParaId> for Pallet<T> {
|
||||
impl<T: Config> Get<ParaId> for Pezpallet<T> {
|
||||
fn get() -> ParaId {
|
||||
TeyrchainId::<T>::get()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Config> Pallet<T> {
|
||||
impl<T: Config> Pezpallet<T> {
|
||||
pub fn teyrchain_id() -> ParaId {
|
||||
TeyrchainId::<T>::get()
|
||||
}
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
use super::*;
|
||||
|
||||
#[allow(unused)]
|
||||
use crate::Pallet as Tiki;
|
||||
use crate::Pezpallet as Tiki;
|
||||
use pezframe_benchmarking::v2::*;
|
||||
use pezframe_system::RawOrigin;
|
||||
// Gerekli trait'leri import ediyoruz
|
||||
use pezframe_support::traits::{Currency, Get};
|
||||
use pezpallet_balances::Pallet as Balances;
|
||||
use pezpallet_balances::Pezpallet as Balances;
|
||||
use pezsp_runtime::traits::StaticLookup;
|
||||
extern crate alloc;
|
||||
use alloc::vec;
|
||||
@@ -38,7 +38,7 @@ mod benchmarks {
|
||||
|
||||
// `while` döngüsü, 'Step' trait'ine olan ihtiyacı ortadan kaldırır.
|
||||
while pezpallet_nfts::NextCollectionId::<T>::get().unwrap_or_default() <= collection_id {
|
||||
let _ = pezpallet_nfts::Pallet::<T>::force_create(
|
||||
let _ = pezpallet_nfts::Pezpallet::<T>::force_create(
|
||||
RawOrigin::Root.into(),
|
||||
T::Lookup::unlookup(caller.clone()),
|
||||
pezpallet_nfts::CollectionConfig {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
//!
|
||||
//! # Feature Unification Note
|
||||
//!
|
||||
//! Due to Cargo's feature unification behavior, this pallet must be excluded
|
||||
//! Due to Cargo's feature unification behavior, this pezpallet must be excluded
|
||||
//! from `cargo check --benches` operations when its `runtime-benchmarks` feature
|
||||
//! is not explicitly enabled. The CI workflow (tests-misc.yml) handles this
|
||||
//! by excluding pezpallet-tiki and all its dependents.
|
||||
@@ -15,10 +15,10 @@
|
||||
//! a required trait method. However, if `pezpallet-tiki/runtime-benchmarks` is not enabled,
|
||||
//! our cfg-gated method won't be compiled, causing E0046 errors.
|
||||
//!
|
||||
//! CI exclusion: .github/workflows/tests-misc.yml excludes this pallet with:
|
||||
//! CI exclusion: .github/workflows/tests-misc.yml excludes this pezpallet with:
|
||||
//! `--exclude pezpallet-tiki` in the `cargo check --benches` command.
|
||||
|
||||
use crate::{Config, Pallet as TikiPallet};
|
||||
use crate::{Config, Pezpallet as TikiPallet};
|
||||
use pezframe_support::traits::EnsureOrigin;
|
||||
use pezframe_system::ensure_signed;
|
||||
use pezsp_std::marker::PhantomData;
|
||||
@@ -96,9 +96,9 @@ impl GetTiki for ParlementerRole {
|
||||
/// // Require the caller to hold the Serok Tiki
|
||||
/// type SerokOrigin = EnsureTiki<Runtime, SerokRole>;
|
||||
///
|
||||
/// // Use in a pallet's dispatchable
|
||||
/// #[pallet::call]
|
||||
/// impl<T: Config> Pallet<T> {
|
||||
/// // Use in a pezpallet's dispatchable
|
||||
/// #[pezpallet::call]
|
||||
/// impl<T: Config> Pezpallet<T> {
|
||||
/// pub fn privileged_action(origin: OriginFor<T>) -> DispatchResult {
|
||||
/// let who = T::SerokOrigin::ensure_origin(origin)?;
|
||||
/// // ... action requiring Serok authority
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
//! # Tiki (Role) Pallet
|
||||
//! # Tiki (Role) Pezpallet
|
||||
//!
|
||||
//! A pallet for managing citizenship and role-based NFTs with automated and governance-driven
|
||||
//! A pezpallet for managing citizenship and role-based NFTs with automated and governance-driven
|
||||
//! assignment.
|
||||
//!
|
||||
//! ## Overview
|
||||
//!
|
||||
//! The Tiki pallet implements a comprehensive role management system using non-transferable NFTs
|
||||
//! The Tiki pezpallet implements a comprehensive role management system using non-transferable NFTs
|
||||
//! to represent citizenship status and various roles within the ecosystem. Each role grants
|
||||
//! specific permissions, rights, and social standing.
|
||||
//!
|
||||
@@ -81,7 +81,7 @@
|
||||
//!
|
||||
//! ## Dependencies
|
||||
//!
|
||||
//! This pallet requires integration with:
|
||||
//! This pezpallet requires integration with:
|
||||
//! - `pezpallet-identity-kyc` - KYC status and approval notifications
|
||||
//! - `pezpallet-nfts` - Underlying NFT infrastructure
|
||||
//! - `pezpallet-trust` - Trust score verification for role eligibility
|
||||
@@ -101,7 +101,7 @@
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
pub use pallet::*;
|
||||
pub use pezpallet::*;
|
||||
|
||||
use alloc::{format, vec::Vec};
|
||||
use pezframe_support::pezpallet_prelude::{MaybeSerializeDeserialize, Parameter, RuntimeDebug};
|
||||
@@ -120,18 +120,18 @@ pub use weights::*;
|
||||
pub mod ensure;
|
||||
pub mod migrations; // Storage migrations // For origin validation
|
||||
|
||||
#[pezframe_support::pallet]
|
||||
pub mod pallet {
|
||||
#[pezframe_support::pezpallet]
|
||||
pub mod pezpallet {
|
||||
use super::*;
|
||||
use pezframe_support::pezpallet_prelude::*;
|
||||
use pezframe_system::pezpallet_prelude::*;
|
||||
use pezsp_runtime::traits::StaticLookup;
|
||||
|
||||
#[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_nfts::Config<ItemId = u32> + pezpallet_identity_kyc::Config
|
||||
{
|
||||
@@ -140,14 +140,14 @@ pub mod pallet {
|
||||
type WeightInfo: weights::WeightInfo;
|
||||
|
||||
/// Collection ID holding Tiki (Role) NFTs.
|
||||
#[pallet::constant]
|
||||
#[pezpallet::constant]
|
||||
type TikiCollectionId: Get<Self::CollectionId>;
|
||||
|
||||
/// Technical upper limit for maximum number of Tikis (roles) a user can hold.
|
||||
#[pallet::constant]
|
||||
#[pezpallet::constant]
|
||||
type MaxTikisPerUser: Get<u32>;
|
||||
|
||||
/// Tiki enum type to be used within the pallet.
|
||||
/// Tiki enum type to be used within the pezpallet.
|
||||
type Tiki: Parameter
|
||||
+ From<Tiki>
|
||||
+ Into<u32>
|
||||
@@ -254,14 +254,14 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
/// Holds citizenship NFT ID for each user
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn citizen_nft)]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::getter(fn citizen_nft)]
|
||||
pub type CitizenNft<T: Config> =
|
||||
StorageMap<_, Blake2_128Concat, T::AccountId, u32, OptionQuery>;
|
||||
|
||||
/// List of Tikis (roles) owned by each user
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn user_tikis)]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::getter(fn user_tikis)]
|
||||
pub type UserTikis<T: Config> = StorageMap<
|
||||
_,
|
||||
Blake2_128Concat,
|
||||
@@ -271,17 +271,17 @@ pub mod pallet {
|
||||
>;
|
||||
|
||||
/// Shows which user a specific Tiki belongs to (for unique roles)
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn tiki_holder)]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::getter(fn tiki_holder)]
|
||||
pub type TikiHolder<T: Config> =
|
||||
StorageMap<_, Blake2_128Concat, Tiki, T::AccountId, OptionQuery>;
|
||||
|
||||
/// Item ID to be used for next NFT
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn next_item_id)]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::getter(fn next_item_id)]
|
||||
pub type NextItemId<T: Config> = StorageValue<_, u32, ValueQuery>;
|
||||
|
||||
#[pallet::error]
|
||||
#[pezpallet::error]
|
||||
pub enum Error<T> {
|
||||
/// Role already belongs to someone else
|
||||
RoleAlreadyTaken,
|
||||
@@ -305,8 +305,8 @@ pub mod pallet {
|
||||
InvalidRoleAssignmentMethod,
|
||||
}
|
||||
|
||||
#[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> {
|
||||
/// New citizenship NFT minted
|
||||
CitizenNftMinted { who: T::AccountId, nft_id: u32 },
|
||||
@@ -323,8 +323,8 @@ pub mod pallet {
|
||||
},
|
||||
}
|
||||
|
||||
#[pallet::hooks]
|
||||
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
|
||||
#[pezpallet::hooks]
|
||||
impl<T: Config> Hooks<BlockNumberFor<T>> for Pezpallet<T> {
|
||||
fn on_initialize(_block_number: BlockNumberFor<T>) -> Weight {
|
||||
// Check newly KYC-approved users and mint citizenship NFT
|
||||
Self::check_and_mint_citizen_nfts();
|
||||
@@ -333,11 +333,11 @@ pub mod pallet {
|
||||
}
|
||||
}
|
||||
|
||||
#[pallet::call]
|
||||
impl<T: Config> Pallet<T> {
|
||||
#[pezpallet::call]
|
||||
impl<T: Config> Pezpallet<T> {
|
||||
/// Admin tarafından belirli bir kullanıcıya Tiki (rol) verme
|
||||
#[pallet::call_index(0)]
|
||||
#[pallet::weight(<T as crate::pallet::Config>::WeightInfo::grant_tiki())]
|
||||
#[pezpallet::call_index(0)]
|
||||
#[pezpallet::weight(<T as crate::pezpallet::Config>::WeightInfo::grant_tiki())]
|
||||
pub fn grant_tiki(
|
||||
origin: OriginFor<T>,
|
||||
dest: <T::Lookup as StaticLookup>::Source,
|
||||
@@ -357,8 +357,8 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
/// Admin tarafından belirli bir kullanıcıdan Tiki (rol) alma
|
||||
#[pallet::call_index(1)]
|
||||
#[pallet::weight(<T as crate::pallet::Config>::WeightInfo::revoke_tiki())]
|
||||
#[pezpallet::call_index(1)]
|
||||
#[pezpallet::weight(<T as crate::pezpallet::Config>::WeightInfo::revoke_tiki())]
|
||||
pub fn revoke_tiki(
|
||||
origin: OriginFor<T>,
|
||||
target: <T::Lookup as StaticLookup>::Source,
|
||||
@@ -372,8 +372,8 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
/// Manually mint citizenship NFT (for testing/emergency)
|
||||
#[pallet::call_index(2)]
|
||||
#[pallet::weight(<T as crate::pallet::Config>::WeightInfo::grant_tiki())]
|
||||
#[pezpallet::call_index(2)]
|
||||
#[pezpallet::weight(<T as crate::pezpallet::Config>::WeightInfo::grant_tiki())]
|
||||
pub fn force_mint_citizen_nft(
|
||||
origin: OriginFor<T>,
|
||||
dest: <T::Lookup as StaticLookup>::Source,
|
||||
@@ -386,8 +386,8 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
/// Grant role through election system (called from pezpallet-voting)
|
||||
#[pallet::call_index(3)]
|
||||
#[pallet::weight(<T as crate::pallet::Config>::WeightInfo::grant_tiki())]
|
||||
#[pezpallet::call_index(3)]
|
||||
#[pezpallet::weight(<T as crate::pezpallet::Config>::WeightInfo::grant_tiki())]
|
||||
pub fn grant_elected_role(
|
||||
origin: OriginFor<T>,
|
||||
dest: <T::Lookup as StaticLookup>::Source,
|
||||
@@ -407,14 +407,14 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
/// Grant role through exam/test system
|
||||
#[pallet::call_index(4)]
|
||||
#[pallet::weight(<T as crate::pallet::Config>::WeightInfo::grant_tiki())]
|
||||
#[pezpallet::call_index(4)]
|
||||
#[pezpallet::weight(<T as crate::pezpallet::Config>::WeightInfo::grant_tiki())]
|
||||
pub fn grant_earned_role(
|
||||
origin: OriginFor<T>,
|
||||
dest: <T::Lookup as StaticLookup>::Source,
|
||||
tiki: Tiki,
|
||||
) -> DispatchResult {
|
||||
T::AdminOrigin::ensure_origin(origin)?; // For now admin, later exam pallet
|
||||
T::AdminOrigin::ensure_origin(origin)?; // For now admin, later exam pezpallet
|
||||
let dest_account = T::Lookup::lookup(dest)?;
|
||||
|
||||
// Check if the role can be earned
|
||||
@@ -428,13 +428,13 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
/// Apply for citizenship after KYC completion
|
||||
#[pallet::call_index(5)]
|
||||
#[pallet::weight(<T as crate::pallet::Config>::WeightInfo::grant_tiki())]
|
||||
#[pezpallet::call_index(5)]
|
||||
#[pezpallet::weight(<T as crate::pezpallet::Config>::WeightInfo::grant_tiki())]
|
||||
pub fn apply_for_citizenship(origin: OriginFor<T>) -> DispatchResult {
|
||||
let who = ensure_signed(origin)?;
|
||||
|
||||
// Check if user's KYC is approved
|
||||
let kyc_status = pezpallet_identity_kyc::Pallet::<T>::kyc_status_of(&who);
|
||||
let kyc_status = pezpallet_identity_kyc::Pezpallet::<T>::kyc_status_of(&who);
|
||||
ensure!(
|
||||
kyc_status == pezpallet_identity_kyc::types::KycLevel::Approved,
|
||||
Error::<T>::KycNotCompleted
|
||||
@@ -447,8 +447,8 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
/// Check NFT transfer for transfer blocking system
|
||||
#[pallet::call_index(6)]
|
||||
#[pallet::weight(<T as crate::pallet::Config>::WeightInfo::grant_tiki())]
|
||||
#[pezpallet::call_index(6)]
|
||||
#[pezpallet::weight(<T as crate::pezpallet::Config>::WeightInfo::grant_tiki())]
|
||||
pub fn check_transfer_permission(
|
||||
_origin: OriginFor<T>,
|
||||
collection_id: T::CollectionId,
|
||||
@@ -465,11 +465,11 @@ pub mod pallet {
|
||||
}
|
||||
}
|
||||
|
||||
// Pallet's helper functions
|
||||
impl<T: Config> Pallet<T> {
|
||||
// Pezpallet's helper functions
|
||||
impl<T: Config> Pezpallet<T> {
|
||||
/// Checks newly KYC-completed users and mints citizenship NFT
|
||||
fn check_and_mint_citizen_nfts() {
|
||||
// Check all approved users in KYC pallet
|
||||
// Check all approved users in KYC pezpallet
|
||||
for (account, kyc_status) in pezpallet_identity_kyc::KycStatuses::<T>::iter() {
|
||||
// Check if KYC is approved
|
||||
if kyc_status == pezpallet_identity_kyc::types::KycLevel::Approved {
|
||||
@@ -494,7 +494,7 @@ pub mod pallet {
|
||||
|
||||
// Mint the NFT - use force_mint in benchmarks to bypass balance/origin requirements
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
pezpallet_nfts::Pallet::<T>::force_mint(
|
||||
pezpallet_nfts::Pezpallet::<T>::force_mint(
|
||||
T::RuntimeOrigin::from(pezframe_system::RawOrigin::Root),
|
||||
collection_id,
|
||||
next_id_u32,
|
||||
@@ -503,7 +503,7 @@ pub mod pallet {
|
||||
)?;
|
||||
|
||||
#[cfg(not(feature = "runtime-benchmarks"))]
|
||||
pezpallet_nfts::Pallet::<T>::force_mint(
|
||||
pezpallet_nfts::Pezpallet::<T>::force_mint(
|
||||
T::RuntimeOrigin::from(pezframe_system::RawOrigin::Root),
|
||||
collection_id,
|
||||
next_id_u32,
|
||||
@@ -595,12 +595,12 @@ pub mod pallet {
|
||||
// Mark NFT with lock attribute - use force_set_attribute in benchmarks to bypass
|
||||
// deposits
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
let _ = pezpallet_nfts::Pallet::<T>::force_set_attribute(
|
||||
let _ = pezpallet_nfts::Pezpallet::<T>::force_set_attribute(
|
||||
T::RuntimeOrigin::from(pezframe_system::RawOrigin::Root),
|
||||
None,
|
||||
*collection_id,
|
||||
Some(*item_id),
|
||||
pezpallet_nfts::AttributeNamespace::Pallet,
|
||||
pezpallet_nfts::AttributeNamespace::Pezpallet,
|
||||
b"locked"
|
||||
.to_vec()
|
||||
.try_into()
|
||||
@@ -612,11 +612,11 @@ pub mod pallet {
|
||||
);
|
||||
|
||||
#[cfg(not(feature = "runtime-benchmarks"))]
|
||||
let _ = pezpallet_nfts::Pallet::<T>::set_attribute(
|
||||
let _ = pezpallet_nfts::Pezpallet::<T>::set_attribute(
|
||||
T::RuntimeOrigin::from(pezframe_system::RawOrigin::Root),
|
||||
*collection_id,
|
||||
Some(*item_id),
|
||||
pezpallet_nfts::AttributeNamespace::Pallet,
|
||||
pezpallet_nfts::AttributeNamespace::Pezpallet,
|
||||
b"locked"
|
||||
.to_vec()
|
||||
.try_into()
|
||||
@@ -646,7 +646,7 @@ pub mod pallet {
|
||||
);
|
||||
|
||||
// Set metadata - log error but don't crash
|
||||
if pezpallet_nfts::Pallet::<T>::set_metadata(
|
||||
if pezpallet_nfts::Pezpallet::<T>::set_metadata(
|
||||
T::RuntimeOrigin::from(pezframe_system::RawOrigin::Root),
|
||||
collection_id,
|
||||
nft_id_u32,
|
||||
@@ -710,7 +710,7 @@ pub mod pallet {
|
||||
/// KYC sonrası otomatik Welati rolü verme
|
||||
pub fn auto_grant_citizenship(account: &T::AccountId) -> DispatchResult {
|
||||
// KYC kontrolü
|
||||
let kyc_status = pezpallet_identity_kyc::Pallet::<T>::kyc_status_of(account);
|
||||
let kyc_status = pezpallet_identity_kyc::Pezpallet::<T>::kyc_status_of(account);
|
||||
if kyc_status == pezpallet_identity_kyc::types::KycLevel::Approved {
|
||||
// Vatandaşlık NFT'si yoksa bas
|
||||
if Self::citizen_nft(account).is_none() {
|
||||
@@ -745,14 +745,14 @@ pub trait TikiProvider<AccountId> {
|
||||
}
|
||||
|
||||
/// Trait implementasyonları
|
||||
impl<T: Config> TikiScoreProvider<T::AccountId> for Pallet<T> {
|
||||
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).sum()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Config> TikiProvider<T::AccountId> for Pallet<T> {
|
||||
impl<T: Config> TikiProvider<T::AccountId> for Pezpallet<T> {
|
||||
fn has_tiki(who: &T::AccountId, tiki: &Tiki) -> bool {
|
||||
Self::has_tiki(who, tiki)
|
||||
}
|
||||
@@ -767,7 +767,7 @@ impl<T: Config> TikiProvider<T::AccountId> for Pallet<T> {
|
||||
}
|
||||
|
||||
// Puanlama mantığını ayrı bir impl bloğunda tutarak kodu daha düzenli hale getiriyoruz.
|
||||
impl<T: Config> Pallet<T> {
|
||||
impl<T: Config> Pezpallet<T> {
|
||||
/// Belirli bir Tiki'nin Trust Puanı'na olan katkısını döndürür.
|
||||
pub fn get_bonus_for_tiki(tiki: &Tiki) -> u32 {
|
||||
match tiki {
|
||||
@@ -833,7 +833,7 @@ impl<T: Config> Pallet<T> {
|
||||
}
|
||||
}
|
||||
// CitizenNftProvider trait implementation for pezpallet-identity-kyc integration
|
||||
impl<T: Config> pezpallet_identity_kyc::types::CitizenNftProvider<T::AccountId> for Pallet<T> {
|
||||
impl<T: Config> pezpallet_identity_kyc::types::CitizenNftProvider<T::AccountId> for Pezpallet<T> {
|
||||
fn mint_citizen_nft(who: &T::AccountId) -> pezsp_runtime::DispatchResult {
|
||||
Self::mint_citizen_nft_for_user(who)
|
||||
}
|
||||
@@ -850,7 +850,7 @@ impl<T: Config> pezpallet_identity_kyc::types::CitizenNftProvider<T::AccountId>
|
||||
let collection_id = T::TikiCollectionId::get();
|
||||
|
||||
// Burn the NFT using pezpallet_nfts burn function
|
||||
pezpallet_nfts::Pallet::<T>::burn(
|
||||
pezpallet_nfts::Pezpallet::<T>::burn(
|
||||
T::RuntimeOrigin::from(pezframe_system::RawOrigin::Signed(who.clone())),
|
||||
collection_id,
|
||||
item_id,
|
||||
|
||||
@@ -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-tiki from {:?} to {:?}",
|
||||
@@ -41,7 +41,7 @@ pub mod v1 {
|
||||
// }
|
||||
|
||||
// Update storage version
|
||||
STORAGE_VERSION.put::<Pallet<T>>();
|
||||
STORAGE_VERSION.put::<Pezpallet<T>>();
|
||||
|
||||
log::info!("✅ Migrated {} entries in pezpallet-tiki", migrated);
|
||||
|
||||
@@ -62,7 +62,7 @@ pub mod v1 {
|
||||
fn pre_upgrade() -> Result<pezsp_std::vec::Vec<u8>, pezsp_runtime::TryRuntimeError> {
|
||||
use codec::Encode;
|
||||
|
||||
let current = Pallet::<T>::on_chain_storage_version();
|
||||
let current = Pezpallet::<T>::on_chain_storage_version();
|
||||
|
||||
log::info!("🔍 Pre-upgrade check for pezpallet-tiki");
|
||||
log::info!(" Current version: {:?}", current);
|
||||
@@ -89,7 +89,7 @@ pub mod v1 {
|
||||
log::info!("🔍 Post-upgrade check for pezpallet-tiki");
|
||||
|
||||
// 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);
|
||||
|
||||
@@ -139,7 +139,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-tiki to v2");
|
||||
@@ -151,7 +151,7 @@ pub mod v2 {
|
||||
// 4. Update version
|
||||
|
||||
// For now, this is just a template
|
||||
STORAGE_VERSION.put::<Pallet<T>>();
|
||||
STORAGE_VERSION.put::<Pezpallet<T>>();
|
||||
|
||||
log::info!("✅ Completed migration to pezpallet-tiki v2");
|
||||
|
||||
@@ -174,13 +174,13 @@ mod tests {
|
||||
fn test_migration_v1() {
|
||||
new_test_ext().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());
|
||||
@@ -191,7 +191,7 @@ mod tests {
|
||||
fn test_migration_idempotent() {
|
||||
new_test_ext().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();
|
||||
|
||||
@@ -14,16 +14,16 @@ type Block = pezframe_system::mocking::MockBlock<Test>;
|
||||
pub type AccountId = u64;
|
||||
pub type Balance = u128;
|
||||
|
||||
// Runtime'ı oluştur - Identity ve IdentityKyc pallet'lerini de ekle
|
||||
// Runtime'ı oluştur - Identity ve IdentityKyc pezpallet'lerini de ekle
|
||||
construct_runtime!(
|
||||
pub enum Test
|
||||
{
|
||||
System: pezframe_system::{Pallet, Call, Config<T>, Storage, Event<T>},
|
||||
Balances: pezpallet_balances::{Pallet, Call, Storage, Event<T>},
|
||||
Identity: pezpallet_identity::{Pallet, Call, Storage, Event<T>},
|
||||
IdentityKyc: pezpallet_identity_kyc::{Pallet, Call, Storage, Event<T>},
|
||||
Nfts: pezpallet_nfts::{Pallet, Call, Storage, Event<T>},
|
||||
Tiki: pezpallet_tiki::{Pallet, Call, Storage, Event<T>},
|
||||
System: pezframe_system::{Pezpallet, Call, Config<T>, Storage, Event<T>},
|
||||
Balances: pezpallet_balances::{Pezpallet, Call, Storage, Event<T>},
|
||||
Identity: pezpallet_identity::{Pezpallet, Call, Storage, Event<T>},
|
||||
IdentityKyc: pezpallet_identity_kyc::{Pezpallet, Call, Storage, Event<T>},
|
||||
Nfts: pezpallet_nfts::{Pezpallet, Call, Storage, Event<T>},
|
||||
Tiki: pezpallet_tiki::{Pezpallet, Call, Storage, Event<T>},
|
||||
}
|
||||
);
|
||||
|
||||
@@ -249,7 +249,7 @@ pub fn advance_blocks(blocks: u64) {
|
||||
let current_block = System::block_number();
|
||||
System::set_block_number(current_block + 1);
|
||||
// Trigger hooks for the new block
|
||||
<pezpallet_tiki::Pallet<Test> as pezframe_support::traits::Hooks<u64>>::on_initialize(
|
||||
<pezpallet_tiki::Pezpallet<Test> as pezframe_support::traits::Hooks<u64>>::on_initialize(
|
||||
current_block + 1,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ use crate::{
|
||||
use pezframe_support::{assert_noop, assert_ok};
|
||||
use pezsp_runtime::DispatchError;
|
||||
|
||||
type TikiPallet = crate::Pallet<Test>;
|
||||
type TikiPallet = crate::Pezpallet<Test>;
|
||||
|
||||
// === Temel NFT ve Rol Testleri ===
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
use super::*;
|
||||
#[allow(unused)]
|
||||
use crate::Pallet as TokenWrapper;
|
||||
use crate::Pezpallet as TokenWrapper;
|
||||
use pezframe_benchmarking::v2::*;
|
||||
use pezframe_support::traits::Currency;
|
||||
use pezframe_system::RawOrigin;
|
||||
@@ -16,10 +16,10 @@ mod benchmarks {
|
||||
#[benchmark]
|
||||
fn wrap() {
|
||||
let caller: T::AccountId = whitelisted_caller();
|
||||
let pezpallet_account = Pallet::<T>::account_id();
|
||||
let pezpallet_account = Pezpallet::<T>::account_id();
|
||||
let amount = 10_000u32.into();
|
||||
|
||||
// Fund both caller and pallet account
|
||||
// Fund both caller and pezpallet account
|
||||
let funding = <T::Currency as Currency<T::AccountId>>::minimum_balance()
|
||||
.saturating_mul(1000u32.into());
|
||||
|
||||
@@ -40,7 +40,7 @@ mod benchmarks {
|
||||
#[benchmark]
|
||||
fn unwrap() {
|
||||
let caller: T::AccountId = whitelisted_caller();
|
||||
let pezpallet_account = Pallet::<T>::account_id();
|
||||
let pezpallet_account = Pezpallet::<T>::account_id();
|
||||
let amount = 10_000u32.into();
|
||||
|
||||
// Fund both accounts
|
||||
@@ -55,7 +55,7 @@ mod benchmarks {
|
||||
T::Assets::create(T::WrapperAssetId::get(), pezpallet_account.clone(), true, 1u32.into());
|
||||
|
||||
// Wrap first
|
||||
let _ = Pallet::<T>::wrap(RawOrigin::Signed(caller.clone()).into(), amount);
|
||||
let _ = Pezpallet::<T>::wrap(RawOrigin::Signed(caller.clone()).into(), amount);
|
||||
|
||||
#[extrinsic_call]
|
||||
_(RawOrigin::Signed(caller.clone()), amount);
|
||||
@@ -64,5 +64,5 @@ mod benchmarks {
|
||||
assert_eq!(T::Assets::balance(T::WrapperAssetId::get(), &caller), 0u32.into());
|
||||
}
|
||||
|
||||
impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(), crate::mock::Test);
|
||||
impl_benchmark_test_suite!(Pezpallet, crate::mock::new_test_ext(), crate::mock::Test);
|
||||
}
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
//! # Token Wrapper Pallet
|
||||
//! # Token Wrapper Pezpallet
|
||||
//!
|
||||
//! A pallet for wrapping native tokens (HEZ) into fungible assets (wHEZ)
|
||||
//! A pezpallet for wrapping native tokens (HEZ) into fungible assets (wHEZ)
|
||||
//! to enable DEX operations between native and asset tokens.
|
||||
//!
|
||||
//! ## Overview
|
||||
//!
|
||||
//! This pallet provides:
|
||||
//! This pezpallet provides:
|
||||
//! - `wrap`: Convert native HEZ to wHEZ (Asset ID 0)
|
||||
//! - `unwrap`: Convert wHEZ back to native HEZ
|
||||
//!
|
||||
//! The pallet maintains a 1:1 backing between HEZ and wHEZ.
|
||||
//! The pezpallet maintains a 1:1 backing between HEZ and wHEZ.
|
||||
|
||||
pub use pallet::*;
|
||||
pub use pezpallet::*;
|
||||
pub use weights::WeightInfo;
|
||||
pub mod weights;
|
||||
|
||||
@@ -36,19 +36,19 @@ use pezframe_support::{
|
||||
use pezframe_system::pezpallet_prelude::*;
|
||||
use pezsp_runtime::traits::{AccountIdConversion, Saturating, Zero};
|
||||
|
||||
#[pezframe_support::pallet]
|
||||
pub mod pallet {
|
||||
#[pezframe_support::pezpallet]
|
||||
pub mod pezpallet {
|
||||
use super::*;
|
||||
|
||||
type BalanceOf<T> =
|
||||
<<T as Config>::Currency as Currency<<T as pezframe_system::Config>::AccountId>>::Balance;
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T>(_);
|
||||
#[pezpallet::pezpallet]
|
||||
pub struct Pezpallet<T>(_);
|
||||
|
||||
#[pallet::config]
|
||||
#[pezpallet::config]
|
||||
pub trait Config: pezframe_system::Config {
|
||||
/// Weight information for extrinsics in this pallet.
|
||||
/// Weight information for extrinsics in this pezpallet.
|
||||
type WeightInfo: crate::WeightInfo;
|
||||
|
||||
/// Native currency (HEZ)
|
||||
@@ -62,12 +62,12 @@ pub mod pallet {
|
||||
+ Mutate<Self::AccountId>
|
||||
+ Create<Self::AccountId>;
|
||||
|
||||
/// Pallet ID for the wrapper account
|
||||
#[pallet::constant]
|
||||
/// Pezpallet ID for the wrapper account
|
||||
#[pezpallet::constant]
|
||||
type PalletId: Get<PalletId>;
|
||||
|
||||
/// Asset ID for wrapped token (wHEZ)
|
||||
#[pallet::constant]
|
||||
#[pezpallet::constant]
|
||||
type WrapperAssetId: Get<Self::AssetId>;
|
||||
}
|
||||
|
||||
@@ -76,16 +76,16 @@ pub mod pallet {
|
||||
// ============================================================================
|
||||
|
||||
/// Total amount of native tokens locked in wrapper
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn total_locked)]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::getter(fn total_locked)]
|
||||
pub type TotalLocked<T: Config> = StorageValue<_, BalanceOf<T>, ValueQuery>;
|
||||
|
||||
// ============================================================================
|
||||
// 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> {
|
||||
/// Native token wrapped into asset token. [who, amount]
|
||||
Wrapped { who: T::AccountId, amount: BalanceOf<T> },
|
||||
@@ -97,7 +97,7 @@ pub mod pallet {
|
||||
// ERRORS
|
||||
// ============================================================================
|
||||
|
||||
#[pallet::error]
|
||||
#[pezpallet::error]
|
||||
pub enum Error<T> {
|
||||
/// Insufficient balance for wrapping
|
||||
InsufficientBalance,
|
||||
@@ -117,22 +117,22 @@ pub mod pallet {
|
||||
// DISPATCHABLE FUNCTIONS
|
||||
// ============================================================================
|
||||
|
||||
#[pallet::call]
|
||||
impl<T: Config> Pallet<T> {
|
||||
#[pezpallet::call]
|
||||
impl<T: Config> Pezpallet<T> {
|
||||
/// Wrap native tokens (HEZ) into wrapped asset tokens (wHEZ)
|
||||
///
|
||||
/// - `amount`: The amount of native tokens to wrap
|
||||
///
|
||||
/// This will:
|
||||
/// 1. Transfer native tokens from user to pallet account (lock)
|
||||
/// 1. Transfer native tokens from user to pezpallet account (lock)
|
||||
/// 2. Mint equivalent amount of wrapped tokens to user
|
||||
///
|
||||
/// Emits `Wrapped` event.
|
||||
#[pallet::call_index(0)]
|
||||
#[pallet::weight(T::WeightInfo::wrap())]
|
||||
#[pezpallet::call_index(0)]
|
||||
#[pezpallet::weight(T::WeightInfo::wrap())]
|
||||
pub fn wrap(
|
||||
origin: OriginFor<T>,
|
||||
#[pallet::compact] amount: BalanceOf<T>,
|
||||
#[pezpallet::compact] amount: BalanceOf<T>,
|
||||
) -> DispatchResult {
|
||||
let who = ensure_signed(origin)?;
|
||||
|
||||
@@ -142,7 +142,7 @@ pub mod pallet {
|
||||
// Check balance
|
||||
ensure!(T::Currency::free_balance(&who) >= amount, Error::<T>::InsufficientBalance);
|
||||
|
||||
// Transfer native tokens to pallet account (lock them)
|
||||
// Transfer native tokens to pezpallet account (lock them)
|
||||
T::Currency::transfer(
|
||||
&who,
|
||||
&Self::account_id(),
|
||||
@@ -173,11 +173,11 @@ pub mod pallet {
|
||||
/// 2. Transfer equivalent native tokens back to user (unlock)
|
||||
///
|
||||
/// Emits `Unwrapped` event.
|
||||
#[pallet::call_index(1)]
|
||||
#[pallet::weight(T::WeightInfo::unwrap())]
|
||||
#[pezpallet::call_index(1)]
|
||||
#[pezpallet::weight(T::WeightInfo::unwrap())]
|
||||
pub fn unwrap(
|
||||
origin: OriginFor<T>,
|
||||
#[pallet::compact] amount: BalanceOf<T>,
|
||||
#[pezpallet::compact] amount: BalanceOf<T>,
|
||||
) -> DispatchResult {
|
||||
let who = ensure_signed(origin)?;
|
||||
|
||||
@@ -222,8 +222,8 @@ pub mod pallet {
|
||||
// HELPER FUNCTIONS
|
||||
// ============================================================================
|
||||
|
||||
impl<T: Config> Pallet<T> {
|
||||
/// Get the account ID of the pallet
|
||||
impl<T: Config> Pezpallet<T> {
|
||||
/// Get the account ID of the pezpallet
|
||||
pub fn account_id() -> T::AccountId {
|
||||
T::PalletId::get().into_account_truncating()
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ pub type AccountId = u64;
|
||||
pub type Balance = u128;
|
||||
pub type AssetId = u32;
|
||||
|
||||
// Configure a mock runtime to test the pallet.
|
||||
// Configure a mock runtime to test the pezpallet.
|
||||
construct_runtime!(
|
||||
pub enum Test {
|
||||
System: pezframe_system,
|
||||
@@ -149,7 +149,7 @@ pub fn new_test_ext() -> pezsp_io::TestExternalities {
|
||||
assert_ok!(Assets::force_create(
|
||||
RuntimeOrigin::root(),
|
||||
0, // Asset ID
|
||||
TokenWrapper::account_id(), // Owner = pallet account
|
||||
TokenWrapper::account_id(), // Owner = pezpallet account
|
||||
true, // is_sufficient
|
||||
1, // min_balance
|
||||
));
|
||||
|
||||
@@ -220,11 +220,11 @@ fn pezpallet_account_balance_consistency() {
|
||||
|
||||
let initial_pallet_balance = Balances::free_balance(&pezpallet_account);
|
||||
|
||||
// Wrap - pallet account should receive native tokens
|
||||
// Wrap - pezpallet account should receive native tokens
|
||||
assert_ok!(TokenWrapper::wrap(RuntimeOrigin::signed(user), amount));
|
||||
assert_eq!(Balances::free_balance(&pezpallet_account), initial_pallet_balance + amount);
|
||||
|
||||
// Unwrap - pallet account should release native tokens
|
||||
// Unwrap - pezpallet account should release native tokens
|
||||
assert_ok!(TokenWrapper::unwrap(RuntimeOrigin::signed(user), amount));
|
||||
assert_eq!(Balances::free_balance(&pezpallet_account), initial_pallet_balance);
|
||||
});
|
||||
@@ -245,7 +245,7 @@ fn wrap_unwrap_maintains_1_to_1_backing() {
|
||||
let pezpallet_account = TokenWrapper::account_id();
|
||||
let pezpallet_balance = Balances::free_balance(&pezpallet_account);
|
||||
|
||||
// Pallet should hold exactly the amount of wrapped tokens
|
||||
// Pezpallet should hold exactly the amount of wrapped tokens
|
||||
// (Note: may include existential deposit, so check >= total_wrapped)
|
||||
assert!(pezpallet_balance >= total_wrapped);
|
||||
assert_eq!(TokenWrapper::total_locked(), total_wrapped);
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
// ./target/release/frame-omni-bencher
|
||||
// v1
|
||||
// benchmark
|
||||
// pallet
|
||||
// pezpallet
|
||||
// --runtime
|
||||
// target/release/wbuild/asset-hub-pezkuwichain-runtime/asset_hub_pezkuwichain_runtime.compact.compressed.wasm
|
||||
// --pallets
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#![cfg(feature = "runtime-benchmarks")]
|
||||
|
||||
use super::*;
|
||||
use crate::Pallet as TrustPallet;
|
||||
use crate::Pezpallet as TrustPallet;
|
||||
|
||||
use pezframe_benchmarking::{v2::*, whitelisted_caller};
|
||||
use pezframe_support::pezpallet_prelude::*;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
//! # Trust Score Pallet
|
||||
//! # Trust Score Pezpallet
|
||||
//!
|
||||
//! A pallet for calculating and managing composite trust scores based on multiple ecosystem
|
||||
//! A pezpallet for calculating and managing composite trust scores based on multiple ecosystem
|
||||
//! metrics.
|
||||
//!
|
||||
//! ## Overview
|
||||
//!
|
||||
//! The Trust Score pallet aggregates multiple reputation and activity metrics to produce
|
||||
//! The Trust Score pezpallet aggregates multiple reputation and activity metrics to produce
|
||||
//! a unified trust score for each citizen. This score is used throughout the ecosystem for:
|
||||
//!
|
||||
//! - Validator pool eligibility (trust-based validators)
|
||||
@@ -68,7 +68,7 @@
|
||||
//!
|
||||
//! ## Dependencies
|
||||
//!
|
||||
//! This pallet requires integration with:
|
||||
//! This pezpallet requires integration with:
|
||||
//! - `pezpallet-identity-kyc` - Citizenship status verification
|
||||
//! - `pezpallet-staking-score` - Staking metrics provider
|
||||
//! - `pezpallet-referral` - Referral score provider
|
||||
@@ -92,7 +92,7 @@
|
||||
//! }
|
||||
//! ```
|
||||
|
||||
pub use pallet::*;
|
||||
pub use pezpallet::*;
|
||||
|
||||
pub mod weights;
|
||||
|
||||
@@ -122,7 +122,7 @@ pub trait ReferralScoreProvider<AccountId> {
|
||||
fn get_referral_score(who: &AccountId) -> u32;
|
||||
}
|
||||
|
||||
// Re-export from identity-kyc pallet
|
||||
// Re-export from identity-kyc pezpallet
|
||||
pub use pezpallet_identity_kyc::CitizenshipStatusProvider;
|
||||
|
||||
pub trait TrustScoreUpdater<AccountId> {
|
||||
@@ -141,17 +141,17 @@ pub trait TikiScoreProvider<AccountId> {
|
||||
fn get_tiki_score(who: &AccountId) -> u32;
|
||||
}
|
||||
|
||||
#[pezframe_support::pallet]
|
||||
pub mod pallet {
|
||||
#[pezframe_support::pezpallet]
|
||||
pub mod pezpallet {
|
||||
use super::{weights::WeightInfo, *};
|
||||
use pezframe_support::pezpallet_prelude::*;
|
||||
use pezframe_system::pezpallet_prelude::*;
|
||||
use pezsp_runtime::traits::{Saturating, Zero};
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T>(_);
|
||||
#[pezpallet::pezpallet]
|
||||
pub struct Pezpallet<T>(_);
|
||||
|
||||
#[pallet::config]
|
||||
#[pezpallet::config]
|
||||
pub trait Config: pezframe_system::Config + pezpallet_identity_kyc::Config {
|
||||
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
|
||||
type WeightInfo: WeightInfo;
|
||||
@@ -168,16 +168,16 @@ pub mod pallet {
|
||||
+ Into<u128>
|
||||
+ TryFrom<u128>;
|
||||
|
||||
#[pallet::constant]
|
||||
#[pezpallet::constant]
|
||||
type ScoreMultiplierBase: Get<u128>;
|
||||
|
||||
/// Block interval for Trust score updates (e.g. daily)
|
||||
#[pallet::constant]
|
||||
#[pezpallet::constant]
|
||||
type UpdateInterval: Get<BlockNumberFor<Self>>;
|
||||
|
||||
/// Maximum number of accounts to process per batch update
|
||||
/// Prevents DoS by limiting computation per extrinsic call
|
||||
#[pallet::constant]
|
||||
#[pezpallet::constant]
|
||||
type MaxBatchSize: Get<u32>;
|
||||
|
||||
type StakingScoreSource: StakingScoreProvider<Self::AccountId, BlockNumberFor<Self>>;
|
||||
@@ -187,23 +187,23 @@ pub mod pallet {
|
||||
type CitizenshipSource: CitizenshipStatusProvider<Self::AccountId>;
|
||||
}
|
||||
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn trust_score_of)]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::getter(fn trust_score_of)]
|
||||
pub type TrustScores<T: Config> =
|
||||
StorageMap<_, Blake2_128Concat, T::AccountId, T::Score, ValueQuery>;
|
||||
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn total_active_trust_score)]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::getter(fn total_active_trust_score)]
|
||||
pub type TotalActiveTrustScore<T: Config> = StorageValue<_, T::Score, ValueQuery>;
|
||||
|
||||
#[pallet::storage]
|
||||
#[pezpallet::storage]
|
||||
pub type LastProcessedAccount<T: Config> = StorageValue<_, T::AccountId, OptionQuery>;
|
||||
|
||||
#[pallet::storage]
|
||||
#[pezpallet::storage]
|
||||
pub type BatchUpdateInProgress<T: Config> = StorageValue<_, bool, ValueQuery>;
|
||||
|
||||
#[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> {
|
||||
/// A user's Trust Score was successfully updated.
|
||||
TrustScoreUpdated { who: T::AccountId, old_score: T::Score, new_score: T::Score },
|
||||
@@ -217,7 +217,7 @@ pub mod pallet {
|
||||
PeriodicUpdateScheduled { next_block: BlockNumberFor<T> },
|
||||
}
|
||||
|
||||
#[pallet::error]
|
||||
#[pezpallet::error]
|
||||
#[derive(PartialEq)]
|
||||
pub enum Error<T> {
|
||||
CalculationOverflow,
|
||||
@@ -225,7 +225,7 @@ pub mod pallet {
|
||||
UpdateInProgress,
|
||||
}
|
||||
|
||||
#[pallet::genesis_config]
|
||||
#[pezpallet::genesis_config]
|
||||
#[derive(pezframe_support::DefaultNoBound)]
|
||||
pub struct GenesisConfig<T: Config> {
|
||||
pub start_periodic_updates: bool,
|
||||
@@ -233,13 +233,13 @@ pub mod pallet {
|
||||
pub _phantom: core::marker::PhantomData<T>,
|
||||
}
|
||||
|
||||
#[pallet::genesis_build]
|
||||
#[pezpallet::genesis_build]
|
||||
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
|
||||
fn build(&self) {
|
||||
if self.start_periodic_updates {
|
||||
// Schedule first periodic update for 1 day later
|
||||
let _first_update_block =
|
||||
pezframe_system::Pallet::<T>::block_number() + T::UpdateInterval::get();
|
||||
pezframe_system::Pezpallet::<T>::block_number() + T::UpdateInterval::get();
|
||||
|
||||
// Note: Scheduler may not be available during Genesis build
|
||||
// In this case, manual start required or scheduled in runtime
|
||||
@@ -248,11 +248,11 @@ pub mod pallet {
|
||||
}
|
||||
}
|
||||
|
||||
#[pallet::call]
|
||||
impl<T: Config> Pallet<T> {
|
||||
#[pezpallet::call]
|
||||
impl<T: Config> Pezpallet<T> {
|
||||
/// To manually recalculate a specific user's Trust Score.
|
||||
#[pallet::call_index(0)]
|
||||
#[pallet::weight(<T as Config>::WeightInfo::force_recalculate_trust_score())]
|
||||
#[pezpallet::call_index(0)]
|
||||
#[pezpallet::weight(<T as Config>::WeightInfo::force_recalculate_trust_score())]
|
||||
pub fn force_recalculate_trust_score(
|
||||
origin: OriginFor<T>,
|
||||
who: T::AccountId,
|
||||
@@ -265,8 +265,8 @@ pub mod pallet {
|
||||
/// Updates Trust Scores of all citizens in bulk
|
||||
/// Works in batches for large user base using efficient pagination
|
||||
/// UPDATED (Gemini suggestion): Uses iter_from for true O(1) resume
|
||||
#[pallet::call_index(1)]
|
||||
#[pallet::weight(<T as Config>::WeightInfo::update_all_trust_scores())]
|
||||
#[pezpallet::call_index(1)]
|
||||
#[pezpallet::weight(<T as Config>::WeightInfo::update_all_trust_scores())]
|
||||
pub fn update_all_trust_scores(origin: OriginFor<T>) -> DispatchResult {
|
||||
ensure_root(origin)?;
|
||||
|
||||
@@ -327,8 +327,8 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
/// Periyodik güncellemeyi başlatan function
|
||||
#[pallet::call_index(2)]
|
||||
#[pallet::weight(<T as Config>::WeightInfo::periodic_trust_score_update())]
|
||||
#[pezpallet::call_index(2)]
|
||||
#[pezpallet::weight(<T as Config>::WeightInfo::periodic_trust_score_update())]
|
||||
pub fn periodic_trust_score_update(origin: OriginFor<T>) -> DispatchResult {
|
||||
ensure_root(origin)?;
|
||||
|
||||
@@ -339,7 +339,7 @@ pub mod pallet {
|
||||
Self::update_all_trust_scores(OriginFor::<T>::root())?;
|
||||
|
||||
// Bir sonraki periyodik güncellemeyi schedule et
|
||||
let current_block = pezframe_system::Pallet::<T>::block_number();
|
||||
let current_block = pezframe_system::Pezpallet::<T>::block_number();
|
||||
let next_update_block = current_block + T::UpdateInterval::get();
|
||||
|
||||
Self::deposit_event(Event::PeriodicUpdateScheduled { next_block: next_update_block });
|
||||
@@ -348,7 +348,7 @@ pub mod pallet {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Config> Pallet<T> {
|
||||
impl<T: Config> Pezpallet<T> {
|
||||
pub fn calculate_trust_score(who: &T::AccountId) -> Result<T::Score, Error<T>> {
|
||||
ensure!(T::CitizenshipSource::is_citizen(who), Error::<T>::NotACitizen);
|
||||
|
||||
@@ -407,13 +407,13 @@ pub mod pallet {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Config> TrustScoreProvider<T::AccountId> for Pallet<T> {
|
||||
impl<T: Config> TrustScoreProvider<T::AccountId> for Pezpallet<T> {
|
||||
fn trust_score_of(who: &T::AccountId) -> u128 {
|
||||
Self::trust_score_of(who).into()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Config> TrustScoreUpdater<T::AccountId> for Pallet<T> {
|
||||
impl<T: Config> TrustScoreUpdater<T::AccountId> for Pezpallet<T> {
|
||||
fn on_score_component_changed(who: &T::AccountId) {
|
||||
if let Err(e) = Self::update_score_for_account(who) {
|
||||
log::error!("Failed to update trust score for {:?}: {:?}", who, e);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user