Skip to content

Commit bdcb2a4

Browse files
committed
feat: multi-evm support for multi-chain scripts
1 parent b8f065f commit bdcb2a4

File tree

12 files changed

+1131
-212
lines changed

12 files changed

+1131
-212
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
cache/
22
out/
3+
out-cancun/
4+
out-shanghai/
35
.vscode
46
.idea

foundry.toml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,22 @@ optimizer_runs = 200
77
# 3860 = init-code-size
88
ignored_error_codes = [3860]
99

10+
[profile.shanghai]
11+
fs_permissions = [{ access = "read-write", path = "./" }]
12+
optimizer = true
13+
optimizer_runs = 200
14+
evm_version = "shanghai"
15+
out = "out-shanghai"
16+
ignored_error_codes = [3860]
17+
18+
[profile.cancun]
19+
fs_permissions = [{ access = "read-write", path = "./" }]
20+
optimizer = true
21+
optimizer_runs = 200
22+
evm_version = "cancun"
23+
out = "out-cancun"
24+
ignored_error_codes = [3860]
25+
1026
[rpc_endpoints]
1127
# The RPC URLs are modified versions of the default for testing initialization.
1228
mainnet = "https://eth.merkle.io" # Different API key.

src/Config.sol

Lines changed: 409 additions & 17 deletions
Large diffs are not rendered by default.

src/LibConfigView.sol

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.13;
3+
4+
import {StdConfig} from "./StdConfig.sol";
5+
import {Variable} from "./LibVariable.sol";
6+
7+
/// @notice A view into a StdConfig instance bound to a specific chain ID.
8+
/// Provides ergonomic access to configuration variables without repeating the chain ID.
9+
struct ConfigView {
10+
StdConfig stdConfig;
11+
uint256 chainId;
12+
}
13+
14+
/// @notice Library providing helper methods for ConfigView.
15+
/// All methods delegate to StdConfig, automatically passing the bound chainId.
16+
library LibConfigView {
17+
// -- GETTER ---------------------------------------------------------------
18+
19+
/// @notice Reads a configuration variable for the bound chain ID.
20+
/// @param self The ConfigView instance.
21+
/// @param key The configuration variable key.
22+
/// @return Variable struct containing the type and ABI-encoded value.
23+
function get(ConfigView memory self, string memory key) internal view returns (Variable memory) {
24+
return self.stdConfig.get(self.chainId, key);
25+
}
26+
27+
// -- SETTERS (SINGLE VALUES) ----------------------------------------------
28+
29+
/// @notice Sets a boolean configuration variable.
30+
function set(ConfigView memory self, string memory key, bool value) internal {
31+
self.stdConfig.set(self.chainId, key, value);
32+
}
33+
34+
/// @notice Sets an address configuration variable.
35+
function set(ConfigView memory self, string memory key, address value) internal {
36+
self.stdConfig.set(self.chainId, key, value);
37+
}
38+
39+
/// @notice Sets a bytes32 configuration variable.
40+
function set(ConfigView memory self, string memory key, bytes32 value) internal {
41+
self.stdConfig.set(self.chainId, key, value);
42+
}
43+
44+
/// @notice Sets a uint256 configuration variable.
45+
function set(ConfigView memory self, string memory key, uint256 value) internal {
46+
self.stdConfig.set(self.chainId, key, value);
47+
}
48+
49+
/// @notice Sets an int256 configuration variable.
50+
function set(ConfigView memory self, string memory key, int256 value) internal {
51+
self.stdConfig.set(self.chainId, key, value);
52+
}
53+
54+
/// @notice Sets a string configuration variable.
55+
function set(ConfigView memory self, string memory key, string memory value) internal {
56+
self.stdConfig.set(self.chainId, key, value);
57+
}
58+
59+
/// @notice Sets a bytes configuration variable.
60+
function set(ConfigView memory self, string memory key, bytes memory value) internal {
61+
self.stdConfig.set(self.chainId, key, value);
62+
}
63+
64+
// -- SETTERS (ARRAYS) -----------------------------------------------------
65+
66+
/// @notice Sets a boolean array configuration variable.
67+
function set(ConfigView memory self, string memory key, bool[] memory value) internal {
68+
self.stdConfig.set(self.chainId, key, value);
69+
}
70+
71+
/// @notice Sets an address array configuration variable.
72+
function set(ConfigView memory self, string memory key, address[] memory value) internal {
73+
self.stdConfig.set(self.chainId, key, value);
74+
}
75+
76+
/// @notice Sets a bytes32 array configuration variable.
77+
function set(ConfigView memory self, string memory key, bytes32[] memory value) internal {
78+
self.stdConfig.set(self.chainId, key, value);
79+
}
80+
81+
/// @notice Sets a uint256 array configuration variable.
82+
function set(ConfigView memory self, string memory key, uint256[] memory value) internal {
83+
self.stdConfig.set(self.chainId, key, value);
84+
}
85+
86+
/// @notice Sets an int256 array configuration variable.
87+
function set(ConfigView memory self, string memory key, int256[] memory value) internal {
88+
self.stdConfig.set(self.chainId, key, value);
89+
}
90+
91+
/// @notice Sets a string array configuration variable.
92+
function set(ConfigView memory self, string memory key, string[] memory value) internal {
93+
self.stdConfig.set(self.chainId, key, value);
94+
}
95+
96+
/// @notice Sets a bytes array configuration variable.
97+
function set(ConfigView memory self, string memory key, bytes[] memory value) internal {
98+
self.stdConfig.set(self.chainId, key, value);
99+
}
100+
}

0 commit comments

Comments
 (0)