From 7efe1bc1a7706a80dc356b27beb529a7cbb3aafa Mon Sep 17 00:00:00 2001 From: Greg Zaitsev Date: Tue, 02 Feb 2021 15:15:33 +0000 Subject: [PATCH] Merge pull request #82 from usetech-llc/feature/transferFromExpectSuccess_helper_fix Fix transferFrom implementation/test --- --- a/pallets/nft/src/lib.rs +++ b/pallets/nft/src/lib.rs @@ -1122,8 +1122,8 @@ // Check approval let mut approval: u128 = 0; - if >::contains_key(collection_id, (item_id, &from, &recipient)) { - approval = >::get(collection_id, (item_id, &from, &recipient)); + if >::contains_key(collection_id, (item_id, &from, &sender)) { + approval = >::get(collection_id, (item_id, &from, &sender)); ensure!(approval >= value, Error::::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 { - >::insert(collection_id, (item_id, &from, &recipient), approval - value); + >::insert(collection_id, (item_id, &from, &sender), approval - value); } else { - >::remove(collection_id, (item_id, &from, &recipient)); + >::remove(collection_id, (item_id, &from, &sender)); } match target_collection.mode --- a/tests/src/util/helpers.ts +++ b/tests/src/util/helpers.ts @@ -462,7 +462,7 @@ } const transferFromTx = await api.tx.nft.transferFrom( accountFrom.address, accountTo.address, collectionId, tokenId, value); - const events = await submitTransactionAsync(accountFrom, transferFromTx); + const events = await submitTransactionAsync(accountApproved, transferFromTx); const result = getCreateItemResult(events); // tslint:disable-next-line:no-unused-expression expect(result.success).to.be.true; -- gitstuff