git.delta.rocks / unique-network / refs/commits / e20b05e467b0

difftreelog

cargo fmt

Daniel Shiposha2022-06-30parent: #e5ae604.patch.diff
in: master

3 files changed

modifiedpallets/nonfungible/src/erc.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/erc.rs
+++ b/pallets/nonfungible/src/erc.rs
@@ -37,8 +37,7 @@
 
 use crate::{
 	AccountBalance, Config, CreateItemData, NonfungibleHandle, Pallet, TokenData, TokensMinted,
-	SelfWeightOf, weights::WeightInfo, TokenProperties,
-	property_guard::PropertyGuard,
+	SelfWeightOf, weights::WeightInfo, TokenProperties, property_guard::PropertyGuard,
 };
 
 #[solidity_interface(name = "TokenProperties")]
@@ -88,13 +87,8 @@
 			.recorder
 			.weight_calls_budget(<StructureWeight<T>>::find_parent());
 
-		let mut guard = PropertyGuard::new(
-			&caller,
-			self,
-			TokenId(token_id),
-			is_token_create,
-			&budget,
-		);
+		let mut guard =
+			PropertyGuard::new(&caller, self, TokenId(token_id), is_token_create, &budget);
 
 		<Pallet<T>>::set_token_property(Property { key, value }, &mut guard)
 			.map_err(dispatch_to_evm::<T>)
@@ -112,16 +106,10 @@
 			.recorder
 			.weight_calls_budget(<StructureWeight<T>>::find_parent());
 
-		let mut guard = PropertyGuard::new(
-			&caller,
-			self,
-			TokenId(token_id),
-			is_token_create,
-			&budget,
-		);
+		let mut guard =
+			PropertyGuard::new(&caller, self, TokenId(token_id), is_token_create, &budget);
 
-		<Pallet<T>>::delete_token_property(key, &mut guard)
-			.map_err(dispatch_to_evm::<T>)
+		<Pallet<T>>::delete_token_property(key, &mut guard).map_err(dispatch_to_evm::<T>)
 	}
 
 	/// Throws error if key not found
modifiedpallets/nonfungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/lib.rs
+++ b/pallets/nonfungible/src/lib.rs
@@ -488,7 +488,10 @@
 		})
 	}
 
-	pub fn set_token_property(property: Property, guard: &mut PropertyGuard<'_, T>) -> DispatchResult {
+	pub fn set_token_property(
+		property: Property,
+		guard: &mut PropertyGuard<'_, T>,
+	) -> DispatchResult {
 		Self::check_token_change_permission(&property.key, guard)?;
 
 		<TokenProperties<T>>::try_mutate((guard.collection.id, guard.token), |properties| {
@@ -530,7 +533,10 @@
 		Ok(())
 	}
 
-	pub fn delete_token_property(property_key: PropertyKey, guard: &mut PropertyGuard<'_, T>) -> DispatchResult {
+	pub fn delete_token_property(
+		property_key: PropertyKey,
+		guard: &mut PropertyGuard<'_, T>,
+	) -> DispatchResult {
 		Self::check_token_change_permission(&property_key, guard)?;
 
 		<TokenProperties<T>>::try_mutate((guard.collection.id, guard.token), |properties| {
@@ -547,7 +553,10 @@
 		Ok(())
 	}
 
-	fn check_token_change_permission(property_key: &PropertyKey, guard: &mut PropertyGuard<'_, T>) -> DispatchResult {
+	fn check_token_change_permission(
+		property_key: &PropertyKey,
+		guard: &mut PropertyGuard<'_, T>,
+	) -> DispatchResult {
 		let permission = <PalletCommon<T>>::property_permissions(guard.collection.id)
 			.get(property_key)
 			.cloned()
modifiedpallets/nonfungible/src/property_guard.rsdiffbeforeafterboth
before · pallets/nonfungible/src/property_guard.rs
1use super::*;23pub struct PropertyGuard<'a, T: Config> {4    pub sender: &'a T::CrossAccountId,5    pub collection: &'a NonfungibleHandle<T>,6    pub token: TokenId,7    pub is_token_create: bool,8    budget: &'a dyn Budget,910    collection_admin_result: Option<DispatchResult>,11    token_owner_result: Option<DispatchResult>,12}1314impl<'a, T: Config> PropertyGuard<'a, T> {15    pub fn new(16        sender: &'a T::CrossAccountId,17        collection: &'a NonfungibleHandle<T>,18        token: TokenId,19        is_token_create: bool,20        budget: &'a dyn Budget,21    ) -> Self {22        Self {23            sender,24            collection,25            token,26            is_token_create,27            budget,2829            collection_admin_result: None,30            token_owner_result: None31        }32    }3334    pub fn check_collection_admin(&mut self) -> DispatchResult {35        if self.collection_admin_result.is_none() {36            self.collection_admin_result = Some(self.collection.check_is_owner_or_admin(self.sender));37        }3839        self.collection_admin_result.unwrap()40    }4142    pub fn check_token_owner(&mut self) -> DispatchResult {43        if self.token_owner_result.is_none() {44            let is_owned = <PalletStructure<T>>::check_indirectly_owned(45                self.sender.clone(),46                self.collection.id,47                self.token,48                None,49                self.budget,50            )?;5152            let result = if is_owned {53                Ok(())54            } else {55                Err(<CommonError<T>>::NoPermission.into())56            };5758            self.token_owner_result = Some(result);59        }6061        self.token_owner_result.unwrap()62    }63}