Closed Zacharyii closed 1 month ago
In this logic of removing hidden SLOADs, the _isApprovedOrOwner
function was removed in favor of a new _isAuthorized
function. Overrides that used to target the _isApprovedOrOwner
should now be performed on the _isAuthorized
function. Calls to _isApprovedOrOwner
that preceded a call to _transfer
, _burn
or _approve
should be removed in favor of using the auth
argument in _update
and _approve
. This is showcased in ERC721Burnable.burn
and in ERC721Wrapper.withdrawTo
.
Is this right? I changed A to B.
A:
function flipMood(uint256 tokenId) public {
if(!_isApprovedOrOwner(msg.sender, tokenId)){
revert MoodNft__CantFlipMoodIfNotOwner();
}
if (s_tokenIdToMood[tokenId] == Mood.HAPPY) {
s_tokenIdToMood[tokenId] = Mood.SAD;
}else{
s_tokenIdToMood[tokenId] = Mood.HAPPY;
}
}
B:
function flipMood(uint256 tokenId) public {
address owner = ownerOf(tokenId); // 获取 tokenId 对应的所有者
if (!_isAuthorized(owner, msg.sender, tokenId)) {
revert MoodNft__CantFlipMoodIfNotOwner();
}
if (s_tokenIdToMood[tokenId] == Mood.HAPPY) {
s_tokenIdToMood[tokenId] = Mood.SAD;
} else {
s_tokenIdToMood[tokenId] = Mood.HAPPY;
}
}
At a first glance, this looks correct! (no promises though). I'm going to close this issue though to keep the codebase as-is.
Error (7576): Undeclared identifier. --> src/MoodNft.sol:38:13: | 38 | if(!_isApprovedOrOwner(msg.sender, tokenId)){ | ^^^^^^^^^^^^^^^^^^