From 101a18907270c31907bd526ae045e99b91726fbe Mon Sep 17 00:00:00 2001 From: Daniel Shiposha Date: Fri, 27 May 2022 17:55:14 +0000 Subject: [PATCH] fix: unnest tokens on transfer --- --- a/pallets/fungible/src/lib.rs +++ b/pallets/fungible/src/lib.rs @@ -256,6 +256,11 @@ // from != to if balance_from == 0 { >::remove((collection.id, from)); + >::unnest_if_nested( + from, + collection.id, + TokenId::default() + ); } else { >::insert((collection.id, from), balance_from); } --- 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 { >::remove((collection.id, token_data.owner.clone())); } else { >::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)); - } - - // ========= + >::unnest_if_nested( + &token_data.owner, + collection.id, + token + ); >::remove((collection.id, &token_data.owner, token)); >::insert(collection.id, burnt); @@ -593,6 +595,12 @@ // ========= + >::unnest_if_nested( + from, + collection.id, + token + ); + >::insert( (collection.id, token), ItemData { --- a/pallets/refungible/src/lib.rs +++ b/pallets/refungible/src/lib.rs @@ -395,6 +395,11 @@ // from != to if balance_from == 0 { >::remove((collection.id, token, from)); + >::unnest_if_nested( + from, + collection.id, + token + ); } else { >::insert((collection.id, token, from), balance_from); } -- gitstuff