-
Notifications
You must be signed in to change notification settings - Fork 9
/
MockTimelockCM.sol
57 lines (51 loc) · 1.84 KB
/
MockTimelockCM.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
50
51
52
53
54
55
56
57
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.21;
error ExecFailed(address multisig, bytes payload);
/// @title MockTimelock - Mock of Timelock contract for community multisig management
/// @author Aleksandr Kuperman - <[email protected]>
/// @author AL
contract MockTimelockCM {
event CallScheduled(address target, uint256 value, bytes data, bytes32 predecessor, bytes32 salt, uint256 delay);
/// @dev Executes the payload at the specified address.
/// @param to Address to call.
/// @param payload Bytes of payload.
function execute(address to, bytes memory payload) external {
(bool success, ) = to.call(payload);
if (!success) {
revert ExecFailed(to, payload);
}
}
/// @dev Executes payloads for specified addresses.
/// @param targets Target addresses.
/// @param payloads Bytes of payloads.
function executeBatch(address[] memory targets, bytes[] memory payloads) external {
for (uint256 i = 0; i < targets.length; ++i) {
(bool success, ) = targets[i].call(payloads[i]);
if (!success) {
revert ExecFailed(targets[i], payloads[i]);
}
}
}
/// @dev Mock of a schedule function.
function schedule(
address target,
uint256 value,
bytes calldata data,
bytes32 predecessor,
bytes32 salt,
uint256 delay
) external {
emit CallScheduled(target, value, data, predecessor, salt, delay);
}
/// @dev Mock of a scheduleBatch function.
function scheduleBatch(
address[] memory targets,
uint256[] memory values,
bytes[] calldata datas,
bytes32 predecessor,
bytes32 salt,
uint256 delay
) external {
emit CallScheduled(targets[0], values[0], datas[0], predecessor, salt, delay);
}
}