git.delta.rocks / unique-network / refs/commits / 91ad8d664eb3

difftreelog

fix wrong allowance key used

Yaroslav Bolyukin2021-01-28parent: #39437c5.patch.diff
in: master
Key is (who_approved, approved_for), not (who_approved, transfer_target)

1 file changed

modifiedpallets/nft/src/lib.rsdiffbeforeafterboth
11431143
1144 // Check approval1144 // Check approval
1145 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 }
11651165
1166 // 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 0
1167 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 }
11731173
1174 match target_collection.mode1174 match target_collection.mode