-
Notifications
You must be signed in to change notification settings - Fork 0
/
Router.sol
49 lines (41 loc) · 1.93 KB
/
Router.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {MultiSendCallOnly} from "src/lib/MultiSendCallOnly.sol";
import {ERC1155Holder} from "openzeppelin-contracts/contracts/token/ERC1155/utils/ERC1155Holder.sol";
import {ERC721Holder} from "openzeppelin-contracts/contracts/token/ERC721/utils/ERC721Holder.sol";
import {Proxy} from "openzeppelin-contracts/contracts/proxy/Proxy.sol";
import {Clones} from "openzeppelin-contracts/contracts/proxy/Clones.sol";
/// @title Router Contract
/// @notice A contract that acts as a router and proxy for executing multiple transactions.
contract Router is Proxy, ERC1155Holder, ERC721Holder {
using Clones for address;
/// @notice The router registry
address internal immutable registry = msg.sender;
/// @notice The router implementation
address internal immutable routerImplementation = address(this);
/// @notice Option logic that can be installed to enhance functionality of the router
address internal pluginLogic;
/// @notice Error when caller is not owner of the router
error NotOwner();
/// @notice Updates the plugin logic address.
/// @param _pluginLogic The new plugin logic address.
function updatePluginLogic(address _pluginLogic) external {
_checkOwner();
pluginLogic = _pluginLogic;
}
/// @notice Executes multiple transactions in a single call.
/// @param transactions The byte array containing the encoded transactions.
function multiSend(bytes calldata transactions) external payable {
_checkOwner();
MultiSendCallOnly.multiSend(transactions);
}
function _implementation() internal view override returns (address) {
return pluginLogic;
}
function _checkOwner() internal view {
address router = routerImplementation.predictDeterministicAddress(
keccak256(abi.encode(msg.sender)), registry
);
if (router != address(this)) revert NotOwner();
}
}