Skip to content

Commit

Permalink
sb-i74 (#325)
Browse files Browse the repository at this point in the history
  • Loading branch information
dianakocsis authored Sep 2, 2024
1 parent b11680c commit 20863db
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .forge-snapshots/PositionManager_permit.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
79506
79595
Original file line number Diff line number Diff line change
@@ -1 +1 @@
62394
62483
2 changes: 1 addition & 1 deletion .forge-snapshots/PositionManager_permit_twice.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
45282
45371
5 changes: 5 additions & 0 deletions src/base/EIP712_v4.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ contract EIP712_v4 is IEIP712_v4 {
mstore(add(fmp, 0x02), domainSeparator)
mstore(add(fmp, 0x22), dataHash)
digest := keccak256(fmp, 0x42)

// now clean the memory we used
mstore(fmp, 0) // fmp held "\x19\x01", domainSeparator
mstore(add(fmp, 0x20), 0) // fmp+0x20 held domainSeparator, dataHash
mstore(add(fmp, 0x40), 0) // fmp+0x40 held dataHash
}
}
}
14 changes: 14 additions & 0 deletions src/libraries/ERC721PermitHash.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ library ERC721PermitHashLibrary {
mstore(add(fmp, 0x60), nonce)
mstore(add(fmp, 0x80), deadline)
digest := keccak256(fmp, 0xa0)

// now clean the memory we used
mstore(fmp, 0) // fmp held PERMIT_TYPEHASH
mstore(add(fmp, 0x20), 0) // fmp+0x20 held spender
mstore(add(fmp, 0x40), 0) // fmp+0x40 held tokenId
mstore(add(fmp, 0x60), 0) // fmp+0x60 held nonce
mstore(add(fmp, 0x80), 0) // fmp+0x80 held deadline
}
}

Expand All @@ -39,6 +46,13 @@ library ERC721PermitHashLibrary {
mstore(add(fmp, 0x60), nonce)
mstore(add(fmp, 0x80), deadline)
digest := keccak256(fmp, 0xa0)

// now clean the memory we used
mstore(fmp, 0) // fmp held PERMIT_FOR_ALL_TYPEHASH
mstore(add(fmp, 0x20), 0) // fmp+0x20 held operator
mstore(add(fmp, 0x40), 0) // fmp+0x40 held approved
mstore(add(fmp, 0x60), 0) // fmp+0x60 held nonce
mstore(add(fmp, 0x80), 0) // fmp+0x80 held deadline
}
}
}

0 comments on commit 20863db

Please sign in to comment.