git.delta.rocks / unique-network / refs/commits / 1358a9bd6efb

difftreelog

fix fungible transfer

Daniel Shiposha2022-12-06parent: #a62a4b7.patch.diff
in: master

1 file changed

modifiedpallets/fungible/src/lib.rsdiffbeforeafterboth
379 let balance_from = <Balance<T>>::get((collection.id, from))379 let balance_from = <Balance<T>>::get((collection.id, from))
380 .checked_sub(amount)380 .checked_sub(amount)
381 .ok_or(<CommonError<T>>::TokenValueTooLow)?;381 .ok_or(<CommonError<T>>::TokenValueTooLow)?;
382 let balance_to = if from != to {382 let balance_to = if from != to && amount != 0 {
383 Some(383 Some(
384 <Balance<T>>::get((collection.id, to))384 <Balance<T>>::get((collection.id, to))
385 .checked_add(amount)385 .checked_add(amount)
391391
392 // =========392 // =========
393
394 if let Some(balance_to) = balance_to {
395 // from != to && amount != 0
393396
394 <PalletStructure<T>>::nest_if_sent_to_token(397 <PalletStructure<T>>::nest_if_sent_to_token(
395 from.clone(),398 from.clone(),
399 nesting_budget,402 nesting_budget,
400 )?;403 )?;
401404
402 if let Some(balance_to) = balance_to {
403 // from != to
404 if balance_from == 0 {405 if balance_from == 0 {
405 <Balance<T>>::remove((collection.id, from));406 <Balance<T>>::remove((collection.id, from));
406 <PalletStructure<T>>::unnest_if_nested(from, collection.id, TokenId::default());407 <PalletStructure<T>>::unnest_if_nested(from, collection.id, TokenId::default());
407 } else {408 } else {
408 <Balance<T>>::insert((collection.id, from), balance_from);409 <Balance<T>>::insert((collection.id, from), balance_from);
409 }410 }
410 <Balance<T>>::insert((collection.id, to), balance_to);411 <Balance<T>>::insert((collection.id, to), balance_to);
411 }412 }
412413
413 <PalletEvm<T>>::deposit_log(414 <PalletEvm<T>>::deposit_log(
414 ERC20Events::Transfer {415 ERC20Events::Transfer {