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
32 'frame-support/runtime-benchmarks',32 'frame-support/runtime-benchmarks',
33 'frame-system/runtime-benchmarks',33 'frame-system/runtime-benchmarks',
34]34]
35unique-runtime = ['std']35unique-runtime = []
36quartz-runtime = ['std']36quartz-runtime = []
37
38refungible = []
3739
38[dependencies.sp-core]40[dependencies.sp-core]
39default-features = false41default-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
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',
119 "orml-vesting/std",119 "orml-vesting/std",
120]120]
121limit-testing = ['pallet-unique/limit-testing', 'up-data-structs/limit-testing']121limit-testing = ['pallet-unique/limit-testing', 'up-data-structs/limit-testing']
122new-functionality = [
123 'unique-runtime-common/refungible',
124]
122125
123################################################################################126################################################################################
124# Substrate Dependencies127# 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
16targets = ['x86_64-unknown-linux-gnu']16targets = ['x86_64-unknown-linux-gnu']
1717
18[features]18[features]
19default = ['std', 'unique-runtime']19default = ['std', 'new-functionality']
20runtime-benchmarks = [20runtime-benchmarks = [
21 'hex-literal',21 'hex-literal',
22 'frame-benchmarking',22 'frame-benchmarking',
119 "orml-vesting/std",119 "orml-vesting/std",
120]120]
121limit-testing = ['pallet-unique/limit-testing', 'up-data-structs/limit-testing']121limit-testing = ['pallet-unique/limit-testing', 'up-data-structs/limit-testing']
122unique-runtime = []122new-functionality = []
123123
124################################################################################124################################################################################
125# Substrate Dependencies125# Substrate Dependencies