From 50ea33350503281b7ba9cc47e5a3de556ab5bd2e Mon Sep 17 00:00:00 2001 From: Greg Zaitsev Date: Fri, 02 Oct 2020 13:24:12 +0000 Subject: [PATCH] Cleanup borrowin in check_white_list --- --- a/pallets/nft/src/lib.rs +++ b/pallets/nft/src/lib.rs @@ -502,8 +502,9 @@ let target_collection = >::get(collection_id); if !Self::is_owner_or_admin_permissions(collection_id, sender.clone()) { - ensure!(target_collection.mint_mode == true, "Collection is not in mint mode"); - Self::check_white_list(collection_id, owner.clone())?; + ensure!(target_collection.mint_mode == true, "Public minting is not allowed for this collection"); + Self::check_white_list(collection_id, &owner)?; + Self::check_white_list(collection_id, &sender)?; } match target_collection.mode @@ -576,7 +577,7 @@ "Only item owner, collection owner and admins can modify item"); if target_collection.access == AccessMode::WhiteList { - Self::check_white_list(collection_id, sender.clone())?; + Self::check_white_list(collection_id, &sender)?; } match target_collection.mode @@ -605,8 +606,8 @@ "Only item owner, collection owner and admins can modify item"); if target_collection.access == AccessMode::WhiteList { - Self::check_white_list(collection_id, sender.clone())?; - Self::check_white_list(collection_id, recipient.clone())?; + Self::check_white_list(collection_id, &sender)?; + Self::check_white_list(collection_id, &recipient)?; } match target_collection.mode @@ -632,8 +633,8 @@ "Only item owner, collection owner and admins can approve"); if target_collection.access == AccessMode::WhiteList { - Self::check_white_list(collection_id, sender.clone())?; - Self::check_white_list(collection_id, approved.clone())?; + Self::check_white_list(collection_id, &sender)?; + Self::check_white_list(collection_id, &approved)?; } // amount param stub @@ -679,8 +680,8 @@ "Only item owner, collection owner and admins can modify items"); if target_collection.access == AccessMode::WhiteList { - Self::check_white_list(collection_id, sender.clone())?; - Self::check_white_list(collection_id, recipient.clone())?; + Self::check_white_list(collection_id, &sender)?; + Self::check_white_list(collection_id, &recipient)?; } // remove approve @@ -935,12 +936,12 @@ } } - fn check_white_list(collection_id: u64, address: T::AccountId) -> DispatchResult { + fn check_white_list(collection_id: u64, address: &T::AccountId) -> DispatchResult { let mes = "Address is not in white list"; ensure!(>::contains_key(collection_id), mes); let wl = >::get(collection_id); - ensure!(wl.contains(&address.clone()), mes); + ensure!(wl.contains(address), mes); Ok(()) } -- gitstuff