git.delta.rocks / unique-network / refs/commits / 101a18907270

difftreelog

fix unnest tokens on transfer

Daniel Shiposha2022-05-27parent: #79ec93e.patch.diff
in: master

3 files changed

modifiedpallets/fungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/fungible/src/lib.rs
+++ b/pallets/fungible/src/lib.rs
@@ -256,6 +256,11 @@
 			// from != to
 			if balance_from == 0 {
 				<Balance<T>>::remove((collection.id, from));
+				<PalletStructure<T>>::unnest_if_nested(
+					from,
+					collection.id,
+					TokenId::default()
+				);
 			} else {
 				<Balance<T>>::insert((collection.id, from), balance_from);
 			}
modifiedpallets/nonfungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/lib.rs
+++ b/pallets/nonfungible/src/lib.rs
@@ -340,17 +340,19 @@
 			.checked_sub(1)
 			.ok_or(ArithmeticError::Overflow)?;
 
+		// =========
+
 		if balance == 0 {
 			<AccountBalance<T>>::remove((collection.id, token_data.owner.clone()));
 		} else {
 			<AccountBalance<T>>::insert((collection.id, token_data.owner.clone()), balance);
 		}
 
-		if let Some(owner) = T::CrossTokenAddressMapping::address_to_token(&token_data.owner) {
-			Self::unnest(owner, (collection.id, token));
-		}
-
-		// =========
+		<PalletStructure<T>>::unnest_if_nested(
+			&token_data.owner,
+			collection.id,
+			token
+		);
 
 		<Owned<T>>::remove((collection.id, &token_data.owner, token));
 		<TokensBurnt<T>>::insert(collection.id, burnt);
@@ -593,6 +595,12 @@
 
 		// =========
 
+		<PalletStructure<T>>::unnest_if_nested(
+			from,
+			collection.id,
+			token
+		);
+
 		<TokenData<T>>::insert(
 			(collection.id, token),
 			ItemData {
modifiedpallets/refungible/src/lib.rsdiffbeforeafterboth
395 // from != to395 // from != to
396 if balance_from == 0 {396 if balance_from == 0 {
397 <Balance<T>>::remove((collection.id, token, from));397 <Balance<T>>::remove((collection.id, token, from));
398 <PalletStructure<T>>::unnest_if_nested(
399 from,
400 collection.id,
401 token
402 );
398 } else {403 } else {
399 <Balance<T>>::insert((collection.id, token, from), balance_from);404 <Balance<T>>::insert((collection.id, token, from), balance_from);
400 }405 }