Skip to content

Commit b1b46c1

Browse files
authored
remove signature minting from Drop bases (#222)
* remove signature minting from Drop bases * update tests * run prettier
1 parent 0952be6 commit b1b46c1

File tree

9 files changed

+59
-875
lines changed

9 files changed

+59
-875
lines changed

contracts/base/ERC1155Drop.sol

+13-62
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import "../extension/Ownable.sol";
99
import "../extension/Royalty.sol";
1010
import "../extension/BatchMintMetadata.sol";
1111
import "../extension/PrimarySale.sol";
12-
import "../extension/SignatureMintERC1155.sol";
1312
import "../extension/DropSinglePhase1155.sol";
1413
import "../extension/LazyMint.sol";
1514
import "../extension/DelayedReveal.sol";
@@ -19,19 +18,25 @@ import "../lib/TWStrings.sol";
1918

2019
/**
2120
* BASE: ERC1155Base
22-
* EXTENSION: SignatureMintERC1155, DropSinglePhase1155
21+
* EXTENSION: DropSinglePhase1155
2322
*
24-
* The `ERC1155Drop` contract uses the `ERC1155Base` contract, along with the `SignatureMintERC1155` and `DropSinglePhase1155` extension.
23+
* The `ERC1155Base` smart contract implements the ERC1155 NFT standard.
24+
* It includes the following additions to standard ERC1155 logic:
2525
*
26-
* The 'signature minting' mechanism in the `SignatureMintERC1155` extension is a way for a contract admin to authorize
27-
* an external party's request to mint tokens on the admin's contract. At a high level, this means you can authorize
28-
* some external party to mint tokens on your contract, and specify what exactly will be minted by that external party.
26+
* - Contract metadata for royalty support on platforms such as OpenSea that use
27+
* off-chain information to distribute roaylties.
28+
*
29+
* - Ownership of the contract, with the ability to restrict certain functions to
30+
* only be called by the contract's owner.
31+
*
32+
* - Multicall capability to perform multiple actions atomically
33+
*
34+
* - EIP 2981 compliance for royalty support on NFT marketplaces.
2935
*
3036
* The `drop` mechanism in the `DropSinglePhase1155` extension is a distribution mechanism for lazy minted tokens. It lets
3137
* you set restrictions such as a price to charge, an allowlist etc. when an address atttempts to mint lazy minted tokens.
3238
*
33-
* The `ERC721Drop` contract lets you lazy mint tokens, and distribute those lazy minted tokens via signature minting, or
34-
* via the drop mechanism.
39+
* The `ERC721Drop` contract lets you lazy mint tokens, and distribute those lazy minted tokens via the drop mechanism.
3540
*/
3641

3742
contract ERC1155Drop is
@@ -42,7 +47,6 @@ contract ERC1155Drop is
4247
Multicall,
4348
BatchMintMetadata,
4449
PrimarySale,
45-
SignatureMintERC1155,
4650
LazyMint,
4751
DelayedReveal,
4852
DropSinglePhase1155
@@ -96,54 +100,6 @@ contract ERC1155Drop is
96100
}
97101
}
98102

99-
/*//////////////////////////////////////////////////////////////
100-
Signature minting logic
101-
//////////////////////////////////////////////////////////////*/
102-
103-
/**
104-
* @notice Mints tokens according to the provided mint request.
105-
*
106-
* @param _req The payload / mint request.
107-
* @param _signature The signature produced by an account signing the mint request.
108-
*/
109-
function mintWithSignature(MintRequest calldata _req, bytes calldata _signature)
110-
external
111-
payable
112-
virtual
113-
override
114-
returns (address signer)
115-
{
116-
require(_req.quantity > 0, "Minting zero tokens.");
117-
118-
uint256 tokenIdToMint = _req.tokenId;
119-
require(tokenIdToMint < nextTokenIdToMint(), "Claiming invalid tokenId.");
120-
121-
// Verify and process payload.
122-
signer = _processRequest(_req, _signature);
123-
124-
/**
125-
* Get receiver of tokens.
126-
*
127-
* Note: If `_req.to == address(0)`, a `mintWithSignature` transaction sitting in the
128-
* mempool can be frontrun by copying the input data, since the minted tokens
129-
* will be sent to the `_msgSender()` in this case.
130-
*/
131-
address receiver = _req.to == address(0) ? msg.sender : _req.to;
132-
133-
// Collect price
134-
collectPriceOnClaim(_req.primarySaleRecipient, _req.quantity, _req.currency, _req.pricePerToken);
135-
136-
// Set royalties, if applicable.
137-
if (_req.royaltyRecipient != address(0) && _req.royaltyBps != 0) {
138-
_setupRoyaltyInfoForToken(tokenIdToMint, _req.royaltyRecipient, _req.royaltyBps);
139-
}
140-
141-
// Mint tokens.
142-
_mint(receiver, tokenIdToMint, _req.quantity, "");
143-
144-
emit TokensMintedWithSignature(signer, receiver, tokenIdToMint, _req);
145-
}
146-
147103
/*///////////////////////////////////////////////////////////////
148104
Delayed reveal logic
149105
//////////////////////////////////////////////////////////////*/
@@ -322,9 +278,4 @@ contract ERC1155Drop is
322278
function _canReveal() internal view virtual returns (bool) {
323279
return msg.sender == owner();
324280
}
325-
326-
/// @dev Returns whether a given address is authorized to sign mint requests.
327-
function _canSignMintRequest(address _signer) internal view virtual override returns (bool) {
328-
return _signer == owner();
329-
}
330281
}

contracts/base/ERC20Drop.sol

+11-59
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,31 @@ import "../extension/ContractMetadata.sol";
77
import "../extension/Multicall.sol";
88
import "../extension/Ownable.sol";
99
import "../extension/PrimarySale.sol";
10-
import { SignatureMintERC20 } from "../extension/SignatureMintERC20.sol";
1110
import "../extension/DropSinglePhase.sol";
1211

1312
import "../lib/CurrencyTransferLib.sol";
1413

1514
/**
1615
* BASE: ERC20
17-
* EXTENSION: SignatureMintERC20, DropSinglePhase
16+
* EXTENSION: DropSinglePhase
1817
*
19-
* The `ERC20Drop` contract uses the `ERC20Base` contract, along with the `SignatureMintERC20` and `DropSinglePhase` extensions.
18+
* The `ERC20Drop` smart contract implements the ERC20 standard.
19+
* It includes the following additions to standard ERC20 logic:
2020
*
21-
* The 'signature minting' mechanism in the `SignatureMintERC20` extension is a way for a contract admin to authorize
22-
* an external party's request to mint tokens on the admin's contract. At a high level, this means you can authorize
23-
* some external party to mint tokens on your contract, and specify what exactly will be minted by that external party.
21+
* - Ownership of the contract, with the ability to restrict certain functions to
22+
* only be called by the contract's owner.
23+
*
24+
* - Multicall capability to perform multiple actions atomically
25+
*
26+
* - EIP 2612 compliance: See {ERC20-permit} method, which can be used to change an account's ERC20 allowance by
27+
* presenting a message signed by the account.
2428
*
2529
* The `drop` mechanism in the `DropSinglePhase` extension is a distribution mechanism for tokens. It lets
2630
* you set restrictions such as a price to charge, an allowlist etc. when an address atttempts to mint tokens.
2731
*
2832
*/
2933

30-
contract ERC20Drop is
31-
ContractMetadata,
32-
Multicall,
33-
Ownable,
34-
ERC20Permit,
35-
PrimarySale,
36-
SignatureMintERC20,
37-
DropSinglePhase
38-
{
34+
contract ERC20Drop is ContractMetadata, Multicall, Ownable, ERC20Permit, PrimarySale, DropSinglePhase {
3935
/*//////////////////////////////////////////////////////////////
4036
Constructor
4137
//////////////////////////////////////////////////////////////*/
@@ -51,45 +47,6 @@ contract ERC20Drop is
5147
_setupPrimarySaleRecipient(_primarySaleRecipient);
5248
}
5349

54-
/*//////////////////////////////////////////////////////////////
55-
Signature minting logic
56-
//////////////////////////////////////////////////////////////*/
57-
58-
/**
59-
* @notice Mints tokens according to the provided mint request.
60-
*
61-
* @param _req The payload / mint request.
62-
* @param _signature The signature produced by an account signing the mint request.
63-
*/
64-
function mintWithSignature(MintRequest calldata _req, bytes calldata _signature)
65-
external
66-
payable
67-
virtual
68-
returns (address signer)
69-
{
70-
require(_req.quantity > 0, "Minting zero tokens.");
71-
72-
// Verify and process payload.
73-
signer = _processRequest(_req, _signature);
74-
75-
/**
76-
* Get receiver of tokens.
77-
*
78-
* Note: If `_req.to == address(0)`, a `mintWithSignature` transaction sitting in the
79-
* mempool can be frontrun by copying the input data, since the minted tokens
80-
* will be sent to the `_msgSender()` in this case.
81-
*/
82-
address receiver = _req.to == address(0) ? msg.sender : _req.to;
83-
84-
// Collect price
85-
collectPriceOnClaim(_req.primarySaleRecipient, _req.quantity, _req.currency, _req.pricePerToken);
86-
87-
// Mint tokens.
88-
_mint(receiver, _req.quantity);
89-
90-
emit TokensMintedWithSignature(signer, receiver, _req);
91-
}
92-
9350
/*//////////////////////////////////////////////////////////////
9451
ERC20 logic
9552
//////////////////////////////////////////////////////////////*/
@@ -162,11 +119,6 @@ contract ERC20Drop is
162119
return msg.sender == owner();
163120
}
164121

165-
/// @dev Returns whether a given address is authorized to sign mint requests.
166-
function _canSignMintRequest(address _signer) internal view virtual override returns (bool) {
167-
return _signer == owner();
168-
}
169-
170122
/// @dev Returns whether primary sale recipient can be set in the given execution context.
171123
function _canSetPrimarySaleRecipient() internal view virtual override returns (bool) {
172124
return msg.sender == owner();

contracts/base/ERC20DropVote.sol

+11-59
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,31 @@ import "../extension/ContractMetadata.sol";
77
import "../extension/Multicall.sol";
88
import "../extension/Ownable.sol";
99
import "../extension/PrimarySale.sol";
10-
import { SignatureMintERC20 } from "../extension/SignatureMintERC20.sol";
1110
import "../extension/DropSinglePhase.sol";
1211

1312
import "../lib/CurrencyTransferLib.sol";
1413

1514
/**
1615
* BASE: ERC20Votes
17-
* EXTENSION: SignatureMintERC20, DropSinglePhase
16+
* EXTENSION: DropSinglePhase
1817
*
19-
* The `ERC20Drop` contract uses the `ERC20Vote` contract, along with the `SignatureMintERC20` and `DropSinglePhase` extensions.
18+
* The `ERC20Drop` contract uses the `DropSinglePhase` extensions, along with `ERC20Votes`.
19+
* It implements the ERC20 standard, along with the following additions to standard ERC20 logic:
2020
*
21-
* The 'signature minting' mechanism in the `SignatureMintERC20` extension is a way for a contract admin to authorize
22-
* an external party's request to mint tokens on the admin's contract. At a high level, this means you can authorize
23-
* some external party to mint tokens on your contract, and specify what exactly will be minted by that external party.
21+
* - Ownership of the contract, with the ability to restrict certain functions to
22+
* only be called by the contract's owner.
23+
*
24+
* - Multicall capability to perform multiple actions atomically
25+
*
26+
* - EIP 2612 compliance: See {ERC20-permit} method, which can be used to change an account's ERC20 allowance by
27+
* presenting a message signed by the account.
2428
*
2529
* The `drop` mechanism in the `DropSinglePhase` extension is a distribution mechanism tokens. It lets
2630
* you set restrictions such as a price to charge, an allowlist etc. when an address atttempts to mint tokens.
2731
*
2832
*/
2933

30-
contract ERC20DropVote is
31-
ContractMetadata,
32-
Multicall,
33-
Ownable,
34-
ERC20Votes,
35-
PrimarySale,
36-
SignatureMintERC20,
37-
DropSinglePhase
38-
{
34+
contract ERC20DropVote is ContractMetadata, Multicall, Ownable, ERC20Votes, PrimarySale, DropSinglePhase {
3935
/*//////////////////////////////////////////////////////////////
4036
Constructor
4137
//////////////////////////////////////////////////////////////*/
@@ -51,45 +47,6 @@ contract ERC20DropVote is
5147
_setupPrimarySaleRecipient(_primarySaleRecipient);
5248
}
5349

54-
/*//////////////////////////////////////////////////////////////
55-
Signature minting logic
56-
//////////////////////////////////////////////////////////////*/
57-
58-
/**
59-
* @notice Mints tokens according to the provided mint request.
60-
*
61-
* @param _req The payload / mint request.
62-
* @param _signature The signature produced by an account signing the mint request.
63-
*/
64-
function mintWithSignature(MintRequest calldata _req, bytes calldata _signature)
65-
external
66-
payable
67-
virtual
68-
returns (address signer)
69-
{
70-
require(_req.quantity > 0, "Minting zero tokens.");
71-
72-
// Verify and process payload.
73-
signer = _processRequest(_req, _signature);
74-
75-
/**
76-
* Get receiver of tokens.
77-
*
78-
* Note: If `_req.to == address(0)`, a `mintWithSignature` transaction sitting in the
79-
* mempool can be frontrun by copying the input data, since the minted tokens
80-
* will be sent to the `_msgSender()` in this case.
81-
*/
82-
address receiver = _req.to == address(0) ? msg.sender : _req.to;
83-
84-
// Collect price
85-
collectPriceOnClaim(_req.primarySaleRecipient, _req.quantity, _req.currency, _req.pricePerToken);
86-
87-
// Mint tokens.
88-
_mint(receiver, _req.quantity);
89-
90-
emit TokensMintedWithSignature(signer, receiver, _req);
91-
}
92-
9350
/*//////////////////////////////////////////////////////////////
9451
ERC20 logic
9552
//////////////////////////////////////////////////////////////*/
@@ -162,11 +119,6 @@ contract ERC20DropVote is
162119
return msg.sender == owner();
163120
}
164121

165-
/// @dev Returns whether a given address is authorized to sign mint requests.
166-
function _canSignMintRequest(address _signer) internal view virtual override returns (bool) {
167-
return _signer == owner();
168-
}
169-
170122
/// @dev Returns whether primary sale recipient can be set in the given execution context.
171123
function _canSetPrimarySaleRecipient() internal view virtual override returns (bool) {
172124
return msg.sender == owner();

0 commit comments

Comments
 (0)