@@ -47,6 +47,8 @@ contract Multiwrap is
4747 bytes32 private constant MINTER_ROLE = keccak256 ("MINTER_ROLE " );
4848 /// @dev Only UNWRAP_ROLE holders can unwrap tokens, when unwrapping is restricted.
4949 bytes32 private constant UNWRAP_ROLE = keccak256 ("UNWRAP_ROLE " );
50+ /// @dev Only assets with ASSET_ROLE can be wrapped, when wrapping is restricted to particular assets.
51+ bytes32 private constant ASSET_ROLE = keccak256 ("ASSET_ROLE " );
5052
5153 /// @dev The next token ID of the NFT to mint.
5254 uint256 public nextTokenIdToMint;
@@ -90,6 +92,9 @@ contract Multiwrap is
9092 // note: see `onlyRoleWithSwitch` for UNWRAP_ROLE behaviour.
9193 _setupRole (UNWRAP_ROLE, address (0 ));
9294
95+ // note: see `onlyRoleWithSwitch` for UNWRAP_ROLE behaviour.
96+ _setupRole (ASSET_ROLE, address (0 ));
97+
9398 _revokeRole (DEFAULT_ADMIN_ROLE, _msgSender ());
9499 }
95100
@@ -98,10 +103,7 @@ contract Multiwrap is
98103 //////////////////////////////////////////////////////////////*/
99104
100105 modifier onlyRoleWithSwitch (bytes32 role ) {
101- if (! hasRole (role, address (0 ))) {
102- _checkRole (role, _msgSender ());
103- }
104-
106+ _checkRoleWithSwitch (role, _msgSender ());
105107 _;
106108 }
107109
@@ -152,6 +154,13 @@ contract Multiwrap is
152154 string calldata _uriForWrappedToken ,
153155 address _recipient
154156 ) external payable nonReentrant onlyRoleWithSwitch (MINTER_ROLE) returns (uint256 tokenId ) {
157+
158+ if (! hasRole (ASSET_ROLE, address (0 ))) {
159+ for (uint256 i = 0 ; i < _tokensToWrap.length ; i += 1 ) {
160+ _checkRole (ASSET_ROLE, _tokensToWrap[i].assetContract);
161+ }
162+ }
163+
155164 tokenId = nextTokenIdToMint;
156165 nextTokenIdToMint += 1 ;
157166
0 commit comments