From 40ec4103d0e29e76cd0a52d9efc094063d9b627c Mon Sep 17 00:00:00 2001 From: Jacob Homanics Date: Fri, 2 Feb 2024 14:07:00 -0600 Subject: [PATCH] allows admin to transfer NFT --- .../foundry/contracts/ATXDAOPartnershipNft.sol | 16 ++++++++++++++++ .../contracts/token/ERC721/ERC721.sol | 4 ++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/packages/foundry/contracts/ATXDAOPartnershipNft.sol b/packages/foundry/contracts/ATXDAOPartnershipNft.sol index 46c84c5..fb2a5ac 100644 --- a/packages/foundry/contracts/ATXDAOPartnershipNft.sol +++ b/packages/foundry/contracts/ATXDAOPartnershipNft.sol @@ -39,6 +39,22 @@ contract ATXDAOPartnershipNft is ERC721URIStorage, AccessControl { transferFrom(ownerOf(tokenId), msg.sender, tokenId); } + function _checkAuthorized( + address owner, + address spender, + uint256 tokenId + ) internal view override { + if (!hasRole(DEFAULT_ADMIN_ROLE, spender)) { + if (!_isAuthorized(owner, spender, tokenId)) { + if (owner == address(0)) { + revert ERC721NonexistentToken(tokenId); + } else { + revert ERC721InsufficientApproval(spender, tokenId); + } + } + } + } + function supportsInterface( bytes4 interfaceId ) public view override(ERC721URIStorage, AccessControl) returns (bool) { diff --git a/packages/foundry/lib/openzeppelin-contracts/contracts/token/ERC721/ERC721.sol b/packages/foundry/lib/openzeppelin-contracts/contracts/token/ERC721/ERC721.sol index 98a80e5..ec390d5 100644 --- a/packages/foundry/lib/openzeppelin-contracts/contracts/token/ERC721/ERC721.sol +++ b/packages/foundry/lib/openzeppelin-contracts/contracts/token/ERC721/ERC721.sol @@ -25,9 +25,9 @@ abstract contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Er // Token symbol string private _symbol; - mapping(uint256 tokenId => address) private _owners; + mapping(uint256 tokenId => address) _owners; - mapping(address owner => uint256) private _balances; + mapping(address owner => uint256) _balances; mapping(uint256 tokenId => address) private _tokenApprovals;