git.delta.rocks / unique-network / refs/commits / 7efe1bc1a770

difftreelog

Merge pull request #82 from usetech-llc/feature/transferFromExpectSuccess_helper_fix

Greg Zaitsev2021-02-02parents: #037be4d #91ad8d6.patch.diff
in: master
Fix transferFrom implementation/test

2 files changed

modifiedpallets/nft/src/lib.rsdiffbeforeafterboth
--- a/pallets/nft/src/lib.rs
+++ b/pallets/nft/src/lib.rs
@@ -1122,8 +1122,8 @@
 
             // Check approval
             let mut approval: u128 = 0;
-            if <Allowances<T>>::contains_key(collection_id, (item_id, &from, &recipient)) {
-                approval = <Allowances<T>>::get(collection_id, (item_id, &from, &recipient));
+            if <Allowances<T>>::contains_key(collection_id, (item_id, &from, &sender)) {
+                approval = <Allowances<T>>::get(collection_id, (item_id, &from, &sender));
                 ensure!(approval >= value, Error::<T>::TokenValueNotEnough);
                 appoved_transfer = true;
             }
@@ -1144,10 +1144,10 @@
 
             // Reduce approval by transferred amount or remove if remaining approval drops to 0
             if approval.checked_sub(value).unwrap_or(0) > 0 {
-                <Allowances<T>>::insert(collection_id, (item_id, &from, &recipient), approval - value);
+                <Allowances<T>>::insert(collection_id, (item_id, &from, &sender), approval - value);
             }
             else {
-                <Allowances<T>>::remove(collection_id, (item_id, &from, &recipient));
+                <Allowances<T>>::remove(collection_id, (item_id, &from, &sender));
             }
 
             match target_collection.mode
modifiedtests/src/util/helpers.tsdiffbeforeafterboth
462 }462 }
463 const transferFromTx = await api.tx.nft.transferFrom(463 const transferFromTx = await api.tx.nft.transferFrom(
464 accountFrom.address, accountTo.address, collectionId, tokenId, value);464 accountFrom.address, accountTo.address, collectionId, tokenId, value);
465 const events = await submitTransactionAsync(accountFrom, transferFromTx);465 const events = await submitTransactionAsync(accountApproved, transferFromTx);
466 const result = getCreateItemResult(events);466 const result = getCreateItemResult(events);
467 // tslint:disable-next-line:no-unused-expression467 // tslint:disable-next-line:no-unused-expression
468 expect(result.success).to.be.true;468 expect(result.success).to.be.true;