Skip to content

Commit e54273e

Browse files
authored
Add Multisig Batch utility for forge scripts (#48)
* included multisig batch script into utilities * removed unecessary ignore
1 parent 613d2d9 commit e54273e

4 files changed

Lines changed: 42 additions & 0 deletions

File tree

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@
66
path = lib/openzeppelin-contracts-upgradeable
77
url = https://github.com/openzeppelin/openzeppelin-contracts-upgradeable
88
branch = release-v5.3
9+
[submodule "lib/safe-utils"]
10+
path = lib/safe-utils
11+
url = https://github.com/Recon-Fuzz/safe-utils

foundry.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ block_timestamp = 1_689_934_508
1818
# Ignore base test files to avoid running tests twice
1919
no_match_path = "./test/base/*.t.sol"
2020

21+
[lint]
22+
lint_on_build = false
23+
2124
[profile.default.fuzz]
2225
runs = 256
2326

lib/safe-utils

Submodule safe-utils added at eccb79f

script/MultiSigBatchBase.sol

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// SPDX-License-Identifier: UNLICENSED
2+
3+
pragma solidity >=0.8.20 <0.9.0;
4+
5+
import { Safe } from "../lib/safe-utils/src/Safe.sol";
6+
import { Script } from "../lib/forge-std/src/Script.sol";
7+
8+
abstract contract MultiSigBatchBase is Script {
9+
using Safe for *;
10+
11+
Safe.Client internal _safeMultiSig;
12+
address[] internal _targets;
13+
bytes[] internal _data;
14+
15+
function _addToBatch(address target_, bytes memory data_) internal {
16+
_targets.push(target_);
17+
_data.push(data_);
18+
}
19+
20+
function _proposeBatch(address safe_, address sender) internal {
21+
_safeMultiSig.initialize(safe_);
22+
_safeMultiSig.proposeTransactions(_targets, _data, sender, "");
23+
}
24+
25+
function _simulateBatch(address safe_) internal {
26+
vm.startPrank(safe_);
27+
28+
for (uint256 i = 0; i < _targets.length; i++) {
29+
(bool success, ) = _targets[i].call(_data[i]);
30+
require(success, "Simulation failed");
31+
}
32+
33+
vm.stopPrank();
34+
}
35+
}

0 commit comments

Comments
 (0)