Skip to content

Commit

Permalink
feat(owned-multicaller): implement remove-kill-fn (#273)
Browse files Browse the repository at this point in the history
  • Loading branch information
TuDo1403 authored Jul 11, 2024
2 parents e79ef6a + 965d395 commit 00c971a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 34 deletions.
24 changes: 12 additions & 12 deletions script/20231106-config-prelaunch/20231106_SubmitReservedNames.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
28 changes: 6 additions & 22 deletions src/utils/OwnedMulticaller.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,22 @@ 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 kill() external onlyOwner {
selfdestruct(payable(_msgSender()));
}

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
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]);
}
Expand Down

0 comments on commit 00c971a

Please sign in to comment.