-
Notifications
You must be signed in to change notification settings - Fork 7
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
rc-v1.0.1-stable proposed bytecode optimization to merge into stable branch #91
Changes from 4 commits
e0068f3
18d1a93
860d147
aaa8a77
6aa0d26
1df59ba
3f4c818
cd41718
f90e509
3033b22
a7136aa
c141b46
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 |
---|---|---|
|
@@ -114,10 +114,7 @@ abstract contract ERC1155 is DiscountedBalances, Context, ERC165, IERC1155, IERC | |
* @dev See {IERC1155-safeTransferFrom}. | ||
*/ | ||
function safeTransferFrom(address _from, address _to, uint256 _id, uint256 _value, bytes memory _data) public { | ||
address sender = _msgSender(); | ||
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. as mentioned before, I tried to not update this forked contract from open zepellin unless where functionally needed. that said, sure this seems like a fair readability improvement. It would be good to have measurements in place in CI so we can see whether this increases or reduces different metrics. I don't want to walk blind for optimisations |
||
if (_from != sender && !isApprovedForAll(_from, sender)) { | ||
revert ERC1155MissingApprovalForAll(sender, _from); | ||
} | ||
_allowanceCheck(_from); | ||
_safeTransferFrom(_from, _to, _id, _value, _data); | ||
} | ||
|
||
|
@@ -131,10 +128,7 @@ abstract contract ERC1155 is DiscountedBalances, Context, ERC165, IERC1155, IERC | |
uint256[] memory _values, | ||
bytes memory _data | ||
) public virtual { | ||
address sender = _msgSender(); | ||
if (_from != sender && !isApprovedForAll(_from, sender)) { | ||
revert ERC1155MissingApprovalForAll(sender, _from); | ||
} | ||
_allowanceCheck(_from); | ||
_safeBatchTransferFrom(_from, _to, _ids, _values, _data); | ||
} | ||
|
||
|
@@ -216,6 +210,16 @@ abstract contract ERC1155 is DiscountedBalances, Context, ERC165, IERC1155, IERC | |
_acceptanceCheck(from, to, ids, values, data); | ||
} | ||
|
||
/** | ||
* @dev do the ERC1155 token the sender allowance check | ||
*/ | ||
function _allowanceCheck(address _from) internal view { | ||
address sender = _msgSender(); | ||
if (_from != sender && !isApprovedForAll(_from, sender)) { | ||
revert ERC1155MissingApprovalForAll(sender, _from); | ||
} | ||
} | ||
|
||
/** | ||
* @dev do the ERC1155 token acceptance check to the receiver | ||
*/ | ||
|
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.
this is possibly an improvement, but as mentioned some of these changes were done on recommendation of reviewers. so my general comment holds, i would like to start measuring explicitly to see what is an optimisation in numbers