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

docs: use unordered nonce #218

Closed
Closed
Changes from all commits
Commits
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
5 changes: 3 additions & 2 deletions src/SignatureTransfer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,13 @@ contract SignatureTransfer is ISignatureTransfer, EIP712 {
bitPos = uint8(nonce);
}

/// @notice Checks whether a nonce is taken and sets the bit at the bit position in the bitmap at the word position
/// @param from The address to use the nonce at
/// @notice Flips the bit at the bit position in the bitmap at the word position, and checks whether the nonce is taken.
/// @param from The owner whose nonce to spend
/// @param nonce The nonce to spend
function _useUnorderedNonce(address from, uint256 nonce) internal {
(uint256 wordPos, uint256 bitPos) = bitmapPositions(nonce);
uint256 bit = 1 << bitPos;
// The mapping assignment on the right is performed first, and the resulting value is assigned to `flipped`.
uint256 flipped = nonceBitmap[from][wordPos] ^= bit;

if (flipped & bit == 0) revert InvalidNonce();
Expand Down