Skip to content

Commit a91ee9e

Browse files
author
Hayden
authored
feature: rename all instances of RoyaltyAllowlist to OperatorAllowlist (#73)
* feature: rename all instances of RoyaltyAllowlist to OperatorAllowlist
1 parent a914dc5 commit a91ee9e

30 files changed

+446
-1082
lines changed

.prettierrc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
{}
1+
{
2+
"printWidth": 120
3+
}

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ contract MyERC721 is ImmutableERC721PermissionedMintable {
3737
string memory symbol,
3838
string memory baseURI,
3939
string memory contractURI,
40-
address royaltyAllowlist,
40+
address operatorAllowlist,
4141
address receiver,
4242
uint96 feeNumerator
4343
) ImmutableERC721PermissionedMintable(
@@ -46,7 +46,7 @@ contract MyERC721 is ImmutableERC721PermissionedMintable {
4646
symbol,
4747
baseURI,
4848
contractURI,
49-
royaltyAllowlist,
49+
operatorAllowlist,
5050
receiver,
5151
feeNumerator
5252
)

contracts/access/IERC173.sol

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ import "@openzeppelin/contracts/utils/introspection/ERC165.sol";
55

66
interface IERC173 is IERC165 {
77
/// @dev This emits when ownership of a contract changes.
8-
event OwnershipTransferred(
9-
address indexed previousOwner,
10-
address indexed newOwner
11-
);
8+
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
129

1310
/// @notice Get the address of the owner
1411
/// @return The address of the owner.

contracts/royalty-enforcement/IRoyaltyAllowlist.sol renamed to contracts/allowlist/IOperatorAllowlist.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
pragma solidity ^0.8.0;
33

44
/**
5-
* @dev Required interface of an RoyaltyAllowlist compliant contract
5+
* @dev Required interface of an OperatorAllowlist compliant contract
66
*/
7-
interface IRoyaltyAllowlist {
7+
interface IOperatorAllowlist {
88
/// @dev Returns true if an address is Allowlisted false otherwise
99
function isAllowlisted(address target) external view returns (bool);
1010
}

contracts/royalty-enforcement/RoyaltyAllowlist.sol renamed to contracts/allowlist/OperatorAllowlist.sol

Lines changed: 15 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
pragma solidity ^0.8.0;
33

44
// Access Control
5-
import "@openzeppelin/contracts/access/AccessControl.sol";
5+
import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol";
66

77
// Introspection
8-
import "@openzeppelin/contracts/utils/introspection/ERC165.sol";
8+
import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
99

1010
// Interfaces
11-
import "./IRoyaltyAllowlist.sol";
11+
import {IOperatorAllowlist} from "./IOperatorAllowlist.sol";
1212

1313
// Interface to retrieve the implemention stored inside the Proxy contract
1414
interface IProxy {
@@ -17,23 +17,19 @@ interface IProxy {
1717
}
1818

1919
/*
20-
RoyaltyAllowlist is an implementation of a Allowlist registry, storing addresses and bytecode
20+
OperatorAllowlist is an implementation of a Allowlist registry, storing addresses and bytecode
2121
which are allowed to be approved operators and execute transfers of interfacing token contracts (e.g. ERC721/ERC1155). The registry
2222
will be a deployed contract that tokens may interface with and point to.
2323
*/
2424

25-
contract RoyaltyAllowlist is ERC165, AccessControl, IRoyaltyAllowlist {
25+
contract OperatorAllowlist is ERC165, AccessControl, IOperatorAllowlist {
2626
/// ===== Events =====
2727

2828
/// @dev Emitted when a target address is added or removed from the Allowlist
2929
event AddressAllowlistChanged(address indexed target, bool added);
3030

3131
/// @dev Emitted when a target smart contract wallet is added or removed from the Allowlist
32-
event WalletAllowlistChanged(
33-
bytes32 indexed targetBytes,
34-
address indexed targetAddress,
35-
bool added
36-
);
32+
event WalletAllowlistChanged(bytes32 indexed targetBytes, address indexed targetAddress, bool added);
3733

3834
/// ===== State Variables =====
3935

@@ -61,18 +57,12 @@ contract RoyaltyAllowlist is ERC165, AccessControl, IRoyaltyAllowlist {
6157
/// ===== View functions =====
6258

6359
/// @dev ERC-165 interface support
64-
function supportsInterface(
65-
bytes4 interfaceId
66-
) public view virtual override(ERC165, AccessControl) returns (bool) {
67-
return
68-
interfaceId == type(IRoyaltyAllowlist).interfaceId ||
69-
super.supportsInterface(interfaceId);
60+
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, AccessControl) returns (bool) {
61+
return interfaceId == type(IOperatorAllowlist).interfaceId || super.supportsInterface(interfaceId);
7062
}
7163

7264
/// @dev Returns true if an address is Allowlisted, false otherwise
73-
function isAllowlisted(
74-
address target
75-
) external view override returns (bool) {
65+
function isAllowlisted(address target) external view override returns (bool) {
7666
if (addressAllowlist[target]) {
7767
return true;
7868
}
@@ -95,19 +85,15 @@ contract RoyaltyAllowlist is ERC165, AccessControl, IRoyaltyAllowlist {
9585
/// ===== External functions =====
9686

9787
/// @dev Add a target address to Allowlist
98-
function addAddressToAllowlist(
99-
address[] calldata addressTargets
100-
) external onlyRole(REGISTRAR_ROLE) {
88+
function addAddressToAllowlist(address[] calldata addressTargets) external onlyRole(REGISTRAR_ROLE) {
10189
for (uint256 i; i < addressTargets.length; i++) {
10290
addressAllowlist[addressTargets[i]] = true;
10391
emit AddressAllowlistChanged(addressTargets[i], true);
10492
}
10593
}
10694

10795
/// @dev Remove a target address from Allowlist
108-
function removeAddressFromAllowlist(
109-
address[] calldata addressTargets
110-
) external onlyRole(REGISTRAR_ROLE) {
96+
function removeAddressFromAllowlist(address[] calldata addressTargets) external onlyRole(REGISTRAR_ROLE) {
11197
for (uint256 i; i < addressTargets.length; i++) {
11298
delete addressAllowlist[addressTargets[i]];
11399
emit AddressAllowlistChanged(addressTargets[i], false);
@@ -119,9 +105,7 @@ contract RoyaltyAllowlist is ERC165, AccessControl, IRoyaltyAllowlist {
119105
// First, the bytecode of the proxy is added to the bytecode allowlist.
120106
// Second, the implementation address stored in the proxy is stored in the
121107
// implementation address allowlist.
122-
function addWalletToAllowlist(
123-
address walletAddr
124-
) external onlyRole(REGISTRAR_ROLE) {
108+
function addWalletToAllowlist(address walletAddr) external onlyRole(REGISTRAR_ROLE) {
125109
// get bytecode of wallet
126110
bytes32 codeHash;
127111
assembly {
@@ -137,9 +121,7 @@ contract RoyaltyAllowlist is ERC165, AccessControl, IRoyaltyAllowlist {
137121

138122
/// @dev Remove a smart contract wallet from the Allowlist
139123
// This will remove the proxy bytecode hash and implementation contract address pair from the allowlist
140-
function removeWalletFromAllowlist(
141-
address walletAddr
142-
) external onlyRole(REGISTRAR_ROLE) {
124+
function removeWalletFromAllowlist(address walletAddr) external onlyRole(REGISTRAR_ROLE) {
143125
// get bytecode of wallet
144126
bytes32 codeHash;
145127
assembly {
@@ -154,16 +136,12 @@ contract RoyaltyAllowlist is ERC165, AccessControl, IRoyaltyAllowlist {
154136
}
155137

156138
/// @dev Allows admin to grant `user` `REGISTRAR_ROLE` role
157-
function grantRegistrarRole(
158-
address user
159-
) external onlyRole(DEFAULT_ADMIN_ROLE) {
139+
function grantRegistrarRole(address user) external onlyRole(DEFAULT_ADMIN_ROLE) {
160140
grantRole(REGISTRAR_ROLE, user);
161141
}
162142

163143
/// @dev Allows admin to revoke `REGISTRAR_ROLE` role from `user`
164-
function revokeRegistrarRole(
165-
address user
166-
) external onlyRole(DEFAULT_ADMIN_ROLE) {
144+
function revokeRegistrarRole(address user) external onlyRole(DEFAULT_ADMIN_ROLE) {
167145
revokeRole(REGISTRAR_ROLE, user);
168146
}
169147
}

contracts/royalty-enforcement/RoyaltyEnforced.sol renamed to contracts/allowlist/OperatorAllowlistEnforced.sol

Lines changed: 21 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,80 +2,57 @@
22
pragma solidity ^0.8.0;
33

44
// Allowlist Registry
5-
import "./IRoyaltyAllowlist.sol";
5+
import {IOperatorAllowlist} from "./IOperatorAllowlist.sol";
66

77
// Access Control
8-
import "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
8+
import {AccessControlEnumerable, IERC165} from "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
99

1010
// Errors
11-
import {RoyaltyEnforcementErrors} from "../errors/Errors.sol";
11+
import {OperatorAllowlistEnforcementErrors} from "../errors/Errors.sol";
1212

13-
abstract contract RoyaltyEnforced is
14-
AccessControlEnumerable,
15-
RoyaltyEnforcementErrors
16-
{
13+
abstract contract OperatorAllowlistEnforced is AccessControlEnumerable, OperatorAllowlistEnforcementErrors {
1714
/// ===== Events =====
1815

1916
/// @dev Emitted whenever the transfer Allowlist registry is updated
20-
event RoyaltyAllowlistRegistryUpdated(
21-
address oldRegistry,
22-
address newRegistry
23-
);
17+
event OperatorAllowlistRegistryUpdated(address oldRegistry, address newRegistry);
2418

2519
/// ===== State Variables =====
2620

27-
/// @dev Interface that implements the `IRoyaltyAllowlist` interface
28-
IRoyaltyAllowlist public royaltyAllowlist;
21+
/// @dev Interface that implements the `IOperatorAllowlist` interface
22+
IOperatorAllowlist public operatorAllowlist;
2923

3024
/// ===== External functions =====
3125

3226
/// @dev Returns the supported interfaces
33-
function supportsInterface(
34-
bytes4 interfaceId
35-
) public view virtual override returns (bool) {
27+
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
3628
return super.supportsInterface(interfaceId);
3729
}
3830

39-
function setRoyaltyAllowlistRegistry(
40-
address _royaltyAllowlist
41-
) public onlyRole(DEFAULT_ADMIN_ROLE) {
42-
_setRoyaltyAllowlistRegistry(_royaltyAllowlist);
31+
function setOperatorAllowlistRegistry(address _operatorAllowlist) public onlyRole(DEFAULT_ADMIN_ROLE) {
32+
_setOperatorAllowlistRegistry(_operatorAllowlist);
4333
}
4434

45-
function _setRoyaltyAllowlistRegistry(address _royaltyAllowlist) internal {
46-
if (
47-
!IERC165(_royaltyAllowlist).supportsInterface(
48-
type(IRoyaltyAllowlist).interfaceId
49-
)
50-
) {
51-
revert RoyaltyEnforcementDoesNotImplementRequiredInterface();
35+
function _setOperatorAllowlistRegistry(address _operatorAllowlist) internal {
36+
if (!IERC165(_operatorAllowlist).supportsInterface(type(IOperatorAllowlist).interfaceId)) {
37+
revert AllowlistDoesNotImplementIOperatorAllowlist();
5238
}
5339

54-
emit RoyaltyAllowlistRegistryUpdated(
55-
address(royaltyAllowlist),
56-
_royaltyAllowlist
57-
);
58-
royaltyAllowlist = IRoyaltyAllowlist(_royaltyAllowlist);
40+
emit OperatorAllowlistRegistryUpdated(address(operatorAllowlist), _operatorAllowlist);
41+
operatorAllowlist = IOperatorAllowlist(_operatorAllowlist);
5942
}
6043

6144
modifier validateApproval(address targetApproval) {
6245
// Check for:
6346
// 1. approver is an EOA. Contract constructor is handled as transfers 'from' are blocked
6447
// 2. approver is address or bytecode is allowlisted
65-
if (
66-
msg.sender.code.length != 0 &&
67-
!royaltyAllowlist.isAllowlisted(msg.sender)
68-
) {
48+
if (msg.sender.code.length != 0 && !operatorAllowlist.isAllowlisted(msg.sender)) {
6949
revert ApproverNotInAllowlist(msg.sender);
7050
}
7151

7252
// Check for:
7353
// 1. approval target is an EOA
7454
// 2. approval target address is Allowlisted or target address bytecode is Allowlisted
75-
if (
76-
targetApproval.code.length != 0 &&
77-
!royaltyAllowlist.isAllowlisted(targetApproval)
78-
) {
55+
if (targetApproval.code.length != 0 && !operatorAllowlist.isAllowlisted(targetApproval)) {
7956
revert ApproveTargetNotInAllowlist(targetApproval);
8057
}
8158
_;
@@ -87,23 +64,23 @@ abstract contract RoyaltyEnforced is
8764
// 1. caller is an EOA
8865
// 2. caller is Allowlisted or is the calling address bytecode is Allowlisted
8966
if (
90-
msg.sender != tx.origin &&
91-
!royaltyAllowlist.isAllowlisted(msg.sender)
67+
msg.sender != tx.origin && // solhint-disable-line avoid-tx-origin
68+
!operatorAllowlist.isAllowlisted(msg.sender)
9269
) {
9370
revert CallerNotInAllowlist(msg.sender);
9471
}
9572

9673
// Check for:
9774
// 1. from is an EOA
9875
// 2. from is Allowlisted or from address bytecode is Allowlisted
99-
if (from.code.length != 0 && !royaltyAllowlist.isAllowlisted(from)) {
76+
if (from.code.length != 0 && !operatorAllowlist.isAllowlisted(from)) {
10077
revert TransferFromNotInAllowlist(from);
10178
}
10279

10380
// Check for:
10481
// 1. to is an EOA
10582
// 2. to is Allowlisted or to address bytecode is Allowlisted
106-
if (to.code.length != 0 && !royaltyAllowlist.isAllowlisted(to)) {
83+
if (to.code.length != 0 && !operatorAllowlist.isAllowlisted(to)) {
10784
revert TransferToNotInAllowlist(to);
10885
}
10986
_;

contracts/errors/Errors.sol

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//SPDX-License-Identifier: Apache 2.0
12
pragma solidity ^0.8.0;
23

34
interface IImmutableERC721Errors {
@@ -17,28 +18,25 @@ interface IImmutableERC721Errors {
1718
error IImmutableERC721NotOwnerOrOperator(uint256 tokenId);
1819

1920
/// @dev Current token owner is not what was expected
20-
error IImmutableERC721MismatchedTokenOwner(
21-
uint256 tokenId,
22-
address currentOwner
23-
);
21+
error IImmutableERC721MismatchedTokenOwner(uint256 tokenId, address currentOwner);
2422
}
2523

26-
interface RoyaltyEnforcementErrors {
27-
/// @dev Caller tried to mint an already burned token
28-
error RoyaltyEnforcementDoesNotImplementRequiredInterface();
24+
interface OperatorAllowlistEnforcementErrors {
25+
/// @dev Error thrown when the operatorAllowlist address does not implement the IOperatorAllowlist interface
26+
error AllowlistDoesNotImplementIOperatorAllowlist();
2927

30-
/// @dev Error thrown when calling address is not Allowlisted
28+
/// @dev Error thrown when calling address is not OperatorAllowlist
3129
error CallerNotInAllowlist(address caller);
3230

33-
/// @dev Error thrown when 'from' address is not Allowlisted
31+
/// @dev Error thrown when 'from' address is not OperatorAllowlist
3432
error TransferFromNotInAllowlist(address from);
3533

36-
/// @dev Error thrown when 'to' address is not Allowlisted
34+
/// @dev Error thrown when 'to' address is not OperatorAllowlist
3735
error TransferToNotInAllowlist(address to);
3836

39-
/// @dev Error thrown when approve target is not Allowlisted
37+
/// @dev Error thrown when approve target is not OperatorAllowlist
4038
error ApproveTargetNotInAllowlist(address target);
4139

42-
/// @dev Error thrown when approve target is not Allowlisted
40+
/// @dev Error thrown when approve target is not OperatorAllowlist
4341
error ApproverNotInAllowlist(address approver);
4442
}

contracts/mocks/MockDisguisedEOA.sol

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@ contract MockDisguisedEOA {
1010
tokenAddress = _tokenAddress;
1111
}
1212

13-
function executeTransfer(
14-
address from,
15-
address recipient,
16-
uint256 _tokenId
17-
) external {
13+
function executeTransfer(address from, address recipient, uint256 _tokenId) external {
1814
tokenAddress.transferFrom(from, recipient, _tokenId);
1915
}
2016
}

contracts/mocks/MockFactory.sol

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ pragma solidity ^0.8.0;
33
import {Create2} from "@openzeppelin/contracts/utils/Create2.sol";
44

55
contract MockFactory {
6-
function computeAddress(
7-
bytes32 salt,
8-
bytes32 codeHash
9-
) public view returns (address) {
6+
function computeAddress(bytes32 salt, bytes32 codeHash) public view returns (address) {
107
return Create2.computeAddress(salt, codeHash);
118
}
129

0 commit comments

Comments
 (0)