Skip to content

Commit 0d55eb1

Browse files
Krishang NadgaudaKrishang Nadgauda
authored andcommitted
Multiwrap final edits
1 parent 8047ec7 commit 0d55eb1

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

contracts/multiwrap/Multiwrap.sol

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,9 @@ contract Multiwrap is
9393
Modifiers
9494
//////////////////////////////////////////////////////////////*/
9595

96-
modifier onlyMinter() {
97-
// if transfer is restricted on the contract, we still want to allow burning and minting
98-
if (!hasRole(MINTER_ROLE, address(0))) {
99-
require(hasRole(MINTER_ROLE, _msgSender()), "restricted to MINTER_ROLE holders.");
96+
modifier onlyRoleWithSwitch(bytes32 role) {
97+
if (!hasRole(role, address(0))) {
98+
_checkRole(role, _msgSender());
10099
}
101100

102101
_;
@@ -148,7 +147,7 @@ contract Multiwrap is
148147
Token[] calldata _wrappedContents,
149148
string calldata _uriForWrappedToken,
150149
address _recipient
151-
) external payable nonReentrant onlyMinter returns (uint256 tokenId) {
150+
) external payable nonReentrant onlyRoleWithSwitch(MINTER_ROLE) returns (uint256 tokenId) {
152151

153152
tokenId = nextTokenIdToMint;
154153
nextTokenIdToMint += 1;
@@ -161,11 +160,10 @@ contract Multiwrap is
161160
}
162161

163162
/// @dev Unwrap a wrapped NFT to retrieve underlying ERC1155, ERC721, ERC20 tokens.
164-
function unwrap(uint256 _tokenId, address _recipient) external nonReentrant {
163+
function unwrap(uint256 _tokenId, address _recipient) external nonReentrant onlyRoleWithSwitch(UNWRAP_ROLE) {
165164

166165
require(_tokenId < nextTokenIdToMint, "invalid tokenId");
167166
require(_isApprovedOrOwner(_msgSender(), _tokenId), "unapproved called");
168-
require(hasRole(UNWRAP_ROLE, address(0)) || hasRole(UNWRAP_ROLE, _msgSender()), "!UNWRAP_ROLE");
169167

170168
_burn(_tokenId);
171169
_releaseTokens(_recipient, _tokenId);
@@ -177,7 +175,7 @@ contract Multiwrap is
177175
Getter functions
178176
//////////////////////////////////////////////////////////////*/
179177

180-
/// @dev Returns the underlygin contents of a wrapped NFT.
178+
/// @dev Returns the underlying contents of a wrapped NFT.
181179
function getWrappedContents(uint256 _tokenId) external view returns (Token[] memory contents) {
182180
uint256 total = getTokenCountOfBundle(_tokenId);
183181
contents = new Token[](total);
@@ -222,7 +220,7 @@ contract Multiwrap is
222220

223221
// if transfer is restricted on the contract, we still want to allow burning and minting
224222
if (!hasRole(TRANSFER_ROLE, address(0)) && from != address(0) && to != address(0)) {
225-
require(hasRole(TRANSFER_ROLE, from) || hasRole(TRANSFER_ROLE, to), "restricted to TRANSFER_ROLE holders.");
223+
require(hasRole(TRANSFER_ROLE, from) || hasRole(TRANSFER_ROLE, to), "!TRANSFER_ROLE");
226224
}
227225
}
228226

0 commit comments

Comments
 (0)