difftreelog
fix wrong allowance key used
in: master
Key is (who_approved, approved_for), not (who_approved, transfer_target)
1 file changed
pallets/nft/src/lib.rsdiffbeforeafterboth114311431144 // Check approval1144 // Check approval1145 let mut approval: u128 = 0;1145 let mut approval: u128 = 0;1146 if <Allowances<T>>::contains_key(collection_id, (item_id, &from, &recipient)) {1146 if <Allowances<T>>::contains_key(collection_id, (item_id, &from, &sender)) {1147 approval = <Allowances<T>>::get(collection_id, (item_id, &from, &recipient));1147 approval = <Allowances<T>>::get(collection_id, (item_id, &from, &sender));1148 ensure!(approval >= value, Error::<T>::TokenValueNotEnough);1148 ensure!(approval >= value, Error::<T>::TokenValueNotEnough);1149 appoved_transfer = true;1149 appoved_transfer = true;1150 }1150 }116511651166 // Reduce approval by transferred amount or remove if remaining approval drops to 01166 // Reduce approval by transferred amount or remove if remaining approval drops to 01167 if approval.checked_sub(value).unwrap_or(0) > 0 {1167 if approval.checked_sub(value).unwrap_or(0) > 0 {1168 <Allowances<T>>::insert(collection_id, (item_id, &from, &recipient), approval - value);1168 <Allowances<T>>::insert(collection_id, (item_id, &from, &sender), approval - value);1169 }1169 }1170 else {1170 else {1171 <Allowances<T>>::remove(collection_id, (item_id, &from, &recipient));1171 <Allowances<T>>::remove(collection_id, (item_id, &from, &sender));1172 }1172 }117311731174 match target_collection.mode1174 match target_collection.mode