Skip to content

Commit d16a11a

Browse files
Krishang NadgaudaKrishang Nadgauda
authored andcommitted
complete multiwrap refactor
1 parent 0595b19 commit d16a11a

15 files changed

+235
-75
lines changed

contracts/feature/ContractMetadata.sol

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@ abstract contract ContractMetadata is IContractMetadata {
88
string public override contractURI;
99

1010
/// @dev Lets a contract admin set the URI for contract-level metadata.
11-
function setContractURI(string calldata _uri) external override {
11+
function setContractURI(string memory _uri) public override {
1212
require(_canSetContractURI(), "Not authorized");
13+
string memory prevURI = contractURI;
1314
contractURI = _uri;
15+
16+
emit ContractURIUpdated(prevURI, _uri);
1417
}
1518

1619
/// @dev Returns whether contract metadata can be set in the given execution context.
1720
function _canSetContractURI() internal virtual returns (bool);
18-
}
21+
}

contracts/feature/Ownable.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ abstract contract Ownable is IOwnable {
1919

2020
/// @dev Returns whether owner can be set in the given execution context.
2121
function _canSetOwner() internal virtual returns (bool);
22-
}
22+
}

contracts/feature/Permissions.sol

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,17 @@ contract Permissions is IPermissions {
2525

2626
function grantRole(bytes32 role, address account) public virtual override {
2727
_checkRole(_getRoleAdmin[role], msg.sender);
28-
29-
_hasRole[role][account] = true;
30-
31-
emit RoleGranted(role, account, msg.sender);
28+
_setupRole(role, account);
3229
}
3330

3431
function revokeRole(bytes32 role, address account) public virtual override {
3532
_checkRole(_getRoleAdmin[role], msg.sender);
36-
37-
delete _hasRole[role][account];
38-
39-
emit RoleRevoked(role, account, msg.sender);
33+
_revokeRole(role, account);
4034
}
4135

4236
function renounceRole(bytes32 role, address account) public virtual override {
4337
require(msg.sender == account, "Can only renounce for self");
44-
45-
delete _hasRole[role][account];
46-
47-
emit RoleRevoked(role, account, msg.sender);
38+
_revokeRole(role, account);
4839
}
4940

5041
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
@@ -58,6 +49,11 @@ contract Permissions is IPermissions {
5849
emit RoleGranted(role, account, msg.sender);
5950
}
6051

52+
function _revokeRole(bytes32 role, address account) internal virtual {
53+
delete _hasRole[role][account];
54+
emit RoleRevoked(role, account, msg.sender);
55+
}
56+
6157
function _checkRole(bytes32 role, address account) internal view virtual {
6258
if (!_hasRole[role][account]) {
6359
revert(

contracts/feature/PlatformFee.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ abstract contract PlatformFee is IPlatformFee {
2828

2929
/// @dev Returns whether platform fee info can be set in the given execution context.
3030
function _canSetPlatformFeeInfo() internal virtual returns (bool);
31-
}
31+
}

contracts/feature/PrimarySale.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ abstract contract PrimarySale is IPrimarySale {
2121

2222
/// @dev Returns whether primary sale recipient can be set in the given execution context.
2323
function _canSetPrimarySaleRecipient() internal virtual returns (bool);
24-
}
24+
}

contracts/feature/Royalty.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,4 @@ abstract contract Royalty is IRoyalty {
6868

6969
/// @dev Returns whether royalty info can be set in the given execution context.
7070
function _canSetRoyaltyInfo() internal virtual returns (bool);
71-
}
71+
}

contracts/feature/interface/IContractMetadata.sol

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ interface IContractMetadata {
1010
* Only module admin can call this function.
1111
*/
1212
function setContractURI(string calldata _uri) external;
13-
}
13+
14+
event ContractURIUpdated(string prevURI, string newURI);
15+
}

contracts/multiwrap/Multiwrap.sol

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,13 @@ pragma solidity ^0.8.11;
44
// ========== External imports ==========
55
import "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol";
66

7-
import "@openzeppelin/contracts-upgradeable/token/ERC1155/IERC1155Upgradeable.sol";
8-
import "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol";
9-
10-
import "@openzeppelin/contracts-upgradeable/token/ERC1155/utils/ERC1155HolderUpgradeable.sol";
11-
import "@openzeppelin/contracts-upgradeable/token/ERC721/utils/ERC721HolderUpgradeable.sol";
12-
import "@openzeppelin/contracts-upgradeable/token/ERC1155/IERC1155Upgradeable.sol";
13-
import "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol";
14-
157
import "@openzeppelin/contracts-upgradeable/utils/MulticallUpgradeable.sol";
16-
import "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol";
178
import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
189
import "@openzeppelin/contracts-upgradeable/interfaces/IERC2981Upgradeable.sol";
1910

2011
// ========== Internal imports ==========
2112

22-
import "../interfaces/IThirdwebContract.sol";
23-
import "../feature/interface/IRoyalty.sol";
24-
import "../feature/interface/IOwnable.sol";
25-
2613
import "../interfaces/IMultiwrap.sol";
27-
import "../lib/CurrencyTransferLib.sol";
2814
import "../openzeppelin-presets/metatx/ERC2771ContextUpgradeable.sol";
2915

3016
// ========== Features ==========
@@ -86,21 +72,21 @@ contract Multiwrap is
8672
__ERC2771Context_init(_trustedForwarders);
8773
__ERC721_init(_name, _symbol);
8874

89-
// _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
75+
// Revoked at the end of the function.
76+
_setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
9077

91-
// // Initialize this contract's state.
92-
// royaltyRecipient = _royaltyRecipient;
93-
// royaltyBps = uint128(_royaltyBps);
94-
// contractURI = _contractURI;
95-
// _owner = _defaultAdmin;
78+
// Initialize this contract's state.
79+
setDefaultRoyaltyInfo(_royaltyRecipient, _royaltyBps);
80+
setOwner(_defaultAdmin);
81+
setContractURI(_contractURI);
9682

97-
// _setupRole(DEFAULT_ADMIN_ROLE, _defaultAdmin);
98-
// _setupRole(MINTER_ROLE, _defaultAdmin);
99-
// _setupRole(TRANSFER_ROLE, _defaultAdmin);
100-
// _setupRole(TRANSFER_ROLE, address(0));
101-
// _setupRole(UNWRAP_ROLE, address(0));
83+
_setupRole(DEFAULT_ADMIN_ROLE, _defaultAdmin);
84+
_setupRole(MINTER_ROLE, _defaultAdmin);
85+
_setupRole(TRANSFER_ROLE, _defaultAdmin);
86+
_setupRole(TRANSFER_ROLE, address(0));
87+
_setupRole(UNWRAP_ROLE, address(0));
10288

103-
// _revokeRole(DEFAULT_ADMIN_ROLE, _msgSender());
89+
_revokeRole(DEFAULT_ADMIN_ROLE, _msgSender());
10490
}
10591

10692
/*///////////////////////////////////////////////////////////////

docs/ByocFactory.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,23 @@ event ContractDeployed(address indexed deployer, address indexed publisher, addr
420420
| publisher `indexed` | address | undefined |
421421
| deployedContract | address | undefined |
422422

423+
### ContractURIUpdated
424+
425+
```solidity
426+
event ContractURIUpdated(string prevURI, string newURI)
427+
```
428+
429+
430+
431+
432+
433+
#### Parameters
434+
435+
| Name | Type | Description |
436+
|---|---|---|
437+
| prevURI | string | undefined |
438+
| newURI | string | undefined |
439+
423440
### OwnerUpdated
424441

425442
```solidity

docs/ContractMetadata.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,24 @@ function setContractURI(string _uri) external nonpayable
4545

4646

4747

48+
## Events
49+
50+
### ContractURIUpdated
51+
52+
```solidity
53+
event ContractURIUpdated(string prevURI, string newURI)
54+
```
55+
56+
57+
58+
59+
60+
#### Parameters
61+
62+
| Name | Type | Description |
63+
|---|---|---|
64+
| prevURI | string | undefined |
65+
| newURI | string | undefined |
66+
67+
4868

0 commit comments

Comments
 (0)