difftreelog
fix do not use add_fungible_item for transfers
in: master
1 file changed
pallets/nft/src/lib.rsdiffbeforeafterboth2026 let collection_id = collection.id;2026 let collection_id = collection.id;202720272028 collection.consume_sload()?;2028 collection.consume_sload()?;2029 collection.consume_sload()?;2030 let mut recipient_balance = <FungibleItemList<T>>::get(collection_id, recipient.as_sub());2029 let mut balance = <FungibleItemList<T>>::get(collection_id, owner.as_sub());2031 let mut balance = <FungibleItemList<T>>::get(collection_id, owner.as_sub());20322030 ensure!(balance.value >= value, Error::<T>::TokenValueTooLow);2033 recipient_balance.value = recipient_balance20312034 .value2032 // Send balance to recipient (updates balanceOf of recipient)2035 .checked_add(value)2036 .ok_or(Error::<T>::NumOverflow)?;2037 balance.value = balance2038 .value2033 Self::add_fungible_item(collection, recipient, value)?;2039 .checked_sub(value)2040 .ok_or(Error::<T>::NumOverflow)?;203420412035 // update balanceOf of sender2042 // update balanceOf2036 collection.consume_sstore()?;2043 collection.consume_sstore()?;2044 collection.consume_sstore()?;2045 if balance.value != 0 {2037 <Balance<T>>::insert(collection_id, owner.as_sub(), balance.value - value);2046 <Balance<T>>::insert(collection_id, owner.as_sub(), balance.value);2047 } else {2048 <Balance<T>>::remove(collection_id, owner.as_sub());2049 }2050 <Balance<T>>::insert(collection_id, recipient.as_sub(), recipient_balance.value);203820512039 // Reduce or remove sender2052 // Reduce or remove sender2040 collection.consume_sstore()?;2053 collection.consume_sstore()?;2054 collection.consume_sstore()?;2041 if balance.value == value {2055 if balance.value != 0 {2042 <FungibleItemList<T>>::remove(collection_id, owner.as_sub());2056 <FungibleItemList<T>>::insert(collection_id, owner.as_sub(), balance);2043 } else {2057 } else {2044 balance.value -= value;2045 <FungibleItemList<T>>::insert(collection_id, owner.as_sub(), balance);2058 <FungibleItemList<T>>::remove(collection_id, owner.as_sub());2046 }2059 }2060 <FungibleItemList<T>>::insert(collection_id, recipient.as_sub(), recipient_balance);204720612048 collection.log(ERC20Events::Transfer {2062 collection.log(ERC20Events::Transfer {2049 from: *owner.as_eth(),2063 from: *owner.as_eth(),