Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
a3526ac
Rebase ERC721._update on top of next-v5
Amxx Apr 27, 2023
1ed8f9e
use __unsafe_increaseBalance to react to batch minting
Amxx Jun 21, 2023
7ec3435
Apply suggestions from code review
Amxx Jun 21, 2023
e2fdbac
fix lint
Amxx Jun 21, 2023
e9f03bd
Exclude address(0) in ERC721._isApprovedOrOwner
frangio Jun 30, 2023
78c280b
Merge branch 'master' into refactor/erc721-update-fnPointer
Amxx Jun 30, 2023
1cc7f54
Merge remote-tracking branch 'upstream' into refactor/erc721-update-f…
Amxx Jul 3, 2023
c7303ec
fix lint
Amxx Jul 3, 2023
54cb3ca
Merge branch 'master' into refactor/erc721-update-fnPointer
Amxx Jul 3, 2023
562ddf5
implement hybrid _update
Amxx Jul 5, 2023
0bb98cb
Merge branch 'master' into feature/Governor-storage
Amxx Jul 7, 2023
5ab254c
lint
Amxx Jul 7, 2023
bd0c52e
refactor constraint into an optionalChecks bitmap
Amxx Jul 11, 2023
1a95520
replace constraints with a simple operator check
Amxx Jul 11, 2023
7e9d024
Apply suggestions from code review
Amxx Jul 12, 2023
16f2f15
remove _isApproedOrOwner in favor of _isApproved + refactor _checkOnE…
Amxx Jul 12, 2023
2558c8f
change _increaseBalance type to uint128
Amxx Jul 12, 2023
de570d0
allow using approve/_approve to clean approval
Amxx Jul 12, 2023
7121ff7
Merge branch 'erc721-approve-0' into refactor/erc721-update-fnPointer
Amxx Jul 12, 2023
b973d98
changesets
Amxx Jul 12, 2023
e4b0e72
use whenNotPaused in ERC721Pausable
Amxx Jul 12, 2023
4516803
make the safe function without a data field non virtual
Amxx Jul 12, 2023
7c3f161
Update .changeset/eighty-lemons-shake.md
frangio Jul 12, 2023
9ba0120
Format _increaseBalance NatSpec
ernestognw Jul 13, 2023
1081508
Lint
ernestognw Jul 13, 2023
fb4d951
Apply suggestions from code review
Amxx Jul 13, 2023
d7a6aaf
remove _exists
Amxx Jul 13, 2023
4c25b48
Merge branch 'refactor/erc721-update-fnPointer' of https://github.com…
Amxx Jul 13, 2023
20048ca
Changes suggested in the PR discussions
Amxx Jul 13, 2023
e996ba4
add ERC721 specific details in the 'How to upgrade from 4.x' section …
Amxx Jul 13, 2023
b29e573
rename from → previousOwner
Amxx Jul 13, 2023
328b16b
Authorised → Authorized
Amxx Jul 13, 2023
08da709
refactor _checkAuhtorized
Amxx Jul 13, 2023
12f63b3
add test
Amxx Jul 13, 2023
81aca96
Update CHANGELOG.md
frangio Jul 13, 2023
d037530
Apply suggestions from code review
frangio Jul 13, 2023
5ce49a4
remove unnecessary solhint annotation
frangio Jul 13, 2023
a023cad
wrap long line
frangio Jul 13, 2023
caabbf3
improve warnings and notes
frangio Jul 13, 2023
ca32b45
fix _safeTransfer docs
frangio Jul 13, 2023
b982e2a
Update ERC721.behavior.js
Amxx Jul 14, 2023
f404802
Update ERC721.sol
Amxx Jul 14, 2023
20bb47f
Update contracts/token/ERC721/ERC721.sol
Amxx Jul 14, 2023
a475ffa
Update ERC721.sol
Amxx Jul 14, 2023
e26d5c0
Update IERC721.sol
Amxx Jul 14, 2023
2897abc
Update ERC721.sol
Amxx Jul 14, 2023
52923d1
coverage for internal _transfer and _safeTransfer
Amxx Aug 4, 2023
42e17ee
mint
Amxx Aug 4, 2023
c2e1a55
fix comments _isApproved -> _isAuthorized
frangio Aug 9, 2023
a036284
extend warning for _isAuthorized
frangio Aug 9, 2023
1e4f353
add comment to _approve
frangio Aug 9, 2023
7b26030
Update contracts/token/ERC721/ERC721.sol
frangio Aug 9, 2023
7249414
Update contracts/token/ERC721/ERC721.sol
frangio Aug 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
change _increaseBalance type to uint128
  • Loading branch information
Amxx committed Jul 12, 2023
commit 2558c8fac82a914b89c79d6e1515ea849b712580
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ contract ERC721ConsecutiveEnumerableMock is ERC721Consecutive, ERC721Enumerable
return super._update(to, tokenId, operatorCheck);
}

function _increaseBalance(address account, uint256 amount) internal virtual override(ERC721, ERC721Enumerable) {
function _increaseBalance(address account, uint128 amount) internal virtual override(ERC721, ERC721Enumerable) {
super._increaseBalance(account, amount);
}
}
2 changes: 1 addition & 1 deletion contracts/mocks/token/ERC721ConsecutiveMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ contract ERC721ConsecutiveMock is ERC721Consecutive, ERC721Pausable, ERC721Votes
}

// solhint-disable-next-line func-name-mixedcase
function _increaseBalance(address account, uint256 amount) internal virtual override(ERC721, ERC721Votes) {
function _increaseBalance(address account, uint128 amount) internal virtual override(ERC721, ERC721Votes) {
super._increaseBalance(account, amount);
}
}
Expand Down
14 changes: 10 additions & 4 deletions contracts/token/ERC721/ERC721.sol
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ abstract contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Er

/**
* @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist
*
* WARNING: Any override of this function that allocates token to accounts following a custom logic should go in
* pair with a call to {_increaseBalance} so that balances and ownerships remain consistent with one another.
*/
function _ownerOf(uint256 tokenId) internal view virtual returns (address) {
return _owners[tokenId];
Expand Down Expand Up @@ -432,11 +435,14 @@ abstract contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Er
/**
* @dev Unsafe write access to the balances, used by extensions that "mint" tokens using an {ownerOf} override.
*
* WARNING: Anyone calling this MUST ensure that the balances remain consistent with the ownership. The invariant
* being that for any address `a` the value returned by `balanceOf(a)` must be equal to the number of tokens such
* that `ownerOf(tokenId)` is `a`.
* NOTE: the value is limited to type(uint128).max. This protect against _balance overflow. It is unrealistic that
* a uint256 would ever overflow from increments when these increments are bounded to uint128 values.
*
* WARNING: Increassing an account's balance using this function should go in pair with an override of the
* {_ownerOf} function that resolve the ownership of the corresponding tokens so that balances and ownerships
* remain consistent with one another.
*/
function _increaseBalance(address account, uint256 value) internal virtual {
function _increaseBalance(address account, uint128 value) internal virtual {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be moved next to _update IMO.

_balances[account] += value;
}
}
2 changes: 1 addition & 1 deletion contracts/token/ERC721/extensions/ERC721Enumerable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
/**
* See {ERC721-_increaseBalance}. We need that to account tokens that were minted in batch
*/
function _increaseBalance(address account, uint256 amount) internal virtual override {
function _increaseBalance(address account, uint128 amount) internal virtual override {
if (amount > 0) {
revert ERC721EnumerableForbiddenBatchMint();
}
Expand Down
3 changes: 1 addition & 2 deletions contracts/token/ERC721/extensions/ERC721Votes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ abstract contract ERC721Votes is ERC721, Votes {
/**
* See {ERC721-_increaseBalance}. We need that to account tokens that were minted in batch
*/
// solhint-disable-next-line func-name-mixedcase
function _increaseBalance(address account, uint256 amount) internal virtual override {
function _increaseBalance(address account, uint128 amount) internal virtual override {
super._increaseBalance(account, amount);
_transferVotingUnits(address(0), account, amount);
}
Expand Down