git.delta.rocks / unique-network / refs/commits / a62a4b76664a

difftreelog

fix rft transfer/burn

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

1 file changed

modifiedpallets/refungible/src/lib.rsdiffbeforeafterboth
452 token: TokenId,452 token: TokenId,
453 amount: u128,453 amount: u128,
454 ) -> DispatchResult {454 ) -> DispatchResult {
455 if <Balance<T>>::get((collection.id, token, owner)) == 0 {
456 return Err(<CommonError<T>>::MustBeTokenOwner.into());
457 }
458
455 let total_supply = <TotalSupply<T>>::get((collection.id, token))459 let total_supply = <TotalSupply<T>>::get((collection.id, token))
456 .checked_sub(amount)460 .checked_sub(amount)
740744
741 let initial_balance_from = <Balance<T>>::get((collection.id, token, from));745 let initial_balance_from = <Balance<T>>::get((collection.id, token, from));
746
747 if initial_balance_from == 0 {
748 return Err(<CommonError<T>>::MustBeTokenOwner.into());
749 }
750
742 let updated_balance_from = initial_balance_from751 let updated_balance_from = initial_balance_from
743 .checked_sub(amount)752 .checked_sub(amount)
744 .ok_or(<CommonError<T>>::TokenValueTooLow)?;753 .ok_or(<CommonError<T>>::TokenValueTooLow)?;
745 let mut create_target = false;754 let mut create_target = false;
746 let from_to_differ = from != to;755 let from_to_differ = from != to;
747 let updated_balance_to = if from != to {756 let updated_balance_to = if from != to && amount != 0 {
748 let old_balance = <Balance<T>>::get((collection.id, token, to));757 let old_balance = <Balance<T>>::get((collection.id, token, to));
749 if old_balance == 0 {758 if old_balance == 0 {
750 create_target = true;759 create_target = true;
786795
787 // =========796 // =========
797
798 if let Some(updated_balance_to) = updated_balance_to {
799 // from != to && amount != 0
788800
789 <PalletStructure<T>>::nest_if_sent_to_token(801 <PalletStructure<T>>::nest_if_sent_to_token(
790 from.clone(),802 from.clone(),
794 nesting_budget,806 nesting_budget,
795 )?;807 )?;
796808
797 if let Some(updated_balance_to) = updated_balance_to {
798 // from != to
799 if updated_balance_from == 0 {809 if updated_balance_from == 0 {
800 <Balance<T>>::remove((collection.id, token, from));810 <Balance<T>>::remove((collection.id, token, from));
801 <PalletStructure<T>>::unnest_if_nested(from, collection.id, token);811 <PalletStructure<T>>::unnest_if_nested(from, collection.id, token);
811 <AccountBalance<T>>::insert((collection.id, to), account_balance_to);821 <AccountBalance<T>>::insert((collection.id, to), account_balance_to);
812 <Owned<T>>::insert((collection.id, to, token), true);822 <Owned<T>>::insert((collection.id, to, token), true);
813 }823 }
814 }824 }
815825
816 <PalletEvm<T>>::deposit_log(826 <PalletEvm<T>>::deposit_log(
817 ERC20Events::Transfer {827 ERC20Events::Transfer {