@@ -4,30 +4,13 @@ pragma solidity ^0.8.20;
44import {Module} from "../../../Module.sol " ;
55import {Role} from "../../../Role.sol " ;
66
7+ import {
8+ OperatorAllowlistEnforced,
9+ OperatorAllowlistEnforcedStorage
10+ } from "../../../../dependecies/immutable/allowlist/OperatorAllowlistEnforced.sol " ;
711import {BeforeApproveForAllCallback} from "../../../callback/BeforeApproveForAllCallback.sol " ;
8-
912import {BeforeBatchTransferCallbackERC1155} from "../../../callback/BeforeBatchTransferCallbackERC1155.sol " ;
1013import {BeforeTransferCallbackERC1155} from "../../../callback/BeforeTransferCallbackERC1155.sol " ;
11- import {OperatorAllowlistEnforced} from "@imtbl/contracts/allowlist/OperatorAllowlistEnforced.sol " ;
12-
13- library ImmutableAllowlistStorage {
14-
15- /// @custom:storage-location erc7201:token.immutableallowlist
16- bytes32 public constant IMMUTABLE_ALLOWLIST_STORAGE_POSITION =
17- keccak256 (abi.encode (uint256 (keccak256 ("token.immutableAllowlist.ERC1155 " )) - 1 )) & ~ bytes32 (uint256 (0xff ));
18-
19- struct Data {
20- address operatorAllowlistRegistry;
21- }
22-
23- function data () internal pure returns (Data storage data_ ) {
24- bytes32 position = IMMUTABLE_ALLOWLIST_STORAGE_POSITION;
25- assembly {
26- data_.slot := position
27- }
28- }
29-
30- }
3114
3215contract ImmutableAllowlistERC1155 is
3316 Module ,
@@ -59,32 +42,20 @@ contract ImmutableAllowlistERC1155 is
5942 config.callbackFunctions = new CallbackFunction [](3 );
6043 config.fallbackFunctions = new FallbackFunction [](2 );
6144
62- config.callbackFunctions[1 ] = CallbackFunction (this .beforeApproveForAll.selector );
63- config.callbackFunctions[2 ] = CallbackFunction (this .beforeTransferERC1155.selector );
64- config.callbackFunctions[3 ] = CallbackFunction (this .beforeBatchTransferERC1155.selector );
45+ config.callbackFunctions[0 ] = CallbackFunction (this .beforeApproveForAll.selector );
46+ config.callbackFunctions[1 ] = CallbackFunction (this .beforeTransferERC1155.selector );
47+ config.callbackFunctions[2 ] = CallbackFunction (this .beforeBatchTransferERC1155.selector );
6548
6649 config.fallbackFunctions[0 ] =
6750 FallbackFunction ({selector: this .setOperatorAllowlistRegistry.selector , permissionBits: Role._MANAGER_ROLE});
68- config.fallbackFunctions[1 ] =
69- FallbackFunction ({selector: this .getOperatorAllowlistRegistry.selector , permissionBits: 0 });
51+ config.fallbackFunctions[1 ] = FallbackFunction ({selector: this .operatorAllowlist.selector , permissionBits: 0 });
7052
7153 config.requiredInterfaces = new bytes4 [](1 );
7254 config.requiredInterfaces[0 ] = 0x80ac58cd ; // ERC1155
7355
7456 config.registerInstallationCallback = true ;
7557 }
7658
77- /*//////////////////////////////////////////////////////////////
78- MODIFIERS
79- //////////////////////////////////////////////////////////////*/
80-
81- modifier isOperatorAllowlistSet () {
82- if (_immutableAllowlistStorage ().operatorAllowlistRegistry == address (0 )) {
83- revert OperatorAllowlistNotSet ();
84- }
85- _;
86- }
87-
8859 /*//////////////////////////////////////////////////////////////
8960 CALLBACK FUNCTIONS
9061 //////////////////////////////////////////////////////////////*/
@@ -93,7 +64,6 @@ contract ImmutableAllowlistERC1155 is
9364 function beforeApproveForAll (address _from , address _to , bool _approved )
9465 external
9566 override
96- isOperatorAllowlistSet
9767 validateApproval (_to)
9868 returns (bytes memory )
9969 {}
@@ -102,7 +72,6 @@ contract ImmutableAllowlistERC1155 is
10272 function beforeTransferERC1155 (address _from , address _to , uint256 _id , uint256 _value )
10373 external
10474 override
105- isOperatorAllowlistSet
10675 validateTransfer (_from, _to)
10776 returns (bytes memory )
10877 {}
@@ -111,15 +80,14 @@ contract ImmutableAllowlistERC1155 is
11180 function beforeBatchTransferERC1155 (address _from , address _to , uint256 [] calldata _ids , uint256 [] calldata _values )
11281 external
11382 override
114- isOperatorAllowlistSet
11583 validateTransfer (_from, _to)
11684 returns (bytes memory )
11785 {}
11886
11987 /// @dev Called by a Core into an Module during the installation of the Module.
12088 function onInstall (bytes calldata data ) external {
12189 address registry = abi.decode (data, (address ));
122- _immutableAllowlistStorage ().operatorAllowlistRegistry = registry;
90+ _setOperatorAllowlistRegistry ( registry) ;
12391 }
12492
12593 /// @dev Called by a Core into an Module during the uninstallation of the Module.
@@ -145,20 +113,7 @@ contract ImmutableAllowlistERC1155 is
145113
146114 /// @notice Set the operator allowlist registry address
147115 function setOperatorAllowlistRegistry (address newRegistry ) external {
148- _immutableAllowlistStorage ().operatorAllowlistRegistry = newRegistry;
149- }
150-
151- /// @notice Get the current operator allowlist registry address
152- function getOperatorAllowlistRegistry () external view returns (address ) {
153- return _immutableAllowlistStorage ().operatorAllowlistRegistry;
154- }
155-
156- /*//////////////////////////////////////////////////////////////
157- INTERNAL FUNCTIONS
158- //////////////////////////////////////////////////////////////*/
159-
160- function _immutableAllowlistStorage () internal pure returns (ImmutableAllowlistStorage.Data storage ) {
161- return ImmutableAllowlistStorage.data ();
116+ _setOperatorAllowlistRegistry (newRegistry);
162117 }
163118
164119}
0 commit comments