Skip to content

Commit 65aa6f6

Browse files
authored
feat(owned-multicaller): implement add-token-callback-handler (#275)
2 parents 2d27f5c + 9236eb3 commit 65aa6f6

File tree

1 file changed

+46
-2
lines changed

1 file changed

+46
-2
lines changed

src/utils/OwnedMulticaller.sol

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,28 @@
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_) {
1214
require(owner_ != address(0), "OwnedMulticaller: owner_ is null");
15+
1316
_transferOwnership(owner_);
1417
}
1518

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+
*/
1627
function multicall(address[] calldata tos, bytes[] calldata callDatas, uint256[] calldata values)
1728
external
1829
payable
@@ -29,4 +40,37 @@ contract OwnedMulticaller is Ownable {
2940
results[i].handleRevert(returnDatas[i]);
3041
}
3142
}
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+
}
3276
}

0 commit comments

Comments
 (0)