From 467f438b41864063ac1ac0e9896788eb1784bf8a Mon Sep 17 00:00:00 2001 From: TuDo1403 Date: Thu, 11 Jul 2024 14:39:35 +0700 Subject: [PATCH 1/5] fix(OwnedMulticaller): remove kill function --- src/utils/OwnedMulticaller.sol | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/utils/OwnedMulticaller.sol b/src/utils/OwnedMulticaller.sol index ef0d3dac..da3d1498 100644 --- a/src/utils/OwnedMulticaller.sol +++ b/src/utils/OwnedMulticaller.sol @@ -13,10 +13,6 @@ contract OwnedMulticaller is Ownable { _transferOwnership(owner_); } - function kill() external onlyOwner { - selfdestruct(payable(_msgSender())); - } - function multiMint( INSUnified rns, uint256 parentId, @@ -36,11 +32,12 @@ contract OwnedMulticaller is Ownable { 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, "invalid 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]); } From 9d8ad8333a604da0d175f86ae02037d6868d2b89 Mon Sep 17 00:00:00 2001 From: TuDo1403 Date: Thu, 11 Jul 2024 14:52:59 +0700 Subject: [PATCH 2/5] fix(OwnedMulticaller): remove multi mint fn --- src/utils/OwnedMulticaller.sol | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/src/utils/OwnedMulticaller.sol b/src/utils/OwnedMulticaller.sol index da3d1498..87ff684d 100644 --- a/src/utils/OwnedMulticaller.sol +++ b/src/utils/OwnedMulticaller.sol @@ -9,23 +9,10 @@ contract OwnedMulticaller is Ownable { using ErrorHandler for bool; constructor(address owner_) { - require(owner_ != address(0), "owner_ == address(0x0)"); + require(owner_ != address(0), "OwnedMulticaller: owner_ is null"); _transferOwnership(owner_); } - 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); - } - } - function multicall(address[] calldata tos, bytes[] calldata callDatas, uint256[] calldata values) external payable @@ -33,7 +20,7 @@ contract OwnedMulticaller is Ownable { returns (bool[] memory results, bytes[] memory returnDatas) { uint256 length = tos.length; - require(length == callDatas.length && length == values.length, "invalid length"); + require(length == callDatas.length && length == values.length, "OwnedMulticaller: mismatch length"); results = new bool[](length); returnDatas = new bytes[](length); From 965d3957386021b6020be64d5387453a1bb7de3d Mon Sep 17 00:00:00 2001 From: TuDo1403 Date: Thu, 11 Jul 2024 16:33:04 +0700 Subject: [PATCH 3/5] script: comment removed interface of owned multicaller --- .../20231106_SubmitReservedNames.s.sol | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/script/20231106-config-prelaunch/20231106_SubmitReservedNames.s.sol b/script/20231106-config-prelaunch/20231106_SubmitReservedNames.s.sol index f62557b0..d2cb63e3 100644 --- a/script/20231106-config-prelaunch/20231106_SubmitReservedNames.s.sol +++ b/script/20231106-config-prelaunch/20231106_SubmitReservedNames.s.sol @@ -28,20 +28,20 @@ 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 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); From 2d27f5c6a62280378826c8204781b450a85aba2c Mon Sep 17 00:00:00 2001 From: "tu-do.ron" Date: Fri, 12 Jul 2024 17:29:25 +0700 Subject: [PATCH 4/5] Update script/20231106-config-prelaunch/20231106_SubmitReservedNames.s.sol --- .../20231106_SubmitReservedNames.s.sol | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/script/20231106-config-prelaunch/20231106_SubmitReservedNames.s.sol b/script/20231106-config-prelaunch/20231106_SubmitReservedNames.s.sol index d2cb63e3..e5276170 100644 --- a/script/20231106-config-prelaunch/20231106_SubmitReservedNames.s.sol +++ b/script/20231106-config-prelaunch/20231106_SubmitReservedNames.s.sol @@ -31,17 +31,6 @@ contract Migration__20231106_SubmitReservedNames is Migration { // 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); From 9236eb36ad55792620650113a3821c28499d5aca Mon Sep 17 00:00:00 2001 From: TuDo1403 Date: Fri, 12 Jul 2024 17:50:56 +0700 Subject: [PATCH 5/5] feat(OwnedMulticaller): add token callback handler --- src/utils/OwnedMulticaller.sol | 48 ++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/src/utils/OwnedMulticaller.sol b/src/utils/OwnedMulticaller.sol index 87ff684d..7925f685 100644 --- a/src/utils/OwnedMulticaller.sol +++ b/src/utils/OwnedMulticaller.sol @@ -2,17 +2,28 @@ 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), "OwnedMulticaller: owner_ is null"); + _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 @@ -29,4 +40,37 @@ contract OwnedMulticaller is Ownable { 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; + } }