Skip to content

Commit

Permalink
remove setApprovalForAll and isApprovedForAll
Browse files Browse the repository at this point in the history
  • Loading branch information
clemsos committed Oct 17, 2024
1 parent a7c0606 commit 6ee3146
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 66 deletions.
24 changes: 2 additions & 22 deletions smart-contracts/contracts/interfaces/IPublicLock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ interface IPublicLock {
* - `from`, `to` cannot be zero.
* - `tokenId` must be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this
* NFT by either `approve` or `setApprovalForAll`.
* `approve`
*/
function safeTransferFrom(address from, address to, uint256 tokenId) external;

Expand All @@ -473,7 +473,7 @@ interface IPublicLock {
* @param to the address that will receive the token
* @param tokenId the id of the token
* @dev Requirements: if the caller is not `from`, it must be approved to move this token by
* either `approve` or `setApprovalForAll`.
* `approve`
* The key manager will be reset to address zero after the transfer
*/
function transferFrom(address from, address to, uint256 tokenId) external;
Expand Down Expand Up @@ -510,26 +510,6 @@ interface IPublicLock {
uint256 _tokenId
) external view returns (address operator);

/**
* @dev Sets or unsets the approval of a given operator
* An operator is allowed to transfer all tokens of the sender on their behalf
* @param _operator operator address to set the approval
* @param _approved representing the status of the approval to be set
* @notice disabled when transfers are disabled
*/
function setApprovalForAll(address _operator, bool _approved) external;

/**
* @dev Tells whether an operator is approved by a given keyManager
* @param _owner owner address which you want to query the approval of
* @param _operator operator address which you want to query the approval of
* @return bool whether the given operator is approved by the given owner
*/
function isApprovedForAll(
address _owner,
address _operator
) external view returns (bool);

/**
* Returns the total number of keys, including non-valid ones
* @return _totalKeysCreated the total number of keys, valid or not
Expand Down
19 changes: 1 addition & 18 deletions smart-contracts/contracts/mixins/MixinKeys.sol
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,10 @@ contract MixinKeys is MixinErrors, MixinLockCore {
* @dev This is a modifier
*/
function _onlyKeyManagerOrApproved(uint _tokenId) internal view {
address realKeyManager = keyManagerOf[_tokenId] == address(0)
? _ownerOf[_tokenId]
: keyManagerOf[_tokenId];
if (
!isLockManager(msg.sender) &&
!_isKeyManager(_tokenId, msg.sender) &&
approved[_tokenId] != msg.sender &&
!isApprovedForAll(realKeyManager, msg.sender)
approved[_tokenId] != msg.sender
) {
revert ONLY_KEY_MANAGER_OR_APPROVED();
}
Expand Down Expand Up @@ -482,19 +478,6 @@ contract MixinKeys is MixinErrors, MixinLockCore {
return approvedRecipient;
}

/**
* @dev Tells whether an operator is approved by a given keyManager
* @param _owner owner address which you want to query the approval of
* @param _operator operator address which you want to query the approval of
* @return bool whether the given operator is approved by the given owner
*/
function isApprovedForAll(
address _owner,
address _operator
) public view returns (bool) {
return managerToOperatorApproved[_owner][_operator];
}

/**
* Returns true if _keyManager is explicitly set as key manager, or if the
* address is the owner but no km is set.
Expand Down
9 changes: 0 additions & 9 deletions smart-contracts/contracts/mixins/MixinLockCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,6 @@ contract MixinLockCore is MixinRoles, MixinFunds, MixinDisable {
address onKeyGrantHook
);

/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(
address indexed owner,
address indexed operator,
bool approved
);

// Unlock Protocol address
IUnlock public unlockProtocol;

Expand Down
18 changes: 1 addition & 17 deletions smart-contracts/contracts/mixins/MixinTransfer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ contract MixinTransfer is
* @param _recipient the address that will receive the token
* @param _tokenId the id of the token
* @dev Requirements: if the caller is not `from`, it must be approved to move this token by
* either `approve` or `setApprovalForAll`.
* `approve`
* The key manager will be reset to address zero after the transfer
*/
function transferFrom(
Expand Down Expand Up @@ -261,22 +261,6 @@ contract MixinTransfer is
safeTransferFrom(_from, _to, _tokenId, "");
}

/**
* @dev Sets or unsets the approval of a given operator
* An operator is allowed to transfer all tokens of the sender on their behalf
* @param _to operator address to set the approval
* @param _approved representing the status of the approval to be set
* @notice disabled when transfers are disabled
*/
function setApprovalForAll(address _to, bool _approved) public {
_transferNotDisabled();
if (_to == msg.sender) {
revert CANNOT_APPROVE_SELF();
}
managerToOperatorApproved[msg.sender][_to] = _approved;
emit ApprovalForAll(msg.sender, _to, _approved);
}

/**
* @notice Transfers the ownership of an NFT from one address to another address.
* When transfer is complete, this functions
Expand Down

0 comments on commit 6ee3146

Please sign in to comment.