difftreelog
fix dont read storage during minting when not needed
in: master
2 files changed
pallets/nonfungible/src/lib.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/lib.rs
+++ b/pallets/nonfungible/src/lib.rs
@@ -620,10 +620,22 @@
Ok(is_owned)
});
- let mut is_token_exist =
- pallet_common::LazyValue::new(|| Self::token_exists(collection, token_id));
+ let is_new_token = matches!(mode, SetPropertyMode::NewToken { .. });
+
+ let mut is_token_exist = pallet_common::LazyValue::new(|| {
+ if is_new_token {
+ debug_assert!(Self::token_exists(collection, token_id));
+ true
+ } else {
+ Self::token_exists(collection, token_id)
+ }
+ });
- let stored_properties = <TokenProperties<T>>::get((collection.id, token_id));
+ let stored_properties = if is_new_token {
+ TokenPropertiesT::new()
+ } else {
+ <TokenProperties<T>>::get((collection.id, token_id))
+ };
<PalletCommon<T>>::modify_token_properties(
collection,
pallets/refungible/src/lib.rsdiffbeforeafterboth563 Ok(is_bundle_owner)563 Ok(is_bundle_owner)564 });564 });565566 let is_new_token = matches!(mode, SetPropertyMode::NewToken { .. });565567566 let mut is_token_exist =568 let mut is_token_exist = pallet_common::LazyValue::new(|| {569 if is_new_token {570 debug_assert!(Self::token_exists(collection, token_id));571 true572 } else {567 pallet_common::LazyValue::new(|| Self::token_exists(collection, token_id));573 Self::token_exists(collection, token_id)574 }575 });568576569 let stored_properties = <TokenProperties<T>>::get((collection.id, token_id));577 let stored_properties = if is_new_token {578 TokenPropertiesT::new()579 } else {580 <TokenProperties<T>>::get((collection.id, token_id))581 };570582571 <PalletCommon<T>>::modify_token_properties(583 <PalletCommon<T>>::modify_token_properties(572 collection,584 collection,