-
-
Notifications
You must be signed in to change notification settings - Fork 82
Adds ERC1155TransferEnforcer #124
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
base: main
Are you sure you want to change the base?
Conversation
| event IncreasedSpentMap(address indexed sender, bytes32 indexed delegationHash, uint256 tokenId, uint256 limit, uint256 spent); | ||
|
|
||
| /** | ||
| * @notice Enforces that the contract and tokenIds are permitted for transfer |
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.
contract, tokenIds and amounts
| /** | ||
| * @notice Enforces that the contract and tokenIds are permitted for transfer | ||
| * @dev Validates that the transfer execution matches the permitted terms and updates spent amounts | ||
| * @param _terms encoded terms containing transfer type, contract address, token IDs and amounts |
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.
terms don't include transfer type anymore since its extracted via bytes length
| /** | ||
| * @notice Decodes the terms to get the transfer type, permitted contract and token IDs | ||
| * @dev Validates the terms length and structure | ||
| * @param _terms The encoded terms containing transfer type, contract address and token IDs |
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.
no transfer type here as well
| if (callData_.length != 196 && callData_.length < 324) revert("ERC1155TransferEnforcer:invalid-calldata-length"); | ||
| if (target_ != permittedContract_) revert("ERC1155TransferEnforcer:unauthorized-contract-target"); | ||
|
|
||
| bytes4 selector_ = bytes4(callData_[0:4]); |
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.
I think writting this this way:
if (isBatch_) {
if (selector_ != IERC1155.safeBatchTransferFrom.selector) {
revert("ERC1155TransferEnforcer:unauthorized-selector-batch");
}
_validateBatchTransfer(_delegationHash, callData_, permittedTokenIds_, permittedAmounts_);
} else {
if (selector_ != IERC1155.safeTransferFrom.selector) {
revert("ERC1155TransferEnforcer:unauthorized-selector-single");
}
_validateSingleTransfer(_delegationHash, callData_, permittedTokenIds_[0], permittedAmounts_[0]);
}
Should be slightly better gas wise.
What?
Why?
How?