Skip to content

Commit

Permalink
feat(OwnedMulticaller): add token callback handler
Browse files Browse the repository at this point in the history
  • Loading branch information
TuDo1403 committed Jul 12, 2024
1 parent 2d27f5c commit 9236eb3
Showing 1 changed file with 46 additions and 2 deletions.
48 changes: 46 additions & 2 deletions src/utils/OwnedMulticaller.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}
}

0 comments on commit 9236eb3

Please sign in to comment.