Skip to content

Commit

Permalink
Module Core Refactor (#145)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
GWSzeto authored Sep 4, 2024
1 parent b8040df commit 76655aa
Show file tree
Hide file tree
Showing 36 changed files with 1,621 additions and 2,065 deletions.
4 changes: 2 additions & 2 deletions src/callback/BeforeMintCallbackERC1155.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ contract BeforeMintCallbackERC1155 {
*
* @param _to The address that is minting tokens.
* @param _id The token ID being minted.
* @param _quantity The quantity of tokens to mint.
* @param _amount The amount of tokens to mint.
* @param _data Optional extra data passed to the hook.
* @return result Abi encoded bytes result of the hook.
*/
function beforeMintERC1155(address _to, uint256 _id, uint256 _quantity, bytes memory _data)
function beforeMintERC1155(address _to, uint256 _id, uint256 _amount, bytes memory _data)
external
payable
virtual
Expand Down
4 changes: 2 additions & 2 deletions src/callback/BeforeMintCallbackERC721.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ contract BeforeMintCallbackERC721 {
* @notice The beforeMintERC721 hook that is called by a core token before minting tokens.
*
* @param _to The address that is minting tokens.
* @param _quantity The quantity of tokens to mint.
* @param _amount The amount of tokens to mint.
* @param _data Optional extra data passed to the hook.
* @return result Abi encoded bytes result of the hook.
*/
function beforeMintERC721(address _to, uint256 _startTokenId, uint256 _quantity, bytes memory _data)
function beforeMintERC721(address _to, uint256 _startTokenId, uint256 _amount, bytes memory _data)
external
payable
virtual
Expand Down
35 changes: 35 additions & 0 deletions src/callback/BeforeMintWithSignatureCallbackERC1155.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.20;

contract BeforeMintWithSignatureCallbackERC1155 {

/*//////////////////////////////////////////////////////////////
ERRORS
//////////////////////////////////////////////////////////////*/

error BeforeMintWithSignatureCallbackERC1155NotImplemented();

/*//////////////////////////////////////////////////////////////
EXTERNAL FUNCTIONS
//////////////////////////////////////////////////////////////*/

/**
* @notice The beforeMintWithSignatureERC1155 hook that is called by a core token before minting tokens.
*
* @param _to The address that is minting tokens.
* @param _amount The quantity of tokens to mint.
* @param _data Optional extra data passed to the hook.
* @param _signer The address that signed the minting request.
* @return result Abi encoded bytes result of the hook.
*/
function beforeMintWithSignatureERC1155(
address _to,
uint256 _id,
uint256 _amount,
bytes memory _data,
address _signer
) external payable virtual returns (bytes memory result) {
revert BeforeMintWithSignatureCallbackERC1155NotImplemented();
}

}
34 changes: 34 additions & 0 deletions src/callback/BeforeMintWithSignatureCallbackERC20.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.20;

contract BeforeMintWithSignatureCallbackERC20 {

/*//////////////////////////////////////////////////////////////
ERRORS
//////////////////////////////////////////////////////////////*/

error BeforeMintWithSignatureCallbackERC20NotImplemented();

/*//////////////////////////////////////////////////////////////
EXTERNAL FUNCTIONS
//////////////////////////////////////////////////////////////*/

/**
* @notice The beforeMintWithSignatureERC20 hook that is called by a core token before minting tokens.
*
* @param _to The address that is minting tokens.
* @param _amount The amount of tokens to mint.
* @param _data Optional extra data passed to the hook.
* @param _signer The address that signed the minting request.
* @return result Abi encoded bytes result of the hook.
*/
function beforeMintWithSignatureERC20(address _to, uint256 _amount, bytes memory _data, address _signer)
external
payable
virtual
returns (bytes memory result)
{
revert BeforeMintWithSignatureCallbackERC20NotImplemented();
}

}
35 changes: 35 additions & 0 deletions src/callback/BeforeMintWithSignatureCallbackERC721.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.20;

contract BeforeMintWithSignatureCallbackERC721 {

/*//////////////////////////////////////////////////////////////
ERRORS
//////////////////////////////////////////////////////////////*/

error BeforeMintWithSignatureCallbackERC721NotImplemented();

/*//////////////////////////////////////////////////////////////
EXTERNAL FUNCTIONS
//////////////////////////////////////////////////////////////*/

/**
* @notice The beforeMintWithSignatureERC721 hook that is called by a core token before minting tokens.
*
* @param _to The address that is minting tokens.
* @param _amount The amount of tokens to mint.
* @param _data Optional extra data passed to the hook.
* @param _signer The address that signed the minting request.
* @return result Abi encoded bytes result of the hook.
*/
function beforeMintWithSignatureERC721(
address _to,
uint256 _startTokenId,
uint256 _amount,
bytes memory _data,
address _signer
) external payable virtual returns (bytes memory result) {
revert BeforeMintWithSignatureCallbackERC721NotImplemented();
}

}
4 changes: 2 additions & 2 deletions src/callback/BeforeTransferCallbackERC1155.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ contract BeforeTransferCallbackERC1155 {
* @param _from The address that is transferring tokens.
* @param _to The address that is receiving tokens.
* @param _id The token ID being transferred.
* @param _value The quantity of tokens being transferred.
* @param _amount The amount of tokens being transferred.
* @return result Abi encoded bytes result of the hook.
*/
function beforeTransferERC1155(address _from, address _to, uint256 _id, uint256 _value)
function beforeTransferERC1155(address _from, address _to, uint256 _id, uint256 _amount)
external
virtual
returns (bytes memory result)
Expand Down
33 changes: 33 additions & 0 deletions src/callback/UpdateMetadataCallbackERC1155.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.20;

contract UpdateMetadataCallbackERC1155 {

/*//////////////////////////////////////////////////////////////
ERRORS
//////////////////////////////////////////////////////////////*/

error UpdateMetadataCallbackERC1155NotImplemented();

/*//////////////////////////////////////////////////////////////
EXTERNAL FUNCTIONS
//////////////////////////////////////////////////////////////*/

/**
* @notice The beforeMintERC1155 hook that is called by a core token before minting tokens.
*
* @param _to The address that is minting tokens.
* @param _quantity The quantity of tokens to mint.
* @param _baseURI The URI to fetch token metadata from.
* @return result Abi encoded bytes result of the hook.
*/
function updateMetadataERC1155(address _to, uint256 _startTokenId, uint256 _quantity, string calldata _baseURI)
external
payable
virtual
returns (bytes memory result)
{
revert UpdateMetadataCallbackERC1155NotImplemented();
}

}
33 changes: 33 additions & 0 deletions src/callback/UpdateMetadataCallbackERC721.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.20;

contract UpdateMetadataCallbackERC721 {

/*//////////////////////////////////////////////////////////////
ERRORS
//////////////////////////////////////////////////////////////*/

error UpdateMetadataCallbackERC721NotImplemented();

/*//////////////////////////////////////////////////////////////
EXTERNAL FUNCTIONS
//////////////////////////////////////////////////////////////*/

/**
* @notice The beforeMintERC721 hook that is called by a core token before minting tokens.
*
* @param _to The address that is minting tokens.
* @param _amount The amount of tokens to mint.
* @param _baseURI The URI to fetch token metadata from.
* @return result Abi encoded bytes result of the hook.
*/
function updateMetadataERC721(address _to, uint256 _startTokenId, uint256 _amount, string calldata _baseURI)
external
payable
virtual
returns (bytes memory result)
{
revert UpdateMetadataCallbackERC721NotImplemented();
}

}
Loading

0 comments on commit 76655aa

Please sign in to comment.