The owner of the ERC721 token could approve an operator to manage his tokens
With the misunderstanding of operator with from in the onERC721Received function the benefits of this function goes to the operator instead of the from(owner):
> Note: read the interface ERC721TokenReceiver in EIP721
Add this in the test contract OnERC721ReceivedTest:
function testOnERC721ReceivedWithOperator() public {
vm.startPrank(borrower);
safeTransferReceivedArgs.swapParams.sqrtPriceLimitX96 = _maxSqrtPriceLimit(true);
address alice = address(2);
nft.approve(alice, collateralId);
vm.stopPrank();
vm.startPrank(alice);
nft.safeTransferFrom(borrower, address(controller), collateralId, abi.encode(safeTransferReceivedArgs));
// This should be pass
IPaprController.VaultInfo memory vaultInfo = controller.vaultInfo(borrower, collateral.addr);
assertEq(vaultInfo.count, 1);
assertEq(vaultInfo.debt, debt);
}
Review
@@ -156,7 +156,7 @@ contract PaprController is
/// @param _id the id of the NFT
/// @param data encoded IPaprController.OnERC721ReceivedArgs
/// @return selector indicating succesful receiving of the NFT
- function onERC721Received(address from, address, uint256 _id, bytes calldata data)
+ function onERC721Received(address, address from, uint256 _id, bytes calldata data)
external
override
returns (bytes4)
The text was updated successfully, but these errors were encountered:
All reactions