@godzillaba/mutest 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/README.md +1 -1
  2. package/index.ts +23 -6
  3. package/package.json +4 -1
  4. package/.devcontainer/Dockerfile +0 -117
  5. package/.devcontainer/devcontainer.json +0 -62
  6. package/.devcontainer/init-firewall.sh +0 -118
  7. package/.github/workflows/test.yml +0 -38
  8. package/.gitmodules +0 -3
  9. package/CLAUDE.md +0 -39
  10. package/foundry.lock +0 -8
  11. package/foundry.toml +0 -6
  12. package/lib/forge-std/.gitattributes +0 -1
  13. package/lib/forge-std/.github/CODEOWNERS +0 -1
  14. package/lib/forge-std/.github/dependabot.yml +0 -6
  15. package/lib/forge-std/.github/workflows/ci.yml +0 -125
  16. package/lib/forge-std/.github/workflows/sync.yml +0 -36
  17. package/lib/forge-std/CONTRIBUTING.md +0 -193
  18. package/lib/forge-std/LICENSE-APACHE +0 -203
  19. package/lib/forge-std/LICENSE-MIT +0 -25
  20. package/lib/forge-std/README.md +0 -314
  21. package/lib/forge-std/RELEASE_CHECKLIST.md +0 -12
  22. package/lib/forge-std/foundry.toml +0 -18
  23. package/lib/forge-std/package.json +0 -16
  24. package/lib/forge-std/scripts/vm.py +0 -636
  25. package/lib/forge-std/src/Base.sol +0 -48
  26. package/lib/forge-std/src/Config.sol +0 -60
  27. package/lib/forge-std/src/LibVariable.sol +0 -477
  28. package/lib/forge-std/src/Script.sol +0 -28
  29. package/lib/forge-std/src/StdAssertions.sol +0 -779
  30. package/lib/forge-std/src/StdChains.sol +0 -303
  31. package/lib/forge-std/src/StdCheats.sol +0 -825
  32. package/lib/forge-std/src/StdConfig.sol +0 -632
  33. package/lib/forge-std/src/StdConstants.sol +0 -30
  34. package/lib/forge-std/src/StdError.sol +0 -15
  35. package/lib/forge-std/src/StdInvariant.sol +0 -140
  36. package/lib/forge-std/src/StdJson.sol +0 -275
  37. package/lib/forge-std/src/StdMath.sol +0 -47
  38. package/lib/forge-std/src/StdStorage.sol +0 -475
  39. package/lib/forge-std/src/StdStyle.sol +0 -333
  40. package/lib/forge-std/src/StdToml.sol +0 -275
  41. package/lib/forge-std/src/StdUtils.sol +0 -200
  42. package/lib/forge-std/src/Test.sol +0 -32
  43. package/lib/forge-std/src/Vm.sol +0 -2533
  44. package/lib/forge-std/src/console.sol +0 -1551
  45. package/lib/forge-std/src/console2.sol +0 -4
  46. package/lib/forge-std/src/interfaces/IERC1155.sol +0 -105
  47. package/lib/forge-std/src/interfaces/IERC165.sol +0 -12
  48. package/lib/forge-std/src/interfaces/IERC20.sol +0 -43
  49. package/lib/forge-std/src/interfaces/IERC4626.sol +0 -190
  50. package/lib/forge-std/src/interfaces/IERC6909.sol +0 -72
  51. package/lib/forge-std/src/interfaces/IERC721.sol +0 -164
  52. package/lib/forge-std/src/interfaces/IERC7540.sol +0 -144
  53. package/lib/forge-std/src/interfaces/IERC7575.sol +0 -241
  54. package/lib/forge-std/src/interfaces/IMulticall3.sol +0 -68
  55. package/lib/forge-std/src/safeconsole.sol +0 -13248
  56. package/lib/forge-std/test/CommonBase.t.sol +0 -44
  57. package/lib/forge-std/test/Config.t.sol +0 -381
  58. package/lib/forge-std/test/LibVariable.t.sol +0 -452
  59. package/lib/forge-std/test/StdAssertions.t.sol +0 -141
  60. package/lib/forge-std/test/StdChains.t.sol +0 -227
  61. package/lib/forge-std/test/StdCheats.t.sol +0 -638
  62. package/lib/forge-std/test/StdConstants.t.sol +0 -38
  63. package/lib/forge-std/test/StdError.t.sol +0 -119
  64. package/lib/forge-std/test/StdJson.t.sol +0 -49
  65. package/lib/forge-std/test/StdMath.t.sol +0 -202
  66. package/lib/forge-std/test/StdStorage.t.sol +0 -485
  67. package/lib/forge-std/test/StdStyle.t.sol +0 -110
  68. package/lib/forge-std/test/StdToml.t.sol +0 -49
  69. package/lib/forge-std/test/StdUtils.t.sol +0 -342
  70. package/lib/forge-std/test/Vm.t.sol +0 -18
  71. package/lib/forge-std/test/compilation/CompilationScript.sol +0 -8
  72. package/lib/forge-std/test/compilation/CompilationScriptBase.sol +0 -8
  73. package/lib/forge-std/test/compilation/CompilationTest.sol +0 -8
  74. package/lib/forge-std/test/compilation/CompilationTestBase.sol +0 -8
  75. package/lib/forge-std/test/fixtures/broadcast.log.json +0 -187
  76. package/lib/forge-std/test/fixtures/config.toml +0 -81
  77. package/lib/forge-std/test/fixtures/test.json +0 -8
  78. package/lib/forge-std/test/fixtures/test.toml +0 -6
  79. package/script/Counter.s.sol +0 -19
  80. package/src/Counter.sol +0 -14
  81. package/test/Counter.t.sol +0 -24
@@ -1,303 +0,0 @@
1
- // SPDX-License-Identifier: MIT OR Apache-2.0
2
- pragma solidity >=0.8.13 <0.9.0;
3
-
4
- import {VmSafe} from "./Vm.sol";
5
-
6
- /**
7
- * StdChains provides information about EVM compatible chains that can be used in scripts/tests.
8
- * For each chain, the chain's name, chain ID, and a default RPC URL are provided. Chains are
9
- * identified by their alias, which is the same as the alias in the `[rpc_endpoints]` section of
10
- * the `foundry.toml` file. For best UX, ensure the alias in the `foundry.toml` file matches the
11
- * alias used in this contract, which can be found as the first argument to the
12
- * `setChainWithDefaultRpcUrl` call in the `initializeStdChains` function.
13
- *
14
- * There are two main ways to use this contract:
15
- * 1. Set a chain with `setChain(string memory chainAlias, ChainData memory chain)` or
16
- * `setChain(string memory chainAlias, Chain memory chain)`
17
- * 2. Get a chain with `getChain(string memory chainAlias)` or `getChain(uint256 chainId)`.
18
- *
19
- * The first time either of those are used, chains are initialized with the default set of RPC URLs.
20
- * This is done in `initializeStdChains`, which uses `setChainWithDefaultRpcUrl`. Defaults are recorded in
21
- * `defaultRpcUrls`.
22
- *
23
- * The `setChain` function is straightforward, and it simply saves off the given chain data.
24
- *
25
- * The `getChain` methods use `getChainWithUpdatedRpcUrl` to return a chain. For example, let's say
26
- * we want to retrieve the RPC URL for `mainnet`:
27
- * - If you have specified data with `setChain`, it will return that.
28
- * - If you have configured a mainnet RPC URL in `foundry.toml`, it will return the URL, provided it
29
- * is valid (e.g. a URL is specified, or an environment variable is given and exists).
30
- * - If neither of the above conditions is met, the default data is returned.
31
- *
32
- * Summarizing the above, the prioritization hierarchy is `setChain` -> `foundry.toml` -> environment variable -> defaults.
33
- */
34
- abstract contract StdChains {
35
- VmSafe private constant vm = VmSafe(address(uint160(uint256(keccak256("hevm cheat code")))));
36
-
37
- bool private stdChainsInitialized;
38
-
39
- struct ChainData {
40
- string name;
41
- uint256 chainId;
42
- string rpcUrl;
43
- }
44
-
45
- struct Chain {
46
- // The chain name.
47
- string name;
48
- // The chain's Chain ID.
49
- uint256 chainId;
50
- // The chain's alias. (i.e. what gets specified in `foundry.toml`).
51
- string chainAlias;
52
- // A default RPC endpoint for this chain.
53
- // NOTE: This default RPC URL is included for convenience to facilitate quick tests and
54
- // experimentation. Do not use this RPC URL for production test suites, CI, or other heavy
55
- // usage as you will be throttled and this is a disservice to others who need this endpoint.
56
- string rpcUrl;
57
- }
58
-
59
- // Maps from the chain's alias (matching the alias in the `foundry.toml` file) to chain data.
60
- mapping(string => Chain) private chains;
61
- // Maps from the chain's alias to its default RPC URL.
62
- mapping(string => string) private defaultRpcUrls;
63
- // Maps from a chain ID to its alias.
64
- mapping(uint256 => string) private idToAlias;
65
-
66
- bool private fallbackToDefaultRpcUrls = true;
67
-
68
- // The RPC URL will be fetched from config or defaultRpcUrls if possible.
69
- function getChain(string memory chainAlias) internal virtual returns (Chain memory chain) {
70
- require(bytes(chainAlias).length != 0, "StdChains getChain(string): Chain alias cannot be the empty string.");
71
-
72
- initializeStdChains();
73
- chain = chains[chainAlias];
74
- require(
75
- chain.chainId != 0,
76
- string(abi.encodePacked("StdChains getChain(string): Chain with alias \"", chainAlias, "\" not found."))
77
- );
78
-
79
- chain = getChainWithUpdatedRpcUrl(chainAlias, chain);
80
- }
81
-
82
- function getChain(uint256 chainId) internal virtual returns (Chain memory chain) {
83
- require(chainId != 0, "StdChains getChain(uint256): Chain ID cannot be 0.");
84
- initializeStdChains();
85
- string memory chainAlias = idToAlias[chainId];
86
-
87
- chain = chains[chainAlias];
88
-
89
- require(
90
- chain.chainId != 0,
91
- string(abi.encodePacked("StdChains getChain(uint256): Chain with ID ", vm.toString(chainId), " not found."))
92
- );
93
-
94
- chain = getChainWithUpdatedRpcUrl(chainAlias, chain);
95
- }
96
-
97
- // set chain info, with priority to argument's rpcUrl field.
98
- function setChain(string memory chainAlias, ChainData memory chain) internal virtual {
99
- require(
100
- bytes(chainAlias).length != 0,
101
- "StdChains setChain(string,ChainData): Chain alias cannot be the empty string."
102
- );
103
-
104
- require(chain.chainId != 0, "StdChains setChain(string,ChainData): Chain ID cannot be 0.");
105
-
106
- initializeStdChains();
107
- string memory foundAlias = idToAlias[chain.chainId];
108
-
109
- require(
110
- bytes(foundAlias).length == 0 || keccak256(bytes(foundAlias)) == keccak256(bytes(chainAlias)),
111
- string(
112
- abi.encodePacked(
113
- "StdChains setChain(string,ChainData): Chain ID ",
114
- vm.toString(chain.chainId),
115
- " already used by \"",
116
- foundAlias,
117
- "\"."
118
- )
119
- )
120
- );
121
-
122
- uint256 oldChainId = chains[chainAlias].chainId;
123
- delete idToAlias[oldChainId];
124
-
125
- chains[chainAlias] =
126
- Chain({name: chain.name, chainId: chain.chainId, chainAlias: chainAlias, rpcUrl: chain.rpcUrl});
127
- idToAlias[chain.chainId] = chainAlias;
128
- }
129
-
130
- // set chain info, with priority to argument's rpcUrl field.
131
- function setChain(string memory chainAlias, Chain memory chain) internal virtual {
132
- setChain(chainAlias, ChainData({name: chain.name, chainId: chain.chainId, rpcUrl: chain.rpcUrl}));
133
- }
134
-
135
- function _toUpper(string memory str) private pure returns (string memory) {
136
- bytes memory strb = bytes(str);
137
- bytes memory copy = new bytes(strb.length);
138
- for (uint256 i = 0; i < strb.length; i++) {
139
- bytes1 b = strb[i];
140
- if (b >= 0x61 && b <= 0x7A) {
141
- copy[i] = bytes1(uint8(b) - 32);
142
- } else {
143
- copy[i] = b;
144
- }
145
- }
146
- return string(copy);
147
- }
148
-
149
- // lookup rpcUrl, in descending order of priority:
150
- // current -> config (foundry.toml) -> environment variable -> default
151
- function getChainWithUpdatedRpcUrl(string memory chainAlias, Chain memory chain)
152
- private
153
- view
154
- returns (Chain memory)
155
- {
156
- if (bytes(chain.rpcUrl).length == 0) {
157
- try vm.rpcUrl(chainAlias) returns (string memory configRpcUrl) {
158
- chain.rpcUrl = configRpcUrl;
159
- } catch (bytes memory err) {
160
- string memory envName = string(abi.encodePacked(_toUpper(chainAlias), "_RPC_URL"));
161
- if (fallbackToDefaultRpcUrls) {
162
- chain.rpcUrl = vm.envOr(envName, defaultRpcUrls[chainAlias]);
163
- } else {
164
- chain.rpcUrl = vm.envString(envName);
165
- }
166
- // Distinguish 'not found' from 'cannot read'
167
- // The upstream error thrown by forge for failing cheats changed so we check both the old and new versions
168
- bytes memory oldNotFoundError =
169
- abi.encodeWithSignature("CheatCodeError", string(abi.encodePacked("invalid rpc url ", chainAlias)));
170
- bytes memory newNotFoundError = abi.encodeWithSignature(
171
- "CheatcodeError(string)", string(abi.encodePacked("invalid rpc url: ", chainAlias))
172
- );
173
- bytes32 errHash = keccak256(err);
174
- if (
175
- (errHash != keccak256(oldNotFoundError) && errHash != keccak256(newNotFoundError))
176
- || bytes(chain.rpcUrl).length == 0
177
- ) {
178
- assembly ("memory-safe") {
179
- revert(add(32, err), mload(err))
180
- }
181
- }
182
- }
183
- }
184
- return chain;
185
- }
186
-
187
- function setFallbackToDefaultRpcUrls(bool useDefault) internal {
188
- fallbackToDefaultRpcUrls = useDefault;
189
- }
190
-
191
- function initializeStdChains() private {
192
- if (stdChainsInitialized) return;
193
-
194
- stdChainsInitialized = true;
195
-
196
- // If adding an RPC here, make sure to test the default RPC URL in `test_Rpcs` in `StdChains.t.sol`
197
- setChainWithDefaultRpcUrl("anvil", ChainData("Anvil", 31337, "http://127.0.0.1:8545"));
198
- setChainWithDefaultRpcUrl("mainnet", ChainData("Mainnet", 1, "https://eth.llamarpc.com"));
199
- setChainWithDefaultRpcUrl(
200
- "sepolia", ChainData("Sepolia", 11155111, "https://sepolia.infura.io/v3/b9794ad1ddf84dfb8c34d6bb5dca2001")
201
- );
202
- setChainWithDefaultRpcUrl("holesky", ChainData("Holesky", 17000, "https://rpc.holesky.ethpandaops.io"));
203
- setChainWithDefaultRpcUrl("hoodi", ChainData("Hoodi", 560048, "https://rpc.hoodi.ethpandaops.io"));
204
- setChainWithDefaultRpcUrl("optimism", ChainData("Optimism", 10, "https://mainnet.optimism.io"));
205
- setChainWithDefaultRpcUrl(
206
- "optimism_sepolia", ChainData("Optimism Sepolia", 11155420, "https://sepolia.optimism.io")
207
- );
208
- setChainWithDefaultRpcUrl("arbitrum_one", ChainData("Arbitrum One", 42161, "https://arb1.arbitrum.io/rpc"));
209
- setChainWithDefaultRpcUrl(
210
- "arbitrum_one_sepolia", ChainData("Arbitrum One Sepolia", 421614, "https://sepolia-rollup.arbitrum.io/rpc")
211
- );
212
- setChainWithDefaultRpcUrl("arbitrum_nova", ChainData("Arbitrum Nova", 42170, "https://nova.arbitrum.io/rpc"));
213
- setChainWithDefaultRpcUrl("polygon", ChainData("Polygon", 137, "https://polygon-rpc.com"));
214
- setChainWithDefaultRpcUrl(
215
- "polygon_amoy", ChainData("Polygon Amoy", 80002, "https://rpc-amoy.polygon.technology")
216
- );
217
- setChainWithDefaultRpcUrl("avalanche", ChainData("Avalanche", 43114, "https://api.avax.network/ext/bc/C/rpc"));
218
- setChainWithDefaultRpcUrl(
219
- "avalanche_fuji", ChainData("Avalanche Fuji", 43113, "https://api.avax-test.network/ext/bc/C/rpc")
220
- );
221
- setChainWithDefaultRpcUrl(
222
- "bnb_smart_chain", ChainData("BNB Smart Chain", 56, "https://bsc-dataseed1.binance.org")
223
- );
224
- setChainWithDefaultRpcUrl(
225
- "bnb_smart_chain_testnet",
226
- ChainData("BNB Smart Chain Testnet", 97, "https://rpc.ankr.com/bsc_testnet_chapel")
227
- );
228
- setChainWithDefaultRpcUrl("gnosis_chain", ChainData("Gnosis Chain", 100, "https://rpc.gnosischain.com"));
229
- setChainWithDefaultRpcUrl("moonbeam", ChainData("Moonbeam", 1284, "https://rpc.api.moonbeam.network"));
230
- setChainWithDefaultRpcUrl(
231
- "moonriver", ChainData("Moonriver", 1285, "https://rpc.api.moonriver.moonbeam.network")
232
- );
233
- setChainWithDefaultRpcUrl("moonbase", ChainData("Moonbase", 1287, "https://rpc.testnet.moonbeam.network"));
234
- setChainWithDefaultRpcUrl("base_sepolia", ChainData("Base Sepolia", 84532, "https://sepolia.base.org"));
235
- setChainWithDefaultRpcUrl("base", ChainData("Base", 8453, "https://mainnet.base.org"));
236
- setChainWithDefaultRpcUrl("blast_sepolia", ChainData("Blast Sepolia", 168587773, "https://sepolia.blast.io"));
237
- setChainWithDefaultRpcUrl("blast", ChainData("Blast", 81457, "https://rpc.blast.io"));
238
- setChainWithDefaultRpcUrl("fantom_opera", ChainData("Fantom Opera", 250, "https://rpc.ankr.com/fantom/"));
239
- setChainWithDefaultRpcUrl(
240
- "fantom_opera_testnet", ChainData("Fantom Opera Testnet", 4002, "https://rpc.ankr.com/fantom_testnet/")
241
- );
242
- setChainWithDefaultRpcUrl("fraxtal", ChainData("Fraxtal", 252, "https://rpc.frax.com"));
243
- setChainWithDefaultRpcUrl("fraxtal_testnet", ChainData("Fraxtal Testnet", 2522, "https://rpc.testnet.frax.com"));
244
- setChainWithDefaultRpcUrl(
245
- "berachain_bartio_testnet", ChainData("Berachain bArtio Testnet", 80084, "https://bartio.rpc.berachain.com")
246
- );
247
- setChainWithDefaultRpcUrl("flare", ChainData("Flare", 14, "https://flare-api.flare.network/ext/C/rpc"));
248
- setChainWithDefaultRpcUrl(
249
- "flare_coston2", ChainData("Flare Coston2", 114, "https://coston2-api.flare.network/ext/C/rpc")
250
- );
251
-
252
- setChainWithDefaultRpcUrl("ink", ChainData("Ink", 57073, "https://rpc-gel.inkonchain.com"));
253
- setChainWithDefaultRpcUrl(
254
- "ink_sepolia", ChainData("Ink Sepolia", 763373, "https://rpc-gel-sepolia.inkonchain.com")
255
- );
256
-
257
- setChainWithDefaultRpcUrl("mode", ChainData("Mode", 34443, "https://mode.drpc.org"));
258
- setChainWithDefaultRpcUrl("mode_sepolia", ChainData("Mode Sepolia", 919, "https://sepolia.mode.network"));
259
-
260
- setChainWithDefaultRpcUrl("zora", ChainData("Zora", 7777777, "https://zora.drpc.org"));
261
- setChainWithDefaultRpcUrl(
262
- "zora_sepolia", ChainData("Zora Sepolia", 999999999, "https://sepolia.rpc.zora.energy")
263
- );
264
-
265
- setChainWithDefaultRpcUrl("race", ChainData("Race", 6805, "https://racemainnet.io"));
266
- setChainWithDefaultRpcUrl("race_sepolia", ChainData("Race Sepolia", 6806, "https://racemainnet.io"));
267
-
268
- setChainWithDefaultRpcUrl("metal", ChainData("Metal", 1750, "https://metall2.drpc.org"));
269
- setChainWithDefaultRpcUrl("metal_sepolia", ChainData("Metal Sepolia", 1740, "https://testnet.rpc.metall2.com"));
270
-
271
- setChainWithDefaultRpcUrl("binary", ChainData("Binary", 624, "https://rpc.zero.thebinaryholdings.com"));
272
- setChainWithDefaultRpcUrl(
273
- "binary_sepolia", ChainData("Binary Sepolia", 625, "https://rpc.zero.thebinaryholdings.com")
274
- );
275
-
276
- setChainWithDefaultRpcUrl("orderly", ChainData("Orderly", 291, "https://rpc.orderly.network"));
277
- setChainWithDefaultRpcUrl(
278
- "orderly_sepolia", ChainData("Orderly Sepolia", 4460, "https://testnet-rpc.orderly.org")
279
- );
280
-
281
- setChainWithDefaultRpcUrl("unichain", ChainData("Unichain", 130, "https://mainnet.unichain.org"));
282
- setChainWithDefaultRpcUrl(
283
- "unichain_sepolia", ChainData("Unichain Sepolia", 1301, "https://sepolia.unichain.org")
284
- );
285
-
286
- setChainWithDefaultRpcUrl("tempo", ChainData("Tempo", 4217, "https://rpc.mainnet.tempo.xyz"));
287
- setChainWithDefaultRpcUrl(
288
- "tempo_moderato", ChainData("Tempo Moderato", 42431, "https://rpc.moderato.tempo.xyz")
289
- );
290
- setChainWithDefaultRpcUrl(
291
- "tempo_andantino", ChainData("Tempo Andantino", 42429, "https://rpc.testnet.tempo.xyz")
292
- );
293
- }
294
-
295
- // set chain info, with priority to chainAlias' rpc url in foundry.toml
296
- function setChainWithDefaultRpcUrl(string memory chainAlias, ChainData memory chain) private {
297
- string memory rpcUrl = chain.rpcUrl;
298
- defaultRpcUrls[chainAlias] = rpcUrl;
299
- chain.rpcUrl = "";
300
- setChain(chainAlias, chain);
301
- chain.rpcUrl = rpcUrl; // restore argument
302
- }
303
- }