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
256 // from != to256 // from != to
257 if balance_from == 0 {257 if balance_from == 0 {
258 <Balance<T>>::remove((collection.id, from));258 <Balance<T>>::remove((collection.id, from));
259 <PalletStructure<T>>::unnest_if_nested(
260 from,
261 collection.id,
262 TokenId::default()
263 );
259 } else {264 } else {
260 <Balance<T>>::insert((collection.id, from), balance_from);265 <Balance<T>>::insert((collection.id, from), balance_from);
261 }266 }
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
--- a/pallets/refungible/src/lib.rs
+++ b/pallets/refungible/src/lib.rs
@@ -395,6 +395,11 @@
 			// from != to
 			if balance_from == 0 {
 				<Balance<T>>::remove((collection.id, token, from));
+				<PalletStructure<T>>::unnest_if_nested(
+					from,
+					collection.id,
+					token
+				);
 			} else {
 				<Balance<T>>::insert((collection.id, token, from), balance_from);
 			}