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:
2025-12-22 17:12:58 +03:00
parent 65b7f5e640
commit 4c8f281051
898 changed files with 8671 additions and 6432 deletions
@@ -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);