From ade2f9890816ee34a56f6ad84b540088c2126333 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 23 Sep 2021 12:21:34 +0200 Subject: [PATCH] chore: rm unneccessary clones --- pallets/asset-index/src/lib.rs | 14 +++++++------- pallets/saft-registry/src/lib.rs | 4 ++-- primitives/primitives/src/traits.rs | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/pallets/asset-index/src/lib.rs b/pallets/asset-index/src/lib.rs index 1be6793ad9..7db6571a1e 100644 --- a/pallets/asset-index/src/lib.rs +++ b/pallets/asset-index/src/lib.rs @@ -796,7 +796,7 @@ pub mod pallet { let index_tokens = Self::index_token_equivalent(asset_id, units)?; // transfer the caller's fund into the treasury account - Self::remove_liquid(who.clone(), asset_id, units, index_tokens, recipient.clone())?; + Self::remove_liquid(&who, asset_id, units, index_tokens, recipient.clone())?; Self::deposit_event(Event::AssetRemoved(asset_id, units, who, recipient, index_tokens)); Ok(().into()) @@ -1090,7 +1090,7 @@ pub mod pallet { } fn remove_liquid( - who: T::AccountId, + who: &T::AccountId, asset_id: T::AssetId, units: T::Balance, nav: T::Balance, @@ -1100,7 +1100,7 @@ pub mod pallet { return Ok(()); } ensure!(Self::is_liquid_asset(&asset_id), Error::::ExpectedLiquid); - ensure!(T::IndexToken::can_slash(&who, nav), Error::::InsufficientDeposit); + ensure!(T::IndexToken::can_slash(who, nav), Error::::InsufficientDeposit); let recipient = recipient.unwrap_or_else(|| who.clone()); @@ -1108,13 +1108,13 @@ pub mod pallet { T::RemoteAssetManager::transfer_asset(recipient, asset_id, units)?; // burn index token accordingly, no index token changes in the meantime - T::IndexToken::slash(&who, nav); + T::IndexToken::slash(who, nav); Ok(()) } fn remove_saft( - who: T::AccountId, + who: &T::AccountId, asset_id: T::AssetId, units: T::Balance, saft_nav: T::Balance, @@ -1129,12 +1129,12 @@ pub mod pallet { let index_token = Self::saft_equivalent(saft_nav)?; ensure!(!Self::is_liquid_asset(&asset_id), Error::::ExpectedSAFT); - ensure!(T::IndexToken::can_slash(&who, index_token), Error::::InsufficientDeposit); + ensure!(T::IndexToken::can_slash(who, index_token), Error::::InsufficientDeposit); // burn SAFT by withdrawing from the index T::Currency::withdraw(asset_id, &Self::treasury_account(), units)?; // burn index token accordingly, no index token changes in the meantime - T::IndexToken::slash(&who, index_token); + T::IndexToken::slash(who, index_token); Ok(()) } diff --git a/pallets/saft-registry/src/lib.rs b/pallets/saft-registry/src/lib.rs index 155808d149..ac62dee932 100644 --- a/pallets/saft-registry/src/lib.rs +++ b/pallets/saft-registry/src/lib.rs @@ -208,7 +208,7 @@ pub mod pallet { #[pallet::weight(T::WeightInfo::remove_saft())] #[transactional] pub fn remove_saft(origin: OriginFor, asset_id: T::AssetId, saft_id: SAFTId) -> DispatchResult { - Self::do_remove_saft(T::AdminOrigin::ensure_origin(origin.clone())?, asset_id, saft_id) + Self::do_remove_saft(T::AdminOrigin::ensure_origin(origin)?, asset_id, saft_id) } /// Removes saft assets with root origin @@ -351,7 +351,7 @@ pub mod pallet { let saft = ActiveSAFTs::::take(asset_id, saft_id).ok_or(Error::::SAFTNotFound)?; // reflect the change in NAV - T::AssetRecorder::remove_saft(who, asset_id, saft.units, saft.nav)?; + T::AssetRecorder::remove_saft(&who, asset_id, saft.units, saft.nav)?; SAFTNetAssetValue::::mutate(asset_id, |nav| *nav = nav.saturating_sub(saft.nav)); Self::deposit_event(Event::::SAFTRemoved(asset_id, saft_id)); diff --git a/primitives/primitives/src/traits.rs b/primitives/primitives/src/traits.rs index af8b8891d9..fd12c1f621 100644 --- a/primitives/primitives/src/traits.rs +++ b/primitives/primitives/src/traits.rs @@ -271,7 +271,7 @@ pub trait AssetRecorder { /// Updates the index by burning the given amount of index token from /// the caller's account. fn remove_liquid( - who: AccountId, + who: &AccountId, id: AssetId, units: Balance, nav: Balance, @@ -280,7 +280,7 @@ pub trait AssetRecorder { /// Burns the given amount of SAFT token from the index and /// the nav from the caller's account - fn remove_saft(who: AccountId, id: AssetId, units: Balance, nav: Balance) -> DispatchResult; + fn remove_saft(who: &AccountId, id: AssetId, units: Balance, nav: Balance) -> DispatchResult; } /// Helper trait for runtime benchmarks @@ -289,7 +289,7 @@ pub trait AssetRecorderBenchmarks { fn add_asset( asset_id: AssetId, units: Balance, - localtion: MultiLocation, + location: MultiLocation, amount: Balance, ) -> DispatchResultWithPostInfo;