From b28ff17c309e8b887192a80ce501680ac2d947d3 Mon Sep 17 00:00:00 2001 From: Drazen Urch Date: Mon, 7 Nov 2022 14:40:52 +0100 Subject: [PATCH] Set default pledge cap to 10% (#1739) * Set default pledge cap to 10% * fix clippy beta lints --- common/cosmwasm-smart-contracts/vesting-contract/src/lib.rs | 2 +- contracts/vesting/src/vesting/account/vesting_account.rs | 6 +++--- contracts/vesting/src/vesting/mod.rs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/common/cosmwasm-smart-contracts/vesting-contract/src/lib.rs b/common/cosmwasm-smart-contracts/vesting-contract/src/lib.rs index 4d494510b5..7e0e90d852 100644 --- a/common/cosmwasm-smart-contracts/vesting-contract/src/lib.rs +++ b/common/cosmwasm-smart-contracts/vesting-contract/src/lib.rs @@ -82,7 +82,7 @@ impl FromStr for PledgeCap { impl Default for PledgeCap { fn default() -> Self { - PledgeCap::Absolute(Uint128::from(100_000_000_000u128)) + PledgeCap::Percent(Percent::from_percentage_value(10).expect("This can never fail!")) } } diff --git a/contracts/vesting/src/vesting/account/vesting_account.rs b/contracts/vesting/src/vesting/account/vesting_account.rs index 53f39e2891..ed10ca4669 100644 --- a/contracts/vesting/src/vesting/account/vesting_account.rs +++ b/contracts/vesting/src/vesting/account/vesting_account.rs @@ -105,7 +105,7 @@ impl VestingAccount for Account { } fn get_end_time(&self) -> Timestamp { - self.periods[(self.num_vesting_periods() - 1) as usize].end_time() + self.periods[(self.num_vesting_periods() - 1)].end_time() } fn get_original_vesting(&self) -> OriginalVestingResponse { @@ -133,7 +133,7 @@ impl VestingAccount for Account { let start_time = match period { Period::Before => 0, Period::After => u64::MAX, - Period::In(idx) => self.periods[idx as usize].start_time, + Period::In(idx) => self.periods[idx].start_time, }; let coin = self.total_delegations_at_timestamp(storage, start_time)?; @@ -179,7 +179,7 @@ impl VestingAccount for Account { let start_time = match period { Period::Before => 0, Period::After => u64::MAX, - Period::In(idx) => self.periods[idx as usize].start_time, + Period::In(idx) => self.periods[idx].start_time, }; let amount = if let Some(bond) = self diff --git a/contracts/vesting/src/vesting/mod.rs b/contracts/vesting/src/vesting/mod.rs index d678d2aab8..288920003a 100644 --- a/contracts/vesting/src/vesting/mod.rs +++ b/contracts/vesting/src/vesting/mod.rs @@ -15,7 +15,7 @@ pub struct VestingPeriod { impl VestingPeriod { pub fn end_time(&self) -> Timestamp { - Timestamp::from_seconds(self.start_time + self.period_seconds as u64) + Timestamp::from_seconds(self.start_time + self.period_seconds) } } @@ -26,7 +26,7 @@ pub fn populate_vesting_periods( let mut periods = Vec::with_capacity(vesting_spec.num_periods() as usize); for i in 0..vesting_spec.num_periods() { let period = VestingPeriod { - start_time: start_time + i as u64 * vesting_spec.period_seconds(), + start_time: start_time + i * vesting_spec.period_seconds(), period_seconds: vesting_spec.period_seconds(), }; periods.push(period);