style: Migrate to stable-only rustfmt configuration
- Remove nightly-only features from .rustfmt.toml and vendor/ss58-registry/rustfmt.toml - Removed features: imports_granularity, wrap_comments, comment_width, reorder_impl_items, spaces_around_ranges, binop_separator, match_arm_blocks, trailing_semicolon, trailing_comma - Format all 898 affected files with stable rustfmt - Ensures long-term reliability without nightly toolchain dependency
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
use crate as pezpallet_identity_kyc;
|
||||
use pezframe_support::{
|
||||
construct_runtime, derive_impl, parameter_types,
|
||||
traits::ConstU128,
|
||||
};
|
||||
use pezframe_support::{construct_runtime, derive_impl, parameter_types, traits::ConstU128};
|
||||
use pezframe_system::EnsureRoot;
|
||||
use pezsp_core::H256;
|
||||
use pezsp_runtime::BuildStorage;
|
||||
|
||||
@@ -141,9 +141,9 @@ fn finalize_epoch_calculates_rewards_correctly() {
|
||||
assert_ok!(PezRewards::record_trust_score(RuntimeOrigin::signed(bob()))); // 50
|
||||
assert_ok!(PezRewards::record_trust_score(RuntimeOrigin::signed(charlie()))); // 75
|
||||
let total_trust: u128 = 100 + 50 + 75;
|
||||
let expected_deadline = System::block_number() +
|
||||
crate::BLOCKS_PER_EPOCH as u64 +
|
||||
crate::CLAIM_PERIOD_BLOCKS as u64;
|
||||
let expected_deadline = System::block_number()
|
||||
+ crate::BLOCKS_PER_EPOCH as u64
|
||||
+ crate::CLAIM_PERIOD_BLOCKS as u64;
|
||||
|
||||
let incentive_pot = PezRewards::incentive_pot_account_id();
|
||||
let initial_pot_balance = pez_balance(&incentive_pot);
|
||||
|
||||
@@ -39,10 +39,10 @@ pub mod v1 {
|
||||
let has_genesis_done =
|
||||
if GenesisDistributionDone::<T>::get() { 1u64 } else { 0u64 };
|
||||
|
||||
let migrated = monthly_releases_count +
|
||||
has_halving_info +
|
||||
has_treasury_start +
|
||||
has_genesis_done;
|
||||
let migrated = monthly_releases_count
|
||||
+ has_halving_info
|
||||
+ has_treasury_start
|
||||
+ has_genesis_done;
|
||||
|
||||
// Update storage version
|
||||
STORAGE_VERSION.put::<Pezpallet<T>>();
|
||||
|
||||
@@ -220,8 +220,9 @@ pub mod pezpallet {
|
||||
fallback_max_weight: None,
|
||||
}]),
|
||||
) {
|
||||
Ok((hash, cost)) =>
|
||||
Self::deposit_event(Event::PongSent(para, seq, payload, hash, cost)),
|
||||
Ok((hash, cost)) => {
|
||||
Self::deposit_event(Event::PongSent(para, seq, payload, hash, cost))
|
||||
},
|
||||
Err(e) => Self::deposit_event(Event::ErrorSendingPong(e, para, seq, payload)),
|
||||
}
|
||||
Ok(())
|
||||
|
||||
@@ -52,16 +52,8 @@ mod benchmarks {
|
||||
let _ = T::Assets::mint_into(payment_asset, caller, payment_amount);
|
||||
|
||||
// Mint payment tokens to platform accounts for fee distribution
|
||||
let _ = T::Assets::mint_into(
|
||||
payment_asset,
|
||||
&T::PlatformTreasury::get(),
|
||||
payment_amount,
|
||||
);
|
||||
let _ = T::Assets::mint_into(
|
||||
payment_asset,
|
||||
&T::StakingRewardPool::get(),
|
||||
payment_amount,
|
||||
);
|
||||
let _ = T::Assets::mint_into(payment_asset, &T::PlatformTreasury::get(), payment_amount);
|
||||
let _ = T::Assets::mint_into(payment_asset, &T::StakingRewardPool::get(), payment_amount);
|
||||
|
||||
// Mint reward tokens to presale treasury for distribution
|
||||
let reward_amount: T::Balance = 10_000_000_000u128.into();
|
||||
@@ -289,8 +281,7 @@ mod benchmarks {
|
||||
let (payment_asset, reward_asset) = setup_benchmark_assets::<T>(&caller, &presale_treasury);
|
||||
|
||||
// Create presale (will get the presale_id we calculated)
|
||||
let _ =
|
||||
create_test_presale::<T>(&caller, payment_asset, reward_asset, false, false);
|
||||
let _ = create_test_presale::<T>(&caller, payment_asset, reward_asset, false, false);
|
||||
|
||||
// Make a contribution
|
||||
let amount: u128 = 10_000u128;
|
||||
@@ -325,13 +316,7 @@ mod benchmarks {
|
||||
let (payment_asset, reward_asset) = setup_benchmark_assets::<T>(&caller, &presale_treasury);
|
||||
|
||||
// Create presale (will get the presale_id we calculated)
|
||||
let _ = create_test_presale::<T>(
|
||||
&caller,
|
||||
payment_asset,
|
||||
reward_asset,
|
||||
false,
|
||||
false,
|
||||
);
|
||||
let _ = create_test_presale::<T>(&caller, payment_asset, reward_asset, false, false);
|
||||
|
||||
// Add n contributors
|
||||
for i in 0..n {
|
||||
@@ -382,7 +367,7 @@ mod benchmarks {
|
||||
limits: crate::ContributionLimits {
|
||||
min_contribution: 100u128,
|
||||
max_contribution: 10_000_000u128,
|
||||
soft_cap: 1_000_000_000_000u128, // very high - will fail
|
||||
soft_cap: 1_000_000_000_000u128, // very high - will fail
|
||||
hard_cap: 2_000_000_000_000u128,
|
||||
},
|
||||
vesting: None,
|
||||
|
||||
@@ -60,7 +60,18 @@ pub mod pezpallet {
|
||||
|
||||
pub type PresaleId = u32;
|
||||
|
||||
#[derive(Clone, Copy, Encode, Decode, DecodeWithMemTracking, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)]
|
||||
#[derive(
|
||||
Clone,
|
||||
Copy,
|
||||
Encode,
|
||||
Decode,
|
||||
DecodeWithMemTracking,
|
||||
Eq,
|
||||
PartialEq,
|
||||
RuntimeDebug,
|
||||
MaxEncodedLen,
|
||||
TypeInfo,
|
||||
)]
|
||||
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub enum PresaleStatus {
|
||||
Pending, // Not started yet
|
||||
@@ -72,7 +83,18 @@ pub mod pezpallet {
|
||||
Finalized, // Tokens distributed (after Successful)
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Encode, Decode, DecodeWithMemTracking, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)]
|
||||
#[derive(
|
||||
Clone,
|
||||
Copy,
|
||||
Encode,
|
||||
Decode,
|
||||
DecodeWithMemTracking,
|
||||
Eq,
|
||||
PartialEq,
|
||||
RuntimeDebug,
|
||||
MaxEncodedLen,
|
||||
TypeInfo,
|
||||
)]
|
||||
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[codec(dumb_trait_bound)]
|
||||
pub enum AccessControl {
|
||||
@@ -80,7 +102,18 @@ pub mod pezpallet {
|
||||
Whitelist, // Only whitelisted accounts
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Encode, Decode, DecodeWithMemTracking, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)]
|
||||
#[derive(
|
||||
Clone,
|
||||
Copy,
|
||||
Encode,
|
||||
Decode,
|
||||
DecodeWithMemTracking,
|
||||
Eq,
|
||||
PartialEq,
|
||||
RuntimeDebug,
|
||||
MaxEncodedLen,
|
||||
TypeInfo,
|
||||
)]
|
||||
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[codec(dumb_trait_bound)]
|
||||
pub struct BonusTier {
|
||||
@@ -90,7 +123,18 @@ pub mod pezpallet {
|
||||
pub bonus_percentage: u8,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Encode, Decode, DecodeWithMemTracking, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)]
|
||||
#[derive(
|
||||
Clone,
|
||||
Copy,
|
||||
Encode,
|
||||
Decode,
|
||||
DecodeWithMemTracking,
|
||||
Eq,
|
||||
PartialEq,
|
||||
RuntimeDebug,
|
||||
MaxEncodedLen,
|
||||
TypeInfo,
|
||||
)]
|
||||
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[codec(dumb_trait_bound)]
|
||||
pub struct VestingSchedule<BlockNumber> {
|
||||
@@ -102,7 +146,18 @@ pub mod pezpallet {
|
||||
pub cliff_blocks: BlockNumber,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Encode, Decode, DecodeWithMemTracking, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)]
|
||||
#[derive(
|
||||
Clone,
|
||||
Copy,
|
||||
Encode,
|
||||
Decode,
|
||||
DecodeWithMemTracking,
|
||||
Eq,
|
||||
PartialEq,
|
||||
RuntimeDebug,
|
||||
MaxEncodedLen,
|
||||
TypeInfo,
|
||||
)]
|
||||
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[codec(dumb_trait_bound)]
|
||||
pub struct ContributionLimits {
|
||||
@@ -116,7 +171,18 @@ pub mod pezpallet {
|
||||
pub hard_cap: u128,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Encode, Decode, DecodeWithMemTracking, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)]
|
||||
#[derive(
|
||||
Clone,
|
||||
Copy,
|
||||
Encode,
|
||||
Decode,
|
||||
DecodeWithMemTracking,
|
||||
Eq,
|
||||
PartialEq,
|
||||
RuntimeDebug,
|
||||
MaxEncodedLen,
|
||||
TypeInfo,
|
||||
)]
|
||||
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[codec(dumb_trait_bound)]
|
||||
pub struct RefundConfig<BlockNumber> {
|
||||
@@ -128,7 +194,18 @@ pub mod pezpallet {
|
||||
pub grace_refund_fee_percent: u8,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Encode, Decode, DecodeWithMemTracking, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)]
|
||||
#[derive(
|
||||
Clone,
|
||||
Copy,
|
||||
Encode,
|
||||
Decode,
|
||||
DecodeWithMemTracking,
|
||||
Eq,
|
||||
PartialEq,
|
||||
RuntimeDebug,
|
||||
MaxEncodedLen,
|
||||
TypeInfo,
|
||||
)]
|
||||
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[codec(dumb_trait_bound)]
|
||||
pub struct PresaleCreationParams<BlockNumber> {
|
||||
@@ -146,7 +223,18 @@ pub mod pezpallet {
|
||||
pub refund_config: RefundConfig<BlockNumber>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Encode, Decode, DecodeWithMemTracking, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)]
|
||||
#[derive(
|
||||
Clone,
|
||||
Copy,
|
||||
Encode,
|
||||
Decode,
|
||||
DecodeWithMemTracking,
|
||||
Eq,
|
||||
PartialEq,
|
||||
RuntimeDebug,
|
||||
MaxEncodedLen,
|
||||
TypeInfo,
|
||||
)]
|
||||
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[codec(dumb_trait_bound)]
|
||||
pub struct ContributionInfo<BlockNumber> {
|
||||
@@ -162,7 +250,17 @@ pub mod pezpallet {
|
||||
pub refund_fee_paid: u128,
|
||||
}
|
||||
|
||||
#[derive(Clone, Encode, Decode, DecodeWithMemTracking, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)]
|
||||
#[derive(
|
||||
Clone,
|
||||
Encode,
|
||||
Decode,
|
||||
DecodeWithMemTracking,
|
||||
Eq,
|
||||
PartialEq,
|
||||
RuntimeDebug,
|
||||
TypeInfo,
|
||||
MaxEncodedLen,
|
||||
)]
|
||||
#[scale_info(skip_type_params(T, MaxBonusTiers))]
|
||||
#[codec(mel_bound(T: Config, MaxBonusTiers: Get<u32>))]
|
||||
pub struct PresaleConfig<T: Config, MaxBonusTiers: Get<u32>> {
|
||||
@@ -428,9 +526,15 @@ pub mod pezpallet {
|
||||
|
||||
ensure!(params.tokens_for_sale > 0, Error::<T>::InvalidTokensForSale);
|
||||
ensure!(params.limits.soft_cap > 0, Error::<T>::InvalidTokensForSale);
|
||||
ensure!(params.limits.soft_cap <= params.limits.hard_cap, Error::<T>::InvalidTokensForSale);
|
||||
ensure!(
|
||||
params.limits.soft_cap <= params.limits.hard_cap,
|
||||
Error::<T>::InvalidTokensForSale
|
||||
);
|
||||
ensure!(params.refund_config.refund_fee_percent <= 100, Error::<T>::InvalidFeePercent);
|
||||
ensure!(params.refund_config.grace_refund_fee_percent <= 100, Error::<T>::InvalidFeePercent);
|
||||
ensure!(
|
||||
params.refund_config.grace_refund_fee_percent <= 100,
|
||||
Error::<T>::InvalidFeePercent
|
||||
);
|
||||
|
||||
let presale_id = NextPresaleId::<T>::get();
|
||||
let start_block = <pezframe_system::Pezpallet<T>>::block_number();
|
||||
@@ -639,8 +743,8 @@ pub mod pezpallet {
|
||||
// Handle vesting
|
||||
if let Some(ref vesting) = presale.vesting {
|
||||
let immediate = total_reward
|
||||
.saturating_mul(vesting.immediate_release_percent as u128) /
|
||||
100;
|
||||
.saturating_mul(vesting.immediate_release_percent as u128)
|
||||
/ 100;
|
||||
|
||||
if immediate > 0 {
|
||||
let immediate_balance: T::Balance = immediate.into();
|
||||
@@ -737,8 +841,7 @@ pub mod pezpallet {
|
||||
let treasury = Self::presale_account_id(presale_id);
|
||||
|
||||
// Step 1: Transfer refund amount to user
|
||||
let refund_amount_balance: T::Balance =
|
||||
refund_amount.into();
|
||||
let refund_amount_balance: T::Balance = refund_amount.into();
|
||||
T::Assets::transfer(
|
||||
presale.payment_asset,
|
||||
&treasury,
|
||||
@@ -819,10 +922,9 @@ pub mod pezpallet {
|
||||
let vested_percent = elapsed_u128.saturating_mul(100) / duration_u128;
|
||||
let immediate_percent = vesting.immediate_release_percent as u128;
|
||||
let vesting_percent = 100u128.saturating_sub(immediate_percent);
|
||||
let vested_amount = total_with_bonus
|
||||
.saturating_mul(vesting_percent)
|
||||
.saturating_mul(vested_percent) /
|
||||
10000;
|
||||
let vested_amount =
|
||||
total_with_bonus.saturating_mul(vesting_percent).saturating_mul(vested_percent)
|
||||
/ 10000;
|
||||
let total_unlocked = vested_amount.saturating_add(already_claimed);
|
||||
total_unlocked.saturating_sub(already_claimed)
|
||||
};
|
||||
@@ -831,8 +933,7 @@ pub mod pezpallet {
|
||||
|
||||
// Transfer tokens
|
||||
let treasury = Self::presale_account_id(presale_id);
|
||||
let claimable_balance: T::Balance =
|
||||
claimable.into();
|
||||
let claimable_balance: T::Balance = claimable.into();
|
||||
T::Assets::transfer(
|
||||
presale.reward_asset,
|
||||
&treasury,
|
||||
@@ -920,15 +1021,13 @@ pub mod pezpallet {
|
||||
// Calculate non-refundable portion (burn + stakers = 50% of platform fee)
|
||||
let platform_fee = contribution_info
|
||||
.amount
|
||||
.saturating_mul(T::PlatformFeePercent::get() as u128) /
|
||||
100;
|
||||
.saturating_mul(T::PlatformFeePercent::get() as u128)
|
||||
/ 100;
|
||||
let non_refundable = platform_fee.saturating_mul(50) / 100; // 1% (burn 25% + stakers 25%)
|
||||
|
||||
// Refund = 99% (contribution - non_refundable portion)
|
||||
let refund_amount: T::Balance = contribution_info
|
||||
.amount
|
||||
.saturating_sub(non_refundable)
|
||||
.into();
|
||||
let refund_amount: T::Balance =
|
||||
contribution_info.amount.saturating_sub(non_refundable).into();
|
||||
|
||||
T::Assets::transfer(
|
||||
presale.payment_asset,
|
||||
@@ -998,15 +1097,13 @@ pub mod pezpallet {
|
||||
// Calculate non-refundable portion (burn + stakers = 50% of platform fee)
|
||||
let platform_fee = contribution_info
|
||||
.amount
|
||||
.saturating_mul(T::PlatformFeePercent::get() as u128) /
|
||||
100;
|
||||
.saturating_mul(T::PlatformFeePercent::get() as u128)
|
||||
/ 100;
|
||||
let non_refundable = platform_fee.saturating_mul(50) / 100; // 1% (burn 25% + stakers 25%)
|
||||
|
||||
// Refund = 99% (contribution - non_refundable portion)
|
||||
let refund_amount: T::Balance = contribution_info
|
||||
.amount
|
||||
.saturating_sub(non_refundable)
|
||||
.into();
|
||||
let refund_amount: T::Balance =
|
||||
contribution_info.amount.saturating_sub(non_refundable).into();
|
||||
|
||||
T::Assets::transfer(
|
||||
presale.payment_asset,
|
||||
@@ -1082,12 +1179,9 @@ pub mod pezpallet {
|
||||
let to_burn = total_fee.saturating_mul(25) / 100; // 25%
|
||||
let to_stakers = total_fee.saturating_mul(25) / 100; // 25%
|
||||
|
||||
let to_treasury_balance: T::Balance =
|
||||
to_treasury.into();
|
||||
let to_burn_balance: T::Balance =
|
||||
to_burn.into();
|
||||
let to_stakers_balance: T::Balance =
|
||||
to_stakers.into();
|
||||
let to_treasury_balance: T::Balance = to_treasury.into();
|
||||
let to_burn_balance: T::Balance = to_burn.into();
|
||||
let to_stakers_balance: T::Balance = to_stakers.into();
|
||||
|
||||
// Note: Balance check removed - rely on Preservation::Expendable to handle insufficient
|
||||
// balance gracefully The operations below will transfer/burn as much as possible
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
use crate::{mock::*, Error, Event, PresaleStatus, ContributionLimits, VestingSchedule, RefundConfig, PresaleCreationParams};
|
||||
use crate::{
|
||||
mock::*, ContributionLimits, Error, Event, PresaleCreationParams, PresaleStatus, RefundConfig,
|
||||
VestingSchedule,
|
||||
};
|
||||
use pezframe_support::{assert_noop, assert_ok};
|
||||
|
||||
/// Helper function to create presale params with common defaults
|
||||
@@ -33,12 +36,7 @@ fn make_presale_params(
|
||||
tokens_for_sale,
|
||||
duration,
|
||||
is_whitelist,
|
||||
limits: ContributionLimits {
|
||||
min_contribution,
|
||||
max_contribution,
|
||||
soft_cap,
|
||||
hard_cap,
|
||||
},
|
||||
limits: ContributionLimits { min_contribution, max_contribution, soft_cap, hard_cap },
|
||||
vesting,
|
||||
refund_config: RefundConfig {
|
||||
grace_period_blocks,
|
||||
@@ -108,12 +106,48 @@ fn create_multiple_presales_works() {
|
||||
// Alice creates first presale
|
||||
assert_ok!(Presale::create_presale(
|
||||
RuntimeOrigin::signed(1),
|
||||
2, 1, make_presale_params(10_000_000_000_000_000_000, 100, false, 10_000_000, 1_000_000_000, 5_000_000_000, 10_000_000_000, false, 0, 0, 0, 24, 5, 2)));
|
||||
2,
|
||||
1,
|
||||
make_presale_params(
|
||||
10_000_000_000_000_000_000,
|
||||
100,
|
||||
false,
|
||||
10_000_000,
|
||||
1_000_000_000,
|
||||
5_000_000_000,
|
||||
10_000_000_000,
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
24,
|
||||
5,
|
||||
2
|
||||
)
|
||||
));
|
||||
|
||||
// Bob creates second presale
|
||||
assert_ok!(Presale::create_presale(
|
||||
RuntimeOrigin::signed(2),
|
||||
2, 1, make_presale_params(20_000_000_000_000_000_000, 200, false, 20_000_000, 2_000_000_000, 10_000_000_000, 20_000_000_000, false, 0, 0, 0, 48, 10, 5)));
|
||||
2,
|
||||
1,
|
||||
make_presale_params(
|
||||
20_000_000_000_000_000_000,
|
||||
200,
|
||||
false,
|
||||
20_000_000,
|
||||
2_000_000_000,
|
||||
10_000_000_000,
|
||||
20_000_000_000,
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
48,
|
||||
10,
|
||||
5
|
||||
)
|
||||
));
|
||||
|
||||
// Check both presales exist
|
||||
assert!(Presale::presales(0).is_some());
|
||||
@@ -137,7 +171,25 @@ fn contribute_works() {
|
||||
mint_assets(1, 1, 100_000_000_000_000_000_000);
|
||||
assert_ok!(Presale::create_presale(
|
||||
RuntimeOrigin::signed(1),
|
||||
2, 1, make_presale_params(10_000_000_000_000_000_000, 100, false, 10_000_000, 1_000_000_000, 5_000_000_000, 10_000_000_000, false, 0, 0, 0, 24, 5, 2)));
|
||||
2,
|
||||
1,
|
||||
make_presale_params(
|
||||
10_000_000_000_000_000_000,
|
||||
100,
|
||||
false,
|
||||
10_000_000,
|
||||
1_000_000_000,
|
||||
5_000_000_000,
|
||||
10_000_000_000,
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
24,
|
||||
5,
|
||||
2
|
||||
)
|
||||
));
|
||||
|
||||
// Mint wUSDT to Bob
|
||||
mint_assets(2, 2, 1_000_000_000); // 1000 USDT
|
||||
@@ -204,7 +256,25 @@ fn contribute_multiple_times_works() {
|
||||
|
||||
assert_ok!(Presale::create_presale(
|
||||
RuntimeOrigin::signed(1),
|
||||
2, 1, make_presale_params(10_000_000_000_000_000_000, 100, false, 10_000_000, 1_000_000_000, 5_000_000_000, 10_000_000_000, false, 0, 0, 0, 24, 5, 2)));
|
||||
2,
|
||||
1,
|
||||
make_presale_params(
|
||||
10_000_000_000_000_000_000,
|
||||
100,
|
||||
false,
|
||||
10_000_000,
|
||||
1_000_000_000,
|
||||
5_000_000_000,
|
||||
10_000_000_000,
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
24,
|
||||
5,
|
||||
2
|
||||
)
|
||||
));
|
||||
|
||||
// First contribution
|
||||
assert_ok!(Presale::contribute(RuntimeOrigin::signed(2), 0, 50_000_000));
|
||||
@@ -234,14 +304,50 @@ fn contribute_to_different_presales_works() {
|
||||
// Create two presales
|
||||
assert_ok!(Presale::create_presale(
|
||||
RuntimeOrigin::signed(1),
|
||||
2, 1, make_presale_params(10_000_000_000_000_000_000, 100, false, 10_000_000, 1_000_000_000, 5_000_000_000, 10_000_000_000, false, 0, 0, 0, 24, 5, 2)));
|
||||
2,
|
||||
1,
|
||||
make_presale_params(
|
||||
10_000_000_000_000_000_000,
|
||||
100,
|
||||
false,
|
||||
10_000_000,
|
||||
1_000_000_000,
|
||||
5_000_000_000,
|
||||
10_000_000_000,
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
24,
|
||||
5,
|
||||
2
|
||||
)
|
||||
));
|
||||
|
||||
// Fund presale 0 treasury with reward tokens
|
||||
mint_assets(1, presale_treasury(0), 10_000_000_000_000_000_000);
|
||||
|
||||
assert_ok!(Presale::create_presale(
|
||||
RuntimeOrigin::signed(1),
|
||||
2, 1, make_presale_params(15_000_000_000_000_000_000, 100, false, 10_000_000, 1_000_000_000, 5_000_000_000, 10_000_000_000, false, 0, 0, 0, 24, 5, 2)));
|
||||
2,
|
||||
1,
|
||||
make_presale_params(
|
||||
15_000_000_000_000_000_000,
|
||||
100,
|
||||
false,
|
||||
10_000_000,
|
||||
1_000_000_000,
|
||||
5_000_000_000,
|
||||
10_000_000_000,
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
24,
|
||||
5,
|
||||
2
|
||||
)
|
||||
));
|
||||
|
||||
// Fund presale 1 treasury with reward tokens
|
||||
mint_assets(1, presale_treasury(1), 15_000_000_000_000_000_000);
|
||||
@@ -279,7 +385,25 @@ fn contribute_below_min_fails() {
|
||||
|
||||
assert_ok!(Presale::create_presale(
|
||||
RuntimeOrigin::signed(1),
|
||||
2, 1, make_presale_params(10_000_000_000_000_000_000, 100, false, 10_000_000, 1_000_000_000, 5_000_000_000, 10_000_000_000, false, 0, 0, 0, 24, 5, 2)));
|
||||
2,
|
||||
1,
|
||||
make_presale_params(
|
||||
10_000_000_000_000_000_000,
|
||||
100,
|
||||
false,
|
||||
10_000_000,
|
||||
1_000_000_000,
|
||||
5_000_000_000,
|
||||
10_000_000_000,
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
24,
|
||||
5,
|
||||
2
|
||||
)
|
||||
));
|
||||
|
||||
// Try to contribute less than minimum (10 USDT)
|
||||
assert_noop!(
|
||||
@@ -298,7 +422,25 @@ fn contribute_above_max_fails() {
|
||||
|
||||
assert_ok!(Presale::create_presale(
|
||||
RuntimeOrigin::signed(1),
|
||||
2, 1, make_presale_params(10_000_000_000_000_000_000, 100, false, 10_000_000, 1_000_000_000, 5_000_000_000, 10_000_000_000, false, 0, 0, 0, 24, 5, 2)));
|
||||
2,
|
||||
1,
|
||||
make_presale_params(
|
||||
10_000_000_000_000_000_000,
|
||||
100,
|
||||
false,
|
||||
10_000_000,
|
||||
1_000_000_000,
|
||||
5_000_000_000,
|
||||
10_000_000_000,
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
24,
|
||||
5,
|
||||
2
|
||||
)
|
||||
));
|
||||
|
||||
// Try to contribute more than maximum (1000 USDT)
|
||||
assert_noop!(
|
||||
@@ -369,7 +511,25 @@ fn contribute_after_presale_ended_fails() {
|
||||
|
||||
assert_ok!(Presale::create_presale(
|
||||
RuntimeOrigin::signed(1),
|
||||
2, 1, make_presale_params(10_000_000_000_000_000_000, 100, false, 10_000_000, 1_000_000_000, 5_000_000_000, 10_000_000_000, false, 0, 0, 0, 24, 5, 2)));
|
||||
2,
|
||||
1,
|
||||
make_presale_params(
|
||||
10_000_000_000_000_000_000,
|
||||
100,
|
||||
false,
|
||||
10_000_000,
|
||||
1_000_000_000,
|
||||
5_000_000_000,
|
||||
10_000_000_000,
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
24,
|
||||
5,
|
||||
2
|
||||
)
|
||||
));
|
||||
|
||||
// Move past presale end (block 1 + 100 = 101)
|
||||
System::set_block_number(102);
|
||||
@@ -390,7 +550,25 @@ fn finalize_presale_works() {
|
||||
mint_assets(1, 1, 100_000_000_000_000_000_000); // 100,000 PEZ
|
||||
assert_ok!(Presale::create_presale(
|
||||
RuntimeOrigin::signed(1),
|
||||
2, 1, make_presale_params(10_000_000_000_000_000_000, 100, false, 10_000_000, 1_000_000_000, 5_000_000_000, 10_000_000_000, false, 0, 0, 0, 24, 5, 2)));
|
||||
2,
|
||||
1,
|
||||
make_presale_params(
|
||||
10_000_000_000_000_000_000,
|
||||
100,
|
||||
false,
|
||||
10_000_000,
|
||||
1_000_000_000,
|
||||
5_000_000_000,
|
||||
10_000_000_000,
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
24,
|
||||
5,
|
||||
2
|
||||
)
|
||||
));
|
||||
|
||||
// Mint PEZ to presale treasury for distribution
|
||||
let treasury = presale_treasury(0);
|
||||
@@ -428,8 +606,8 @@ fn finalize_presale_works() {
|
||||
let contributor_pez = Assets::balance(1, i);
|
||||
// Allow for small rounding differences (within 0.1%)
|
||||
assert!(
|
||||
contributor_pez >= expected_pez - 10_000_000_000_000_000 &&
|
||||
contributor_pez <= expected_pez + 10_000_000_000_000_000,
|
||||
contributor_pez >= expected_pez - 10_000_000_000_000_000
|
||||
&& contributor_pez <= expected_pez + 10_000_000_000_000_000,
|
||||
"Contributor {i} PEZ: {contributor_pez} (expected ~{expected_pez})"
|
||||
);
|
||||
}
|
||||
@@ -449,7 +627,25 @@ fn finalize_presale_before_end_fails() {
|
||||
|
||||
assert_ok!(Presale::create_presale(
|
||||
RuntimeOrigin::signed(1),
|
||||
2, 1, make_presale_params(10_000_000_000_000_000_000, 100, false, 10_000_000, 1_000_000_000, 5_000_000_000, 10_000_000_000, false, 0, 0, 0, 24, 5, 2)));
|
||||
2,
|
||||
1,
|
||||
make_presale_params(
|
||||
10_000_000_000_000_000_000,
|
||||
100,
|
||||
false,
|
||||
10_000_000,
|
||||
1_000_000_000,
|
||||
5_000_000_000,
|
||||
10_000_000_000,
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
24,
|
||||
5,
|
||||
2
|
||||
)
|
||||
));
|
||||
|
||||
// Try to finalize immediately (use root to test the actual business logic error)
|
||||
assert_noop!(
|
||||
@@ -467,7 +663,25 @@ fn finalize_presale_non_root_fails() {
|
||||
|
||||
assert_ok!(Presale::create_presale(
|
||||
RuntimeOrigin::signed(1),
|
||||
2, 1, make_presale_params(10_000_000_000_000_000_000, 100, false, 10_000_000, 1_000_000_000, 5_000_000_000, 10_000_000_000, false, 0, 0, 0, 24, 5, 2)));
|
||||
2,
|
||||
1,
|
||||
make_presale_params(
|
||||
10_000_000_000_000_000_000,
|
||||
100,
|
||||
false,
|
||||
10_000_000,
|
||||
1_000_000_000,
|
||||
5_000_000_000,
|
||||
10_000_000_000,
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
24,
|
||||
5,
|
||||
2
|
||||
)
|
||||
));
|
||||
|
||||
System::set_block_number(101);
|
||||
|
||||
@@ -488,7 +702,25 @@ fn refund_works() {
|
||||
|
||||
assert_ok!(Presale::create_presale(
|
||||
RuntimeOrigin::signed(1),
|
||||
2, 1, make_presale_params(10_000_000_000_000_000_000, 100, false, 10_000_000, 1_000_000_000, 5_000_000_000, 10_000_000_000, false, 0, 0, 0, 24, 5, 2)));
|
||||
2,
|
||||
1,
|
||||
make_presale_params(
|
||||
10_000_000_000_000_000_000,
|
||||
100,
|
||||
false,
|
||||
10_000_000,
|
||||
1_000_000_000,
|
||||
5_000_000_000,
|
||||
10_000_000_000,
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
24,
|
||||
5,
|
||||
2
|
||||
)
|
||||
));
|
||||
|
||||
// Bob contributes
|
||||
let contribution = 100_000_000; // 100 USDT
|
||||
@@ -596,7 +828,25 @@ fn refund_with_no_contribution_fails() {
|
||||
|
||||
assert_ok!(Presale::create_presale(
|
||||
RuntimeOrigin::signed(1),
|
||||
2, 1, make_presale_params(10_000_000_000_000_000_000, 100, false, 10_000_000, 1_000_000_000, 5_000_000_000, 10_000_000_000, false, 0, 0, 0, 24, 5, 2)));
|
||||
2,
|
||||
1,
|
||||
make_presale_params(
|
||||
10_000_000_000_000_000_000,
|
||||
100,
|
||||
false,
|
||||
10_000_000,
|
||||
1_000_000_000,
|
||||
5_000_000_000,
|
||||
10_000_000_000,
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
24,
|
||||
5,
|
||||
2
|
||||
)
|
||||
));
|
||||
|
||||
// Bob tries to refund without contributing
|
||||
assert_noop!(Presale::refund(RuntimeOrigin::signed(2), 0), Error::<Test>::NoContribution);
|
||||
@@ -612,7 +862,25 @@ fn cancel_presale_works() {
|
||||
|
||||
assert_ok!(Presale::create_presale(
|
||||
RuntimeOrigin::signed(1),
|
||||
2, 1, make_presale_params(10_000_000_000_000_000_000, 100, false, 10_000_000, 1_000_000_000, 5_000_000_000, 10_000_000_000, false, 0, 0, 0, 24, 5, 2)));
|
||||
2,
|
||||
1,
|
||||
make_presale_params(
|
||||
10_000_000_000_000_000_000,
|
||||
100,
|
||||
false,
|
||||
10_000_000,
|
||||
1_000_000_000,
|
||||
5_000_000_000,
|
||||
10_000_000_000,
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
24,
|
||||
5,
|
||||
2
|
||||
)
|
||||
));
|
||||
|
||||
// Bob contributes
|
||||
assert_ok!(Presale::contribute(RuntimeOrigin::signed(2), 0, 100_000_000));
|
||||
@@ -637,7 +905,25 @@ fn cancel_presale_non_authorized_fails() {
|
||||
|
||||
assert_ok!(Presale::create_presale(
|
||||
RuntimeOrigin::signed(1),
|
||||
2, 1, make_presale_params(10_000_000_000_000_000_000, 100, false, 10_000_000, 1_000_000_000, 5_000_000_000, 10_000_000_000, false, 0, 0, 0, 24, 5, 2)));
|
||||
2,
|
||||
1,
|
||||
make_presale_params(
|
||||
10_000_000_000_000_000_000,
|
||||
100,
|
||||
false,
|
||||
10_000_000,
|
||||
1_000_000_000,
|
||||
5_000_000_000,
|
||||
10_000_000_000,
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
24,
|
||||
5,
|
||||
2
|
||||
)
|
||||
));
|
||||
|
||||
// Non-authorized user tries to cancel (needs EmergencyOrigin or Root)
|
||||
assert_noop!(
|
||||
@@ -655,7 +941,25 @@ fn emergency_cancel_by_root_works() {
|
||||
|
||||
assert_ok!(Presale::create_presale(
|
||||
RuntimeOrigin::signed(1),
|
||||
2, 1, make_presale_params(10_000_000_000_000_000_000, 100, false, 10_000_000, 1_000_000_000, 5_000_000_000, 10_000_000_000, false, 0, 0, 0, 24, 5, 2)));
|
||||
2,
|
||||
1,
|
||||
make_presale_params(
|
||||
10_000_000_000_000_000_000,
|
||||
100,
|
||||
false,
|
||||
10_000_000,
|
||||
1_000_000_000,
|
||||
5_000_000_000,
|
||||
10_000_000_000,
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
24,
|
||||
5,
|
||||
2
|
||||
)
|
||||
));
|
||||
|
||||
// Root can cancel any presale (emergency)
|
||||
assert_ok!(Presale::cancel_presale(RuntimeOrigin::root(), 0));
|
||||
@@ -675,8 +979,25 @@ fn whitelist_presale_works() {
|
||||
// Create whitelist presale
|
||||
assert_ok!(Presale::create_presale(
|
||||
RuntimeOrigin::signed(1),
|
||||
2, 1, make_presale_params(10_000_000_000_000_000_000, 100, true, // whitelist enabled
|
||||
10_000_000, 1_000_000_000, 5_000_000_000, 10_000_000_000, false, 0, 0, 0, 24, 5, 2)));
|
||||
2,
|
||||
1,
|
||||
make_presale_params(
|
||||
10_000_000_000_000_000_000,
|
||||
100,
|
||||
true, // whitelist enabled
|
||||
10_000_000,
|
||||
1_000_000_000,
|
||||
5_000_000_000,
|
||||
10_000_000_000,
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
24,
|
||||
5,
|
||||
2
|
||||
)
|
||||
));
|
||||
|
||||
// Bob tries to contribute (not whitelisted)
|
||||
assert_noop!(
|
||||
@@ -700,7 +1021,25 @@ fn add_to_whitelist_non_owner_fails() {
|
||||
|
||||
assert_ok!(Presale::create_presale(
|
||||
RuntimeOrigin::signed(1),
|
||||
2, 1, make_presale_params(10_000_000_000_000_000_000, 100, true, 10_000_000, 1_000_000_000, 5_000_000_000, 10_000_000_000, false, 0, 0, 0, 24, 5, 2)));
|
||||
2,
|
||||
1,
|
||||
make_presale_params(
|
||||
10_000_000_000_000_000_000,
|
||||
100,
|
||||
true,
|
||||
10_000_000,
|
||||
1_000_000_000,
|
||||
5_000_000_000,
|
||||
10_000_000_000,
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
24,
|
||||
5,
|
||||
2
|
||||
)
|
||||
));
|
||||
|
||||
// Charlie tries to add Bob to Alice's presale whitelist
|
||||
assert_noop!(
|
||||
@@ -722,7 +1061,25 @@ fn finalize_presale_soft_cap_reached_success() {
|
||||
mint_assets(1, 1, 100_000_000_000_000_000_000); // 100,000 PEZ
|
||||
assert_ok!(Presale::create_presale(
|
||||
RuntimeOrigin::signed(1),
|
||||
2, 1, make_presale_params(10_000_000_000_000_000_000, 100, false, 10_000_000, 1_000_000_000, 5_000_000_000, 10_000_000_000, false, 0, 0, 0, 24, 5, 2)));
|
||||
2,
|
||||
1,
|
||||
make_presale_params(
|
||||
10_000_000_000_000_000_000,
|
||||
100,
|
||||
false,
|
||||
10_000_000,
|
||||
1_000_000_000,
|
||||
5_000_000_000,
|
||||
10_000_000_000,
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
24,
|
||||
5,
|
||||
2
|
||||
)
|
||||
));
|
||||
|
||||
// Mint PEZ to presale treasury
|
||||
let treasury = presale_treasury(0);
|
||||
@@ -769,7 +1126,25 @@ fn finalize_presale_soft_cap_not_reached_fails() {
|
||||
mint_assets(1, 1, 100_000_000_000_000_000_000);
|
||||
assert_ok!(Presale::create_presale(
|
||||
RuntimeOrigin::signed(1),
|
||||
2, 1, make_presale_params(10_000_000_000_000_000_000, 100, false, 10_000_000, 1_000_000_000, 5_000_000_000, 10_000_000_000, false, 0, 0, 0, 24, 5, 2)));
|
||||
2,
|
||||
1,
|
||||
make_presale_params(
|
||||
10_000_000_000_000_000_000,
|
||||
100,
|
||||
false,
|
||||
10_000_000,
|
||||
1_000_000_000,
|
||||
5_000_000_000,
|
||||
10_000_000_000,
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
24,
|
||||
5,
|
||||
2
|
||||
)
|
||||
));
|
||||
|
||||
// Contributors below soft cap (max is 1000 USDT each)
|
||||
// Need to contribute less than soft cap of 5000 USDT
|
||||
@@ -811,7 +1186,25 @@ fn batch_refund_failed_presale_works() {
|
||||
mint_assets(1, 1, 100_000_000_000_000_000_000);
|
||||
assert_ok!(Presale::create_presale(
|
||||
RuntimeOrigin::signed(1),
|
||||
2, 1, make_presale_params(10_000_000_000_000_000_000, 100, false, 10_000_000, 1_000_000_000, 5_000_000_000, 10_000_000_000, false, 0, 0, 0, 24, 5, 2)));
|
||||
2,
|
||||
1,
|
||||
make_presale_params(
|
||||
10_000_000_000_000_000_000,
|
||||
100,
|
||||
false,
|
||||
10_000_000,
|
||||
1_000_000_000,
|
||||
5_000_000_000,
|
||||
10_000_000_000,
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
24,
|
||||
5,
|
||||
2
|
||||
)
|
||||
));
|
||||
|
||||
// Fund presale treasury with wUSDT for refunds
|
||||
let treasury = presale_treasury(0);
|
||||
@@ -864,7 +1257,25 @@ fn batch_refund_successful_presale_fails() {
|
||||
mint_assets(1, 1, 100_000_000_000_000_000_000);
|
||||
assert_ok!(Presale::create_presale(
|
||||
RuntimeOrigin::signed(1),
|
||||
2, 1, make_presale_params(10_000_000_000_000_000_000, 100, false, 10_000_000, 1_000_000_000, 5_000_000_000, 10_000_000_000, false, 0, 0, 0, 24, 5, 2)));
|
||||
2,
|
||||
1,
|
||||
make_presale_params(
|
||||
10_000_000_000_000_000_000,
|
||||
100,
|
||||
false,
|
||||
10_000_000,
|
||||
1_000_000_000,
|
||||
5_000_000_000,
|
||||
10_000_000_000,
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
24,
|
||||
5,
|
||||
2
|
||||
)
|
||||
));
|
||||
|
||||
let treasury = presale_treasury(0);
|
||||
mint_assets(1, treasury, 100_000_000_000_000_000_000);
|
||||
@@ -906,7 +1317,25 @@ fn create_presale_with_soft_cap_greater_than_hard_cap_fails() {
|
||||
assert_noop!(
|
||||
Presale::create_presale(
|
||||
RuntimeOrigin::signed(1),
|
||||
2, 1, make_presale_params(10_000_000_000_000_000_000, 100, false, 10_000_000, 1_000_000_000, 15_000_000_000, 10_000_000_000, false, 0, 0, 0, 24, 5, 2)),
|
||||
2,
|
||||
1,
|
||||
make_presale_params(
|
||||
10_000_000_000_000_000_000,
|
||||
100,
|
||||
false,
|
||||
10_000_000,
|
||||
1_000_000_000,
|
||||
15_000_000_000,
|
||||
10_000_000_000,
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
24,
|
||||
5,
|
||||
2
|
||||
)
|
||||
),
|
||||
Error::<Test>::InvalidTokensForSale
|
||||
);
|
||||
});
|
||||
@@ -925,7 +1354,25 @@ fn debug_finalize_presale() {
|
||||
// Create presale
|
||||
assert_ok!(Presale::create_presale(
|
||||
RuntimeOrigin::signed(1),
|
||||
2, 1, make_presale_params(10_000_000_000, 100, false, 10_000_000, 1_000_000_000, 5_000_000_000, 10_000_000_000, false, 0, 0, 0, 24, 5, 2)));
|
||||
2,
|
||||
1,
|
||||
make_presale_params(
|
||||
10_000_000_000,
|
||||
100,
|
||||
false,
|
||||
10_000_000,
|
||||
1_000_000_000,
|
||||
5_000_000_000,
|
||||
10_000_000_000,
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
24,
|
||||
5,
|
||||
2
|
||||
)
|
||||
));
|
||||
|
||||
// Fund presale treasury with reward tokens
|
||||
let treasury = presale_treasury(0);
|
||||
|
||||
@@ -266,8 +266,8 @@ pub mod pezpallet {
|
||||
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::Pezpallet::<T>::get_kyc_status(who) ==
|
||||
pezpallet_identity_kyc::types::KycLevel::Approved
|
||||
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)
|
||||
if Referrals::<T>::contains_key(who) {
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
// pezkuwi/pallets/referral/src/mock.rs (Updated for new trustless model)
|
||||
|
||||
use crate as pezpallet_referral;
|
||||
use pezframe_support::{
|
||||
construct_runtime, derive_impl, parameter_types,
|
||||
traits::ConstU128,
|
||||
};
|
||||
use pezframe_support::{construct_runtime, derive_impl, parameter_types, traits::ConstU128};
|
||||
use pezframe_system::EnsureRoot;
|
||||
use pezsp_core::H256;
|
||||
use pezsp_runtime::BuildStorage;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use crate::{
|
||||
mock::*, Error, Event, PendingReferrals, ReferralCount, Referrals,
|
||||
ReferrerStatsStorage,
|
||||
mock::*, Error, Event, PendingReferrals, ReferralCount, Referrals, ReferrerStatsStorage,
|
||||
};
|
||||
use pezframe_support::{assert_noop, assert_ok};
|
||||
use pezpallet_identity_kyc::types::{OnCitizenshipRevoked, OnKycApproved};
|
||||
|
||||
@@ -261,13 +261,15 @@ impl ExtBuilder {
|
||||
invulnerables: self
|
||||
.stakers
|
||||
.iter()
|
||||
.filter_map(|(stash, _, _, status)| {
|
||||
if let StakerStatus::Validator = status {
|
||||
Some(*stash)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.filter_map(
|
||||
|(stash, _, _, status)| {
|
||||
if let StakerStatus::Validator = status {
|
||||
Some(*stash)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
},
|
||||
)
|
||||
.collect(),
|
||||
force_era: pezpallet_staking::Forcing::ForceNew, // Yeni era başlatmaya zorla
|
||||
min_nominator_bond: MinNominatorBond::get(), // Tanımlanan minimum değerleri kullan
|
||||
|
||||
@@ -49,7 +49,9 @@ mod benchmarks {
|
||||
}
|
||||
|
||||
// Helper to ensure user has a citizen NFT
|
||||
fn ensure_citizen_nft<T: Config + pezpallet_balances::Config>(who: T::AccountId) -> Result<(), DispatchError>
|
||||
fn ensure_citizen_nft<T: Config + pezpallet_balances::Config>(
|
||||
who: T::AccountId,
|
||||
) -> Result<(), DispatchError>
|
||||
where
|
||||
T::CollectionId: Default + PartialOrd,
|
||||
{
|
||||
|
||||
@@ -677,15 +677,16 @@ pub mod pezpallet {
|
||||
Tiki::Welati => RoleAssignmentType::Automatic,
|
||||
|
||||
// Elected roles
|
||||
Tiki::Parlementer | Tiki::SerokiMeclise | Tiki::Serok =>
|
||||
RoleAssignmentType::Elected,
|
||||
Tiki::Parlementer | Tiki::SerokiMeclise | Tiki::Serok => {
|
||||
RoleAssignmentType::Elected
|
||||
},
|
||||
|
||||
// Earned roles (automatically given by pezpallet-referral)
|
||||
Tiki::Axa |
|
||||
Tiki::Mamoste |
|
||||
Tiki::Rewsenbîr |
|
||||
Tiki::SerokêKomele |
|
||||
Tiki::ModeratorêCivakê => RoleAssignmentType::Earned,
|
||||
Tiki::Axa
|
||||
| Tiki::Mamoste
|
||||
| Tiki::Rewsenbîr
|
||||
| Tiki::SerokêKomele
|
||||
| Tiki::ModeratorêCivakê => RoleAssignmentType::Earned,
|
||||
|
||||
// Appointed roles (default)
|
||||
_ => RoleAssignmentType::Appointed,
|
||||
|
||||
@@ -101,9 +101,7 @@ pub mod v1 {
|
||||
let post_tiki_holder_count = TikiHolder::<T>::iter().count() as u32;
|
||||
|
||||
log::info!(" CitizenNft entries: {pre_citizen_count} -> {post_citizen_count}");
|
||||
log::info!(
|
||||
" UserTikis entries: {pre_user_tikis_count} -> {post_user_tikis_count}"
|
||||
);
|
||||
log::info!(" UserTikis entries: {pre_user_tikis_count} -> {post_user_tikis_count}");
|
||||
log::info!(
|
||||
" TikiHolder entries: {pre_tiki_holder_count} -> {post_tiki_holder_count}"
|
||||
);
|
||||
|
||||
@@ -20,10 +20,13 @@ use pezsp_runtime::RuntimeAppPublic;
|
||||
pub struct IdentityBenchmarkHelper;
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
impl pezpallet_identity::BenchmarkHelper<UintAuthorityId, TestSignature> for IdentityBenchmarkHelper {
|
||||
impl pezpallet_identity::BenchmarkHelper<UintAuthorityId, TestSignature>
|
||||
for IdentityBenchmarkHelper
|
||||
{
|
||||
fn sign_message(message: &[u8]) -> (UintAuthorityId, TestSignature) {
|
||||
let signer = UintAuthorityId(0);
|
||||
let signature = <UintAuthorityId as RuntimeAppPublic>::sign(&signer, &message.to_vec()).unwrap();
|
||||
let signature =
|
||||
<UintAuthorityId as RuntimeAppPublic>::sign(&signer, &message.to_vec()).unwrap();
|
||||
(signer, signature)
|
||||
}
|
||||
}
|
||||
@@ -33,7 +36,9 @@ impl pezpallet_identity::BenchmarkHelper<UintAuthorityId, TestSignature> for Ide
|
||||
pub struct NftsBenchmarkHelper;
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
impl pezpallet_nfts::BenchmarkHelper<u32, u32, UintAuthorityId, AccountId, TestSignature> for NftsBenchmarkHelper {
|
||||
impl pezpallet_nfts::BenchmarkHelper<u32, u32, UintAuthorityId, AccountId, TestSignature>
|
||||
for NftsBenchmarkHelper
|
||||
{
|
||||
fn collection(i: u16) -> u32 {
|
||||
i.into()
|
||||
}
|
||||
|
||||
@@ -49,11 +49,7 @@ fn grant_appointed_role_works() {
|
||||
assert_ok!(TikiPallet::force_mint_citizen_nft(RuntimeOrigin::root(), user_account));
|
||||
|
||||
// Tiki ver
|
||||
assert_ok!(TikiPallet::grant_tiki(
|
||||
RuntimeOrigin::root(),
|
||||
user_account,
|
||||
tiki_to_grant
|
||||
));
|
||||
assert_ok!(TikiPallet::grant_tiki(RuntimeOrigin::root(), user_account, tiki_to_grant));
|
||||
|
||||
// Kullanıcının rollerini kontrol et
|
||||
let user_tikis = TikiPallet::user_tikis(user_account);
|
||||
@@ -189,11 +185,7 @@ fn grant_earned_role_works() {
|
||||
assert_ok!(TikiPallet::force_mint_citizen_nft(RuntimeOrigin::root(), user_account));
|
||||
|
||||
// Earned rolü ver
|
||||
assert_ok!(TikiPallet::grant_earned_role(
|
||||
RuntimeOrigin::root(),
|
||||
user_account,
|
||||
earned_role
|
||||
));
|
||||
assert_ok!(TikiPallet::grant_earned_role(RuntimeOrigin::root(), user_account, earned_role));
|
||||
|
||||
// Rolün eklendiğini kontrol et
|
||||
assert!(TikiPallet::user_tikis(user_account).contains(&earned_role));
|
||||
@@ -237,11 +229,7 @@ fn unique_roles_work_correctly() {
|
||||
assert_ok!(TikiPallet::force_mint_citizen_nft(RuntimeOrigin::root(), user2));
|
||||
|
||||
// İlk kullanıcıya unique rolü ver (elected role olarak)
|
||||
assert_ok!(TikiPallet::grant_elected_role(
|
||||
RuntimeOrigin::root(),
|
||||
user1,
|
||||
unique_role
|
||||
));
|
||||
assert_ok!(TikiPallet::grant_elected_role(RuntimeOrigin::root(), user1, unique_role));
|
||||
|
||||
// İkinci kullanıcıya aynı rolü vermeye çalış
|
||||
assert_noop!(
|
||||
@@ -279,21 +267,13 @@ fn revoke_tiki_works() {
|
||||
|
||||
// NFT bas ve role ver
|
||||
assert_ok!(TikiPallet::force_mint_citizen_nft(RuntimeOrigin::root(), user_account));
|
||||
assert_ok!(TikiPallet::grant_tiki(
|
||||
RuntimeOrigin::root(),
|
||||
user_account,
|
||||
tiki_to_revoke
|
||||
));
|
||||
assert_ok!(TikiPallet::grant_tiki(RuntimeOrigin::root(), user_account, tiki_to_revoke));
|
||||
|
||||
// Rolün eklendiğini kontrol et
|
||||
assert!(TikiPallet::user_tikis(user_account).contains(&tiki_to_revoke));
|
||||
|
||||
// Rolü kaldır
|
||||
assert_ok!(TikiPallet::revoke_tiki(
|
||||
RuntimeOrigin::root(),
|
||||
user_account,
|
||||
tiki_to_revoke
|
||||
));
|
||||
assert_ok!(TikiPallet::revoke_tiki(RuntimeOrigin::root(), user_account, tiki_to_revoke));
|
||||
|
||||
// Rolün kaldırıldığını kontrol et
|
||||
assert!(!TikiPallet::user_tikis(user_account).contains(&tiki_to_revoke));
|
||||
@@ -332,11 +312,7 @@ fn revoke_unique_role_clears_holder() {
|
||||
|
||||
// NFT bas ve unique rolü ver
|
||||
assert_ok!(TikiPallet::force_mint_citizen_nft(RuntimeOrigin::root(), user));
|
||||
assert_ok!(TikiPallet::grant_elected_role(
|
||||
RuntimeOrigin::root(),
|
||||
user,
|
||||
unique_role
|
||||
));
|
||||
assert_ok!(TikiPallet::grant_elected_role(RuntimeOrigin::root(), user, unique_role));
|
||||
|
||||
// TikiHolder'da kayıtlı olduğunu kontrol et
|
||||
assert_eq!(TikiPallet::tiki_holder(unique_role), Some(user));
|
||||
|
||||
@@ -152,7 +152,9 @@ pub mod pezpallet {
|
||||
pub struct Pezpallet<T>(_);
|
||||
|
||||
#[pezpallet::config]
|
||||
pub trait Config: pezframe_system::Config<RuntimeEvent: From<Event<Self>>> + pezpallet_identity_kyc::Config {
|
||||
pub trait Config:
|
||||
pezframe_system::Config<RuntimeEvent: From<Event<Self>>> + pezpallet_identity_kyc::Config
|
||||
{
|
||||
type WeightInfo: WeightInfo;
|
||||
|
||||
type Score: Member
|
||||
|
||||
@@ -303,8 +303,8 @@ fn update_all_trust_scores_emits_event() {
|
||||
|
||||
let events = System::events();
|
||||
let bulk_update_event = events.iter().any(|event| {
|
||||
matches!(event.event, RuntimeEvent::TrustPallet(Event::BulkTrustScoreUpdate { .. })) ||
|
||||
matches!(
|
||||
matches!(event.event, RuntimeEvent::TrustPallet(Event::BulkTrustScoreUpdate { .. }))
|
||||
|| matches!(
|
||||
event.event,
|
||||
RuntimeEvent::TrustPallet(Event::AllTrustScoresUpdated { .. })
|
||||
)
|
||||
@@ -412,7 +412,6 @@ fn multiple_users_independent_scores() {
|
||||
#[test]
|
||||
fn trust_score_provider_trait_returns_zero_initially() {
|
||||
new_test_ext().execute_with(|| {
|
||||
|
||||
let account = 1u64;
|
||||
let score = TrustPallet::trust_score_of(account);
|
||||
assert_eq!(score, 0);
|
||||
@@ -422,7 +421,6 @@ fn trust_score_provider_trait_returns_zero_initially() {
|
||||
#[test]
|
||||
fn trust_score_provider_trait_returns_updated_score() {
|
||||
new_test_ext().execute_with(|| {
|
||||
|
||||
let account = 1u64;
|
||||
TrustPallet::update_score_for_account(&account).unwrap();
|
||||
|
||||
@@ -434,7 +432,6 @@ fn trust_score_provider_trait_returns_updated_score() {
|
||||
#[test]
|
||||
fn trust_score_provider_trait_multiple_users() {
|
||||
new_test_ext().execute_with(|| {
|
||||
|
||||
TrustPallet::update_score_for_account(&1u64).unwrap();
|
||||
TrustPallet::update_score_for_account(&2u64).unwrap();
|
||||
|
||||
|
||||
@@ -928,9 +928,7 @@ pub mod pezpallet {
|
||||
|
||||
// Create appointment process
|
||||
let documents: BoundedVec<BoundedVec<u8, ConstU32<1000>>, ConstU32<10>> =
|
||||
vec![justification]
|
||||
.try_into()
|
||||
.map_err(|_| Error::<T>::CalculationOverflow)?;
|
||||
vec![justification].try_into().map_err(|_| Error::<T>::CalculationOverflow)?;
|
||||
|
||||
let appointment_process = AppointmentProcess {
|
||||
process_id,
|
||||
@@ -1099,9 +1097,9 @@ pub mod pezpallet {
|
||||
|
||||
// For Parliament decisions, voter must be a parliament member
|
||||
match proposal.decision_type {
|
||||
CollectiveDecisionType::ParliamentSimpleMajority |
|
||||
CollectiveDecisionType::ParliamentSuperMajority |
|
||||
CollectiveDecisionType::ParliamentAbsoluteMajority => {
|
||||
CollectiveDecisionType::ParliamentSimpleMajority
|
||||
| CollectiveDecisionType::ParliamentSuperMajority
|
||||
| CollectiveDecisionType::ParliamentAbsoluteMajority => {
|
||||
// Check if voter is in parliament
|
||||
let members = ParliamentMembers::<T>::get();
|
||||
let is_member = members.iter().any(|m| m.account == voter);
|
||||
@@ -1127,12 +1125,15 @@ pub mod pezpallet {
|
||||
ActiveProposals::<T>::mutate(proposal_id, |proposal_opt| {
|
||||
if let Some(proposal) = proposal_opt {
|
||||
match vote {
|
||||
VoteChoice::Aye =>
|
||||
proposal.aye_votes = proposal.aye_votes.saturating_add(1),
|
||||
VoteChoice::Nay =>
|
||||
proposal.nay_votes = proposal.nay_votes.saturating_add(1),
|
||||
VoteChoice::Abstain =>
|
||||
proposal.abstain_votes = proposal.abstain_votes.saturating_add(1),
|
||||
VoteChoice::Aye => {
|
||||
proposal.aye_votes = proposal.aye_votes.saturating_add(1)
|
||||
},
|
||||
VoteChoice::Nay => {
|
||||
proposal.nay_votes = proposal.nay_votes.saturating_add(1)
|
||||
},
|
||||
VoteChoice::Abstain => {
|
||||
proposal.abstain_votes = proposal.abstain_votes.saturating_add(1)
|
||||
},
|
||||
}
|
||||
proposal.votes_cast = proposal.votes_cast.saturating_add(1);
|
||||
}
|
||||
@@ -1350,14 +1351,15 @@ pub mod pezpallet {
|
||||
winners: &[T::AccountId],
|
||||
) -> Result<(), Error<T>> {
|
||||
match election_type {
|
||||
ElectionType::Presidential =>
|
||||
ElectionType::Presidential => {
|
||||
if let Some(winner) = winners.first() {
|
||||
CurrentOfficials::<T>::insert(GovernmentPosition::Serok, winner);
|
||||
},
|
||||
}
|
||||
},
|
||||
ElectionType::Parliamentary => {
|
||||
let current_block = pezframe_system::Pezpallet::<T>::block_number();
|
||||
let term_end = current_block +
|
||||
BlockNumberFor::<T>::from(4u32 * 365u32 * 24u32 * 60u32 * 10u32);
|
||||
let term_end = current_block
|
||||
+ BlockNumberFor::<T>::from(4u32 * 365u32 * 24u32 * 60u32 * 10u32);
|
||||
|
||||
let parliament_members: Result<BoundedVec<_, _>, _> = winners
|
||||
.iter()
|
||||
@@ -1382,10 +1384,11 @@ pub mod pezpallet {
|
||||
term_start: current_block,
|
||||
});
|
||||
},
|
||||
ElectionType::SpeakerElection =>
|
||||
ElectionType::SpeakerElection => {
|
||||
if let Some(winner) = winners.first() {
|
||||
CurrentOfficials::<T>::insert(GovernmentPosition::MeclisBaskanı, winner);
|
||||
},
|
||||
}
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
Ok(())
|
||||
@@ -1397,15 +1400,16 @@ pub mod pezpallet {
|
||||
decision_type: &CollectiveDecisionType,
|
||||
) -> Result<bool, Error<T>> {
|
||||
match decision_type {
|
||||
CollectiveDecisionType::ExecutiveDecision =>
|
||||
Ok(CurrentOfficials::<T>::get(GovernmentPosition::Serok) ==
|
||||
Some(proposer.clone())),
|
||||
CollectiveDecisionType::ExecutiveDecision => {
|
||||
Ok(CurrentOfficials::<T>::get(GovernmentPosition::Serok)
|
||||
== Some(proposer.clone()))
|
||||
},
|
||||
_ => {
|
||||
let is_parliamentarian = ParliamentMembers::<T>::get()
|
||||
.iter()
|
||||
.any(|member| member.account == *proposer);
|
||||
let is_president = CurrentOfficials::<T>::get(GovernmentPosition::Serok) ==
|
||||
Some(proposer.clone());
|
||||
let is_president = CurrentOfficials::<T>::get(GovernmentPosition::Serok)
|
||||
== Some(proposer.clone());
|
||||
|
||||
Ok(is_parliamentarian || is_president)
|
||||
},
|
||||
@@ -1415,12 +1419,15 @@ pub mod pezpallet {
|
||||
/// Calculate voting threshold
|
||||
fn get_voting_threshold(decision_type: &CollectiveDecisionType) -> u32 {
|
||||
match decision_type {
|
||||
CollectiveDecisionType::ParliamentSimpleMajority =>
|
||||
(T::ParliamentSize::get() / 2) + 1,
|
||||
CollectiveDecisionType::ParliamentSuperMajority =>
|
||||
(T::ParliamentSize::get() * 2) / 3,
|
||||
CollectiveDecisionType::ParliamentAbsoluteMajority =>
|
||||
(T::ParliamentSize::get() * 3) / 4,
|
||||
CollectiveDecisionType::ParliamentSimpleMajority => {
|
||||
(T::ParliamentSize::get() / 2) + 1
|
||||
},
|
||||
CollectiveDecisionType::ParliamentSuperMajority => {
|
||||
(T::ParliamentSize::get() * 2) / 3
|
||||
},
|
||||
CollectiveDecisionType::ParliamentAbsoluteMajority => {
|
||||
(T::ParliamentSize::get() * 3) / 4
|
||||
},
|
||||
CollectiveDecisionType::ConstitutionalReview => (T::DiwanSize::get() * 2) / 3,
|
||||
CollectiveDecisionType::ConstitutionalUnanimous => T::DiwanSize::get(),
|
||||
_ => T::ParliamentSize::get() / 2 + 1,
|
||||
@@ -1553,10 +1560,10 @@ impl<T: Config> Pezpallet<T> {
|
||||
/// Check if an account is any type of governance member
|
||||
/// Used for fee exemption in governance-related transactions
|
||||
pub fn is_governance_member(who: &T::AccountId) -> bool {
|
||||
Self::is_serok(who) ||
|
||||
Self::is_parliament_member(who) ||
|
||||
Self::is_diwan_member(who) ||
|
||||
Self::is_minister(who)
|
||||
Self::is_serok(who)
|
||||
|| Self::is_parliament_member(who)
|
||||
|| Self::is_diwan_member(who)
|
||||
|| Self::is_minister(who)
|
||||
}
|
||||
|
||||
/// Check if account is Serok (President)
|
||||
|
||||
@@ -41,7 +41,8 @@ pub mod v1 {
|
||||
let elections_count = ActiveElections::<T>::iter().count() as u64;
|
||||
let proposals_count = ActiveProposals::<T>::iter().count() as u64;
|
||||
|
||||
let migrated = officials_count + ministers_count + elections_count + proposals_count;
|
||||
let migrated =
|
||||
officials_count + ministers_count + elections_count + proposals_count;
|
||||
|
||||
// Update storage version
|
||||
STORAGE_VERSION.put::<Pezpallet<T>>();
|
||||
@@ -143,9 +144,8 @@ pub mod v1 {
|
||||
pre_appointments_count,
|
||||
pre_proposals_count,
|
||||
pre_collective_votes_count,
|
||||
): PreUpgradeState =
|
||||
Decode::decode(&mut &state[..])
|
||||
.map_err(|_| "Failed to decode pre-upgrade state")?;
|
||||
): PreUpgradeState = Decode::decode(&mut &state[..])
|
||||
.map_err(|_| "Failed to decode pre-upgrade state")?;
|
||||
|
||||
log::info!("🔍 Post-upgrade check for pezpallet-welati");
|
||||
|
||||
@@ -170,19 +170,33 @@ pub mod v1 {
|
||||
let post_proposals_count = ActiveProposals::<T>::iter().count() as u32;
|
||||
let post_collective_votes_count = CollectiveVotes::<T>::iter().count() as u32;
|
||||
|
||||
log::info!(" CurrentOfficials entries: {pre_officials_count} -> {post_officials_count}");
|
||||
log::info!(" CurrentMinisters entries: {pre_ministers_count} -> {post_ministers_count}");
|
||||
log::info!(" ParliamentMembers entries: {pre_parliament_count} -> {post_parliament_count}");
|
||||
log::info!(
|
||||
" CurrentOfficials entries: {pre_officials_count} -> {post_officials_count}"
|
||||
);
|
||||
log::info!(
|
||||
" CurrentMinisters entries: {pre_ministers_count} -> {post_ministers_count}"
|
||||
);
|
||||
log::info!(
|
||||
" ParliamentMembers entries: {pre_parliament_count} -> {post_parliament_count}"
|
||||
);
|
||||
log::info!(" DiwanMembers entries: {pre_diwan_count} -> {post_diwan_count}");
|
||||
log::info!(" AppointedOfficials entries: {pre_appointed_count} -> {post_appointed_count}");
|
||||
log::info!(" ActiveElections entries: {pre_elections_count} -> {post_elections_count}");
|
||||
log::info!(" ElectionCandidates entries: {pre_candidates_count} -> {post_candidates_count}");
|
||||
log::info!(
|
||||
" AppointedOfficials entries: {pre_appointed_count} -> {post_appointed_count}"
|
||||
);
|
||||
log::info!(
|
||||
" ActiveElections entries: {pre_elections_count} -> {post_elections_count}"
|
||||
);
|
||||
log::info!(
|
||||
" ElectionCandidates entries: {pre_candidates_count} -> {post_candidates_count}"
|
||||
);
|
||||
log::info!(" ElectionVotes entries: {pre_votes_count} -> {post_votes_count}");
|
||||
log::info!(" ElectionResults entries: {pre_results_count} -> {post_results_count}");
|
||||
log::info!(" ElectoralDistrictConfig entries: {pre_districts_count} -> {post_districts_count}");
|
||||
log::info!(" PendingNominations entries: {pre_nominations_count} -> {post_nominations_count}");
|
||||
log::info!(" AppointmentProcesses entries: {pre_appointments_count} -> {post_appointments_count}");
|
||||
log::info!(" ActiveProposals entries: {pre_proposals_count} -> {post_proposals_count}");
|
||||
log::info!(
|
||||
" ActiveProposals entries: {pre_proposals_count} -> {post_proposals_count}"
|
||||
);
|
||||
log::info!(" CollectiveVotes entries: {pre_collective_votes_count} -> {post_collective_votes_count}");
|
||||
|
||||
// Verify no data was lost
|
||||
|
||||
@@ -125,7 +125,9 @@ parameter_types! {
|
||||
pub struct NftsBenchmarkHelper;
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
impl pezpallet_nfts::BenchmarkHelper<u32, u32, UintAuthorityId, AccountId, TestSignature> for NftsBenchmarkHelper {
|
||||
impl pezpallet_nfts::BenchmarkHelper<u32, u32, UintAuthorityId, AccountId, TestSignature>
|
||||
for NftsBenchmarkHelper
|
||||
{
|
||||
fn collection(i: u16) -> u32 {
|
||||
i.into()
|
||||
}
|
||||
@@ -192,10 +194,13 @@ parameter_types! {
|
||||
pub struct IdentityBenchmarkHelper;
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
impl pezpallet_identity::BenchmarkHelper<UintAuthorityId, TestSignature> for IdentityBenchmarkHelper {
|
||||
impl pezpallet_identity::BenchmarkHelper<UintAuthorityId, TestSignature>
|
||||
for IdentityBenchmarkHelper
|
||||
{
|
||||
fn sign_message(message: &[u8]) -> (UintAuthorityId, TestSignature) {
|
||||
let signer = UintAuthorityId(0);
|
||||
let signature = <UintAuthorityId as RuntimeAppPublic>::sign(&signer, &message.to_vec()).unwrap();
|
||||
let signature =
|
||||
<UintAuthorityId as RuntimeAppPublic>::sign(&signer, &message.to_vec()).unwrap();
|
||||
(signer, signature)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1339,31 +1339,33 @@ impl OfficialRoleInfo for OfficialRole {
|
||||
|
||||
fn nominating_minister(&self) -> MinisterRole {
|
||||
match self {
|
||||
OfficialRole::Dadger |
|
||||
OfficialRole::Dozger |
|
||||
OfficialRole::Hiquqnas |
|
||||
OfficialRole::Noter => MinisterRole::AdvaletWeziri,
|
||||
OfficialRole::Dadger
|
||||
| OfficialRole::Dozger
|
||||
| OfficialRole::Hiquqnas
|
||||
| OfficialRole::Noter => MinisterRole::AdvaletWeziri,
|
||||
|
||||
OfficialRole::Xezinedar | OfficialRole::Bacgir | OfficialRole::GerinendeyeCavkaniye =>
|
||||
MinisterRole::XezineWeziri,
|
||||
OfficialRole::Xezinedar | OfficialRole::Bacgir | OfficialRole::GerinendeyeCavkaniye => {
|
||||
MinisterRole::XezineWeziri
|
||||
},
|
||||
|
||||
OfficialRole::OperatoreTore |
|
||||
OfficialRole::PisporeEwlehiyaSiber |
|
||||
OfficialRole::GerinendeyeDaneye => MinisterRole::TeknolojîWeziri,
|
||||
OfficialRole::OperatoreTore
|
||||
| OfficialRole::PisporeEwlehiyaSiber
|
||||
| OfficialRole::GerinendeyeDaneye => MinisterRole::TeknolojîWeziri,
|
||||
|
||||
OfficialRole::Berdevk | OfficialRole::Qeydkar => MinisterRole::NavxweWeziri,
|
||||
|
||||
OfficialRole::Balyoz | OfficialRole::Navbeynkar | OfficialRole::ParezvaneCandi =>
|
||||
MinisterRole::DerveWeziri,
|
||||
OfficialRole::Balyoz | OfficialRole::Navbeynkar | OfficialRole::ParezvaneCandi => {
|
||||
MinisterRole::DerveWeziri
|
||||
},
|
||||
|
||||
OfficialRole::Mufetis | OfficialRole::KaliteKontrolker => MinisterRole::DenetimWeziri,
|
||||
|
||||
OfficialRole::Bazargan | OfficialRole::RêvebereProjeyê => MinisterRole::AbûrîWeziri,
|
||||
|
||||
OfficialRole::Feqi |
|
||||
OfficialRole::Perwerdekar |
|
||||
OfficialRole::Rewsenbir |
|
||||
OfficialRole::Mamoste => MinisterRole::PerwerdeDiyanetWeziri,
|
||||
OfficialRole::Feqi
|
||||
| OfficialRole::Perwerdekar
|
||||
| OfficialRole::Rewsenbir
|
||||
| OfficialRole::Mamoste => MinisterRole::PerwerdeDiyanetWeziri,
|
||||
|
||||
// Mela özel durum - doğrudan Serok atar
|
||||
OfficialRole::Mela => MinisterRole::AdvaletWeziri, // Placeholder
|
||||
@@ -1373,11 +1375,11 @@ impl OfficialRoleInfo for OfficialRole {
|
||||
fn requires_parliament_approval(&self) -> bool {
|
||||
match self {
|
||||
// Yüksek düzey pozisyonlar Parlamento onayı gerektirir
|
||||
OfficialRole::Dadger |
|
||||
OfficialRole::Xezinedar |
|
||||
OfficialRole::PisporeEwlehiyaSiber |
|
||||
OfficialRole::Mufetis |
|
||||
OfficialRole::Balyoz => true,
|
||||
OfficialRole::Dadger
|
||||
| OfficialRole::Xezinedar
|
||||
| OfficialRole::PisporeEwlehiyaSiber
|
||||
| OfficialRole::Mufetis
|
||||
| OfficialRole::Balyoz => true,
|
||||
// Diğerleri sadece Serok onayı
|
||||
_ => false,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user