difftreelog
Merge pull request #82 from usetech-llc/feature/transferFromExpectSuccess_helper_fix
in: master
Fix transferFrom implementation/test
2 files changed
pallets/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
tests/src/util/helpers.tsdiffbeforeafterboth462 }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-expression468 expect(result.success).to.be.true;468 expect(result.success).to.be.true;