Cyfrin / foundry-nft-cu

21 stars 22 forks source link

Openzeppelin has replaced '_isApprovedOrOwner' with '_isAuthorized' | lesson 11 @ 9.17 hrs #33

Closed dew10120 closed 3 months ago

dew10120 commented 3 months ago

DATE - May 31, 2024

Hi all,

So in ERC721.sol, Openzeppelin has replaced '_isApprovedOrOwner' with '_isAuthorized'

therefore, in function flipMode to check the owner u must use '_checkAuthorized' instead of '_isApprovedOrOwner'

The new code for function flipMode should read as,

    function flipMood(uint256 tokenId) public {
        // Fetch the owner of the token
        address owner = ownerOf(tokenId);
        // Only want the owner of NFT to change the mood.
        _checkAuthorized(owner, msg.sender, tokenId);

        if (s_tokenIdToMood[tokenId] == Mood.HAPPY) {
            s_tokenIdToMood[tokenId] = Mood.SAD;
        } else {
            s_tokenIdToMood[tokenId] = Mood.HAPPY;
        }
    }

check the CHANGELOG.md at

line 203

Thank you,

DEW

Equious commented 3 months ago

Thanks for the heads up! We've appended the recommended adjustment to this lesson on Updraft with an update visible on the video page here: https://updraft.cyfrin.io/courses/advanced-foundry/how-to-create-an-NFT-collection/create-dynamic-nft?lesson_format=video

We'll also assure the written lesson is accurate when the rewrite hits this point.