foundry_cheatcodes_spec/vm.rs
1// We don't document function parameters individually so we can't enable `missing_docs` for this
2// module. Instead, we emit custom diagnostics in `#[derive(Cheatcode)]`.
3#![allow(missing_docs)]
4
5use super::*;
6use crate::Vm::ForgeContext;
7use alloy_sol_types::sol;
8use foundry_macros::Cheatcode;
9
10sol! {
11// Cheatcodes are marked as view/pure/none using the following rules:
12// 0. A call's observable behaviour includes its return value, logs, reverts and state writes,
13// 1. If you can influence a later call's observable behaviour, you're neither `view` nor `pure`
14// (you are modifying some state be it the EVM, interpreter, filesystem, etc),
15// 2. Otherwise if you can be influenced by an earlier call, or if reading some state, you're `view`,
16// 3. Otherwise you're `pure`.
17
18/// Foundry cheatcodes interface.
19#[derive(Debug, Cheatcode)] // Keep this list small to avoid unnecessary bloat.
20interface Vm {
21 // ======== Types ========
22
23 /// Error thrown by cheatcodes.
24 error CheatcodeError(string message);
25
26 /// A modification applied to either `msg.sender` or `tx.origin`. Returned by `readCallers`.
27 enum CallerMode {
28 /// No caller modification is currently active.
29 None,
30 /// A one time broadcast triggered by a `vm.broadcast()` call is currently active.
31 Broadcast,
32 /// A recurrent broadcast triggered by a `vm.startBroadcast()` call is currently active.
33 RecurrentBroadcast,
34 /// A one time prank triggered by a `vm.prank()` call is currently active.
35 Prank,
36 /// A recurrent prank triggered by a `vm.startPrank()` call is currently active.
37 RecurrentPrank,
38 }
39
40 /// The kind of account access that occurred.
41 enum AccountAccessKind {
42 /// The account was called.
43 Call,
44 /// The account was called via delegatecall.
45 DelegateCall,
46 /// The account was called via callcode.
47 CallCode,
48 /// The account was called via staticcall.
49 StaticCall,
50 /// The account was created.
51 Create,
52 /// The account was selfdestructed.
53 SelfDestruct,
54 /// Synthetic access indicating the current context has resumed after a previous sub-context (AccountAccess).
55 Resume,
56 /// The account's balance was read.
57 Balance,
58 /// The account's codesize was read.
59 Extcodesize,
60 /// The account's codehash was read.
61 Extcodehash,
62 /// The account's code was copied.
63 Extcodecopy,
64 }
65
66 /// Forge execution contexts.
67 enum ForgeContext {
68 /// Test group execution context (test, coverage or snapshot).
69 TestGroup,
70 /// `forge test` execution context.
71 Test,
72 /// `forge coverage` execution context.
73 Coverage,
74 /// `forge snapshot` execution context.
75 Snapshot,
76 /// Script group execution context (dry run, broadcast or resume).
77 ScriptGroup,
78 /// `forge script` execution context.
79 ScriptDryRun,
80 /// `forge script --broadcast` execution context.
81 ScriptBroadcast,
82 /// `forge script --resume` execution context.
83 ScriptResume,
84 /// Unknown `forge` execution context.
85 Unknown,
86 }
87
88 /// An Ethereum log. Returned by `getRecordedLogs`.
89 struct Log {
90 /// The topics of the log, including the signature, if any.
91 bytes32[] topics;
92 /// The raw data of the log.
93 bytes data;
94 /// The address of the log's emitter.
95 address emitter;
96 }
97
98 /// Gas measured for the last completed call or create frame, from the callee's perspective,
99 /// including nested execution. Isolated transactions include intrinsic gas.
100 /// Regular gas (the EIP's execution gas) and EIP-8037 state gas are reported separately.
101 /// Without EIP-8037, state creation uses the ordinary gas schedule and `gasStateUsed` is zero.
102 /// See <https://eips.ethereum.org/EIPS/eip-8037> and <https://getfoundry.sh/reference/cheatcodes/last-frame-gas>.
103 struct Gas {
104 /// Regular gas available to the frame at entry. Excludes the EIP-8037 state gas reservoir.
105 uint64 gasLimit;
106 /// Regular gas spent by the frame, before refunds. Excludes EIP-8037 state gas; see `gasStateUsed`.
107 /// With isolation, includes intrinsic gas and the regular-gas calldata floor.
108 uint64 gasTotalUsed;
109 /// DEPRECATED: always zero. Memory expansion costs are included in `gasTotalUsed`.
110 /// Ref: <https://github.com/foundry-rs/foundry/pull/7934#pullrequestreview-2069236939>.
111 uint64 gasMemoryUsed;
112 /// Ordinary refund counter before transaction settlement; finalized for an isolated transaction.
113 /// Can be negative in nested frames. State gas refills are already netted into `gasStateUsed`.
114 int64 gasRefunded;
115 /// Regular gas left at frame end. Excludes the EIP-8037 state gas reservoir.
116 /// State charges can draw from this allowance, so `gasLimit - gasRemaining` can include state gas.
117 uint64 gasRemaining;
118 /// Net EIP-8037 state gas: state creation charges minus refills, including nested execution.
119 /// Zero without EIP-8037 or if the frame reverted or halted. Can be negative when the frame
120 /// undoes state created earlier in the same transaction; use signed arithmetic with `gasTotalUsed`.
121 /// Their sum measures net consumption, not the gas limit needed to execute.
122 int64 gasStateUsed;
123 }
124
125 /// An RPC URL and its alias. Returned by `rpcUrlStructs`.
126 struct Rpc {
127 /// The alias of the RPC URL.
128 string key;
129 /// The RPC URL.
130 string url;
131 }
132
133 /// An RPC log object. Returned by `eth_getLogs`.
134 struct EthGetLogs {
135 /// The address of the log's emitter.
136 address emitter;
137 /// The topics of the log, including the signature, if any.
138 bytes32[] topics;
139 /// The raw data of the log.
140 bytes data;
141 /// The block hash.
142 bytes32 blockHash;
143 /// The block number.
144 uint64 blockNumber;
145 /// The transaction hash.
146 bytes32 transactionHash;
147 /// The transaction index in the block.
148 uint64 transactionIndex;
149 /// The log index.
150 uint256 logIndex;
151 /// Whether the log was removed.
152 bool removed;
153 }
154
155 /// A Merkle proof for a single storage slot. Part of `EthGetProof`.
156 struct EthStorageProof {
157 /// The storage slot.
158 bytes32 key;
159 /// The value stored at the slot.
160 uint256 value;
161 /// The RLP-encoded trie nodes from the storage root to the slot, root first.
162 bytes[] proof;
163 }
164
165 /// An EIP-1186 account and storage proof. Returned by `eth_getProof`.
166 struct EthGetProof {
167 /// The address of the account.
168 address account;
169 /// The balance of the account.
170 uint256 balance;
171 /// The hash of the account's code.
172 bytes32 codeHash;
173 /// The nonce of the account.
174 uint64 nonce;
175 /// The root of the account's storage trie.
176 bytes32 storageHash;
177 /// The RLP-encoded trie nodes from the state root to the account, root first.
178 bytes[] accountProof;
179 /// The proofs for the requested storage slots, in the order they were requested.
180 EthStorageProof[] storageProof;
181 }
182
183 /// A single entry in a directory listing. Returned by `readDir`.
184 struct DirEntry {
185 /// The error message, if any.
186 string errorMessage;
187 /// The path of the entry.
188 string path;
189 /// The depth of the entry.
190 uint64 depth;
191 /// Whether the entry is a directory.
192 bool isDir;
193 /// Whether the entry is a symlink.
194 bool isSymlink;
195 }
196
197 /// Metadata information about a file.
198 ///
199 /// This structure is returned from the `fsMetadata` function and represents known
200 /// metadata about a file such as its permissions, size, modification
201 /// times, etc.
202 struct FsMetadata {
203 /// True if this metadata is for a directory.
204 bool isDir;
205 /// True if this metadata is for a symlink.
206 bool isSymlink;
207 /// The size of the file, in bytes, this metadata is for.
208 uint256 length;
209 /// True if this metadata is for a readonly (unwritable) file.
210 bool readOnly;
211 /// The last modification time listed in this metadata.
212 uint256 modified;
213 /// The last access time of this metadata.
214 uint256 accessed;
215 /// The creation time listed in this metadata.
216 uint256 created;
217 }
218
219 /// A wallet with a public and private key.
220 struct Wallet {
221 /// The wallet's address.
222 address addr;
223 /// The wallet's public key `X`.
224 uint256 publicKeyX;
225 /// The wallet's public key `Y`.
226 uint256 publicKeyY;
227 /// The wallet's private key.
228 uint256 privateKey;
229 }
230
231 /// The result of a `tryFfi` call.
232 struct FfiResult {
233 /// The exit code of the call.
234 int32 exitCode;
235 /// The optionally hex-decoded `stdout` data.
236 bytes stdout;
237 /// The `stderr` data.
238 bytes stderr;
239 }
240
241 /// Information on the chain and fork.
242 struct ChainInfo {
243 /// The fork identifier. Set to zero if no fork is active.
244 uint256 forkId;
245 /// The chain ID of the current fork.
246 uint256 chainId;
247 }
248
249 /// Information about a blockchain.
250 struct Chain {
251 /// The chain name.
252 string name;
253 /// The chain's Chain ID.
254 uint256 chainId;
255 /// The chain's alias. (i.e. what gets specified in `foundry.toml`).
256 string chainAlias;
257 /// A default RPC endpoint for this chain.
258 string rpcUrl;
259 }
260
261 /// The storage accessed during an `AccountAccess`.
262 struct StorageAccess {
263 /// The account whose storage was accessed.
264 address account;
265 /// The slot that was accessed.
266 bytes32 slot;
267 /// If the access was a write.
268 bool isWrite;
269 /// The previous value of the slot.
270 bytes32 previousValue;
271 /// The new value of the slot.
272 bytes32 newValue;
273 /// If the access was reverted.
274 bool reverted;
275 }
276
277 /// An EIP-2930 access list item.
278 struct AccessListItem {
279 /// The address to be added in access list.
280 address target;
281 /// The storage keys to be added in access list.
282 bytes32[] storageKeys;
283 }
284
285 /// The result of a `stopAndReturnStateDiff` call.
286 struct AccountAccess {
287 /// The chain and fork the access occurred.
288 ChainInfo chainInfo;
289 /// The kind of account access that determines what the account is.
290 /// If kind is Call, DelegateCall, StaticCall or CallCode, then the account is the callee.
291 /// If kind is Create, then the account is the newly created account.
292 /// If kind is SelfDestruct, then the account is the selfdestruct recipient.
293 /// If kind is a Resume, then account represents a account context that has resumed.
294 AccountAccessKind kind;
295 /// The account that was accessed.
296 /// It's either the account created, callee or a selfdestruct recipient for CREATE, CALL or SELFDESTRUCT.
297 address account;
298 /// What accessed the account.
299 address accessor;
300 /// If the account was initialized or empty prior to the access.
301 /// An account is considered initialized if it has code, a
302 /// non-zero nonce, or a non-zero balance.
303 bool initialized;
304 /// The previous balance of the accessed account.
305 uint256 oldBalance;
306 /// The potential new balance of the accessed account.
307 /// That is, all balance changes are recorded here, even if reverts occurred.
308 uint256 newBalance;
309 /// Code of the account deployed by CREATE.
310 bytes deployedCode;
311 /// Value passed along with the account access
312 uint256 value;
313 /// Input data provided to the CREATE or CALL
314 bytes data;
315 /// If this access reverted in either the current or parent context.
316 bool reverted;
317 /// An ordered list of storage accesses made during an account access operation.
318 StorageAccess[] storageAccesses;
319 /// Call depth traversed during the recording of state differences
320 uint64 depth;
321 /// The previous nonce of the accessed account.
322 uint64 oldNonce;
323 /// The new nonce of the accessed account.
324 uint64 newNonce;
325 }
326
327 /// The result of the `stopDebugTraceRecording` call
328 struct DebugStep {
329 /// The stack before executing the step of the run.
330 /// stack\[0\] represents the top of the stack.
331 /// and only stack data relevant to the opcode execution is contained.
332 uint256[] stack;
333 /// The memory input data before executing the step of the run.
334 /// only input data relevant to the opcode execution is contained.
335 ///
336 /// e.g. for MLOAD, it will have memory\[offset:offset+32\] copied here.
337 /// the offset value can be get by the stack data.
338 bytes memoryInput;
339 /// The opcode that was accessed.
340 uint8 opcode;
341 /// The call depth of the step.
342 uint64 depth;
343 /// Whether the call end up with out of gas error.
344 bool isOutOfGas;
345 /// The contract address where the opcode is running
346 address contractAddr;
347 }
348
349 /// The transaction type (`txType`) of the broadcast.
350 enum BroadcastTxType {
351 /// Represents a CALL broadcast tx.
352 Call,
353 /// Represents a CREATE broadcast tx.
354 Create,
355 /// Represents a CREATE2 broadcast tx.
356 Create2
357 }
358
359 /// Represents a transaction's broadcast details.
360 struct BroadcastTxSummary {
361 /// The hash of the transaction that was broadcasted
362 bytes32 txHash;
363 /// Represent the type of transaction among CALL, CREATE, CREATE2
364 BroadcastTxType txType;
365 /// The address of the contract that was called or created.
366 /// This is address of the contract that is created if the txType is CREATE or CREATE2.
367 address contractAddress;
368 /// The block number the transaction landed in.
369 uint64 blockNumber;
370 /// Status of the transaction, retrieved from the transaction receipt.
371 bool success;
372 }
373
374 /// Holds a signed EIP-7702 authorization for an authority account to delegate to an implementation.
375 struct SignedDelegation {
376 /// The y-parity of the recovered secp256k1 signature (0 or 1).
377 uint8 v;
378 /// First 32 bytes of the signature.
379 bytes32 r;
380 /// Second 32 bytes of the signature.
381 bytes32 s;
382 /// The current nonce of the authority account at signing time.
383 /// Used to ensure signature can't be replayed after account nonce changes.
384 uint64 nonce;
385 /// Address of the contract implementation that will be delegated to.
386 /// Gets encoded into delegation code: 0xef0100 || implementation.
387 address implementation;
388 }
389
390 /// Represents a "potential" revert reason from a single subsequent call when using `vm.assumeNoReverts`.
391 /// Reverts that match will result in a FOUNDRY::ASSUME rejection, whereas unmatched reverts will be surfaced
392 /// as normal.
393 struct PotentialRevert {
394 /// The allowed origin of the revert opcode; address(0) allows reverts from any address
395 address reverter;
396 /// When true, only matches on the first 4 bytes (usually the selector) of the revert data, otherwise, matches on entire revert data
397 bool partialMatch;
398 /// The data to use to match encountered reverts
399 bytes revertData;
400 }
401
402 /// An owner of a Tempo configurable account (TIP-1107).
403 struct ConfigurableAccountOwner {
404 /// The owner address: a secp256k1 address, or `keccak256(x || y)[12:]` of a P-256 key.
405 address owner;
406 /// The nonzero weight of the owner's approval.
407 uint8 weight;
408 }
409
410 /// The configuration of a Tempo configurable account (TIP-1107).
411 struct ConfigurableAccountConfig {
412 /// The salt that, with the initial owners and threshold, determines the account address.
413 bytes32 salt;
414 /// The configuration version: zero for the initial configuration, incremented by each update.
415 uint64 version;
416 /// The total owner weight that approvals must reach.
417 uint8 threshold;
418 /// The owners, sorted by ascending address.
419 ConfigurableAccountOwner[] owners;
420 }
421
422 /// The key type of a configurable account owner.
423 enum OwnerKeyType {
424 /// A secp256k1 key, signing with a 65-byte ECDSA signature.
425 Secp256k1,
426 /// A P-256 key, signing the digest directly (`0x01` signature).
427 P256,
428 /// A P-256 passkey, signing a WebAuthn assertion (`0x02` signature) with the RP ID
429 /// `localhost` and the origin `http://localhost`.
430 WebAuthn
431 }
432
433 /// A private key of a configurable account owner.
434 struct OwnerKey {
435 /// The key type.
436 OwnerKeyType keyType;
437 /// The private key, on secp256k1 or P-256 depending on `keyType`.
438 uint256 privateKey;
439 }
440
441 // ======== EVM ========
442
443 /// Gets the address for a given private key.
444 #[cheatcode(group = Evm, safety = Safe)]
445 function addr(uint256 privateKey) external pure returns (address keyAddr);
446
447 /// Dumps a genesis JSON file's `allocs` to disk. Accounts created in the current transaction
448 /// are ordered by deployment, followed by the remaining accounts in ascending address order.
449 #[cheatcode(group = Evm, safety = Unsafe)]
450 function dumpState(string calldata pathToStateJson) external;
451
452 /// Gets the nonce of an account.
453 #[cheatcode(group = Evm, safety = Safe)]
454 function getNonce(address account) external view returns (uint64 nonce);
455
456 /// Get the nonce of a `Wallet`.
457 #[cheatcode(group = Evm, safety = Safe)]
458 function getNonce(Wallet calldata wallet) external view returns (uint64 nonce);
459
460 /// Loads a storage slot from an address.
461 #[cheatcode(group = Evm, safety = Safe)]
462 function load(address target, bytes32 slot) external view returns (bytes32 data);
463
464 /// Loads a transient storage slot from an address.
465 #[cheatcode(group = Evm, safety = Safe)]
466 function loadTransient(address target, bytes32 slot) external view returns (bytes32 data);
467
468 /// Load a genesis JSON file's `allocs` into the in-memory EVM state.
469 #[cheatcode(group = Evm, safety = Unsafe)]
470 function loadAllocs(string calldata pathToAllocsJson) external;
471
472 // -------- Record Debug Traces --------
473
474 /// Records the debug trace during the run.
475 #[cheatcode(group = Evm, safety = Safe)]
476 function startDebugTraceRecording() external;
477
478 /// Stop debug trace recording and returns the recorded debug trace.
479 #[cheatcode(group = Evm, safety = Safe)]
480 function stopAndReturnDebugTraceRecording() external returns (DebugStep[] memory step);
481
482
483 /// Clones a source account code, state, balance and nonce to a target account and updates in-memory EVM state.
484 #[cheatcode(group = Evm, safety = Unsafe)]
485 function cloneAccount(address source, address target) external;
486
487 // -------- Record Storage --------
488
489 /// Records all storage reads and writes. Use `accesses` to get the recorded data.
490 /// Subsequent calls to `record` will clear the previous data.
491 #[cheatcode(group = Evm, safety = Safe)]
492 function record() external;
493
494 /// Stops recording storage reads and writes.
495 #[cheatcode(group = Evm, safety = Safe)]
496 function stopRecord() external;
497
498 /// Gets all accessed reads and write slot from a `vm.record` session, for a given address.
499 #[cheatcode(group = Evm, safety = Safe)]
500 function accesses(address target) external view returns (bytes32[] memory readSlots, bytes32[] memory writeSlots);
501
502 /// Registers a callback invoked after each SLOAD against `target`'s effective storage account,
503 /// including when its code runs by delegatecall.
504 ///
505 /// The callback must have the signature `function(address,bytes32,bytes32) external`.
506 /// Registering another callback for the same target and access kind replaces it. Registration
507 /// survives EVM reverts, while callback state follows the enclosing EVM context and rolls back
508 /// with it. Callback reverts propagate through the storage operation. Hooks are suppressed in
509 /// the callback and its entire call subtree. The callback must authenticate
510 /// `msg.sender == address(vm)` to prevent external spoofing. Callback execution is hidden from
511 /// mocks, expectations, log recording, and storage-access recording. It does not inherit
512 /// staticness. The callback runs as an ordinary call frame and consumes one of the 1024
513 /// protocol call-depth slots; a load at the maximum legal call depth can have its callback
514 /// rejected as too deep, propagating as a failure of the load.
515 #[cheatcode(group = Evm, safety = Unsafe)]
516 function registerSloadHook(address target, bytes4 callback) external;
517
518 /// Registers a callback invoked after each SSTORE against `target`'s effective storage account,
519 /// including when its code runs by delegatecall.
520 ///
521 /// The callback must have the signature `function(address,bytes32,bytes32,bytes32) external`.
522 /// Registering another callback for the same target and access kind replaces it. Registration
523 /// survives EVM reverts, while callback state follows the enclosing EVM context and rolls back
524 /// with it. Callback reverts propagate through the storage operation. Hooks are suppressed in
525 /// the callback and its entire call subtree. The callback must authenticate
526 /// `msg.sender == address(vm)` to prevent external spoofing. Callback execution is hidden from
527 /// mocks, expectations, log recording, and storage-access recording. It does not inherit
528 /// staticness. The callback runs as an ordinary call frame and consumes one of the 1024
529 /// protocol call-depth slots; a store at the maximum legal call depth can have its callback
530 /// rejected as too deep, propagating as a failure of the store.
531 #[cheatcode(group = Evm, safety = Unsafe)]
532 function registerSstoreHook(address target, bytes4 callback) external;
533
534 /// Registers a callback after exact mapping-element SSTOREs rooted at `rootSlot` in `target`'s effective storage account.
535 ///
536 /// The callback signature is `function(address account, bytes32 computedSlot, bytes32 rootSlot,
537 /// bytes32[] keys, bytes32 oldValue, bytes32 newValue) external`; keys are raw words in
538 /// root-to-leaf order. Only complete 64-byte Keccak chains observed after the latest mapping
539 /// hook registration for `target` in the current top-level execution match; provenance is
540 /// cleared between top-level executions. Resolution follows the complete chain to its terminal
541 /// root and ignores registered intermediate hashes. Offsets, incomplete or unknown chains,
542 /// hashes computed before registration or in an earlier top-level execution, and source layouts
543 /// do not match. The contract that calls this cheatcode receives the callback. Registration
544 /// persists across reverts and replaces the same target/root callback; callback state rolls back
545 /// with its enclosing context, callback reverts propagate, and hooks are suppressed throughout
546 /// callback subtrees. The callback must authenticate `msg.sender == address(vm)` to prevent
547 /// external spoofing. Raw and mapping SSTORE hooks conflict per target, while multiple mapping
548 /// roots may be registered.
549 #[cheatcode(group = Evm, safety = Unsafe)]
550 function registerMappingSstoreHook(address target, bytes32 rootSlot, bytes4 callback) external;
551
552 /// Record all account accesses as part of CREATE, CALL or SELFDESTRUCT opcodes in order,
553 /// along with the context of the calls
554 #[cheatcode(group = Evm, safety = Safe)]
555 function startStateDiffRecording() external;
556
557 /// Returns an ordered array of all account accesses from a `vm.startStateDiffRecording` session.
558 #[cheatcode(group = Evm, safety = Safe)]
559 function stopAndReturnStateDiff() external returns (AccountAccess[] memory accountAccesses);
560
561 /// Returns state diffs from current `vm.startStateDiffRecording` session.
562 #[cheatcode(group = Evm, safety = Safe)]
563 function getStateDiff() external view returns (string memory diff);
564
565 /// Returns state diffs from current `vm.startStateDiffRecording` session, in json format.
566 #[cheatcode(group = Evm, safety = Safe)]
567 function getStateDiffJson() external view returns (string memory diff);
568
569 /// Returns an array of storage slots occupied by the specified variable.
570 #[cheatcode(group = Evm, safety = Safe)]
571 function getStorageSlots(address target, string calldata variableName) external view returns (uint256[] memory slots);
572
573 /// Returns the storage location of the specified variable: its base slot, the byte offset of
574 /// the value within that slot, and its size in bytes, as given by the storage layout.
575 ///
576 /// `variableName` is the variable's name, or `<namespace>.<field>` for a field of an ERC-7201
577 /// namespace. Works for every storage encoding. For mappings and dynamic arrays the returned
578 /// slot is the base slot used to derive the location of their entries.
579 #[cheatcode(group = Evm, safety = Safe)]
580 function getStorageSlot(address target, string calldata variableName) external view returns (uint256 slot, uint256 offset, uint256 numberOfBytes);
581
582 /// Returns an array of `StorageAccess` from current `vm.stateStateDiffRecording` session
583 #[cheatcode(group = Evm, safety = Safe)]
584 function getStorageAccesses() external view returns (StorageAccess[] memory storageAccesses);
585
586 // -------- Recording Mapping Accesses --------
587
588 /// Starts recording mapping SSTOREs for later retrieval.
589 #[cheatcode(group = Evm, safety = Safe)]
590 function startMappingRecording() external;
591
592 /// Stops recording mapping SSTOREs and clears the recorded data.
593 #[cheatcode(group = Evm, safety = Safe)]
594 function stopMappingRecording() external;
595
596 /// Gets the number of elements in the mapping at the given slot, for a given address.
597 #[cheatcode(group = Evm, safety = Safe)]
598 function getMappingLength(address target, bytes32 mappingSlot) external view returns (uint256 length);
599
600 /// Gets the elements at index idx of the mapping at the given slot, for a given address. The
601 /// index must be less than the length of the mapping (i.e. the number of keys in the mapping).
602 #[cheatcode(group = Evm, safety = Safe)]
603 function getMappingSlotAt(address target, bytes32 mappingSlot, uint256 idx) external view returns (bytes32 value);
604
605 /// Gets the map key and parent of a mapping at a given slot, for a given address.
606 #[cheatcode(group = Evm, safety = Safe)]
607 function getMappingKeyAndParentOf(address target, bytes32 elementSlot)
608 external
609 view
610 returns (bool found, bytes32 key, bytes32 parent);
611
612 // -------- Block and Transaction Properties --------
613
614 /// Gets the current `block.chainid` of the currently selected environment.
615 /// You should use this instead of `block.chainid` if you use `vm.selectFork` or `vm.createSelectFork`, as `block.chainid` could be assumed
616 /// to be constant across a transaction, and as a result will get optimized out by the compiler.
617 /// See https://github.com/foundry-rs/foundry/issues/6180
618 #[cheatcode(group = Evm, safety = Safe)]
619 function getChainId() external view returns (uint256 blockChainId);
620
621 /// Sets `block.chainid`.
622 #[cheatcode(group = Evm, safety = Unsafe)]
623 function chainId(uint256 newChainId) external;
624
625 /// Sets `block.coinbase`.
626 #[cheatcode(group = Evm, safety = Unsafe)]
627 function coinbase(address newCoinbase) external;
628
629 /// Sets `block.difficulty`.
630 /// Not available on EVM versions from Paris onwards. Use `prevrandao` instead.
631 /// Reverts if used on unsupported EVM versions.
632 #[cheatcode(group = Evm, safety = Unsafe)]
633 function difficulty(uint256 newDifficulty) external;
634
635 /// Sets `block.basefee`.
636 #[cheatcode(group = Evm, safety = Unsafe)]
637 function fee(uint256 newBasefee) external;
638
639 /// Sets `block.prevrandao`.
640 /// Not available on EVM versions before Paris. Use `difficulty` instead.
641 /// If used on unsupported EVM versions it will revert.
642 #[cheatcode(group = Evm, safety = Unsafe)]
643 function prevrandao(bytes32 newPrevrandao) external;
644 /// Sets `block.prevrandao`.
645 /// Not available on EVM versions before Paris. Use `difficulty` instead.
646 /// If used on unsupported EVM versions it will revert.
647 #[cheatcode(group = Evm, safety = Unsafe)]
648 function prevrandao(uint256 newPrevrandao) external;
649
650 /// Sets the blobhashes in the transaction.
651 /// Not available on EVM versions before Cancun.
652 /// If used on unsupported EVM versions it will revert.
653 #[cheatcode(group = Evm, safety = Unsafe)]
654 function blobhashes(bytes32[] calldata hashes) external;
655
656 /// Gets the blobhashes from the current transaction.
657 /// Not available on EVM versions before Cancun.
658 /// If used on unsupported EVM versions it will revert.
659 #[cheatcode(group = Evm, safety = Unsafe)]
660 function getBlobhashes() external view returns (bytes32[] memory hashes);
661
662 /// Sets `block.height`.
663 #[cheatcode(group = Evm, safety = Unsafe)]
664 function roll(uint256 newHeight) external;
665
666 /// Gets the current `block.number`.
667 /// You should use this instead of `block.number` if you use `vm.roll`, as `block.number` is assumed to be constant across a transaction,
668 /// and as a result will get optimized out by the compiler.
669 /// See https://github.com/foundry-rs/foundry/issues/6180
670 #[cheatcode(group = Evm, safety = Safe)]
671 function getBlockNumber() external view returns (uint256 height);
672
673 /// Sets `block.slotnum` without changing the block number or timestamp.
674 /// Not available on EVM versions before Amsterdam.
675 /// If used on unsupported EVM versions it will revert.
676 #[cheatcode(group = Evm, safety = Unsafe)]
677 function rollSlot(uint64 newSlotNumber) external;
678
679 /// Gets the current `block.slotnum`.
680 /// Use this instead of `block.slotnum` after `vm.rollSlot`, as the compiler assumes
681 /// `block.slotnum` is constant across a transaction and may optimize repeated reads away.
682 /// Not available on EVM versions before Amsterdam.
683 /// If used on unsupported EVM versions it will revert.
684 #[cheatcode(group = Evm, safety = Safe)]
685 function getSlotNumber() external view returns (uint64 slotNumber);
686
687 /// Sets `tx.gasprice`.
688 #[cheatcode(group = Evm, safety = Unsafe)]
689 function txGasPrice(uint256 newGasPrice) external;
690
691 /// Sets `block.timestamp`.
692 #[cheatcode(group = Evm, safety = Unsafe)]
693 function warp(uint256 newTimestamp) external;
694
695 /// Gets the current `block.timestamp`.
696 /// You should use this instead of `block.timestamp` if you use `vm.warp`, as `block.timestamp` is assumed to be constant across a transaction,
697 /// and as a result will get optimized out by the compiler.
698 /// See https://github.com/foundry-rs/foundry/issues/6180
699 #[cheatcode(group = Evm, safety = Safe)]
700 function getBlockTimestamp() external view returns (uint256 timestamp);
701
702 /// Gets the RLP encoded block header for a given block number.
703 /// Returns the block header in the same format as `cast block <block_number> --raw`.
704 #[cheatcode(group = Evm, safety = Safe)]
705 function getRawBlockHeader(uint256 blockNumber) external view returns (bytes memory rlpHeader);
706
707 /// Sets `block.blobbasefee`
708 #[cheatcode(group = Evm, safety = Unsafe)]
709 function blobBaseFee(uint256 newBlobBaseFee) external;
710
711 /// Gets the current `block.blobbasefee`.
712 /// You should use this instead of `block.blobbasefee` if you use `vm.blobBaseFee`, as `block.blobbasefee` is assumed to be constant across a transaction,
713 /// and as a result will get optimized out by the compiler.
714 /// See https://github.com/foundry-rs/foundry/issues/6180
715 #[cheatcode(group = Evm, safety = Safe)]
716 function getBlobBaseFee() external view returns (uint256 blobBaseFee);
717
718 /// Set blockhash for the current block.
719 /// It only sets the blockhash for blocks where `block.number - 256 <= number < block.number`.
720 #[cheatcode(group = Evm, safety = Unsafe)]
721 function setBlockhash(uint256 blockNumber, bytes32 blockHash) external;
722
723 /// Executes an RLP-encoded signed transaction with full EVM semantics (like `--isolate` mode).
724 /// The transaction is decoded from EIP-2718 format (type byte prefix + RLP payload) or legacy RLP.
725 /// Returns the execution output bytes.
726 ///
727 /// This cheatcode is not allowed in `forge script` contexts.
728 #[cheatcode(group = Evm, safety = Unsafe)]
729 function executeTransaction(bytes calldata rawTx) external returns (bytes memory);
730
731 // -------- Account State --------
732
733 /// Sets an address' balance.
734 #[cheatcode(group = Evm, safety = Unsafe)]
735 function deal(address account, uint256 newBalance) external;
736
737 /// Sets an address' code.
738 #[cheatcode(group = Evm, safety = Unsafe)]
739 function etch(address target, bytes calldata newRuntimeBytecode) external;
740
741 /// Resets the nonce of an account to 0 for EOAs and 1 for contract accounts.
742 #[cheatcode(group = Evm, safety = Unsafe)]
743 function resetNonce(address account) external;
744
745 /// Sets the nonce of an account. Must be higher than the current nonce of the account.
746 #[cheatcode(group = Evm, safety = Unsafe)]
747 function setNonce(address account, uint64 newNonce) external;
748
749 /// Sets the nonce of an account to an arbitrary value.
750 #[cheatcode(group = Evm, safety = Unsafe)]
751 function setNonceUnsafe(address account, uint64 newNonce) external;
752
753 /// Stores a value to an address' storage slot.
754 #[cheatcode(group = Evm, safety = Unsafe)]
755 function store(address target, bytes32 slot, bytes32 value) external;
756
757 /// Stores a value to an address' transient storage slot.
758 /// The value lasts until the end of the current transaction, like a value written with `TSTORE`.
759 /// This writes the journal directly rather than executing `TSTORE`.
760 /// With isolation enabled (the default), each top-level `CALL` from a test runs as its own
761 /// transaction with empty transient storage, so a value the test stored is not visible to that
762 /// call, even though a later `loadTransient` in the test still returns it. For the target to see
763 /// the value, store it and call the target inside the same call, for example through a helper.
764 /// `STATICCALL` and `DELEGATECALL` stay in the surrounding transaction and can see its values;
765 /// `DELEGATECALL` uses the caller's transient storage, not the target's.
766 /// Example usage, where `f` is non-view and `helper.storeAndCall` stores then calls `target.f()`:
767 /// vm.storeTransient(address(target), slot, value);
768 /// target.f(); // With isolation, `f` reads 0 from `slot`.
769 /// helper.storeAndCall(address(target), slot, value); // `f` reads `value`.
770 #[cheatcode(group = Evm, safety = Unsafe)]
771 function storeTransient(address target, bytes32 slot, bytes32 value) external;
772
773 /// Sets a TIP-20 token's logo URI directly in storage.
774 /// This bypasses the token admin check, but still validates the URI against T5 constraints.
775 #[cheatcode(group = Evm, safety = Unsafe)]
776 function setTip20LogoURI(address token, string calldata newLogoURI) external;
777
778 /// Sets a TIP-20 token's logo URI directly in storage.
779 /// This bypasses the token admin check, but still validates the URI against T5 constraints.
780 #[cheatcode(group = Evm, safety = Unsafe)]
781 function setLogoURI(address token, string calldata newLogoURI) external;
782
783 /// Marks the slots of an account and the account address as cold.
784 #[cheatcode(group = Evm, safety = Unsafe)]
785 function cool(address target) external;
786
787 /// Utility cheatcode to set an EIP-2930 access list for all subsequent transactions.
788 #[cheatcode(group = Evm, safety = Unsafe)]
789 function accessList(AccessListItem[] calldata access) external;
790
791 /// Utility cheatcode to remove any EIP-2930 access list set by `accessList` cheatcode.
792 #[cheatcode(group = Evm, safety = Unsafe)]
793 function noAccessList() external;
794
795 /// Utility cheatcode to mark specific storage slot as warm, simulating a prior read.
796 #[cheatcode(group = Evm, safety = Unsafe)]
797 function warmSlot(address target, bytes32 slot) external;
798
799 /// Utility cheatcode to mark specific storage slot as cold, simulating no prior read.
800 #[cheatcode(group = Evm, safety = Unsafe)]
801 function coolSlot(address target, bytes32 slot) external;
802
803 /// Returns true if isolated test execution is enabled.
804 #[cheatcode(group = Evm, safety = Safe)]
805 function isIsolateMode() external view returns (bool result);
806
807 /// Returns the test or script execution evm version.
808 ///
809 /// **Note:** The execution evm version is not the same as the compilation one.
810 #[cheatcode(group = Evm, safety = Safe)]
811 function getEvmVersion() external pure returns (string memory evm);
812
813 /// Selects the test or script execution hardfork, e.g. `berlin`, `cancun`, or `tempo:T7`.
814 /// Uses the active network's version mappings and gas schedule. Does not change the network
815 /// or Solidity compiler target. On Tempo, runtime changes do not rebuild instructions or
816 /// precompiles; configure `hardfork` before execution to select a different revision.
817 ///
818 /// **Note:** The execution evm version is not the same as the compilation one.
819 #[cheatcode(group = Evm, safety = Safe)]
820 function setEvmVersion(string calldata evm) external;
821
822 /// Returns `true` if `spender` is on the active Tempo hardfork's implicit-approval list,
823 /// meaning it can pull TIP-20 tokens from `msg.sender` without a prior `approve()`.
824 /// Returns `false` on non-Tempo networks.
825 #[cheatcode(group = Evm, safety = Safe)]
826 function isImplicitlyApproved(address spender) external view returns (bool implicitlyApproved);
827
828 /// Skips a fuzz/invariant input unless `spender` is implicitly approved.
829 #[cheatcode(group = Testing, safety = Safe)]
830 function assumeImplicitApproval(address spender) external view;
831
832 // -------- Call Manipulation --------
833 // --- Mocks ---
834
835 /// Clears all mocked calls.
836 #[cheatcode(group = Evm, safety = Unsafe)]
837 function clearMockedCalls() external;
838
839 /// Mocks a call to an address, returning specified data.
840 /// Calldata can either be strict or a partial match, e.g. if you only
841 /// pass a Solidity selector to the expected calldata, then the entire Solidity
842 /// function will be mocked.
843 #[cheatcode(group = Evm, safety = Unsafe)]
844 function mockCall(address callee, bytes calldata data, bytes calldata returnData) external;
845
846 /// Mocks a call to an address with a specific `msg.value`, returning specified data.
847 /// Calldata match takes precedence over `msg.value` in case of ambiguity.
848 #[cheatcode(group = Evm, safety = Unsafe)]
849 function mockCall(address callee, uint256 msgValue, bytes calldata data, bytes calldata returnData) external;
850
851 /// Mocks a call to an address, returning specified data.
852 /// Calldata can either be strict or a partial match, e.g. if you only
853 /// pass a Solidity selector to the expected calldata, then the entire Solidity
854 /// function will be mocked.
855 ///
856 /// Overload to pass the function selector directly `token.approve.selector` instead of `abi.encodeWithSelector(token.approve.selector)`.
857 #[cheatcode(group = Evm, safety = Unsafe)]
858 function mockCall(address callee, bytes4 data, bytes calldata returnData) external;
859
860 /// Mocks a call to an address with a specific `msg.value`, returning specified data.
861 /// Calldata match takes precedence over `msg.value` in case of ambiguity.
862 ///
863 /// Overload to pass the function selector directly `token.approve.selector` instead of `abi.encodeWithSelector(token.approve.selector)`.
864 #[cheatcode(group = Evm, safety = Unsafe)]
865 function mockCall(address callee, uint256 msgValue, bytes4 data, bytes calldata returnData) external;
866
867 /// Mocks a call to an address, returning specified data.
868 /// Calldata can either be strict or a partial match, e.g. if you only
869 /// pass a Solidity selector to the expected calldata, then the entire Solidity
870 /// function will be mocked.
871 ///
872 /// Overload to control whether code is injected into `callee`. The other overloads etch a
873 /// single byte into an empty account to circumvent Solidity's `extcodesize` check, with the
874 /// side effect that unmocked calls to it no longer revert; `injectCode = false` leaves the
875 /// account codeless, so unmocked calls to it revert in the caller. Mocked calls that return
876 /// data still succeed, as Solidity checks `returndatasize()` instead of `extcodesize()` when
877 /// return data is expected, but mocked calls to functions without return values may still
878 /// revert in the caller due to the `extcodesize` check.
879 #[cheatcode(group = Evm, safety = Unsafe)]
880 function mockCall(address callee, bytes calldata data, bytes calldata returnData, bool injectCode) external;
881
882 /// Mocks multiple calls to an address, returning specified data for each call.
883 #[cheatcode(group = Evm, safety = Unsafe)]
884 function mockCalls(address callee, bytes calldata data, bytes[] calldata returnData) external;
885
886 /// Mocks multiple calls to an address with a specific `msg.value`, returning specified data for each call.
887 #[cheatcode(group = Evm, safety = Unsafe)]
888 function mockCalls(address callee, uint256 msgValue, bytes calldata data, bytes[] calldata returnData) external;
889
890 /// Reverts a call to an address with specified revert data.
891 #[cheatcode(group = Evm, safety = Unsafe)]
892 function mockCallRevert(address callee, bytes calldata data, bytes calldata revertData) external;
893
894 /// Reverts a call to an address with a specific `msg.value`, with specified revert data.
895 #[cheatcode(group = Evm, safety = Unsafe)]
896 function mockCallRevert(address callee, uint256 msgValue, bytes calldata data, bytes calldata revertData)
897 external;
898
899 /// Reverts a call to an address with specified revert data.
900 ///
901 /// Overload to pass the function selector directly `token.approve.selector` instead of `abi.encodeWithSelector(token.approve.selector)`.
902 #[cheatcode(group = Evm, safety = Unsafe)]
903 function mockCallRevert(address callee, bytes4 data, bytes calldata revertData) external;
904
905 /// Reverts a call to an address with a specific `msg.value`, with specified revert data.
906 ///
907 /// Overload to pass the function selector directly `token.approve.selector` instead of `abi.encodeWithSelector(token.approve.selector)`.
908 #[cheatcode(group = Evm, safety = Unsafe)]
909 function mockCallRevert(address callee, uint256 msgValue, bytes4 data, bytes calldata revertData)
910 external;
911
912 /// Whenever a call is made to `callee` with calldata `data`, this cheatcode instead calls
913 /// `target` with the same calldata. This functionality is similar to a delegate call made to
914 /// `target` contract from `callee`.
915 /// Can be used to substitute a call to a function with another implementation that captures
916 /// the primary logic of the original function but is easier to reason about.
917 /// If no exact calldata match exists, a mock registered with only the 4-byte selector is
918 /// attempted.
919 #[cheatcode(group = Evm, safety = Unsafe)]
920 function mockFunction(address callee, address target, bytes calldata data) external;
921
922 // --- Impersonation (pranks) ---
923
924 /// Sets the *next* call's `msg.sender` to be the input address.
925 #[cheatcode(group = Evm, safety = Unsafe)]
926 function prank(address msgSender) external;
927
928 /// Sets all subsequent calls' `msg.sender` to be the input address until `stopPrank` is called.
929 #[cheatcode(group = Evm, safety = Unsafe)]
930 function startPrank(address msgSender) external;
931
932 /// Sets the *next* call's `msg.sender` to be the input address, and the `tx.origin` to be the second input.
933 #[cheatcode(group = Evm, safety = Unsafe)]
934 function prank(address msgSender, address txOrigin) external;
935
936 /// Sets all subsequent calls' `msg.sender` to be the input address until `stopPrank` is called, and the `tx.origin` to be the second input.
937 #[cheatcode(group = Evm, safety = Unsafe)]
938 function startPrank(address msgSender, address txOrigin) external;
939
940 /// Sets the *next* delegate call's `msg.sender` to be the input address.
941 #[cheatcode(group = Evm, safety = Unsafe)]
942 function prank(address msgSender, bool delegateCall) external;
943
944 /// Sets all subsequent delegate calls' `msg.sender` to be the input address until `stopPrank` is called.
945 #[cheatcode(group = Evm, safety = Unsafe)]
946 function startPrank(address msgSender, bool delegateCall) external;
947
948 /// Sets the *next* delegate call's `msg.sender` to be the input address, and the `tx.origin` to be the second input.
949 #[cheatcode(group = Evm, safety = Unsafe)]
950 function prank(address msgSender, address txOrigin, bool delegateCall) external;
951
952 /// Sets all subsequent delegate calls' `msg.sender` to be the input address until `stopPrank` is called, and the `tx.origin` to be the second input.
953 #[cheatcode(group = Evm, safety = Unsafe)]
954 function startPrank(address msgSender, address txOrigin, bool delegateCall) external;
955
956 /// Resets subsequent calls' `msg.sender` to be `address(this)`.
957 #[cheatcode(group = Evm, safety = Unsafe)]
958 function stopPrank() external;
959
960 /// Reads the current `msg.sender` and `tx.origin` from state and reports if there is any active caller modification.
961 #[cheatcode(group = Evm, safety = Unsafe)]
962 function readCallers() external view returns (CallerMode callerMode, address msgSender, address txOrigin);
963
964 // ----- Arbitrary Snapshots -----
965
966 /// Snapshot capture an arbitrary numerical value by name.
967 /// The group name is derived from the contract name.
968 #[cheatcode(group = Evm, safety = Unsafe)]
969 function snapshotValue(string calldata name, uint256 value) external;
970
971 /// Snapshot capture an arbitrary numerical value by name in a group.
972 #[cheatcode(group = Evm, safety = Unsafe)]
973 function snapshotValue(string calldata group, string calldata name, uint256 value) external;
974
975 // -------- Gas Snapshots --------
976
977 /// DEPRECATED: use `snapshotGasLastFrame` instead.
978 /// Snapshot capture the gas usage of the last call by name from the callee perspective.
979 /// Without isolation, measures regular counter consumption, including spillover but excluding reservoir-funded state gas.
980 /// Isolated frames with zero net state gas use receipt gas; see <https://getfoundry.sh/reference/cheatcodes/gas-snapshots>.
981 #[cheatcode(group = Evm, safety = Unsafe, status = Deprecated(Some("replaced by `snapshotGasLastFrame`")))]
982 function snapshotGasLastCall(string calldata name) external returns (uint256 gasUsed);
983
984 /// DEPRECATED: use `snapshotGasLastFrame` instead.
985 /// Snapshot capture the gas usage of the last call by name in a group from the callee perspective.
986 /// Without isolation, measures regular counter consumption, including spillover but excluding reservoir-funded state gas.
987 /// Isolated frames with zero net state gas use receipt gas; see <https://getfoundry.sh/reference/cheatcodes/gas-snapshots>.
988 #[cheatcode(group = Evm, safety = Unsafe, status = Deprecated(Some("replaced by `snapshotGasLastFrame`")))]
989 function snapshotGasLastCall(string calldata group, string calldata name) external returns (uint256 gasUsed);
990
991 /// Snapshot capture the gas usage of the last call or create by name from the callee perspective.
992 /// Without isolation, measures regular counter consumption, including spillover but excluding reservoir-funded state gas.
993 /// Isolated frames with zero net state gas use receipt gas; see <https://getfoundry.sh/reference/cheatcodes/gas-snapshots>.
994 #[cheatcode(group = Evm, safety = Unsafe)]
995 function snapshotGasLastFrame(string calldata name) external returns (uint256 gasUsed);
996
997 /// Snapshot capture the gas usage of the last call or create by name in a group from the callee perspective.
998 /// Without isolation, measures regular counter consumption, including spillover but excluding reservoir-funded state gas.
999 /// Isolated frames with zero net state gas use receipt gas; see <https://getfoundry.sh/reference/cheatcodes/gas-snapshots>.
1000 #[cheatcode(group = Evm, safety = Unsafe)]
1001 function snapshotGasLastFrame(string calldata group, string calldata name) external returns (uint256 gasUsed);
1002
1003 /// Start a snapshot capture of the current gas usage by name.
1004 /// The group name is derived from the contract name.
1005 /// Measures gas consumed from the regular counter, including state spillover but excluding reservoir-funded state gas.
1006 #[cheatcode(group = Evm, safety = Unsafe)]
1007 function startSnapshotGas(string calldata name) external;
1008
1009 /// Start a snapshot capture of the current gas usage by name in a group.
1010 /// Measures gas consumed from the regular counter, including state spillover but excluding reservoir-funded state gas.
1011 #[cheatcode(group = Evm, safety = Unsafe)]
1012 function startSnapshotGas(string calldata group, string calldata name) external;
1013
1014 /// Stop the snapshot capture of the current gas by latest snapshot name, capturing the gas used since the start.
1015 /// Measures gas consumed from the regular counter, including state spillover but excluding reservoir-funded state gas.
1016 #[cheatcode(group = Evm, safety = Unsafe)]
1017 function stopSnapshotGas() external returns (uint256 gasUsed);
1018
1019 /// Stop the snapshot capture of the current gas usage by name, capturing the gas used since the start.
1020 /// The group name is derived from the contract name.
1021 /// Measures gas consumed from the regular counter, including state spillover but excluding reservoir-funded state gas.
1022 #[cheatcode(group = Evm, safety = Unsafe)]
1023 function stopSnapshotGas(string calldata name) external returns (uint256 gasUsed);
1024
1025 /// Stop the snapshot capture of the current gas usage by name in a group, capturing the gas used since the start.
1026 /// Measures gas consumed from the regular counter, including state spillover but excluding reservoir-funded state gas.
1027 #[cheatcode(group = Evm, safety = Unsafe)]
1028 function stopSnapshotGas(string calldata group, string calldata name) external returns (uint256 gasUsed);
1029
1030 // -------- State Snapshots --------
1031
1032 /// `snapshot` is being deprecated in favor of `snapshotState`. It will be removed in future versions.
1033 #[cheatcode(group = Evm, safety = Unsafe, status = Deprecated(Some("replaced by `snapshotState`")))]
1034 function snapshot() external returns (uint256 snapshotId);
1035
1036 /// Snapshot the current state of the evm.
1037 /// Returns the ID of the snapshot that was created.
1038 /// To revert a snapshot use `revertToState`.
1039 #[cheatcode(group = Evm, safety = Unsafe)]
1040 function snapshotState() external returns (uint256 snapshotId);
1041
1042 /// `revertTo` is being deprecated in favor of `revertToState`. It will be removed in future versions.
1043 #[cheatcode(group = Evm, safety = Unsafe, status = Deprecated(Some("replaced by `revertToState`")))]
1044 function revertTo(uint256 snapshotId) external returns (bool success);
1045
1046 /// Revert the state of the EVM to a previous snapshot
1047 /// Takes the snapshot ID to revert to.
1048 ///
1049 /// Returns `true` if the snapshot was successfully reverted.
1050 /// Returns `false` if the snapshot does not exist.
1051 ///
1052 /// **Note:** This does not automatically delete the snapshot. To delete the snapshot use `deleteStateSnapshot`.
1053 #[cheatcode(group = Evm, safety = Unsafe)]
1054 function revertToState(uint256 snapshotId) external returns (bool success);
1055
1056 /// `revertToAndDelete` is being deprecated in favor of `revertToStateAndDelete`. It will be removed in future versions.
1057 #[cheatcode(group = Evm, safety = Unsafe, status = Deprecated(Some("replaced by `revertToStateAndDelete`")))]
1058 function revertToAndDelete(uint256 snapshotId) external returns (bool success);
1059
1060 /// Revert the state of the EVM to a previous snapshot and automatically deletes the snapshots
1061 /// Takes the snapshot ID to revert to.
1062 ///
1063 /// Returns `true` if the snapshot was successfully reverted and deleted.
1064 /// Returns `false` if the snapshot does not exist.
1065 #[cheatcode(group = Evm, safety = Unsafe)]
1066 function revertToStateAndDelete(uint256 snapshotId) external returns (bool success);
1067
1068 /// `deleteSnapshot` is being deprecated in favor of `deleteStateSnapshot`. It will be removed in future versions.
1069 #[cheatcode(group = Evm, safety = Unsafe, status = Deprecated(Some("replaced by `deleteStateSnapshot`")))]
1070 function deleteSnapshot(uint256 snapshotId) external returns (bool success);
1071
1072 /// Removes the snapshot with the given ID created by `snapshot`.
1073 /// Takes the snapshot ID to delete.
1074 ///
1075 /// Returns `true` if the snapshot was successfully deleted.
1076 /// Returns `false` if the snapshot does not exist.
1077 #[cheatcode(group = Evm, safety = Unsafe)]
1078 function deleteStateSnapshot(uint256 snapshotId) external returns (bool success);
1079
1080 /// `deleteSnapshots` is being deprecated in favor of `deleteStateSnapshots`. It will be removed in future versions.
1081 #[cheatcode(group = Evm, safety = Unsafe, status = Deprecated(Some("replaced by `deleteStateSnapshots`")))]
1082 function deleteSnapshots() external;
1083
1084 /// Removes _all_ snapshots previously created by `snapshot`.
1085 #[cheatcode(group = Evm, safety = Unsafe)]
1086 function deleteStateSnapshots() external;
1087
1088 // -------- Forking --------
1089 // --- Creation and Selection ---
1090
1091 /// Returns the identifier of the currently active fork. Reverts if no fork is currently active.
1092 #[cheatcode(group = Evm, safety = Unsafe)]
1093 function activeFork() external view returns (uint256 forkId);
1094
1095 /// Creates a new fork with the given endpoint and the _latest_ block and returns the identifier of the fork.
1096 #[cheatcode(group = Evm, safety = Unsafe)]
1097 function createFork(string calldata urlOrAlias) external returns (uint256 forkId);
1098 /// Creates a new fork with the given endpoint and block and returns the identifier of the fork.
1099 #[cheatcode(group = Evm, safety = Unsafe)]
1100 function createFork(string calldata urlOrAlias, uint256 blockNumber) external returns (uint256 forkId);
1101 /// Creates a new fork with the given endpoint and at the block the given transaction was mined in,
1102 /// replays all transaction mined in the block before the transaction, and returns the identifier of the fork.
1103 #[cheatcode(group = Evm, safety = Unsafe)]
1104 function createFork(string calldata urlOrAlias, bytes32 txHash) external returns (uint256 forkId);
1105
1106 /// Creates and also selects a new fork with the given endpoint and the latest block and returns the identifier of the fork.
1107 #[cheatcode(group = Evm, safety = Unsafe)]
1108 function createSelectFork(string calldata urlOrAlias) external returns (uint256 forkId);
1109 /// Creates and also selects a new fork with the given endpoint and block and returns the identifier of the fork.
1110 #[cheatcode(group = Evm, safety = Unsafe)]
1111 function createSelectFork(string calldata urlOrAlias, uint256 blockNumber) external returns (uint256 forkId);
1112 /// Creates and also selects new fork with the given endpoint and at the block the given transaction was mined in,
1113 /// replays all transaction mined in the block before the transaction, returns the identifier of the fork.
1114 #[cheatcode(group = Evm, safety = Unsafe)]
1115 function createSelectFork(string calldata urlOrAlias, bytes32 txHash) external returns (uint256 forkId);
1116
1117 /// Updates the currently active fork to given block number
1118 /// This is similar to `roll` but for the currently active fork.
1119 #[cheatcode(group = Evm, safety = Unsafe)]
1120 function rollFork(uint256 blockNumber) external;
1121 /// Updates the currently active fork to given transaction. This will `rollFork` with the number
1122 /// of the block the transaction was mined in and replays all transaction mined before it in the block.
1123 #[cheatcode(group = Evm, safety = Unsafe)]
1124 function rollFork(bytes32 txHash) external;
1125 /// Updates the given fork to given block number.
1126 #[cheatcode(group = Evm, safety = Unsafe)]
1127 function rollFork(uint256 forkId, uint256 blockNumber) external;
1128 /// Updates the given fork to block number of the given transaction and replays all transaction mined before it in the block.
1129 #[cheatcode(group = Evm, safety = Unsafe)]
1130 function rollFork(uint256 forkId, bytes32 txHash) external;
1131
1132 /// Takes a fork identifier created by `createFork` and sets the corresponding forked state as active.
1133 #[cheatcode(group = Evm, safety = Unsafe)]
1134 function selectFork(uint256 forkId) external;
1135
1136 /// Fetches the given transaction from the active fork and executes it on the current state.
1137 #[cheatcode(group = Evm, safety = Unsafe)]
1138 function transact(bytes32 txHash) external;
1139 /// Fetches the given transaction from the given fork and executes it on the current state.
1140 #[cheatcode(group = Evm, safety = Unsafe)]
1141 function transact(uint256 forkId, bytes32 txHash) external;
1142
1143 /// Performs an Ethereum JSON-RPC request to the current fork URL.
1144 #[cheatcode(group = Evm, safety = Safe)]
1145 function rpc(string calldata method, string calldata params) external returns (bytes memory data);
1146
1147 /// Performs an Ethereum JSON-RPC request to the given endpoint.
1148 #[cheatcode(group = Evm, safety = Safe)]
1149 function rpc(string calldata urlOrAlias, string calldata method, string calldata params)
1150 external
1151 returns (bytes memory data);
1152
1153 /// Performs an Ethereum JSON-RPC request to the current fork URL and returns the JSON result.
1154 #[cheatcode(group = Evm, safety = Safe)]
1155 function rpcJson(string calldata method, string calldata params) external returns (string memory data);
1156
1157 /// Performs an Ethereum JSON-RPC request to the given endpoint and returns the JSON result.
1158 #[cheatcode(group = Evm, safety = Safe)]
1159 function rpcJson(string calldata urlOrAlias, string calldata method, string calldata params)
1160 external
1161 returns (string memory data);
1162
1163 /// Gets all the logs according to specified filter.
1164 #[cheatcode(group = Evm, safety = Safe)]
1165 function eth_getLogs(uint256 fromBlock, uint256 toBlock, address target, bytes32[] calldata topics)
1166 external
1167 view
1168 returns (EthGetLogs[] memory logs);
1169
1170 /// Gets the EIP-1186 account and storage proof of `target` at `blockNumber` from the active fork.
1171 /// The proof is fetched from the fork's RPC endpoint and does not reflect local state changes.
1172 #[cheatcode(group = Evm, safety = Safe)]
1173 function eth_getProof(address target, bytes32[] calldata slots, uint256 blockNumber)
1174 external
1175 view
1176 returns (EthGetProof memory proof);
1177
1178 // --- Behavior ---
1179
1180 /// In forking mode, explicitly grant the given address cheatcode access.
1181 #[cheatcode(group = Evm, safety = Unsafe)]
1182 function allowCheatcodes(address account) external;
1183
1184 /// Marks that the account(s) should use persistent storage across fork swaps in a multifork setup
1185 /// Meaning, changes made to the state of this account will be kept when switching forks.
1186 #[cheatcode(group = Evm, safety = Unsafe)]
1187 function makePersistent(address account) external;
1188 /// See `makePersistent(address)`.
1189 #[cheatcode(group = Evm, safety = Unsafe)]
1190 function makePersistent(address account0, address account1) external;
1191 /// See `makePersistent(address)`.
1192 #[cheatcode(group = Evm, safety = Unsafe)]
1193 function makePersistent(address account0, address account1, address account2) external;
1194 /// See `makePersistent(address)`.
1195 #[cheatcode(group = Evm, safety = Unsafe)]
1196 function makePersistent(address[] calldata accounts) external;
1197
1198 /// Revokes persistent status from the address, previously added via `makePersistent`.
1199 #[cheatcode(group = Evm, safety = Unsafe)]
1200 function revokePersistent(address account) external;
1201 /// See `revokePersistent(address)`.
1202 #[cheatcode(group = Evm, safety = Unsafe)]
1203 function revokePersistent(address[] calldata accounts) external;
1204
1205 /// Returns true if the account is marked as persistent.
1206 #[cheatcode(group = Evm, safety = Unsafe)]
1207 function isPersistent(address account) external view returns (bool persistent);
1208
1209 // -------- Record Logs --------
1210
1211 /// Record all the transaction logs. Logs emitted by calls or contract creations that revert or
1212 /// halt are discarded, including reverts expected with `expectRevert`.
1213 #[cheatcode(group = Evm, safety = Safe)]
1214 function recordLogs() external;
1215
1216 /// Gets all the recorded logs.
1217 #[cheatcode(group = Evm, safety = Safe)]
1218 function getRecordedLogs() external view returns (Log[] memory logs);
1219
1220 /// Gets all the recorded logs, in JSON format.
1221 #[cheatcode(group = Evm, safety = Safe)]
1222 function getRecordedLogsJson() external view returns (string memory logsJson);
1223
1224 // -------- Gas Metering --------
1225
1226 // It's recommend to use the `noGasMetering` modifier included with forge-std, instead of
1227 // using these functions directly.
1228
1229 /// Pauses gas metering (i.e. gas usage is not counted). Noop if already paused.
1230 #[cheatcode(group = Evm, safety = Safe)]
1231 function pauseGasMetering() external;
1232
1233 /// Resumes gas metering (i.e. gas usage is counted again). Noop if already on.
1234 #[cheatcode(group = Evm, safety = Safe)]
1235 function resumeGasMetering() external;
1236
1237 /// Reset gas metering (i.e. gas usage is set to gas limit).
1238 #[cheatcode(group = Evm, safety = Safe)]
1239 function resetGasMetering() external;
1240
1241 // -------- Gas Measurement --------
1242
1243 /// DEPRECATED: use `lastFrameGas` instead.
1244 /// Gets gas measurements for the last completed call, from the callee's perspective.
1245 /// Unlike `lastFrameGas`, CREATE and CREATE2 frames are not recorded; calls made by a constructor are.
1246 /// See `Gas` for field semantics.
1247 #[cheatcode(group = Evm, safety = Safe, status = Deprecated(Some("replaced by `lastFrameGas`")))]
1248 function lastCallGas() external view returns (Gas memory gas);
1249
1250 /// Gets gas measurements for the last completed call or create, from the callee's perspective.
1251 /// Unlike `lastCallGas`, CREATE and CREATE2 frames are recorded too. Cheatcode calls are never recorded.
1252 /// See `Gas` for field semantics and <https://getfoundry.sh/reference/cheatcodes/last-frame-gas>.
1253 #[cheatcode(group = Evm, safety = Safe)]
1254 function lastFrameGas() external view returns (Gas memory gas);
1255
1256 // ======== Test Assertions and Utilities ========
1257
1258 /// If the condition is false, discard this run's fuzz inputs and generate new ones.
1259 #[cheatcode(group = Testing, safety = Safe)]
1260 function assume(bool condition) external pure;
1261
1262 /// Discard this run's fuzz inputs and generate new ones if next call reverted.
1263 #[cheatcode(group = Testing, safety = Safe)]
1264 function assumeNoRevert() external pure;
1265
1266 /// Discard this run's fuzz inputs and generate new ones if next call reverts with the potential revert parameters.
1267 #[cheatcode(group = Testing, safety = Safe)]
1268 function assumeNoRevert(PotentialRevert calldata potentialRevert) external pure;
1269
1270 /// Discard this run's fuzz inputs and generate new ones if next call reverts with the any of the potential revert parameters.
1271 #[cheatcode(group = Testing, safety = Safe)]
1272 function assumeNoRevert(PotentialRevert[] calldata potentialReverts) external pure;
1273
1274 /// Writes a breakpoint to jump to in the debugger.
1275 #[cheatcode(group = Testing, safety = Safe)]
1276 function breakpoint(string calldata char) external pure;
1277
1278 /// Writes a conditional breakpoint to jump to in the debugger.
1279 #[cheatcode(group = Testing, safety = Safe)]
1280 function breakpoint(string calldata char, bool value) external pure;
1281
1282 /// Returns the Foundry version.
1283 /// Format: <cargo_version>-<tag>+<git_sha_short>.<unix_build_timestamp>.<profile>
1284 /// Sample output: 0.3.0-nightly+3cb96bde9b.1737036656.debug
1285 /// Note: Build timestamps may vary slightly across platforms due to separate CI jobs.
1286 /// For reliable version comparisons, use UNIX format (e.g., >= 1700000000)
1287 /// to compare timestamps while ignoring minor time differences.
1288 #[cheatcode(group = Testing, safety = Safe)]
1289 function getFoundryVersion() external view returns (string memory version);
1290
1291 /// Returns the RPC url for the given alias.
1292 #[cheatcode(group = Testing, safety = Safe)]
1293 function rpcUrl(string calldata rpcAlias) external view returns (string memory json);
1294
1295 /// Returns all rpc urls and their aliases `[alias, url][]`.
1296 #[cheatcode(group = Testing, safety = Safe)]
1297 function rpcUrls() external view returns (string[2][] memory urls);
1298
1299 /// Returns all rpc urls and their aliases as structs.
1300 #[cheatcode(group = Testing, safety = Safe)]
1301 function rpcUrlStructs() external view returns (Rpc[] memory urls);
1302
1303 /// Returns a Chain struct for specific alias
1304 #[cheatcode(group = Testing, safety = Safe)]
1305 function getChain(string calldata chainAlias) external view returns (Chain memory chain);
1306
1307 /// Returns a Chain struct for specific chainId
1308 #[cheatcode(group = Testing, safety = Safe)]
1309 function getChain(uint256 chainId) external view returns (Chain memory chain);
1310
1311 /// Suspends execution of the main thread for `duration` milliseconds.
1312 #[cheatcode(group = Testing, safety = Safe)]
1313 function sleep(uint256 duration) external;
1314
1315 /// Expects a call to an address with the specified calldata.
1316 /// Calldata can either be a strict or a partial match.
1317 #[cheatcode(group = Testing, safety = Unsafe)]
1318 function expectCall(address callee, bytes calldata data) external;
1319
1320 /// Expects given number of calls to an address with the specified calldata.
1321 #[cheatcode(group = Testing, safety = Unsafe)]
1322 function expectCall(address callee, bytes calldata data, uint64 count) external;
1323
1324 /// Expects a call to an address with the specified `msg.value` and calldata.
1325 #[cheatcode(group = Testing, safety = Unsafe)]
1326 function expectCall(address callee, uint256 msgValue, bytes calldata data) external;
1327
1328 /// Expects given number of calls to an address with the specified `msg.value` and calldata.
1329 #[cheatcode(group = Testing, safety = Unsafe)]
1330 function expectCall(address callee, uint256 msgValue, bytes calldata data, uint64 count) external;
1331
1332 /// Expect a call to an address with the specified `msg.value`, gas, and calldata.
1333 #[cheatcode(group = Testing, safety = Unsafe)]
1334 function expectCall(address callee, uint256 msgValue, uint64 gas, bytes calldata data) external;
1335
1336 /// Expects given number of calls to an address with the specified `msg.value`, gas, and calldata.
1337 #[cheatcode(group = Testing, safety = Unsafe)]
1338 function expectCall(address callee, uint256 msgValue, uint64 gas, bytes calldata data, uint64 count) external;
1339
1340 /// Expects a delegate call to an address with the specified calldata.
1341 /// Calldata can either be a strict or a partial match.
1342 #[cheatcode(group = Testing, safety = Unsafe)]
1343 function expectDelegateCall(address callee, bytes calldata data) external;
1344
1345 /// Expect a call to an address with the specified `msg.value` and calldata, and a *minimum* amount of gas.
1346 #[cheatcode(group = Testing, safety = Unsafe)]
1347 function expectCallMinGas(address callee, uint256 msgValue, uint64 minGas, bytes calldata data) external;
1348
1349 /// Expect given number of calls to an address with the specified `msg.value` and calldata, and a *minimum* amount of gas.
1350 #[cheatcode(group = Testing, safety = Unsafe)]
1351 function expectCallMinGas(address callee, uint256 msgValue, uint64 minGas, bytes calldata data, uint64 count)
1352 external;
1353
1354 /// Prepare an expected log with (bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData.).
1355 /// Call this function, then emit an event, then call a function. Internally after the call, we check if
1356 /// logs were emitted in the expected order with the expected topics and data (as specified by the booleans).
1357 /// Must be placed immediately before the call you want to assert on. If the next call reverts and the
1358 /// revert is caught by the caller (low-level call or try/catch), the expectation remains active and may
1359 /// be satisfied by a log emitted from a later call.
1360 #[cheatcode(group = Testing, safety = Unsafe)]
1361 function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData) external;
1362
1363 /// Same as the previous method, but also checks supplied address against emitting contract.
1364 #[cheatcode(group = Testing, safety = Unsafe)]
1365 function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, address emitter)
1366 external;
1367
1368 /// Prepare an expected log with all topic and data checks enabled.
1369 /// Call this function, then emit an event, then call a function. Internally after the call, we check if
1370 /// logs were emitted in the expected order with the expected topics and data.
1371 /// Must be placed immediately before the call you want to assert on. If the next call reverts and the
1372 /// revert is caught by the caller (low-level call or try/catch), the expectation remains active and may
1373 /// be satisfied by a log emitted from a later call.
1374 #[cheatcode(group = Testing, safety = Unsafe)]
1375 function expectEmit() external;
1376
1377 /// Same as the previous method, but also checks supplied address against emitting contract.
1378 #[cheatcode(group = Testing, safety = Unsafe)]
1379 function expectEmit(address emitter) external;
1380
1381 /// Expect a given number of logs with the provided topics.
1382 #[cheatcode(group = Testing, safety = Unsafe)]
1383 function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, uint64 count) external;
1384
1385 /// Expect a given number of logs from a specific emitter with the provided topics.
1386 #[cheatcode(group = Testing, safety = Unsafe)]
1387 function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, address emitter, uint64 count)
1388 external;
1389
1390 /// Expect a given number of logs with all topic and data checks enabled.
1391 #[cheatcode(group = Testing, safety = Unsafe)]
1392 function expectEmit(uint64 count) external;
1393
1394 /// Expect a given number of logs from a specific emitter with all topic and data checks enabled.
1395 #[cheatcode(group = Testing, safety = Unsafe)]
1396 function expectEmit(address emitter, uint64 count) external;
1397
1398 /// Prepare an expected anonymous log with (bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData.).
1399 /// Call this function, then emit an anonymous event, then call a function. Internally after the call, we check if
1400 /// logs were emitted in the expected order with the expected topics and data (as specified by the booleans).
1401 #[cheatcode(group = Testing, safety = Unsafe)]
1402 function expectEmitAnonymous(bool checkTopic0, bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData) external;
1403
1404 /// Same as the previous method, but also checks supplied address against emitting contract.
1405 #[cheatcode(group = Testing, safety = Unsafe)]
1406 function expectEmitAnonymous(bool checkTopic0, bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, address emitter)
1407 external;
1408
1409 /// Prepare an expected anonymous log with all topic and data checks enabled.
1410 /// Call this function, then emit an anonymous event, then call a function. Internally after the call, we check if
1411 /// logs were emitted in the expected order with the expected topics and data.
1412 #[cheatcode(group = Testing, safety = Unsafe)]
1413 function expectEmitAnonymous() external;
1414
1415 /// Same as the previous method, but also checks supplied address against emitting contract.
1416 #[cheatcode(group = Testing, safety = Unsafe)]
1417 function expectEmitAnonymous(address emitter) external;
1418
1419 /// Expects the deployment of the specified bytecode by the specified address using the CREATE opcode
1420 #[cheatcode(group = Testing, safety = Unsafe)]
1421 function expectCreate(bytes calldata bytecode, address deployer) external;
1422
1423 /// Expects the deployment of the specified bytecode by the specified address using the CREATE2 opcode
1424 #[cheatcode(group = Testing, safety = Unsafe)]
1425 function expectCreate2(bytes calldata bytecode, address deployer) external;
1426
1427 /// Expects a TIP-20 `LogoURIUpdated(address indexed updater, string newLogoURI)` event.
1428 #[cheatcode(group = Testing, safety = Unsafe)]
1429 function expectTip20LogoURIUpdated(address token, address updater, string calldata newLogoURI) external;
1430
1431 /// Expects a call to `SignatureVerifier.verifyKeychain(account, digest, signature)`.
1432 #[cheatcode(group = Testing, safety = Unsafe)]
1433 function expectKeychainVerified(address account, bytes32 digest, bytes calldata signature) external;
1434
1435 /// Expects a call to `SignatureVerifier.verifyKeychainAdmin(account, digest, signature)`.
1436 ///
1437 /// The supplied `digest` should already be domain-separated with chain ID, contract address,
1438 /// and account address.
1439 #[cheatcode(group = Testing, safety = Unsafe, status = Deprecated(Some("TIP-1137 stops admin keys at Tempo T14")))]
1440 function expectKeychainAdminVerified(address account, bytes32 digest, bytes calldata signature) external;
1441
1442 /// Expects a TIP-20 `LogoURIUpdated(address indexed updater, string newLogoURI)` event.
1443 #[cheatcode(group = Testing, safety = Unsafe)]
1444 function expectLogoURIUpdated(address token, address updater, string calldata newLogoURI) external;
1445
1446 /// Expects an error on next call with any revert data.
1447 #[cheatcode(group = Testing, safety = Unsafe)]
1448 function expectRevert() external;
1449
1450 /// Expects an error on next call that exactly matches the revert data.
1451 #[cheatcode(group = Testing, safety = Unsafe)]
1452 function expectRevert(bytes4 revertData) external;
1453
1454 /// Expects an error on next call that exactly matches the revert data.
1455 #[cheatcode(group = Testing, safety = Unsafe)]
1456 function expectRevert(bytes calldata revertData) external;
1457
1458 /// Expects an error with any revert data on next call to reverter address.
1459 ///
1460 /// The `reverter` argument is matched against the address associated with
1461 /// the frame that produced the revert:
1462 /// - For a CALL: the address that was called.
1463 /// - For a CREATE / CREATE2: the would-be deployed address of the failed
1464 /// deployment (computed from the deployer + nonce, or salt + initcode).
1465 ///
1466 /// For a single expected revert, the innermost reverting frame wins in
1467 /// nested CALL, CREATE, or mixed chains. With `count > 1`, nested
1468 /// CREATE / CREATE2 chains apply the same rule independently to each
1469 /// iteration; nested CALL chains keep their existing
1470 /// outermost-call-per-iteration behavior.
1471 #[cheatcode(group = Testing, safety = Unsafe)]
1472 function expectRevert(address reverter) external;
1473
1474 /// Expects an error from reverter address on next call, with any revert data.
1475 /// See `expectRevert(address)` for `reverter` matching semantics.
1476 #[cheatcode(group = Testing, safety = Unsafe)]
1477 function expectRevert(bytes4 revertData, address reverter) external;
1478
1479 /// Expects an error from reverter address on next call, that exactly matches the revert data.
1480 /// See `expectRevert(address)` for `reverter` matching semantics.
1481 #[cheatcode(group = Testing, safety = Unsafe)]
1482 function expectRevert(bytes calldata revertData, address reverter) external;
1483
1484 /// Expects a `count` number of reverts from the upcoming calls with any revert data or reverter.
1485 #[cheatcode(group = Testing, safety = Unsafe)]
1486 function expectRevert(uint64 count) external;
1487
1488 /// Expects a `count` number of reverts from the upcoming calls that match the revert data.
1489 #[cheatcode(group = Testing, safety = Unsafe)]
1490 function expectRevert(bytes4 revertData, uint64 count) external;
1491
1492 /// Expects a `count` number of reverts from the upcoming calls that exactly match the revert data.
1493 #[cheatcode(group = Testing, safety = Unsafe)]
1494 function expectRevert(bytes calldata revertData, uint64 count) external;
1495
1496 /// Expects a `count` number of reverts from the upcoming calls from the reverter address.
1497 /// See `expectRevert(address)` for `reverter` matching semantics.
1498 #[cheatcode(group = Testing, safety = Unsafe)]
1499 function expectRevert(address reverter, uint64 count) external;
1500
1501 /// Expects a `count` number of reverts from the upcoming calls from the reverter address that match the revert data.
1502 /// See `expectRevert(address)` for `reverter` matching semantics.
1503 #[cheatcode(group = Testing, safety = Unsafe)]
1504 function expectRevert(bytes4 revertData, address reverter, uint64 count) external;
1505
1506 /// Expects a `count` number of reverts from the upcoming calls from the reverter address that exactly match the revert data.
1507 /// See `expectRevert(address)` for `reverter` matching semantics.
1508 #[cheatcode(group = Testing, safety = Unsafe)]
1509 function expectRevert(bytes calldata revertData, address reverter, uint64 count) external;
1510
1511 /// Expects an error on next call that starts with the revert data.
1512 #[cheatcode(group = Testing, safety = Unsafe)]
1513 function expectPartialRevert(bytes4 revertData) external;
1514
1515 /// Expects an error on next call to reverter address, that starts with the revert data.
1516 /// See `expectRevert(address)` for `reverter` matching semantics.
1517 #[cheatcode(group = Testing, safety = Unsafe)]
1518 function expectPartialRevert(bytes4 revertData, address reverter) external;
1519
1520 /// Expects an error on next cheatcode call with any revert data.
1521 #[cheatcode(group = Testing, safety = Unsafe, status = Internal)]
1522 function _expectCheatcodeRevert() external;
1523
1524 /// Expects an error on next cheatcode call that starts with the revert data.
1525 #[cheatcode(group = Testing, safety = Unsafe, status = Internal)]
1526 function _expectCheatcodeRevert(bytes4 revertData) external;
1527
1528 /// Expects an error on next cheatcode call that contains the revert data.
1529 #[cheatcode(group = Testing, safety = Unsafe, status = Internal)]
1530 function _expectCheatcodeRevert(bytes calldata revertData) external;
1531
1532 /// Only allows memory writes to offsets [0x00, 0x60) ∪ [min, max) in the current subcontext. If any other
1533 /// memory is written to, the test will fail. Can be called multiple times to add more ranges to the set.
1534 #[cheatcode(group = Testing, safety = Unsafe)]
1535 function expectSafeMemory(uint64 min, uint64 max) external;
1536
1537 /// Stops all safe memory expectation in the current subcontext.
1538 #[cheatcode(group = Testing, safety = Unsafe)]
1539 function stopExpectSafeMemory() external;
1540
1541 /// Only allows memory writes to offsets [0x00, 0x60) ∪ [min, max) in the next created subcontext.
1542 /// If any other memory is written to, the test will fail. Can be called multiple times to add more ranges
1543 /// to the set.
1544 #[cheatcode(group = Testing, safety = Unsafe)]
1545 function expectSafeMemoryCall(uint64 min, uint64 max) external;
1546
1547 /// Marks a test as skipped. Must be called at the top level of a test.
1548 #[cheatcode(group = Testing, safety = Unsafe)]
1549 function skip(bool skipTest) external;
1550
1551 /// Marks a test as skipped with a reason. Must be called at the top level of a test.
1552 #[cheatcode(group = Testing, safety = Unsafe)]
1553 function skip(bool skipTest, string calldata reason) external;
1554
1555 /// Asserts that the given condition is true.
1556 #[cheatcode(group = Testing, safety = Safe)]
1557 function assertTrue(bool condition) external pure;
1558
1559 /// Asserts that the given condition is true and includes error message into revert string on failure.
1560 #[cheatcode(group = Testing, safety = Safe)]
1561 function assertTrue(bool condition, string calldata err) external pure;
1562
1563 /// Asserts that the given condition is false.
1564 #[cheatcode(group = Testing, safety = Safe)]
1565 function assertFalse(bool condition) external pure;
1566
1567 /// Asserts that the given condition is false and includes error message into revert string on failure.
1568 #[cheatcode(group = Testing, safety = Safe)]
1569 function assertFalse(bool condition, string calldata err) external pure;
1570
1571 /// Asserts that two `bool` values are equal.
1572 #[cheatcode(group = Testing, safety = Safe)]
1573 function assertEq(bool left, bool right) external pure;
1574
1575 /// Asserts that two `bool` values are equal and includes error message into revert string on failure.
1576 #[cheatcode(group = Testing, safety = Safe)]
1577 function assertEq(bool left, bool right, string calldata err) external pure;
1578
1579 /// Asserts that two `uint256` values are equal.
1580 #[cheatcode(group = Testing, safety = Safe)]
1581 function assertEq(uint256 left, uint256 right) external pure;
1582
1583 /// Asserts that two `uint256` values are equal and includes error message into revert string on failure.
1584 #[cheatcode(group = Testing, safety = Safe)]
1585 function assertEq(uint256 left, uint256 right, string calldata err) external pure;
1586
1587 /// Asserts that two `int256` values are equal.
1588 #[cheatcode(group = Testing, safety = Safe)]
1589 function assertEq(int256 left, int256 right) external pure;
1590
1591 /// Asserts that two `int256` values are equal and includes error message into revert string on failure.
1592 #[cheatcode(group = Testing, safety = Safe)]
1593 function assertEq(int256 left, int256 right, string calldata err) external pure;
1594
1595 /// Asserts that two `address` values are equal.
1596 #[cheatcode(group = Testing, safety = Safe)]
1597 function assertEq(address left, address right) external pure;
1598
1599 /// Asserts that two `address` values are equal and includes error message into revert string on failure.
1600 #[cheatcode(group = Testing, safety = Safe)]
1601 function assertEq(address left, address right, string calldata err) external pure;
1602
1603 /// Asserts that two `bytes32` values are equal.
1604 #[cheatcode(group = Testing, safety = Safe)]
1605 function assertEq(bytes32 left, bytes32 right) external pure;
1606
1607 /// Asserts that two `bytes32` values are equal and includes error message into revert string on failure.
1608 #[cheatcode(group = Testing, safety = Safe)]
1609 function assertEq(bytes32 left, bytes32 right, string calldata err) external pure;
1610
1611 /// Asserts that two `string` values are equal.
1612 #[cheatcode(group = Testing, safety = Safe)]
1613 function assertEq(string calldata left, string calldata right) external pure;
1614
1615 /// Asserts that two `string` values are equal and includes error message into revert string on failure.
1616 #[cheatcode(group = Testing, safety = Safe)]
1617 function assertEq(string calldata left, string calldata right, string calldata err) external pure;
1618
1619 /// Asserts that two `bytes` values are equal.
1620 #[cheatcode(group = Testing, safety = Safe)]
1621 function assertEq(bytes calldata left, bytes calldata right) external pure;
1622
1623 /// Asserts that two `bytes` values are equal and includes error message into revert string on failure.
1624 #[cheatcode(group = Testing, safety = Safe)]
1625 function assertEq(bytes calldata left, bytes calldata right, string calldata err) external pure;
1626
1627 /// Asserts that two arrays of `bool` values are equal.
1628 #[cheatcode(group = Testing, safety = Safe)]
1629 function assertEq(bool[] calldata left, bool[] calldata right) external pure;
1630
1631 /// Asserts that two arrays of `bool` values are equal and includes error message into revert string on failure.
1632 #[cheatcode(group = Testing, safety = Safe)]
1633 function assertEq(bool[] calldata left, bool[] calldata right, string calldata err) external pure;
1634
1635 /// Asserts that two arrays of `uint256 values are equal.
1636 #[cheatcode(group = Testing, safety = Safe)]
1637 function assertEq(uint256[] calldata left, uint256[] calldata right) external pure;
1638
1639 /// Asserts that two arrays of `uint256` values are equal and includes error message into revert string on failure.
1640 #[cheatcode(group = Testing, safety = Safe)]
1641 function assertEq(uint256[] calldata left, uint256[] calldata right, string calldata err) external pure;
1642
1643 /// Asserts that two arrays of `int256` values are equal.
1644 #[cheatcode(group = Testing, safety = Safe)]
1645 function assertEq(int256[] calldata left, int256[] calldata right) external pure;
1646
1647 /// Asserts that two arrays of `int256` values are equal and includes error message into revert string on failure.
1648 #[cheatcode(group = Testing, safety = Safe)]
1649 function assertEq(int256[] calldata left, int256[] calldata right, string calldata err) external pure;
1650
1651 /// Asserts that two arrays of `address` values are equal.
1652 #[cheatcode(group = Testing, safety = Safe)]
1653 function assertEq(address[] calldata left, address[] calldata right) external pure;
1654
1655 /// Asserts that two arrays of `address` values are equal and includes error message into revert string on failure.
1656 #[cheatcode(group = Testing, safety = Safe)]
1657 function assertEq(address[] calldata left, address[] calldata right, string calldata err) external pure;
1658
1659 /// Asserts that two arrays of `bytes32` values are equal.
1660 #[cheatcode(group = Testing, safety = Safe)]
1661 function assertEq(bytes32[] calldata left, bytes32[] calldata right) external pure;
1662
1663 /// Asserts that two arrays of `bytes32` values are equal and includes error message into revert string on failure.
1664 #[cheatcode(group = Testing, safety = Safe)]
1665 function assertEq(bytes32[] calldata left, bytes32[] calldata right, string calldata err) external pure;
1666
1667 /// Asserts that two arrays of `string` values are equal.
1668 #[cheatcode(group = Testing, safety = Safe)]
1669 function assertEq(string[] calldata left, string[] calldata right) external pure;
1670
1671 /// Asserts that two arrays of `string` values are equal and includes error message into revert string on failure.
1672 #[cheatcode(group = Testing, safety = Safe)]
1673 function assertEq(string[] calldata left, string[] calldata right, string calldata err) external pure;
1674
1675 /// Asserts that two arrays of `bytes` values are equal.
1676 #[cheatcode(group = Testing, safety = Safe)]
1677 function assertEq(bytes[] calldata left, bytes[] calldata right) external pure;
1678
1679 /// Asserts that two arrays of `bytes` values are equal and includes error message into revert string on failure.
1680 #[cheatcode(group = Testing, safety = Safe)]
1681 function assertEq(bytes[] calldata left, bytes[] calldata right, string calldata err) external pure;
1682
1683 /// Asserts that two `uint256` values are equal, formatting them with decimals in failure message.
1684 #[cheatcode(group = Testing, safety = Safe)]
1685 function assertEqDecimal(uint256 left, uint256 right, uint256 decimals) external pure;
1686
1687 /// Asserts that two `uint256` values are equal, formatting them with decimals in failure message.
1688 /// Includes error message into revert string on failure.
1689 #[cheatcode(group = Testing, safety = Safe)]
1690 function assertEqDecimal(uint256 left, uint256 right, uint256 decimals, string calldata err) external pure;
1691
1692 /// Asserts that two `int256` values are equal, formatting them with decimals in failure message.
1693 #[cheatcode(group = Testing, safety = Safe)]
1694 function assertEqDecimal(int256 left, int256 right, uint256 decimals) external pure;
1695
1696 /// Asserts that two `int256` values are equal, formatting them with decimals in failure message.
1697 /// Includes error message into revert string on failure.
1698 #[cheatcode(group = Testing, safety = Safe)]
1699 function assertEqDecimal(int256 left, int256 right, uint256 decimals, string calldata err) external pure;
1700
1701 /// Asserts that two `bool` values are not equal.
1702 #[cheatcode(group = Testing, safety = Safe)]
1703 function assertNotEq(bool left, bool right) external pure;
1704
1705 /// Asserts that two `bool` values are not equal and includes error message into revert string on failure.
1706 #[cheatcode(group = Testing, safety = Safe)]
1707 function assertNotEq(bool left, bool right, string calldata err) external pure;
1708
1709 /// Asserts that two `uint256` values are not equal.
1710 #[cheatcode(group = Testing, safety = Safe)]
1711 function assertNotEq(uint256 left, uint256 right) external pure;
1712
1713 /// Asserts that two `uint256` values are not equal and includes error message into revert string on failure.
1714 #[cheatcode(group = Testing, safety = Safe)]
1715 function assertNotEq(uint256 left, uint256 right, string calldata err) external pure;
1716
1717 /// Asserts that two `int256` values are not equal.
1718 #[cheatcode(group = Testing, safety = Safe)]
1719 function assertNotEq(int256 left, int256 right) external pure;
1720
1721 /// Asserts that two `int256` values are not equal and includes error message into revert string on failure.
1722 #[cheatcode(group = Testing, safety = Safe)]
1723 function assertNotEq(int256 left, int256 right, string calldata err) external pure;
1724
1725 /// Asserts that two `address` values are not equal.
1726 #[cheatcode(group = Testing, safety = Safe)]
1727 function assertNotEq(address left, address right) external pure;
1728
1729 /// Asserts that two `address` values are not equal and includes error message into revert string on failure.
1730 #[cheatcode(group = Testing, safety = Safe)]
1731 function assertNotEq(address left, address right, string calldata err) external pure;
1732
1733 /// Asserts that two `bytes32` values are not equal.
1734 #[cheatcode(group = Testing, safety = Safe)]
1735 function assertNotEq(bytes32 left, bytes32 right) external pure;
1736
1737 /// Asserts that two `bytes32` values are not equal and includes error message into revert string on failure.
1738 #[cheatcode(group = Testing, safety = Safe)]
1739 function assertNotEq(bytes32 left, bytes32 right, string calldata err) external pure;
1740
1741 /// Asserts that two `string` values are not equal.
1742 #[cheatcode(group = Testing, safety = Safe)]
1743 function assertNotEq(string calldata left, string calldata right) external pure;
1744
1745 /// Asserts that two `string` values are not equal and includes error message into revert string on failure.
1746 #[cheatcode(group = Testing, safety = Safe)]
1747 function assertNotEq(string calldata left, string calldata right, string calldata err) external pure;
1748
1749 /// Asserts that two `bytes` values are not equal.
1750 #[cheatcode(group = Testing, safety = Safe)]
1751 function assertNotEq(bytes calldata left, bytes calldata right) external pure;
1752
1753 /// Asserts that two `bytes` values are not equal and includes error message into revert string on failure.
1754 #[cheatcode(group = Testing, safety = Safe)]
1755 function assertNotEq(bytes calldata left, bytes calldata right, string calldata err) external pure;
1756
1757 /// Asserts that two arrays of `bool` values are not equal.
1758 #[cheatcode(group = Testing, safety = Safe)]
1759 function assertNotEq(bool[] calldata left, bool[] calldata right) external pure;
1760
1761 /// Asserts that two arrays of `bool` values are not equal and includes error message into revert string on failure.
1762 #[cheatcode(group = Testing, safety = Safe)]
1763 function assertNotEq(bool[] calldata left, bool[] calldata right, string calldata err) external pure;
1764
1765 /// Asserts that two arrays of `uint256` values are not equal.
1766 #[cheatcode(group = Testing, safety = Safe)]
1767 function assertNotEq(uint256[] calldata left, uint256[] calldata right) external pure;
1768
1769 /// Asserts that two arrays of `uint256` values are not equal and includes error message into revert string on failure.
1770 #[cheatcode(group = Testing, safety = Safe)]
1771 function assertNotEq(uint256[] calldata left, uint256[] calldata right, string calldata err) external pure;
1772
1773 /// Asserts that two arrays of `int256` values are not equal.
1774 #[cheatcode(group = Testing, safety = Safe)]
1775 function assertNotEq(int256[] calldata left, int256[] calldata right) external pure;
1776
1777 /// Asserts that two arrays of `int256` values are not equal and includes error message into revert string on failure.
1778 #[cheatcode(group = Testing, safety = Safe)]
1779 function assertNotEq(int256[] calldata left, int256[] calldata right, string calldata err) external pure;
1780
1781 /// Asserts that two arrays of `address` values are not equal.
1782 #[cheatcode(group = Testing, safety = Safe)]
1783 function assertNotEq(address[] calldata left, address[] calldata right) external pure;
1784
1785 /// Asserts that two arrays of `address` values are not equal and includes error message into revert string on failure.
1786 #[cheatcode(group = Testing, safety = Safe)]
1787 function assertNotEq(address[] calldata left, address[] calldata right, string calldata err) external pure;
1788
1789 /// Asserts that two arrays of `bytes32` values are not equal.
1790 #[cheatcode(group = Testing, safety = Safe)]
1791 function assertNotEq(bytes32[] calldata left, bytes32[] calldata right) external pure;
1792
1793 /// Asserts that two arrays of `bytes32` values are not equal and includes error message into revert string on failure.
1794 #[cheatcode(group = Testing, safety = Safe)]
1795 function assertNotEq(bytes32[] calldata left, bytes32[] calldata right, string calldata err) external pure;
1796
1797 /// Asserts that two arrays of `string` values are not equal.
1798 #[cheatcode(group = Testing, safety = Safe)]
1799 function assertNotEq(string[] calldata left, string[] calldata right) external pure;
1800
1801 /// Asserts that two arrays of `string` values are not equal and includes error message into revert string on failure.
1802 #[cheatcode(group = Testing, safety = Safe)]
1803 function assertNotEq(string[] calldata left, string[] calldata right, string calldata err) external pure;
1804
1805 /// Asserts that two arrays of `bytes` values are not equal.
1806 #[cheatcode(group = Testing, safety = Safe)]
1807 function assertNotEq(bytes[] calldata left, bytes[] calldata right) external pure;
1808
1809 /// Asserts that two arrays of `bytes` values are not equal and includes error message into revert string on failure.
1810 #[cheatcode(group = Testing, safety = Safe)]
1811 function assertNotEq(bytes[] calldata left, bytes[] calldata right, string calldata err) external pure;
1812
1813 /// Asserts that two `uint256` values are not equal, formatting them with decimals in failure message.
1814 #[cheatcode(group = Testing, safety = Safe)]
1815 function assertNotEqDecimal(uint256 left, uint256 right, uint256 decimals) external pure;
1816
1817 /// Asserts that two `uint256` values are not equal, formatting them with decimals in failure message.
1818 /// Includes error message into revert string on failure.
1819 #[cheatcode(group = Testing, safety = Safe)]
1820 function assertNotEqDecimal(uint256 left, uint256 right, uint256 decimals, string calldata err) external pure;
1821
1822 /// Asserts that two `int256` values are not equal, formatting them with decimals in failure message.
1823 #[cheatcode(group = Testing, safety = Safe)]
1824 function assertNotEqDecimal(int256 left, int256 right, uint256 decimals) external pure;
1825
1826 /// Asserts that two `int256` values are not equal, formatting them with decimals in failure message.
1827 /// Includes error message into revert string on failure.
1828 #[cheatcode(group = Testing, safety = Safe)]
1829 function assertNotEqDecimal(int256 left, int256 right, uint256 decimals, string calldata err) external pure;
1830
1831 /// Compares two `uint256` values. Expects first value to be greater than second.
1832 #[cheatcode(group = Testing, safety = Safe)]
1833 function assertGt(uint256 left, uint256 right) external pure;
1834
1835 /// Compares two `uint256` values. Expects first value to be greater than second.
1836 /// Includes error message into revert string on failure.
1837 #[cheatcode(group = Testing, safety = Safe)]
1838 function assertGt(uint256 left, uint256 right, string calldata err) external pure;
1839
1840 /// Compares two `int256` values. Expects first value to be greater than second.
1841 #[cheatcode(group = Testing, safety = Safe)]
1842 function assertGt(int256 left, int256 right) external pure;
1843
1844 /// Compares two `int256` values. Expects first value to be greater than second.
1845 /// Includes error message into revert string on failure.
1846 #[cheatcode(group = Testing, safety = Safe)]
1847 function assertGt(int256 left, int256 right, string calldata err) external pure;
1848
1849 /// Compares two `uint256` values. Expects first value to be greater than second.
1850 /// Formats values with decimals in failure message.
1851 #[cheatcode(group = Testing, safety = Safe)]
1852 function assertGtDecimal(uint256 left, uint256 right, uint256 decimals) external pure;
1853
1854 /// Compares two `uint256` values. Expects first value to be greater than second.
1855 /// Formats values with decimals in failure message. Includes error message into revert string on failure.
1856 #[cheatcode(group = Testing, safety = Safe)]
1857 function assertGtDecimal(uint256 left, uint256 right, uint256 decimals, string calldata err) external pure;
1858
1859 /// Compares two `int256` values. Expects first value to be greater than second.
1860 /// Formats values with decimals in failure message.
1861 #[cheatcode(group = Testing, safety = Safe)]
1862 function assertGtDecimal(int256 left, int256 right, uint256 decimals) external pure;
1863
1864 /// Compares two `int256` values. Expects first value to be greater than second.
1865 /// Formats values with decimals in failure message. Includes error message into revert string on failure.
1866 #[cheatcode(group = Testing, safety = Safe)]
1867 function assertGtDecimal(int256 left, int256 right, uint256 decimals, string calldata err) external pure;
1868
1869 /// Compares two `uint256` values. Expects first value to be greater than or equal to second.
1870 #[cheatcode(group = Testing, safety = Safe)]
1871 function assertGe(uint256 left, uint256 right) external pure;
1872
1873 /// Compares two `uint256` values. Expects first value to be greater than or equal to second.
1874 /// Includes error message into revert string on failure.
1875 #[cheatcode(group = Testing, safety = Safe)]
1876 function assertGe(uint256 left, uint256 right, string calldata err) external pure;
1877
1878 /// Compares two `int256` values. Expects first value to be greater than or equal to second.
1879 #[cheatcode(group = Testing, safety = Safe)]
1880 function assertGe(int256 left, int256 right) external pure;
1881
1882 /// Compares two `int256` values. Expects first value to be greater than or equal to second.
1883 /// Includes error message into revert string on failure.
1884 #[cheatcode(group = Testing, safety = Safe)]
1885 function assertGe(int256 left, int256 right, string calldata err) external pure;
1886
1887 /// Compares two `uint256` values. Expects first value to be greater than or equal to second.
1888 /// Formats values with decimals in failure message.
1889 #[cheatcode(group = Testing, safety = Safe)]
1890 function assertGeDecimal(uint256 left, uint256 right, uint256 decimals) external pure;
1891
1892 /// Compares two `uint256` values. Expects first value to be greater than or equal to second.
1893 /// Formats values with decimals in failure message. Includes error message into revert string on failure.
1894 #[cheatcode(group = Testing, safety = Safe)]
1895 function assertGeDecimal(uint256 left, uint256 right, uint256 decimals, string calldata err) external pure;
1896
1897 /// Compares two `int256` values. Expects first value to be greater than or equal to second.
1898 /// Formats values with decimals in failure message.
1899 #[cheatcode(group = Testing, safety = Safe)]
1900 function assertGeDecimal(int256 left, int256 right, uint256 decimals) external pure;
1901
1902 /// Compares two `int256` values. Expects first value to be greater than or equal to second.
1903 /// Formats values with decimals in failure message. Includes error message into revert string on failure.
1904 #[cheatcode(group = Testing, safety = Safe)]
1905 function assertGeDecimal(int256 left, int256 right, uint256 decimals, string calldata err) external pure;
1906
1907 /// Compares two `uint256` values. Expects first value to be less than second.
1908 #[cheatcode(group = Testing, safety = Safe)]
1909 function assertLt(uint256 left, uint256 right) external pure;
1910
1911 /// Compares two `uint256` values. Expects first value to be less than second.
1912 /// Includes error message into revert string on failure.
1913 #[cheatcode(group = Testing, safety = Safe)]
1914 function assertLt(uint256 left, uint256 right, string calldata err) external pure;
1915
1916 /// Compares two `int256` values. Expects first value to be less than second.
1917 #[cheatcode(group = Testing, safety = Safe)]
1918 function assertLt(int256 left, int256 right) external pure;
1919
1920 /// Compares two `int256` values. Expects first value to be less than second.
1921 /// Includes error message into revert string on failure.
1922 #[cheatcode(group = Testing, safety = Safe)]
1923 function assertLt(int256 left, int256 right, string calldata err) external pure;
1924
1925 /// Compares two `uint256` values. Expects first value to be less than second.
1926 /// Formats values with decimals in failure message.
1927 #[cheatcode(group = Testing, safety = Safe)]
1928 function assertLtDecimal(uint256 left, uint256 right, uint256 decimals) external pure;
1929
1930 /// Compares two `uint256` values. Expects first value to be less than second.
1931 /// Formats values with decimals in failure message. Includes error message into revert string on failure.
1932 #[cheatcode(group = Testing, safety = Safe)]
1933 function assertLtDecimal(uint256 left, uint256 right, uint256 decimals, string calldata err) external pure;
1934
1935 /// Compares two `int256` values. Expects first value to be less than second.
1936 /// Formats values with decimals in failure message.
1937 #[cheatcode(group = Testing, safety = Safe)]
1938 function assertLtDecimal(int256 left, int256 right, uint256 decimals) external pure;
1939
1940 /// Compares two `int256` values. Expects first value to be less than second.
1941 /// Formats values with decimals in failure message. Includes error message into revert string on failure.
1942 #[cheatcode(group = Testing, safety = Safe)]
1943 function assertLtDecimal(int256 left, int256 right, uint256 decimals, string calldata err) external pure;
1944
1945 /// Compares two `uint256` values. Expects first value to be less than or equal to second.
1946 #[cheatcode(group = Testing, safety = Safe)]
1947 function assertLe(uint256 left, uint256 right) external pure;
1948
1949 /// Compares two `uint256` values. Expects first value to be less than or equal to second.
1950 /// Includes error message into revert string on failure.
1951 #[cheatcode(group = Testing, safety = Safe)]
1952 function assertLe(uint256 left, uint256 right, string calldata err) external pure;
1953
1954 /// Compares two `int256` values. Expects first value to be less than or equal to second.
1955 #[cheatcode(group = Testing, safety = Safe)]
1956 function assertLe(int256 left, int256 right) external pure;
1957
1958 /// Compares two `int256` values. Expects first value to be less than or equal to second.
1959 /// Includes error message into revert string on failure.
1960 #[cheatcode(group = Testing, safety = Safe)]
1961 function assertLe(int256 left, int256 right, string calldata err) external pure;
1962
1963 /// Compares two `uint256` values. Expects first value to be less than or equal to second.
1964 /// Formats values with decimals in failure message.
1965 #[cheatcode(group = Testing, safety = Safe)]
1966 function assertLeDecimal(uint256 left, uint256 right, uint256 decimals) external pure;
1967
1968 /// Compares two `uint256` values. Expects first value to be less than or equal to second.
1969 /// Formats values with decimals in failure message. Includes error message into revert string on failure.
1970 #[cheatcode(group = Testing, safety = Safe)]
1971 function assertLeDecimal(uint256 left, uint256 right, uint256 decimals, string calldata err) external pure;
1972
1973 /// Compares two `int256` values. Expects first value to be less than or equal to second.
1974 /// Formats values with decimals in failure message.
1975 #[cheatcode(group = Testing, safety = Safe)]
1976 function assertLeDecimal(int256 left, int256 right, uint256 decimals) external pure;
1977
1978 /// Compares two `int256` values. Expects first value to be less than or equal to second.
1979 /// Formats values with decimals in failure message. Includes error message into revert string on failure.
1980 #[cheatcode(group = Testing, safety = Safe)]
1981 function assertLeDecimal(int256 left, int256 right, uint256 decimals, string calldata err) external pure;
1982
1983 /// Compares two `uint256` values. Expects difference to be less than or equal to `maxDelta`.
1984 #[cheatcode(group = Testing, safety = Safe)]
1985 function assertApproxEqAbs(uint256 left, uint256 right, uint256 maxDelta) external pure;
1986
1987 /// Compares two `uint256` values. Expects difference to be less than or equal to `maxDelta`.
1988 /// Includes error message into revert string on failure.
1989 #[cheatcode(group = Testing, safety = Safe)]
1990 function assertApproxEqAbs(uint256 left, uint256 right, uint256 maxDelta, string calldata err) external pure;
1991
1992 /// Compares two `int256` values. Expects difference to be less than or equal to `maxDelta`.
1993 #[cheatcode(group = Testing, safety = Safe)]
1994 function assertApproxEqAbs(int256 left, int256 right, uint256 maxDelta) external pure;
1995
1996 /// Compares two `int256` values. Expects difference to be less than or equal to `maxDelta`.
1997 /// Includes error message into revert string on failure.
1998 #[cheatcode(group = Testing, safety = Safe)]
1999 function assertApproxEqAbs(int256 left, int256 right, uint256 maxDelta, string calldata err) external pure;
2000
2001 /// Compares two `uint256` values. Expects difference to be less than or equal to `maxDelta`.
2002 /// Formats values with decimals in failure message.
2003 #[cheatcode(group = Testing, safety = Safe)]
2004 function assertApproxEqAbsDecimal(uint256 left, uint256 right, uint256 maxDelta, uint256 decimals) external pure;
2005
2006 /// Compares two `uint256` values. Expects difference to be less than or equal to `maxDelta`.
2007 /// Formats values with decimals in failure message. Includes error message into revert string on failure.
2008 #[cheatcode(group = Testing, safety = Safe)]
2009 function assertApproxEqAbsDecimal(
2010 uint256 left,
2011 uint256 right,
2012 uint256 maxDelta,
2013 uint256 decimals,
2014 string calldata err
2015 ) external pure;
2016
2017 /// Compares two `int256` values. Expects difference to be less than or equal to `maxDelta`.
2018 /// Formats values with decimals in failure message.
2019 #[cheatcode(group = Testing, safety = Safe)]
2020 function assertApproxEqAbsDecimal(int256 left, int256 right, uint256 maxDelta, uint256 decimals) external pure;
2021
2022 /// Compares two `int256` values. Expects difference to be less than or equal to `maxDelta`.
2023 /// Formats values with decimals in failure message. Includes error message into revert string on failure.
2024 #[cheatcode(group = Testing, safety = Safe)]
2025 function assertApproxEqAbsDecimal(
2026 int256 left,
2027 int256 right,
2028 uint256 maxDelta,
2029 uint256 decimals,
2030 string calldata err
2031 ) external pure;
2032
2033 /// Compares two `uint256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`.
2034 /// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100%
2035 #[cheatcode(group = Testing, safety = Safe)]
2036 function assertApproxEqRel(uint256 left, uint256 right, uint256 maxPercentDelta) external pure;
2037
2038 /// Compares two `uint256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`.
2039 /// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100%
2040 /// Includes error message into revert string on failure.
2041 #[cheatcode(group = Testing, safety = Safe)]
2042 function assertApproxEqRel(uint256 left, uint256 right, uint256 maxPercentDelta, string calldata err) external pure;
2043
2044 /// Compares two `int256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`.
2045 /// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100%
2046 #[cheatcode(group = Testing, safety = Safe)]
2047 function assertApproxEqRel(int256 left, int256 right, uint256 maxPercentDelta) external pure;
2048
2049 /// Compares two `int256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`.
2050 /// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100%
2051 /// Includes error message into revert string on failure.
2052 #[cheatcode(group = Testing, safety = Safe)]
2053 function assertApproxEqRel(int256 left, int256 right, uint256 maxPercentDelta, string calldata err) external pure;
2054
2055 /// Compares two `uint256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`.
2056 /// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100%
2057 /// Formats values with decimals in failure message.
2058 #[cheatcode(group = Testing, safety = Safe)]
2059 function assertApproxEqRelDecimal(
2060 uint256 left,
2061 uint256 right,
2062 uint256 maxPercentDelta,
2063 uint256 decimals
2064 ) external pure;
2065
2066 /// Compares two `uint256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`.
2067 /// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100%
2068 /// Formats values with decimals in failure message. Includes error message into revert string on failure.
2069 #[cheatcode(group = Testing, safety = Safe)]
2070 function assertApproxEqRelDecimal(
2071 uint256 left,
2072 uint256 right,
2073 uint256 maxPercentDelta,
2074 uint256 decimals,
2075 string calldata err
2076 ) external pure;
2077
2078 /// Compares two `int256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`.
2079 /// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100%
2080 /// Formats values with decimals in failure message.
2081 #[cheatcode(group = Testing, safety = Safe)]
2082 function assertApproxEqRelDecimal(
2083 int256 left,
2084 int256 right,
2085 uint256 maxPercentDelta,
2086 uint256 decimals
2087 ) external pure;
2088
2089 /// Compares two `int256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`.
2090 /// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100%
2091 /// Formats values with decimals in failure message. Includes error message into revert string on failure.
2092 #[cheatcode(group = Testing, safety = Safe)]
2093 function assertApproxEqRelDecimal(
2094 int256 left,
2095 int256 right,
2096 uint256 maxPercentDelta,
2097 uint256 decimals,
2098 string calldata err
2099 ) external pure;
2100
2101 /// Returns true if the current Foundry version is greater than or equal to the given version.
2102 /// The given version string must be in the format `major.minor.patch`.
2103 ///
2104 /// This is equivalent to `foundryVersionCmp(version) >= 0`.
2105 #[cheatcode(group = Testing, safety = Safe)]
2106 function foundryVersionAtLeast(string calldata version) external view returns (bool);
2107
2108 /// Compares the current Foundry version with the given version string.
2109 /// The given version string must be in the format `major.minor.patch`.
2110 ///
2111 /// Returns:
2112 /// -1 if current Foundry version is less than the given version
2113 /// 0 if current Foundry version equals the given version
2114 /// 1 if current Foundry version is greater than the given version
2115 ///
2116 /// This result can then be used with a comparison operator against `0`.
2117 /// For example, to check if the current Foundry version is greater than or equal to `1.0.0`:
2118 /// `if (foundryVersionCmp("1.0.0") >= 0) { ... }`
2119 #[cheatcode(group = Testing, safety = Safe)]
2120 function foundryVersionCmp(string calldata version) external view returns (int256);
2121
2122 // ======== OS and Filesystem ========
2123
2124 // -------- Metadata --------
2125
2126 /// Returns true if the given path points to an existing entity, else returns false.
2127 #[cheatcode(group = Filesystem)]
2128 function exists(string calldata path) external view returns (bool result);
2129
2130 /// Given a path, query the file system to get information about a file, directory, etc.
2131 #[cheatcode(group = Filesystem)]
2132 function fsMetadata(string calldata path) external view returns (FsMetadata memory metadata);
2133
2134 /// Returns true if the path exists on disk and is pointing at a directory, else returns false.
2135 #[cheatcode(group = Filesystem)]
2136 function isDir(string calldata path) external view returns (bool result);
2137
2138 /// Returns true if the path exists on disk and is pointing at a regular file, else returns false.
2139 #[cheatcode(group = Filesystem)]
2140 function isFile(string calldata path) external view returns (bool result);
2141
2142 /// Get the path of the current project root.
2143 #[cheatcode(group = Filesystem)]
2144 function projectRoot() external view returns (string memory path);
2145
2146 /// Get the source file path of the currently running test or script contract,
2147 /// relative to the project root.
2148 #[cheatcode(group = Filesystem)]
2149 function currentFilePath() external view returns (string memory path);
2150
2151 /// Returns the time since unix epoch in milliseconds.
2152 #[cheatcode(group = Filesystem)]
2153 function unixTime() external view returns (uint256 milliseconds);
2154
2155 // -------- Reading and writing --------
2156
2157 /// Closes file for reading, resetting the offset and allowing to read it from beginning with readLine.
2158 /// `path` is relative to the project root.
2159 #[cheatcode(group = Filesystem)]
2160 function closeFile(string calldata path) external;
2161
2162 /// Copies the contents of one file to another. This function will **overwrite** the contents of `to`.
2163 /// On success, the total number of bytes copied is returned and it is equal to the length of the `to` file as reported by `metadata`.
2164 /// Both `from` and `to` are relative to the project root.
2165 #[cheatcode(group = Filesystem)]
2166 function copyFile(string calldata from, string calldata to) external returns (uint64 copied);
2167
2168 /// Creates a new, empty directory at the provided path.
2169 /// This cheatcode will revert in the following situations, but is not limited to just these cases:
2170 /// - User lacks permissions to modify `path`.
2171 /// - A parent of the given path doesn't exist and `recursive` is false.
2172 /// - `path` already exists and `recursive` is false.
2173 /// `path` is relative to the project root.
2174 #[cheatcode(group = Filesystem)]
2175 function createDir(string calldata path, bool recursive) external;
2176
2177 /// Reads the directory at the given path recursively, up to `maxDepth`.
2178 /// `maxDepth` defaults to 1, meaning only the direct children of the given directory will be returned.
2179 /// Follows symbolic links if `followLinks` is true.
2180 #[cheatcode(group = Filesystem)]
2181 function readDir(string calldata path) external view returns (DirEntry[] memory entries);
2182 /// See `readDir(string)`.
2183 #[cheatcode(group = Filesystem)]
2184 function readDir(string calldata path, uint64 maxDepth) external view returns (DirEntry[] memory entries);
2185 /// See `readDir(string)`.
2186 #[cheatcode(group = Filesystem)]
2187 function readDir(string calldata path, uint64 maxDepth, bool followLinks)
2188 external
2189 view
2190 returns (DirEntry[] memory entries);
2191
2192 /// Reads the entire content of file to string. `path` is relative to the project root.
2193 #[cheatcode(group = Filesystem)]
2194 function readFile(string calldata path) external view returns (string memory data);
2195
2196 /// Reads the entire content of file as binary. `path` is relative to the project root.
2197 #[cheatcode(group = Filesystem)]
2198 function readFileBinary(string calldata path) external view returns (bytes memory data);
2199
2200 /// Reads next line of file to string.
2201 #[cheatcode(group = Filesystem)]
2202 function readLine(string calldata path) external view returns (string memory line);
2203
2204 /// Reads a symbolic link, returning the path that the link points to.
2205 /// This cheatcode will revert in the following situations, but is not limited to just these cases:
2206 /// - `path` is not a symbolic link.
2207 /// - `path` does not exist.
2208 #[cheatcode(group = Filesystem)]
2209 function readLink(string calldata linkPath) external view returns (string memory targetPath);
2210
2211 /// Removes a directory at the provided path.
2212 /// This cheatcode will revert in the following situations, but is not limited to just these cases:
2213 /// - `path` doesn't exist.
2214 /// - `path` isn't a directory.
2215 /// - User lacks permissions to modify `path`.
2216 /// - The directory is not empty and `recursive` is false.
2217 /// `path` is relative to the project root.
2218 #[cheatcode(group = Filesystem)]
2219 function removeDir(string calldata path, bool recursive) external;
2220
2221 /// Removes a file from the filesystem.
2222 /// This cheatcode will revert in the following situations, but is not limited to just these cases:
2223 /// - `path` points to a directory.
2224 /// - The file doesn't exist.
2225 /// - The user lacks permissions to remove the file.
2226 /// `path` is relative to the project root.
2227 #[cheatcode(group = Filesystem)]
2228 function removeFile(string calldata path) external;
2229
2230 /// Writes data to file, creating a file if it does not exist, and entirely replacing its contents if it does.
2231 /// `path` is relative to the project root.
2232 #[cheatcode(group = Filesystem)]
2233 function writeFile(string calldata path, string calldata data) external;
2234
2235 /// Writes binary data to a file, creating a file if it does not exist, and entirely replacing its contents if it does.
2236 /// `path` is relative to the project root.
2237 #[cheatcode(group = Filesystem)]
2238 function writeFileBinary(string calldata path, bytes calldata data) external;
2239
2240 /// Writes line to file, creating a file if it does not exist.
2241 /// `path` is relative to the project root.
2242 #[cheatcode(group = Filesystem)]
2243 function writeLine(string calldata path, string calldata data) external;
2244
2245 /// Gets the artifact path from code (aka. creation code).
2246 #[cheatcode(group = Filesystem)]
2247 function getArtifactPathByCode(bytes calldata code) external view returns (string memory path);
2248
2249 /// Gets the artifact path from deployed code (aka. runtime code).
2250 #[cheatcode(group = Filesystem)]
2251 function getArtifactPathByDeployedCode(bytes calldata deployedCode) external view returns (string memory path);
2252
2253 /// Gets the creation bytecode from an artifact file. Takes in the relative path to the json file or the path to the
2254 /// artifact in the form of <path>:<contract>:<version> or <path>:<contract>:<profile> where <contract> and
2255 /// <version>/<profile> parts are optional. Use <profile> to select artifacts compiled with a specific profile
2256 /// from foundry.toml.
2257 #[cheatcode(group = Filesystem)]
2258 function getCode(string calldata artifactPath) external view returns (bytes memory creationBytecode);
2259
2260 /// Gets all function selectors from a contract artifact. Takes in the relative path to the json file or the path to the
2261 /// artifact in the form of <path>:<contract>:<version> where <contract> and <version> parts are optional.
2262 #[cheatcode(group = Filesystem)]
2263 function getSelectors(string calldata artifactPath) external view returns (bytes4[] memory selectors);
2264
2265 /// Deploys a contract from an artifact file. Takes in the relative path to the json file or the path to the
2266 /// artifact in the form of <path>:<contract>:<version> or <path>:<contract>:<profile> where <contract> and
2267 /// <version>/<profile> parts are optional.
2268 /// Reverts if the target artifact contains unlinked library placeholders.
2269 #[cheatcode(group = Filesystem)]
2270 function deployCode(string calldata artifactPath) external returns (address deployedAddress);
2271
2272 /// Deploys a contract from an artifact file. Takes in the relative path to the json file or the path to the
2273 /// artifact in the form of <path>:<contract>:<version> or <path>:<contract>:<profile> where <contract> and
2274 /// <version>/<profile> parts are optional.
2275 /// Reverts if the target artifact contains unlinked library placeholders.
2276 ///
2277 /// Additionally accepts abi-encoded constructor arguments.
2278 #[cheatcode(group = Filesystem)]
2279 function deployCode(string calldata artifactPath, bytes calldata constructorArgs) external returns (address deployedAddress);
2280
2281 /// Deploys a contract from an artifact file. Takes in the relative path to the json file or the path to the
2282 /// artifact in the form of <path>:<contract>:<version> or <path>:<contract>:<profile> where <contract> and
2283 /// <version>/<profile> parts are optional.
2284 /// Reverts if the target artifact contains unlinked library placeholders.
2285 ///
2286 /// Additionally accepts `msg.value`.
2287 #[cheatcode(group = Filesystem)]
2288 function deployCode(string calldata artifactPath, uint256 value) external returns (address deployedAddress);
2289
2290 /// Deploys a contract from an artifact file. Takes in the relative path to the json file or the path to the
2291 /// artifact in the form of <path>:<contract>:<version> or <path>:<contract>:<profile> where <contract> and
2292 /// <version>/<profile> parts are optional.
2293 /// Reverts if the target artifact contains unlinked library placeholders.
2294 ///
2295 /// Additionally accepts abi-encoded constructor arguments and `msg.value`.
2296 #[cheatcode(group = Filesystem)]
2297 function deployCode(string calldata artifactPath, bytes calldata constructorArgs, uint256 value) external returns (address deployedAddress);
2298
2299 /// Deploys a contract from an artifact file, using the CREATE2 salt. Takes in the relative path to the json file or the path to the
2300 /// artifact in the form of <path>:<contract>:<version> or <path>:<contract>:<profile> where <contract> and
2301 /// <version>/<profile> parts are optional.
2302 /// Reverts if the target artifact contains unlinked library placeholders.
2303 #[cheatcode(group = Filesystem)]
2304 function deployCode(string calldata artifactPath, bytes32 salt) external returns (address deployedAddress);
2305
2306 /// Deploys a contract from an artifact file, using the CREATE2 salt. Takes in the relative path to the json file or the path to the
2307 /// artifact in the form of <path>:<contract>:<version> or <path>:<contract>:<profile> where <contract> and
2308 /// <version>/<profile> parts are optional.
2309 /// Reverts if the target artifact contains unlinked library placeholders.
2310 ///
2311 /// Additionally accepts abi-encoded constructor arguments.
2312 #[cheatcode(group = Filesystem)]
2313 function deployCode(string calldata artifactPath, bytes calldata constructorArgs, bytes32 salt) external returns (address deployedAddress);
2314
2315 /// Deploys a contract from an artifact file, using the CREATE2 salt. Takes in the relative path to the json file or the path to the
2316 /// artifact in the form of <path>:<contract>:<version> or <path>:<contract>:<profile> where <contract> and
2317 /// <version>/<profile> parts are optional.
2318 /// Reverts if the target artifact contains unlinked library placeholders.
2319 ///
2320 /// Additionally accepts `msg.value`.
2321 #[cheatcode(group = Filesystem)]
2322 function deployCode(string calldata artifactPath, uint256 value, bytes32 salt) external returns (address deployedAddress);
2323
2324 /// Deploys a contract from an artifact file, using the CREATE2 salt. Takes in the relative path to the json file or the path to the
2325 /// artifact in the form of <path>:<contract>:<version> or <path>:<contract>:<profile> where <contract> and
2326 /// <version>/<profile> parts are optional.
2327 /// Reverts if the target artifact contains unlinked library placeholders.
2328 ///
2329 /// Additionally accepts abi-encoded constructor arguments and `msg.value`.
2330 #[cheatcode(group = Filesystem)]
2331 function deployCode(string calldata artifactPath, bytes calldata constructorArgs, uint256 value, bytes32 salt) external returns (address deployedAddress);
2332
2333 /// Gets the deployed bytecode from an artifact file. Takes in the relative path to the json file or the path to the
2334 /// artifact in the form of <path>:<contract>:<version> or <path>:<contract>:<profile> where <contract> and
2335 /// <version>/<profile> parts are optional.
2336 #[cheatcode(group = Filesystem)]
2337 function getDeployedCode(string calldata artifactPath) external view returns (bytes memory runtimeBytecode);
2338
2339 /// Returns the most recent broadcast for the given contract on `chainId` matching `txType`.
2340 ///
2341 /// For example:
2342 ///
2343 /// The most recent deployment can be fetched by passing `txType` as `CREATE` or `CREATE2`.
2344 ///
2345 /// The most recent call can be fetched by passing `txType` as `CALL`.
2346 #[cheatcode(group = Filesystem)]
2347 function getBroadcast(string calldata contractName, uint64 chainId, BroadcastTxType txType) external view returns (BroadcastTxSummary memory);
2348
2349 /// Returns all broadcasts for the given contract on `chainId` with the specified `txType`.
2350 ///
2351 /// Sorted such that the most recent broadcast is the first element, and the oldest is the last. i.e descending order of BroadcastTxSummary.blockNumber.
2352 #[cheatcode(group = Filesystem)]
2353 function getBroadcasts(string calldata contractName, uint64 chainId, BroadcastTxType txType) external view returns (BroadcastTxSummary[] memory);
2354
2355 /// Returns all broadcasts for the given contract on `chainId`.
2356 ///
2357 /// Sorted such that the most recent broadcast is the first element, and the oldest is the last. i.e descending order of BroadcastTxSummary.blockNumber.
2358 #[cheatcode(group = Filesystem)]
2359 function getBroadcasts(string calldata contractName, uint64 chainId) external view returns (BroadcastTxSummary[] memory);
2360
2361 /// Returns the most recent deployment for the current `chainId`.
2362 #[cheatcode(group = Filesystem)]
2363 function getDeployment(string calldata contractName) external view returns (address deployedAddress);
2364
2365 /// Returns the most recent deployment for the given contract on `chainId`
2366 #[cheatcode(group = Filesystem)]
2367 function getDeployment(string calldata contractName, uint64 chainId) external view returns (address deployedAddress);
2368
2369 /// Returns all deployments for the given contract on `chainId`
2370 ///
2371 /// Sorted in descending order of deployment time i.e descending order of BroadcastTxSummary.blockNumber.
2372 ///
2373 /// The most recent deployment is the first element, and the oldest is the last.
2374 #[cheatcode(group = Filesystem)]
2375 function getDeployments(string calldata contractName, uint64 chainId) external view returns (address[] memory deployedAddresses);
2376
2377 // -------- Foreign Function Interface --------
2378
2379 /// Performs a foreign function call via the terminal.
2380 #[cheatcode(group = Filesystem)]
2381 function ffi(string[] calldata commandInput) external returns (bytes memory result);
2382
2383 /// Performs a foreign function call via the terminal and parses the output as a `uint256`.
2384 #[cheatcode(group = Filesystem)]
2385 function ffiUint(string[] calldata commandInput) external returns (uint256 result);
2386
2387 /// Performs a foreign function call via the terminal and returns the output as a string.
2388 #[cheatcode(group = Filesystem)]
2389 function ffiString(string[] calldata commandInput) external returns (string memory result);
2390
2391 /// Performs a foreign function call via the terminal and decodes the output as hex bytes.
2392 #[cheatcode(group = Filesystem)]
2393 function ffiBytes(string[] calldata commandInput) external returns (bytes memory result);
2394
2395 /// Performs a foreign function call via terminal and returns the exit code, stdout, and stderr.
2396 #[cheatcode(group = Filesystem)]
2397 function tryFfi(string[] calldata commandInput) external returns (FfiResult memory result);
2398
2399 // -------- User Interaction --------
2400
2401 /// Prompts the user for a string value in the terminal.
2402 #[cheatcode(group = Filesystem)]
2403 function prompt(string calldata promptText) external returns (string memory input);
2404
2405 /// Prompts the user for a hidden string value in the terminal.
2406 #[cheatcode(group = Filesystem)]
2407 function promptSecret(string calldata promptText) external returns (string memory input);
2408
2409 /// Prompts the user for hidden uint256 in the terminal (usually pk).
2410 #[cheatcode(group = Filesystem)]
2411 function promptSecretUint(string calldata promptText) external returns (uint256);
2412
2413 /// Prompts the user for an address in the terminal.
2414 #[cheatcode(group = Filesystem)]
2415 function promptAddress(string calldata promptText) external returns (address);
2416
2417 /// Prompts the user for uint256 in the terminal.
2418 #[cheatcode(group = Filesystem)]
2419 function promptUint(string calldata promptText) external returns (uint256);
2420
2421 // ======== Environment Variables ========
2422
2423 /// Resolves the env variable placeholders of a given input string.
2424 #[cheatcode(group = Environment)]
2425 function resolveEnv(string calldata input) external returns (string memory);
2426
2427 /// Sets environment variables.
2428 #[cheatcode(group = Environment)]
2429 function setEnv(string calldata name, string calldata value) external;
2430
2431 /// Gets the environment variable `name` and returns true if it exists, else returns false.
2432 #[cheatcode(group = Environment)]
2433 function envExists(string calldata name) external view returns (bool result);
2434
2435 /// Gets the environment variable `name` and parses it as `bool`.
2436 /// Reverts if the variable was not found or could not be parsed.
2437 #[cheatcode(group = Environment)]
2438 function envBool(string calldata name) external view returns (bool value);
2439 /// Gets the environment variable `name` and parses it as `uint256`.
2440 /// Reverts if the variable was not found or could not be parsed.
2441 #[cheatcode(group = Environment)]
2442 function envUint(string calldata name) external view returns (uint256 value);
2443 /// Gets the environment variable `name` and parses it as `int256`.
2444 /// Reverts if the variable was not found or could not be parsed.
2445 #[cheatcode(group = Environment)]
2446 function envInt(string calldata name) external view returns (int256 value);
2447 /// Gets the environment variable `name` and parses it as `address`.
2448 /// Reverts if the variable was not found or could not be parsed.
2449 #[cheatcode(group = Environment)]
2450 function envAddress(string calldata name) external view returns (address value);
2451 /// Gets the environment variable `name` and parses it as `bytes32`.
2452 /// Reverts if the variable was not found or could not be parsed.
2453 #[cheatcode(group = Environment)]
2454 function envBytes32(string calldata name) external view returns (bytes32 value);
2455 /// Gets the environment variable `name` and parses it as `string`.
2456 /// Reverts if the variable was not found or could not be parsed.
2457 #[cheatcode(group = Environment)]
2458 function envString(string calldata name) external view returns (string memory value);
2459 /// Gets the environment variable `name` and parses it as `bytes`.
2460 /// Reverts if the variable was not found or could not be parsed.
2461 #[cheatcode(group = Environment)]
2462 function envBytes(string calldata name) external view returns (bytes memory value);
2463
2464 /// Gets the environment variable `name` and parses it as an array of `bool`, delimited by `delim`.
2465 /// Reverts if the variable was not found or could not be parsed.
2466 #[cheatcode(group = Environment)]
2467 function envBool(string calldata name, string calldata delim) external view returns (bool[] memory value);
2468 /// Gets the environment variable `name` and parses it as an array of `uint256`, delimited by `delim`.
2469 /// Reverts if the variable was not found or could not be parsed.
2470 #[cheatcode(group = Environment)]
2471 function envUint(string calldata name, string calldata delim) external view returns (uint256[] memory value);
2472 /// Gets the environment variable `name` and parses it as an array of `int256`, delimited by `delim`.
2473 /// Reverts if the variable was not found or could not be parsed.
2474 #[cheatcode(group = Environment)]
2475 function envInt(string calldata name, string calldata delim) external view returns (int256[] memory value);
2476 /// Gets the environment variable `name` and parses it as an array of `address`, delimited by `delim`.
2477 /// Reverts if the variable was not found or could not be parsed.
2478 #[cheatcode(group = Environment)]
2479 function envAddress(string calldata name, string calldata delim) external view returns (address[] memory value);
2480 /// Gets the environment variable `name` and parses it as an array of `bytes32`, delimited by `delim`.
2481 /// Reverts if the variable was not found or could not be parsed.
2482 #[cheatcode(group = Environment)]
2483 function envBytes32(string calldata name, string calldata delim) external view returns (bytes32[] memory value);
2484 /// Gets the environment variable `name` and parses it as an array of `string`, delimited by `delim`.
2485 /// Reverts if the variable was not found or could not be parsed.
2486 #[cheatcode(group = Environment)]
2487 function envString(string calldata name, string calldata delim) external view returns (string[] memory value);
2488 /// Gets the environment variable `name` and parses it as an array of `bytes`, delimited by `delim`.
2489 /// Reverts if the variable was not found or could not be parsed.
2490 #[cheatcode(group = Environment)]
2491 function envBytes(string calldata name, string calldata delim) external view returns (bytes[] memory value);
2492
2493 /// Gets the environment variable `name` and parses it as `bool`.
2494 /// Reverts if the variable could not be parsed.
2495 /// Returns `defaultValue` if the variable was not found.
2496 #[cheatcode(group = Environment)]
2497 function envOr(string calldata name, bool defaultValue) external view returns (bool value);
2498 /// Gets the environment variable `name` and parses it as `uint256`.
2499 /// Reverts if the variable could not be parsed.
2500 /// Returns `defaultValue` if the variable was not found.
2501 #[cheatcode(group = Environment)]
2502 function envOr(string calldata name, uint256 defaultValue) external view returns (uint256 value);
2503 /// Gets the environment variable `name` and parses it as `int256`.
2504 /// Reverts if the variable could not be parsed.
2505 /// Returns `defaultValue` if the variable was not found.
2506 #[cheatcode(group = Environment)]
2507 function envOr(string calldata name, int256 defaultValue) external view returns (int256 value);
2508 /// Gets the environment variable `name` and parses it as `address`.
2509 /// Reverts if the variable could not be parsed.
2510 /// Returns `defaultValue` if the variable was not found.
2511 #[cheatcode(group = Environment)]
2512 function envOr(string calldata name, address defaultValue) external view returns (address value);
2513 /// Gets the environment variable `name` and parses it as `bytes32`.
2514 /// Reverts if the variable could not be parsed.
2515 /// Returns `defaultValue` if the variable was not found.
2516 #[cheatcode(group = Environment)]
2517 function envOr(string calldata name, bytes32 defaultValue) external view returns (bytes32 value);
2518 /// Gets the environment variable `name` and parses it as `string`.
2519 /// Reverts if the variable could not be parsed.
2520 /// Returns `defaultValue` if the variable was not found.
2521 #[cheatcode(group = Environment)]
2522 function envOr(string calldata name, string calldata defaultValue) external view returns (string memory value);
2523 /// Gets the environment variable `name` and parses it as `bytes`.
2524 /// Reverts if the variable could not be parsed.
2525 /// Returns `defaultValue` if the variable was not found.
2526 #[cheatcode(group = Environment)]
2527 function envOr(string calldata name, bytes calldata defaultValue) external view returns (bytes memory value);
2528
2529 /// Gets the environment variable `name` and parses it as an array of `bool`, delimited by `delim`.
2530 /// Reverts if the variable could not be parsed.
2531 /// Returns `defaultValue` if the variable was not found.
2532 #[cheatcode(group = Environment)]
2533 function envOr(string calldata name, string calldata delim, bool[] calldata defaultValue)
2534 external view
2535 returns (bool[] memory value);
2536 /// Gets the environment variable `name` and parses it as an array of `uint256`, delimited by `delim`.
2537 /// Reverts if the variable could not be parsed.
2538 /// Returns `defaultValue` if the variable was not found.
2539 #[cheatcode(group = Environment)]
2540 function envOr(string calldata name, string calldata delim, uint256[] calldata defaultValue)
2541 external view
2542 returns (uint256[] memory value);
2543 /// Gets the environment variable `name` and parses it as an array of `int256`, delimited by `delim`.
2544 /// Reverts if the variable could not be parsed.
2545 /// Returns `defaultValue` if the variable was not found.
2546 #[cheatcode(group = Environment)]
2547 function envOr(string calldata name, string calldata delim, int256[] calldata defaultValue)
2548 external view
2549 returns (int256[] memory value);
2550 /// Gets the environment variable `name` and parses it as an array of `address`, delimited by `delim`.
2551 /// Reverts if the variable could not be parsed.
2552 /// Returns `defaultValue` if the variable was not found.
2553 #[cheatcode(group = Environment)]
2554 function envOr(string calldata name, string calldata delim, address[] calldata defaultValue)
2555 external view
2556 returns (address[] memory value);
2557 /// Gets the environment variable `name` and parses it as an array of `bytes32`, delimited by `delim`.
2558 /// Reverts if the variable could not be parsed.
2559 /// Returns `defaultValue` if the variable was not found.
2560 #[cheatcode(group = Environment)]
2561 function envOr(string calldata name, string calldata delim, bytes32[] calldata defaultValue)
2562 external view
2563 returns (bytes32[] memory value);
2564 /// Gets the environment variable `name` and parses it as an array of `string`, delimited by `delim`.
2565 /// Reverts if the variable could not be parsed.
2566 /// Returns `defaultValue` if the variable was not found.
2567 #[cheatcode(group = Environment)]
2568 function envOr(string calldata name, string calldata delim, string[] calldata defaultValue)
2569 external view
2570 returns (string[] memory value);
2571 /// Gets the environment variable `name` and parses it as an array of `bytes`, delimited by `delim`.
2572 /// Reverts if the variable could not be parsed.
2573 /// Returns `defaultValue` if the variable was not found.
2574 #[cheatcode(group = Environment)]
2575 function envOr(string calldata name, string calldata delim, bytes[] calldata defaultValue)
2576 external view
2577 returns (bytes[] memory value);
2578
2579 /// Returns true if `forge` command was executed in given context.
2580 #[cheatcode(group = Environment)]
2581 function isContext(ForgeContext context) external view returns (bool result);
2582
2583 // ======== Scripts ========
2584 // -------- Broadcasting Transactions --------
2585
2586 /// Has the next call (at this call depth only) create transactions that can later be signed and sent onchain.
2587 ///
2588 /// Broadcasting address is determined by checking the following in order:
2589 /// 1. If `--sender` argument was provided, that address is used.
2590 /// 2. If exactly one signer (e.g. private key, hw wallet, keystore) is set when `forge broadcast` is invoked, that signer is used.
2591 /// 3. Otherwise, default foundry sender (1804c8AB1F12E6bbf3894d4083f33e07309d1f38) is used.
2592 #[cheatcode(group = Scripting)]
2593 function broadcast() external;
2594
2595 /// Has the next call (at this call depth only) create a transaction with the address provided
2596 /// as the sender that can later be signed and sent onchain.
2597 #[cheatcode(group = Scripting)]
2598 function broadcast(address signer) external;
2599
2600 /// Has the next call (at this call depth only) create a transaction with the private key
2601 /// provided as the sender that can later be signed and sent onchain.
2602 #[cheatcode(group = Scripting)]
2603 function broadcast(uint256 privateKey) external;
2604
2605 /// Has all subsequent calls (at this call depth only) create transactions that can later be signed and sent onchain.
2606 ///
2607 /// Broadcasting address is determined by checking the following in order:
2608 /// 1. If `--sender` argument was provided, that address is used.
2609 /// 2. If exactly one signer (e.g. private key, hw wallet, keystore) is set when `forge broadcast` is invoked, that signer is used.
2610 /// 3. Otherwise, default foundry sender (1804c8AB1F12E6bbf3894d4083f33e07309d1f38) is used.
2611 #[cheatcode(group = Scripting)]
2612 function startBroadcast() external;
2613
2614 /// Has all subsequent calls (at this call depth only) create transactions with the address
2615 /// provided that can later be signed and sent onchain.
2616 #[cheatcode(group = Scripting)]
2617 function startBroadcast(address signer) external;
2618
2619 /// Has all subsequent calls (at this call depth only) create transactions with the private key
2620 /// provided that can later be signed and sent onchain.
2621 #[cheatcode(group = Scripting)]
2622 function startBroadcast(uint256 privateKey) external;
2623
2624 /// Stops collecting onchain transactions.
2625 #[cheatcode(group = Scripting)]
2626 function stopBroadcast() external;
2627
2628 /// Takes a signed transaction and broadcasts it to the network.
2629 #[cheatcode(group = Scripting)]
2630 function broadcastRawTransaction(bytes calldata data) external;
2631
2632 /// Sign an EIP-7702 authorization for delegation
2633 #[cheatcode(group = Scripting)]
2634 function signDelegation(address implementation, uint256 privateKey) external returns (SignedDelegation memory signedDelegation);
2635
2636 /// Sign an EIP-7702 authorization for delegation for specific nonce
2637 #[cheatcode(group = Scripting)]
2638 function signDelegation(address implementation, uint256 privateKey, uint64 nonce) external returns (SignedDelegation memory signedDelegation);
2639
2640 /// Sign an EIP-7702 authorization for delegation, with optional cross-chain validity.
2641 #[cheatcode(group = Scripting)]
2642 function signDelegation(address implementation, uint256 privateKey, bool crossChain) external returns (SignedDelegation memory signedDelegation);
2643
2644 /// Designate the next call as an EIP-7702 transaction
2645 #[cheatcode(group = Scripting)]
2646 function attachDelegation(SignedDelegation calldata signedDelegation) external;
2647
2648 /// Designate the next call as an EIP-7702 transaction, with optional cross-chain validity.
2649 #[cheatcode(group = Scripting)]
2650 function attachDelegation(SignedDelegation calldata signedDelegation, bool crossChain) external;
2651
2652 /// Sign an EIP-7702 authorization and designate the next call as an EIP-7702 transaction
2653 #[cheatcode(group = Scripting)]
2654 function signAndAttachDelegation(address implementation, uint256 privateKey) external returns (SignedDelegation memory signedDelegation);
2655
2656 /// Sign an EIP-7702 authorization and designate the next call as an EIP-7702 transaction for specific nonce
2657 #[cheatcode(group = Scripting)]
2658 function signAndAttachDelegation(address implementation, uint256 privateKey, uint64 nonce) external returns (SignedDelegation memory signedDelegation);
2659
2660 /// Sign an EIP-7702 authorization and designate the next call as an EIP-7702 transaction, with optional cross-chain validity.
2661 #[cheatcode(group = Scripting)]
2662 function signAndAttachDelegation(address implementation, uint256 privateKey, bool crossChain) external returns (SignedDelegation memory signedDelegation);
2663
2664 /// Attach an EIP-4844 blob to the next call
2665 #[cheatcode(group = Scripting)]
2666 function attachBlob(bytes calldata blob) external;
2667
2668 /// Returns addresses of available unlocked wallets in the script environment.
2669 #[cheatcode(group = Scripting)]
2670 function getWallets() external view returns (address[] memory wallets);
2671
2672 // ======== Utilities ========
2673
2674 // -------- Strings --------
2675
2676 /// Converts the given value to a `string`.
2677 #[cheatcode(group = String)]
2678 function toString(address value) external pure returns (string memory stringifiedValue);
2679 /// Converts the given value to a `string`.
2680 #[cheatcode(group = String)]
2681 function toString(bytes calldata value) external pure returns (string memory stringifiedValue);
2682 /// Converts the given value to a `string`.
2683 #[cheatcode(group = String)]
2684 function toString(bytes32 value) external pure returns (string memory stringifiedValue);
2685 /// Converts the given value to a `string`.
2686 #[cheatcode(group = String)]
2687 function toString(bool value) external pure returns (string memory stringifiedValue);
2688 /// Converts the given value to a `string`.
2689 #[cheatcode(group = String)]
2690 function toString(uint256 value) external pure returns (string memory stringifiedValue);
2691 /// Converts the given value to a `string`.
2692 #[cheatcode(group = String)]
2693 function toString(int256 value) external pure returns (string memory stringifiedValue);
2694
2695 /// Parses the given `string` into `bytes`.
2696 #[cheatcode(group = String)]
2697 function parseBytes(string calldata stringifiedValue) external pure returns (bytes memory parsedValue);
2698 /// Parses the given `string` into an `address`.
2699 #[cheatcode(group = String)]
2700 function parseAddress(string calldata stringifiedValue) external pure returns (address parsedValue);
2701 /// Parses the given `string` into a `uint256`.
2702 #[cheatcode(group = String)]
2703 function parseUint(string calldata stringifiedValue) external pure returns (uint256 parsedValue);
2704 /// Parses the given `string` into a `int256`.
2705 #[cheatcode(group = String)]
2706 function parseInt(string calldata stringifiedValue) external pure returns (int256 parsedValue);
2707 /// Parses the given `string` into a `bytes32`.
2708 #[cheatcode(group = String)]
2709 function parseBytes32(string calldata stringifiedValue) external pure returns (bytes32 parsedValue);
2710 /// Parses the given `string` into a `bool`.
2711 #[cheatcode(group = String)]
2712 function parseBool(string calldata stringifiedValue) external pure returns (bool parsedValue);
2713
2714 /// Converts the given `string` value to Lowercase.
2715 #[cheatcode(group = String)]
2716 function toLowercase(string calldata input) external pure returns (string memory output);
2717 /// Converts the given `string` value to Uppercase.
2718 #[cheatcode(group = String)]
2719 function toUppercase(string calldata input) external pure returns (string memory output);
2720 /// Trims leading and trailing whitespace from the given `string` value.
2721 #[cheatcode(group = String)]
2722 function trim(string calldata input) external pure returns (string memory output);
2723 /// Replaces occurrences of `from` in the given `string` with `to`.
2724 #[cheatcode(group = String)]
2725 function replace(string calldata input, string calldata from, string calldata to) external pure returns (string memory output);
2726 /// Splits the given `string` into an array of strings divided by the `delimiter`.
2727 #[cheatcode(group = String)]
2728 function split(string calldata input, string calldata delimiter) external pure returns (string[] memory outputs);
2729 /// Returns the index of the first occurrence of a `key` in an `input` string.
2730 /// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `key` is not found.
2731 /// Returns 0 in case of an empty `key`.
2732 #[cheatcode(group = String)]
2733 function indexOf(string calldata input, string calldata key) external pure returns (uint256);
2734 /// Returns true if `search` is found in `subject`, false otherwise.
2735 #[cheatcode(group = String)]
2736 function contains(string calldata subject, string calldata search) external pure returns (bool result);
2737
2738 // ======== JSON Parsing and Manipulation ========
2739
2740 // -------- Reading --------
2741
2742 // NOTE: Please read https://book.getfoundry.sh/cheatcodes/parse-json to understand the
2743 // limitations and caveats of the JSON parsing cheats.
2744
2745 /// Checks if `key` (a JSONPath selector; use `.foo`, not `foo`, for object fields) exists in a JSON object.
2746 /// `keyExists` is being deprecated in favor of `keyExistsJson`. It will be removed in future versions.
2747 #[cheatcode(group = Json, status = Deprecated(Some("replaced by `keyExistsJson`")))]
2748 function keyExists(string calldata json, string calldata key) external view returns (bool);
2749 /// Checks if `key` (a JSONPath selector; use `.foo`, not `foo`, for object fields) exists in a JSON object.
2750 #[cheatcode(group = Json)]
2751 function keyExistsJson(string calldata json, string calldata key) external view returns (bool);
2752
2753 /// ABI-encodes a JSON object.
2754 #[cheatcode(group = Json)]
2755 function parseJson(string calldata json) external pure returns (bytes memory abiEncodedData);
2756 /// ABI-encodes a JSON object at `key` (a JSONPath selector; use `.foo`, not `foo`, for object fields).
2757 #[cheatcode(group = Json)]
2758 function parseJson(string calldata json, string calldata key) external pure returns (bytes memory abiEncodedData);
2759
2760 // The following parseJson cheatcodes will do type coercion, for the type that they indicate.
2761 // For example, parseJsonUint will coerce all values to a uint256. That includes stringified numbers '12.'
2762 // and hex numbers '0xEF.'.
2763 // Type coercion works ONLY for discrete values or arrays. That means that the key must return a value or array, not
2764 // a JSON object.
2765
2766 /// Parses a string of JSON data at `key` (a JSONPath selector; use `.foo`, not `foo`, for object fields) and coerces it to `uint256`.
2767 #[cheatcode(group = Json)]
2768 function parseJsonUint(string calldata json, string calldata key) external pure returns (uint256);
2769 /// Parses a string of JSON data at `key` (a JSONPath selector; use `.foo`, not `foo`, for object fields) and coerces it to `uint256`, or returns `defaultValue` if the key does not exist.
2770 #[cheatcode(group = Json)]
2771 function parseJsonUint(string calldata json, string calldata key, uint256 defaultValue) external pure returns (uint256);
2772 /// Parses a string of JSON data at `key` (a JSONPath selector; use `.foo`, not `foo`, for object fields) and coerces it to `uint256[]`.
2773 #[cheatcode(group = Json)]
2774 function parseJsonUintArray(string calldata json, string calldata key) external pure returns (uint256[] memory);
2775 /// Parses a string of JSON data at `key` (a JSONPath selector; use `.foo`, not `foo`, for object fields) and coerces it to `uint256[]`, or returns `defaultValue` if the key does not exist.
2776 #[cheatcode(group = Json)]
2777 function parseJsonUintArray(string calldata json, string calldata key, uint256[] calldata defaultValue)
2778 external
2779 pure
2780 returns (uint256[] memory);
2781 /// Parses a string of JSON data at `key` (a JSONPath selector; use `.foo`, not `foo`, for object fields) and coerces it to `int256`.
2782 #[cheatcode(group = Json)]
2783 function parseJsonInt(string calldata json, string calldata key) external pure returns (int256);
2784 /// Parses a string of JSON data at `key` (a JSONPath selector; use `.foo`, not `foo`, for object fields) and coerces it to `int256`, or returns `defaultValue` if the key does not exist.
2785 #[cheatcode(group = Json)]
2786 function parseJsonInt(string calldata json, string calldata key, int256 defaultValue) external pure returns (int256);
2787 /// Parses a string of JSON data at `key` (a JSONPath selector; use `.foo`, not `foo`, for object fields) and coerces it to `int256[]`.
2788 #[cheatcode(group = Json)]
2789 function parseJsonIntArray(string calldata json, string calldata key) external pure returns (int256[] memory);
2790 /// Parses a string of JSON data at `key` (a JSONPath selector; use `.foo`, not `foo`, for object fields) and coerces it to `int256[]`, or returns `defaultValue` if the key does not exist.
2791 #[cheatcode(group = Json)]
2792 function parseJsonIntArray(string calldata json, string calldata key, int256[] calldata defaultValue)
2793 external
2794 pure
2795 returns (int256[] memory);
2796 /// Parses a string of JSON data at `key` (a JSONPath selector; use `.foo`, not `foo`, for object fields) and coerces it to `bool`.
2797 #[cheatcode(group = Json)]
2798 function parseJsonBool(string calldata json, string calldata key) external pure returns (bool);
2799 /// Parses a string of JSON data at `key` (a JSONPath selector; use `.foo`, not `foo`, for object fields) and coerces it to `bool`, or returns `defaultValue` if the key does not exist.
2800 #[cheatcode(group = Json)]
2801 function parseJsonBool(string calldata json, string calldata key, bool defaultValue) external pure returns (bool);
2802 /// Parses a string of JSON data at `key` (a JSONPath selector; use `.foo`, not `foo`, for object fields) and coerces it to `bool[]`.
2803 #[cheatcode(group = Json)]
2804 function parseJsonBoolArray(string calldata json, string calldata key) external pure returns (bool[] memory);
2805 /// Parses a string of JSON data at `key` (a JSONPath selector; use `.foo`, not `foo`, for object fields) and coerces it to `bool[]`, or returns `defaultValue` if the key does not exist.
2806 #[cheatcode(group = Json)]
2807 function parseJsonBoolArray(string calldata json, string calldata key, bool[] calldata defaultValue)
2808 external
2809 pure
2810 returns (bool[] memory);
2811 /// Parses a string of JSON data at `key` (a JSONPath selector; use `.foo`, not `foo`, for object fields) and coerces it to `address`.
2812 #[cheatcode(group = Json)]
2813 function parseJsonAddress(string calldata json, string calldata key) external pure returns (address);
2814 /// Parses a string of JSON data at `key` (a JSONPath selector; use `.foo`, not `foo`, for object fields) and coerces it to `address`, or returns `defaultValue` if the key does not exist.
2815 #[cheatcode(group = Json)]
2816 function parseJsonAddress(string calldata json, string calldata key, address defaultValue) external pure returns (address);
2817 /// Parses a string of JSON data at `key` (a JSONPath selector; use `.foo`, not `foo`, for object fields) and coerces it to `address[]`.
2818 #[cheatcode(group = Json)]
2819 function parseJsonAddressArray(string calldata json, string calldata key)
2820 external
2821 pure
2822 returns (address[] memory);
2823 /// Parses a string of JSON data at `key` (a JSONPath selector; use `.foo`, not `foo`, for object fields) and coerces it to `address[]`, or returns `defaultValue` if the key does not exist.
2824 #[cheatcode(group = Json)]
2825 function parseJsonAddressArray(string calldata json, string calldata key, address[] calldata defaultValue)
2826 external
2827 pure
2828 returns (address[] memory);
2829 /// Parses a string of JSON data at `key` (a JSONPath selector; use `.foo`, not `foo`, for object fields) and coerces it to `string`.
2830 #[cheatcode(group = Json)]
2831 function parseJsonString(string calldata json, string calldata key) external pure returns (string memory);
2832 /// Parses a string of JSON data at `key` (a JSONPath selector; use `.foo`, not `foo`, for object fields) and coerces it to `string`, or returns `defaultValue` if the key does not exist.
2833 #[cheatcode(group = Json)]
2834 function parseJsonString(string calldata json, string calldata key, string calldata defaultValue)
2835 external
2836 pure
2837 returns (string memory);
2838 /// Parses a string of JSON data at `key` (a JSONPath selector; use `.foo`, not `foo`, for object fields) and coerces it to `string[]`.
2839 #[cheatcode(group = Json)]
2840 function parseJsonStringArray(string calldata json, string calldata key) external pure returns (string[] memory);
2841 /// Parses a string of JSON data at `key` (a JSONPath selector; use `.foo`, not `foo`, for object fields) and coerces it to `string[]`, or returns `defaultValue` if the key does not exist.
2842 #[cheatcode(group = Json)]
2843 function parseJsonStringArray(string calldata json, string calldata key, string[] calldata defaultValue)
2844 external
2845 pure
2846 returns (string[] memory);
2847 /// Returns the length of the JSON array at `key` (a JSONPath selector; use `.foo`, not `foo`, for object fields).
2848 #[cheatcode(group = Json)]
2849 function parseJsonArrayLength(string calldata json, string calldata key) external pure returns (uint256 length);
2850 /// Parses a string of JSON data at `key` (a JSONPath selector; use `.foo`, not `foo`, for object fields) and coerces it to `bytes`.
2851 #[cheatcode(group = Json)]
2852 function parseJsonBytes(string calldata json, string calldata key) external pure returns (bytes memory);
2853 /// Parses a string of JSON data at `key` (a JSONPath selector; use `.foo`, not `foo`, for object fields) and coerces it to `bytes`, or returns `defaultValue` if the key does not exist.
2854 #[cheatcode(group = Json)]
2855 function parseJsonBytes(string calldata json, string calldata key, bytes calldata defaultValue)
2856 external
2857 pure
2858 returns (bytes memory);
2859 /// Parses a string of JSON data at `key` (a JSONPath selector; use `.foo`, not `foo`, for object fields) and coerces it to `bytes[]`.
2860 #[cheatcode(group = Json)]
2861 function parseJsonBytesArray(string calldata json, string calldata key) external pure returns (bytes[] memory);
2862 /// Parses a string of JSON data at `key` (a JSONPath selector; use `.foo`, not `foo`, for object fields) and coerces it to `bytes[]`, or returns `defaultValue` if the key does not exist.
2863 #[cheatcode(group = Json)]
2864 function parseJsonBytesArray(string calldata json, string calldata key, bytes[] calldata defaultValue)
2865 external
2866 pure
2867 returns (bytes[] memory);
2868 /// Parses a string of JSON data at `key` (a JSONPath selector; use `.foo`, not `foo`, for object fields) and coerces it to `bytes32`.
2869 #[cheatcode(group = Json)]
2870 function parseJsonBytes32(string calldata json, string calldata key) external pure returns (bytes32);
2871 /// Parses a string of JSON data at `key` (a JSONPath selector; use `.foo`, not `foo`, for object fields) and coerces it to `bytes32`, or returns `defaultValue` if the key does not exist.
2872 #[cheatcode(group = Json)]
2873 function parseJsonBytes32(string calldata json, string calldata key, bytes32 defaultValue) external pure returns (bytes32);
2874 /// Parses a string of JSON data at `key` (a JSONPath selector; use `.foo`, not `foo`, for object fields) and coerces it to `bytes32[]`.
2875 #[cheatcode(group = Json)]
2876 function parseJsonBytes32Array(string calldata json, string calldata key)
2877 external
2878 pure
2879 returns (bytes32[] memory);
2880 /// Parses a string of JSON data at `key` (a JSONPath selector; use `.foo`, not `foo`, for object fields) and coerces it to `bytes32[]`, or returns `defaultValue` if the key does not exist.
2881 #[cheatcode(group = Json)]
2882 function parseJsonBytes32Array(string calldata json, string calldata key, bytes32[] calldata defaultValue)
2883 external
2884 pure
2885 returns (bytes32[] memory);
2886
2887 /// Parses a string of JSON data and coerces it to type corresponding to `typeDescription`.
2888 #[cheatcode(group = Json)]
2889 function parseJsonType(string calldata json, string calldata typeDescription) external pure returns (bytes memory);
2890 /// Parses a string of JSON data at `key` (a JSONPath selector; use `.foo`, not `foo`, for object fields) and coerces it to type corresponding to `typeDescription`.
2891 #[cheatcode(group = Json)]
2892 function parseJsonType(string calldata json, string calldata key, string calldata typeDescription) external pure returns (bytes memory);
2893 /// Parses a string of JSON data at `key` (a JSONPath selector; use `.foo`, not `foo`, for object fields) and coerces it to type array corresponding to `typeDescription`.
2894 #[cheatcode(group = Json)]
2895 function parseJsonTypeArray(string calldata json, string calldata key, string calldata typeDescription)
2896 external
2897 pure
2898 returns (bytes memory);
2899
2900 /// Returns an array of all the keys in a JSON object.
2901 #[cheatcode(group = Json)]
2902 function parseJsonKeys(string calldata json, string calldata key) external pure returns (string[] memory keys);
2903
2904 // -------- Writing --------
2905
2906 // NOTE: Please read https://book.getfoundry.sh/cheatcodes/serialize-json to understand how
2907 // to use the serialization cheats.
2908
2909 /// Serializes a key and value to a JSON object stored in-memory that can be later written to a file.
2910 /// Returns the stringified version of the specific JSON file up to that moment.
2911 #[cheatcode(group = Json)]
2912 function serializeJson(string calldata objectKey, string calldata value) external returns (string memory json);
2913
2914 /// See `serializeJson`.
2915 #[cheatcode(group = Json)]
2916 function serializeBool(string calldata objectKey, string calldata valueKey, bool value)
2917 external
2918 returns (string memory json);
2919 /// See `serializeJson`.
2920 #[cheatcode(group = Json)]
2921 function serializeUint(string calldata objectKey, string calldata valueKey, uint256 value)
2922 external
2923 returns (string memory json);
2924 /// See `serializeJson`.
2925 #[cheatcode(group = Json)]
2926 function serializeUintToHex(string calldata objectKey, string calldata valueKey, uint256 value)
2927 external
2928 returns (string memory json);
2929 /// See `serializeJson`.
2930 #[cheatcode(group = Json)]
2931 function serializeInt(string calldata objectKey, string calldata valueKey, int256 value)
2932 external
2933 returns (string memory json);
2934 /// See `serializeJson`.
2935 #[cheatcode(group = Json)]
2936 function serializeAddress(string calldata objectKey, string calldata valueKey, address value)
2937 external
2938 returns (string memory json);
2939 /// See `serializeJson`.
2940 #[cheatcode(group = Json)]
2941 function serializeBytes32(string calldata objectKey, string calldata valueKey, bytes32 value)
2942 external
2943 returns (string memory json);
2944 /// See `serializeJson`.
2945 #[cheatcode(group = Json)]
2946 function serializeString(string calldata objectKey, string calldata valueKey, string calldata value)
2947 external
2948 returns (string memory json);
2949 /// See `serializeJson`.
2950 #[cheatcode(group = Json)]
2951 function serializeBytes(string calldata objectKey, string calldata valueKey, bytes calldata value)
2952 external
2953 returns (string memory json);
2954
2955 /// See `serializeJson`.
2956 #[cheatcode(group = Json)]
2957 function serializeBool(string calldata objectKey, string calldata valueKey, bool[] calldata values)
2958 external
2959 returns (string memory json);
2960 /// See `serializeJson`.
2961 #[cheatcode(group = Json)]
2962 function serializeUint(string calldata objectKey, string calldata valueKey, uint256[] calldata values)
2963 external
2964 returns (string memory json);
2965 /// See `serializeJson`.
2966 #[cheatcode(group = Json)]
2967 function serializeInt(string calldata objectKey, string calldata valueKey, int256[] calldata values)
2968 external
2969 returns (string memory json);
2970 /// See `serializeJson`.
2971 #[cheatcode(group = Json)]
2972 function serializeAddress(string calldata objectKey, string calldata valueKey, address[] calldata values)
2973 external
2974 returns (string memory json);
2975 /// See `serializeJson`.
2976 #[cheatcode(group = Json)]
2977 function serializeBytes32(string calldata objectKey, string calldata valueKey, bytes32[] calldata values)
2978 external
2979 returns (string memory json);
2980 /// See `serializeJson`.
2981 #[cheatcode(group = Json)]
2982 function serializeString(string calldata objectKey, string calldata valueKey, string[] calldata values)
2983 external
2984 returns (string memory json);
2985 /// See `serializeJson`.
2986 #[cheatcode(group = Json)]
2987 function serializeBytes(string calldata objectKey, string calldata valueKey, bytes[] calldata values)
2988 external
2989 returns (string memory json);
2990 /// See `serializeJson`.
2991 #[cheatcode(group = Json)]
2992 function serializeJsonType(string calldata typeDescription, bytes calldata value)
2993 external
2994 pure
2995 returns (string memory json);
2996 /// See `serializeJson`.
2997 #[cheatcode(group = Json)]
2998 function serializeJsonType(string calldata objectKey, string calldata valueKey, string calldata typeDescription, bytes calldata value)
2999 external
3000 returns (string memory json);
3001
3002 // NOTE: Please read https://book.getfoundry.sh/cheatcodes/write-json to understand how
3003 // to use the JSON writing cheats.
3004
3005 /// Write a serialized JSON object to a file. If the file exists, it will be overwritten.
3006 #[cheatcode(group = Json)]
3007 function writeJson(string calldata json, string calldata path) external;
3008
3009 /// Write a serialized JSON object to an **existing** JSON file, replacing a value with key = <value_key.>
3010 /// This is useful to replace a specific value of a JSON file, without having to parse the entire thing.
3011 /// This cheatcode will create new keys if they didn't previously exist.
3012 #[cheatcode(group = Json)]
3013 function writeJson(string calldata json, string calldata path, string calldata valueKey) external;
3014
3015 // ======== TOML Parsing and Manipulation ========
3016
3017 // -------- Reading --------
3018
3019 // NOTE: Please read https://book.getfoundry.sh/cheatcodes/parse-toml to understand the
3020 // limitations and caveats of the TOML parsing cheat.
3021
3022 /// Checks if `key` exists in a TOML table.
3023 #[cheatcode(group = Toml)]
3024 function keyExistsToml(string calldata toml, string calldata key) external view returns (bool);
3025
3026 /// ABI-encodes a TOML table.
3027 #[cheatcode(group = Toml)]
3028 function parseToml(string calldata toml) external pure returns (bytes memory abiEncodedData);
3029
3030 /// ABI-encodes a TOML table at `key`.
3031 #[cheatcode(group = Toml)]
3032 function parseToml(string calldata toml, string calldata key) external pure returns (bytes memory abiEncodedData);
3033
3034 // The following parseToml cheatcodes will do type coercion, for the type that they indicate.
3035 // For example, parseTomlUint will coerce all values to a uint256. That includes stringified numbers '12.'
3036 // and hex numbers '0xEF.'.
3037 // Type coercion works ONLY for discrete values or arrays. That means that the key must return a value or array, not
3038 // a TOML table.
3039
3040 /// Parses a string of TOML data at `key` and coerces it to `uint256`.
3041 #[cheatcode(group = Toml)]
3042 function parseTomlUint(string calldata toml, string calldata key) external pure returns (uint256);
3043 /// Parses a string of TOML data at `key` and coerces it to `uint256`, or returns `defaultValue` if the key does not exist.
3044 #[cheatcode(group = Toml)]
3045 function parseTomlUint(string calldata toml, string calldata key, uint256 defaultValue) external pure returns (uint256);
3046 /// Parses a string of TOML data at `key` and coerces it to `uint256[]`.
3047 #[cheatcode(group = Toml)]
3048 function parseTomlUintArray(string calldata toml, string calldata key) external pure returns (uint256[] memory);
3049 /// Parses a string of TOML data at `key` and coerces it to `uint256[]`, or returns `defaultValue` if the key does not exist.
3050 #[cheatcode(group = Toml)]
3051 function parseTomlUintArray(string calldata toml, string calldata key, uint256[] calldata defaultValue)
3052 external
3053 pure
3054 returns (uint256[] memory);
3055 /// Parses a string of TOML data at `key` and coerces it to `int256`.
3056 #[cheatcode(group = Toml)]
3057 function parseTomlInt(string calldata toml, string calldata key) external pure returns (int256);
3058 /// Parses a string of TOML data at `key` and coerces it to `int256`, or returns `defaultValue` if the key does not exist.
3059 #[cheatcode(group = Toml)]
3060 function parseTomlInt(string calldata toml, string calldata key, int256 defaultValue) external pure returns (int256);
3061 /// Parses a string of TOML data at `key` and coerces it to `int256[]`.
3062 #[cheatcode(group = Toml)]
3063 function parseTomlIntArray(string calldata toml, string calldata key) external pure returns (int256[] memory);
3064 /// Parses a string of TOML data at `key` and coerces it to `int256[]`, or returns `defaultValue` if the key does not exist.
3065 #[cheatcode(group = Toml)]
3066 function parseTomlIntArray(string calldata toml, string calldata key, int256[] calldata defaultValue)
3067 external
3068 pure
3069 returns (int256[] memory);
3070 /// Parses a string of TOML data at `key` and coerces it to `bool`.
3071 #[cheatcode(group = Toml)]
3072 function parseTomlBool(string calldata toml, string calldata key) external pure returns (bool);
3073 /// Parses a string of TOML data at `key` and coerces it to `bool`, or returns `defaultValue` if the key does not exist.
3074 #[cheatcode(group = Toml)]
3075 function parseTomlBool(string calldata toml, string calldata key, bool defaultValue) external pure returns (bool);
3076 /// Parses a string of TOML data at `key` and coerces it to `bool[]`.
3077 #[cheatcode(group = Toml)]
3078 function parseTomlBoolArray(string calldata toml, string calldata key) external pure returns (bool[] memory);
3079 /// Parses a string of TOML data at `key` and coerces it to `bool[]`, or returns `defaultValue` if the key does not exist.
3080 #[cheatcode(group = Toml)]
3081 function parseTomlBoolArray(string calldata toml, string calldata key, bool[] calldata defaultValue)
3082 external
3083 pure
3084 returns (bool[] memory);
3085 /// Parses a string of TOML data at `key` and coerces it to `address`.
3086 #[cheatcode(group = Toml)]
3087 function parseTomlAddress(string calldata toml, string calldata key) external pure returns (address);
3088 /// Parses a string of TOML data at `key` and coerces it to `address`, or returns `defaultValue` if the key does not exist.
3089 #[cheatcode(group = Toml)]
3090 function parseTomlAddress(string calldata toml, string calldata key, address defaultValue) external pure returns (address);
3091 /// Parses a string of TOML data at `key` and coerces it to `address[]`.
3092 #[cheatcode(group = Toml)]
3093 function parseTomlAddressArray(string calldata toml, string calldata key)
3094 external
3095 pure
3096 returns (address[] memory);
3097 /// Parses a string of TOML data at `key` and coerces it to `address[]`, or returns `defaultValue` if the key does not exist.
3098 #[cheatcode(group = Toml)]
3099 function parseTomlAddressArray(string calldata toml, string calldata key, address[] calldata defaultValue)
3100 external
3101 pure
3102 returns (address[] memory);
3103 /// Parses a string of TOML data at `key` and coerces it to `string`.
3104 #[cheatcode(group = Toml)]
3105 function parseTomlString(string calldata toml, string calldata key) external pure returns (string memory);
3106 /// Parses a string of TOML data at `key` and coerces it to `string`, or returns `defaultValue` if the key does not exist.
3107 #[cheatcode(group = Toml)]
3108 function parseTomlString(string calldata toml, string calldata key, string calldata defaultValue)
3109 external
3110 pure
3111 returns (string memory);
3112 /// Parses a string of TOML data at `key` and coerces it to `string[]`.
3113 #[cheatcode(group = Toml)]
3114 function parseTomlStringArray(string calldata toml, string calldata key) external pure returns (string[] memory);
3115 /// Parses a string of TOML data at `key` and coerces it to `string[]`, or returns `defaultValue` if the key does not exist.
3116 #[cheatcode(group = Toml)]
3117 function parseTomlStringArray(string calldata toml, string calldata key, string[] calldata defaultValue)
3118 external
3119 pure
3120 returns (string[] memory);
3121 /// Parses a string of TOML data at `key` and coerces it to `bytes`.
3122 #[cheatcode(group = Toml)]
3123 function parseTomlBytes(string calldata toml, string calldata key) external pure returns (bytes memory);
3124 /// Parses a string of TOML data at `key` and coerces it to `bytes`, or returns `defaultValue` if the key does not exist.
3125 #[cheatcode(group = Toml)]
3126 function parseTomlBytes(string calldata toml, string calldata key, bytes calldata defaultValue)
3127 external
3128 pure
3129 returns (bytes memory);
3130 /// Parses a string of TOML data at `key` and coerces it to `bytes[]`.
3131 #[cheatcode(group = Toml)]
3132 function parseTomlBytesArray(string calldata toml, string calldata key) external pure returns (bytes[] memory);
3133 /// Parses a string of TOML data at `key` and coerces it to `bytes[]`, or returns `defaultValue` if the key does not exist.
3134 #[cheatcode(group = Toml)]
3135 function parseTomlBytesArray(string calldata toml, string calldata key, bytes[] calldata defaultValue)
3136 external
3137 pure
3138 returns (bytes[] memory);
3139 /// Parses a string of TOML data at `key` and coerces it to `bytes32`.
3140 #[cheatcode(group = Toml)]
3141 function parseTomlBytes32(string calldata toml, string calldata key) external pure returns (bytes32);
3142 /// Parses a string of TOML data at `key` and coerces it to `bytes32`, or returns `defaultValue` if the key does not exist.
3143 #[cheatcode(group = Toml)]
3144 function parseTomlBytes32(string calldata toml, string calldata key, bytes32 defaultValue) external pure returns (bytes32);
3145 /// Parses a string of TOML data at `key` and coerces it to `bytes32[]`.
3146 #[cheatcode(group = Toml)]
3147 function parseTomlBytes32Array(string calldata toml, string calldata key)
3148 external
3149 pure
3150 returns (bytes32[] memory);
3151 /// Parses a string of TOML data at `key` and coerces it to `bytes32[]`, or returns `defaultValue` if the key does not exist.
3152 #[cheatcode(group = Toml)]
3153 function parseTomlBytes32Array(string calldata toml, string calldata key, bytes32[] calldata defaultValue)
3154 external
3155 pure
3156 returns (bytes32[] memory);
3157
3158 /// Parses a string of TOML data and coerces it to type corresponding to `typeDescription`.
3159 #[cheatcode(group = Toml)]
3160 function parseTomlType(string calldata toml, string calldata typeDescription) external pure returns (bytes memory);
3161 /// Parses a string of TOML data at `key` and coerces it to type corresponding to `typeDescription`.
3162 #[cheatcode(group = Toml)]
3163 function parseTomlType(string calldata toml, string calldata key, string calldata typeDescription) external pure returns (bytes memory);
3164 /// Parses a string of TOML data at `key` and coerces it to type array corresponding to `typeDescription`.
3165 #[cheatcode(group = Toml)]
3166 function parseTomlTypeArray(string calldata toml, string calldata key, string calldata typeDescription)
3167 external
3168 pure
3169 returns (bytes memory);
3170
3171 /// Returns an array of all the keys in a TOML table.
3172 #[cheatcode(group = Toml)]
3173 function parseTomlKeys(string calldata toml, string calldata key) external pure returns (string[] memory keys);
3174
3175 // -------- Writing --------
3176
3177 // NOTE: Please read https://book.getfoundry.sh/cheatcodes/write-toml to understand how
3178 // to use the TOML writing cheat.
3179
3180 /// Takes serialized JSON, converts to TOML and write a serialized TOML to a file.
3181 #[cheatcode(group = Toml)]
3182 function writeToml(string calldata json, string calldata path) external;
3183
3184 /// Takes serialized JSON, converts to TOML and write a serialized TOML table to an **existing** TOML file, replacing a value with key = <value_key.>
3185 /// This is useful to replace a specific value of a TOML file, without having to parse the entire thing.
3186 /// This cheatcode will create new keys if they didn't previously exist.
3187 #[cheatcode(group = Toml)]
3188 function writeToml(string calldata json, string calldata path, string calldata valueKey) external;
3189
3190 // ======== Cryptography ========
3191
3192 // -------- Key Management --------
3193
3194 /// Derives a private key from the name, labels the account with that name, and returns the wallet.
3195 #[cheatcode(group = Crypto)]
3196 function createWallet(string calldata walletLabel) external returns (Wallet memory wallet);
3197
3198 /// Generates a wallet from the private key and returns the wallet.
3199 #[cheatcode(group = Crypto)]
3200 function createWallet(uint256 privateKey) external returns (Wallet memory wallet);
3201
3202 /// Generates a wallet from the private key, labels the account with that name, and returns the wallet.
3203 #[cheatcode(group = Crypto)]
3204 function createWallet(uint256 privateKey, string calldata walletLabel) external returns (Wallet memory wallet);
3205
3206 /// Signs data with a `Wallet`.
3207 #[cheatcode(group = Crypto)]
3208 function sign(Wallet calldata wallet, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s);
3209
3210 /// Signs data with a `Wallet`.
3211 ///
3212 /// Returns a compact signature (`r`, `vs`) as per EIP-2098, where `vs` encodes both the
3213 /// signature's `s` value, and the recovery id `v` in a single bytes32.
3214 /// This format reduces the signature size from 65 to 64 bytes.
3215 #[cheatcode(group = Crypto)]
3216 function signCompact(Wallet calldata wallet, bytes32 digest) external pure returns (bytes32 r, bytes32 vs);
3217
3218 /// Signs `digest` with `privateKey` using the secp256k1 curve.
3219 #[cheatcode(group = Crypto)]
3220 function sign(uint256 privateKey, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s);
3221
3222 /// Signs `digest` with `privateKey` on the secp256k1 curve, using the given `nonce`
3223 /// as the raw ephemeral k value in ECDSA (instead of deriving it deterministically).
3224 #[cheatcode(group = Crypto)]
3225 function signWithNonceUnsafe(uint256 privateKey, bytes32 digest, uint256 nonce) external pure returns (uint8 v, bytes32 r, bytes32 s);
3226
3227 /// Signs `digest` as a Tempo V2 keychain signature for `account` using a secp256k1 access key.
3228 ///
3229 /// Returns the encoded signature bytes accepted by `SignatureVerifier.verifyKeychain`.
3230 #[cheatcode(group = Crypto)]
3231 function signKeychain(uint256 privateKey, address account, bytes32 digest) external pure returns (bytes memory signature);
3232
3233 /// Signs `digest` as a Tempo V2 keychain signature for `account` using a root or admin secp256k1 key.
3234 ///
3235 /// Returns the encoded signature bytes accepted by `SignatureVerifier.verifyKeychainAdmin`.
3236 /// The supplied `digest` should already be domain-separated with chain ID, contract address,
3237 /// and account address. Returns the same bytes as `signKeychain`.
3238 #[cheatcode(group = Crypto, status = Deprecated(Some("replaced by `signKeychain`; TIP-1137 stops admin keys at Tempo T14")))]
3239 function signKeychainAdmin(uint256 privateKey, address account, bytes32 digest) external pure returns (bytes memory signature);
3240
3241 /// Derives the address of the Tempo configurable account with the initial configuration `config`
3242 /// (TIP-1107), as `IConfigurableAccount.deriveAccount` does, without the chain's reserved
3243 /// address checks. `config.version` is ignored.
3244 #[cheatcode(group = Crypto)]
3245 function deriveConfigurableAccount(ConfigurableAccountConfig calldata config) external pure returns (address account);
3246
3247 /// Returns the digest that the owners of the configurable account `account` approve for
3248 /// `digest`, such as a transaction signature hash, under configuration version `configVersion`:
3249 /// `keccak256("tempo:configurable-account:signature" || digest || account || uint64(configVersion))`.
3250 #[cheatcode(group = Crypto)]
3251 function configurableAccountDigest(address account, uint64 configVersion, bytes32 digest) external pure returns (bytes32 ownerDigest);
3252
3253 /// Encodes a `0x05` configurable account signature for `account` from its current configuration
3254 /// `config` and encoded owner approvals of its owner digest (65-byte secp256k1, `0x01` P-256 or
3255 /// `0x02` WebAuthn signatures).
3256 ///
3257 /// Approvals are encoded in the given order. Only the shape is checked, so this can build
3258 /// signatures that the node rejects, such as unsorted or excess approvals.
3259 #[cheatcode(group = Crypto)]
3260 function encodeConfigurableAccountSignature(address account, ConfigurableAccountConfig calldata config, bytes[] calldata ownerSignatures) external pure returns (bytes memory signature);
3261
3262 /// Signs `digest` as the configurable account `account` with its current configuration `config`,
3263 /// using secp256k1 owner keys.
3264 ///
3265 /// Signs with the fewest keys that form a quorum the node accepts: at most 8 approvals, sorted
3266 /// by owner address, the last of which reaches the threshold. Reverts if `config` is invalid,
3267 /// has version 0 but does not derive `account`, a key is not an owner, or no such quorum exists
3268 /// among the keys. Returns the `0x05` signature accepted by
3269 /// `SignatureVerifier.verifyConfigurableAccount`.
3270 #[cheatcode(group = Crypto)]
3271 function signConfigurableAccount(uint256[] calldata privateKeys, address account, ConfigurableAccountConfig calldata config, bytes32 digest) external pure returns (bytes memory signature);
3272
3273 /// Signs `digest` as the configurable account `account` with its current configuration `config`,
3274 /// using secp256k1, P-256 or WebAuthn owner keys.
3275 ///
3276 /// Signs with the fewest keys that form a quorum the node accepts: at most 8 approvals, sorted
3277 /// by owner address, the last of which reaches the threshold. Reverts if `config` is invalid,
3278 /// has version 0 but does not derive `account`, a key is not an owner, or no such quorum exists
3279 /// among the keys. Returns the `0x05` signature accepted by
3280 /// `SignatureVerifier.verifyConfigurableAccount`.
3281 #[cheatcode(group = Crypto)]
3282 function signConfigurableAccount(OwnerKey[] calldata ownerKeys, address account, ConfigurableAccountConfig calldata config, bytes32 digest) external pure returns (bytes memory signature);
3283
3284 /// Signs `digest` as a Tempo V2 keychain signature for `account` whose access key is the
3285 /// configurable account `configurableAccount` with its current configuration `config` (TIP-1111).
3286 ///
3287 /// The owners approve the keychain V2 hash `keccak256(0x04 || digest || account)`, with
3288 /// approvals chosen as in `signConfigurableAccount`. Returns the signature accepted by
3289 /// `SignatureVerifier.verifyKeychain`.
3290 #[cheatcode(group = Crypto)]
3291 function signKeychainConfigurableAccount(OwnerKey[] calldata ownerKeys, address configurableAccount, ConfigurableAccountConfig calldata config, address account, bytes32 digest) external pure returns (bytes memory signature);
3292
3293 /// Signs `digest` with `privateKey` using the secp256k1 curve.
3294 ///
3295 /// Returns a compact signature (`r`, `vs`) as per EIP-2098, where `vs` encodes both the
3296 /// signature's `s` value, and the recovery id `v` in a single bytes32.
3297 /// This format reduces the signature size from 65 to 64 bytes.
3298 #[cheatcode(group = Crypto)]
3299 function signCompact(uint256 privateKey, bytes32 digest) external pure returns (bytes32 r, bytes32 vs);
3300
3301 /// Signs `digest` with signer provided to script using the secp256k1 curve.
3302 ///
3303 /// If `--sender` is provided, the signer with provided address is used, otherwise,
3304 /// if exactly one signer is provided to the script, that signer is used.
3305 ///
3306 /// Raises error if signer passed through `--sender` does not match any unlocked signers or
3307 /// if `--sender` is not provided and not exactly one signer is passed to the script.
3308 #[cheatcode(group = Crypto)]
3309 function sign(bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s);
3310
3311 /// Signs `digest` with signer provided to script using the secp256k1 curve.
3312 ///
3313 /// Returns a compact signature (`r`, `vs`) as per EIP-2098, where `vs` encodes both the
3314 /// signature's `s` value, and the recovery id `v` in a single bytes32.
3315 /// This format reduces the signature size from 65 to 64 bytes.
3316 ///
3317 /// If `--sender` is provided, the signer with provided address is used, otherwise,
3318 /// if exactly one signer is provided to the script, that signer is used.
3319 ///
3320 /// Raises error if signer passed through `--sender` does not match any unlocked signers or
3321 /// if `--sender` is not provided and not exactly one signer is passed to the script.
3322 #[cheatcode(group = Crypto)]
3323 function signCompact(bytes32 digest) external pure returns (bytes32 r, bytes32 vs);
3324
3325 /// Signs `digest` with signer provided to script using the secp256k1 curve.
3326 ///
3327 /// Raises error if none of the signers passed into the script have provided address.
3328 #[cheatcode(group = Crypto)]
3329 function sign(address signer, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s);
3330
3331 /// Signs `digest` with signer provided to script using the secp256k1 curve.
3332 ///
3333 /// Returns a compact signature (`r`, `vs`) as per EIP-2098, where `vs` encodes both the
3334 /// signature's `s` value, and the recovery id `v` in a single bytes32.
3335 /// This format reduces the signature size from 65 to 64 bytes.
3336 ///
3337 /// Raises error if none of the signers passed into the script have provided address.
3338 #[cheatcode(group = Crypto)]
3339 function signCompact(address signer, bytes32 digest) external pure returns (bytes32 r, bytes32 vs);
3340
3341 /// Signs `digest` with `privateKey` using the secp256r1 curve.
3342 #[cheatcode(group = Crypto)]
3343 function signP256(uint256 privateKey, bytes32 digest) external pure returns (bytes32 r, bytes32 s);
3344
3345 /// Derives secp256r1 public key from the provided `privateKey`.
3346 #[cheatcode(group = Crypto)]
3347 function publicKeyP256(uint256 privateKey) external pure returns (uint256 publicKeyX, uint256 publicKeyY);
3348
3349 /// Converts the secp256k1 affine point `(pointX, pointY)` to projective coordinates.
3350 /// The point at infinity is converted from `(0, 0)` to `(0, 1, 0)`.
3351 #[cheatcode(group = Crypto)]
3352 function ecAffineToProjective(uint256 pointX, uint256 pointY)
3353 external
3354 pure
3355 returns (uint256 resultX, uint256 resultY, uint256 resultZ);
3356
3357 /// Converts the secp256k1 projective point `(pointX, pointY, pointZ)` to affine coordinates.
3358 /// The point at infinity is converted from `(0, y, 0)` for any non-zero `y` to `(0, 0)`.
3359 #[cheatcode(group = Crypto)]
3360 function ecProjectiveToAffine(uint256 pointX, uint256 pointY, uint256 pointZ)
3361 external
3362 pure
3363 returns (uint256 resultX, uint256 resultY);
3364
3365 /// Adds the secp256k1 affine points `point1 = (pointX1, pointY1)` and
3366 /// `point2 = (pointX2, pointY2)`.
3367 /// The point at infinity is represented as `(0, 0)`.
3368 #[cheatcode(group = Crypto)]
3369 function ecAddAffine(uint256 pointX1, uint256 pointY1, uint256 pointX2, uint256 pointY2)
3370 external
3371 pure
3372 returns (uint256 resultX, uint256 resultY);
3373
3374 /// Adds the secp256k1 projective points `point1 = (pointX1, pointY1, pointZ1)` and
3375 /// `point2 = (pointX2, pointY2, pointZ2)`.
3376 /// The point at infinity is accepted as `(0, y, 0)` for any non-zero `y` and returned as
3377 /// `(0, 1, 0)`. Any other result is normalized to `(x, y, 1)`.
3378 #[cheatcode(group = Crypto)]
3379 function ecAddProjective(
3380 uint256 pointX1,
3381 uint256 pointY1,
3382 uint256 pointZ1,
3383 uint256 pointX2,
3384 uint256 pointY2,
3385 uint256 pointZ2
3386 )
3387 external
3388 pure
3389 returns (uint256 resultX, uint256 resultY, uint256 resultZ);
3390
3391 /// Multiplies the secp256k1 affine point `(pointX, pointY)` by `scalar`.
3392 /// The scalar is reduced modulo the secp256k1 group order.
3393 /// The point at infinity is represented as `(0, 0)`.
3394 #[cheatcode(group = Crypto)]
3395 function ecMulAffine(uint256 pointX, uint256 pointY, uint256 scalar)
3396 external
3397 pure
3398 returns (uint256 resultX, uint256 resultY);
3399
3400 /// Multiplies the secp256k1 projective point `(pointX, pointY, pointZ)` by `scalar`.
3401 /// The scalar is reduced modulo the secp256k1 group order.
3402 /// The point at infinity is accepted as `(0, y, 0)` for any non-zero `y` and returned as
3403 /// `(0, 1, 0)`. Any other result is normalized to `(x, y, 1)`.
3404 #[cheatcode(group = Crypto)]
3405 function ecMulProjective(uint256 pointX, uint256 pointY, uint256 pointZ, uint256 scalar)
3406 external
3407 pure
3408 returns (uint256 resultX, uint256 resultY, uint256 resultZ);
3409
3410 /// Generates an Ed25519 key pair from a deterministic salt.
3411 /// Returns (publicKey, privateKey) as 32-byte values.
3412 #[cheatcode(group = Crypto, safety = Safe)]
3413 function createEd25519Key(bytes32 salt) external pure returns (bytes32 publicKey, bytes32 privateKey);
3414
3415 /// Derives the Ed25519 public key from a private key.
3416 #[cheatcode(group = Crypto, safety = Safe)]
3417 function publicKeyEd25519(bytes32 privateKey) external pure returns (bytes32 publicKey);
3418
3419 /// Signs a message with namespace using Ed25519.
3420 /// The signature covers namespace || message for domain separation.
3421 /// Returns a 64-byte Ed25519 signature.
3422 #[cheatcode(group = Crypto, safety = Safe)]
3423 function signEd25519(bytes calldata namespace, bytes calldata message, bytes32 privateKey)
3424 external
3425 pure
3426 returns (bytes memory signature);
3427
3428 /// Verifies an Ed25519 signature over namespace || message.
3429 /// Returns true if signature is valid, false otherwise.
3430 #[cheatcode(group = Crypto, safety = Safe)]
3431 function verifyEd25519(
3432 bytes calldata signature,
3433 bytes calldata namespace,
3434 bytes calldata message,
3435 bytes32 publicKey
3436 ) external pure returns (bool valid);
3437
3438 /// Derive a private key from a provided mnemonic string (or mnemonic file path)
3439 /// at the derivation path `m/44'/60'/0'/0/{index}`.
3440 #[cheatcode(group = Crypto)]
3441 function deriveKey(string calldata mnemonic, uint32 index) external pure returns (uint256 privateKey);
3442 /// Derive a private key from a provided mnemonic string (or mnemonic file path)
3443 /// at `{derivationPath}{index}`.
3444 #[cheatcode(group = Crypto)]
3445 function deriveKey(string calldata mnemonic, string calldata derivationPath, uint32 index)
3446 external
3447 pure
3448 returns (uint256 privateKey);
3449 /// Derive a private key from a provided mnemonic string (or mnemonic file path) in the specified language
3450 /// at the derivation path `m/44'/60'/0'/0/{index}`.
3451 #[cheatcode(group = Crypto)]
3452 function deriveKey(string calldata mnemonic, uint32 index, string calldata language)
3453 external
3454 pure
3455 returns (uint256 privateKey);
3456 /// Derive a private key from a provided mnemonic string (or mnemonic file path) in the specified language
3457 /// at `{derivationPath}{index}`.
3458 #[cheatcode(group = Crypto)]
3459 function deriveKey(string calldata mnemonic, string calldata derivationPath, uint32 index, string calldata language)
3460 external
3461 pure
3462 returns (uint256 privateKey);
3463
3464 /// Adds a private key to the local forge wallet and returns the address.
3465 #[cheatcode(group = Crypto)]
3466 function rememberKey(uint256 privateKey) external returns (address keyAddr);
3467
3468 /// Derive a set number of wallets from a mnemonic at the derivation path `m/44'/60'/0'/0/{0..count}`.
3469 ///
3470 /// The respective private keys are saved to the local forge wallet for later use and their addresses are returned.
3471 #[cheatcode(group = Crypto)]
3472 function rememberKeys(string calldata mnemonic, string calldata derivationPath, uint32 count) external returns (address[] memory keyAddrs);
3473
3474 /// Derive a set number of wallets from a mnemonic in the specified language at the derivation path `m/44'/60'/0'/0/{0..count}`.
3475 ///
3476 /// The respective private keys are saved to the local forge wallet for later use and their addresses are returned.
3477 #[cheatcode(group = Crypto)]
3478 function rememberKeys(string calldata mnemonic, string calldata derivationPath, string calldata language, uint32 count)
3479 external
3480 returns (address[] memory keyAddrs);
3481
3482 // -------- Uncategorized Utilities --------
3483
3484 /// Labels an address in call traces.
3485 #[cheatcode(group = Utilities)]
3486 function label(address account, string calldata newLabel) external;
3487
3488 /// Gets the label for the specified address.
3489 #[cheatcode(group = Utilities)]
3490 function getLabel(address account) external view returns (string memory currentLabel);
3491
3492 /// Compute the address a contract will be deployed at for a given deployer address and nonce.
3493 #[cheatcode(group = Utilities)]
3494 function computeCreateAddress(address deployer, uint256 nonce) external pure returns (address);
3495
3496 /// Compute the address of a contract created with CREATE2 using the given CREATE2 deployer.
3497 #[cheatcode(group = Utilities)]
3498 function computeCreate2Address(bytes32 salt, bytes32 initCodeHash, address deployer) external pure returns (address);
3499
3500 /// Compute the address of a contract created with CREATE2 using the default CREATE2 deployer.
3501 #[cheatcode(group = Utilities)]
3502 function computeCreate2Address(bytes32 salt, bytes32 initCodeHash) external pure returns (address);
3503
3504 /// Encodes a `bytes` value to a base64 string.
3505 #[cheatcode(group = Utilities)]
3506 function toBase64(bytes calldata data) external pure returns (string memory);
3507
3508 /// Encodes a `string` value to a base64 string.
3509 #[cheatcode(group = Utilities)]
3510 function toBase64(string calldata data) external pure returns (string memory);
3511
3512 /// Encodes a `bytes` value to a base64url string.
3513 #[cheatcode(group = Utilities)]
3514 function toBase64URL(bytes calldata data) external pure returns (string memory);
3515
3516 /// Encodes a `string` value to a base64url string.
3517 #[cheatcode(group = Utilities)]
3518 function toBase64URL(string calldata data) external pure returns (string memory);
3519
3520 /// Returns ENS namehash for provided string.
3521 #[cheatcode(group = Utilities)]
3522 function ensNamehash(string calldata name) external pure returns (bytes32);
3523
3524 /// Returns an uint256 value bounded in given range and different from the current one.
3525 #[cheatcode(group = Utilities)]
3526 function bound(uint256 current, uint256 min, uint256 max) external view returns (uint256);
3527
3528 /// Returns a random uint256 value.
3529 #[cheatcode(group = Utilities)]
3530 function randomUint() external view returns (uint256);
3531
3532 /// Returns random uint256 value between the provided range (=min..=max).
3533 #[cheatcode(group = Utilities)]
3534 function randomUint(uint256 min, uint256 max) external view returns (uint256);
3535
3536 /// Returns a random `uint256` value of given bits.
3537 #[cheatcode(group = Utilities)]
3538 function randomUint(uint256 bits) external view returns (uint256);
3539
3540 /// Returns a random `address`.
3541 #[cheatcode(group = Utilities)]
3542 function randomAddress() external view returns (address);
3543
3544 /// Returns an int256 value bounded in given range and different from the current one.
3545 #[cheatcode(group = Utilities)]
3546 function bound(int256 current, int256 min, int256 max) external view returns (int256);
3547
3548 /// Returns a random `int256` value.
3549 #[cheatcode(group = Utilities)]
3550 function randomInt() external view returns (int256);
3551
3552 /// Returns a random `int256` value of given bits.
3553 #[cheatcode(group = Utilities)]
3554 function randomInt(uint256 bits) external view returns (int256);
3555
3556 /// Returns a random `bool`.
3557 #[cheatcode(group = Utilities)]
3558 function randomBool() external view returns (bool);
3559
3560 /// Returns a random byte array value of the given length.
3561 #[cheatcode(group = Utilities)]
3562 function randomBytes(uint256 len) external view returns (bytes memory);
3563
3564 /// Returns a random fixed-size byte array of length 4.
3565 #[cheatcode(group = Utilities)]
3566 function randomBytes4() external view returns (bytes4);
3567
3568 /// Returns a random fixed-size byte array of length 8.
3569 #[cheatcode(group = Utilities)]
3570 function randomBytes8() external view returns (bytes8);
3571
3572 /// Pauses collection of call traces. Useful in cases when you want to skip tracing of
3573 /// complex calls which are not useful for debugging.
3574 #[cheatcode(group = Utilities)]
3575 function pauseTracing() external view;
3576
3577 /// Unpauses collection of call traces.
3578 #[cheatcode(group = Utilities)]
3579 function resumeTracing() external view;
3580
3581 /// Utility cheatcode to copy storage of `from` contract to another `to` contract.
3582 #[cheatcode(group = Utilities, safety = Unsafe)]
3583 function copyStorage(address from, address to) external;
3584
3585 /// Utility cheatcode to set arbitrary storage for given target address.
3586 #[cheatcode(group = Utilities, safety = Unsafe)]
3587 function setArbitraryStorage(address target) external;
3588
3589 /// Utility cheatcode to set arbitrary storage for given target address and overwrite
3590 /// any storage slots that have been previously set.
3591 #[cheatcode(group = Utilities, safety = Unsafe)]
3592 function setArbitraryStorage(address target, bool overwrite) external;
3593
3594 /// Sorts an array in ascending order.
3595 #[cheatcode(group = Utilities)]
3596 function sort(uint256[] calldata array) external returns (uint256[] memory);
3597
3598 /// Randomly shuffles an array.
3599 #[cheatcode(group = Utilities)]
3600 function shuffle(uint256[] calldata array) external returns (uint256[] memory);
3601
3602 /// Set RNG seed.
3603 #[cheatcode(group = Utilities)]
3604 function setSeed(uint256 seed) external;
3605
3606 /// Causes the next contract creation (via new) to fail and return its initcode in the returndata buffer.
3607 /// This allows type-safe access to the initcode payload that would be used for contract creation.
3608 /// Example usage:
3609 /// vm.interceptInitcode();
3610 /// bytes memory initcode;
3611 /// try new MyContract(param1, param2) { assert(false); }
3612 /// catch (bytes memory interceptedInitcode) { initcode = interceptedInitcode; }
3613 #[cheatcode(group = Utilities, safety = Unsafe)]
3614 function interceptInitcode() external;
3615
3616 /// Generates the hash of the canonical EIP-712 type representation.
3617 ///
3618 /// Supports 2 different inputs:
3619 /// 1. Name of the type (i.e. "Transaction"):
3620 /// * requires previous binding generation with `forge bind-json`.
3621 /// * bindings will be retrieved from the path configured in `foundry.toml`.
3622 ///
3623 /// 2. String representation of the type (i.e. "Foo(Bar bar) Bar(uint256 baz)").
3624 /// * Note: the cheatcode will output the canonical type even if the input is malformed
3625 /// with the wrong order of elements or with extra whitespaces.
3626 #[cheatcode(group = Utilities)]
3627 function eip712HashType(string calldata typeNameOrDefinition) external pure returns (bytes32 typeHash);
3628
3629 /// Generates the hash of the canonical EIP-712 type representation.
3630 /// Requires previous binding generation with `forge bind-json`.
3631 ///
3632 /// Params:
3633 /// * `bindingsPath`: path where the output of `forge bind-json` is stored.
3634 /// * `typeName`: Name of the type (i.e. "Transaction").
3635 #[cheatcode(group = Utilities)]
3636 function eip712HashType(string calldata bindingsPath, string calldata typeName) external pure returns (bytes32 typeHash);
3637
3638 /// Generates the struct hash of the canonical EIP-712 type representation and its abi-encoded data.
3639 ///
3640 /// Supports 2 different inputs:
3641 /// 1. Name of the type (i.e. "PermitSingle"):
3642 /// * requires previous binding generation with `forge bind-json`.
3643 /// * bindings will be retrieved from the path configured in `foundry.toml`.
3644 ///
3645 /// 2. String representation of the type (i.e. "Foo(Bar bar) Bar(uint256 baz)").
3646 /// * Note: the cheatcode will use the canonical type even if the input is malformed
3647 /// with the wrong order of elements or with extra whitespaces.
3648 #[cheatcode(group = Utilities)]
3649 function eip712HashStruct(string calldata typeNameOrDefinition, bytes calldata abiEncodedData) external pure returns (bytes32 typeHash);
3650
3651 /// Generates the struct hash of the canonical EIP-712 type representation and its abi-encoded data.
3652 /// Requires previous binding generation with `forge bind-json`.
3653 ///
3654 /// Params:
3655 /// * `bindingsPath`: path where the output of `forge bind-json` is stored.
3656 /// * `typeName`: Name of the type (i.e. "PermitSingle").
3657 /// * `abiEncodedData`: ABI-encoded data for the struct that is being hashed.
3658 #[cheatcode(group = Utilities)]
3659 function eip712HashStruct(string calldata bindingsPath, string calldata typeName, bytes calldata abiEncodedData) external pure returns (bytes32 typeHash);
3660
3661 /// Generates a ready-to-sign digest of human-readable typed data following the EIP-712 standard.
3662 #[cheatcode(group = Utilities)]
3663 function eip712HashTypedData(string calldata jsonData) external pure returns (bytes32 digest);
3664
3665 /// RLP encodes a list of bytes into an RLP payload.
3666 #[cheatcode(group = Utilities)]
3667 function toRlp(bytes[] calldata data) external pure returns (bytes memory);
3668 /// RLP decodes an RLP payload into a list of bytes.
3669 #[cheatcode(group = Utilities)]
3670 function fromRlp(bytes calldata rlp) external pure returns (bytes[] memory data);
3671}
3672}
3673
3674impl PartialEq for ForgeContext {
3675 // Handles test group case (any of test, coverage or snapshot)
3676 // and script group case (any of dry run, broadcast or resume).
3677 fn eq(&self, other: &Self) -> bool {
3678 match (self, other) {
3679 (_, Self::TestGroup) => {
3680 matches!(self, Self::Test | Self::Snapshot | Self::Coverage)
3681 }
3682 (_, Self::ScriptGroup) => {
3683 matches!(self, Self::ScriptDryRun | Self::ScriptBroadcast | Self::ScriptResume)
3684 }
3685 (Self::Test, Self::Test)
3686 | (Self::Snapshot, Self::Snapshot)
3687 | (Self::Coverage, Self::Coverage)
3688 | (Self::ScriptDryRun, Self::ScriptDryRun)
3689 | (Self::ScriptBroadcast, Self::ScriptBroadcast)
3690 | (Self::ScriptResume, Self::ScriptResume)
3691 | (Self::Unknown, Self::Unknown) => true,
3692 _ => false,
3693 }
3694 }
3695}
3696
3697impl fmt::Display for Vm::CheatcodeError {
3698 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3699 self.message.fmt(f)
3700 }
3701}
3702
3703impl fmt::Display for Vm::VmErrors {
3704 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3705 match self {
3706 Self::CheatcodeError(err) => err.fmt(f),
3707 }
3708 }
3709}
3710
3711#[track_caller]
3712const fn panic_unknown_safety() -> ! {
3713 panic!("cannot determine safety from the group, add a `#[cheatcode(safety = ...)]` attribute")
3714}