git.delta.rocks / unique-network / refs/commits / 47c39a449fef

difftreelog

refactor hide permissive unless benchmarking

Farhad Hakimov2022-06-21parent: #011ebf2.patch.diff
in: master

5 files changed

modifiedpallets/common/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/common/src/benchmarking.rs
+++ b/pallets/common/src/benchmarking.rs
@@ -98,6 +98,7 @@
 					token_owner: false,
 					collection_admin: false,
 					restricted: None,
+					#[cfg(feature = "runtime-benchmarks")]
 					permissive: true,
 				}),
 				mint_mode: Some(true),
modifiedpallets/common/src/lib.rsdiffbeforeafterboth
--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -1212,14 +1212,7 @@
 		limit_default_clone!(old_limit, new_limit,
 			access => {},
 			mint_mode => {},
-			nesting => {
-				#[cfg(not(feature = "runtime-benchmarks"))]
-				ensure!(
-					// Permissive is only allowed for tests and internal usage of chain for now
-					old_limit.permissive || !new_limit.permissive,
-					<Error<T>>::NoPermission,
-				)
-			},
+			nesting => { /* todo check for permissive, if only it gets out of benchmarks */ },
 		);
 		Ok(new_limit)
 	}
modifiedpallets/nonfungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/lib.rs
+++ b/pallets/nonfungible/src/lib.rs
@@ -1038,7 +1038,13 @@
 		nesting_budget: &dyn Budget,
 	) -> DispatchResult {
 		let nesting = handle.permissions.nesting();
-		if nesting.permissive {
+		
+		#[cfg(not(feature = "runtime-benchmarks"))]
+		let permissive = false;
+		#[cfg(feature = "runtime-benchmarks")]
+		let permissive = nesting.permissive;
+
+		if permissive {
 			// Pass
 		} else if nesting.token_owner
 			&& <PalletStructure<T>>::check_indirectly_owned(
modifiedpallets/proxy-rmrk-core/src/lib.rsdiffbeforeafterboth
--- a/pallets/proxy-rmrk-core/src/lib.rs
+++ b/pallets/proxy-rmrk-core/src/lib.rs
@@ -205,7 +205,7 @@
 						token_owner: true,
 						collection_admin: false,
 						restricted: None,
-
+						#[cfg(feature = "runtime-benchmarks")]
 						permissive: false,
 					}),
 					..Default::default()
modifiedprimitives/data-structs/src/lib.rsdiffbeforeafterboth
454 token_owner: false,454 token_owner: false,
455 collection_admin: false,455 collection_admin: false,
456 restricted: None,456 restricted: None,
457457 #[cfg(feature = "runtime-benchmarks")]
458 permissive: false,458 permissive: false,
459 };459 };
460 self.nesting.as_ref().unwrap_or(&DEFAULT)460 self.nesting.as_ref().unwrap_or(&DEFAULT)
499 /// If set - only tokens from specified collections can be nested499 /// If set - only tokens from specified collections can be nested
500 pub restricted: Option<OwnerRestrictedSet>,500 pub restricted: Option<OwnerRestrictedSet>,
501501
502 #[cfg(feature = "runtime-benchmarks")]
502 /// Anyone can nest tokens, mutually exclusive with `token_owner`, `admin`503 /// Anyone can nest tokens, mutually exclusive with `token_owner`, `admin`
503 pub permissive: bool,504 pub permissive: bool,
504}505}