git.delta.rocks / unique-network / refs/commits / 67532f473fe2

difftreelog

feat add refungible and new-functionality feature

Daniel Shiposha2022-08-01parent: #7a2dbea.patch.diff
in: master

5 files changed

modifiedruntime/common/Cargo.tomldiffbeforeafterboth
--- a/runtime/common/Cargo.toml
+++ b/runtime/common/Cargo.toml
@@ -32,8 +32,10 @@
     'frame-support/runtime-benchmarks',
     'frame-system/runtime-benchmarks',
 ]
-unique-runtime = ['std']
-quartz-runtime = ['std']
+unique-runtime = []
+quartz-runtime = []
+
+refungible = []
 
 [dependencies.sp-core]
 default-features = false
modifiedruntime/common/src/weights.rsdiffbeforeafterboth
--- a/runtime/common/src/weights.rs
+++ b/runtime/common/src/weights.rs
@@ -25,33 +25,36 @@
 };
 use up_data_structs::{CreateItemExData, CreateItemData};
 
-#[cfg(not(any(feature = "unique-runtime", feature = "quartz-runtime")))]
 macro_rules! max_weight_of {
-	($method:ident ( $($args:tt)* )) => {
-		<FungibleWeights<T>>::$method($($args)*)
-		.max(<NonfungibleWeights<T>>::$method($($args)*))
-		.max(<RefungibleWeights<T>>::$method($($args)*))
-	};
+	($method:ident ( $($args:tt)* )) => {{
+		let max_weight = <FungibleWeights<T>>::$method($($args)*)
+			.max(<NonfungibleWeights<T>>::$method($($args)*));
+
+		#[cfg(feature = "refungible")]
+		let max_weight = max_weight.max(<RefungibleWeights<T>>::$method($($args)*));
+
+		max_weight
+	}};
 }
 
-#[cfg(any(feature = "unique-runtime", feature = "quartz-runtime"))]
-macro_rules! max_weight_of {
-	($method:ident ( $($args:tt)* )) => {
-		<FungibleWeights<T>>::$method($($args)*)
-		.max(<NonfungibleWeights<T>>::$method($($args)*))
+#[cfg(not(feature = "refungible"))]
+pub trait CommonWeightConfigs: FungibleConfig + NonfungibleConfig {}
+
+#[cfg(not(feature = "refungible"))]
+impl<T: FungibleConfig + NonfungibleConfig> CommonWeightConfigs for T {}
+
+#[cfg(feature = "refungible")]
+pub trait CommonWeightConfigs: FungibleConfig + NonfungibleConfig + RefungibleConfig {}
+
+#[cfg(feature = "refungible")]
+impl<T: FungibleConfig + NonfungibleConfig + RefungibleConfig> CommonWeightConfigs for T {}
 
-	};
-}
 
-#[cfg(not(any(feature = "unique-runtime", feature = "quartz-runtime")))]
-pub struct CommonWeights<T>(PhantomData<T>)
-where
-	T: FungibleConfig + NonfungibleConfig + RefungibleConfig;
+pub struct CommonWeights<T>(PhantomData<T>);
 
-#[cfg(not(any(feature = "unique-runtime", feature = "quartz-runtime")))]
 impl<T> CommonWeightInfo<T::CrossAccountId> for CommonWeights<T>
 where
-	T: FungibleConfig + NonfungibleConfig + RefungibleConfig,
+	T: CommonWeightConfigs,
 {
 	fn create_item() -> Weight {
 		dispatch_weight::<T>() + max_weight_of!(create_item())
@@ -114,7 +117,7 @@
 	}
 }
 
-#[cfg(not(any(feature = "unique-runtime", feature = "quartz-runtime")))]
+#[cfg(feature = "refungible")]
 impl<T> RefungibleExtensionsWeightInfo for CommonWeights<T>
 where
 	T: FungibleConfig + NonfungibleConfig + RefungibleConfig,
@@ -124,78 +127,7 @@
 	}
 }
 
-#[cfg(any(feature = "unique-runtime", feature = "quartz-runtime"))]
-pub struct CommonWeights<T>(PhantomData<T>)
-where
-	T: FungibleConfig + NonfungibleConfig;
-
-#[cfg(any(feature = "unique-runtime", feature = "quartz-runtime"))]
-impl<T> CommonWeightInfo<T::CrossAccountId> for CommonWeights<T>
-where
-	T: FungibleConfig + NonfungibleConfig,
-{
-	fn create_item() -> Weight {
-		dispatch_weight::<T>() + max_weight_of!(create_item())
-	}
-
-	fn create_multiple_items(data: &[CreateItemData]) -> Weight {
-		dispatch_weight::<T>() + max_weight_of!(create_multiple_items(data))
-	}
-
-	fn create_multiple_items_ex(data: &CreateItemExData<T::CrossAccountId>) -> Weight {
-		dispatch_weight::<T>() + max_weight_of!(create_multiple_items_ex(data))
-	}
-
-	fn burn_item() -> Weight {
-		dispatch_weight::<T>() + max_weight_of!(burn_item())
-	}
-
-	fn set_collection_properties(amount: u32) -> Weight {
-		dispatch_weight::<T>() + max_weight_of!(set_collection_properties(amount))
-	}
-
-	fn delete_collection_properties(amount: u32) -> Weight {
-		dispatch_weight::<T>() + max_weight_of!(delete_collection_properties(amount))
-	}
-
-	fn set_token_properties(amount: u32) -> Weight {
-		dispatch_weight::<T>() + max_weight_of!(set_token_properties(amount))
-	}
-
-	fn delete_token_properties(amount: u32) -> Weight {
-		dispatch_weight::<T>() + max_weight_of!(delete_token_properties(amount))
-	}
-
-	fn set_token_property_permissions(amount: u32) -> Weight {
-		dispatch_weight::<T>() + max_weight_of!(set_token_property_permissions(amount))
-	}
-
-	fn transfer() -> Weight {
-		dispatch_weight::<T>() + max_weight_of!(transfer())
-	}
-
-	fn approve() -> Weight {
-		dispatch_weight::<T>() + max_weight_of!(approve())
-	}
-
-	fn transfer_from() -> Weight {
-		dispatch_weight::<T>() + max_weight_of!(transfer_from())
-	}
-
-	fn burn_from() -> Weight {
-		dispatch_weight::<T>() + max_weight_of!(burn_from())
-	}
-
-	fn burn_recursively_self_raw() -> Weight {
-		max_weight_of!(burn_recursively_self_raw())
-	}
-
-	fn burn_recursively_breadth_raw(amount: u32) -> Weight {
-		max_weight_of!(burn_recursively_breadth_raw(amount))
-	}
-}
-
-#[cfg(any(feature = "unique-runtime", feature = "quartz-runtime"))]
+#[cfg(not(feature = "refungible"))]
 impl<T> RefungibleExtensionsWeightInfo for CommonWeights<T>
 where
 	T: FungibleConfig + NonfungibleConfig,
modifiedruntime/opal/Cargo.tomldiffbeforeafterboth
--- a/runtime/opal/Cargo.toml
+++ b/runtime/opal/Cargo.toml
@@ -16,7 +16,7 @@
 targets = ['x86_64-unknown-linux-gnu']
 
 [features]
-default = ['std']
+default = ['std', 'new-functionality']
 runtime-benchmarks = [
     'hex-literal',
     'frame-benchmarking',
@@ -119,6 +119,9 @@
     "orml-vesting/std",
 ]
 limit-testing = ['pallet-unique/limit-testing', 'up-data-structs/limit-testing']
+new-functionality = [
+    'unique-runtime-common/refungible',
+]
 
 ################################################################################
 # Substrate Dependencies
modifiedruntime/quartz/Cargo.tomldiffbeforeafterboth
16targets = ['x86_64-unknown-linux-gnu']16targets = ['x86_64-unknown-linux-gnu']
1717
18[features]18[features]
19default = ['std']19default = ['std', 'new-functionality']
20runtime-benchmarks = [20runtime-benchmarks = [
21 'hex-literal',21 'hex-literal',
22 'frame-benchmarking',22 'frame-benchmarking',
118 "orml-vesting/std",118 "orml-vesting/std",
119]119]
120limit-testing = ['pallet-unique/limit-testing', 'up-data-structs/limit-testing']120limit-testing = ['pallet-unique/limit-testing', 'up-data-structs/limit-testing']
121new-functionality = []
121122
122################################################################################123################################################################################
123# Substrate Dependencies124# Substrate Dependencies
modifiedruntime/unique/Cargo.tomldiffbeforeafterboth
--- a/runtime/unique/Cargo.toml
+++ b/runtime/unique/Cargo.toml
@@ -16,7 +16,7 @@
 targets = ['x86_64-unknown-linux-gnu']
 
 [features]
-default = ['std', 'unique-runtime']
+default = ['std', 'new-functionality']
 runtime-benchmarks = [
     'hex-literal',
     'frame-benchmarking',
@@ -119,7 +119,7 @@
     "orml-vesting/std",
 ]
 limit-testing = ['pallet-unique/limit-testing', 'up-data-structs/limit-testing']
-unique-runtime = []
+new-functionality = []
 
 ################################################################################
 # Substrate Dependencies