Skip to content

Commit c58b1a0

Browse files
authored
fix: update credits pallet params (#1039)
* chore: format code * chore: format code * chore: format edition * chore: build docker in ci * chore: fix rust * chore: fix branch * chore: fix max rate per block * chore: cleanup params * chore: fix len * chore: update tests
1 parent 7b36b16 commit c58b1a0

File tree

8 files changed

+361
-19
lines changed

8 files changed

+361
-19
lines changed

pallets/credits/src/lib.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ pub mod pallet {
9191

9292
// Move STORAGE_VERSION inside the pallet mod
9393
const STORAGE_VERSION: StorageVersion = StorageVersion::new(2);
94-
const MAX_RATE_PER_BLOCK: u128 = 1_000_000;
9594

9695
#[pallet::pallet]
9796
#[pallet::without_storage_info]
@@ -153,6 +152,10 @@ pub mod pallet {
153152
/// Type for the origin that is allowed to update stake tiers.
154153
type ForceOrigin: frame_support::traits::EnsureOrigin<Self::RuntimeOrigin>;
155154

155+
/// The maximum rate per block for a stake tier.
156+
#[pallet::constant]
157+
type MaxRatePerBlock: Get<BalanceOf<Self>>;
158+
156159
/// The weight information for the pallet.
157160
type WeightInfo: WeightInfo;
158161
}
@@ -412,7 +415,7 @@ pub mod pallet {
412415

413416
// Validate that rates don't exceed maximum allowed value
414417
for tier in &new_tiers {
415-
let max_rate = BalanceOf::<T>::saturated_from(MAX_RATE_PER_BLOCK);
418+
let max_rate = BalanceOf::<T>::saturated_from(T::MaxRatePerBlock::get());
416419
ensure!(tier.rate_per_block <= max_rate, Error::<T>::RateTooHigh);
417420
}
418421

@@ -465,7 +468,7 @@ pub mod pallet {
465468

466469
// Validate that rates don't exceed maximum allowed value
467470
for tier in &new_tiers {
468-
let max_rate = BalanceOf::<T>::saturated_from(MAX_RATE_PER_BLOCK);
471+
let max_rate = BalanceOf::<T>::saturated_from(T::MaxRatePerBlock::get());
469472
ensure!(tier.rate_per_block <= max_rate, Error::<T>::RateTooHigh);
470473
}
471474

pallets/credits/src/mock.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -534,11 +534,15 @@ impl pallet_multi_asset_delegation::Config for Runtime {
534534
parameter_types! {
535535
#[derive(Default, Copy, Clone, Eq, PartialEq, RuntimeDebug, Encode, Decode, MaxEncodedLen, TypeInfo)]
536536
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
537-
pub const MaxStakeTiers: u32 = 10;
537+
pub const MaxStakeTiers: u32 = tangle_primitives::credits::MAX_STAKE_TIERS;
538538

539539
#[derive(Default, Copy, Clone, Eq, PartialEq, RuntimeDebug, Encode, Decode, MaxEncodedLen, TypeInfo)]
540540
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
541541
pub const CreditBurnRecipient: Option<AccountId> = None;
542+
543+
#[derive(Default, Copy, Clone, Eq, PartialEq, RuntimeDebug, Encode, Decode, MaxEncodedLen, TypeInfo)]
544+
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
545+
pub const MaxRatePerBlock: Balance = tangle_primitives::credits::MAX_RATE_PER_BLOCK;
542546
}
543547

544548
impl pallet_credits::Config for Runtime {
@@ -547,11 +551,12 @@ impl pallet_credits::Config for Runtime {
547551
type AssetId = AssetId;
548552
type MultiAssetDelegationInfo = MultiAssetDelegation;
549553
type BurnConversionRate = ConstU128<1000>;
550-
type ClaimWindowBlocks = ConstU64<1000>;
554+
type ClaimWindowBlocks = ConstU64<{ tangle_primitives::credits::CLAIM_WINDOW_BLOCKS }>;
551555
type CreditBurnRecipient = CreditBurnRecipient;
552-
type MaxOffchainAccountIdLength = ConstU32<100>;
556+
type MaxOffchainAccountIdLength = ConstU32<1024>;
553557
type MaxStakeTiers = MaxStakeTiers;
554558
type ForceOrigin = frame_system::EnsureRoot<AccountId>;
559+
type MaxRatePerBlock = MaxRatePerBlock;
555560
type WeightInfo = ();
556561
}
557562

0 commit comments

Comments
 (0)