Skip to content
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

feat(owned-multicaller): implement remove-kill-fn #273

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading