Skip to content
This repository was archived by the owner on Sep 1, 2023. It is now read-only.

Commit a2b8f08

Browse files
tweak impl to inherit
1 parent e5333e4 commit a2b8f08

File tree

1 file changed

+13
-36
lines changed

1 file changed

+13
-36
lines changed

src/upgradeable/UpdatableOperatorFiltererUpgradeable.sol

Lines changed: 13 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity ^0.8.13;
33

4-
import {Initializable} from "openzeppelin-contracts-upgradeable/proxy/utils/Initializable.sol";
5-
4+
import {OperatorFiltererUpgradeable} from "./OperatorFiltererUpgradeable.sol";
65
import {IOperatorFilterRegistry} from "../IOperatorFilterRegistry.sol";
76

8-
97
/**
108
* @title Upgradeable storage layout for UpdatableOperatorFiltererUpgradeable.
119
* @author qed.team, abarbatei, balajmarius
@@ -19,7 +17,8 @@ library UpdatableOperatorFiltererUpgradeableStorage {
1917
}
2018

2119
/// @dev The EIP-1967 specific storage slot for the layout
22-
bytes32 internal constant STORAGE_SLOT = bytes32(uint256(keccak256(bytes("UpdatableOperatorFiltererUpgradeable.contracts.storage"))) - 1);
20+
bytes32 internal constant STORAGE_SLOT =
21+
bytes32(uint256(keccak256(bytes("UpdatableOperatorFiltererUpgradeable.contracts.storage"))) - 1);
2322

2423
/// @dev The layout of the storage.
2524
function layout() internal pure returns (Layout storage l) {
@@ -44,12 +43,9 @@ library UpdatableOperatorFiltererUpgradeableStorage {
4443
* - `onlyAllowedOperatorApproval` modifier for `approve` and `setApprovalForAll` methods.
4544
* Use updateOperatorFilterRegistryAddress function to change registry address if needed
4645
*/
47-
abstract contract UpdatableOperatorFiltererUpgradeable is Initializable {
48-
46+
abstract contract UpdatableOperatorFiltererUpgradeable is OperatorFiltererUpgradeable {
4947
using UpdatableOperatorFiltererUpgradeableStorage for UpdatableOperatorFiltererUpgradeableStorage.Layout;
5048

51-
/// @notice Emitted when an operator is not allowed.
52-
error OperatorNotAllowed(address operator);
5349
/// @notice Emitted when someone other than the owner is trying to call an only owner function.
5450
error OnlyOwner();
5551

@@ -64,11 +60,12 @@ abstract contract UpdatableOperatorFiltererUpgradeable is Initializable {
6460
* imitating/copying blocked addresses and codehashes
6561
* @param subscribe If to subscribe to the subscriptionOrRegistrantToCopy address or just copy entries from it
6662
*/
67-
function __UpdatableOperatorFiltererUpgradeable_init(address _registry, address subscriptionOrRegistrantToCopy, bool subscribe)
68-
internal
69-
onlyInitializing
70-
{
71-
UpdatableOperatorFiltererUpgradeableStorage.layout()._operatorFilterRegistry = _registry;
63+
function __UpdatableOperatorFiltererUpgradeable_init(
64+
address _registry,
65+
address subscriptionOrRegistrantToCopy,
66+
bool subscribe
67+
) internal onlyInitializing {
68+
UpdatableOperatorFiltererUpgradeableStorage.layout()._operatorFilterRegistry = _registry;
7269
IOperatorFilterRegistry registry = IOperatorFilterRegistry(_registry);
7370
// If an inheriting token contract is deployed to a network without the registry deployed, the modifier
7471
// will not revert, but the contract will need to be registered with the registry once it is deployed in
@@ -86,27 +83,6 @@ abstract contract UpdatableOperatorFiltererUpgradeable is Initializable {
8683
}
8784
}
8885

89-
/**
90-
* @dev A helper modifier to check if the operator is allowed.
91-
*/
92-
modifier onlyAllowedOperator(address from) virtual {
93-
// Allow spending tokens from addresses with balance
94-
// Note that this still allows listings and marketplaces with escrow to transfer tokens if transferred
95-
// from an EOA.
96-
if (from != msg.sender) {
97-
_checkFilterOperator(msg.sender);
98-
}
99-
_;
100-
}
101-
102-
/**
103-
* @dev A helper modifier to check if the operator approval is allowed.
104-
*/
105-
modifier onlyAllowedOperatorApproval(address operator) virtual {
106-
_checkFilterOperator(operator);
107-
_;
108-
}
109-
11086
/**
11187
* @notice Update the address that the contract will make OperatorFilter checks against. When set to the zero
11288
* address, checks will be bypassed. OnlyOwner.
@@ -136,8 +112,9 @@ abstract contract UpdatableOperatorFiltererUpgradeable is Initializable {
136112
/**
137113
* @dev A helper function to check if the operator is allowed
138114
*/
139-
function _checkFilterOperator(address operator) internal view virtual {
140-
IOperatorFilterRegistry registry = IOperatorFilterRegistry(UpdatableOperatorFiltererUpgradeableStorage.layout()._operatorFilterRegistry);
115+
function _checkFilterOperator(address operator) internal view virtual override {
116+
IOperatorFilterRegistry registry =
117+
IOperatorFilterRegistry(UpdatableOperatorFiltererUpgradeableStorage.layout()._operatorFilterRegistry);
141118
// Check registry code length to facilitate testing in environments without a deployed registry.
142119
if (address(registry) != address(0) && address(registry).code.length > 0) {
143120
// under normal circumstances, this function will revert rather than return false, but inheriting or

0 commit comments

Comments
 (0)