-
Notifications
You must be signed in to change notification settings - Fork 510
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
Changes from 10 commits
bd1afc1
d2e9425
5d22b1d
0f675cb
e005016
5cdaba4
3a54c91
c90e0e9
4ccc9b7
25f2e3a
3a254d0
c9e8c06
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
416622 | ||
416667 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,13 +27,49 @@ abstract contract ERC721Permit_v4 is ERC721, IERC721Permit_v4, EIP712_v4, Unorde | |
address owner = ownerOf(tokenId); | ||
if (spender == owner) revert NoSelfPermit(); | ||
|
||
bytes32 hash = ERC721PermitHashLibrary.hash(spender, tokenId, nonce, deadline); | ||
bytes32 hash = ERC721PermitHashLibrary.hashPermit(spender, tokenId, nonce, deadline); | ||
signature.verify(_hashTypedData(hash), owner); | ||
|
||
_useUnorderedNonce(owner, nonce); | ||
_approve(owner, spender, tokenId); | ||
} | ||
|
||
/// @inheritdoc IERC721Permit_v4 | ||
function permitForAll( | ||
address owner, | ||
address operator, | ||
bool approved, | ||
uint256 deadline, | ||
uint256 nonce, | ||
bytes calldata signature | ||
) 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 commentThe 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 |
||
|
||
bytes32 hash = ERC721PermitHashLibrary.hashPermitForAll(operator, approved, nonce, deadline); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the variable name There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do u wanna use digest here too? |
||
signature.verify(_hashTypedData(hash), owner); | ||
|
||
_useUnorderedNonce(owner, nonce); | ||
_approveForAll(owner, operator, approved); | ||
} | ||
|
||
/// @notice Enable or disable approval for a third party ("operator") to manage | ||
/// all of `msg.sender`'s assets | ||
/// @dev Emits the ApprovalForAll event. The contract MUST allow | ||
/// multiple operators per owner. | ||
/// @dev Override Solmate's ERC721 setApprovalForAll so setApprovalForAll() and permit() share the _approveForAll method | ||
/// @param operator Address to add to the set of authorized operators | ||
/// @param approved True if the operator is approved, false to revoke approval | ||
function setApprovalForAll(address operator, bool approved) public override { | ||
_approveForAll(msg.sender, operator, approved); | ||
} | ||
|
||
function _approveForAll(address owner, address operator, bool approved) internal { | ||
isApprovedForAll[owner][operator] = approved; | ||
emit ApprovalForAll(owner, operator, approved); | ||
} | ||
|
||
/// @notice Change or reaffirm the approved address for an NFT | ||
/// @dev override Solmate's ERC721 approve so approve() and permit() share the _approve method | ||
/// The zero address indicates there is no approved address | ||
|
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