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
340 .checked_sub(1)340 .checked_sub(1)
341 .ok_or(ArithmeticError::Overflow)?;341 .ok_or(ArithmeticError::Overflow)?;
342
343 // =========
342344
343 if balance == 0 {345 if balance == 0 {
344 <AccountBalance<T>>::remove((collection.id, token_data.owner.clone()));346 <AccountBalance<T>>::remove((collection.id, token_data.owner.clone()));
345 } else {347 } else {
346 <AccountBalance<T>>::insert((collection.id, token_data.owner.clone()), balance);348 <AccountBalance<T>>::insert((collection.id, token_data.owner.clone()), balance);
347 }349 }
348350
351 <PalletStructure<T>>::unnest_if_nested(
349 if let Some(owner) = T::CrossTokenAddressMapping::address_to_token(&token_data.owner) {352 &token_data.owner,
350 Self::unnest(owner, (collection.id, token));353 collection.id,
351 }354 token
352355 );
353 // =========
354356
355 <Owned<T>>::remove((collection.id, &token_data.owner, token));357 <Owned<T>>::remove((collection.id, &token_data.owner, token));
356 <TokensBurnt<T>>::insert(collection.id, burnt);358 <TokensBurnt<T>>::insert(collection.id, burnt);
593595
594 // =========596 // =========
597
598 <PalletStructure<T>>::unnest_if_nested(
599 from,
600 collection.id,
601 token
602 );
595603
596 <TokenData<T>>::insert(604 <TokenData<T>>::insert(
597 (collection.id, token),605 (collection.id, token),
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 }