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
25};25};
26use up_data_structs::{CreateItemExData, CreateItemData};26use up_data_structs::{CreateItemExData, CreateItemData};
2727
28#[cfg(not(any(feature = "unique-runtime", feature = "quartz-runtime")))]
29macro_rules! max_weight_of {28macro_rules! max_weight_of {
30 ($method:ident ( $($args:tt)* )) => {29 ($method:ident ( $($args:tt)* )) => {{
31 <FungibleWeights<T>>::$method($($args)*)30 let max_weight = <FungibleWeights<T>>::$method($($args)*)
32 .max(<NonfungibleWeights<T>>::$method($($args)*))31 .max(<NonfungibleWeights<T>>::$method($($args)*));
32
33 #[cfg(feature = "refungible")]
33 .max(<RefungibleWeights<T>>::$method($($args)*))34 let max_weight = max_weight.max(<RefungibleWeights<T>>::$method($($args)*));
35
36 max_weight
34 };37 }};
35}38}
39
40#[cfg(not(feature = "refungible"))]
41pub trait CommonWeightConfigs: FungibleConfig + NonfungibleConfig {}
3642
37#[cfg(any(feature = "unique-runtime", feature = "quartz-runtime"))]43#[cfg(not(feature = "refungible"))]
38macro_rules! max_weight_of {
39 ($method:ident ( $($args:tt)* )) => {44impl<T: FungibleConfig + NonfungibleConfig> CommonWeightConfigs for T {}
40 <FungibleWeights<T>>::$method($($args)*)45
41 .max(<NonfungibleWeights<T>>::$method($($args)*))46#[cfg(feature = "refungible")]
4247pub trait CommonWeightConfigs: FungibleConfig + NonfungibleConfig + RefungibleConfig {}
43 };
44}
4548
46#[cfg(not(any(feature = "unique-runtime", feature = "quartz-runtime")))]49#[cfg(feature = "refungible")]
47pub struct CommonWeights<T>(PhantomData<T>)
48where
49 T: FungibleConfig + NonfungibleConfig + RefungibleConfig;50impl<T: FungibleConfig + NonfungibleConfig + RefungibleConfig> CommonWeightConfigs for T {}
51
5052
51#[cfg(not(any(feature = "unique-runtime", feature = "quartz-runtime")))]53pub struct CommonWeights<T>(PhantomData<T>);
54
52impl<T> CommonWeightInfo<T::CrossAccountId> for CommonWeights<T>55impl<T> CommonWeightInfo<T::CrossAccountId> for CommonWeights<T>
53where56where
54 T: FungibleConfig + NonfungibleConfig + RefungibleConfig,57 T: CommonWeightConfigs,
55{58{
56 fn create_item() -> Weight {59 fn create_item() -> Weight {
57 dispatch_weight::<T>() + max_weight_of!(create_item())60 dispatch_weight::<T>() + max_weight_of!(create_item())
114 }117 }
115}118}
116119
117#[cfg(not(any(feature = "unique-runtime", feature = "quartz-runtime")))]120#[cfg(feature = "refungible")]
118impl<T> RefungibleExtensionsWeightInfo for CommonWeights<T>121impl<T> RefungibleExtensionsWeightInfo for CommonWeights<T>
119where122where
120 T: FungibleConfig + NonfungibleConfig + RefungibleConfig,123 T: FungibleConfig + NonfungibleConfig + RefungibleConfig,
124 }127 }
125}128}
126
127#[cfg(any(feature = "unique-runtime", feature = "quartz-runtime"))]
128pub struct CommonWeights<T>(PhantomData<T>)
129where
130 T: FungibleConfig + NonfungibleConfig;
131
132#[cfg(any(feature = "unique-runtime", feature = "quartz-runtime"))]
133impl<T> CommonWeightInfo<T::CrossAccountId> for CommonWeights<T>
134where
135 T: FungibleConfig + NonfungibleConfig,
136{
137 fn create_item() -> Weight {
138 dispatch_weight::<T>() + max_weight_of!(create_item())
139 }
140
141 fn create_multiple_items(data: &[CreateItemData]) -> Weight {
142 dispatch_weight::<T>() + max_weight_of!(create_multiple_items(data))
143 }
144
145 fn create_multiple_items_ex(data: &CreateItemExData<T::CrossAccountId>) -> Weight {
146 dispatch_weight::<T>() + max_weight_of!(create_multiple_items_ex(data))
147 }
148
149 fn burn_item() -> Weight {
150 dispatch_weight::<T>() + max_weight_of!(burn_item())
151 }
152
153 fn set_collection_properties(amount: u32) -> Weight {
154 dispatch_weight::<T>() + max_weight_of!(set_collection_properties(amount))
155 }
156
157 fn delete_collection_properties(amount: u32) -> Weight {
158 dispatch_weight::<T>() + max_weight_of!(delete_collection_properties(amount))
159 }
160
161 fn set_token_properties(amount: u32) -> Weight {
162 dispatch_weight::<T>() + max_weight_of!(set_token_properties(amount))
163 }
164
165 fn delete_token_properties(amount: u32) -> Weight {
166 dispatch_weight::<T>() + max_weight_of!(delete_token_properties(amount))
167 }
168
169 fn set_token_property_permissions(amount: u32) -> Weight {
170 dispatch_weight::<T>() + max_weight_of!(set_token_property_permissions(amount))
171 }
172
173 fn transfer() -> Weight {
174 dispatch_weight::<T>() + max_weight_of!(transfer())
175 }
176
177 fn approve() -> Weight {
178 dispatch_weight::<T>() + max_weight_of!(approve())
179 }
180
181 fn transfer_from() -> Weight {
182 dispatch_weight::<T>() + max_weight_of!(transfer_from())
183 }
184
185 fn burn_from() -> Weight {
186 dispatch_weight::<T>() + max_weight_of!(burn_from())
187 }
188
189 fn burn_recursively_self_raw() -> Weight {
190 max_weight_of!(burn_recursively_self_raw())
191 }
192
193 fn burn_recursively_breadth_raw(amount: u32) -> Weight {
194 max_weight_of!(burn_recursively_breadth_raw(amount))
195 }
196}
197129
198#[cfg(any(feature = "unique-runtime", feature = "quartz-runtime"))]130#[cfg(not(feature = "refungible"))]
199impl<T> RefungibleExtensionsWeightInfo for CommonWeights<T>131impl<T> RefungibleExtensionsWeightInfo for CommonWeights<T>
200where132where
201 T: FungibleConfig + NonfungibleConfig,133 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
--- a/runtime/quartz/Cargo.toml
+++ b/runtime/quartz/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',
@@ -118,6 +118,7 @@
     "orml-vesting/std",
 ]
 limit-testing = ['pallet-unique/limit-testing', 'up-data-structs/limit-testing']
+new-functionality = []
 
 ################################################################################
 # 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