Skip to content

Commit 520215f

Browse files
authored
fix(OwnedMulticaller): remove multiMint, kill fn (#274)
2 parents e79ef6a + 65aa6f6 commit 520215f

File tree

2 files changed

+53
-36
lines changed

2 files changed

+53
-36
lines changed

script/20231106-config-prelaunch/20231106_SubmitReservedNames.s.sol

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,9 @@ contract Migration__20231106_SubmitReservedNames is Migration {
2828
address[] memory tos;
2929
string[] memory labels;
3030
(tos, labels) = _parseData("./script/20231106-param-prelaunch/data/finalReservedNames.json");
31-
mintBatch(multicall, duration, rns, resolver, tos, labels);
31+
// mintBatch(multicall, duration, rns, resolver, tos, labels);
3232
}
3333

34-
function mintBatch(
35-
OwnedMulticaller multicall,
36-
uint64 duration,
37-
RNSUnified rns,
38-
address resolver,
39-
address[] memory tos,
40-
string[] memory labels
41-
) public {
42-
vm.broadcast(config.getSender());
43-
multicall.multiMint(rns, LibRNSDomain.RON_ID, resolver, duration, tos, labels);
44-
}
4534

4635
function _parseData(string memory path) internal view returns (address[] memory tos, string[] memory labels) {
4736
string memory raw = vm.readFile(path);

src/utils/OwnedMulticaller.sol

Lines changed: 52 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,75 @@
22
pragma solidity ^0.8.19;
33

44
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
5-
import { INSUnified } from "../interfaces/INSUnified.sol";
65
import { ErrorHandler } from "../libraries/ErrorHandler.sol";
6+
import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
7+
import { IERC721Receiver } from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
8+
import { IERC1155Receiver } from "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol";
79

8-
contract OwnedMulticaller is Ownable {
10+
contract OwnedMulticaller is Ownable, IERC721Receiver, IERC1155Receiver {
911
using ErrorHandler for bool;
1012

1113
constructor(address owner_) {
12-
require(owner_ != address(0), "owner_ == address(0x0)");
13-
_transferOwnership(owner_);
14-
}
15-
16-
function kill() external onlyOwner {
17-
selfdestruct(payable(_msgSender()));
18-
}
14+
require(owner_ != address(0), "OwnedMulticaller: owner_ is null");
1915

20-
function multiMint(
21-
INSUnified rns,
22-
uint256 parentId,
23-
address resolver,
24-
uint64 duration,
25-
address[] calldata tos,
26-
string[] calldata labels
27-
) external onlyOwner {
28-
for (uint256 i; i < labels.length; ++i) {
29-
rns.mint(parentId, labels[i], resolver, tos[i], duration);
30-
}
16+
_transferOwnership(owner_);
3117
}
3218

19+
/**
20+
* @dev Execute multiple calls in a single transaction.
21+
* @param tos The addresses to call.
22+
* @param callDatas The call data for each call.
23+
* @param values The value to send for each call.
24+
* @return results The results of each call.
25+
* @return returnDatas The return data of each call.
26+
*/
3327
function multicall(address[] calldata tos, bytes[] calldata callDatas, uint256[] calldata values)
3428
external
3529
payable
3630
onlyOwner
3731
returns (bool[] memory results, bytes[] memory returnDatas)
3832
{
39-
require(tos.length == callDatas.length && tos.length == values.length, "invalid length");
40-
results = new bool[](tos.length);
41-
returnDatas = new bytes[](tos.length);
33+
uint256 length = tos.length;
34+
require(length == callDatas.length && length == values.length, "OwnedMulticaller: mismatch length");
35+
results = new bool[](length);
36+
returnDatas = new bytes[](length);
4237

43-
for (uint256 i; i < tos.length; ++i) {
38+
for (uint256 i; i < length; ++i) {
4439
(results[i], returnDatas[i]) = tos[i].call{ value: values[i] }(callDatas[i]);
4540
results[i].handleRevert(returnDatas[i]);
4641
}
4742
}
43+
44+
/**
45+
* @dev See {IERC165-supportsInterface}.
46+
*/
47+
function supportsInterface(bytes4 interfaceId) external view returns (bool) {
48+
return interfaceId == type(IERC165).interfaceId || interfaceId == type(IERC721Receiver).interfaceId
49+
|| interfaceId == type(IERC1155Receiver).interfaceId;
50+
}
51+
52+
/**
53+
* @dev See {IERC721Receiver-onERC721Received}.
54+
*/
55+
function onERC721Received(address, address, uint256, bytes calldata) external pure returns (bytes4) {
56+
return msg.sig;
57+
}
58+
59+
/**
60+
* @dev See {IERC1155Receiver-onERC1155Received}.
61+
*/
62+
function onERC1155BatchReceived(address, address, uint256[] calldata, uint256[] calldata, bytes calldata)
63+
external
64+
pure
65+
returns (bytes4)
66+
{
67+
return msg.sig;
68+
}
69+
70+
/**
71+
* @dev See {IERC1155Receiver-onERC1155Received}.
72+
*/
73+
function onERC1155Received(address, address, uint256, uint256, bytes calldata) external pure returns (bytes4) {
74+
return msg.sig;
75+
}
4876
}

0 commit comments

Comments
 (0)