diff --git a/script/20231106-config-prelaunch/20231106_SubmitReservedNames.s.sol b/script/20231106-config-prelaunch/20231106_SubmitReservedNames.s.sol index f62557b0..e5276170 100644 --- a/script/20231106-config-prelaunch/20231106_SubmitReservedNames.s.sol +++ b/script/20231106-config-prelaunch/20231106_SubmitReservedNames.s.sol @@ -28,20 +28,9 @@ contract Migration__20231106_SubmitReservedNames is Migration { address[] memory tos; string[] memory labels; (tos, labels) = _parseData("./script/20231106-param-prelaunch/data/finalReservedNames.json"); - mintBatch(multicall, duration, rns, resolver, tos, labels); + // mintBatch(multicall, duration, rns, resolver, tos, labels); } - function mintBatch( - OwnedMulticaller multicall, - uint64 duration, - RNSUnified rns, - address resolver, - address[] memory tos, - string[] memory labels - ) public { - vm.broadcast(config.getSender()); - multicall.multiMint(rns, LibRNSDomain.RON_ID, resolver, duration, tos, labels); - } function _parseData(string memory path) internal view returns (address[] memory tos, string[] memory labels) { string memory raw = vm.readFile(path); diff --git a/src/utils/OwnedMulticaller.sol b/src/utils/OwnedMulticaller.sol index ef0d3dac..7925f685 100644 --- a/src/utils/OwnedMulticaller.sol +++ b/src/utils/OwnedMulticaller.sol @@ -2,47 +2,75 @@ pragma solidity ^0.8.19; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; -import { INSUnified } from "../interfaces/INSUnified.sol"; import { ErrorHandler } from "../libraries/ErrorHandler.sol"; +import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; +import { IERC721Receiver } from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol"; +import { IERC1155Receiver } from "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol"; -contract OwnedMulticaller is Ownable { +contract OwnedMulticaller is Ownable, IERC721Receiver, IERC1155Receiver { using ErrorHandler for bool; constructor(address owner_) { - require(owner_ != address(0), "owner_ == address(0x0)"); - _transferOwnership(owner_); - } - - function kill() external onlyOwner { - selfdestruct(payable(_msgSender())); - } + require(owner_ != address(0), "OwnedMulticaller: owner_ is null"); - function multiMint( - INSUnified rns, - uint256 parentId, - address resolver, - uint64 duration, - address[] calldata tos, - string[] calldata labels - ) external onlyOwner { - for (uint256 i; i < labels.length; ++i) { - rns.mint(parentId, labels[i], resolver, tos[i], duration); - } + _transferOwnership(owner_); } + /** + * @dev Execute multiple calls in a single transaction. + * @param tos The addresses to call. + * @param callDatas The call data for each call. + * @param values The value to send for each call. + * @return results The results of each call. + * @return returnDatas The return data of each call. + */ function multicall(address[] calldata tos, bytes[] calldata callDatas, uint256[] calldata values) external payable onlyOwner returns (bool[] memory results, bytes[] memory returnDatas) { - require(tos.length == callDatas.length && tos.length == values.length, "invalid length"); - results = new bool[](tos.length); - returnDatas = new bytes[](tos.length); + uint256 length = tos.length; + require(length == callDatas.length && length == values.length, "OwnedMulticaller: mismatch length"); + results = new bool[](length); + returnDatas = new bytes[](length); - for (uint256 i; i < tos.length; ++i) { + for (uint256 i; i < length; ++i) { (results[i], returnDatas[i]) = tos[i].call{ value: values[i] }(callDatas[i]); results[i].handleRevert(returnDatas[i]); } } + + /** + * @dev See {IERC165-supportsInterface}. + */ + function supportsInterface(bytes4 interfaceId) external view returns (bool) { + return interfaceId == type(IERC165).interfaceId || interfaceId == type(IERC721Receiver).interfaceId + || interfaceId == type(IERC1155Receiver).interfaceId; + } + + /** + * @dev See {IERC721Receiver-onERC721Received}. + */ + function onERC721Received(address, address, uint256, bytes calldata) external pure returns (bytes4) { + return msg.sig; + } + + /** + * @dev See {IERC1155Receiver-onERC1155Received}. + */ + function onERC1155BatchReceived(address, address, uint256[] calldata, uint256[] calldata, bytes calldata) + external + pure + returns (bytes4) + { + return msg.sig; + } + + /** + * @dev See {IERC1155Receiver-onERC1155Received}. + */ + function onERC1155Received(address, address, uint256, uint256, bytes calldata) external pure returns (bytes4) { + return msg.sig; + } }