Skip to content

Conversation

@snreynolds
Copy link
Member

No description provided.

revert AllowanceExpired(allowed.expiration, operator.expiration);
}

uint256 maxAmount = allowed.amount;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Whats the reason for having this as a 256 for a while and then casting it back to a 160 later?

Copy link
Collaborator

@marktoda marktoda left a comment

Choose a reason for hiding this comment

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

couple thoughts!

if (operatorExpired) revert InsufficientAllowance(maxAmount);
} else {
unchecked {
allowed.amount = uint160(maxAmount) - amount;
Copy link
Collaborator

Choose a reason for hiding this comment

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

wait isn't this backwards? like, if approval is MAX then we shouldn't update, but if it's not MAX then we should update?

}

uint256 maxAmount = allowed.amount;
if (maxAmount != type(uint160).max) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

could save a level of nesting here i think by switching the ordering around:

if (maxAmount == type(uint160).max) {
   ... max stuff
} else if (amount > maxAmount) {
   revert
}

}

/// @inheritdoc IAllowanceTransferERC1155
function invalidateNonces(address token, address spender, uint48 newNonce) external {
Copy link
Collaborator

Choose a reason for hiding this comment

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

not sure but maybe invalidateOperatorNonces better for clarity?

/// @notice EIP712 helpers for Permit2 ERC1155s
/// @dev Maintains cross-chain replay protection in the event of a fork
/// @dev Reference: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/EIP712.sol
contract EIP712ForERC1155 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

isnt this contract the same for all types minus the _HASHED_NAME? wonder if we could have it be shared and take the name as constructor arg

/// @return bitPos The bit position
/// @dev The first 248 bits of the nonce value is the index of the desired bitmap
/// @dev The last 8 bits of the nonce value is the position of the bit in the bitmap
function bitmapPositions(uint256 nonce) private pure returns (uint256 wordPos, uint256 bitPos) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

could these be in like an UnorderedNonceLibrary since theyre shared across all 3 instances?

"PermitBatch(PermitDetails[] details,address spender,uint256 sigDeadline)PermitDetails(address token,uint160 amount,uint48 expiration,uint48 nonce)"
);

bytes32 public constant _TOKEN_PERMISSIONS_TYPEHASH = keccak256("TokenPermissions(address token,uint256 amount)");
Copy link
Collaborator

Choose a reason for hiding this comment

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

doesnt this need tokenId?

Copy link
Collaborator

Choose a reason for hiding this comment

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

also could just be keccak256(TOKEN_PERMISSIONS_TYPESTRING)

"PermitTransferFrom(TokenPermissions permitted,address spender,uint256 nonce,uint256 deadline)TokenPermissions(address token,uint256 amount)"
);

bytes32 public constant _PERMIT_BATCH_TRANSFER_FROM_TYPEHASH = keccak256(
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: maybe string.concat("PermitBatch....", _TOKEN_PERMISSIONS_TYPEHASH) to help avoid typos?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants