@@ -16,19 +16,7 @@ abstract contract OperatorFiltererUpgradeable is OperatorFilterToggle {
1616 // If an inheriting token contract is deployed to a network without the registry deployed, the modifier
1717 // will not revert, but the contract will need to be registered with the registry once it is deployed in
1818 // order for the modifier to filter addresses.
19- if (address (OPERATOR_FILTER_REGISTRY).code.length > 0 ) {
20- if (! OPERATOR_FILTER_REGISTRY.isRegistered (address (this ))) {
21- if (subscribe) {
22- OPERATOR_FILTER_REGISTRY.registerAndSubscribe (address (this ), subscriptionOrRegistrantToCopy);
23- } else {
24- if (subscriptionOrRegistrantToCopy != address (0 )) {
25- OPERATOR_FILTER_REGISTRY.registerAndCopyEntries (address (this ), subscriptionOrRegistrantToCopy);
26- } else {
27- OPERATOR_FILTER_REGISTRY.register (address (this ));
28- }
29- }
30- }
31- }
19+ _register (subscriptionOrRegistrantToCopy, subscribe);
3220 }
3321
3422 modifier onlyAllowedOperator (address from ) virtual {
@@ -61,4 +49,21 @@ abstract contract OperatorFiltererUpgradeable is OperatorFilterToggle {
6149 }
6250 _;
6351 }
52+
53+ function _register (address subscriptionOrRegistrantToCopy , bool subscribe ) internal {
54+ // Is the registry deployed?
55+ if (address (OPERATOR_FILTER_REGISTRY).code.length > 0 ) {
56+ // Is the subscription contract deployed?
57+ if (address (subscriptionOrRegistrantToCopy).code.length > 0 ) {
58+ // Do we want to subscribe?
59+ if (subscribe) {
60+ OPERATOR_FILTER_REGISTRY.registerAndSubscribe (address (this ), subscriptionOrRegistrantToCopy);
61+ } else {
62+ OPERATOR_FILTER_REGISTRY.registerAndCopyEntries (address (this ), subscriptionOrRegistrantToCopy);
63+ }
64+ } else {
65+ OPERATOR_FILTER_REGISTRY.register (address (this ));
66+ }
67+ }
68+ }
6469}
0 commit comments