difftreelog
fix dont read storage during minting when not needed
in: master
2 files changed
pallets/nonfungible/src/lib.rsdiffbeforeafterboth620 Ok(is_owned)620 Ok(is_owned)621 });621 });622623 let is_new_token = matches!(mode, SetPropertyMode::NewToken { .. });622624623 let mut is_token_exist =625 let mut is_token_exist = pallet_common::LazyValue::new(|| {626 if is_new_token {627 debug_assert!(Self::token_exists(collection, token_id));628 true629 } else {624 pallet_common::LazyValue::new(|| Self::token_exists(collection, token_id));630 Self::token_exists(collection, token_id)631 }632 });625633626 let stored_properties = <TokenProperties<T>>::get((collection.id, token_id));634 let stored_properties = if is_new_token {635 TokenPropertiesT::new()636 } else {637 <TokenProperties<T>>::get((collection.id, token_id))638 };627639628 <PalletCommon<T>>::modify_token_properties(640 <PalletCommon<T>>::modify_token_properties(629 collection,641 collection,pallets/refungible/src/lib.rsdiffbeforeafterboth--- a/pallets/refungible/src/lib.rs
+++ b/pallets/refungible/src/lib.rs
@@ -563,10 +563,22 @@
Ok(is_bundle_owner)
});
- 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,