-
Notifications
You must be signed in to change notification settings - Fork 504
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ERC721Permit - PermitForAll #271
Conversation
src/base/ERC721Permit_v4.sol
Outdated
uint256 nonce, | ||
bytes calldata signature | ||
) external payable { | ||
if (block.timestamp > deadline) revert DeadlineExpired(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shared modifier? We should also make the revert name more distinct since we have DeadlinePassed
in modifyLiquidities
src/base/ERC721Permit_v4.sol
Outdated
) external payable { | ||
if (block.timestamp > deadline) revert DeadlineExpired(); | ||
|
||
if (operator == owner) revert NoSelfPermit(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also same? can put this in a shared internal func? same check in permit
src/base/ERC721Permit_v4.sol
Outdated
|
||
if (operator == owner) revert NoSelfPermit(); | ||
|
||
bytes32 hash = ERC721PermitHashLibrary.hashPermitForAll(operator, approved, nonce, deadline); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the variable name hash
highlights as a keyword for me 🤔
assertEq(erc721Permit.nonces(alice, wordPos) & (1 << bitPos), 2); // 2 = 0010 | ||
} | ||
|
||
function test_fuzz_erc721permitForAll_nonceAlreadyUsed() public { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be fuzzed on the nonce value?
vm.stopPrank(); | ||
} | ||
|
||
function test_fuzz_erc721permitForAll_unauthorized() public { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also use fuzz?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also i think this should be _invalidSigner ?
|
||
uint256 nonce = 1; | ||
uint256 deadline = block.timestamp; | ||
bytes32 digest = keccak256( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_getPermitDigest ?
|
||
uint256 nonce = 1; | ||
uint256 deadline = block.timestamp; | ||
bytes32 digest = keccak256( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_getPermitDigest ?
} | ||
|
||
/// @dev a nonce used in permit is unusable for permitForAll | ||
function test_erc721PermitForAll_permitNonceUsed() public { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could probably fuzz this on the nonce value as well ?
src/base/ERC721Permit_v4.sol
Outdated
|
||
if (operator == owner) revert NoSelfPermit(); | ||
) external payable checkSignatureDeadline(deadline) { | ||
_checkNoSelfPermit(owner, operator); | ||
|
||
bytes32 hash = ERC721PermitHashLibrary.hashPermitForAll(operator, approved, nonce, deadline); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do u wanna use digest here too?
Related Issue
Closes #227
Description of changes
Added signature-based
permitForAll
for setting operators (the equivalent to setApprovalForAll)Tested the base contract, and will add another PR for testing with posm operations to try and keep the PR more manageable