Skip to content
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

Merged
merged 12 commits into from
Aug 5, 2024
Merged

ERC721Permit - PermitForAll #271

merged 12 commits into from
Aug 5, 2024

Conversation

saucepoint
Copy link
Collaborator

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

@saucepoint saucepoint added the posm position manager label Aug 5, 2024
@saucepoint saucepoint requested a review from snreynolds August 5, 2024 00:46
uint256 nonce,
bytes calldata signature
) external payable {
if (block.timestamp > deadline) revert DeadlineExpired();
Copy link
Member

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

) external payable {
if (block.timestamp > deadline) revert DeadlineExpired();

if (operator == owner) revert NoSelfPermit();
Copy link
Member

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


if (operator == owner) revert NoSelfPermit();

bytes32 hash = ERC721PermitHashLibrary.hashPermitForAll(operator, approved, nonce, deadline);
Copy link
Member

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 {
Copy link
Member

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 {
Copy link
Member

Choose a reason for hiding this comment

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

also use fuzz?

Copy link
Member

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(
Copy link
Member

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(
Copy link
Member

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 {
Copy link
Member

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 ?


if (operator == owner) revert NoSelfPermit();
) external payable checkSignatureDeadline(deadline) {
_checkNoSelfPermit(owner, operator);

bytes32 hash = ERC721PermitHashLibrary.hashPermitForAll(operator, approved, nonce, deadline);
Copy link
Member

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?

@saucepoint saucepoint merged commit d1f9005 into main Aug 5, 2024
3 checks passed
@saucepoint saucepoint deleted the posm-erc721permit-forall branch August 5, 2024 03:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
posm position manager
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ERC721Permit: PermitForAll
2 participants