use __unsafe_increaseBalance to react to batch minting
This commit is contained in:
@ -34,4 +34,8 @@ contract ERC721ConsecutiveEnumerableMock is ERC721Consecutive, ERC721Enumerable
|
||||
) internal virtual override(ERC721Consecutive, ERC721Enumerable) returns (address) {
|
||||
return super._update(to, tokenId, constraints);
|
||||
}
|
||||
|
||||
function __unsafe_increaseBalance(address account, uint256 amount) internal virtual override(ERC721, ERC721Enumerable) {
|
||||
super.__unsafe_increaseBalance(account, amount);
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,6 +46,10 @@ contract ERC721ConsecutiveMock is ERC721Consecutive, ERC721Pausable, ERC721Votes
|
||||
) internal virtual override(ERC721Consecutive, ERC721Pausable, ERC721Votes) returns (address) {
|
||||
return super._update(to, tokenId, constraints);
|
||||
}
|
||||
|
||||
function __unsafe_increaseBalance(address account, uint256 amount) internal virtual override(ERC721, ERC721Votes) {
|
||||
super.__unsafe_increaseBalance(account, amount);
|
||||
}
|
||||
}
|
||||
|
||||
contract ERC721ConsecutiveNoConstructorMintMock is ERC721Consecutive {
|
||||
|
||||
@ -456,7 +456,7 @@ abstract contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Er
|
||||
* that `ownerOf(tokenId)` is `a`.
|
||||
*/
|
||||
// solhint-disable-next-line func-name-mixedcase
|
||||
function __unsafe_increaseBalance(address account, uint256 amount) internal {
|
||||
function __unsafe_increaseBalance(address account, uint256 amount) internal virtual {
|
||||
_balances[account] += amount;
|
||||
}
|
||||
}
|
||||
|
||||
@ -164,4 +164,15 @@ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
|
||||
delete _allTokensIndex[tokenId];
|
||||
_allTokens.pop();
|
||||
}
|
||||
|
||||
/**
|
||||
* See {ERC721-__unsafe_increaseBalance}. We need that to account tokens that were minted in batch
|
||||
*/
|
||||
// solhint-disable-next-line func-name-mixedcase
|
||||
function __unsafe_increaseBalance(address account, uint256 amount) internal virtual override {
|
||||
if (amount > 0) {
|
||||
revert ERC721EnumerableForbiddenBatchMint();
|
||||
}
|
||||
super.__unsafe_increaseBalance(account, amount);
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,4 +40,13 @@ abstract contract ERC721Votes is ERC721, Votes {
|
||||
function _getVotingUnits(address account) internal view virtual override returns (uint256) {
|
||||
return balanceOf(account);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {ERC721-__unsafe_increaseBalance}. We need that to account tokens that were minted in batch
|
||||
*/
|
||||
// solhint-disable-next-line func-name-mixedcase
|
||||
function __unsafe_increaseBalance(address account, uint256 amount) internal virtual override {
|
||||
super.__unsafe_increaseBalance(account, amount);
|
||||
_transferVotingUnits(address(0), account, amount);
|
||||
}
|
||||
}
|
||||
|
||||
@ -180,17 +180,6 @@ contract('ERC721Consecutive', function (accounts) {
|
||||
expect(await this.token.$_exists(tokenId)).to.be.equal(true);
|
||||
expect(await this.token.ownerOf(tokenId), user2);
|
||||
});
|
||||
|
||||
it('reverts burning batches of size != 1', async function () {
|
||||
const tokenId = batches[0].amount + offset;
|
||||
const receiver = batches[0].receiver;
|
||||
|
||||
await expectRevertCustomError(
|
||||
this.token.$_afterTokenTransfer(receiver, ZERO_ADDRESS, tokenId, 2),
|
||||
'ERC721ForbiddenBatchBurn',
|
||||
[],
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user