From 78506e6a3d3736ba230a0550affd14bdba24940d Mon Sep 17 00:00:00 2001 From: Leonardo Razovic <4128940+lrazovic@users.noreply.github.com> Date: Fri, 21 Jul 2023 14:16:44 +0200 Subject: [PATCH] chore: cargo fmt --- .../pallets/linear-release/src/impls.rs | 12 ++++++------ polimec-skeleton/pallets/linear-release/src/lib.rs | 2 +- polimec-skeleton/pallets/linear-release/src/mock.rs | 13 ++++++------- .../pallets/linear-release/src/tests.rs | 8 +++++--- .../pallets/linear-release/src/traits.rs | 10 ++++++---- 5 files changed, 24 insertions(+), 21 deletions(-) diff --git a/polimec-skeleton/pallets/linear-release/src/impls.rs b/polimec-skeleton/pallets/linear-release/src/impls.rs index b7d648179..3c4f3fb72 100644 --- a/polimec-skeleton/pallets/linear-release/src/impls.rs +++ b/polimec-skeleton/pallets/linear-release/src/impls.rs @@ -72,7 +72,7 @@ impl Pallet { // Validate user inputs. ensure!(schedule.locked() >= T::MinVestedTransfer::get(), Error::::AmountLow); if !schedule.is_valid() { - return Err(Error::::InvalidScheduleParams.into()); + return Err(Error::::InvalidScheduleParams.into()) }; // Check we can add to this account prior to any storage writes. @@ -274,13 +274,13 @@ impl ReleaseSchedule, ReasonOf> for Pallet { reason: ReasonOf, ) -> DispatchResult { if locked.is_zero() { - return Ok(()); + return Ok(()) } let vesting_schedule = VestingInfo::new(locked, per_block, starting_block); // Check for `per_block` or `locked` of 0. if !vesting_schedule.is_valid() { - return Err(Error::::InvalidScheduleParams.into()); + return Err(Error::::InvalidScheduleParams.into()) }; let mut schedules = Self::vesting(who, reason).unwrap_or_default(); @@ -307,7 +307,7 @@ impl ReleaseSchedule, ReasonOf> for Pallet { ) -> DispatchResult { // Check for `per_block` or `locked` of 0. if !VestingInfo::new(locked, per_block, starting_block).is_valid() { - return Err(Error::::InvalidScheduleParams.into()); + return Err(Error::::InvalidScheduleParams.into()) } ensure!( @@ -326,13 +326,13 @@ impl ReleaseSchedule, ReasonOf> for Pallet { reason: ReasonOf, ) -> DispatchResult { if locked.is_zero() { - return Ok(()); + return Ok(()) } let vesting_schedule = VestingInfo::new(locked, per_block, starting_block); // Check for `per_block` or `locked` of 0. if !vesting_schedule.is_valid() { - return Err(Error::::InvalidScheduleParams.into()); + return Err(Error::::InvalidScheduleParams.into()) }; let mut schedules = Self::vesting(who, reason).unwrap_or_default(); diff --git a/polimec-skeleton/pallets/linear-release/src/lib.rs b/polimec-skeleton/pallets/linear-release/src/lib.rs index 47f71addd..470d8a9a2 100644 --- a/polimec-skeleton/pallets/linear-release/src/lib.rs +++ b/polimec-skeleton/pallets/linear-release/src/lib.rs @@ -363,7 +363,7 @@ pub mod pallet { ) -> DispatchResult { let who = ensure_signed(origin)?; if schedule1_index == schedule2_index { - return Ok(()); + return Ok(()) }; let schedule1_index = schedule1_index as usize; let schedule2_index = schedule2_index as usize; diff --git a/polimec-skeleton/pallets/linear-release/src/mock.rs b/polimec-skeleton/pallets/linear-release/src/mock.rs index bd751c9bb..284d64733 100644 --- a/polimec-skeleton/pallets/linear-release/src/mock.rs +++ b/polimec-skeleton/pallets/linear-release/src/mock.rs @@ -96,11 +96,13 @@ impl Config for Test { type Balance = u64; type BlockNumberToBalance = Identity; type Currency = Balances; - type Reason = LockType; // TODO: Use the type from Balances. + // TODO: Use the type from Balances. type MinVestedTransfer = MinVestedTransfer; + type Reason = LockType; type RuntimeEvent = RuntimeEvent; type UnvestedFundsAllowedWithdrawReasons = UnvestedFundsAllowedWithdrawReasons; type WeightInfo = (); + const MAX_VESTING_SCHEDULES: u32 = 3; } @@ -116,7 +118,6 @@ impl ExtBuilder { self } - pub fn build(self) -> sp_io::TestExternalities { EXISTENTIAL_DEPOSIT.with(|v| *v.borrow_mut() = self.existential_deposit); let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); @@ -140,15 +141,13 @@ impl ExtBuilder { vec![ (1, 0, 10, 5 * self.existential_deposit, LockType::Participation(0)), (2, 10, 20, self.existential_deposit, LockType::Participation(0)), - (12, 10, 20, 5 * self.existential_deposit, LockType::Participation(0)), + (12, 10, 20, 5 * self.existential_deposit, LockType::Participation(0)), ] }; - pallet_vesting::GenesisConfig:: { vesting } - .assimilate_storage(&mut t) - .unwrap(); + pallet_vesting::GenesisConfig:: { vesting }.assimilate_storage(&mut t).unwrap(); let mut ext = sp_io::TestExternalities::new(t); ext.execute_with(|| System::set_block_number(1)); ext } -} \ No newline at end of file +} diff --git a/polimec-skeleton/pallets/linear-release/src/tests.rs b/polimec-skeleton/pallets/linear-release/src/tests.rs index 7d75140ea..e527231dd 100644 --- a/polimec-skeleton/pallets/linear-release/src/tests.rs +++ b/polimec-skeleton/pallets/linear-release/src/tests.rs @@ -1298,13 +1298,15 @@ fn merge_schedules_different_reason() { assert_eq!(Balances::balance(&2), ED); assert_eq!(Vesting::vesting(&2, LockType::Participation(0)).unwrap(), vec![sched0]); - // Add a schedule that is identical to the one that already exists. assert_ok!(Vesting::vested_transfer(Some(14).into(), 2, sched0, LockType::Participation(1))); assert_ok!(Vesting::vested_transfer(Some(14).into(), 2, sched0, LockType::Participation(1))); assert_eq!(Vesting::vesting(&2, LockType::Participation(1)).unwrap(), vec![sched0, sched0]); assert_eq!(Balances::balance(&2), ED); - assert_noop!(Vesting::merge_schedules(Some(2).into(), 0, 1, LockType::Participation(0)), Error::::ScheduleIndexOutOfBounds); + assert_noop!( + Vesting::merge_schedules(Some(2).into(), 0, 1, LockType::Participation(0)), + Error::::ScheduleIndexOutOfBounds + ); assert_ok!(Vesting::merge_schedules(Some(2).into(), 0, 1, LockType::Participation(1))); // Since we merged identical schedules, the new schedule finishes at the same @@ -1318,4 +1320,4 @@ fn merge_schedules_different_reason() { assert_eq!(Balances::balance(&2), ED); }); -} \ No newline at end of file +} diff --git a/polimec-skeleton/pallets/linear-release/src/traits.rs b/polimec-skeleton/pallets/linear-release/src/traits.rs index 205e92e19..0e834c6f3 100644 --- a/polimec-skeleton/pallets/linear-release/src/traits.rs +++ b/polimec-skeleton/pallets/linear-release/src/traits.rs @@ -26,11 +26,13 @@ pub trait ReleaseSchedule { type Currency: fungible::InspectHold + fungible::MutateHold + fungible::BalancedHold; - /// Get the amount that is currently being vested and cannot be transferred out of this account. /// Returns `None` if the account has no vesting schedule. - fn vesting_balance(who: &AccountId, reason: Reason) -> Option<>::Balance>; + fn vesting_balance( + who: &AccountId, + reason: Reason, + ) -> Option<>::Balance>; /// Adds a release schedule to a given account. /// @@ -61,7 +63,7 @@ pub trait ReleaseSchedule { locked: >::Balance, per_block: >::Balance, starting_block: Self::Moment, - reason: Reason + reason: Reason, ) -> DispatchResult; /// Checks if `add_release_schedule` would work against `who`. @@ -70,7 +72,7 @@ pub trait ReleaseSchedule { locked: >::Balance, per_block: >::Balance, starting_block: Self::Moment, - reason: Reason + reason: Reason, ) -> DispatchResult; /// Remove a release schedule for a given account.