Closed Avelous closed 2 years ago
Awesome!
Could you add all this code as a comment? I'd love to keep it as similar to the video as possible.
sure! here
//error
error IsNotOwner()
//modifier
modifier isNotOwner(
address nftAddress,
uint256 tokenId,
address spender
) {
IERC721 nft = IERC721(nftAddress);
address owner = nft.ownerOf(tokenId);
if (spender == owner) {
revert IsNotOwner();
}
_;
}
//Add this to the buyItem function
//Prevents the owner of an NFT from buying it
isNotOwner(nftAddress, tokenId, msg.sender)
No I mean in the PR, the code stay commented out as a suggestion for users.
Alright, i commented the changes. please check now
Just a minimal observation that might be necessary. I observed that "Address A" lists an NFT and "Address A" can also buy the same NFT
So, In this pull request, I added a modifier,
isNotOwner
which prevents the owner of the NFT from buying it.