From 2330f4efcf9421a2a4ba38ddf91f4acebc4dad97 Mon Sep 17 00:00:00 2001 From: Operator Filterer Date: Tue, 10 Jan 2023 21:19:07 -0800 Subject: [PATCH 1/2] use caps for constants --- src/OwnedRegistrant.sol | 4 ++-- .../OperatorFiltererUpgradeable.sol | 20 +++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/OwnedRegistrant.sol b/src/OwnedRegistrant.sol index fdf1060..a52b306 100644 --- a/src/OwnedRegistrant.sol +++ b/src/OwnedRegistrant.sol @@ -10,10 +10,10 @@ import {Ownable2Step} from "openzeppelin-contracts/access/Ownable2Step.sol"; * to facilitate a subscription whose ownership can be transferred. */ contract OwnedRegistrant is Ownable2Step { - address constant registry = 0x000000000000AAeB6D7670E522A718067333cd4E; + address constant REGISTRY = 0x000000000000AAeB6D7670E522A718067333cd4E; constructor(address _owner) { - IOperatorFilterRegistry(registry).register(address(this)); + IOperatorFilterRegistry(REGISTRY).register(address(this)); transferOwnership(_owner); } } diff --git a/src/upgradeable/OperatorFiltererUpgradeable.sol b/src/upgradeable/OperatorFiltererUpgradeable.sol index 42191c4..1d6c177 100644 --- a/src/upgradeable/OperatorFiltererUpgradeable.sol +++ b/src/upgradeable/OperatorFiltererUpgradeable.sol @@ -7,7 +7,7 @@ import {Initializable} from "openzeppelin-contracts-upgradeable/proxy/utils/Init abstract contract OperatorFiltererUpgradeable is Initializable { error OperatorNotAllowed(address operator); - IOperatorFilterRegistry constant operatorFilterRegistry = + IOperatorFilterRegistry constant OPERATOR_FILTER_REGISTRY = IOperatorFilterRegistry(0x000000000000AAeB6D7670E522A718067333cd4E); function __OperatorFilterer_init(address subscriptionOrRegistrantToCopy, bool subscribe) @@ -17,15 +17,15 @@ abstract contract OperatorFiltererUpgradeable is Initializable { // If an inheriting token contract is deployed to a network without the registry deployed, the modifier // will not revert, but the contract will need to be registered with the registry once it is deployed in // order for the modifier to filter addresses. - if (address(operatorFilterRegistry).code.length > 0) { - if (!operatorFilterRegistry.isRegistered(address(this))) { + if (address(OPERATOR_FILTER_REGISTRY).code.length > 0) { + if (!OPERATOR_FILTER_REGISTRY.isRegistered(address(this))) { if (subscribe) { - operatorFilterRegistry.registerAndSubscribe(address(this), subscriptionOrRegistrantToCopy); + OPERATOR_FILTER_REGISTRY.registerAndSubscribe(address(this), subscriptionOrRegistrantToCopy); } else { if (subscriptionOrRegistrantToCopy != address(0)) { - operatorFilterRegistry.registerAndCopyEntries(address(this), subscriptionOrRegistrantToCopy); + OPERATOR_FILTER_REGISTRY.registerAndCopyEntries(address(this), subscriptionOrRegistrantToCopy); } else { - operatorFilterRegistry.register(address(this)); + OPERATOR_FILTER_REGISTRY.register(address(this)); } } } @@ -34,7 +34,7 @@ abstract contract OperatorFiltererUpgradeable is Initializable { modifier onlyAllowedOperator(address from) virtual { // Check registry code length to facilitate testing in environments without a deployed registry. - if (address(operatorFilterRegistry).code.length > 0) { + if (address(OPERATOR_FILTER_REGISTRY).code.length > 0) { // Allow spending tokens from addresses with balance // Note that this still allows listings and marketplaces with escrow to transfer tokens if transferred // from an EOA. @@ -42,7 +42,7 @@ abstract contract OperatorFiltererUpgradeable is Initializable { _; return; } - if (!operatorFilterRegistry.isOperatorAllowed(address(this), msg.sender)) { + if (!OPERATOR_FILTER_REGISTRY.isOperatorAllowed(address(this), msg.sender)) { revert OperatorNotAllowed(msg.sender); } } @@ -51,8 +51,8 @@ abstract contract OperatorFiltererUpgradeable is Initializable { modifier onlyAllowedOperatorApproval(address operator) virtual { // Check registry code length to facilitate testing in environments without a deployed registry. - if (address(operatorFilterRegistry).code.length > 0) { - if (!operatorFilterRegistry.isOperatorAllowed(address(this), operator)) { + if (address(OPERATOR_FILTER_REGISTRY).code.length > 0) { + if (!OPERATOR_FILTER_REGISTRY.isOperatorAllowed(address(this), operator)) { revert OperatorNotAllowed(operator); } } From d14f1484b489c815f96dd20d9d8c8e8a0636e47d Mon Sep 17 00:00:00 2001 From: Operator Filterer Date: Tue, 10 Jan 2023 23:19:13 -0800 Subject: [PATCH 2/2] fix reference --- src/upgradeable/RevokableOperatorFiltererUpgradeable.sol | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/upgradeable/RevokableOperatorFiltererUpgradeable.sol b/src/upgradeable/RevokableOperatorFiltererUpgradeable.sol index ac91a49..e1d66e9 100644 --- a/src/upgradeable/RevokableOperatorFiltererUpgradeable.sol +++ b/src/upgradeable/RevokableOperatorFiltererUpgradeable.sol @@ -22,7 +22,7 @@ abstract contract RevokableOperatorFiltererUpgradeable is OperatorFiltererUpgrad modifier onlyAllowedOperator(address from) override { // Check registry code length to facilitate testing in environments without a deployed registry. - if (!_isOperatorFilterRegistryRevoked && address(operatorFilterRegistry).code.length > 0) { + if (!_isOperatorFilterRegistryRevoked && address(OPERATOR_FILTER_REGISTRY).code.length > 0) { // Allow spending tokens from addresses with balance // Note that this still allows listings and marketplaces with escrow to transfer tokens if transferred // from an EOA. @@ -30,7 +30,7 @@ abstract contract RevokableOperatorFiltererUpgradeable is OperatorFiltererUpgrad _; return; } - if (!operatorFilterRegistry.isOperatorAllowed(address(this), msg.sender)) { + if (!OPERATOR_FILTER_REGISTRY.isOperatorAllowed(address(this), msg.sender)) { revert OperatorNotAllowed(msg.sender); } } @@ -39,8 +39,8 @@ abstract contract RevokableOperatorFiltererUpgradeable is OperatorFiltererUpgrad modifier onlyAllowedOperatorApproval(address operator) override { // Check registry code length to facilitate testing in environments without a deployed registry. - if (!_isOperatorFilterRegistryRevoked && address(operatorFilterRegistry).code.length > 0) { - if (!operatorFilterRegistry.isOperatorAllowed(address(this), operator)) { + if (!_isOperatorFilterRegistryRevoked && address(OPERATOR_FILTER_REGISTRY).code.length > 0) { + if (!OPERATOR_FILTER_REGISTRY.isOperatorAllowed(address(this), operator)) { revert OperatorNotAllowed(operator); } }