-
Notifications
You must be signed in to change notification settings - Fork 5
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
ERC1155 Compatibility #1238
base: main
Are you sure you want to change the base?
ERC1155 Compatibility #1238
Conversation
Pull Request Test Coverage Report for Build 13083371547Details
💛 - Coveralls |
Hyperdrive Gas Benchmark
This comment was automatically generated by workflow using github-action-benchmark. |
address _to, | ||
uint256[] calldata _ids, | ||
uint256[] calldata _amounts, | ||
bytes memory _data |
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.
Why the 2 lines above can be calldata but this line is using memory?
I saw OZ is doing all 3 lines calldata here: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/828dbc357cd7975c0a31d919f6d4dcf7ef2dc427/contracts/token/ERC1155/IERC1155.sol#L121
revert IHyperdrive.BatchInputLengthMismatch(); | ||
} | ||
|
||
// Call internal transfer for each asset. | ||
for (uint256 i = 0; i < ids.length; i++) { | ||
_transferFrom(ids[i], from, to, values[i], msg.sender); | ||
for (uint256 i = 0; i < _ids.length; i++) { |
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.
nit: it should be a gas saver to read the _ids.length
once and save it to a local uint length
(on the stack, minimal gas) than repeatedly reading the _ids.length
thru the loop (3 gas each time)?
bytes calldata | ||
) external view returns (bytes4) { | ||
// If the sender is the right Hyperdrive contract, we accept the transfer. | ||
if (msg.sender == hyperdrive) { |
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 at this time, the hyperdrive
is still the dummy address 0x1 instead of the real address?
) external view returns (bytes4) { | ||
// If the sender is the right Hyperdrive contract, we accept the batch | ||
// transfer. | ||
if (msg.sender == hyperdrive) { |
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.
Also here, 0x1 or the real address?
|
||
// Load the balances. | ||
uint256[] memory batchBalances = new uint256[](_accounts.length); | ||
for (uint256 i = 0; i < _accounts.length; ++i) { |
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.
nit: same here for the gas related comment -- https://github.com/delvtech/hyperdrive/pull/1238/files#r1938433041
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.
Approved once the comments are resolved, especially the question of hyperdrive
address being dummy or real.
Description
This PR makes Hyperdrive fully ERC1155 compatible. To do this, we added
safeTransferFrom
,safeBatchTransferFrom
, andbalanceOfBatch
. To ensure that our contracts remain code size limit, we also had to removetransferFrom
andbatchTransferFrom
.