-
Notifications
You must be signed in to change notification settings - Fork 41
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
[REG-1440] [WIP] feat: updating ENSCustody contract to support wallet migration #369
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ import {IENSCustody, Unauthorised, InvalidToken, UnknownToken, CustodyNotEnoughB | |
import {InvalidForwardedToken, ERC2771RegistryContext} from '../metatx/ERC2771RegistryContext.sol'; | ||
import {Forwarder} from '../metatx/Forwarder.sol'; | ||
import {MinterRole} from '../roles/MinterRole.sol'; | ||
import {Multicall} from '../utils/Multicall.sol'; | ||
|
||
contract ENSCustody is | ||
Initializable, | ||
|
@@ -27,7 +28,8 @@ contract ENSCustody is | |
ERC2771RegistryContext, | ||
Forwarder, | ||
MinterRole, | ||
IENSCustody | ||
IENSCustody, | ||
Multicall | ||
{ | ||
string public constant NAME = 'ENS Custody'; | ||
string public constant VERSION = '0.1.3'; | ||
|
@@ -215,15 +217,33 @@ contract ENSCustody is | |
} | ||
|
||
function safeTransfer(address to, uint256 tokenId) external onlyTokenOwner(tokenId) { | ||
this.safeTransfer(to, tokenId, false); | ||
} | ||
|
||
function safeTransfer(address to, uint256 tokenId, bool internalTransfer) external onlyTokenOwner(tokenId) { | ||
_protectTokenOperation(tokenId); | ||
StorageSlotUpgradeable.getAddressSlot(keccak256(abi.encodePacked(_OWNER_PREFIX_SLOT, tokenId))).value = address(0); | ||
if (internalTransfer) { | ||
_park(tokenId, to); | ||
} else { | ||
StorageSlotUpgradeable.getAddressSlot(keccak256(abi.encodePacked(_OWNER_PREFIX_SLOT, tokenId))).value = address(0); | ||
|
||
INameWrapper _wrapper = INameWrapper(StorageSlotUpgradeable.getAddressSlot(_ENS_WRAPPER_SLOT).value); | ||
_wrapper.safeTransferFrom(address(this), to, tokenId, 1, ''); | ||
INameWrapper _wrapper = INameWrapper(StorageSlotUpgradeable.getAddressSlot(_ENS_WRAPPER_SLOT).value); | ||
_wrapper.safeTransferFrom(address(this), to, tokenId, 1, ''); | ||
} | ||
} | ||
|
||
receive() external payable {} | ||
|
||
function multicall(bytes[] calldata data) public returns (bytes[] memory results) { | ||
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. we discussed with Nick and Kiryl that it is better not to include generic multicall here but to add just butchTransfer 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. Do you mean something like this?
Why can't we reuse existing meta tx functionality to handle validations for each transfer? 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. that's what I ment, to reuse existing meta functionality but for a narrow field of bulk transfer and not for generic multicall. |
||
bytes[] memory _data = data; | ||
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. you can just mark data as |
||
if (isTrustedForwarder(msg.sender)) { | ||
for (uint256 i = 0; i < data.length; i++) { | ||
_data[i] = _buildData(_msgSender(), _msgToken(), data[i], ''); | ||
} | ||
} | ||
return _multicall(_data); | ||
} | ||
|
||
function _register( | ||
string calldata name, | ||
address owner, | ||
|
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
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.
While calling
this.safeTransfer(to, tokenId, false);
msg.sender will be contract address in the second function, which I suppose will most likely fail on
onlyTokenOwner
check.Using call through
this.
in smart contracts is a highly unrecommended practice. Better to make lower function public and calling it like internal one