Skip to content

Commit e84dd98

Browse files
authored
GMS-1104: Update bulkMintThreshold func name (#101)
- Make the name more consistent
1 parent 22ff3e0 commit e84dd98

File tree

4 files changed

+32
-32
lines changed

4 files changed

+32
-32
lines changed

contracts/token/erc721/abstract/ERC721Hybrid.sol

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This contract allows for minting with one of two strategies:
1212
- ERC721: minting with specified tokenIDs (inefficient)
1313
- ERC721Psi: minting in batches with consecutive tokenIDs (efficient)
1414
15-
All other ERC721 functions are supported, with routing logic depending on the tokenId.
15+
All other ERC721 functions are supported, with routing logic depending on the tokenId.
1616
*/
1717

1818
abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Errors {
@@ -56,13 +56,13 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err
5656
/** @dev returns the threshold that divides tokens that are minted by id and
5757
* minted by quantity
5858
**/
59-
function bulkMintThreshold() public pure virtual returns (uint256) {
59+
function mintBatchByQuantityThreshold() public pure virtual returns (uint256) {
6060
return 2 ** 128;
6161
}
6262

6363
/// @dev returns the startTokenID for the minting by quantity section of the contract
6464
function _startTokenId() internal pure virtual override(ERC721Psi) returns (uint256) {
65-
return bulkMintThreshold();
65+
return mintBatchByQuantityThreshold();
6666
}
6767

6868
/// @dev mints number of tokens specified to the address given via erc721psi
@@ -93,7 +93,7 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err
9393

9494
/// @dev mints by id to a specified address via erc721
9595
function _mintByID(address to, uint256 tokenId) internal {
96-
if (tokenId >= bulkMintThreshold()) {
96+
if (tokenId >= mintBatchByQuantityThreshold()) {
9797
revert IImmutableERC721IDAboveThreshold(tokenId);
9898
}
9999

@@ -106,7 +106,7 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err
106106

107107
/// @dev safe mints by id to a specified address via erc721
108108
function _safeMintByID(address to, uint256 tokenId) internal {
109-
if (tokenId >= bulkMintThreshold()) {
109+
if (tokenId >= mintBatchByQuantityThreshold()) {
110110
revert IImmutableERC721IDAboveThreshold(tokenId);
111111
}
112112

@@ -192,22 +192,22 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err
192192
* the erc721psi method is invoked. They then behave like their specified ancestors methods.
193193
**/
194194
function _exists(uint256 tokenId) internal view virtual override(ERC721, ERC721PsiBurnable) returns (bool) {
195-
if (tokenId < bulkMintThreshold()) {
195+
if (tokenId < mintBatchByQuantityThreshold()) {
196196
return ERC721._ownerOf(tokenId) != address(0) && (!_burnedTokens.get(tokenId));
197197
}
198198
return ERC721PsiBurnable._exists(tokenId);
199199
}
200200

201201
function _transfer(address from, address to, uint256 tokenId) internal virtual override(ERC721, ERC721Psi) {
202-
if (tokenId < bulkMintThreshold()) {
202+
if (tokenId < mintBatchByQuantityThreshold()) {
203203
ERC721._transfer(from, to, tokenId);
204204
} else {
205205
ERC721Psi._transfer(from, to, tokenId);
206206
}
207207
}
208208

209209
function ownerOf(uint256 tokenId) public view virtual override(ERC721, ERC721Psi) returns (address) {
210-
if (tokenId < bulkMintThreshold()) {
210+
if (tokenId < mintBatchByQuantityThreshold()) {
211211
return ERC721.ownerOf(tokenId);
212212
}
213213
return ERC721Psi.ownerOf(tokenId);
@@ -217,7 +217,7 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err
217217
* additional tracking is added for erc721 to prevent re-minting
218218
**/
219219
function _burn(uint256 tokenId) internal virtual override(ERC721, ERC721PsiBurnable) {
220-
if (tokenId < bulkMintThreshold()) {
220+
if (tokenId < mintBatchByQuantityThreshold()) {
221221
ERC721._burn(tokenId);
222222
_burnedTokens.set(tokenId);
223223
_idMintTotalSupply--;
@@ -227,7 +227,7 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err
227227
}
228228

229229
function _approve(address to, uint256 tokenId) internal virtual override(ERC721, ERC721Psi) {
230-
if (tokenId < bulkMintThreshold()) {
230+
if (tokenId < mintBatchByQuantityThreshold()) {
231231
return ERC721._approve(to, tokenId);
232232
}
233233
return ERC721Psi._approve(to, tokenId);
@@ -237,7 +237,7 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err
237237
address spender,
238238
uint256 tokenId
239239
) internal view virtual override(ERC721, ERC721Psi) returns (bool) {
240-
if (tokenId < bulkMintThreshold()) {
240+
if (tokenId < mintBatchByQuantityThreshold()) {
241241
return ERC721._isApprovedOrOwner(spender, tokenId);
242242
}
243243
return ERC721Psi._isApprovedOrOwner(spender, tokenId);
@@ -249,7 +249,7 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err
249249
uint256 tokenId,
250250
bytes memory _data
251251
) internal virtual override(ERC721, ERC721Psi) {
252-
if (tokenId < bulkMintThreshold()) {
252+
if (tokenId < mintBatchByQuantityThreshold()) {
253253
return ERC721._safeTransfer(from, to, tokenId, _data);
254254
}
255255
return ERC721Psi._safeTransfer(from, to, tokenId, _data);
@@ -261,7 +261,7 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err
261261
uint256 tokenId,
262262
bytes memory _data
263263
) public virtual override(ERC721, ERC721Psi) {
264-
if (tokenId < bulkMintThreshold()) {
264+
if (tokenId < mintBatchByQuantityThreshold()) {
265265
return ERC721.safeTransferFrom(from, to, tokenId, _data);
266266
}
267267
return ERC721Psi.safeTransferFrom(from, to, tokenId, _data);
@@ -275,21 +275,21 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err
275275
}
276276

277277
function getApproved(uint256 tokenId) public view virtual override(ERC721, ERC721Psi) returns (address) {
278-
if (tokenId < bulkMintThreshold()) {
278+
if (tokenId < mintBatchByQuantityThreshold()) {
279279
return ERC721.getApproved(tokenId);
280280
}
281281
return ERC721Psi.getApproved(tokenId);
282282
}
283283

284284
function approve(address to, uint256 tokenId) public virtual override(ERC721, ERC721Psi) {
285-
if (tokenId < bulkMintThreshold()) {
285+
if (tokenId < mintBatchByQuantityThreshold()) {
286286
return ERC721.approve(to, tokenId);
287287
}
288288
return ERC721Psi.approve(to, tokenId);
289289
}
290290

291291
function transferFrom(address from, address to, uint256 tokenId) public virtual override(ERC721, ERC721Psi) {
292-
if (tokenId < bulkMintThreshold()) {
292+
if (tokenId < mintBatchByQuantityThreshold()) {
293293
return ERC721.transferFrom(from, to, tokenId);
294294
}
295295
return ERC721Psi.transferFrom(from, to, tokenId);

test/allowlist/HybridApproval.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ describe("Royalty Checks with Hybrid ERC721", function () {
8686
});
8787

8888
it("Should allow EOAs to be approved", async function () {
89-
const first = await erc721.bulkMintThreshold();
89+
const first = await erc721.mintBatchByQuantityThreshold();
9090
await erc721.connect(minter).mintByQuantity(minter.address, 1);
9191
// Approve EOA addr
9292
const tokenId = first;
@@ -99,7 +99,7 @@ describe("Royalty Checks with Hybrid ERC721", function () {
9999
it("Should allow Allowlisted addresses to be approved", async function () {
100100
// Add the mock marketplace to registry
101101
await operatorAllowlist.connect(registrar).addAddressToAllowlist([marketPlace.address]);
102-
const first = await erc721.bulkMintThreshold();
102+
const first = await erc721.mintBatchByQuantityThreshold();
103103
await erc721.connect(minter).mintByQuantity(minter.address, 1);
104104
const tokenId = first;
105105
// Approve marketplace on erc721 contract
@@ -112,7 +112,7 @@ describe("Royalty Checks with Hybrid ERC721", function () {
112112
it("Should allow Allowlisted smart contract wallets to be approved", async function () {
113113
// Allowlist the bytecode
114114
await operatorAllowlist.connect(registrar).addWalletToAllowlist(deployedAddr);
115-
const first = await erc721.bulkMintThreshold();
115+
const first = await erc721.mintBatchByQuantityThreshold();
116116
await erc721.connect(minter).mintByQuantity(minter.address, 1);
117117
const tokenId = first;
118118
await erc721.connect(minter).approve(deployedAddr, tokenId);
@@ -128,7 +128,7 @@ describe("Royalty Checks with Hybrid ERC721", function () {
128128
await erc721.connect(owner).setOperatorAllowlistRegistry(operatorAllowlist.address);
129129
});
130130
it("Should freely allow transfers between EOAs", async function () {
131-
const first = await erc721.bulkMintThreshold();
131+
const first = await erc721.mintBatchByQuantityThreshold();
132132
await erc721.connect(minter).mintByQuantity(accs[0].address, 1);
133133
await erc721.connect(minter).mintByQuantity(accs[1].address, 1);
134134
const tokenIdOne = first;
@@ -152,7 +152,7 @@ describe("Royalty Checks with Hybrid ERC721", function () {
152152
});
153153

154154
it("Should block transfers from a not allow listed contracts", async function () {
155-
const first = await erc721.bulkMintThreshold();
155+
const first = await erc721.mintBatchByQuantityThreshold();
156156
await erc721.connect(minter).mintByQuantity(marketPlace.address, 1);
157157
const tokenId = first;
158158
await expect(marketPlace.connect(minter).executeTransferFrom(marketPlace.address, minter.address, tokenId))

test/token/erc721/ImmutableERC721.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ describe("ImmutableERC721", function () {
105105
it("Should allow batch minting of tokens by quantity", async function () {
106106
const qty = 5;
107107
const mintRequests = [{ to: user.address, quantity: qty }];
108-
const first = await erc721.bulkMintThreshold();
108+
const first = await erc721.mintBatchByQuantityThreshold();
109109
const originalBalance = await erc721.balanceOf(user.address);
110110
const originalSupply = await erc721.totalSupply();
111111
await erc721.connect(minter).mintBatchByQuantity(mintRequests);
@@ -119,7 +119,7 @@ describe("ImmutableERC721", function () {
119119
it("Should allow safe batch minting of tokens by quantity", async function () {
120120
const qty = 5;
121121
const mintRequests = [{ to: user2.address, quantity: qty }];
122-
const first = await erc721.bulkMintThreshold();
122+
const first = await erc721.mintBatchByQuantityThreshold();
123123
const originalBalance = await erc721.balanceOf(user2.address);
124124
const originalSupply = await erc721.totalSupply();
125125
await erc721.connect(minter).safeMintBatchByQuantity(mintRequests);
@@ -142,7 +142,7 @@ describe("ImmutableERC721", function () {
142142
it("Should allow owner or approved to burn a batch of mixed ID/PSI tokens", async function () {
143143
const originalBalance = await erc721.balanceOf(user.address);
144144
const originalSupply = await erc721.totalSupply();
145-
const first = await erc721.bulkMintThreshold();
145+
const first = await erc721.mintBatchByQuantityThreshold();
146146
const batch = [3, 4, first.toString(), first.add(1).toString()];
147147
await erc721.connect(user).burnBatch(batch);
148148
expect(await erc721.balanceOf(user.address)).to.equal(originalBalance.sub(batch.length));
@@ -206,7 +206,7 @@ describe("ImmutableERC721", function () {
206206
});
207207

208208
it("Should prevent not approved to burn a batch of tokens", async function () {
209-
const first = await erc721.bulkMintThreshold();
209+
const first = await erc721.mintBatchByQuantityThreshold();
210210
await expect(erc721.connect(minter).burnBatch([first.add(2), first.add(3)]))
211211
.to.be.revertedWith("IImmutableERC721NotOwnerOrOperator")
212212
.withArgs(first.add(2));
@@ -221,7 +221,7 @@ describe("ImmutableERC721", function () {
221221
});
222222

223223
it("Should revert if minting by id with id above threshold", async function () {
224-
const first = await erc721.bulkMintThreshold();
224+
const first = await erc721.mintBatchByQuantityThreshold();
225225
const mintRequests = [{ to: user.address, tokenIds: [first] }];
226226
await expect(erc721.connect(minter).mintBatch(mintRequests))
227227
.to.be.revertedWith("IImmutableERC721IDAboveThreshold")
@@ -293,7 +293,7 @@ describe("ImmutableERC721", function () {
293293

294294
describe("exists", async function () {
295295
it("verifies valid tokens minted by quantity", async function () {
296-
const first = await erc721.bulkMintThreshold();
296+
const first = await erc721.mintBatchByQuantityThreshold();
297297
expect(await erc721.exists(first.add(3))).to.equal(true);
298298
});
299299

@@ -302,7 +302,7 @@ describe("ImmutableERC721", function () {
302302
});
303303

304304
it("verifies invalid tokens", async function () {
305-
const first = await erc721.bulkMintThreshold();
305+
const first = await erc721.mintBatchByQuantityThreshold();
306306
expect(await erc721.exists(first.add(10))).to.equal(false);
307307
});
308308
});
@@ -321,7 +321,7 @@ describe("ImmutableERC721", function () {
321321

322322
describe("Transfers", function () {
323323
it("Should allow users to transfer tokens using safeTransferFromBatch", async function () {
324-
const first = await erc721.bulkMintThreshold();
324+
const first = await erc721.mintBatchByQuantityThreshold();
325325
// Mint tokens for testing transfers
326326
const mintRequests = [
327327
{ to: minter.address, tokenIds: [51, 52, 53] },

test/token/erc721/ImmutableERC721HybridPermit.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ describe("ImmutableERC721Permit", function () {
9696

9797
it("can use permits to approve spender on token minted by quantity", async function () {
9898
await erc721.connect(minter).mintByQuantity(user.address, 1);
99-
const first = await erc721.bulkMintThreshold();
99+
const first = await erc721.mintBatchByQuantityThreshold();
100100

101101
const deadline = Math.round(Date.now() / 1000 + 24 * 60 * 60);
102102
const nonce = await erc721.nonces(first);
@@ -200,7 +200,7 @@ describe("ImmutableERC721Permit", function () {
200200
await erc721.connect(minter).mintByQuantity(user.address, 1);
201201
const deadline = Math.round(Date.now() / 1000 + 24 * 60 * 60);
202202
const operatorAddress = await operator.getAddress();
203-
const tokenId = (await erc721.bulkMintThreshold()).add(1);
203+
const tokenId = (await erc721.mintBatchByQuantityThreshold()).add(1);
204204

205205
await erc721
206206
.connect(user)
@@ -240,7 +240,7 @@ describe("ImmutableERC721Permit", function () {
240240
await erc721.connect(minter).mintByQuantity(user.address, 1);
241241
const deadline = Math.round(Date.now() / 1000 + 24 * 60 * 60);
242242

243-
const tokenId = (await erc721.bulkMintThreshold()).add(2);
243+
const tokenId = (await erc721.mintBatchByQuantityThreshold()).add(2);
244244
const nonce = await erc721.nonces(tokenId);
245245
expect(nonce).to.be.equal(0);
246246

0 commit comments

Comments
 (0)