Skip to content

Commit 5464318

Browse files
GWSzetoPranavGarg01joaquim-verges
authored
Merge dev to main (#163)
* renamed to nextTokenIdToMint in BatchMetadata (#141) * fix: expectRevert on low-level call (#136) * update batchMetadata logic to make each batchUris independent (#144) * update batchMetadata logic to make each batchUris independent * format * Module Core Refactor (#145) * separated out metadata functionality from mintable module * built in signature mint into the core erc721 contract * implemented in Mintable * Implemented updateMetadata * simplified parameters and structs * all tests pass * updated ERC721 initializable to match ERC721Core * addressed the PR issues * updated 1155 versions to now match 721 implementations * completed all the tests * Implemented parity in the ERC1155Initializable contract * unified naming from quantity and value to amount * slapped on a keccak256 * move OwnableRoles check on the signature * removed double events being emitted * tests pass * updated ERC20 core * implemented Claimable and Mintable on the ERC20 side * tests pass * updated based on PR feedback * Fix getSupportedCallbackFunctions ub ERC721CoreInitializable (#149) * implmented delayed functionality into batchMetadata (#148) * implmented delayed functionality into batchMetadata * created tests for BatchMetadata * updated ERC1155 tests and updated from batchStartId to batchRange * Implement tokenIdERC1155 module to handle tokenId management (#147) * initial commit * created tests for tokenIdERC1155 * updated to be optional * updated naming and tests * Transfer validator has roles (#143) * created hasRole function in the roylaty module * created tests * Optimzed callback execution (#135) * gas benchmark * optimize execute callback function * fix typo * optimize execute callback view function * optimize callback mode loop * Implement Max per wallet (#151) * implemented maxMintPerWallet * tests pass * maxMintPerWalletExceeded tests pass * introduced base contracts for core and initilizable to inherit * rename commit * rename commit * renamed from core to coreInitializable for the ERC1155 (#152) * updated to now use 1e18 divided (#153) * Remove double initializer in ERC721CoreInitializable (#154) * rebase off of main (#157) * [L-4] Wrong function selector returned for the transfer validation function (#150) * [L-4] Wrong function selector returned for the transfer validation function * [Q-3] Move interface identifier for ERC165 to Core * [Q-5] Royalty modules should inherit ICreatorToken interface * [Q-6] Nitpicks * removes duplicate supportsInterface (#156) * renamed to nextTokenIdToMint in BatchMetadata (#141) * fix: expectRevert on low-level call (#136) * update batchMetadata logic to make each batchUris independent (#144) * update batchMetadata logic to make each batchUris independent * format * Module Core Refactor (#145) * separated out metadata functionality from mintable module * built in signature mint into the core erc721 contract * implemented in Mintable * Implemented updateMetadata * simplified parameters and structs * all tests pass * updated ERC721 initializable to match ERC721Core * addressed the PR issues * updated 1155 versions to now match 721 implementations * completed all the tests * Implemented parity in the ERC1155Initializable contract * unified naming from quantity and value to amount * slapped on a keccak256 * move OwnableRoles check on the signature * removed double events being emitted * tests pass * updated ERC20 core * implemented Claimable and Mintable on the ERC20 side * tests pass * updated based on PR feedback * Fix getSupportedCallbackFunctions ub ERC721CoreInitializable (#149) * implmented delayed functionality into batchMetadata (#148) * implmented delayed functionality into batchMetadata * created tests for BatchMetadata * updated ERC1155 tests and updated from batchStartId to batchRange * Implement tokenIdERC1155 module to handle tokenId management (#147) * initial commit * created tests for tokenIdERC1155 * updated to be optional * updated naming and tests * Transfer validator has roles (#143) * created hasRole function in the roylaty module * created tests * Optimzed callback execution (#135) * gas benchmark * optimize execute callback function * fix typo * optimize execute callback view function * optimize callback mode loop * Implement Max per wallet (#151) * implemented maxMintPerWallet * tests pass * maxMintPerWalletExceeded tests pass * introduced base contracts for core and initilizable to inherit * rename commit * rename commit * renamed from core to coreInitializable for the ERC1155 (#152) * updated to now use 1e18 divided (#153) * Remove double initializer in ERC721CoreInitializable (#154) --------- Co-authored-by: Pranav Garg <[email protected]> Co-authored-by: Joaquim Verges <[email protected]> * Duplicate constant (#161) * [L-4] Wrong function selector returned for the transfer validation function (#150) * [L-4] Wrong function selector returned for the transfer validation function * [Q-3] Move interface identifier for ERC165 to Core * [Q-5] Royalty modules should inherit ICreatorToken interface * [Q-6] Nitpicks * removes duplicate supportsInterface (#156) * Has roles (#158) * created hasRole function in the roylaty module * created tests * removed duplicate constant in royaltyERC721 * removed .vscode * case sensitivity issue --------- Co-authored-by: Pranav Garg <[email protected]> Co-authored-by: Joaquim Verges <[email protected]>
1 parent 3a4d98d commit 5464318

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+2964
-4312
lines changed

.gas-snapshot

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
CoreBenchmark:test_core_callCallbackFunction_required() (gas: 46411)
2-
CoreBenchmark:test_core_callFunction_callback_callbackFunctionRequired() (gas: 44067)
3-
CoreBenchmark:test_core_callFunction_notPermissionedDelegate() (gas: 18029)
4-
CoreBenchmark:test_core_callFunction_notPermissionedExternal() (gas: 17985)
5-
CoreBenchmark:test_deployCore() (gas: 1920924)
6-
CoreBenchmark:test_deployExtension() (gas: 258057)
7-
CoreBenchmark:test_extension_callFunction_notPermissionedDelegate() (gas: 8294)
8-
CoreBenchmark:test_extension_callFunction_notPermissionedExternal() (gas: 8314)
9-
CoreBenchmark:test_installExtension() (gas: 330369)
10-
CoreBenchmark:test_uninstallExtension() (gas: 18385)
1+
CoreBenchmark:test_core_callCallbackFunction_required() (gas: 67409)
2+
CoreBenchmark:test_core_callFunction_callback_callbackFunctionRequired() (gas: 65131)
3+
CoreBenchmark:test_core_callFunction_notPermissionedDelegate() (gas: 39115)
4+
CoreBenchmark:test_core_callFunction_notPermissionedExternal() (gas: 39093)
5+
CoreBenchmark:test_deployCore() (gas: 2139892)
6+
CoreBenchmark:test_deployModule() (gas: 350173)
7+
CoreBenchmark:test_installModule() (gas: 352153)
8+
CoreBenchmark:test_module_callFunction_notPermissionedDelegate() (gas: 29381)
9+
CoreBenchmark:test_module_callFunction_notPermissionedExternal() (gas: 29379)
10+
CoreBenchmark:test_uninstallModule() (gas: 91332)

.vscode/settings.json

-3
This file was deleted.

src/Core.sol

+34-36
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ abstract contract Core is ICore, OwnableRoles, ReentrancyGuard {
3838
EVENTS
3939
//////////////////////////////////////////////////////////////*/
4040

41-
/// @notice Emitted when an module is installed.
41+
/// @notice Emitted when a module is installed.
4242
event ModuleInstalled(address caller, address implementation, address installedModule);
4343

44-
/// @notice Emitted when an module is uninstalled.
44+
/// @notice Emitted when a module is uninstalled.
4545
event ModuleUninstalled(address caller, address implementation, address installedModule);
4646

4747
/*//////////////////////////////////////////////////////////////
@@ -125,7 +125,7 @@ abstract contract Core is ICore, OwnableRoles, ReentrancyGuard {
125125
EXTERNAL FUNCTIONS
126126
//////////////////////////////////////////////////////////////*/
127127

128-
/// @notice Installs an module contract.
128+
/// @notice Installs a module contract.
129129
function installModule(address _module, bytes calldata _data)
130130
external
131131
payable
@@ -135,7 +135,7 @@ abstract contract Core is ICore, OwnableRoles, ReentrancyGuard {
135135
_installModule(_module, _data);
136136
}
137137

138-
/// @notice Uninstalls an module contract.
138+
/// @notice Uninstalls a module contract.
139139
function uninstallModule(address _module, bytes calldata _data)
140140
external
141141
payable
@@ -175,7 +175,7 @@ abstract contract Core is ICore, OwnableRoles, ReentrancyGuard {
175175
return false;
176176
}
177177

178-
/// @dev Installs an module contract.
178+
/// @dev Installs a module contract.
179179
function _installModule(address _module, bytes memory _data) internal {
180180
if (!modules.add(_module)) {
181181
revert ModuleAlreadyInstalled();
@@ -257,7 +257,7 @@ abstract contract Core is ICore, OwnableRoles, ReentrancyGuard {
257257
emit ModuleInstalled(msg.sender, _module, _module);
258258
}
259259

260-
/// @notice Uninstalls an module contract.
260+
/// @notice Uninstalls a module contract.
261261
function _uninstallModule(address _module, bytes memory _data) internal {
262262
// Check: remove and check if the module is installed
263263
if (!modules.remove(_module)) {
@@ -292,7 +292,7 @@ abstract contract Core is ICore, OwnableRoles, ReentrancyGuard {
292292
emit ModuleUninstalled(msg.sender, _module, _module);
293293
}
294294

295-
/// @dev Calls an module callback function and checks whether it is optional or required.
295+
/// @dev Calls a module callback function and checks whether it is optional or required.
296296
function _executeCallbackFunction(bytes4 _selector, bytes memory _abiEncodedCalldata)
297297
internal
298298
nonReentrant
@@ -305,29 +305,28 @@ abstract contract Core is ICore, OwnableRoles, ReentrancyGuard {
305305
revert CallbackFunctionNotSupported();
306306
}
307307

308-
// Get callback mode -- required or not required.
309-
SupportedCallbackFunction[] memory functions = getSupportedCallbackFunctions();
310-
uint256 len = functions.length;
311-
312-
CallbackMode callbackMode;
313-
for (uint256 i = 0; i < len; i++) {
314-
if (functions[i].selector == _selector) {
315-
callbackMode = functions[i].mode;
316-
break;
317-
}
318-
}
319-
320308
if (callbackFunction.implementation != address(0)) {
321309
(success, returndata) = callbackFunction.implementation.delegatecall(_abiEncodedCalldata);
322310
if (!success) {
323311
_revert(returndata, CallbackExecutionReverted.selector);
324312
}
325-
} else if (callbackMode == CallbackMode.REQUIRED) {
326-
revert CallbackFunctionRequired();
313+
} else {
314+
// Get callback mode -- required or not required.
315+
SupportedCallbackFunction[] memory functions = getSupportedCallbackFunctions();
316+
uint256 len = functions.length;
317+
318+
for (uint256 i = 0; i < len; i++) {
319+
if (functions[i].selector == _selector) {
320+
if (functions[i].mode == CallbackMode.REQUIRED) {
321+
revert CallbackFunctionRequired();
322+
}
323+
break;
324+
}
325+
}
327326
}
328327
}
329328

330-
/// @dev Calls an module callback function and checks whether it is optional or required.
329+
/// @dev Calls a module callback function and checks whether it is optional or required.
331330
function _executeCallbackFunctionView(bytes4 _selector, bytes memory _abiEncodedCalldata)
332331
internal
333332
view
@@ -340,25 +339,24 @@ abstract contract Core is ICore, OwnableRoles, ReentrancyGuard {
340339
revert CallbackFunctionNotSupported();
341340
}
342341

343-
// Get callback mode -- required or not required.
344-
SupportedCallbackFunction[] memory functions = getSupportedCallbackFunctions();
345-
uint256 len = functions.length;
346-
347-
CallbackMode callbackMode;
348-
for (uint256 i = 0; i < len; i++) {
349-
if (functions[i].selector == _selector) {
350-
callbackMode = functions[i].mode;
351-
break;
352-
}
353-
}
354-
355342
if (callbackFunction.implementation != address(0)) {
356343
(success, returndata) = address(this).staticcall(_abiEncodedCalldata);
357344
if (!success) {
358345
_revert(returndata, CallbackExecutionReverted.selector);
359346
}
360-
} else if (callbackMode == CallbackMode.REQUIRED) {
361-
revert CallbackFunctionRequired();
347+
} else {
348+
// Get callback mode -- required or not required.
349+
SupportedCallbackFunction[] memory functions = getSupportedCallbackFunctions();
350+
uint256 len = functions.length;
351+
352+
for (uint256 i = 0; i < len; i++) {
353+
if (functions[i].selector == _selector) {
354+
if (functions[i].mode == CallbackMode.REQUIRED) {
355+
revert CallbackFunctionRequired();
356+
}
357+
break;
358+
}
359+
}
362360
}
363361
}
364362

src/callback/BeforeMintCallbackERC1155.sol

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ contract BeforeMintCallbackERC1155 {
1818
*
1919
* @param _to The address that is minting tokens.
2020
* @param _id The token ID being minted.
21-
* @param _quantity The quantity of tokens to mint.
21+
* @param _amount The amount of tokens to mint.
2222
* @param _data Optional extra data passed to the hook.
2323
* @return result Abi encoded bytes result of the hook.
2424
*/
25-
function beforeMintERC1155(address _to, uint256 _id, uint256 _quantity, bytes memory _data)
25+
function beforeMintERC1155(address _to, uint256 _id, uint256 _amount, bytes memory _data)
2626
external
2727
payable
2828
virtual

src/callback/BeforeMintCallbackERC721.sol

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ contract BeforeMintCallbackERC721 {
1717
* @notice The beforeMintERC721 hook that is called by a core token before minting tokens.
1818
*
1919
* @param _to The address that is minting tokens.
20-
* @param _quantity The quantity of tokens to mint.
20+
* @param _amount The amount of tokens to mint.
2121
* @param _data Optional extra data passed to the hook.
2222
* @return result Abi encoded bytes result of the hook.
2323
*/
24-
function beforeMintERC721(address _to, uint256 _startTokenId, uint256 _quantity, bytes memory _data)
24+
function beforeMintERC721(address _to, uint256 _startTokenId, uint256 _amount, bytes memory _data)
2525
external
2626
payable
2727
virtual
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
pragma solidity ^0.8.20;
3+
4+
contract BeforeMintWithSignatureCallbackERC1155 {
5+
6+
/*//////////////////////////////////////////////////////////////
7+
ERRORS
8+
//////////////////////////////////////////////////////////////*/
9+
10+
error BeforeMintWithSignatureCallbackERC1155NotImplemented();
11+
12+
/*//////////////////////////////////////////////////////////////
13+
EXTERNAL FUNCTIONS
14+
//////////////////////////////////////////////////////////////*/
15+
16+
/**
17+
* @notice The beforeMintWithSignatureERC1155 hook that is called by a core token before minting tokens.
18+
*
19+
* @param _to The address that is minting tokens.
20+
* @param _amount The quantity of tokens to mint.
21+
* @param _data Optional extra data passed to the hook.
22+
* @param _signer The address that signed the minting request.
23+
* @return result Abi encoded bytes result of the hook.
24+
*/
25+
function beforeMintWithSignatureERC1155(
26+
address _to,
27+
uint256 _id,
28+
uint256 _amount,
29+
bytes memory _data,
30+
address _signer
31+
) external payable virtual returns (bytes memory result) {
32+
revert BeforeMintWithSignatureCallbackERC1155NotImplemented();
33+
}
34+
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
pragma solidity ^0.8.20;
3+
4+
contract BeforeMintWithSignatureCallbackERC20 {
5+
6+
/*//////////////////////////////////////////////////////////////
7+
ERRORS
8+
//////////////////////////////////////////////////////////////*/
9+
10+
error BeforeMintWithSignatureCallbackERC20NotImplemented();
11+
12+
/*//////////////////////////////////////////////////////////////
13+
EXTERNAL FUNCTIONS
14+
//////////////////////////////////////////////////////////////*/
15+
16+
/**
17+
* @notice The beforeMintWithSignatureERC20 hook that is called by a core token before minting tokens.
18+
*
19+
* @param _to The address that is minting tokens.
20+
* @param _amount The amount of tokens to mint.
21+
* @param _data Optional extra data passed to the hook.
22+
* @param _signer The address that signed the minting request.
23+
* @return result Abi encoded bytes result of the hook.
24+
*/
25+
function beforeMintWithSignatureERC20(address _to, uint256 _amount, bytes memory _data, address _signer)
26+
external
27+
payable
28+
virtual
29+
returns (bytes memory result)
30+
{
31+
revert BeforeMintWithSignatureCallbackERC20NotImplemented();
32+
}
33+
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
pragma solidity ^0.8.20;
3+
4+
contract BeforeMintWithSignatureCallbackERC721 {
5+
6+
/*//////////////////////////////////////////////////////////////
7+
ERRORS
8+
//////////////////////////////////////////////////////////////*/
9+
10+
error BeforeMintWithSignatureCallbackERC721NotImplemented();
11+
12+
/*//////////////////////////////////////////////////////////////
13+
EXTERNAL FUNCTIONS
14+
//////////////////////////////////////////////////////////////*/
15+
16+
/**
17+
* @notice The beforeMintWithSignatureERC721 hook that is called by a core token before minting tokens.
18+
*
19+
* @param _to The address that is minting tokens.
20+
* @param _amount The amount of tokens to mint.
21+
* @param _data Optional extra data passed to the hook.
22+
* @param _signer The address that signed the minting request.
23+
* @return result Abi encoded bytes result of the hook.
24+
*/
25+
function beforeMintWithSignatureERC721(
26+
address _to,
27+
uint256 _startTokenId,
28+
uint256 _amount,
29+
bytes memory _data,
30+
address _signer
31+
) external payable virtual returns (bytes memory result) {
32+
revert BeforeMintWithSignatureCallbackERC721NotImplemented();
33+
}
34+
35+
}

src/callback/BeforeTransferCallbackERC1155.sol

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ contract BeforeTransferCallbackERC1155 {
1818
* @param _from The address that is transferring tokens.
1919
* @param _to The address that is receiving tokens.
2020
* @param _id The token ID being transferred.
21-
* @param _value The quantity of tokens being transferred.
21+
* @param _amount The amount of tokens being transferred.
2222
* @return result Abi encoded bytes result of the hook.
2323
*/
24-
function beforeTransferERC1155(address _from, address _to, uint256 _id, uint256 _value)
24+
function beforeTransferERC1155(address _from, address _to, uint256 _id, uint256 _amount)
2525
external
2626
virtual
2727
returns (bytes memory result)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
pragma solidity ^0.8.20;
3+
4+
contract UpdateMetadataCallbackERC1155 {
5+
6+
/*//////////////////////////////////////////////////////////////
7+
ERRORS
8+
//////////////////////////////////////////////////////////////*/
9+
10+
error UpdateMetadataCallbackERC1155NotImplemented();
11+
12+
/*//////////////////////////////////////////////////////////////
13+
EXTERNAL FUNCTIONS
14+
//////////////////////////////////////////////////////////////*/
15+
16+
/**
17+
* @notice The beforeMintERC1155 hook that is called by a core token before minting tokens.
18+
*
19+
* @param _to The address that is minting tokens.
20+
* @param _quantity The quantity of tokens to mint.
21+
* @param _baseURI The URI to fetch token metadata from.
22+
* @return result Abi encoded bytes result of the hook.
23+
*/
24+
function updateMetadataERC1155(address _to, uint256 _startTokenId, uint256 _quantity, string calldata _baseURI)
25+
external
26+
payable
27+
virtual
28+
returns (bytes memory result)
29+
{
30+
revert UpdateMetadataCallbackERC1155NotImplemented();
31+
}
32+
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
pragma solidity ^0.8.20;
3+
4+
contract UpdateMetadataCallbackERC721 {
5+
6+
/*//////////////////////////////////////////////////////////////
7+
ERRORS
8+
//////////////////////////////////////////////////////////////*/
9+
10+
error UpdateMetadataCallbackERC721NotImplemented();
11+
12+
/*//////////////////////////////////////////////////////////////
13+
EXTERNAL FUNCTIONS
14+
//////////////////////////////////////////////////////////////*/
15+
16+
/**
17+
* @notice The beforeMintERC721 hook that is called by a core token before minting tokens.
18+
*
19+
* @param _to The address that is minting tokens.
20+
* @param _amount The amount of tokens to mint.
21+
* @param _baseURI The URI to fetch token metadata from.
22+
* @return result Abi encoded bytes result of the hook.
23+
*/
24+
function updateMetadataERC721(address _to, uint256 _startTokenId, uint256 _amount, string calldata _baseURI)
25+
external
26+
payable
27+
virtual
28+
returns (bytes memory result)
29+
{
30+
revert UpdateMetadataCallbackERC721NotImplemented();
31+
}
32+
33+
}

0 commit comments

Comments
 (0)