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

difftreelog

Merge pull request #828 from UniqueNetwork/fix/bulk-set-properties

Yaroslav Bolyukin2023-01-16parents: #46515fa #91e514b.patch.diff
in: master
Fix/bulk set properties

10 files changed

modifiedpallets/common/src/benchmarking.rsdiffbeforeafterboth
176 key: property_key(p as usize),176 key: property_key(p as usize),
177 value: property_value(),177 value: property_value(),
178 }).collect::<Vec<_>>();178 }).collect::<Vec<_>>();
179 }: {<Pallet<T>>::set_collection_properties(&collection, &owner, props)?}179 }: {<Pallet<T>>::set_collection_properties(&collection, &owner, props.into_iter())?}
180180
181 delete_collection_properties {181 delete_collection_properties {
182 let b in 0..MAX_PROPERTIES_PER_ITEM;182 let b in 0..MAX_PROPERTIES_PER_ITEM;
188 key: property_key(p as usize),188 key: property_key(p as usize),
189 value: property_value(),189 value: property_value(),
190 }).collect::<Vec<_>>();190 }).collect::<Vec<_>>();
191 <Pallet<T>>::set_collection_properties(&collection, &owner, props)?;191 <Pallet<T>>::set_collection_properties(&collection, &owner, props.into_iter())?;
192 let to_delete = (0..b).map(|p| property_key(p as usize)).collect::<Vec<_>>();192 let to_delete = (0..b).map(|p| property_key(p as usize)).collect::<Vec<_>>();
193 }: {<Pallet<T>>::delete_collection_properties(&collection, &owner, to_delete)?}193 }: {<Pallet<T>>::delete_collection_properties(&collection, &owner, to_delete.into_iter())?}
194}194}
195195
modifiedpallets/common/src/erc.rsdiffbeforeafterboth
125 .map(eth::Property::try_into)125 .map(eth::Property::try_into)
126 .collect::<Result<Vec<_>>>()?;126 .collect::<Result<Vec<_>>>()?;
127127
128 <Pallet<T>>::set_collection_properties(self, &caller, properties)128 <Pallet<T>>::set_collection_properties(self, &caller, properties.into_iter())
129 .map_err(dispatch_to_evm::<T>)129 .map_err(dispatch_to_evm::<T>)
130 }130 }
131131
158 })158 })
159 .collect::<Result<Vec<_>>>()?;159 .collect::<Result<Vec<_>>>()?;
160160
161 <Pallet<T>>::delete_collection_properties(self, &caller, keys).map_err(dispatch_to_evm::<T>)161 <Pallet<T>>::delete_collection_properties(self, &caller, keys.into_iter())
162 .map_err(dispatch_to_evm::<T>)
162 }163 }
163164
modifiedpallets/common/src/lib.rsdiffbeforeafterboth
1198 Ok(())1198 Ok(())
1199 }1199 }
12001200
1201 /// Set collection property.1201 /// This function sets or removes a collection properties according to
1202 /// `properties_updates` contents:
1203 /// * sets a property under the <key> with the value provided `(<key>, Some(<value>))`
1204 /// * removes a property under the <key> if the value is `None` `(<key>, None)`.
1202 ///1205 ///
1203 /// * `collection` - Collection handler.1206 /// This function fires an event for each property change.
1204 /// * `sender` - The owner or administrator of the collection.1207 /// In case of an error, all the changes (including the events) will be reverted
1205 /// * `property` - The property to set.1208 /// since the function is transactional.
1209 #[transactional]
1206 pub fn set_collection_property(1210 fn modify_collection_properties(
1207 collection: &CollectionHandle<T>,1211 collection: &CollectionHandle<T>,
1208 sender: &T::CrossAccountId,1212 sender: &T::CrossAccountId,
1209 property: Property,1213 properties_updates: impl Iterator<Item = (PropertyKey, Option<PropertyValue>)>,
1210 ) -> DispatchResult {1214 ) -> DispatchResult {
1211 collection.check_is_owner_or_admin(sender)?;1215 collection.check_is_owner_or_admin(sender)?;
12121216
1213 CollectionProperties::<T>::try_mutate(collection.id, |properties| {1217 let mut stored_properties = <CollectionProperties<T>>::get(collection.id);
1214 let property = property.clone();1218
1215 properties.try_set(property.key, property.value)1219 for (key, value) in properties_updates {
1216 })1220 match value {
1217 .map_err(<Error<T>>::from)?;1221 Some(value) => {
12181222 stored_properties
1223 .try_set(key.clone(), value)
1219 Self::deposit_event(Event::CollectionPropertySet(collection.id, property.key));1224 .map_err(<Error<T>>::from)?;
1225
1226 Self::deposit_event(Event::CollectionPropertySet(collection.id, key));
1220 <PalletEvm<T>>::deposit_log(1227 <PalletEvm<T>>::deposit_log(
1221 erc::CollectionHelpersEvents::CollectionChanged {1228 erc::CollectionHelpersEvents::CollectionChanged {
1222 collection_id: eth::collection_id_to_address(collection.id),1229 collection_id: eth::collection_id_to_address(collection.id),
1223 }1230 }
1224 .to_log(T::ContractAddress::get()),1231 .to_log(T::ContractAddress::get()),
1225 );1232 );
1233 }
1234 None => {
1235 stored_properties.remove(&key).map_err(<Error<T>>::from)?;
1236
1237 Self::deposit_event(Event::CollectionPropertyDeleted(collection.id, key));
1238 <PalletEvm<T>>::deposit_log(
1239 erc::CollectionHelpersEvents::CollectionChanged {
1240 collection_id: eth::collection_id_to_address(collection.id),
1241 }
1242 .to_log(T::ContractAddress::get()),
1243 );
1244 }
1245 }
1246 }
1247
1248 <CollectionProperties<T>>::set(collection.id, stored_properties);
12261249
1227 Ok(())1250 Ok(())
1228 }1251 }
1252
1253 /// Set collection property.
1254 ///
1255 /// * `collection` - Collection handler.
1256 /// * `sender` - The owner or administrator of the collection.
1257 /// * `property` - The property to set.
1258 pub fn set_collection_property(
1259 collection: &CollectionHandle<T>,
1260 sender: &T::CrossAccountId,
1261 property: Property,
1262 ) -> DispatchResult {
1263 Self::set_collection_properties(collection, sender, [property].into_iter())
1264 }
12291265
1230 /// Set a scoped collection property, where the scope is a special prefix1266 /// Set a scoped collection property, where the scope is a special prefix
1231 /// prohibiting a user access to change the property directly.1267 /// prohibiting a user access to change the property directly.
1270 /// * `collection` - Collection handler.1306 /// * `collection` - Collection handler.
1271 /// * `sender` - The owner or administrator of the collection.1307 /// * `sender` - The owner or administrator of the collection.
1272 /// * `properties` - The properties to set.1308 /// * `properties` - The properties to set.
1273 #[transactional]
1274 pub fn set_collection_properties(1309 pub fn set_collection_properties(
1275 collection: &CollectionHandle<T>,1310 collection: &CollectionHandle<T>,
1276 sender: &T::CrossAccountId,1311 sender: &T::CrossAccountId,
1277 properties: Vec<Property>,1312 properties: impl Iterator<Item = Property>,
1278 ) -> DispatchResult {1313 ) -> DispatchResult {
1279 for property in properties {
1280 Self::set_collection_property(collection, sender, property)?;1314 Self::modify_collection_properties(
1281 }1315 collection,
12821316 sender,
1283 Ok(())1317 properties.map(|property| (property.key, Some(property.value))),
1318 )
1284 }1319 }
12851320
1293 sender: &T::CrossAccountId,1328 sender: &T::CrossAccountId,
1294 property_key: PropertyKey,1329 property_key: PropertyKey,
1295 ) -> DispatchResult {1330 ) -> DispatchResult {
1296 collection.check_is_owner_or_admin(sender)?;
1297
1298 CollectionProperties::<T>::try_mutate(collection.id, |properties| {
1299 properties.remove(&property_key)
1300 })
1301 .map_err(<Error<T>>::from)?;
1302
1303 Self::deposit_event(Event::CollectionPropertyDeleted(
1304 collection.id,
1305 property_key,
1306 ));
1307 <PalletEvm<T>>::deposit_log(1331 Self::delete_collection_properties(collection, sender, [property_key].into_iter())
1308 erc::CollectionHelpersEvents::CollectionChanged {
1309 collection_id: eth::collection_id_to_address(collection.id),
1310 }
1311 .to_log(T::ContractAddress::get()),
1312 );
1313
1314 Ok(())
1315 }1332 }
13161333
1317 /// Delete collection properties.1334 /// Delete collection properties.
1318 ///1335 ///
1319 /// * `collection` - Collection handler.1336 /// * `collection` - Collection handler.
1320 /// * `sender` - The owner or administrator of the collection.1337 /// * `sender` - The owner or administrator of the collection.
1321 /// * `properties` - The properties to delete.1338 /// * `properties` - The properties to delete.
1322 #[transactional]
1323 pub fn delete_collection_properties(1339 pub fn delete_collection_properties(
1324 collection: &CollectionHandle<T>,1340 collection: &CollectionHandle<T>,
1325 sender: &T::CrossAccountId,1341 sender: &T::CrossAccountId,
1326 property_keys: Vec<PropertyKey>,1342 property_keys: impl Iterator<Item = PropertyKey>,
1327 ) -> DispatchResult {1343 ) -> DispatchResult {
1328 for key in property_keys {
1329 Self::delete_collection_property(collection, sender, key)?;1344 Self::modify_collection_properties(collection, sender, property_keys.map(|key| (key, None)))
1330 }
1331
1332 Ok(())
1333 }1345 }
13341346
1335 /// Set collection propetry permission without any checks.1347 /// Set collection propetry permission without any checks.
modifiedpallets/fungible/src/lib.rsdiffbeforeafterboth
266 sender: &T::CrossAccountId,266 sender: &T::CrossAccountId,
267 properties: Vec<Property>,267 properties: Vec<Property>,
268 ) -> DispatchResult {268 ) -> DispatchResult {
269 <PalletCommon<T>>::set_collection_properties(collection, sender, properties)269 <PalletCommon<T>>::set_collection_properties(collection, sender, properties.into_iter())
270 }270 }
271271
272 /// Delete properties of the collection, associated with the provided keys.272 /// Delete properties of the collection, associated with the provided keys.
278 <PalletCommon<T>>::delete_collection_properties(collection, sender, property_keys)278 <PalletCommon<T>>::delete_collection_properties(
279 collection,
280 sender,
281 property_keys.into_iter(),
282 )
279 }283 }
280284
modifiedpallets/nonfungible/src/lib.rsdiffbeforeafterboth
577 })577 })
578 }578 }
579579
580 /// Batch operation to add, edit or remove properties for the token580 /// A batch operation to add, edit or remove properties for a token.
581 ///581 /// It sets or removes a token's properties according to
582 /// All affected properties should have mutable permission and sender should have582 /// `properties_updates` contents:
583 /// permission to edit those properties.583 /// * sets a property under the <key> with the value provided `(<key>, Some(<value>))`
584 /// * removes a property under the <key> if the value is `None` `(<key>, None)`.
584 ///585 ///
585 /// - `nesting_budget`: Limit for searching parents in depth to check ownership.586 /// - `nesting_budget`: Limit for searching parents in-depth to check ownership.
586 /// - `is_token_create`: Indicates that method is called during token initialization.587 /// - `is_token_create`: Indicates that method is called during token initialization.
587 /// Allows to bypass ownership check.588 /// Allows to bypass ownership check.
589 ///
590 /// All affected properties should have `mutable` permission
591 /// to be **deleted** or to be **set more than once**,
592 /// and the sender should have permission to edit those properties.
593 ///
594 /// This function fires an event for each property change.
595 /// In case of an error, all the changes (including the events) will be reverted
596 /// since the function is transactional.
588 #[transactional]597 #[transactional]
589 fn modify_token_properties(598 fn modify_token_properties(
590 collection: &NonfungibleHandle<T>,599 collection: &NonfungibleHandle<T>,
591 sender: &T::CrossAccountId,600 sender: &T::CrossAccountId,
592 token_id: TokenId,601 token_id: TokenId,
593 properties: impl Iterator<Item = (PropertyKey, Option<PropertyValue>)>,602 properties_updates: impl Iterator<Item = (PropertyKey, Option<PropertyValue>)>,
594 is_token_create: bool,603 is_token_create: bool,
595 nesting_budget: &dyn Budget,604 nesting_budget: &dyn Budget,
596 ) -> DispatchResult {605 ) -> DispatchResult {
614 })623 })
615 };624 };
625
626 let mut stored_properties = <TokenProperties<T>>::get((collection.id, token_id));
627 let permissions = <PalletCommon<T>>::property_permissions(collection.id);
616628
617 for (key, value) in properties {629 for (key, value) in properties_updates {
618 let permission = <PalletCommon<T>>::property_permissions(collection.id)630 let permission = permissions
619 .get(&key)631 .get(&key)
620 .cloned()632 .cloned()
621 .unwrap_or_else(PropertyPermission::none);633 .unwrap_or_else(PropertyPermission::none);
622634
623 let is_property_exists = TokenProperties::<T>::get((collection.id, token_id))635 let is_property_exists = stored_properties.get(&key).is_some();
624 .get(&key)
625 .is_some();
626636
649659
650 match value {660 match value {
651 Some(value) => {661 Some(value) => {
652 <TokenProperties<T>>::try_mutate((collection.id, token_id), |properties| {662 stored_properties
653 properties.try_set(key.clone(), value)663 .try_set(key.clone(), value)
654 })
655 .map_err(<CommonError<T>>::from)?;664 .map_err(<CommonError<T>>::from)?;
656665
657 <PalletCommon<T>>::deposit_event(CommonEvent::TokenPropertySet(666 <PalletCommon<T>>::deposit_event(CommonEvent::TokenPropertySet(
661 ));670 ));
662 }671 }
663 None => {672 None => {
664 <TokenProperties<T>>::try_mutate((collection.id, token_id), |properties| {673 stored_properties
665 properties.remove(&key)674 .remove(&key)
666 })
667 .map_err(<CommonError<T>>::from)?;675 .map_err(<CommonError<T>>::from)?;
668676
669 <PalletCommon<T>>::deposit_event(CommonEvent::TokenPropertyDeleted(677 <PalletCommon<T>>::deposit_event(CommonEvent::TokenPropertyDeleted(
683 );691 );
684 }692 }
693
694 <TokenProperties<T>>::set((collection.id, token_id), stored_properties);
685695
686 Ok(())696 Ok(())
687 }697 }
784 sender: &T::CrossAccountId,794 sender: &T::CrossAccountId,
785 properties: Vec<Property>,795 properties: Vec<Property>,
786 ) -> DispatchResult {796 ) -> DispatchResult {
787 <PalletCommon<T>>::set_collection_properties(collection, sender, properties)797 <PalletCommon<T>>::set_collection_properties(collection, sender, properties.into_iter())
788 }798 }
789799
790 /// Remove properties from the collection800 /// Remove properties from the collection
796 <PalletCommon<T>>::delete_collection_properties(collection, sender, property_keys)806 <PalletCommon<T>>::delete_collection_properties(
807 collection,
808 sender,
809 property_keys.into_iter(),
810 )
797 }811 }
798812
modifiedpallets/nonfungible/src/weights.rsdiffbeforeafterboth
184 .saturating_add(T::DbWeight::get().reads(1 as u64))184 .saturating_add(T::DbWeight::get().reads(1 as u64))
185 .saturating_add(T::DbWeight::get().writes(1 as u64))185 .saturating_add(T::DbWeight::get().writes(1 as u64))
186 }186 }
187 // Storage: Common CollectionPropertyPermissions (r:1 w:0)
188 // Storage: Nonfungible TokenProperties (r:1 w:1)187 // Storage: Nonfungible TokenProperties (r:1 w:1)
188 // Storage: Common CollectionPropertyPermissions (r:1 w:0)
189 fn set_token_properties(b: u32, ) -> Weight {189 fn set_token_properties(b: u32, ) -> Weight {
190 Weight::from_ref_time(4_361_000 as u64)190 Weight::from_ref_time(31_850_484 as u64)
191 // Standard Error: 5_349_868191 // Standard Error: 9_618
192 .saturating_add(Weight::from_ref_time(637_246_356 as u64).saturating_mul(b as u64))192 .saturating_add(Weight::from_ref_time(4_721_947 as u64).saturating_mul(b as u64))
193 .saturating_add(T::DbWeight::get().reads(2 as u64))193 .saturating_add(T::DbWeight::get().reads(2 as u64))
194 .saturating_add(T::DbWeight::get().writes(1 as u64))194 .saturating_add(T::DbWeight::get().writes(1 as u64))
195 }195 }
196 // Storage: Common CollectionPropertyPermissions (r:1 w:0)
197 // Storage: Nonfungible TokenProperties (r:1 w:1)196 // Storage: Nonfungible TokenProperties (r:1 w:1)
197 // Storage: Common CollectionPropertyPermissions (r:1 w:0)
198 fn delete_token_properties(b: u32, ) -> Weight {198 fn delete_token_properties(b: u32, ) -> Weight {
199 Weight::from_ref_time(4_489_000 as u64)199 Weight::from_ref_time(13_795_000 as u64)
200 // Standard Error: 5_738_954200 // Standard Error: 28_239
201 .saturating_add(Weight::from_ref_time(689_912_822 as u64).saturating_mul(b as u64))201 .saturating_add(Weight::from_ref_time(12_840_446 as u64).saturating_mul(b as u64))
202 .saturating_add(T::DbWeight::get().reads(2 as u64))202 .saturating_add(T::DbWeight::get().reads(2 as u64))
203 .saturating_add(T::DbWeight::get().writes(1 as u64))203 .saturating_add(T::DbWeight::get().writes(1 as u64))
204 }204 }
354 .saturating_add(RocksDbWeight::get().reads(1 as u64))354 .saturating_add(RocksDbWeight::get().reads(1 as u64))
355 .saturating_add(RocksDbWeight::get().writes(1 as u64))355 .saturating_add(RocksDbWeight::get().writes(1 as u64))
356 }356 }
357 // Storage: Common CollectionPropertyPermissions (r:1 w:0)
358 // Storage: Nonfungible TokenProperties (r:1 w:1)357 // Storage: Nonfungible TokenProperties (r:1 w:1)
358 // Storage: Common CollectionPropertyPermissions (r:1 w:0)
359 fn set_token_properties(b: u32, ) -> Weight {359 fn set_token_properties(b: u32, ) -> Weight {
360 Weight::from_ref_time(4_361_000 as u64)360 Weight::from_ref_time(31_850_484 as u64)
361 // Standard Error: 5_349_868361 // Standard Error: 9_618
362 .saturating_add(Weight::from_ref_time(637_246_356 as u64).saturating_mul(b as u64))362 .saturating_add(Weight::from_ref_time(4_721_947 as u64).saturating_mul(b as u64))
363 .saturating_add(RocksDbWeight::get().reads(2 as u64))363 .saturating_add(RocksDbWeight::get().reads(2 as u64))
364 .saturating_add(RocksDbWeight::get().writes(1 as u64))364 .saturating_add(RocksDbWeight::get().writes(1 as u64))
365 }365 }
366 // Storage: Common CollectionPropertyPermissions (r:1 w:0)
367 // Storage: Nonfungible TokenProperties (r:1 w:1)366 // Storage: Nonfungible TokenProperties (r:1 w:1)
367 // Storage: Common CollectionPropertyPermissions (r:1 w:0)
368 fn delete_token_properties(b: u32, ) -> Weight {368 fn delete_token_properties(b: u32, ) -> Weight {
369 Weight::from_ref_time(4_489_000 as u64)369 Weight::from_ref_time(13_795_000 as u64)
370 // Standard Error: 5_738_954370 // Standard Error: 28_239
371 .saturating_add(Weight::from_ref_time(689_912_822 as u64).saturating_mul(b as u64))371 .saturating_add(Weight::from_ref_time(12_840_446 as u64).saturating_mul(b as u64))
372 .saturating_add(RocksDbWeight::get().reads(2 as u64))372 .saturating_add(RocksDbWeight::get().reads(2 as u64))
373 .saturating_add(RocksDbWeight::get().writes(1 as u64))373 .saturating_add(RocksDbWeight::get().writes(1 as u64))
374 }374 }
modifiedpallets/refungible/src/lib.rsdiffbeforeafterboth
515 Ok(())515 Ok(())
516 }516 }
517517
518 /// A batch operation to add, edit or remove properties for a token.
519 /// It sets or removes a token's properties according to
520 /// `properties_updates` contents:
521 /// * sets a property under the <key> with the value provided `(<key>, Some(<value>))`
522 /// * removes a property under the <key> if the value is `None` `(<key>, None)`.
523 ///
524 /// - `nesting_budget`: Limit for searching parents in-depth to check ownership.
525 /// - `is_token_create`: Indicates that method is called during token initialization.
526 /// Allows to bypass ownership check.
527 ///
528 /// All affected properties should have `mutable` permission
529 /// to be **deleted** or to be **set more than once**,
530 /// and the sender should have permission to edit those properties.
531 ///
532 /// This function fires an event for each property change.
533 /// In case of an error, all the changes (including the events) will be reverted
534 /// since the function is transactional.
518 #[transactional]535 #[transactional]
519 fn modify_token_properties(536 fn modify_token_properties(
520 collection: &RefungibleHandle<T>,537 collection: &RefungibleHandle<T>,
521 sender: &T::CrossAccountId,538 sender: &T::CrossAccountId,
522 token_id: TokenId,539 token_id: TokenId,
523 properties: impl Iterator<Item = (PropertyKey, Option<PropertyValue>)>,540 properties_updates: impl Iterator<Item = (PropertyKey, Option<PropertyValue>)>,
524 is_token_create: bool,541 is_token_create: bool,
525 nesting_budget: &dyn Budget,542 nesting_budget: &dyn Budget,
526 ) -> DispatchResult {543 ) -> DispatchResult {
544 Ok(is_bundle_owner)561 Ok(is_bundle_owner)
545 };562 };
563
564 let mut stored_properties = <TokenProperties<T>>::get((collection.id, token_id));
565 let permissions = <PalletCommon<T>>::property_permissions(collection.id);
546566
547 for (key, value) in properties {567 for (key, value) in properties_updates {
548 let permission = <PalletCommon<T>>::property_permissions(collection.id)568 let permission = permissions
549 .get(&key)569 .get(&key)
550 .cloned()570 .cloned()
551 .unwrap_or_else(PropertyPermission::none);571 .unwrap_or_else(PropertyPermission::none);
552572
553 let is_property_exists = TokenProperties::<T>::get((collection.id, token_id))573 let is_property_exists = stored_properties.get(&key).is_some();
554 .get(&key)
555 .is_some();
556574
578596
579 match value {597 match value {
580 Some(value) => {598 Some(value) => {
581 <TokenProperties<T>>::try_mutate((collection.id, token_id), |properties| {599 stored_properties
582 properties.try_set(key.clone(), value)600 .try_set(key.clone(), value)
583 })
584 .map_err(<CommonError<T>>::from)?;601 .map_err(<CommonError<T>>::from)?;
585602
586 <PalletCommon<T>>::deposit_event(CommonEvent::TokenPropertySet(603 <PalletCommon<T>>::deposit_event(CommonEvent::TokenPropertySet(
590 ));607 ));
591 }608 }
592 None => {609 None => {
593 <TokenProperties<T>>::try_mutate((collection.id, token_id), |properties| {610 stored_properties
594 properties.remove(&key)611 .remove(&key)
595 })
596 .map_err(<CommonError<T>>::from)?;612 .map_err(<CommonError<T>>::from)?;
597613
598 <PalletCommon<T>>::deposit_event(CommonEvent::TokenPropertyDeleted(614 <PalletCommon<T>>::deposit_event(CommonEvent::TokenPropertyDeleted(
612 );628 );
613 }629 }
630
631 <TokenProperties<T>>::set((collection.id, token_id), stored_properties);
614632
615 Ok(())633 Ok(())
616 }634 }
1353 sender: &T::CrossAccountId,1371 sender: &T::CrossAccountId,
1354 properties: Vec<Property>,1372 properties: Vec<Property>,
1355 ) -> DispatchResult {1373 ) -> DispatchResult {
1356 <PalletCommon<T>>::set_collection_properties(collection, sender, properties)1374 <PalletCommon<T>>::set_collection_properties(collection, sender, properties.into_iter())
1357 }1375 }
13581376
1359 pub fn delete_collection_properties(1377 pub fn delete_collection_properties(
1364 <PalletCommon<T>>::delete_collection_properties(collection, sender, property_keys)1382 <PalletCommon<T>>::delete_collection_properties(
1383 collection,
1384 sender,
1385 property_keys.into_iter(),
1386 )
1365 }1387 }
13661388
modifiedpallets/refungible/src/weights.rsdiffbeforeafterboth
246 .saturating_add(T::DbWeight::get().reads(1 as u64))246 .saturating_add(T::DbWeight::get().reads(1 as u64))
247 .saturating_add(T::DbWeight::get().writes(1 as u64))247 .saturating_add(T::DbWeight::get().writes(1 as u64))
248 }248 }
249 // Storage: Common CollectionPropertyPermissions (r:1 w:0)
250 // Storage: Refungible TokenProperties (r:1 w:1)249 // Storage: Refungible TokenProperties (r:1 w:1)
250 // Storage: Common CollectionPropertyPermissions (r:1 w:0)
251 fn set_token_properties(b: u32, ) -> Weight {251 fn set_token_properties(b: u32, ) -> Weight {
252 Weight::from_ref_time(4_578_000 as u64)252 Weight::from_ref_time(25_518_267 as u64)
253 // Standard Error: 5_396_287253 // Standard Error: 20_451
254 .saturating_add(Weight::from_ref_time(633_314_546 as u64).saturating_mul(b as u64))254 .saturating_add(Weight::from_ref_time(5_041_089 as u64).saturating_mul(b as u64))
255 .saturating_add(T::DbWeight::get().reads(2 as u64))255 .saturating_add(T::DbWeight::get().reads(2 as u64))
256 .saturating_add(T::DbWeight::get().writes(1 as u64))256 .saturating_add(T::DbWeight::get().writes(1 as u64))
257 }257 }
258 // Storage: Common CollectionPropertyPermissions (r:1 w:0)
259 // Storage: Refungible TokenProperties (r:1 w:1)258 // Storage: Refungible TokenProperties (r:1 w:1)
259 // Storage: Common CollectionPropertyPermissions (r:1 w:0)
260 fn delete_token_properties(b: u32, ) -> Weight {260 fn delete_token_properties(b: u32, ) -> Weight {
261 Weight::from_ref_time(4_583_000 as u64)261 Weight::from_ref_time(13_715_000 as u64)
262 // Standard Error: 5_762_380262 // Standard Error: 28_323
263 .saturating_add(Weight::from_ref_time(696_007_076 as u64).saturating_mul(b as u64))263 .saturating_add(Weight::from_ref_time(13_113_351 as u64).saturating_mul(b as u64))
264 .saturating_add(T::DbWeight::get().reads(2 as u64))264 .saturating_add(T::DbWeight::get().reads(2 as u64))
265 .saturating_add(T::DbWeight::get().writes(1 as u64))265 .saturating_add(T::DbWeight::get().writes(1 as u64))
266 }266 }
478 .saturating_add(RocksDbWeight::get().reads(1 as u64))478 .saturating_add(RocksDbWeight::get().reads(1 as u64))
479 .saturating_add(RocksDbWeight::get().writes(1 as u64))479 .saturating_add(RocksDbWeight::get().writes(1 as u64))
480 }480 }
481 // Storage: Common CollectionPropertyPermissions (r:1 w:0)
482 // Storage: Refungible TokenProperties (r:1 w:1)481 // Storage: Refungible TokenProperties (r:1 w:1)
482 // Storage: Common CollectionPropertyPermissions (r:1 w:0)
483 fn set_token_properties(b: u32, ) -> Weight {483 fn set_token_properties(b: u32, ) -> Weight {
484 Weight::from_ref_time(4_578_000 as u64)484 Weight::from_ref_time(25_518_267 as u64)
485 // Standard Error: 5_396_287485 // Standard Error: 20_451
486 .saturating_add(Weight::from_ref_time(633_314_546 as u64).saturating_mul(b as u64))486 .saturating_add(Weight::from_ref_time(5_041_089 as u64).saturating_mul(b as u64))
487 .saturating_add(RocksDbWeight::get().reads(2 as u64))487 .saturating_add(RocksDbWeight::get().reads(2 as u64))
488 .saturating_add(RocksDbWeight::get().writes(1 as u64))488 .saturating_add(RocksDbWeight::get().writes(1 as u64))
489 }489 }
490 // Storage: Common CollectionPropertyPermissions (r:1 w:0)
491 // Storage: Refungible TokenProperties (r:1 w:1)490 // Storage: Refungible TokenProperties (r:1 w:1)
491 // Storage: Common CollectionPropertyPermissions (r:1 w:0)
492 fn delete_token_properties(b: u32, ) -> Weight {492 fn delete_token_properties(b: u32, ) -> Weight {
493 Weight::from_ref_time(4_583_000 as u64)493 Weight::from_ref_time(13_715_000 as u64)
494 // Standard Error: 5_762_380494 // Standard Error: 28_323
495 .saturating_add(Weight::from_ref_time(696_007_076 as u64).saturating_mul(b as u64))495 .saturating_add(Weight::from_ref_time(13_113_351 as u64).saturating_mul(b as u64))
496 .saturating_add(RocksDbWeight::get().reads(2 as u64))496 .saturating_add(RocksDbWeight::get().reads(2 as u64))
497 .saturating_add(RocksDbWeight::get().writes(1 as u64))497 .saturating_add(RocksDbWeight::get().writes(1 as u64))
498 }498 }
modifiedpallets/unique/src/eth/mod.rsdiffbeforeafterboth
33};33};
34use pallet_evm::{account::CrossAccountId, OnMethodCall, PrecompileHandle, PrecompileResult};34use pallet_evm::{account::CrossAccountId, OnMethodCall, PrecompileHandle, PrecompileResult};
35use pallet_evm_coder_substrate::{dispatch_to_evm, SubstrateRecorder, WithRecorder};35use pallet_evm_coder_substrate::{dispatch_to_evm, SubstrateRecorder, WithRecorder};
36use sp_std::vec;
37use up_data_structs::{36use up_data_structs::{
38 CollectionDescription, CollectionMode, CollectionName, CollectionTokenPrefix,37 CollectionDescription, CollectionMode, CollectionName, CollectionTokenPrefix,
39 CreateCollectionData,38 CreateCollectionData,
316 <PalletCommon<T>>::set_collection_properties(315 <PalletCommon<T>>::set_collection_properties(
317 &collection,316 &collection,
318 &caller,317 &caller,
319 vec![up_data_structs::Property {318 [up_data_structs::Property {
320 key: key::base_uri(),319 key: key::base_uri(),
321 value: base_uri320 value: base_uri
322 .into_bytes()321 .into_bytes()
323 .try_into()322 .try_into()
324 .map_err(|_| "base uri is too large")?,323 .map_err(|_| "base uri is too large")?,
325 }],324 }]
325 .into_iter(),
326 )326 )
327 .map_err(dispatch_to_evm::<T>)?;327 .map_err(dispatch_to_evm::<T>)?;
328 }328 }
modifiedruntime/common/identity.rsdiffbeforeafterboth
24 transaction_validity::{TransactionValidity, ValidTransaction, TransactionValidityError},24 transaction_validity::{TransactionValidity, ValidTransaction, TransactionValidityError},
25};25};
26
27#[cfg(feature = "collator-selection")]
28use sp_runtime::transaction_validity::InvalidTransaction;
2629
27#[derive(Debug, Encode, Decode, PartialEq, Eq, Clone, TypeInfo)]30#[derive(Debug, Encode, Decode, PartialEq, Eq, Clone, TypeInfo)]
28pub struct DisableIdentityCalls;31pub struct DisableIdentityCalls;