fix: Complete snowbridge pezpallet rebrand and critical bug fixes

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

Verified: pezsnowbridge-pezpallet-*, pezpallet-staking,
pezpallet-staking-async, pezframe-benchmarking-cli all pass cargo check
This commit is contained in:
2025-12-16 09:57:23 +03:00
parent eea003e14d
commit 3139ffa25e
3022 changed files with 42157 additions and 23579 deletions
+18 -18
View File
@@ -35,7 +35,7 @@ use xcm_executor::traits::ConvertLocation;
pub type AccountIdOf<T> = <T as pezframe_system::Config>::AccountId;
/// Type alias to conveniently refer to the `Currency::NegativeImbalance` associated type.
pub type NegativeImbalance<T> = <pezpallet_balances::Pallet<T> as Currency<
pub type NegativeImbalance<T> = <pezpallet_balances::Pezpallet<T> as Currency<
<T as pezframe_system::Config>::AccountId,
>>::NegativeImbalance;
@@ -52,16 +52,16 @@ where
<R as pezframe_system::Config>::RuntimeEvent: From<pezpallet_balances::Event<R>>,
{
fn on_nonzero_unbalanced(amount: NegativeImbalance<R>) {
let staking_pot = <pezpallet_collator_selection::Pallet<R>>::account_id();
let staking_pot = <pezpallet_collator_selection::Pezpallet<R>>::account_id();
// In case of error: Will drop the result triggering the `OnDrop` of the imbalance.
<pezpallet_balances::Pallet<R>>::resolve_creating(&staking_pot, amount);
<pezpallet_balances::Pezpallet<R>>::resolve_creating(&staking_pot, amount);
}
}
/// Fungible implementation of `OnUnbalanced` that deals with the fees by combining tip and fee and
/// passing the result on to `ToStakingPot`.
pub struct DealWithFees<R>(PhantomData<R>);
impl<R> OnUnbalanced<fungible::Credit<R::AccountId, pezpallet_balances::Pallet<R>>> for DealWithFees<R>
impl<R> OnUnbalanced<fungible::Credit<R::AccountId, pezpallet_balances::Pezpallet<R>>> for DealWithFees<R>
where
R: pezpallet_balances::Config + pezpallet_collator_selection::Config,
AccountIdOf<R>: From<pezkuwi_primitives::AccountId> + Into<pezkuwi_primitives::AccountId>,
@@ -69,14 +69,14 @@ where
{
fn on_unbalanceds(
mut fees_then_tips: impl Iterator<
Item = fungible::Credit<R::AccountId, pezpallet_balances::Pallet<R>>,
Item = fungible::Credit<R::AccountId, pezpallet_balances::Pezpallet<R>>,
>,
) {
if let Some(mut fees) = fees_then_tips.next() {
if let Some(tips) = fees_then_tips.next() {
tips.merge_into(&mut fees);
}
ResolveTo::<StakingPotAccountId<R>, pezpallet_balances::Pallet<R>>::on_unbalanced(fees)
ResolveTo::<StakingPotAccountId<R>, pezpallet_balances::Pezpallet<R>>::on_unbalanced(fees)
}
}
}
@@ -84,17 +84,17 @@ where
/// A `HandleCredit` implementation that naively transfers the fees to the block author.
/// Will drop and burn the assets in case the transfer fails.
pub struct AssetsToBlockAuthor<R, I>(PhantomData<(R, I)>);
impl<R, I> HandleCredit<AccountIdOf<R>, pezpallet_assets::Pallet<R, I>> for AssetsToBlockAuthor<R, I>
impl<R, I> HandleCredit<AccountIdOf<R>, pezpallet_assets::Pezpallet<R, I>> for AssetsToBlockAuthor<R, I>
where
I: 'static,
R: pezpallet_authorship::Config + pezpallet_assets::Config<I>,
AccountIdOf<R>: From<pezkuwi_primitives::AccountId> + Into<pezkuwi_primitives::AccountId>,
{
fn handle_credit(credit: fungibles::Credit<AccountIdOf<R>, pezpallet_assets::Pallet<R, I>>) {
fn handle_credit(credit: fungibles::Credit<AccountIdOf<R>, pezpallet_assets::Pezpallet<R, I>>) {
use pezframe_support::traits::fungibles::Balanced;
if let Some(author) = pezpallet_authorship::Pallet::<R>::author() {
if let Some(author) = pezpallet_authorship::Pezpallet::<R>::author() {
// In case of error: Will drop the result triggering the `OnDrop` of the imbalance.
let _ = pezpallet_assets::Pallet::<R, I>::resolve(&author, credit).defensive();
let _ = pezpallet_assets::Pezpallet::<R, I>::resolve(&author, credit).defensive();
}
}
}
@@ -136,7 +136,7 @@ impl<T: Get<Location>> ContainsPair<Asset, Location> for AssetsFrom<T> {
/// Type alias to conveniently refer to the `Currency::Balance` associated type.
pub type BalanceOf<T> =
<pezpallet_balances::Pallet<T> as Currency<<T as pezframe_system::Config>::AccountId>>::Balance;
<pezpallet_balances::Pezpallet<T> as Currency<<T as pezframe_system::Config>::AccountId>>::Balance;
/// Implements `OnUnbalanced::on_unbalanced` to teleport slashed assets to relay chain treasury
/// account.
@@ -171,9 +171,9 @@ where
};
let treasury_account: AccountIdOf<T> = TreasuryAccount::get();
<pezpallet_balances::Pallet<T>>::resolve_creating(&root_account, amount);
<pezpallet_balances::Pezpallet<T>>::resolve_creating(&root_account, amount);
let result = <pezpallet_xcm::Pallet<T>>::limited_teleport_assets(
let result = <pezpallet_xcm::Pezpallet<T>>::limited_teleport_assets(
<<T as pezframe_system::Config>::RuntimeOrigin>::root(),
Box::new(Parent.into()),
Box::new(
@@ -216,9 +216,9 @@ mod tests {
pezframe_support::construct_runtime!(
pub enum Test
{
System: pezframe_system::{Pallet, Call, Config<T>, Storage, Event<T>},
Balances: pezpallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
CollatorSelection: pezpallet_collator_selection::{Pallet, Call, Storage, Event<T>},
System: pezframe_system::{Pezpallet, Call, Config<T>, Storage, Event<T>},
Balances: pezpallet_balances::{Pezpallet, Call, Storage, Config<T>, Event<T>},
CollatorSelection: pezpallet_collator_selection::{Pezpallet, Call, Storage, Event<T>},
}
);
@@ -312,11 +312,11 @@ mod tests {
fn test_fees_and_tip_split() {
new_test_ext().execute_with(|| {
let fee =
<pezpallet_balances::Pallet<Test> as pezframe_support::traits::fungible::Balanced<
<pezpallet_balances::Pezpallet<Test> as pezframe_support::traits::fungible::Balanced<
AccountId,
>>::issue(10);
let tip =
<pezpallet_balances::Pallet<Test> as pezframe_support::traits::fungible::Balanced<
<pezpallet_balances::Pezpallet<Test> as pezframe_support::traits::fungible::Balanced<
AccountId,
>>::issue(20);
+1 -1
View File
@@ -117,7 +117,7 @@ mod constants {
pezkuwi_primitives::MAX_POV_SIZE as u64,
);
/// Treasury pallet id of the local chain, used to convert into AccountId
/// Treasury pezpallet id of the local chain, used to convert into AccountId
pub const TREASURY_PALLET_ID: PalletId = PalletId(*b"py/trsry");
}
+1 -1
View File
@@ -132,7 +132,7 @@ pub mod benchmarks {
/// the payout made by [`LocalPay`].
///
/// ### Parameters:
/// - `PalletId`: The ID of the assets registry pallet.
/// - `PalletId`: The ID of the assets registry pezpallet.
/// - `AssetId`: The ID of the asset that will be created for the benchmark within `PalletId`.
pub struct LocalPayArguments<PalletId = ConstU8<0>>(PhantomData<PalletId>);
impl<PalletId: Get<u8>>
@@ -35,7 +35,7 @@ pub struct AssetFeeAsExistentialDepositMultiplier<
impl<CurrencyBalance, Runtime, WeightToFee, BalanceConverter, AssetInstance>
pezcumulus_primitives_utility::ChargeWeightInFungibles<
AccountIdOf<Runtime>,
pezpallet_assets::Pallet<Runtime, AssetInstance>,
pezpallet_assets::Pezpallet<Runtime, AssetInstance>,
> for AssetFeeAsExistentialDepositMultiplier<Runtime, WeightToFee, BalanceConverter, AssetInstance>
where
Runtime: pezpallet_assets::Config<AssetInstance>,
@@ -52,12 +52,12 @@ where
>>::Error: core::fmt::Debug,
{
fn charge_weight_in_fungibles(
asset_id: <pezpallet_assets::Pallet<Runtime, AssetInstance> as Inspect<
asset_id: <pezpallet_assets::Pezpallet<Runtime, AssetInstance> as Inspect<
AccountIdOf<Runtime>,
>>::AssetId,
weight: Weight,
) -> Result<
<pezpallet_assets::Pallet<Runtime, AssetInstance> as Inspect<AccountIdOf<Runtime>>>::Balance,
<pezpallet_assets::Pezpallet<Runtime, AssetInstance> as Inspect<AccountIdOf<Runtime>>>::Balance,
XcmError,
> {
let amount = WeightToFee::weight_to_fee(&weight);
@@ -97,7 +97,7 @@ impl<SystemTeyrchainMatcher: Contains<Location>, Runtime: teyrchain_info::Config
for RelayOrOtherSystemTeyrchains<SystemTeyrchainMatcher, Runtime>
{
fn contains(l: &Location) -> bool {
let self_para_id: u32 = teyrchain_info::Pallet::<Runtime>::get().into();
let self_para_id: u32 = teyrchain_info::Pezpallet::<Runtime>::get().into();
if let (0, [Teyrchain(para_id)]) = l.unpack() {
if *para_id == self_para_id {
return false;
@@ -65,7 +65,7 @@ use bp_messages::{
MessageKey, OutboundLaneData,
};
pub use bp_xcm_bridge_hub::XcmBridgeHubCall;
use pezpallet_bridge_messages::{Config as BridgeMessagesConfig, LaneIdOf, OutboundLanes, Pallet};
use pezpallet_bridge_messages::{Config as BridgeMessagesConfig, LaneIdOf, OutboundLanes, Pezpallet};
pub use pezpallet_bridge_messages::{
Instance1 as BridgeMessagesInstance1, Instance2 as BridgeMessagesInstance2,
Instance3 as BridgeMessagesInstance3,
@@ -112,7 +112,7 @@ where
OutboundLanes::<S, SI>::get(lane).unwrap().latest_received_nonce;
(latest_received_nonce + 1..=latest_generated_nonce).for_each(|nonce| {
let encoded_payload: Vec<u8> = Pallet::<S, SI>::outbound_message_data(lane, nonce)
let encoded_payload: Vec<u8> = Pezpallet::<S, SI>::outbound_message_data(lane, nonce)
.expect("Bridge message does not exist")
.into();
let payload = Vec::<u8>::decode(&mut &encoded_payload[..])
@@ -371,7 +371,7 @@ macro_rules! impl_send_transact_helpers_for_relay_chain {
let destination: $crate::impls::Location = <Self as RelayChain>::child_location_of(recipient);
let xcm = $crate::impls::xcm_transact_unpaid_execution(call, $crate::impls::OriginKind::Superuser);
$crate::impls::dmp::Pallet::<<Self as $crate::impls::Chain>::Runtime>::make_teyrchain_reachable(recipient);
$crate::impls::dmp::Pezpallet::<<Self as $crate::impls::Chain>::Runtime>::make_teyrchain_reachable(recipient);
// Send XCM `Transact`
$crate::impls::assert_ok!(<Self as [<$chain RelayPallet>]>::XcmPallet::send(
@@ -600,7 +600,7 @@ macro_rules! impl_assets_helpers_for_system_teyrchain {
( $chain:ident, $relay_chain:ident ) => {
$crate::impls::paste::paste! {
impl<N: $crate::impls::Network> $chain<N> {
/// Returns the encoded call for `force_create` from the assets pallet
/// Returns the encoded call for `force_create` from the assets pezpallet
pub fn force_create_asset_call(
asset_id: u32,
owner: $crate::impls::AccountId,
@@ -622,7 +622,7 @@ macro_rules! impl_assets_helpers_for_system_teyrchain {
.into()
}
/// Returns a `VersionedXcm` for `force_create` from the assets pallet
/// Returns a `VersionedXcm` for `force_create` from the assets pezpallet
pub fn force_create_asset_xcm(
origin_kind: $crate::impls::OriginKind,
asset_id: u32,
@@ -634,7 +634,7 @@ macro_rules! impl_assets_helpers_for_system_teyrchain {
$crate::impls::xcm_transact_unpaid_execution(call, origin_kind)
}
/// Force create and mint assets making use of the assets pallet
/// Force create and mint assets making use of the assets pezpallet
pub fn force_create_and_mint_asset(
id: u32,
min_balance: u128,
@@ -744,7 +744,7 @@ macro_rules! impl_assets_helpers_for_teyrchain {
}
}
/// Mint assets making use of the assets pallet
/// Mint assets making use of the assets pezpallet
pub fn mint_asset(
signed_origin: <Self as $crate::impls::Chain>::RuntimeOrigin,
id: u32,
@@ -776,7 +776,7 @@ macro_rules! impl_assets_helpers_for_teyrchain {
});
}
/// Returns the encoded call for `create` from the assets pallet
/// Returns the encoded call for `create` from the assets pezpallet
pub fn create_asset_call(
asset_id: u32,
min_balance: $crate::impls::Balance,
@@ -898,7 +898,7 @@ macro_rules! impl_foreign_assets_helpers_for_teyrchain {
});
}
/// Returns the encoded call for `create` from the foreign assets pallet
/// Returns the encoded call for `create` from the foreign assets pezpallet
pub fn create_foreign_asset_call(
asset_id: $asset_id_type,
min_balance: $crate::impls::Balance,
@@ -954,7 +954,7 @@ macro_rules! impl_xcm_helpers_for_teyrchain {
#[macro_export]
macro_rules! impl_bridge_helpers_for_chain {
( $chain:ident, $pallet:ident, $pezpallet_xcm:ident, $runtime_call_wrapper:path ) => {
( $chain:ident, $pezpallet:ident, $pezpallet_xcm:ident, $runtime_call_wrapper:path ) => {
$crate::impls::paste::paste! {
impl<N: $crate::impls::Network> $chain<N> {
/// Open bridge with `dest`.
@@ -985,7 +985,7 @@ macro_rules! impl_bridge_helpers_for_chain {
};
// Send XCM `Transact` with `open_bridge` call
$crate::impls::assert_ok!(<Self as [<$chain $pallet>]>::$pezpallet_xcm::send(
$crate::impls::assert_ok!(<Self as [<$chain $pezpallet>]>::$pezpallet_xcm::send(
root_origin,
bx!(bridge_location.into()),
bx!(xcm),
@@ -27,7 +27,7 @@ pub use pezpallet_xcm;
pub use pezframe_support::assert_ok;
// Pezkuwi
pub use pezkuwi_runtime_teyrchains::dmp::Pallet as Dmp;
pub use pezkuwi_runtime_teyrchains::dmp::Pezpallet as Dmp;
pub use xcm::{
latest::AssetTransferFilter,
prelude::{
@@ -354,7 +354,7 @@ macro_rules! test_teyrchain_is_trusted_teleporter_for_relay {
let sender = [<$sender_para Sender>]::get();
// Mint assets to `$sender_para` to succeed with teleport.
<$sender_para as $crate::macros::TestExt>::execute_with(|| {
$crate::macros::assert_ok!(<<$sender_para as [<$sender_para Pallet>]>::Balances
$crate::macros::assert_ok!(<<$sender_para as [<$sender_para Pezpallet>]>::Balances
as $crate::macros::Mutate<_>>::mint_into(&sender, $amount + 10_000_000_000));
});
@@ -370,8 +370,8 @@ macro_rules! test_teyrchain_is_trusted_teleporter_for_relay {
// Else we'd get a `NotWithdrawable` error since it tries to reduce the check account balance, which
// would be 0.
<$receiver_relay as $crate::macros::TestExt>::execute_with(|| {
let check_account = <$receiver_relay as [<$receiver_relay Pallet>]>::XcmPallet::check_account();
$crate::macros::assert_ok!(<<$receiver_relay as [<$receiver_relay Pallet>]>::Balances
let check_account = <$receiver_relay as [<$receiver_relay Pezpallet>]>::XcmPallet::check_account();
$crate::macros::assert_ok!(<<$receiver_relay as [<$receiver_relay Pezpallet>]>::Balances
as $crate::macros::Mutate<_>>::mint_into(&check_account, $amount));
});
@@ -443,14 +443,14 @@ macro_rules! test_teyrchain_is_trusted_teleporter_for_relay {
<$receiver_relay as $crate::macros::TestExt>::reset_ext();
// Mint assets to `$sender_para` to succeed with teleport.
<$sender_para as $crate::macros::TestExt>::execute_with(|| {
$crate::macros::assert_ok!(<<$sender_para as [<$sender_para Pallet>]>::Balances
$crate::macros::assert_ok!(<<$sender_para as [<$sender_para Pezpallet>]>::Balances
as $crate::macros::Mutate<_>>::mint_into(&sender, $amount + 10_000_000_000));
});
// Since we reset everything, we need to mint funds into the checking account again.
<$receiver_relay as $crate::macros::TestExt>::execute_with(|| {
let check_account = <$receiver_relay as [<$receiver_relay Pallet>]>::XcmPallet::check_account();
$crate::macros::assert_ok!(<<$receiver_relay as [<$receiver_relay Pallet>]>::Balances
let check_account = <$receiver_relay as [<$receiver_relay Pezpallet>]>::XcmPallet::check_account();
$crate::macros::assert_ok!(<<$receiver_relay as [<$receiver_relay Pezpallet>]>::Balances
as $crate::macros::Mutate<_>>::mint_into(&check_account, $amount));
});
@@ -523,7 +523,7 @@ macro_rules! test_chain_can_claim_assets {
<$sender_para as $crate::macros::TestExt>::execute_with(|| {
// Assets are trapped for whatever reason.
// The possible reasons for this might differ from runtime to runtime, so here we just drop them directly.
<<$sender_para as [<$sender_para Pallet>]>::PezkuwiXcm as $crate::macros::DropAssets>::drop_assets(
<<$sender_para as [<$sender_para Pezpallet>]>::PezkuwiXcm as $crate::macros::DropAssets>::drop_assets(
&beneficiary,
$assets.clone().into(),
&$crate::macros::XcmContext { origin: None, message_id: [0u8; 32], topic: None },
@@ -539,25 +539,25 @@ macro_rules! test_chain_can_claim_assets {
]
);
let balance_before = <<$sender_para as [<$sender_para Pallet>]>::Balances
let balance_before = <<$sender_para as [<$sender_para Pezpallet>]>::Balances
as $crate::macros::Currency<_>>::free_balance(&sender);
// Different origin or different assets won't work.
let other_origin = <$sender_para as $crate::macros::Chain>::RuntimeOrigin::signed([<$sender_para Receiver>]::get());
assert!(<$sender_para as [<$sender_para Pallet>]>::PezkuwiXcm::claim_assets(
assert!(<$sender_para as [<$sender_para Pezpallet>]>::PezkuwiXcm::claim_assets(
other_origin,
Box::new(versioned_assets.clone().into()),
Box::new(beneficiary.clone().into()),
).is_err());
let other_versioned_assets: $crate::macros::VersionedAssets = $crate::macros::Assets::new().into();
assert!(<$sender_para as [<$sender_para Pallet>]>::PezkuwiXcm::claim_assets(
assert!(<$sender_para as [<$sender_para Pezpallet>]>::PezkuwiXcm::claim_assets(
origin.clone(),
Box::new(other_versioned_assets.into()),
Box::new(beneficiary.clone().into()),
).is_err());
// Assets will be claimed to `beneficiary`, which is the same as `sender`.
$crate::macros::assert_ok!(<$sender_para as [<$sender_para Pallet>]>::PezkuwiXcm::claim_assets(
$crate::macros::assert_ok!(<$sender_para as [<$sender_para Pezpallet>]>::PezkuwiXcm::claim_assets(
origin.clone(),
Box::new(versioned_assets.clone().into()),
Box::new(beneficiary.clone().into()),
@@ -573,23 +573,23 @@ macro_rules! test_chain_can_claim_assets {
);
// After claiming the assets, the balance has increased.
let balance_after = <<$sender_para as [<$sender_para Pallet>]>::Balances
let balance_after = <<$sender_para as [<$sender_para Pezpallet>]>::Balances
as $crate::macros::Currency<_>>::free_balance(&sender);
assert_eq!(balance_after, balance_before + $amount);
// Claiming the assets again doesn't work.
assert!(<$sender_para as [<$sender_para Pallet>]>::PezkuwiXcm::claim_assets(
assert!(<$sender_para as [<$sender_para Pezpallet>]>::PezkuwiXcm::claim_assets(
origin.clone(),
Box::new(versioned_assets.clone().into()),
Box::new(beneficiary.clone().into()),
).is_err());
let balance = <<$sender_para as [<$sender_para Pallet>]>::Balances
let balance = <<$sender_para as [<$sender_para Pezpallet>]>::Balances
as $crate::macros::Currency<_>>::free_balance(&sender);
assert_eq!(balance, balance_after);
// You can also claim assets and send them to a different account.
<<$sender_para as [<$sender_para Pallet>]>::PezkuwiXcm as $crate::macros::DropAssets>::drop_assets(
<<$sender_para as [<$sender_para Pezpallet>]>::PezkuwiXcm as $crate::macros::DropAssets>::drop_assets(
&beneficiary,
$assets.clone().into(),
&$crate::macros::XcmContext { origin: None, message_id: [0u8; 32], topic: None },
@@ -597,14 +597,14 @@ macro_rules! test_chain_can_claim_assets {
let receiver = [<$sender_para Receiver>]::get();
let other_beneficiary: $crate::macros::Location =
$crate::macros::Junction::AccountId32 { network: Some($network_id), id: receiver.clone().into() }.into();
let balance_before = <<$sender_para as [<$sender_para Pallet>]>::Balances
let balance_before = <<$sender_para as [<$sender_para Pezpallet>]>::Balances
as $crate::macros::Currency<_>>::free_balance(&receiver);
$crate::macros::assert_ok!(<$sender_para as [<$sender_para Pallet>]>::PezkuwiXcm::claim_assets(
$crate::macros::assert_ok!(<$sender_para as [<$sender_para Pezpallet>]>::PezkuwiXcm::claim_assets(
origin.clone(),
Box::new(versioned_assets.clone().into()),
Box::new(other_beneficiary.clone().into()),
));
let balance_after = <<$sender_para as [<$sender_para Pallet>]>::Balances
let balance_after = <<$sender_para as [<$sender_para Pezpallet>]>::Balances
as $crate::macros::Currency<_>>::free_balance(&receiver);
assert_eq!(balance_after, balance_before + $amount);
});
@@ -811,11 +811,11 @@ macro_rules! test_can_estimate_and_pay_exact_fees {
// Actually run the extrinsic.
let sender_assets_before = <$sender_para as $crate::macros::TestExt>::execute_with(|| {
type ForeignAssets = <$sender_para as [<$sender_para Pallet>]>::ForeignAssets;
type ForeignAssets = <$sender_para as [<$sender_para Pezpallet>]>::ForeignAssets;
<ForeignAssets as $crate::macros::Inspect<_>>::balance($asset_id.clone().into(), &sender)
});
let receiver_assets_before = <$receiver_para as $crate::macros::TestExt>::execute_with(|| {
type ForeignAssets = <$receiver_para as [<$receiver_para Pallet>]>::ForeignAssets;
type ForeignAssets = <$receiver_para as [<$receiver_para Pezpallet>]>::ForeignAssets;
<ForeignAssets as $crate::macros::Inspect<_>>::balance($asset_id.clone().into(), &beneficiary_id)
});
@@ -831,11 +831,11 @@ macro_rules! test_can_estimate_and_pay_exact_fees {
test.assert();
let sender_assets_after = <$sender_para as $crate::macros::TestExt>::execute_with(|| {
type ForeignAssets = <$sender_para as [<$sender_para Pallet>]>::ForeignAssets;
type ForeignAssets = <$sender_para as [<$sender_para Pezpallet>]>::ForeignAssets;
<ForeignAssets as $crate::macros::Inspect<_>>::balance($asset_id.clone().into(), &sender)
});
let receiver_assets_after = <$receiver_para as $crate::macros::TestExt>::execute_with(|| {
type ForeignAssets = <$receiver_para as [<$receiver_para Pallet>]>::ForeignAssets;
type ForeignAssets = <$receiver_para as [<$receiver_para Pezpallet>]>::ForeignAssets;
<ForeignAssets as $crate::macros::Inspect<_>>::balance($asset_id.into(), &beneficiary_id)
});
@@ -870,7 +870,7 @@ macro_rules! test_dry_run_transfer_across_pk_bridge {
type Runtime = <$sender_asset_hub as $crate::macros::Chain>::Runtime;
type RuntimeCall = <$sender_asset_hub as $crate::macros::Chain>::RuntimeCall;
type OriginCaller = <$sender_asset_hub as $crate::macros::Chain>::OriginCaller;
type Balances = <$sender_asset_hub as [<$sender_asset_hub Pallet>]>::Balances;
type Balances = <$sender_asset_hub as [<$sender_asset_hub Pezpallet>]>::Balances;
// Give some initial funds.
<Balances as $crate::macros::Mutate<_>>::set_balance(&who, initial_balance);
@@ -914,8 +914,8 @@ macro_rules! test_xcm_fee_querying_apis_work_for_asset_hub {
<$asset_hub as $crate::macros::TestExt>::execute_with(|| {
// Setup a pool between USDT and ZGR.
type RuntimeOrigin = <$asset_hub as $crate::macros::Chain>::RuntimeOrigin;
type Assets = <$asset_hub as [<$asset_hub Pallet>]>::Assets;
type AssetConversion = <$asset_hub as [<$asset_hub Pallet>]>::AssetConversion;
type Assets = <$asset_hub as [<$asset_hub Pezpallet>]>::Assets;
type AssetConversion = <$asset_hub as [<$asset_hub Pezpallet>]>::AssetConversion;
let wnd = $crate::macros::Location::new(1, []);
let usdt = $crate::macros::Location::new(0, [$crate::macros::PalletInstance($crate::macros::ASSETS_PALLET_ID),
$crate::macros::GeneralIndex($crate::macros::USDT_ID.into())]);
@@ -1036,7 +1036,7 @@ macro_rules! test_cross_chain_alias {
]);
let signed_origin = <$sender_para as $crate::macros::Chain>::RuntimeOrigin::signed(account.into());
$crate::macros::assert_ok!(<$sender_para as [<$sender_para Pallet>]>::PezkuwiXcm::execute(
$crate::macros::assert_ok!(<$sender_para as [<$sender_para Pezpallet>]>::PezkuwiXcm::execute(
signed_origin,
Box::new($crate::macros::VersionedXcm::from(xcm_message.into())),
$crate::macros::Weight::MAX
@@ -1089,7 +1089,7 @@ macro_rules! create_pool_with_native_on {
let native_asset: $crate::macros::Location = $crate::macros::Parent.into();
if $is_foreign {
$crate::macros::assert_ok!(<$chain as [<$chain Pallet>]>::ForeignAssets::mint(
$crate::macros::assert_ok!(<$chain as [<$chain Pezpallet>]>::ForeignAssets::mint(
signed_owner.clone(),
$asset.clone().into(),
owner.clone().into(),
@@ -1100,7 +1100,7 @@ macro_rules! create_pool_with_native_on {
Some($crate::macros::GeneralIndex(id)) => *id as u32,
_ => unreachable!(),
};
$crate::macros::assert_ok!(<$chain as [<$chain Pallet>]>::Assets::mint(
$crate::macros::assert_ok!(<$chain as [<$chain Pezpallet>]>::Assets::mint(
signed_owner.clone(),
asset_id.into(),
owner.clone().into(),
@@ -1108,7 +1108,7 @@ macro_rules! create_pool_with_native_on {
));
}
$crate::macros::assert_ok!(<$chain as [<$chain Pallet>]>::AssetConversion::create_pool(
$crate::macros::assert_ok!(<$chain as [<$chain Pezpallet>]>::AssetConversion::create_pool(
signed_owner.clone(),
Box::new(native_asset.clone()),
Box::new($asset.clone()),
@@ -1121,7 +1121,7 @@ macro_rules! create_pool_with_native_on {
]
);
$crate::macros::assert_ok!(<$chain as [<$chain Pallet>]>::AssetConversion::add_liquidity(
$crate::macros::assert_ok!(<$chain as [<$chain Pezpallet>]>::AssetConversion::add_liquidity(
signed_owner,
Box::new(native_asset),
Box::new($asset),
@@ -47,7 +47,7 @@ macro_rules! create_pool_with_roc_on {
let signed_owner = <$chain as Chain>::RuntimeOrigin::signed(owner.clone());
let roc_location: Location = Parent.into();
if $is_foreign {
assert_ok!(<$chain as [<$chain Pallet>]>::ForeignAssets::mint(
assert_ok!(<$chain as [<$chain Pezpallet>]>::ForeignAssets::mint(
signed_owner.clone(),
$asset_id.clone().into(),
owner.clone().into(),
@@ -58,7 +58,7 @@ macro_rules! create_pool_with_roc_on {
Some(GeneralIndex(id)) => *id as u32,
_ => unreachable!(),
};
assert_ok!(<$chain as [<$chain Pallet>]>::Assets::mint(
assert_ok!(<$chain as [<$chain Pezpallet>]>::Assets::mint(
signed_owner.clone(),
asset_id.into(),
owner.clone().into(),
@@ -66,7 +66,7 @@ macro_rules! create_pool_with_roc_on {
));
}
assert_ok!(<$chain as [<$chain Pallet>]>::AssetConversion::create_pool(
assert_ok!(<$chain as [<$chain Pezpallet>]>::AssetConversion::create_pool(
signed_owner.clone(),
Box::new(roc_location.clone()),
Box::new($asset_id.clone()),
@@ -79,7 +79,7 @@ macro_rules! create_pool_with_roc_on {
]
);
assert_ok!(<$chain as [<$chain Pallet>]>::AssetConversion::add_liquidity(
assert_ok!(<$chain as [<$chain Pezpallet>]>::AssetConversion::add_liquidity(
signed_owner,
Box::new(roc_location),
Box::new($asset_id),
@@ -153,7 +153,7 @@ fn spend_roc_on_asset_hub() {
// Assert events triggered by xcm pay program:
// 1. treasury asset transferred to spend beneficiary;
// 2. response to Relay Chain Treasury pallet instance sent back;
// 2. response to Relay Chain Treasury pezpallet instance sent back;
// 3. XCM program completed;
assert_expected_events!(
AssetHubPezkuwichain,
@@ -229,7 +229,7 @@ fn create_and_claim_treasury_spend_in_usdt() {
// assert events triggered by xcm pay program
// 1. treasury asset transferred to spend beneficiary
// 2. response to Relay Chain treasury pallet instance sent back
// 2. response to Relay Chain treasury pezpallet instance sent back
// 3. XCM program completed
assert_expected_events!(
AssetHubPezkuwichain,
@@ -85,7 +85,7 @@ fn create_and_claim_treasury_spend() {
// assert events triggered by xcm pay program
// 1. treasury asset transferred to spend beneficiary
// 2. response to the Fellowship treasury pallet instance sent back
// 2. response to the Fellowship treasury pezpallet instance sent back
// 3. XCM program completed
assert_expected_events!(
AssetHubZagros,
@@ -36,7 +36,7 @@ macro_rules! foreign_balance_on {
( $chain:ident, $id:expr, $who:expr ) => {
emulated_integration_tests_common::impls::paste::paste! {
<$chain>::execute_with(|| {
type ForeignAssets = <$chain as [<$chain Pallet>]>::ForeignAssets;
type ForeignAssets = <$chain as [<$chain Pezpallet>]>::ForeignAssets;
<ForeignAssets as pezframe_support::traits::fungibles::Inspect<_>>::balance($id, $who)
})
}
@@ -48,7 +48,7 @@ macro_rules! assets_balance_on {
( $chain:ident, $id:expr, $who:expr ) => {
emulated_integration_tests_common::impls::paste::paste! {
<$chain>::execute_with(|| {
type Assets = <$chain as [<$chain Pallet>]>::Assets;
type Assets = <$chain as [<$chain Pezpallet>]>::Assets;
<Assets as pezframe_support::traits::fungibles::Inspect<_>>::balance($id, $who)
})
}
@@ -78,7 +78,7 @@ macro_rules! create_pool_with_wnd_on {
let signed_owner = <$chain as Chain>::RuntimeOrigin::signed(owner.clone());
let wnd_location: Location = Parent.into();
if $is_foreign {
assert_ok!(<$chain as [<$chain Pallet>]>::ForeignAssets::mint(
assert_ok!(<$chain as [<$chain Pezpallet>]>::ForeignAssets::mint(
signed_owner.clone(),
$asset_id.clone().into(),
owner.clone().into(),
@@ -89,7 +89,7 @@ macro_rules! create_pool_with_wnd_on {
Some(GeneralIndex(id)) => *id as u32,
_ => unreachable!(),
};
assert_ok!(<$chain as [<$chain Pallet>]>::Assets::mint(
assert_ok!(<$chain as [<$chain Pezpallet>]>::Assets::mint(
signed_owner.clone(),
asset_id.into(),
owner.clone().into(),
@@ -97,7 +97,7 @@ macro_rules! create_pool_with_wnd_on {
));
}
assert_ok!(<$chain as [<$chain Pallet>]>::AssetConversion::create_pool(
assert_ok!(<$chain as [<$chain Pezpallet>]>::AssetConversion::create_pool(
signed_owner.clone(),
Box::new(wnd_location.clone()),
Box::new($asset_id.clone()),
@@ -110,7 +110,7 @@ macro_rules! create_pool_with_wnd_on {
]
);
assert_ok!(<$chain as [<$chain Pallet>]>::AssetConversion::add_liquidity(
assert_ok!(<$chain as [<$chain Pezpallet>]>::AssetConversion::add_liquidity(
signed_owner,
Box::new(wnd_location),
Box::new($asset_id),
@@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Tests for the validation of `pezpallet_xcm::Pallet::<T>::transfer_assets`.
//! Tests for the validation of `pezpallet_xcm::Pezpallet::<T>::transfer_assets`.
//! See the `pezpallet_xcm::transfer_assets_validation` module for more information.
use crate::imports::*;
@@ -86,7 +86,7 @@ fn create_and_claim_treasury_spend() {
// assert events triggered by xcm pay program
// 1. treasury asset transferred to spend beneficiary
// 2. response to Relay Chain treasury pallet instance sent back
// 2. response to Relay Chain treasury pezpallet instance sent back
// 3. XCM program completed
assert_expected_events!(
AssetHubZagros,
@@ -154,7 +154,7 @@ fn fellowship_treasury_spend() {
// Assert events triggered by xcm pay program:
// 1. treasury asset transferred to spend beneficiary;
// 2. response to Relay Chain Treasury pallet instance sent back;
// 2. response to Relay Chain Treasury pezpallet instance sent back;
// 3. XCM program completed;
assert_expected_events!(
AssetHubZagros,
@@ -228,7 +228,7 @@ fn fellowship_treasury_spend() {
// Assert events triggered by xcm pay program:
// 1. treasury asset transferred to spend beneficiary;
// 2. response to Relay Chain Treasury pallet instance sent back;
// 2. response to Relay Chain Treasury pezpallet instance sent back;
// 3. XCM program completed;
assert_expected_events!(
AssetHubZagros,
@@ -128,7 +128,7 @@ fn transact_hardcoded_weights_are_sane() {
let config = CoretimePezkuwichain::ext_wrapper(|| {
Configuration::<<CoretimePezkuwichain as Chain>::Runtime>::get()
.expect("Pallet was configured earlier.")
.expect("Pezpallet was configured earlier.")
});
// Now run up to the block before the sale is rotated.
@@ -127,7 +127,7 @@ fn transact_hardcoded_weights_are_sane() {
let config = CoretimeZagros::ext_wrapper(|| {
Configuration::<<CoretimeZagros as Chain>::Runtime>::get()
.expect("Pallet was configured earlier.")
.expect("Pezpallet was configured earlier.")
});
// Now run up to the block before the sale is rotated.
@@ -52,9 +52,9 @@ teyrchains-common = { workspace = true, default-features = true }
# Snowbridge
pezsnowbridge-inbound-queue-primitives = { workspace = true }
pezsnowbridge-outbound-queue-primitives = { workspace = true }
snowbridge-pezpallet-inbound-queue-fixtures = { workspace = true, default-features = true }
snowbridge-pezpallet-outbound-queue = { workspace = true }
snowbridge-pezpallet-system = { workspace = true }
pezsnowbridge-pezpallet-inbound-queue-fixtures = { workspace = true, default-features = true }
pezsnowbridge-pezpallet-outbound-queue = { workspace = true }
pezsnowbridge-pezpallet-system = { workspace = true }
[features]
runtime-benchmarks = [
@@ -73,9 +73,9 @@ runtime-benchmarks = [
"pezkuwichain-zagros-system-emulated-network/runtime-benchmarks",
"pezsnowbridge-inbound-queue-primitives/runtime-benchmarks",
"pezsnowbridge-outbound-queue-primitives/runtime-benchmarks",
"snowbridge-pezpallet-inbound-queue-fixtures/runtime-benchmarks",
"snowbridge-pezpallet-outbound-queue/runtime-benchmarks",
"snowbridge-pezpallet-system/runtime-benchmarks",
"pezsnowbridge-pezpallet-inbound-queue-fixtures/runtime-benchmarks",
"pezsnowbridge-pezpallet-outbound-queue/runtime-benchmarks",
"pezsnowbridge-pezpallet-system/runtime-benchmarks",
"pezsp-runtime/runtime-benchmarks",
"testnet-teyrchains-constants/runtime-benchmarks",
"teyrchains-common/runtime-benchmarks",
@@ -36,7 +36,7 @@ fn register_pezkuwichain_asset_on_wah_from_rah() {
],
);
// Encoded `create_asset` call to be executed in Zagros Asset Hub ForeignAssets pallet.
// Encoded `create_asset` call to be executed in Zagros Asset Hub ForeignAssets pezpallet.
let call = AssetHubZagros::create_foreign_asset_call(
bridged_asset_at_wah.clone(),
ASSET_MIN_BALANCE,
@@ -57,13 +57,13 @@ teyrchains-common = { workspace = true, default-features = true }
pezsnowbridge-core = { workspace = true }
pezsnowbridge-inbound-queue-primitives = { workspace = true }
pezsnowbridge-outbound-queue-primitives = { workspace = true }
snowbridge-pezpallet-inbound-queue = { workspace = true }
snowbridge-pezpallet-inbound-queue-fixtures = { workspace = true }
snowbridge-pezpallet-inbound-queue-v2 = { workspace = true }
snowbridge-pezpallet-outbound-queue = { workspace = true }
snowbridge-pezpallet-outbound-queue-v2 = { workspace = true }
snowbridge-pezpallet-system = { workspace = true }
snowbridge-pezpallet-system-v2 = { workspace = true }
pezsnowbridge-pezpallet-inbound-queue = { workspace = true }
pezsnowbridge-pezpallet-inbound-queue-fixtures = { workspace = true }
pezsnowbridge-pezpallet-inbound-queue-v2 = { workspace = true }
pezsnowbridge-pezpallet-outbound-queue = { workspace = true }
pezsnowbridge-pezpallet-outbound-queue-v2 = { workspace = true }
pezsnowbridge-pezpallet-system = { workspace = true }
pezsnowbridge-pezpallet-system-v2 = { workspace = true }
[features]
runtime-benchmarks = [
@@ -86,13 +86,13 @@ runtime-benchmarks = [
"pezsnowbridge-core/runtime-benchmarks",
"pezsnowbridge-inbound-queue-primitives/runtime-benchmarks",
"pezsnowbridge-outbound-queue-primitives/runtime-benchmarks",
"snowbridge-pezpallet-inbound-queue-fixtures/runtime-benchmarks",
"snowbridge-pezpallet-inbound-queue-v2/runtime-benchmarks",
"snowbridge-pezpallet-inbound-queue/runtime-benchmarks",
"snowbridge-pezpallet-outbound-queue-v2/runtime-benchmarks",
"snowbridge-pezpallet-outbound-queue/runtime-benchmarks",
"snowbridge-pezpallet-system-v2/runtime-benchmarks",
"snowbridge-pezpallet-system/runtime-benchmarks",
"pezsnowbridge-pezpallet-inbound-queue-fixtures/runtime-benchmarks",
"pezsnowbridge-pezpallet-inbound-queue-v2/runtime-benchmarks",
"pezsnowbridge-pezpallet-inbound-queue/runtime-benchmarks",
"pezsnowbridge-pezpallet-outbound-queue-v2/runtime-benchmarks",
"pezsnowbridge-pezpallet-outbound-queue/runtime-benchmarks",
"pezsnowbridge-pezpallet-system-v2/runtime-benchmarks",
"pezsnowbridge-pezpallet-system/runtime-benchmarks",
"pezsp-io/runtime-benchmarks",
"pezsp-runtime/runtime-benchmarks",
"testnet-teyrchains-constants/runtime-benchmarks",
@@ -57,7 +57,7 @@ fn register_asset_on_rah_from_wah(bridged_asset_at_rah: Location) {
AssetHubZagros::para_id(),
);
// Encoded `create_asset` call to be executed in Pezkuwichain Asset Hub ForeignAssets pallet.
// Encoded `create_asset` call to be executed in Pezkuwichain Asset Hub ForeignAssets pezpallet.
let call = AssetHubPezkuwichain::create_foreign_asset_call(
bridged_asset_at_rah.clone(),
ASSET_MIN_BALANCE,
@@ -51,7 +51,7 @@ use pezsnowbridge_inbound_queue_primitives::{
v1::{Command, Destination, MessageV1, VersionedMessage},
EventFixture,
};
use snowbridge_pezpallet_inbound_queue_fixtures::send_native_eth::make_send_native_eth_message;
use pezsnowbridge_pezpallet_inbound_queue_fixtures::send_native_eth::make_send_native_eth_message;
use pezsp_core::{H160, H256};
use testnet_teyrchains_constants::zagros::snowbridge::EthereumNetwork;
use xcm_builder::ExternalConsensusLocationsConverterFor;
@@ -403,8 +403,8 @@ fn send_eth_asset_from_asset_hub_to_ethereum_and_back() {
assert_expected_events!(
BridgeHubZagros,
vec![
RuntimeEvent::EthereumOutboundQueue(snowbridge_pezpallet_outbound_queue::Event::MessageAccepted {..}) => {},
RuntimeEvent::EthereumOutboundQueue(snowbridge_pezpallet_outbound_queue::Event::MessageQueued {..}) => {},
RuntimeEvent::EthereumOutboundQueue(pezsnowbridge_pezpallet_outbound_queue::Event::MessageAccepted {..}) => {},
RuntimeEvent::EthereumOutboundQueue(pezsnowbridge_pezpallet_outbound_queue::Event::MessageQueued {..}) => {},
]
);
});
@@ -703,7 +703,7 @@ fn send_weth_asset_from_asset_hub_to_ethereum() {
// Outbound Queue
assert_expected_events!(
BridgeHubZagros,
vec![RuntimeEvent::EthereumOutboundQueue(snowbridge_pezpallet_outbound_queue::Event::MessageQueued{ .. }) => {},]
vec![RuntimeEvent::EthereumOutboundQueue(pezsnowbridge_pezpallet_outbound_queue::Event::MessageQueued{ .. }) => {},]
);
});
}
@@ -844,7 +844,7 @@ fn transfer_relay_token() {
// Check that a message was sent to Ethereum to create the agent
assert_expected_events!(
BridgeHubZagros,
vec![RuntimeEvent::EthereumSystem(snowbridge_pezpallet_system::Event::RegisterToken { .. }) => {},]
vec![RuntimeEvent::EthereumSystem(pezsnowbridge_pezpallet_system::Event::RegisterToken { .. }) => {},]
);
});
@@ -901,7 +901,7 @@ fn transfer_relay_token() {
// Outbound Queue
assert_expected_events!(
BridgeHubZagros,
vec![RuntimeEvent::EthereumOutboundQueue(snowbridge_pezpallet_outbound_queue::Event::MessageQueued{ .. }) => {},]
vec![RuntimeEvent::EthereumOutboundQueue(pezsnowbridge_pezpallet_outbound_queue::Event::MessageQueued{ .. }) => {},]
);
// Send relay token back to AH
@@ -1068,7 +1068,7 @@ fn transfer_ah_token() {
// Outbound Queue
assert_expected_events!(
BridgeHubZagros,
vec![RuntimeEvent::EthereumOutboundQueue(snowbridge_pezpallet_outbound_queue::Event::MessageQueued{ .. }) => {},]
vec![RuntimeEvent::EthereumOutboundQueue(pezsnowbridge_pezpallet_outbound_queue::Event::MessageQueued{ .. }) => {},]
);
let message = VersionedMessage::V1(MessageV1 {
@@ -1426,7 +1426,7 @@ fn send_weth_from_ethereum_to_ahw_to_ahr_back_to_ahw_and_ethereum() {
// Outbound Queue
assert_expected_events!(
BridgeHubZagros,
vec![RuntimeEvent::EthereumOutboundQueue(snowbridge_pezpallet_outbound_queue::Event::MessageQueued{ .. }) => {},]
vec![RuntimeEvent::EthereumOutboundQueue(pezsnowbridge_pezpallet_outbound_queue::Event::MessageQueued{ .. }) => {},]
);
});
}
@@ -1558,7 +1558,7 @@ fn transfer_penpal_native_asset() {
type RuntimeEvent = <BridgeHubZagros as Chain>::RuntimeEvent;
assert_expected_events!(
BridgeHubZagros,
vec![RuntimeEvent::EthereumOutboundQueue(snowbridge_pezpallet_outbound_queue::Event::MessageQueued{ .. }) => {},]
vec![RuntimeEvent::EthereumOutboundQueue(pezsnowbridge_pezpallet_outbound_queue::Event::MessageQueued{ .. }) => {},]
);
});
@@ -1771,7 +1771,7 @@ fn transfer_penpal_teleport_enabled_asset() {
type RuntimeEvent = <BridgeHubZagros as Chain>::RuntimeEvent;
assert_expected_events!(
BridgeHubZagros,
vec![RuntimeEvent::EthereumOutboundQueue(snowbridge_pezpallet_outbound_queue::Event::MessageQueued{ .. }) => {},]
vec![RuntimeEvent::EthereumOutboundQueue(pezsnowbridge_pezpallet_outbound_queue::Event::MessageQueued{ .. }) => {},]
);
});
@@ -2125,7 +2125,7 @@ fn transfer_roc_from_ah_with_transfer_and_then() {
// Outbound Queue
assert_expected_events!(
BridgeHubZagros,
vec![RuntimeEvent::EthereumOutboundQueue(snowbridge_pezpallet_outbound_queue::Event::MessageQueued{ .. }) => {},]
vec![RuntimeEvent::EthereumOutboundQueue(pezsnowbridge_pezpallet_outbound_queue::Event::MessageQueued{ .. }) => {},]
);
});
@@ -2222,7 +2222,7 @@ fn register_pna_in_v5_while_transfer_in_v4_should_work() {
// Check that a message was sent to Ethereum to create the agent
assert_expected_events!(
BridgeHubZagros,
vec![RuntimeEvent::EthereumSystem(snowbridge_pezpallet_system::Event::RegisterToken { .. }) => {},]
vec![RuntimeEvent::EthereumSystem(pezsnowbridge_pezpallet_system::Event::RegisterToken { .. }) => {},]
);
});
@@ -2288,7 +2288,7 @@ fn register_pna_in_v5_while_transfer_in_v4_should_work() {
assert_expected_events!(
BridgeHubZagros,
vec![RuntimeEvent::EthereumOutboundQueue(snowbridge_pezpallet_outbound_queue::Event::MessageQueued{ .. }) => {},]
vec![RuntimeEvent::EthereumOutboundQueue(pezsnowbridge_pezpallet_outbound_queue::Event::MessageQueued{ .. }) => {},]
);
});
}
@@ -75,7 +75,7 @@ pub fn register_relay_token_on_bh() {
));
assert_expected_events!(
BridgeHubZagros,
vec![RuntimeEvent::EthereumSystem(snowbridge_pezpallet_system::Event::RegisterToken { .. }) => {},]
vec![RuntimeEvent::EthereumSystem(pezsnowbridge_pezpallet_system::Event::RegisterToken { .. }) => {},]
);
});
}
@@ -390,7 +390,7 @@ pub fn register_pal_on_bh() {
));
assert_expected_events!(
BridgeHubZagros,
vec![RuntimeEvent::EthereumSystem(snowbridge_pezpallet_system::Event::RegisterToken { .. }) => {},]
vec![RuntimeEvent::EthereumSystem(pezsnowbridge_pezpallet_system::Event::RegisterToken { .. }) => {},]
);
});
}
@@ -519,7 +519,7 @@ pub fn register_roc_on_bh() {
));
assert_expected_events!(
BridgeHubZagros,
vec![RuntimeEvent::EthereumSystem(snowbridge_pezpallet_system::Event::RegisterToken { .. }) => {},]
vec![RuntimeEvent::EthereumSystem(pezsnowbridge_pezpallet_system::Event::RegisterToken { .. }) => {},]
);
});
}
@@ -17,7 +17,7 @@ use crate::{imports::*, tests::snowbridge_common::*};
use pezbridge_hub_zagros_runtime::xcm_config::LocationToAccountId;
use emulated_integration_tests_common::snowbridge::{SEPOLIA_ID, WETH};
use pezsnowbridge_core::AssetMetadata;
use snowbridge_pezpallet_system::Error;
use pezsnowbridge_pezpallet_system::Error;
use testnet_teyrchains_constants::zagros::snowbridge::EthereumNetwork;
use xcm_executor::traits::ConvertLocation;
@@ -210,7 +210,7 @@ fn send_token_v2() {
reward_kind: *reward_kind == BridgeReward::Snowbridge,
reward_balance: *reward_balance == relayer_reward,
},
RuntimeEvent::EthereumInboundQueueV2(snowbridge_pezpallet_inbound_queue_v2::Event::MessageReceived { message_id, .. }) => {
RuntimeEvent::EthereumInboundQueueV2(pezsnowbridge_pezpallet_inbound_queue_v2::Event::MessageReceived { message_id, .. }) => {
message_id: *message_id == topic_id,
},
]
@@ -1059,7 +1059,7 @@ pub fn add_tip_from_asset_hub_user_origin() {
assert!(
events.iter().any(|event| matches!(
event,
RuntimeEvent::EthereumSystemV2(snowbridge_pezpallet_system_v2::Event::TipProcessed { sender, message_id, success, ..})
RuntimeEvent::EthereumSystemV2(pezsnowbridge_pezpallet_system_v2::Event::TipProcessed { sender, message_id, success, ..})
if *sender == relayer &&*message_id == tip_message_id.clone() && *success, // expect success
)),
"tip added event found"
@@ -25,8 +25,8 @@ use pezframe_support::{assert_err_ignore_postinfo, pezpallet_prelude::TypeInfo};
use pezkuwichain_zagros_system_emulated_network::pez_penpal_emulated_chain::pez_penpal_runtime::xcm_config::LocalTeleportableToAssetHub;
use pezsnowbridge_core::{reward::MessageId, AssetMetadata, BasicOperatingMode};
use pezsnowbridge_outbound_queue_primitives::v2::{ContractCall, DeliveryReceipt};
use snowbridge_pezpallet_outbound_queue_v2::Error;
use snowbridge_pezpallet_system_v2::LostTips;
use pezsnowbridge_pezpallet_outbound_queue_v2::Error;
use pezsnowbridge_pezpallet_system_v2::LostTips;
use pezsp_core::H256;
use xcm::v5::AssetTransferFilter;
@@ -98,7 +98,7 @@ fn send_weth_from_asset_hub_to_ethereum() {
assert_expected_events!(
BridgeHubZagros,
vec![
RuntimeEvent::EthereumOutboundQueueV2(snowbridge_pezpallet_outbound_queue_v2::Event::MessageQueued{ .. }) => {},
RuntimeEvent::EthereumOutboundQueueV2(pezsnowbridge_pezpallet_outbound_queue_v2::Event::MessageQueued{ .. }) => {},
]
);
@@ -152,7 +152,7 @@ pub fn register_relay_token_from_asset_hub_with_sudo() {
type RuntimeEvent = <BridgeHubZagros as Chain>::RuntimeEvent;
assert_expected_events!(
BridgeHubZagros,
vec![RuntimeEvent::EthereumOutboundQueueV2(snowbridge_pezpallet_outbound_queue_v2::Event::MessageQueued{ .. }) => {},]
vec![RuntimeEvent::EthereumOutboundQueueV2(pezsnowbridge_pezpallet_outbound_queue_v2::Event::MessageQueued{ .. }) => {},]
);
});
}
@@ -192,7 +192,7 @@ pub fn register_usdt_from_owner_on_asset_hub() {
type RuntimeEvent = <BridgeHubZagros as Chain>::RuntimeEvent;
assert_expected_events!(
BridgeHubZagros,
vec![RuntimeEvent::EthereumOutboundQueueV2(snowbridge_pezpallet_outbound_queue_v2::Event::MessageQueued{ .. }) => {},]
vec![RuntimeEvent::EthereumOutboundQueueV2(pezsnowbridge_pezpallet_outbound_queue_v2::Event::MessageQueued{ .. }) => {},]
);
});
}
@@ -268,7 +268,7 @@ pub fn add_tip_from_asset_hub_user_origin() {
assert!(
events.iter().any(|event| matches!(
event,
RuntimeEvent::EthereumSystemV2(snowbridge_pezpallet_system_v2::Event::TipProcessed { sender, message_id, success, ..})
RuntimeEvent::EthereumSystemV2(pezsnowbridge_pezpallet_system_v2::Event::TipProcessed { sender, message_id, success, ..})
if *sender == relayer && *message_id == tip_message_id.clone() && *success, // expect success
)),
"tip added event found"
@@ -307,7 +307,7 @@ pub fn tip_to_invalid_nonce_is_added_to_lost_tips() {
assert!(
events.iter().any(|event| matches!(
event,
RuntimeEvent::EthereumSystemV2(snowbridge_pezpallet_system_v2::Event::TipProcessed { sender, message_id, success, ..})
RuntimeEvent::EthereumSystemV2(pezsnowbridge_pezpallet_system_v2::Event::TipProcessed { sender, message_id, success, ..})
if *sender == relayer && *message_id == tip_message_id.clone() && !(*success), // expect a failure
)),
"tip added event found"
@@ -403,7 +403,7 @@ fn transfer_relay_token_from_ah() {
// Check that the Ethereum message was queue in the Outbound Queue
assert_expected_events!(
BridgeHubZagros,
vec![RuntimeEvent::EthereumOutboundQueueV2(snowbridge_pezpallet_outbound_queue_v2::Event::MessageQueued{ .. }) => {},]
vec![RuntimeEvent::EthereumOutboundQueueV2(pezsnowbridge_pezpallet_outbound_queue_v2::Event::MessageQueued{ .. }) => {},]
);
let relayer = BridgeHubZagrosSender::get();
@@ -490,7 +490,7 @@ fn send_weth_and_hez_from_asset_hub_to_ethereum() {
// Check that Ethereum message was queue in the Outbound Queue
assert_expected_events!(
BridgeHubZagros,
vec![RuntimeEvent::EthereumOutboundQueueV2(snowbridge_pezpallet_outbound_queue_v2::Event::MessageQueued{ .. }) => {},]
vec![RuntimeEvent::EthereumOutboundQueueV2(pezsnowbridge_pezpallet_outbound_queue_v2::Event::MessageQueued{ .. }) => {},]
);
let relayer = BridgeHubZagrosSender::get();
@@ -586,7 +586,7 @@ fn transact_with_agent_from_asset_hub() {
// Check that Ethereum message was queue in the Outbound Queue
assert_expected_events!(
BridgeHubZagros,
vec![RuntimeEvent::EthereumOutboundQueueV2(snowbridge_pezpallet_outbound_queue_v2::Event::MessageQueued{ .. }) => {},]
vec![RuntimeEvent::EthereumOutboundQueueV2(pezsnowbridge_pezpallet_outbound_queue_v2::Event::MessageQueued{ .. }) => {},]
);
let relayer = BridgeHubZagrosSender::get();
@@ -670,7 +670,7 @@ fn transact_with_agent_from_asset_hub_without_any_asset_transfer() {
// Check that Ethereum message was queue in the Outbound Queue
assert_expected_events!(
BridgeHubZagros,
vec![RuntimeEvent::EthereumOutboundQueueV2(snowbridge_pezpallet_outbound_queue_v2::Event::MessageQueued{ .. }) => {},]
vec![RuntimeEvent::EthereumOutboundQueueV2(pezsnowbridge_pezpallet_outbound_queue_v2::Event::MessageQueued{ .. }) => {},]
);
let relayer = BridgeHubZagrosSender::get();
@@ -789,7 +789,7 @@ fn register_token_from_penpal() {
type RuntimeEvent = <BridgeHubZagros as Chain>::RuntimeEvent;
assert_expected_events!(
BridgeHubZagros,
vec![RuntimeEvent::EthereumOutboundQueueV2(snowbridge_pezpallet_outbound_queue_v2::Event::MessageQueued{ .. }) => {},]
vec![RuntimeEvent::EthereumOutboundQueueV2(pezsnowbridge_pezpallet_outbound_queue_v2::Event::MessageQueued{ .. }) => {},]
);
let relayer = BridgeHubZagrosSender::get();
@@ -808,7 +808,7 @@ fn register_token_from_penpal() {
assert_expected_events!(
BridgeHubZagros,
vec![
RuntimeEvent::EthereumOutboundQueueV2(snowbridge_pezpallet_outbound_queue_v2::Event::MessageDelivered { .. }) => {},
RuntimeEvent::EthereumOutboundQueueV2(pezsnowbridge_pezpallet_outbound_queue_v2::Event::MessageDelivered { .. }) => {},
]
);
});
@@ -937,7 +937,7 @@ fn send_message_from_penpal_to_ethereum(sudo: bool) {
type RuntimeEvent = <BridgeHubZagros as Chain>::RuntimeEvent;
assert_expected_events!(
BridgeHubZagros,
vec![RuntimeEvent::EthereumOutboundQueueV2(snowbridge_pezpallet_outbound_queue_v2::Event::MessageQueued{ .. }) => {},]
vec![RuntimeEvent::EthereumOutboundQueueV2(pezsnowbridge_pezpallet_outbound_queue_v2::Event::MessageQueued{ .. }) => {},]
);
});
}
@@ -270,7 +270,7 @@ fn send_roc_from_asset_hub_pezkuwichain_to_ethereum() {
// Check that the Ethereum message was queue in the Outbound Queue
assert_expected_events!(
BridgeHubZagros,
vec![RuntimeEvent::EthereumOutboundQueueV2(snowbridge_pezpallet_outbound_queue_v2::Event::MessageQueued{ .. }) => {},]
vec![RuntimeEvent::EthereumOutboundQueueV2(pezsnowbridge_pezpallet_outbound_queue_v2::Event::MessageQueued{ .. }) => {},]
);
});
}
@@ -366,7 +366,7 @@ fn register_pezkuwichain_asset_on_ethereum_from_rah() {
// Check that the Ethereum message was queue in the Outbound Queue
assert_expected_events!(
BridgeHubZagros,
vec![RuntimeEvent::EthereumOutboundQueueV2(snowbridge_pezpallet_outbound_queue_v2::Event::MessageQueued{ .. }) => {},]
vec![RuntimeEvent::EthereumOutboundQueueV2(pezsnowbridge_pezpallet_outbound_queue_v2::Event::MessageQueued{ .. }) => {},]
);
});
}
@@ -57,7 +57,7 @@ fn transfer_and_transact_in_same_xcm(
let destination = destination.reanchored(&asset_hub_location, &context).unwrap();
let xcm_to_ah = Xcm::<()>(vec![
UnpaidExecution { check_origin: None, weight_limit: Unlimited },
DescendOrigin([PalletInstance(80)].into()), // snowbridge pallet
DescendOrigin([PalletInstance(80)].into()), // snowbridge pezpallet
UniversalOrigin(GlobalConsensus(Ethereum { chain_id: SEPOLIA_ID })),
ReserveAssetDeposited(weth.clone().into()),
AliasOrigin(sender),
@@ -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
);

Some files were not shown because too many files have changed in this diff Show More