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.
20#[sol(abi)]
21interface Vm {
22 // ======== Types ========
23
24 /// Error thrown by cheatcodes.
25 error CheatcodeError(string message);
26
27 /// A modification applied to either `msg.sender` or `tx.origin`. Returned by `readCallers`.
28 enum CallerMode {
29 /// No caller modification is currently active.
30 None,
31 /// A one time broadcast triggered by a `vm.broadcast()` call is currently active.
32 Broadcast,
33 /// A recurrent broadcast triggered by a `vm.startBroadcast()` call is currently active.
34 RecurrentBroadcast,
35 /// A one time prank triggered by a `vm.prank()` call is currently active.
36 Prank,
37 /// A recurrent prank triggered by a `vm.startPrank()` call is currently active.
38 RecurrentPrank,
39 }
40
41 /// The kind of account access that occurred.
42 enum AccountAccessKind {
43 /// The account was called.
44 Call,
45 /// The account was called via delegatecall.
46 DelegateCall,
47 /// The account was called via callcode.
48 CallCode,
49 /// The account was called via staticcall.
50 StaticCall,
51 /// The account was created.
52 Create,
53 /// The account was selfdestructed.
54 SelfDestruct,
55 /// Synthetic access indicating the current context has resumed after a previous sub-context (AccountAccess).
56 Resume,
57 /// The account's balance was read.
58 Balance,
59 /// The account's codesize was read.
60 Extcodesize,
61 /// The account's codehash was read.
62 Extcodehash,
63 /// The account's code was copied.
64 Extcodecopy,
65 }
66
67 /// Forge execution contexts.
68 enum ForgeContext {
69 /// Test group execution context (test, coverage or snapshot).
70 TestGroup,
71 /// `forge test` execution context.
72 Test,
73 /// `forge coverage` execution context.
74 Coverage,
75 /// `forge snapshot` execution context.
76 Snapshot,
77 /// Script group execution context (dry run, broadcast or resume).
78 ScriptGroup,
79 /// `forge script` execution context.
80 ScriptDryRun,
81 /// `forge script --broadcast` execution context.
82 ScriptBroadcast,
83 /// `forge script --resume` execution context.
84 ScriptResume,
85 /// Unknown `forge` execution context.
86 Unknown,
87 }
88
89 /// An Ethereum log. Returned by `getRecordedLogs`.
90 struct Log {
91 /// The topics of the log, including the signature, if any.
92 bytes32[] topics;
93 /// The raw data of the log.
94 bytes data;
95 /// The address of the log's emitter.
96 address emitter;
97 }
98
99 /// Gas used. Returned by `lastCallGas`.
100 struct Gas {
101 /// The gas limit of the call.
102 uint64 gasLimit;
103 /// The total gas used.
104 uint64 gasTotalUsed;
105 /// DEPRECATED: The amount of gas used for memory expansion. Ref: <https://github.com/foundry-rs/foundry/pull/7934#pullrequestreview-2069236939>
106 uint64 gasMemoryUsed;
107 /// The amount of gas refunded.
108 int64 gasRefunded;
109 /// The amount of gas remaining.
110 uint64 gasRemaining;
111 }
112
113 /// An RPC URL and its alias. Returned by `rpcUrlStructs`.
114 struct Rpc {
115 /// The alias of the RPC URL.
116 string key;
117 /// The RPC URL.
118 string url;
119 }
120
121 /// An RPC log object. Returned by `eth_getLogs`.
122 struct EthGetLogs {
123 /// The address of the log's emitter.
124 address emitter;
125 /// The topics of the log, including the signature, if any.
126 bytes32[] topics;
127 /// The raw data of the log.
128 bytes data;
129 /// The block hash.
130 bytes32 blockHash;
131 /// The block number.
132 uint64 blockNumber;
133 /// The transaction hash.
134 bytes32 transactionHash;
135 /// The transaction index in the block.
136 uint64 transactionIndex;
137 /// The log index.
138 uint256 logIndex;
139 /// Whether the log was removed.
140 bool removed;
141 }
142
143 /// A single entry in a directory listing. Returned by `readDir`.
144 struct DirEntry {
145 /// The error message, if any.
146 string errorMessage;
147 /// The path of the entry.
148 string path;
149 /// The depth of the entry.
150 uint64 depth;
151 /// Whether the entry is a directory.
152 bool isDir;
153 /// Whether the entry is a symlink.
154 bool isSymlink;
155 }
156
157 /// Metadata information about a file.
158 ///
159 /// This structure is returned from the `fsMetadata` function and represents known
160 /// metadata about a file such as its permissions, size, modification
161 /// times, etc.
162 struct FsMetadata {
163 /// True if this metadata is for a directory.
164 bool isDir;
165 /// True if this metadata is for a symlink.
166 bool isSymlink;
167 /// The size of the file, in bytes, this metadata is for.
168 uint256 length;
169 /// True if this metadata is for a readonly (unwritable) file.
170 bool readOnly;
171 /// The last modification time listed in this metadata.
172 uint256 modified;
173 /// The last access time of this metadata.
174 uint256 accessed;
175 /// The creation time listed in this metadata.
176 uint256 created;
177 }
178
179 /// A wallet with a public and private key.
180 struct Wallet {
181 /// The wallet's address.
182 address addr;
183 /// The wallet's public key `X`.
184 uint256 publicKeyX;
185 /// The wallet's public key `Y`.
186 uint256 publicKeyY;
187 /// The wallet's private key.
188 uint256 privateKey;
189 }
190
191 /// The result of a `tryFfi` call.
192 struct FfiResult {
193 /// The exit code of the call.
194 int32 exitCode;
195 /// The optionally hex-decoded `stdout` data.
196 bytes stdout;
197 /// The `stderr` data.
198 bytes stderr;
199 }
200
201 /// Information on the chain and fork.
202 struct ChainInfo {
203 /// The fork identifier. Set to zero if no fork is active.
204 uint256 forkId;
205 /// The chain ID of the current fork.
206 uint256 chainId;
207 }
208
209 /// Information about a blockchain.
210 struct Chain {
211 /// The chain name.
212 string name;
213 /// The chain's Chain ID.
214 uint256 chainId;
215 /// The chain's alias. (i.e. what gets specified in `foundry.toml`).
216 string chainAlias;
217 /// A default RPC endpoint for this chain.
218 string rpcUrl;
219 }
220
221 /// The storage accessed during an `AccountAccess`.
222 struct StorageAccess {
223 /// The account whose storage was accessed.
224 address account;
225 /// The slot that was accessed.
226 bytes32 slot;
227 /// If the access was a write.
228 bool isWrite;
229 /// The previous value of the slot.
230 bytes32 previousValue;
231 /// The new value of the slot.
232 bytes32 newValue;
233 /// If the access was reverted.
234 bool reverted;
235 }
236
237 /// An EIP-2930 access list item.
238 struct AccessListItem {
239 /// The address to be added in access list.
240 address target;
241 /// The storage keys to be added in access list.
242 bytes32[] storageKeys;
243 }
244
245 /// The result of a `stopAndReturnStateDiff` call.
246 struct AccountAccess {
247 /// The chain and fork the access occurred.
248 ChainInfo chainInfo;
249 /// The kind of account access that determines what the account is.
250 /// If kind is Call, DelegateCall, StaticCall or CallCode, then the account is the callee.
251 /// If kind is Create, then the account is the newly created account.
252 /// If kind is SelfDestruct, then the account is the selfdestruct recipient.
253 /// If kind is a Resume, then account represents a account context that has resumed.
254 AccountAccessKind kind;
255 /// The account that was accessed.
256 /// It's either the account created, callee or a selfdestruct recipient for CREATE, CALL or SELFDESTRUCT.
257 address account;
258 /// What accessed the account.
259 address accessor;
260 /// If the account was initialized or empty prior to the access.
261 /// An account is considered initialized if it has code, a
262 /// non-zero nonce, or a non-zero balance.
263 bool initialized;
264 /// The previous balance of the accessed account.
265 uint256 oldBalance;
266 /// The potential new balance of the accessed account.
267 /// That is, all balance changes are recorded here, even if reverts occurred.
268 uint256 newBalance;
269 /// Code of the account deployed by CREATE.
270 bytes deployedCode;
271 /// Value passed along with the account access
272 uint256 value;
273 /// Input data provided to the CREATE or CALL
274 bytes data;
275 /// If this access reverted in either the current or parent context.
276 bool reverted;
277 /// An ordered list of storage accesses made during an account access operation.
278 StorageAccess[] storageAccesses;
279 /// Call depth traversed during the recording of state differences
280 uint64 depth;
281 }
282
283 /// The result of the `stopDebugTraceRecording` call
284 struct DebugStep {
285 /// The stack before executing the step of the run.
286 /// stack\[0\] represents the top of the stack.
287 /// and only stack data relevant to the opcode execution is contained.
288 uint256[] stack;
289 /// The memory input data before executing the step of the run.
290 /// only input data relevant to the opcode execution is contained.
291 ///
292 /// e.g. for MLOAD, it will have memory\[offset:offset+32\] copied here.
293 /// the offset value can be get by the stack data.
294 bytes memoryInput;
295 /// The opcode that was accessed.
296 uint8 opcode;
297 /// The call depth of the step.
298 uint64 depth;
299 /// Whether the call end up with out of gas error.
300 bool isOutOfGas;
301 /// The contract address where the opcode is running
302 address contractAddr;
303 }
304
305 /// The transaction type (`txType`) of the broadcast.
306 enum BroadcastTxType {
307 /// Represents a CALL broadcast tx.
308 Call,
309 /// Represents a CREATE broadcast tx.
310 Create,
311 /// Represents a CREATE2 broadcast tx.
312 Create2
313 }
314
315 /// Represents a transaction's broadcast details.
316 struct BroadcastTxSummary {
317 /// The hash of the transaction that was broadcasted
318 bytes32 txHash;
319 /// Represent the type of transaction among CALL, CREATE, CREATE2
320 BroadcastTxType txType;
321 /// The address of the contract that was called or created.
322 /// This is address of the contract that is created if the txType is CREATE or CREATE2.
323 address contractAddress;
324 /// The block number the transaction landed in.
325 uint64 blockNumber;
326 /// Status of the transaction, retrieved from the transaction receipt.
327 bool success;
328 }
329
330 /// Holds a signed EIP-7702 authorization for an authority account to delegate to an implementation.
331 struct SignedDelegation {
332 /// The y-parity of the recovered secp256k1 signature (0 or 1).
333 uint8 v;
334 /// First 32 bytes of the signature.
335 bytes32 r;
336 /// Second 32 bytes of the signature.
337 bytes32 s;
338 /// The current nonce of the authority account at signing time.
339 /// Used to ensure signature can't be replayed after account nonce changes.
340 uint64 nonce;
341 /// Address of the contract implementation that will be delegated to.
342 /// Gets encoded into delegation code: 0xef0100 || implementation.
343 address implementation;
344 }
345
346 /// Represents a "potential" revert reason from a single subsequent call when using `vm.assumeNoReverts`.
347 /// Reverts that match will result in a FOUNDRY::ASSUME rejection, whereas unmatched reverts will be surfaced
348 /// as normal.
349 struct PotentialRevert {
350 /// The allowed origin of the revert opcode; address(0) allows reverts from any address
351 address reverter;
352 /// When true, only matches on the beginning of the revert data, otherwise, matches on entire revert data
353 bool partialMatch;
354 /// The data to use to match encountered reverts
355 bytes revertData;
356 }
357
358 // ======== EVM ========
359
360 /// Gets the address for a given private key.
361 #[cheatcode(group = Evm, safety = Safe)]
362 function addr(uint256 privateKey) external pure returns (address keyAddr);
363
364 /// Dump a genesis JSON file's `allocs` to disk.
365 #[cheatcode(group = Evm, safety = Unsafe)]
366 function dumpState(string calldata pathToStateJson) external;
367
368 /// Gets the nonce of an account.
369 #[cheatcode(group = Evm, safety = Safe)]
370 function getNonce(address account) external view returns (uint64 nonce);
371
372 /// Get the nonce of a `Wallet`.
373 #[cheatcode(group = Evm, safety = Safe)]
374 function getNonce(Wallet calldata wallet) external returns (uint64 nonce);
375
376 /// Loads a storage slot from an address.
377 #[cheatcode(group = Evm, safety = Safe)]
378 function load(address target, bytes32 slot) external view returns (bytes32 data);
379
380 /// Load a genesis JSON file's `allocs` into the in-memory EVM state.
381 #[cheatcode(group = Evm, safety = Unsafe)]
382 function loadAllocs(string calldata pathToAllocsJson) external;
383
384 // -------- Record Debug Traces --------
385
386 /// Records the debug trace during the run.
387 #[cheatcode(group = Evm, safety = Safe)]
388 function startDebugTraceRecording() external;
389
390 /// Stop debug trace recording and returns the recorded debug trace.
391 #[cheatcode(group = Evm, safety = Safe)]
392 function stopAndReturnDebugTraceRecording() external returns (DebugStep[] memory step);
393
394
395 /// Clones a source account code, state, balance and nonce to a target account and updates in-memory EVM state.
396 #[cheatcode(group = Evm, safety = Unsafe)]
397 function cloneAccount(address source, address target) external;
398
399 // -------- Record Storage --------
400
401 /// Records all storage reads and writes. Use `accesses` to get the recorded data.
402 /// Subsequent calls to `record` will clear the previous data.
403 #[cheatcode(group = Evm, safety = Safe)]
404 function record() external;
405
406 /// Stops recording storage reads and writes.
407 #[cheatcode(group = Evm, safety = Safe)]
408 function stopRecord() external;
409
410 /// Gets all accessed reads and write slot from a `vm.record` session, for a given address.
411 #[cheatcode(group = Evm, safety = Safe)]
412 function accesses(address target) external returns (bytes32[] memory readSlots, bytes32[] memory writeSlots);
413
414 /// Record all account accesses as part of CREATE, CALL or SELFDESTRUCT opcodes in order,
415 /// along with the context of the calls
416 #[cheatcode(group = Evm, safety = Safe)]
417 function startStateDiffRecording() external;
418
419 /// Returns an ordered array of all account accesses from a `vm.startStateDiffRecording` session.
420 #[cheatcode(group = Evm, safety = Safe)]
421 function stopAndReturnStateDiff() external returns (AccountAccess[] memory accountAccesses);
422
423 /// Returns state diffs from current `vm.startStateDiffRecording` session.
424 #[cheatcode(group = Evm, safety = Safe)]
425 function getStateDiff() external view returns (string memory diff);
426
427 /// Returns state diffs from current `vm.startStateDiffRecording` session, in json format.
428 #[cheatcode(group = Evm, safety = Safe)]
429 function getStateDiffJson() external view returns (string memory diff);
430
431 // -------- Recording Map Writes --------
432
433 /// Starts recording all map SSTOREs for later retrieval.
434 #[cheatcode(group = Evm, safety = Safe)]
435 function startMappingRecording() external;
436
437 /// Stops recording all map SSTOREs for later retrieval and clears the recorded data.
438 #[cheatcode(group = Evm, safety = Safe)]
439 function stopMappingRecording() external;
440
441 /// Gets the number of elements in the mapping at the given slot, for a given address.
442 #[cheatcode(group = Evm, safety = Safe)]
443 function getMappingLength(address target, bytes32 mappingSlot) external returns (uint256 length);
444
445 /// Gets the elements at index idx of the mapping at the given slot, for a given address. The
446 /// index must be less than the length of the mapping (i.e. the number of keys in the mapping).
447 #[cheatcode(group = Evm, safety = Safe)]
448 function getMappingSlotAt(address target, bytes32 mappingSlot, uint256 idx) external returns (bytes32 value);
449
450 /// Gets the map key and parent of a mapping at a given slot, for a given address.
451 #[cheatcode(group = Evm, safety = Safe)]
452 function getMappingKeyAndParentOf(address target, bytes32 elementSlot)
453 external
454 returns (bool found, bytes32 key, bytes32 parent);
455
456 // -------- Block and Transaction Properties --------
457
458 /// Sets `block.chainid`.
459 #[cheatcode(group = Evm, safety = Unsafe)]
460 function chainId(uint256 newChainId) external;
461
462 /// Sets `block.coinbase`.
463 #[cheatcode(group = Evm, safety = Unsafe)]
464 function coinbase(address newCoinbase) external;
465
466 /// Sets `block.difficulty`.
467 /// Not available on EVM versions from Paris onwards. Use `prevrandao` instead.
468 /// Reverts if used on unsupported EVM versions.
469 #[cheatcode(group = Evm, safety = Unsafe)]
470 function difficulty(uint256 newDifficulty) external;
471
472 /// Sets `block.basefee`.
473 #[cheatcode(group = Evm, safety = Unsafe)]
474 function fee(uint256 newBasefee) external;
475
476 /// Sets `block.prevrandao`.
477 /// Not available on EVM versions before Paris. Use `difficulty` instead.
478 /// If used on unsupported EVM versions it will revert.
479 #[cheatcode(group = Evm, safety = Unsafe)]
480 function prevrandao(bytes32 newPrevrandao) external;
481 /// Sets `block.prevrandao`.
482 /// Not available on EVM versions before Paris. Use `difficulty` instead.
483 /// If used on unsupported EVM versions it will revert.
484 #[cheatcode(group = Evm, safety = Unsafe)]
485 function prevrandao(uint256 newPrevrandao) external;
486
487 /// Sets the blobhashes in the transaction.
488 /// Not available on EVM versions before Cancun.
489 /// If used on unsupported EVM versions it will revert.
490 #[cheatcode(group = Evm, safety = Unsafe)]
491 function blobhashes(bytes32[] calldata hashes) external;
492
493 /// Gets the blockhashes from the current transaction.
494 /// Not available on EVM versions before Cancun.
495 /// If used on unsupported EVM versions it will revert.
496 #[cheatcode(group = Evm, safety = Unsafe)]
497 function getBlobhashes() external view returns (bytes32[] memory hashes);
498
499 /// Sets `block.height`.
500 #[cheatcode(group = Evm, safety = Unsafe)]
501 function roll(uint256 newHeight) external;
502
503 /// Gets the current `block.number`.
504 /// You should use this instead of `block.number` if you use `vm.roll`, as `block.number` is assumed to be constant across a transaction,
505 /// and as a result will get optimized out by the compiler.
506 /// See https://github.com/foundry-rs/foundry/issues/6180
507 #[cheatcode(group = Evm, safety = Safe)]
508 function getBlockNumber() external view returns (uint256 height);
509
510 /// Sets `tx.gasprice`.
511 #[cheatcode(group = Evm, safety = Unsafe)]
512 function txGasPrice(uint256 newGasPrice) external;
513
514 /// Sets `block.timestamp`.
515 #[cheatcode(group = Evm, safety = Unsafe)]
516 function warp(uint256 newTimestamp) external;
517
518 /// Gets the current `block.timestamp`.
519 /// You should use this instead of `block.timestamp` if you use `vm.warp`, as `block.timestamp` is assumed to be constant across a transaction,
520 /// and as a result will get optimized out by the compiler.
521 /// See https://github.com/foundry-rs/foundry/issues/6180
522 #[cheatcode(group = Evm, safety = Safe)]
523 function getBlockTimestamp() external view returns (uint256 timestamp);
524
525 /// Sets `block.blobbasefee`
526 #[cheatcode(group = Evm, safety = Unsafe)]
527 function blobBaseFee(uint256 newBlobBaseFee) external;
528
529 /// Gets the current `block.blobbasefee`.
530 /// You should use this instead of `block.blobbasefee` if you use `vm.blobBaseFee`, as `block.blobbasefee` is assumed to be constant across a transaction,
531 /// and as a result will get optimized out by the compiler.
532 /// See https://github.com/foundry-rs/foundry/issues/6180
533 #[cheatcode(group = Evm, safety = Safe)]
534 function getBlobBaseFee() external view returns (uint256 blobBaseFee);
535
536 /// Set blockhash for the current block.
537 /// It only sets the blockhash for blocks where `block.number - 256 <= number < block.number`.
538 #[cheatcode(group = Evm, safety = Unsafe)]
539 function setBlockhash(uint256 blockNumber, bytes32 blockHash) external;
540
541 // -------- Account State --------
542
543 /// Sets an address' balance.
544 #[cheatcode(group = Evm, safety = Unsafe)]
545 function deal(address account, uint256 newBalance) external;
546
547 /// Sets an address' code.
548 #[cheatcode(group = Evm, safety = Unsafe)]
549 function etch(address target, bytes calldata newRuntimeBytecode) external;
550
551 /// Resets the nonce of an account to 0 for EOAs and 1 for contract accounts.
552 #[cheatcode(group = Evm, safety = Unsafe)]
553 function resetNonce(address account) external;
554
555 /// Sets the nonce of an account. Must be higher than the current nonce of the account.
556 #[cheatcode(group = Evm, safety = Unsafe)]
557 function setNonce(address account, uint64 newNonce) external;
558
559 /// Sets the nonce of an account to an arbitrary value.
560 #[cheatcode(group = Evm, safety = Unsafe)]
561 function setNonceUnsafe(address account, uint64 newNonce) external;
562
563 /// Stores a value to an address' storage slot.
564 #[cheatcode(group = Evm, safety = Unsafe)]
565 function store(address target, bytes32 slot, bytes32 value) external;
566
567 /// Marks the slots of an account and the account address as cold.
568 #[cheatcode(group = Evm, safety = Unsafe)]
569 function cool(address target) external;
570
571 /// Utility cheatcode to set an EIP-2930 access list for all subsequent transactions.
572 #[cheatcode(group = Evm, safety = Unsafe)]
573 function accessList(AccessListItem[] calldata access) external;
574
575 /// Utility cheatcode to remove any EIP-2930 access list set by `accessList` cheatcode.
576 #[cheatcode(group = Evm, safety = Unsafe)]
577 function noAccessList() external;
578
579 /// Utility cheatcode to mark specific storage slot as warm, simulating a prior read.
580 #[cheatcode(group = Evm, safety = Unsafe)]
581 function warmSlot(address target, bytes32 slot) external;
582
583 /// Utility cheatcode to mark specific storage slot as cold, simulating no prior read.
584 #[cheatcode(group = Evm, safety = Unsafe)]
585 function coolSlot(address target, bytes32 slot) external;
586
587 // -------- Call Manipulation --------
588 // --- Mocks ---
589
590 /// Clears all mocked calls.
591 #[cheatcode(group = Evm, safety = Unsafe)]
592 function clearMockedCalls() external;
593
594 /// Mocks a call to an address, returning specified data.
595 /// Calldata can either be strict or a partial match, e.g. if you only
596 /// pass a Solidity selector to the expected calldata, then the entire Solidity
597 /// function will be mocked.
598 #[cheatcode(group = Evm, safety = Unsafe)]
599 function mockCall(address callee, bytes calldata data, bytes calldata returnData) external;
600
601 /// Mocks a call to an address with a specific `msg.value`, returning specified data.
602 /// Calldata match takes precedence over `msg.value` in case of ambiguity.
603 #[cheatcode(group = Evm, safety = Unsafe)]
604 function mockCall(address callee, uint256 msgValue, bytes calldata data, bytes calldata returnData) external;
605
606 /// Mocks a call to an address, returning specified data.
607 /// Calldata can either be strict or a partial match, e.g. if you only
608 /// pass a Solidity selector to the expected calldata, then the entire Solidity
609 /// function will be mocked.
610 ///
611 /// Overload to pass the function selector directly `token.approve.selector` instead of `abi.encodeWithSelector(token.approve.selector)`.
612 #[cheatcode(group = Evm, safety = Unsafe)]
613 function mockCall(address callee, bytes4 data, bytes calldata returnData) external;
614
615 /// Mocks a call to an address with a specific `msg.value`, returning specified data.
616 /// Calldata match takes precedence over `msg.value` in case of ambiguity.
617 ///
618 /// Overload to pass the function selector directly `token.approve.selector` instead of `abi.encodeWithSelector(token.approve.selector)`.
619 #[cheatcode(group = Evm, safety = Unsafe)]
620 function mockCall(address callee, uint256 msgValue, bytes4 data, bytes calldata returnData) external;
621
622 /// Mocks multiple calls to an address, returning specified data for each call.
623 #[cheatcode(group = Evm, safety = Unsafe)]
624 function mockCalls(address callee, bytes calldata data, bytes[] calldata returnData) external;
625
626 /// Mocks multiple calls to an address with a specific `msg.value`, returning specified data for each call.
627 #[cheatcode(group = Evm, safety = Unsafe)]
628 function mockCalls(address callee, uint256 msgValue, bytes calldata data, bytes[] calldata returnData) external;
629
630 /// Reverts a call to an address with specified revert data.
631 #[cheatcode(group = Evm, safety = Unsafe)]
632 function mockCallRevert(address callee, bytes calldata data, bytes calldata revertData) external;
633
634 /// Reverts a call to an address with a specific `msg.value`, with specified revert data.
635 #[cheatcode(group = Evm, safety = Unsafe)]
636 function mockCallRevert(address callee, uint256 msgValue, bytes calldata data, bytes calldata revertData)
637 external;
638
639 /// Reverts a call to an address with specified revert data.
640 ///
641 /// Overload to pass the function selector directly `token.approve.selector` instead of `abi.encodeWithSelector(token.approve.selector)`.
642 #[cheatcode(group = Evm, safety = Unsafe)]
643 function mockCallRevert(address callee, bytes4 data, bytes calldata revertData) external;
644
645 /// Reverts a call to an address with a specific `msg.value`, with specified revert data.
646 ///
647 /// Overload to pass the function selector directly `token.approve.selector` instead of `abi.encodeWithSelector(token.approve.selector)`.
648 #[cheatcode(group = Evm, safety = Unsafe)]
649 function mockCallRevert(address callee, uint256 msgValue, bytes4 data, bytes calldata revertData)
650 external;
651
652 /// Whenever a call is made to `callee` with calldata `data`, this cheatcode instead calls
653 /// `target` with the same calldata. This functionality is similar to a delegate call made to
654 /// `target` contract from `callee`.
655 /// Can be used to substitute a call to a function with another implementation that captures
656 /// the primary logic of the original function but is easier to reason about.
657 /// If calldata is not a strict match then partial match by selector is attempted.
658 #[cheatcode(group = Evm, safety = Unsafe)]
659 function mockFunction(address callee, address target, bytes calldata data) external;
660
661 // --- Impersonation (pranks) ---
662
663 /// Sets the *next* call's `msg.sender` to be the input address.
664 #[cheatcode(group = Evm, safety = Unsafe)]
665 function prank(address msgSender) external;
666
667 /// Sets all subsequent calls' `msg.sender` to be the input address until `stopPrank` is called.
668 #[cheatcode(group = Evm, safety = Unsafe)]
669 function startPrank(address msgSender) external;
670
671 /// Sets the *next* call's `msg.sender` to be the input address, and the `tx.origin` to be the second input.
672 #[cheatcode(group = Evm, safety = Unsafe)]
673 function prank(address msgSender, address txOrigin) external;
674
675 /// Sets all subsequent calls' `msg.sender` to be the input address until `stopPrank` is called, and the `tx.origin` to be the second input.
676 #[cheatcode(group = Evm, safety = Unsafe)]
677 function startPrank(address msgSender, address txOrigin) external;
678
679 /// Sets the *next* delegate call's `msg.sender` to be the input address.
680 #[cheatcode(group = Evm, safety = Unsafe)]
681 function prank(address msgSender, bool delegateCall) external;
682
683 /// Sets all subsequent delegate calls' `msg.sender` to be the input address until `stopPrank` is called.
684 #[cheatcode(group = Evm, safety = Unsafe)]
685 function startPrank(address msgSender, bool delegateCall) external;
686
687 /// Sets the *next* delegate call's `msg.sender` to be the input address, and the `tx.origin` to be the second input.
688 #[cheatcode(group = Evm, safety = Unsafe)]
689 function prank(address msgSender, address txOrigin, bool delegateCall) external;
690
691 /// 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.
692 #[cheatcode(group = Evm, safety = Unsafe)]
693 function startPrank(address msgSender, address txOrigin, bool delegateCall) external;
694
695 /// Resets subsequent calls' `msg.sender` to be `address(this)`.
696 #[cheatcode(group = Evm, safety = Unsafe)]
697 function stopPrank() external;
698
699 /// Reads the current `msg.sender` and `tx.origin` from state and reports if there is any active caller modification.
700 #[cheatcode(group = Evm, safety = Unsafe)]
701 function readCallers() external returns (CallerMode callerMode, address msgSender, address txOrigin);
702
703 // ----- Arbitrary Snapshots -----
704
705 /// Snapshot capture an arbitrary numerical value by name.
706 /// The group name is derived from the contract name.
707 #[cheatcode(group = Evm, safety = Unsafe)]
708 function snapshotValue(string calldata name, uint256 value) external;
709
710 /// Snapshot capture an arbitrary numerical value by name in a group.
711 #[cheatcode(group = Evm, safety = Unsafe)]
712 function snapshotValue(string calldata group, string calldata name, uint256 value) external;
713
714 // -------- Gas Snapshots --------
715
716 /// Snapshot capture the gas usage of the last call by name from the callee perspective.
717 #[cheatcode(group = Evm, safety = Unsafe)]
718 function snapshotGasLastCall(string calldata name) external returns (uint256 gasUsed);
719
720 /// Snapshot capture the gas usage of the last call by name in a group from the callee perspective.
721 #[cheatcode(group = Evm, safety = Unsafe)]
722 function snapshotGasLastCall(string calldata group, string calldata name) external returns (uint256 gasUsed);
723
724 /// Start a snapshot capture of the current gas usage by name.
725 /// The group name is derived from the contract name.
726 #[cheatcode(group = Evm, safety = Unsafe)]
727 function startSnapshotGas(string calldata name) external;
728
729 /// Start a snapshot capture of the current gas usage by name in a group.
730 #[cheatcode(group = Evm, safety = Unsafe)]
731 function startSnapshotGas(string calldata group, string calldata name) external;
732
733 /// Stop the snapshot capture of the current gas by latest snapshot name, capturing the gas used since the start.
734 #[cheatcode(group = Evm, safety = Unsafe)]
735 function stopSnapshotGas() external returns (uint256 gasUsed);
736
737 /// Stop the snapshot capture of the current gas usage by name, capturing the gas used since the start.
738 /// The group name is derived from the contract name.
739 #[cheatcode(group = Evm, safety = Unsafe)]
740 function stopSnapshotGas(string calldata name) external returns (uint256 gasUsed);
741
742 /// Stop the snapshot capture of the current gas usage by name in a group, capturing the gas used since the start.
743 #[cheatcode(group = Evm, safety = Unsafe)]
744 function stopSnapshotGas(string calldata group, string calldata name) external returns (uint256 gasUsed);
745
746 // -------- State Snapshots --------
747
748 /// `snapshot` is being deprecated in favor of `snapshotState`. It will be removed in future versions.
749 #[cheatcode(group = Evm, safety = Unsafe, status = Deprecated(Some("replaced by `snapshotState`")))]
750 function snapshot() external returns (uint256 snapshotId);
751
752 /// Snapshot the current state of the evm.
753 /// Returns the ID of the snapshot that was created.
754 /// To revert a snapshot use `revertToState`.
755 #[cheatcode(group = Evm, safety = Unsafe)]
756 function snapshotState() external returns (uint256 snapshotId);
757
758 /// `revertTo` is being deprecated in favor of `revertToState`. It will be removed in future versions.
759 #[cheatcode(group = Evm, safety = Unsafe, status = Deprecated(Some("replaced by `revertToState`")))]
760 function revertTo(uint256 snapshotId) external returns (bool success);
761
762 /// Revert the state of the EVM to a previous snapshot
763 /// Takes the snapshot ID to revert to.
764 ///
765 /// Returns `true` if the snapshot was successfully reverted.
766 /// Returns `false` if the snapshot does not exist.
767 ///
768 /// **Note:** This does not automatically delete the snapshot. To delete the snapshot use `deleteStateSnapshot`.
769 #[cheatcode(group = Evm, safety = Unsafe)]
770 function revertToState(uint256 snapshotId) external returns (bool success);
771
772 /// `revertToAndDelete` is being deprecated in favor of `revertToStateAndDelete`. It will be removed in future versions.
773 #[cheatcode(group = Evm, safety = Unsafe, status = Deprecated(Some("replaced by `revertToStateAndDelete`")))]
774 function revertToAndDelete(uint256 snapshotId) external returns (bool success);
775
776 /// Revert the state of the EVM to a previous snapshot and automatically deletes the snapshots
777 /// Takes the snapshot ID to revert to.
778 ///
779 /// Returns `true` if the snapshot was successfully reverted and deleted.
780 /// Returns `false` if the snapshot does not exist.
781 #[cheatcode(group = Evm, safety = Unsafe)]
782 function revertToStateAndDelete(uint256 snapshotId) external returns (bool success);
783
784 /// `deleteSnapshot` is being deprecated in favor of `deleteStateSnapshot`. It will be removed in future versions.
785 #[cheatcode(group = Evm, safety = Unsafe, status = Deprecated(Some("replaced by `deleteStateSnapshot`")))]
786 function deleteSnapshot(uint256 snapshotId) external returns (bool success);
787
788 /// Removes the snapshot with the given ID created by `snapshot`.
789 /// Takes the snapshot ID to delete.
790 ///
791 /// Returns `true` if the snapshot was successfully deleted.
792 /// Returns `false` if the snapshot does not exist.
793 #[cheatcode(group = Evm, safety = Unsafe)]
794 function deleteStateSnapshot(uint256 snapshotId) external returns (bool success);
795
796 /// `deleteSnapshots` is being deprecated in favor of `deleteStateSnapshots`. It will be removed in future versions.
797 #[cheatcode(group = Evm, safety = Unsafe, status = Deprecated(Some("replaced by `deleteStateSnapshots`")))]
798 function deleteSnapshots() external;
799
800 /// Removes _all_ snapshots previously created by `snapshot`.
801 #[cheatcode(group = Evm, safety = Unsafe)]
802 function deleteStateSnapshots() external;
803
804 // -------- Forking --------
805 // --- Creation and Selection ---
806
807 /// Returns the identifier of the currently active fork. Reverts if no fork is currently active.
808 #[cheatcode(group = Evm, safety = Unsafe)]
809 function activeFork() external view returns (uint256 forkId);
810
811 /// Creates a new fork with the given endpoint and the _latest_ block and returns the identifier of the fork.
812 #[cheatcode(group = Evm, safety = Unsafe)]
813 function createFork(string calldata urlOrAlias) external returns (uint256 forkId);
814 /// Creates a new fork with the given endpoint and block and returns the identifier of the fork.
815 #[cheatcode(group = Evm, safety = Unsafe)]
816 function createFork(string calldata urlOrAlias, uint256 blockNumber) external returns (uint256 forkId);
817 /// Creates a new fork with the given endpoint and at the block the given transaction was mined in,
818 /// replays all transaction mined in the block before the transaction, and returns the identifier of the fork.
819 #[cheatcode(group = Evm, safety = Unsafe)]
820 function createFork(string calldata urlOrAlias, bytes32 txHash) external returns (uint256 forkId);
821
822 /// Creates and also selects a new fork with the given endpoint and the latest block and returns the identifier of the fork.
823 #[cheatcode(group = Evm, safety = Unsafe)]
824 function createSelectFork(string calldata urlOrAlias) external returns (uint256 forkId);
825 /// Creates and also selects a new fork with the given endpoint and block and returns the identifier of the fork.
826 #[cheatcode(group = Evm, safety = Unsafe)]
827 function createSelectFork(string calldata urlOrAlias, uint256 blockNumber) external returns (uint256 forkId);
828 /// Creates and also selects new fork with the given endpoint and at the block the given transaction was mined in,
829 /// replays all transaction mined in the block before the transaction, returns the identifier of the fork.
830 #[cheatcode(group = Evm, safety = Unsafe)]
831 function createSelectFork(string calldata urlOrAlias, bytes32 txHash) external returns (uint256 forkId);
832
833 /// Updates the currently active fork to given block number
834 /// This is similar to `roll` but for the currently active fork.
835 #[cheatcode(group = Evm, safety = Unsafe)]
836 function rollFork(uint256 blockNumber) external;
837 /// Updates the currently active fork to given transaction. This will `rollFork` with the number
838 /// of the block the transaction was mined in and replays all transaction mined before it in the block.
839 #[cheatcode(group = Evm, safety = Unsafe)]
840 function rollFork(bytes32 txHash) external;
841 /// Updates the given fork to given block number.
842 #[cheatcode(group = Evm, safety = Unsafe)]
843 function rollFork(uint256 forkId, uint256 blockNumber) external;
844 /// Updates the given fork to block number of the given transaction and replays all transaction mined before it in the block.
845 #[cheatcode(group = Evm, safety = Unsafe)]
846 function rollFork(uint256 forkId, bytes32 txHash) external;
847
848 /// Takes a fork identifier created by `createFork` and sets the corresponding forked state as active.
849 #[cheatcode(group = Evm, safety = Unsafe)]
850 function selectFork(uint256 forkId) external;
851
852 /// Fetches the given transaction from the active fork and executes it on the current state.
853 #[cheatcode(group = Evm, safety = Unsafe)]
854 function transact(bytes32 txHash) external;
855 /// Fetches the given transaction from the given fork and executes it on the current state.
856 #[cheatcode(group = Evm, safety = Unsafe)]
857 function transact(uint256 forkId, bytes32 txHash) external;
858
859 /// Performs an Ethereum JSON-RPC request to the current fork URL.
860 #[cheatcode(group = Evm, safety = Safe)]
861 function rpc(string calldata method, string calldata params) external returns (bytes memory data);
862
863 /// Performs an Ethereum JSON-RPC request to the given endpoint.
864 #[cheatcode(group = Evm, safety = Safe)]
865 function rpc(string calldata urlOrAlias, string calldata method, string calldata params)
866 external
867 returns (bytes memory data);
868
869 /// Gets all the logs according to specified filter.
870 #[cheatcode(group = Evm, safety = Safe)]
871 function eth_getLogs(uint256 fromBlock, uint256 toBlock, address target, bytes32[] calldata topics)
872 external
873 returns (EthGetLogs[] memory logs);
874
875 // --- Behavior ---
876
877 /// In forking mode, explicitly grant the given address cheatcode access.
878 #[cheatcode(group = Evm, safety = Unsafe)]
879 function allowCheatcodes(address account) external;
880
881 /// Marks that the account(s) should use persistent storage across fork swaps in a multifork setup
882 /// Meaning, changes made to the state of this account will be kept when switching forks.
883 #[cheatcode(group = Evm, safety = Unsafe)]
884 function makePersistent(address account) external;
885 /// See `makePersistent(address)`.
886 #[cheatcode(group = Evm, safety = Unsafe)]
887 function makePersistent(address account0, address account1) external;
888 /// See `makePersistent(address)`.
889 #[cheatcode(group = Evm, safety = Unsafe)]
890 function makePersistent(address account0, address account1, address account2) external;
891 /// See `makePersistent(address)`.
892 #[cheatcode(group = Evm, safety = Unsafe)]
893 function makePersistent(address[] calldata accounts) external;
894
895 /// Revokes persistent status from the address, previously added via `makePersistent`.
896 #[cheatcode(group = Evm, safety = Unsafe)]
897 function revokePersistent(address account) external;
898 /// See `revokePersistent(address)`.
899 #[cheatcode(group = Evm, safety = Unsafe)]
900 function revokePersistent(address[] calldata accounts) external;
901
902 /// Returns true if the account is marked as persistent.
903 #[cheatcode(group = Evm, safety = Unsafe)]
904 function isPersistent(address account) external view returns (bool persistent);
905
906 // -------- Record Logs --------
907
908 /// Record all the transaction logs.
909 #[cheatcode(group = Evm, safety = Safe)]
910 function recordLogs() external;
911
912 /// Gets all the recorded logs.
913 #[cheatcode(group = Evm, safety = Safe)]
914 function getRecordedLogs() external returns (Log[] memory logs);
915
916 // -------- Gas Metering --------
917
918 // It's recommend to use the `noGasMetering` modifier included with forge-std, instead of
919 // using these functions directly.
920
921 /// Pauses gas metering (i.e. gas usage is not counted). Noop if already paused.
922 #[cheatcode(group = Evm, safety = Safe)]
923 function pauseGasMetering() external;
924
925 /// Resumes gas metering (i.e. gas usage is counted again). Noop if already on.
926 #[cheatcode(group = Evm, safety = Safe)]
927 function resumeGasMetering() external;
928
929 /// Reset gas metering (i.e. gas usage is set to gas limit).
930 #[cheatcode(group = Evm, safety = Safe)]
931 function resetGasMetering() external;
932
933 // -------- Gas Measurement --------
934
935 /// Gets the gas used in the last call from the callee perspective.
936 #[cheatcode(group = Evm, safety = Safe)]
937 function lastCallGas() external view returns (Gas memory gas);
938
939 // ======== Test Assertions and Utilities ========
940
941 /// If the condition is false, discard this run's fuzz inputs and generate new ones.
942 #[cheatcode(group = Testing, safety = Safe)]
943 function assume(bool condition) external pure;
944
945 /// Discard this run's fuzz inputs and generate new ones if next call reverted.
946 #[cheatcode(group = Testing, safety = Safe)]
947 function assumeNoRevert() external pure;
948
949 /// Discard this run's fuzz inputs and generate new ones if next call reverts with the potential revert parameters.
950 #[cheatcode(group = Testing, safety = Safe)]
951 function assumeNoRevert(PotentialRevert calldata potentialRevert) external pure;
952
953 /// Discard this run's fuzz inputs and generate new ones if next call reverts with the any of the potential revert parameters.
954 #[cheatcode(group = Testing, safety = Safe)]
955 function assumeNoRevert(PotentialRevert[] calldata potentialReverts) external pure;
956
957 /// Writes a breakpoint to jump to in the debugger.
958 #[cheatcode(group = Testing, safety = Safe)]
959 function breakpoint(string calldata char) external pure;
960
961 /// Writes a conditional breakpoint to jump to in the debugger.
962 #[cheatcode(group = Testing, safety = Safe)]
963 function breakpoint(string calldata char, bool value) external pure;
964
965 /// Returns the Foundry version.
966 /// Format: <cargo_version>-<tag>+<git_sha_short>.<unix_build_timestamp>.<profile>
967 /// Sample output: 0.3.0-nightly+3cb96bde9b.1737036656.debug
968 /// Note: Build timestamps may vary slightly across platforms due to separate CI jobs.
969 /// For reliable version comparisons, use UNIX format (e.g., >= 1700000000)
970 /// to compare timestamps while ignoring minor time differences.
971 #[cheatcode(group = Testing, safety = Safe)]
972 function getFoundryVersion() external view returns (string memory version);
973
974 /// Returns the RPC url for the given alias.
975 #[cheatcode(group = Testing, safety = Safe)]
976 function rpcUrl(string calldata rpcAlias) external view returns (string memory json);
977
978 /// Returns all rpc urls and their aliases `[alias, url][]`.
979 #[cheatcode(group = Testing, safety = Safe)]
980 function rpcUrls() external view returns (string[2][] memory urls);
981
982 /// Returns all rpc urls and their aliases as structs.
983 #[cheatcode(group = Testing, safety = Safe)]
984 function rpcUrlStructs() external view returns (Rpc[] memory urls);
985
986 /// Returns a Chain struct for specific alias
987 #[cheatcode(group = Testing, safety = Safe)]
988 function getChain(string calldata chainAlias) external view returns (Chain memory chain);
989
990 /// Returns a Chain struct for specific chainId
991 #[cheatcode(group = Testing, safety = Safe)]
992 function getChain(uint256 chainId) external view returns (Chain memory chain);
993
994 /// Suspends execution of the main thread for `duration` milliseconds.
995 #[cheatcode(group = Testing, safety = Safe)]
996 function sleep(uint256 duration) external;
997
998 /// Expects a call to an address with the specified calldata.
999 /// Calldata can either be a strict or a partial match.
1000 #[cheatcode(group = Testing, safety = Unsafe)]
1001 function expectCall(address callee, bytes calldata data) external;
1002
1003 /// Expects given number of calls to an address with the specified calldata.
1004 #[cheatcode(group = Testing, safety = Unsafe)]
1005 function expectCall(address callee, bytes calldata data, uint64 count) external;
1006
1007 /// Expects a call to an address with the specified `msg.value` and calldata.
1008 #[cheatcode(group = Testing, safety = Unsafe)]
1009 function expectCall(address callee, uint256 msgValue, bytes calldata data) external;
1010
1011 /// Expects given number of calls to an address with the specified `msg.value` and calldata.
1012 #[cheatcode(group = Testing, safety = Unsafe)]
1013 function expectCall(address callee, uint256 msgValue, bytes calldata data, uint64 count) external;
1014
1015 /// Expect a call to an address with the specified `msg.value`, gas, and calldata.
1016 #[cheatcode(group = Testing, safety = Unsafe)]
1017 function expectCall(address callee, uint256 msgValue, uint64 gas, bytes calldata data) external;
1018
1019 /// Expects given number of calls to an address with the specified `msg.value`, gas, and calldata.
1020 #[cheatcode(group = Testing, safety = Unsafe)]
1021 function expectCall(address callee, uint256 msgValue, uint64 gas, bytes calldata data, uint64 count) external;
1022
1023 /// Expect a call to an address with the specified `msg.value` and calldata, and a *minimum* amount of gas.
1024 #[cheatcode(group = Testing, safety = Unsafe)]
1025 function expectCallMinGas(address callee, uint256 msgValue, uint64 minGas, bytes calldata data) external;
1026
1027 /// Expect given number of calls to an address with the specified `msg.value` and calldata, and a *minimum* amount of gas.
1028 #[cheatcode(group = Testing, safety = Unsafe)]
1029 function expectCallMinGas(address callee, uint256 msgValue, uint64 minGas, bytes calldata data, uint64 count)
1030 external;
1031
1032 /// Prepare an expected log with (bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData.).
1033 /// Call this function, then emit an event, then call a function. Internally after the call, we check if
1034 /// logs were emitted in the expected order with the expected topics and data (as specified by the booleans).
1035 #[cheatcode(group = Testing, safety = Unsafe)]
1036 function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData) external;
1037
1038 /// Same as the previous method, but also checks supplied address against emitting contract.
1039 #[cheatcode(group = Testing, safety = Unsafe)]
1040 function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, address emitter)
1041 external;
1042
1043 /// Prepare an expected log with all topic and data checks enabled.
1044 /// Call this function, then emit an event, then call a function. Internally after the call, we check if
1045 /// logs were emitted in the expected order with the expected topics and data.
1046 #[cheatcode(group = Testing, safety = Unsafe)]
1047 function expectEmit() external;
1048
1049 /// Same as the previous method, but also checks supplied address against emitting contract.
1050 #[cheatcode(group = Testing, safety = Unsafe)]
1051 function expectEmit(address emitter) external;
1052
1053 /// Expect a given number of logs with the provided topics.
1054 #[cheatcode(group = Testing, safety = Unsafe)]
1055 function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, uint64 count) external;
1056
1057 /// Expect a given number of logs from a specific emitter with the provided topics.
1058 #[cheatcode(group = Testing, safety = Unsafe)]
1059 function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, address emitter, uint64 count)
1060 external;
1061
1062 /// Expect a given number of logs with all topic and data checks enabled.
1063 #[cheatcode(group = Testing, safety = Unsafe)]
1064 function expectEmit(uint64 count) external;
1065
1066 /// Expect a given number of logs from a specific emitter with all topic and data checks enabled.
1067 #[cheatcode(group = Testing, safety = Unsafe)]
1068 function expectEmit(address emitter, uint64 count) external;
1069
1070 /// Prepare an expected anonymous log with (bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData.).
1071 /// Call this function, then emit an anonymous event, then call a function. Internally after the call, we check if
1072 /// logs were emitted in the expected order with the expected topics and data (as specified by the booleans).
1073 #[cheatcode(group = Testing, safety = Unsafe)]
1074 function expectEmitAnonymous(bool checkTopic0, bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData) external;
1075
1076 /// Same as the previous method, but also checks supplied address against emitting contract.
1077 #[cheatcode(group = Testing, safety = Unsafe)]
1078 function expectEmitAnonymous(bool checkTopic0, bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, address emitter)
1079 external;
1080
1081 /// Prepare an expected anonymous log with all topic and data checks enabled.
1082 /// Call this function, then emit an anonymous event, then call a function. Internally after the call, we check if
1083 /// logs were emitted in the expected order with the expected topics and data.
1084 #[cheatcode(group = Testing, safety = Unsafe)]
1085 function expectEmitAnonymous() external;
1086
1087 /// Same as the previous method, but also checks supplied address against emitting contract.
1088 #[cheatcode(group = Testing, safety = Unsafe)]
1089 function expectEmitAnonymous(address emitter) external;
1090
1091 /// Expects the deployment of the specified bytecode by the specified address using the CREATE opcode
1092 #[cheatcode(group = Testing, safety = Unsafe)]
1093 function expectCreate(bytes calldata bytecode, address deployer) external;
1094
1095 /// Expects the deployment of the specified bytecode by the specified address using the CREATE2 opcode
1096 #[cheatcode(group = Testing, safety = Unsafe)]
1097 function expectCreate2(bytes calldata bytecode, address deployer) external;
1098
1099 /// Expects an error on next call with any revert data.
1100 #[cheatcode(group = Testing, safety = Unsafe)]
1101 function expectRevert() external;
1102
1103 /// Expects an error on next call that exactly matches the revert data.
1104 #[cheatcode(group = Testing, safety = Unsafe)]
1105 function expectRevert(bytes4 revertData) external;
1106
1107 /// Expects an error on next call that exactly matches the revert data.
1108 #[cheatcode(group = Testing, safety = Unsafe)]
1109 function expectRevert(bytes calldata revertData) external;
1110
1111 /// Expects an error with any revert data on next call to reverter address.
1112 #[cheatcode(group = Testing, safety = Unsafe)]
1113 function expectRevert(address reverter) external;
1114
1115 /// Expects an error from reverter address on next call, with any revert data.
1116 #[cheatcode(group = Testing, safety = Unsafe)]
1117 function expectRevert(bytes4 revertData, address reverter) external;
1118
1119 /// Expects an error from reverter address on next call, that exactly matches the revert data.
1120 #[cheatcode(group = Testing, safety = Unsafe)]
1121 function expectRevert(bytes calldata revertData, address reverter) external;
1122
1123 /// Expects a `count` number of reverts from the upcoming calls with any revert data or reverter.
1124 #[cheatcode(group = Testing, safety = Unsafe)]
1125 function expectRevert(uint64 count) external;
1126
1127 /// Expects a `count` number of reverts from the upcoming calls that match the revert data.
1128 #[cheatcode(group = Testing, safety = Unsafe)]
1129 function expectRevert(bytes4 revertData, uint64 count) external;
1130
1131 /// Expects a `count` number of reverts from the upcoming calls that exactly match the revert data.
1132 #[cheatcode(group = Testing, safety = Unsafe)]
1133 function expectRevert(bytes calldata revertData, uint64 count) external;
1134
1135 /// Expects a `count` number of reverts from the upcoming calls from the reverter address.
1136 #[cheatcode(group = Testing, safety = Unsafe)]
1137 function expectRevert(address reverter, uint64 count) external;
1138
1139 /// Expects a `count` number of reverts from the upcoming calls from the reverter address that match the revert data.
1140 #[cheatcode(group = Testing, safety = Unsafe)]
1141 function expectRevert(bytes4 revertData, address reverter, uint64 count) external;
1142
1143 /// Expects a `count` number of reverts from the upcoming calls from the reverter address that exactly match the revert data.
1144 #[cheatcode(group = Testing, safety = Unsafe)]
1145 function expectRevert(bytes calldata revertData, address reverter, uint64 count) external;
1146
1147 /// Expects an error on next call that starts with the revert data.
1148 #[cheatcode(group = Testing, safety = Unsafe)]
1149 function expectPartialRevert(bytes4 revertData) external;
1150
1151 /// Expects an error on next call to reverter address, that starts with the revert data.
1152 #[cheatcode(group = Testing, safety = Unsafe)]
1153 function expectPartialRevert(bytes4 revertData, address reverter) external;
1154
1155 /// Expects an error on next cheatcode call with any revert data.
1156 #[cheatcode(group = Testing, safety = Unsafe, status = Internal)]
1157 function _expectCheatcodeRevert() external;
1158
1159 /// Expects an error on next cheatcode call that starts with the revert data.
1160 #[cheatcode(group = Testing, safety = Unsafe, status = Internal)]
1161 function _expectCheatcodeRevert(bytes4 revertData) external;
1162
1163 /// Expects an error on next cheatcode call that exactly matches the revert data.
1164 #[cheatcode(group = Testing, safety = Unsafe, status = Internal)]
1165 function _expectCheatcodeRevert(bytes calldata revertData) external;
1166
1167 /// Only allows memory writes to offsets [0x00, 0x60) ∪ [min, max) in the current subcontext. If any other
1168 /// memory is written to, the test will fail. Can be called multiple times to add more ranges to the set.
1169 #[cheatcode(group = Testing, safety = Unsafe)]
1170 function expectSafeMemory(uint64 min, uint64 max) external;
1171
1172 /// Stops all safe memory expectation in the current subcontext.
1173 #[cheatcode(group = Testing, safety = Unsafe)]
1174 function stopExpectSafeMemory() external;
1175
1176 /// Only allows memory writes to offsets [0x00, 0x60) ∪ [min, max) in the next created subcontext.
1177 /// If any other memory is written to, the test will fail. Can be called multiple times to add more ranges
1178 /// to the set.
1179 #[cheatcode(group = Testing, safety = Unsafe)]
1180 function expectSafeMemoryCall(uint64 min, uint64 max) external;
1181
1182 /// Marks a test as skipped. Must be called at the top level of a test.
1183 #[cheatcode(group = Testing, safety = Unsafe)]
1184 function skip(bool skipTest) external;
1185
1186 /// Marks a test as skipped with a reason. Must be called at the top level of a test.
1187 #[cheatcode(group = Testing, safety = Unsafe)]
1188 function skip(bool skipTest, string calldata reason) external;
1189
1190 /// Asserts that the given condition is true.
1191 #[cheatcode(group = Testing, safety = Safe)]
1192 function assertTrue(bool condition) external pure;
1193
1194 /// Asserts that the given condition is true and includes error message into revert string on failure.
1195 #[cheatcode(group = Testing, safety = Safe)]
1196 function assertTrue(bool condition, string calldata error) external pure;
1197
1198 /// Asserts that the given condition is false.
1199 #[cheatcode(group = Testing, safety = Safe)]
1200 function assertFalse(bool condition) external pure;
1201
1202 /// Asserts that the given condition is false and includes error message into revert string on failure.
1203 #[cheatcode(group = Testing, safety = Safe)]
1204 function assertFalse(bool condition, string calldata error) external pure;
1205
1206 /// Asserts that two `bool` values are equal.
1207 #[cheatcode(group = Testing, safety = Safe)]
1208 function assertEq(bool left, bool right) external pure;
1209
1210 /// Asserts that two `bool` values are equal and includes error message into revert string on failure.
1211 #[cheatcode(group = Testing, safety = Safe)]
1212 function assertEq(bool left, bool right, string calldata error) external pure;
1213
1214 /// Asserts that two `uint256` values are equal.
1215 #[cheatcode(group = Testing, safety = Safe)]
1216 function assertEq(uint256 left, uint256 right) external pure;
1217
1218 /// Asserts that two `uint256` values are equal and includes error message into revert string on failure.
1219 #[cheatcode(group = Testing, safety = Safe)]
1220 function assertEq(uint256 left, uint256 right, string calldata error) external pure;
1221
1222 /// Asserts that two `int256` values are equal.
1223 #[cheatcode(group = Testing, safety = Safe)]
1224 function assertEq(int256 left, int256 right) external pure;
1225
1226 /// Asserts that two `int256` values are equal and includes error message into revert string on failure.
1227 #[cheatcode(group = Testing, safety = Safe)]
1228 function assertEq(int256 left, int256 right, string calldata error) external pure;
1229
1230 /// Asserts that two `address` values are equal.
1231 #[cheatcode(group = Testing, safety = Safe)]
1232 function assertEq(address left, address right) external pure;
1233
1234 /// Asserts that two `address` values are equal and includes error message into revert string on failure.
1235 #[cheatcode(group = Testing, safety = Safe)]
1236 function assertEq(address left, address right, string calldata error) external pure;
1237
1238 /// Asserts that two `bytes32` values are equal.
1239 #[cheatcode(group = Testing, safety = Safe)]
1240 function assertEq(bytes32 left, bytes32 right) external pure;
1241
1242 /// Asserts that two `bytes32` values are equal and includes error message into revert string on failure.
1243 #[cheatcode(group = Testing, safety = Safe)]
1244 function assertEq(bytes32 left, bytes32 right, string calldata error) external pure;
1245
1246 /// Asserts that two `string` values are equal.
1247 #[cheatcode(group = Testing, safety = Safe)]
1248 function assertEq(string calldata left, string calldata right) external pure;
1249
1250 /// Asserts that two `string` values are equal and includes error message into revert string on failure.
1251 #[cheatcode(group = Testing, safety = Safe)]
1252 function assertEq(string calldata left, string calldata right, string calldata error) external pure;
1253
1254 /// Asserts that two `bytes` values are equal.
1255 #[cheatcode(group = Testing, safety = Safe)]
1256 function assertEq(bytes calldata left, bytes calldata right) external pure;
1257
1258 /// Asserts that two `bytes` values are equal and includes error message into revert string on failure.
1259 #[cheatcode(group = Testing, safety = Safe)]
1260 function assertEq(bytes calldata left, bytes calldata right, string calldata error) external pure;
1261
1262 /// Asserts that two arrays of `bool` values are equal.
1263 #[cheatcode(group = Testing, safety = Safe)]
1264 function assertEq(bool[] calldata left, bool[] calldata right) external pure;
1265
1266 /// Asserts that two arrays of `bool` values are equal and includes error message into revert string on failure.
1267 #[cheatcode(group = Testing, safety = Safe)]
1268 function assertEq(bool[] calldata left, bool[] calldata right, string calldata error) external pure;
1269
1270 /// Asserts that two arrays of `uint256 values are equal.
1271 #[cheatcode(group = Testing, safety = Safe)]
1272 function assertEq(uint256[] calldata left, uint256[] calldata right) external pure;
1273
1274 /// Asserts that two arrays of `uint256` values are equal and includes error message into revert string on failure.
1275 #[cheatcode(group = Testing, safety = Safe)]
1276 function assertEq(uint256[] calldata left, uint256[] calldata right, string calldata error) external pure;
1277
1278 /// Asserts that two arrays of `int256` values are equal.
1279 #[cheatcode(group = Testing, safety = Safe)]
1280 function assertEq(int256[] calldata left, int256[] calldata right) external pure;
1281
1282 /// Asserts that two arrays of `int256` values are equal and includes error message into revert string on failure.
1283 #[cheatcode(group = Testing, safety = Safe)]
1284 function assertEq(int256[] calldata left, int256[] calldata right, string calldata error) external pure;
1285
1286 /// Asserts that two arrays of `address` values are equal.
1287 #[cheatcode(group = Testing, safety = Safe)]
1288 function assertEq(address[] calldata left, address[] calldata right) external pure;
1289
1290 /// Asserts that two arrays of `address` values are equal and includes error message into revert string on failure.
1291 #[cheatcode(group = Testing, safety = Safe)]
1292 function assertEq(address[] calldata left, address[] calldata right, string calldata error) external pure;
1293
1294 /// Asserts that two arrays of `bytes32` values are equal.
1295 #[cheatcode(group = Testing, safety = Safe)]
1296 function assertEq(bytes32[] calldata left, bytes32[] calldata right) external pure;
1297
1298 /// Asserts that two arrays of `bytes32` values are equal and includes error message into revert string on failure.
1299 #[cheatcode(group = Testing, safety = Safe)]
1300 function assertEq(bytes32[] calldata left, bytes32[] calldata right, string calldata error) external pure;
1301
1302 /// Asserts that two arrays of `string` values are equal.
1303 #[cheatcode(group = Testing, safety = Safe)]
1304 function assertEq(string[] calldata left, string[] calldata right) external pure;
1305
1306 /// Asserts that two arrays of `string` values are equal and includes error message into revert string on failure.
1307 #[cheatcode(group = Testing, safety = Safe)]
1308 function assertEq(string[] calldata left, string[] calldata right, string calldata error) external pure;
1309
1310 /// Asserts that two arrays of `bytes` values are equal.
1311 #[cheatcode(group = Testing, safety = Safe)]
1312 function assertEq(bytes[] calldata left, bytes[] calldata right) external pure;
1313
1314 /// Asserts that two arrays of `bytes` values are equal and includes error message into revert string on failure.
1315 #[cheatcode(group = Testing, safety = Safe)]
1316 function assertEq(bytes[] calldata left, bytes[] calldata right, string calldata error) external pure;
1317
1318 /// Asserts that two `uint256` values are equal, formatting them with decimals in failure message.
1319 #[cheatcode(group = Testing, safety = Safe)]
1320 function assertEqDecimal(uint256 left, uint256 right, uint256 decimals) external pure;
1321
1322 /// Asserts that two `uint256` values are equal, formatting them with decimals in failure message.
1323 /// Includes error message into revert string on failure.
1324 #[cheatcode(group = Testing, safety = Safe)]
1325 function assertEqDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure;
1326
1327 /// Asserts that two `int256` values are equal, formatting them with decimals in failure message.
1328 #[cheatcode(group = Testing, safety = Safe)]
1329 function assertEqDecimal(int256 left, int256 right, uint256 decimals) external pure;
1330
1331 /// Asserts that two `int256` values are equal, formatting them with decimals in failure message.
1332 /// Includes error message into revert string on failure.
1333 #[cheatcode(group = Testing, safety = Safe)]
1334 function assertEqDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure;
1335
1336 /// Asserts that two `bool` values are not equal.
1337 #[cheatcode(group = Testing, safety = Safe)]
1338 function assertNotEq(bool left, bool right) external pure;
1339
1340 /// Asserts that two `bool` values are not equal and includes error message into revert string on failure.
1341 #[cheatcode(group = Testing, safety = Safe)]
1342 function assertNotEq(bool left, bool right, string calldata error) external pure;
1343
1344 /// Asserts that two `uint256` values are not equal.
1345 #[cheatcode(group = Testing, safety = Safe)]
1346 function assertNotEq(uint256 left, uint256 right) external pure;
1347
1348 /// Asserts that two `uint256` values are not equal and includes error message into revert string on failure.
1349 #[cheatcode(group = Testing, safety = Safe)]
1350 function assertNotEq(uint256 left, uint256 right, string calldata error) external pure;
1351
1352 /// Asserts that two `int256` values are not equal.
1353 #[cheatcode(group = Testing, safety = Safe)]
1354 function assertNotEq(int256 left, int256 right) external pure;
1355
1356 /// Asserts that two `int256` values are not equal and includes error message into revert string on failure.
1357 #[cheatcode(group = Testing, safety = Safe)]
1358 function assertNotEq(int256 left, int256 right, string calldata error) external pure;
1359
1360 /// Asserts that two `address` values are not equal.
1361 #[cheatcode(group = Testing, safety = Safe)]
1362 function assertNotEq(address left, address right) external pure;
1363
1364 /// Asserts that two `address` values are not equal and includes error message into revert string on failure.
1365 #[cheatcode(group = Testing, safety = Safe)]
1366 function assertNotEq(address left, address right, string calldata error) external pure;
1367
1368 /// Asserts that two `bytes32` values are not equal.
1369 #[cheatcode(group = Testing, safety = Safe)]
1370 function assertNotEq(bytes32 left, bytes32 right) external pure;
1371
1372 /// Asserts that two `bytes32` values are not equal and includes error message into revert string on failure.
1373 #[cheatcode(group = Testing, safety = Safe)]
1374 function assertNotEq(bytes32 left, bytes32 right, string calldata error) external pure;
1375
1376 /// Asserts that two `string` values are not equal.
1377 #[cheatcode(group = Testing, safety = Safe)]
1378 function assertNotEq(string calldata left, string calldata right) external pure;
1379
1380 /// Asserts that two `string` values are not equal and includes error message into revert string on failure.
1381 #[cheatcode(group = Testing, safety = Safe)]
1382 function assertNotEq(string calldata left, string calldata right, string calldata error) external pure;
1383
1384 /// Asserts that two `bytes` values are not equal.
1385 #[cheatcode(group = Testing, safety = Safe)]
1386 function assertNotEq(bytes calldata left, bytes calldata right) external pure;
1387
1388 /// Asserts that two `bytes` values are not equal and includes error message into revert string on failure.
1389 #[cheatcode(group = Testing, safety = Safe)]
1390 function assertNotEq(bytes calldata left, bytes calldata right, string calldata error) external pure;
1391
1392 /// Asserts that two arrays of `bool` values are not equal.
1393 #[cheatcode(group = Testing, safety = Safe)]
1394 function assertNotEq(bool[] calldata left, bool[] calldata right) external pure;
1395
1396 /// Asserts that two arrays of `bool` values are not equal and includes error message into revert string on failure.
1397 #[cheatcode(group = Testing, safety = Safe)]
1398 function assertNotEq(bool[] calldata left, bool[] calldata right, string calldata error) external pure;
1399
1400 /// Asserts that two arrays of `uint256` values are not equal.
1401 #[cheatcode(group = Testing, safety = Safe)]
1402 function assertNotEq(uint256[] calldata left, uint256[] calldata right) external pure;
1403
1404 /// Asserts that two arrays of `uint256` values are not equal and includes error message into revert string on failure.
1405 #[cheatcode(group = Testing, safety = Safe)]
1406 function assertNotEq(uint256[] calldata left, uint256[] calldata right, string calldata error) external pure;
1407
1408 /// Asserts that two arrays of `int256` values are not equal.
1409 #[cheatcode(group = Testing, safety = Safe)]
1410 function assertNotEq(int256[] calldata left, int256[] calldata right) external pure;
1411
1412 /// Asserts that two arrays of `int256` values are not equal and includes error message into revert string on failure.
1413 #[cheatcode(group = Testing, safety = Safe)]
1414 function assertNotEq(int256[] calldata left, int256[] calldata right, string calldata error) external pure;
1415
1416 /// Asserts that two arrays of `address` values are not equal.
1417 #[cheatcode(group = Testing, safety = Safe)]
1418 function assertNotEq(address[] calldata left, address[] calldata right) external pure;
1419
1420 /// Asserts that two arrays of `address` values are not equal and includes error message into revert string on failure.
1421 #[cheatcode(group = Testing, safety = Safe)]
1422 function assertNotEq(address[] calldata left, address[] calldata right, string calldata error) external pure;
1423
1424 /// Asserts that two arrays of `bytes32` values are not equal.
1425 #[cheatcode(group = Testing, safety = Safe)]
1426 function assertNotEq(bytes32[] calldata left, bytes32[] calldata right) external pure;
1427
1428 /// Asserts that two arrays of `bytes32` values are not equal and includes error message into revert string on failure.
1429 #[cheatcode(group = Testing, safety = Safe)]
1430 function assertNotEq(bytes32[] calldata left, bytes32[] calldata right, string calldata error) external pure;
1431
1432 /// Asserts that two arrays of `string` values are not equal.
1433 #[cheatcode(group = Testing, safety = Safe)]
1434 function assertNotEq(string[] calldata left, string[] calldata right) external pure;
1435
1436 /// Asserts that two arrays of `string` values are not equal and includes error message into revert string on failure.
1437 #[cheatcode(group = Testing, safety = Safe)]
1438 function assertNotEq(string[] calldata left, string[] calldata right, string calldata error) external pure;
1439
1440 /// Asserts that two arrays of `bytes` values are not equal.
1441 #[cheatcode(group = Testing, safety = Safe)]
1442 function assertNotEq(bytes[] calldata left, bytes[] calldata right) external pure;
1443
1444 /// Asserts that two arrays of `bytes` values are not equal and includes error message into revert string on failure.
1445 #[cheatcode(group = Testing, safety = Safe)]
1446 function assertNotEq(bytes[] calldata left, bytes[] calldata right, string calldata error) external pure;
1447
1448 /// Asserts that two `uint256` values are not equal, formatting them with decimals in failure message.
1449 #[cheatcode(group = Testing, safety = Safe)]
1450 function assertNotEqDecimal(uint256 left, uint256 right, uint256 decimals) external pure;
1451
1452 /// Asserts that two `uint256` values are not equal, formatting them with decimals in failure message.
1453 /// Includes error message into revert string on failure.
1454 #[cheatcode(group = Testing, safety = Safe)]
1455 function assertNotEqDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure;
1456
1457 /// Asserts that two `int256` values are not equal, formatting them with decimals in failure message.
1458 #[cheatcode(group = Testing, safety = Safe)]
1459 function assertNotEqDecimal(int256 left, int256 right, uint256 decimals) external pure;
1460
1461 /// Asserts that two `int256` values are not equal, formatting them with decimals in failure message.
1462 /// Includes error message into revert string on failure.
1463 #[cheatcode(group = Testing, safety = Safe)]
1464 function assertNotEqDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure;
1465
1466 /// Compares two `uint256` values. Expects first value to be greater than second.
1467 #[cheatcode(group = Testing, safety = Safe)]
1468 function assertGt(uint256 left, uint256 right) external pure;
1469
1470 /// Compares two `uint256` values. Expects first value to be greater than second.
1471 /// Includes error message into revert string on failure.
1472 #[cheatcode(group = Testing, safety = Safe)]
1473 function assertGt(uint256 left, uint256 right, string calldata error) external pure;
1474
1475 /// Compares two `int256` values. Expects first value to be greater than second.
1476 #[cheatcode(group = Testing, safety = Safe)]
1477 function assertGt(int256 left, int256 right) external pure;
1478
1479 /// Compares two `int256` values. Expects first value to be greater than second.
1480 /// Includes error message into revert string on failure.
1481 #[cheatcode(group = Testing, safety = Safe)]
1482 function assertGt(int256 left, int256 right, string calldata error) external pure;
1483
1484 /// Compares two `uint256` values. Expects first value to be greater than second.
1485 /// Formats values with decimals in failure message.
1486 #[cheatcode(group = Testing, safety = Safe)]
1487 function assertGtDecimal(uint256 left, uint256 right, uint256 decimals) external pure;
1488
1489 /// Compares two `uint256` values. Expects first value to be greater than second.
1490 /// Formats values with decimals in failure message. Includes error message into revert string on failure.
1491 #[cheatcode(group = Testing, safety = Safe)]
1492 function assertGtDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure;
1493
1494 /// Compares two `int256` values. Expects first value to be greater than second.
1495 /// Formats values with decimals in failure message.
1496 #[cheatcode(group = Testing, safety = Safe)]
1497 function assertGtDecimal(int256 left, int256 right, uint256 decimals) external pure;
1498
1499 /// Compares two `int256` values. Expects first value to be greater than second.
1500 /// Formats values with decimals in failure message. Includes error message into revert string on failure.
1501 #[cheatcode(group = Testing, safety = Safe)]
1502 function assertGtDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure;
1503
1504 /// Compares two `uint256` values. Expects first value to be greater than or equal to second.
1505 #[cheatcode(group = Testing, safety = Safe)]
1506 function assertGe(uint256 left, uint256 right) external pure;
1507
1508 /// Compares two `uint256` values. Expects first value to be greater than or equal to second.
1509 /// Includes error message into revert string on failure.
1510 #[cheatcode(group = Testing, safety = Safe)]
1511 function assertGe(uint256 left, uint256 right, string calldata error) external pure;
1512
1513 /// Compares two `int256` values. Expects first value to be greater than or equal to second.
1514 #[cheatcode(group = Testing, safety = Safe)]
1515 function assertGe(int256 left, int256 right) external pure;
1516
1517 /// Compares two `int256` values. Expects first value to be greater than or equal to second.
1518 /// Includes error message into revert string on failure.
1519 #[cheatcode(group = Testing, safety = Safe)]
1520 function assertGe(int256 left, int256 right, string calldata error) external pure;
1521
1522 /// Compares two `uint256` values. Expects first value to be greater than or equal to second.
1523 /// Formats values with decimals in failure message.
1524 #[cheatcode(group = Testing, safety = Safe)]
1525 function assertGeDecimal(uint256 left, uint256 right, uint256 decimals) external pure;
1526
1527 /// Compares two `uint256` values. Expects first value to be greater than or equal to second.
1528 /// Formats values with decimals in failure message. Includes error message into revert string on failure.
1529 #[cheatcode(group = Testing, safety = Safe)]
1530 function assertGeDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure;
1531
1532 /// Compares two `int256` values. Expects first value to be greater than or equal to second.
1533 /// Formats values with decimals in failure message.
1534 #[cheatcode(group = Testing, safety = Safe)]
1535 function assertGeDecimal(int256 left, int256 right, uint256 decimals) external pure;
1536
1537 /// Compares two `int256` values. Expects first value to be greater than or equal to second.
1538 /// Formats values with decimals in failure message. Includes error message into revert string on failure.
1539 #[cheatcode(group = Testing, safety = Safe)]
1540 function assertGeDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure;
1541
1542 /// Compares two `uint256` values. Expects first value to be less than second.
1543 #[cheatcode(group = Testing, safety = Safe)]
1544 function assertLt(uint256 left, uint256 right) external pure;
1545
1546 /// Compares two `uint256` values. Expects first value to be less than second.
1547 /// Includes error message into revert string on failure.
1548 #[cheatcode(group = Testing, safety = Safe)]
1549 function assertLt(uint256 left, uint256 right, string calldata error) external pure;
1550
1551 /// Compares two `int256` values. Expects first value to be less than second.
1552 #[cheatcode(group = Testing, safety = Safe)]
1553 function assertLt(int256 left, int256 right) external pure;
1554
1555 /// Compares two `int256` values. Expects first value to be less than second.
1556 /// Includes error message into revert string on failure.
1557 #[cheatcode(group = Testing, safety = Safe)]
1558 function assertLt(int256 left, int256 right, string calldata error) external pure;
1559
1560 /// Compares two `uint256` values. Expects first value to be less than second.
1561 /// Formats values with decimals in failure message.
1562 #[cheatcode(group = Testing, safety = Safe)]
1563 function assertLtDecimal(uint256 left, uint256 right, uint256 decimals) external pure;
1564
1565 /// Compares two `uint256` values. Expects first value to be less than second.
1566 /// Formats values with decimals in failure message. Includes error message into revert string on failure.
1567 #[cheatcode(group = Testing, safety = Safe)]
1568 function assertLtDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure;
1569
1570 /// Compares two `int256` values. Expects first value to be less than second.
1571 /// Formats values with decimals in failure message.
1572 #[cheatcode(group = Testing, safety = Safe)]
1573 function assertLtDecimal(int256 left, int256 right, uint256 decimals) external pure;
1574
1575 /// Compares two `int256` values. Expects first value to be less than second.
1576 /// Formats values with decimals in failure message. Includes error message into revert string on failure.
1577 #[cheatcode(group = Testing, safety = Safe)]
1578 function assertLtDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure;
1579
1580 /// Compares two `uint256` values. Expects first value to be less than or equal to second.
1581 #[cheatcode(group = Testing, safety = Safe)]
1582 function assertLe(uint256 left, uint256 right) external pure;
1583
1584 /// Compares two `uint256` values. Expects first value to be less than or equal to second.
1585 /// Includes error message into revert string on failure.
1586 #[cheatcode(group = Testing, safety = Safe)]
1587 function assertLe(uint256 left, uint256 right, string calldata error) external pure;
1588
1589 /// Compares two `int256` values. Expects first value to be less than or equal to second.
1590 #[cheatcode(group = Testing, safety = Safe)]
1591 function assertLe(int256 left, int256 right) external pure;
1592
1593 /// Compares two `int256` values. Expects first value to be less than or equal to second.
1594 /// Includes error message into revert string on failure.
1595 #[cheatcode(group = Testing, safety = Safe)]
1596 function assertLe(int256 left, int256 right, string calldata error) external pure;
1597
1598 /// Compares two `uint256` values. Expects first value to be less than or equal to second.
1599 /// Formats values with decimals in failure message.
1600 #[cheatcode(group = Testing, safety = Safe)]
1601 function assertLeDecimal(uint256 left, uint256 right, uint256 decimals) external pure;
1602
1603 /// Compares two `uint256` values. Expects first value to be less than or equal to second.
1604 /// Formats values with decimals in failure message. Includes error message into revert string on failure.
1605 #[cheatcode(group = Testing, safety = Safe)]
1606 function assertLeDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure;
1607
1608 /// Compares two `int256` values. Expects first value to be less than or equal to second.
1609 /// Formats values with decimals in failure message.
1610 #[cheatcode(group = Testing, safety = Safe)]
1611 function assertLeDecimal(int256 left, int256 right, uint256 decimals) external pure;
1612
1613 /// Compares two `int256` values. Expects first value to be less than or equal to second.
1614 /// Formats values with decimals in failure message. Includes error message into revert string on failure.
1615 #[cheatcode(group = Testing, safety = Safe)]
1616 function assertLeDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure;
1617
1618 /// Compares two `uint256` values. Expects difference to be less than or equal to `maxDelta`.
1619 #[cheatcode(group = Testing, safety = Safe)]
1620 function assertApproxEqAbs(uint256 left, uint256 right, uint256 maxDelta) external pure;
1621
1622 /// Compares two `uint256` values. Expects difference to be less than or equal to `maxDelta`.
1623 /// Includes error message into revert string on failure.
1624 #[cheatcode(group = Testing, safety = Safe)]
1625 function assertApproxEqAbs(uint256 left, uint256 right, uint256 maxDelta, string calldata error) external pure;
1626
1627 /// Compares two `int256` values. Expects difference to be less than or equal to `maxDelta`.
1628 #[cheatcode(group = Testing, safety = Safe)]
1629 function assertApproxEqAbs(int256 left, int256 right, uint256 maxDelta) external pure;
1630
1631 /// Compares two `int256` values. Expects difference to be less than or equal to `maxDelta`.
1632 /// Includes error message into revert string on failure.
1633 #[cheatcode(group = Testing, safety = Safe)]
1634 function assertApproxEqAbs(int256 left, int256 right, uint256 maxDelta, string calldata error) external pure;
1635
1636 /// Compares two `uint256` values. Expects difference to be less than or equal to `maxDelta`.
1637 /// Formats values with decimals in failure message.
1638 #[cheatcode(group = Testing, safety = Safe)]
1639 function assertApproxEqAbsDecimal(uint256 left, uint256 right, uint256 maxDelta, uint256 decimals) external pure;
1640
1641 /// Compares two `uint256` values. Expects difference to be less than or equal to `maxDelta`.
1642 /// Formats values with decimals in failure message. Includes error message into revert string on failure.
1643 #[cheatcode(group = Testing, safety = Safe)]
1644 function assertApproxEqAbsDecimal(
1645 uint256 left,
1646 uint256 right,
1647 uint256 maxDelta,
1648 uint256 decimals,
1649 string calldata error
1650 ) external pure;
1651
1652 /// Compares two `int256` values. Expects difference to be less than or equal to `maxDelta`.
1653 /// Formats values with decimals in failure message.
1654 #[cheatcode(group = Testing, safety = Safe)]
1655 function assertApproxEqAbsDecimal(int256 left, int256 right, uint256 maxDelta, uint256 decimals) external pure;
1656
1657 /// Compares two `int256` values. Expects difference to be less than or equal to `maxDelta`.
1658 /// Formats values with decimals in failure message. Includes error message into revert string on failure.
1659 #[cheatcode(group = Testing, safety = Safe)]
1660 function assertApproxEqAbsDecimal(
1661 int256 left,
1662 int256 right,
1663 uint256 maxDelta,
1664 uint256 decimals,
1665 string calldata error
1666 ) external pure;
1667
1668 /// Compares two `uint256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`.
1669 /// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100%
1670 #[cheatcode(group = Testing, safety = Safe)]
1671 function assertApproxEqRel(uint256 left, uint256 right, uint256 maxPercentDelta) external pure;
1672
1673 /// Compares two `uint256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`.
1674 /// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100%
1675 /// Includes error message into revert string on failure.
1676 #[cheatcode(group = Testing, safety = Safe)]
1677 function assertApproxEqRel(uint256 left, uint256 right, uint256 maxPercentDelta, string calldata error) external pure;
1678
1679 /// Compares two `int256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`.
1680 /// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100%
1681 #[cheatcode(group = Testing, safety = Safe)]
1682 function assertApproxEqRel(int256 left, int256 right, uint256 maxPercentDelta) external pure;
1683
1684 /// Compares two `int256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`.
1685 /// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100%
1686 /// Includes error message into revert string on failure.
1687 #[cheatcode(group = Testing, safety = Safe)]
1688 function assertApproxEqRel(int256 left, int256 right, uint256 maxPercentDelta, string calldata error) external pure;
1689
1690 /// Compares two `uint256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`.
1691 /// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100%
1692 /// Formats values with decimals in failure message.
1693 #[cheatcode(group = Testing, safety = Safe)]
1694 function assertApproxEqRelDecimal(
1695 uint256 left,
1696 uint256 right,
1697 uint256 maxPercentDelta,
1698 uint256 decimals
1699 ) external pure;
1700
1701 /// Compares two `uint256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`.
1702 /// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100%
1703 /// Formats values with decimals in failure message. Includes error message into revert string on failure.
1704 #[cheatcode(group = Testing, safety = Safe)]
1705 function assertApproxEqRelDecimal(
1706 uint256 left,
1707 uint256 right,
1708 uint256 maxPercentDelta,
1709 uint256 decimals,
1710 string calldata error
1711 ) external pure;
1712
1713 /// Compares two `int256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`.
1714 /// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100%
1715 /// Formats values with decimals in failure message.
1716 #[cheatcode(group = Testing, safety = Safe)]
1717 function assertApproxEqRelDecimal(
1718 int256 left,
1719 int256 right,
1720 uint256 maxPercentDelta,
1721 uint256 decimals
1722 ) external pure;
1723
1724 /// Compares two `int256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`.
1725 /// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100%
1726 /// Formats values with decimals in failure message. Includes error message into revert string on failure.
1727 #[cheatcode(group = Testing, safety = Safe)]
1728 function assertApproxEqRelDecimal(
1729 int256 left,
1730 int256 right,
1731 uint256 maxPercentDelta,
1732 uint256 decimals,
1733 string calldata error
1734 ) external pure;
1735
1736 /// Returns true if the current Foundry version is greater than or equal to the given version.
1737 /// The given version string must be in the format `major.minor.patch`.
1738 ///
1739 /// This is equivalent to `foundryVersionCmp(version) >= 0`.
1740 #[cheatcode(group = Testing, safety = Safe)]
1741 function foundryVersionAtLeast(string calldata version) external view returns (bool);
1742
1743 /// Compares the current Foundry version with the given version string.
1744 /// The given version string must be in the format `major.minor.patch`.
1745 ///
1746 /// Returns:
1747 /// -1 if current Foundry version is less than the given version
1748 /// 0 if current Foundry version equals the given version
1749 /// 1 if current Foundry version is greater than the given version
1750 ///
1751 /// This result can then be used with a comparison operator against `0`.
1752 /// For example, to check if the current Foundry version is greater than or equal to `1.0.0`:
1753 /// `if (foundryVersionCmp("1.0.0") >= 0) { ... }`
1754 #[cheatcode(group = Testing, safety = Safe)]
1755 function foundryVersionCmp(string calldata version) external view returns (int256);
1756
1757 // ======== OS and Filesystem ========
1758
1759 // -------- Metadata --------
1760
1761 /// Returns true if the given path points to an existing entity, else returns false.
1762 #[cheatcode(group = Filesystem)]
1763 function exists(string calldata path) external view returns (bool result);
1764
1765 /// Given a path, query the file system to get information about a file, directory, etc.
1766 #[cheatcode(group = Filesystem)]
1767 function fsMetadata(string calldata path) external view returns (FsMetadata memory metadata);
1768
1769 /// Returns true if the path exists on disk and is pointing at a directory, else returns false.
1770 #[cheatcode(group = Filesystem)]
1771 function isDir(string calldata path) external view returns (bool result);
1772
1773 /// Returns true if the path exists on disk and is pointing at a regular file, else returns false.
1774 #[cheatcode(group = Filesystem)]
1775 function isFile(string calldata path) external view returns (bool result);
1776
1777 /// Get the path of the current project root.
1778 #[cheatcode(group = Filesystem)]
1779 function projectRoot() external view returns (string memory path);
1780
1781 /// Returns the time since unix epoch in milliseconds.
1782 #[cheatcode(group = Filesystem)]
1783 function unixTime() external view returns (uint256 milliseconds);
1784
1785 // -------- Reading and writing --------
1786
1787 /// Closes file for reading, resetting the offset and allowing to read it from beginning with readLine.
1788 /// `path` is relative to the project root.
1789 #[cheatcode(group = Filesystem)]
1790 function closeFile(string calldata path) external;
1791
1792 /// Copies the contents of one file to another. This function will **overwrite** the contents of `to`.
1793 /// 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`.
1794 /// Both `from` and `to` are relative to the project root.
1795 #[cheatcode(group = Filesystem)]
1796 function copyFile(string calldata from, string calldata to) external returns (uint64 copied);
1797
1798 /// Creates a new, empty directory at the provided path.
1799 /// This cheatcode will revert in the following situations, but is not limited to just these cases:
1800 /// - User lacks permissions to modify `path`.
1801 /// - A parent of the given path doesn't exist and `recursive` is false.
1802 /// - `path` already exists and `recursive` is false.
1803 /// `path` is relative to the project root.
1804 #[cheatcode(group = Filesystem)]
1805 function createDir(string calldata path, bool recursive) external;
1806
1807 /// Reads the directory at the given path recursively, up to `maxDepth`.
1808 /// `maxDepth` defaults to 1, meaning only the direct children of the given directory will be returned.
1809 /// Follows symbolic links if `followLinks` is true.
1810 #[cheatcode(group = Filesystem)]
1811 function readDir(string calldata path) external view returns (DirEntry[] memory entries);
1812 /// See `readDir(string)`.
1813 #[cheatcode(group = Filesystem)]
1814 function readDir(string calldata path, uint64 maxDepth) external view returns (DirEntry[] memory entries);
1815 /// See `readDir(string)`.
1816 #[cheatcode(group = Filesystem)]
1817 function readDir(string calldata path, uint64 maxDepth, bool followLinks)
1818 external
1819 view
1820 returns (DirEntry[] memory entries);
1821
1822 /// Reads the entire content of file to string. `path` is relative to the project root.
1823 #[cheatcode(group = Filesystem)]
1824 function readFile(string calldata path) external view returns (string memory data);
1825
1826 /// Reads the entire content of file as binary. `path` is relative to the project root.
1827 #[cheatcode(group = Filesystem)]
1828 function readFileBinary(string calldata path) external view returns (bytes memory data);
1829
1830 /// Reads next line of file to string.
1831 #[cheatcode(group = Filesystem)]
1832 function readLine(string calldata path) external view returns (string memory line);
1833
1834 /// Reads a symbolic link, returning the path that the link points to.
1835 /// This cheatcode will revert in the following situations, but is not limited to just these cases:
1836 /// - `path` is not a symbolic link.
1837 /// - `path` does not exist.
1838 #[cheatcode(group = Filesystem)]
1839 function readLink(string calldata linkPath) external view returns (string memory targetPath);
1840
1841 /// Removes a directory at the provided path.
1842 /// This cheatcode will revert in the following situations, but is not limited to just these cases:
1843 /// - `path` doesn't exist.
1844 /// - `path` isn't a directory.
1845 /// - User lacks permissions to modify `path`.
1846 /// - The directory is not empty and `recursive` is false.
1847 /// `path` is relative to the project root.
1848 #[cheatcode(group = Filesystem)]
1849 function removeDir(string calldata path, bool recursive) external;
1850
1851 /// Removes a file from the filesystem.
1852 /// This cheatcode will revert in the following situations, but is not limited to just these cases:
1853 /// - `path` points to a directory.
1854 /// - The file doesn't exist.
1855 /// - The user lacks permissions to remove the file.
1856 /// `path` is relative to the project root.
1857 #[cheatcode(group = Filesystem)]
1858 function removeFile(string calldata path) external;
1859
1860 /// Writes data to file, creating a file if it does not exist, and entirely replacing its contents if it does.
1861 /// `path` is relative to the project root.
1862 #[cheatcode(group = Filesystem)]
1863 function writeFile(string calldata path, string calldata data) external;
1864
1865 /// Writes binary data to a file, creating a file if it does not exist, and entirely replacing its contents if it does.
1866 /// `path` is relative to the project root.
1867 #[cheatcode(group = Filesystem)]
1868 function writeFileBinary(string calldata path, bytes calldata data) external;
1869
1870 /// Writes line to file, creating a file if it does not exist.
1871 /// `path` is relative to the project root.
1872 #[cheatcode(group = Filesystem)]
1873 function writeLine(string calldata path, string calldata data) external;
1874
1875 /// Gets the artifact path from code (aka. creation code).
1876 #[cheatcode(group = Filesystem)]
1877 function getArtifactPathByCode(bytes calldata code) external view returns (string memory path);
1878
1879 /// Gets the artifact path from deployed code (aka. runtime code).
1880 #[cheatcode(group = Filesystem)]
1881 function getArtifactPathByDeployedCode(bytes calldata deployedCode) external view returns (string memory path);
1882
1883 /// Gets the creation bytecode from an artifact file. Takes in the relative path to the json file or the path to the
1884 /// artifact in the form of <path>:<contract>:<version> where <contract> and <version> parts are optional.
1885 #[cheatcode(group = Filesystem)]
1886 function getCode(string calldata artifactPath) external view returns (bytes memory creationBytecode);
1887
1888 /// Deploys a contract from an artifact file. Takes in the relative path to the json file or the path to the
1889 /// artifact in the form of <path>:<contract>:<version> where <contract> and <version> parts are optional.
1890 #[cheatcode(group = Filesystem)]
1891 function deployCode(string calldata artifactPath) external returns (address deployedAddress);
1892
1893 /// Deploys a contract from an artifact file. Takes in the relative path to the json file or the path to the
1894 /// artifact in the form of <path>:<contract>:<version> where <contract> and <version> parts are optional.
1895 ///
1896 /// Additionally accepts abi-encoded constructor arguments.
1897 #[cheatcode(group = Filesystem)]
1898 function deployCode(string calldata artifactPath, bytes calldata constructorArgs) external returns (address deployedAddress);
1899
1900 /// Deploys a contract from an artifact file. Takes in the relative path to the json file or the path to the
1901 /// artifact in the form of <path>:<contract>:<version> where <contract> and <version> parts are optional.
1902 ///
1903 /// Additionally accepts `msg.value`.
1904 #[cheatcode(group = Filesystem)]
1905 function deployCode(string calldata artifactPath, uint256 value) external returns (address deployedAddress);
1906
1907 /// Deploys a contract from an artifact file. Takes in the relative path to the json file or the path to the
1908 /// artifact in the form of <path>:<contract>:<version> where <contract> and <version> parts are optional.
1909 ///
1910 /// Additionally accepts abi-encoded constructor arguments and `msg.value`.
1911 #[cheatcode(group = Filesystem)]
1912 function deployCode(string calldata artifactPath, bytes calldata constructorArgs, uint256 value) external returns (address deployedAddress);
1913
1914 /// 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
1915 /// artifact in the form of <path>:<contract>:<version> where <contract> and <version> parts are optional.
1916 #[cheatcode(group = Filesystem)]
1917 function deployCode(string calldata artifactPath, bytes32 salt) external returns (address deployedAddress);
1918
1919 /// 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
1920 /// artifact in the form of <path>:<contract>:<version> where <contract> and <version> parts are optional.
1921 ///
1922 /// Additionally accepts abi-encoded constructor arguments.
1923 #[cheatcode(group = Filesystem)]
1924 function deployCode(string calldata artifactPath, bytes calldata constructorArgs, bytes32 salt) external returns (address deployedAddress);
1925
1926 /// 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
1927 /// artifact in the form of <path>:<contract>:<version> where <contract> and <version> parts are optional.
1928 ///
1929 /// Additionally accepts `msg.value`.
1930 #[cheatcode(group = Filesystem)]
1931 function deployCode(string calldata artifactPath, uint256 value, bytes32 salt) external returns (address deployedAddress);
1932
1933 /// 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
1934 /// artifact in the form of <path>:<contract>:<version> where <contract> and <version> parts are optional.
1935 ///
1936 /// Additionally accepts abi-encoded constructor arguments and `msg.value`.
1937 #[cheatcode(group = Filesystem)]
1938 function deployCode(string calldata artifactPath, bytes calldata constructorArgs, uint256 value, bytes32 salt) external returns (address deployedAddress);
1939
1940 /// Gets the deployed bytecode from an artifact file. Takes in the relative path to the json file or the path to the
1941 /// artifact in the form of <path>:<contract>:<version> where <contract> and <version> parts are optional.
1942 #[cheatcode(group = Filesystem)]
1943 function getDeployedCode(string calldata artifactPath) external view returns (bytes memory runtimeBytecode);
1944
1945 /// Returns the most recent broadcast for the given contract on `chainId` matching `txType`.
1946 ///
1947 /// For example:
1948 ///
1949 /// The most recent deployment can be fetched by passing `txType` as `CREATE` or `CREATE2`.
1950 ///
1951 /// The most recent call can be fetched by passing `txType` as `CALL`.
1952 #[cheatcode(group = Filesystem)]
1953 function getBroadcast(string calldata contractName, uint64 chainId, BroadcastTxType txType) external view returns (BroadcastTxSummary memory);
1954
1955 /// Returns all broadcasts for the given contract on `chainId` with the specified `txType`.
1956 ///
1957 /// Sorted such that the most recent broadcast is the first element, and the oldest is the last. i.e descending order of BroadcastTxSummary.blockNumber.
1958 #[cheatcode(group = Filesystem)]
1959 function getBroadcasts(string calldata contractName, uint64 chainId, BroadcastTxType txType) external view returns (BroadcastTxSummary[] memory);
1960
1961 /// Returns all broadcasts for the given contract on `chainId`.
1962 ///
1963 /// Sorted such that the most recent broadcast is the first element, and the oldest is the last. i.e descending order of BroadcastTxSummary.blockNumber.
1964 #[cheatcode(group = Filesystem)]
1965 function getBroadcasts(string calldata contractName, uint64 chainId) external view returns (BroadcastTxSummary[] memory);
1966
1967 /// Returns the most recent deployment for the current `chainId`.
1968 #[cheatcode(group = Filesystem)]
1969 function getDeployment(string calldata contractName) external view returns (address deployedAddress);
1970
1971 /// Returns the most recent deployment for the given contract on `chainId`
1972 #[cheatcode(group = Filesystem)]
1973 function getDeployment(string calldata contractName, uint64 chainId) external view returns (address deployedAddress);
1974
1975 /// Returns all deployments for the given contract on `chainId`
1976 ///
1977 /// Sorted in descending order of deployment time i.e descending order of BroadcastTxSummary.blockNumber.
1978 ///
1979 /// The most recent deployment is the first element, and the oldest is the last.
1980 #[cheatcode(group = Filesystem)]
1981 function getDeployments(string calldata contractName, uint64 chainId) external view returns (address[] memory deployedAddresses);
1982
1983 // -------- Foreign Function Interface --------
1984
1985 /// Performs a foreign function call via the terminal.
1986 #[cheatcode(group = Filesystem)]
1987 function ffi(string[] calldata commandInput) external returns (bytes memory result);
1988
1989 /// Performs a foreign function call via terminal and returns the exit code, stdout, and stderr.
1990 #[cheatcode(group = Filesystem)]
1991 function tryFfi(string[] calldata commandInput) external returns (FfiResult memory result);
1992
1993 // -------- User Interaction --------
1994
1995 /// Prompts the user for a string value in the terminal.
1996 #[cheatcode(group = Filesystem)]
1997 function prompt(string calldata promptText) external returns (string memory input);
1998
1999 /// Prompts the user for a hidden string value in the terminal.
2000 #[cheatcode(group = Filesystem)]
2001 function promptSecret(string calldata promptText) external returns (string memory input);
2002
2003 /// Prompts the user for hidden uint256 in the terminal (usually pk).
2004 #[cheatcode(group = Filesystem)]
2005 function promptSecretUint(string calldata promptText) external returns (uint256);
2006
2007 /// Prompts the user for an address in the terminal.
2008 #[cheatcode(group = Filesystem)]
2009 function promptAddress(string calldata promptText) external returns (address);
2010
2011 /// Prompts the user for uint256 in the terminal.
2012 #[cheatcode(group = Filesystem)]
2013 function promptUint(string calldata promptText) external returns (uint256);
2014
2015 // ======== Environment Variables ========
2016
2017 /// Sets environment variables.
2018 #[cheatcode(group = Environment)]
2019 function setEnv(string calldata name, string calldata value) external;
2020
2021 /// Gets the environment variable `name` and returns true if it exists, else returns false.
2022 #[cheatcode(group = Environment)]
2023 function envExists(string calldata name) external view returns (bool result);
2024
2025 /// Gets the environment variable `name` and parses it as `bool`.
2026 /// Reverts if the variable was not found or could not be parsed.
2027 #[cheatcode(group = Environment)]
2028 function envBool(string calldata name) external view returns (bool value);
2029 /// Gets the environment variable `name` and parses it as `uint256`.
2030 /// Reverts if the variable was not found or could not be parsed.
2031 #[cheatcode(group = Environment)]
2032 function envUint(string calldata name) external view returns (uint256 value);
2033 /// Gets the environment variable `name` and parses it as `int256`.
2034 /// Reverts if the variable was not found or could not be parsed.
2035 #[cheatcode(group = Environment)]
2036 function envInt(string calldata name) external view returns (int256 value);
2037 /// Gets the environment variable `name` and parses it as `address`.
2038 /// Reverts if the variable was not found or could not be parsed.
2039 #[cheatcode(group = Environment)]
2040 function envAddress(string calldata name) external view returns (address value);
2041 /// Gets the environment variable `name` and parses it as `bytes32`.
2042 /// Reverts if the variable was not found or could not be parsed.
2043 #[cheatcode(group = Environment)]
2044 function envBytes32(string calldata name) external view returns (bytes32 value);
2045 /// Gets the environment variable `name` and parses it as `string`.
2046 /// Reverts if the variable was not found or could not be parsed.
2047 #[cheatcode(group = Environment)]
2048 function envString(string calldata name) external view returns (string memory value);
2049 /// Gets the environment variable `name` and parses it as `bytes`.
2050 /// Reverts if the variable was not found or could not be parsed.
2051 #[cheatcode(group = Environment)]
2052 function envBytes(string calldata name) external view returns (bytes memory value);
2053
2054 /// Gets the environment variable `name` and parses it as an array of `bool`, delimited by `delim`.
2055 /// Reverts if the variable was not found or could not be parsed.
2056 #[cheatcode(group = Environment)]
2057 function envBool(string calldata name, string calldata delim) external view returns (bool[] memory value);
2058 /// Gets the environment variable `name` and parses it as an array of `uint256`, delimited by `delim`.
2059 /// Reverts if the variable was not found or could not be parsed.
2060 #[cheatcode(group = Environment)]
2061 function envUint(string calldata name, string calldata delim) external view returns (uint256[] memory value);
2062 /// Gets the environment variable `name` and parses it as an array of `int256`, delimited by `delim`.
2063 /// Reverts if the variable was not found or could not be parsed.
2064 #[cheatcode(group = Environment)]
2065 function envInt(string calldata name, string calldata delim) external view returns (int256[] memory value);
2066 /// Gets the environment variable `name` and parses it as an array of `address`, delimited by `delim`.
2067 /// Reverts if the variable was not found or could not be parsed.
2068 #[cheatcode(group = Environment)]
2069 function envAddress(string calldata name, string calldata delim) external view returns (address[] memory value);
2070 /// Gets the environment variable `name` and parses it as an array of `bytes32`, delimited by `delim`.
2071 /// Reverts if the variable was not found or could not be parsed.
2072 #[cheatcode(group = Environment)]
2073 function envBytes32(string calldata name, string calldata delim) external view returns (bytes32[] memory value);
2074 /// Gets the environment variable `name` and parses it as an array of `string`, delimited by `delim`.
2075 /// Reverts if the variable was not found or could not be parsed.
2076 #[cheatcode(group = Environment)]
2077 function envString(string calldata name, string calldata delim) external view returns (string[] memory value);
2078 /// Gets the environment variable `name` and parses it as an array of `bytes`, delimited by `delim`.
2079 /// Reverts if the variable was not found or could not be parsed.
2080 #[cheatcode(group = Environment)]
2081 function envBytes(string calldata name, string calldata delim) external view returns (bytes[] memory value);
2082
2083 /// Gets the environment variable `name` and parses it as `bool`.
2084 /// Reverts if the variable could not be parsed.
2085 /// Returns `defaultValue` if the variable was not found.
2086 #[cheatcode(group = Environment)]
2087 function envOr(string calldata name, bool defaultValue) external view returns (bool value);
2088 /// Gets the environment variable `name` and parses it as `uint256`.
2089 /// Reverts if the variable could not be parsed.
2090 /// Returns `defaultValue` if the variable was not found.
2091 #[cheatcode(group = Environment)]
2092 function envOr(string calldata name, uint256 defaultValue) external view returns (uint256 value);
2093 /// Gets the environment variable `name` and parses it as `int256`.
2094 /// Reverts if the variable could not be parsed.
2095 /// Returns `defaultValue` if the variable was not found.
2096 #[cheatcode(group = Environment)]
2097 function envOr(string calldata name, int256 defaultValue) external view returns (int256 value);
2098 /// Gets the environment variable `name` and parses it as `address`.
2099 /// Reverts if the variable could not be parsed.
2100 /// Returns `defaultValue` if the variable was not found.
2101 #[cheatcode(group = Environment)]
2102 function envOr(string calldata name, address defaultValue) external view returns (address value);
2103 /// Gets the environment variable `name` and parses it as `bytes32`.
2104 /// Reverts if the variable could not be parsed.
2105 /// Returns `defaultValue` if the variable was not found.
2106 #[cheatcode(group = Environment)]
2107 function envOr(string calldata name, bytes32 defaultValue) external view returns (bytes32 value);
2108 /// Gets the environment variable `name` and parses it as `string`.
2109 /// Reverts if the variable could not be parsed.
2110 /// Returns `defaultValue` if the variable was not found.
2111 #[cheatcode(group = Environment)]
2112 function envOr(string calldata name, string calldata defaultValue) external view returns (string memory value);
2113 /// Gets the environment variable `name` and parses it as `bytes`.
2114 /// Reverts if the variable could not be parsed.
2115 /// Returns `defaultValue` if the variable was not found.
2116 #[cheatcode(group = Environment)]
2117 function envOr(string calldata name, bytes calldata defaultValue) external view returns (bytes memory value);
2118
2119 /// Gets the environment variable `name` and parses it as an array of `bool`, delimited by `delim`.
2120 /// Reverts if the variable could not be parsed.
2121 /// Returns `defaultValue` if the variable was not found.
2122 #[cheatcode(group = Environment)]
2123 function envOr(string calldata name, string calldata delim, bool[] calldata defaultValue)
2124 external view
2125 returns (bool[] memory value);
2126 /// Gets the environment variable `name` and parses it as an array of `uint256`, delimited by `delim`.
2127 /// Reverts if the variable could not be parsed.
2128 /// Returns `defaultValue` if the variable was not found.
2129 #[cheatcode(group = Environment)]
2130 function envOr(string calldata name, string calldata delim, uint256[] calldata defaultValue)
2131 external view
2132 returns (uint256[] memory value);
2133 /// Gets the environment variable `name` and parses it as an array of `int256`, delimited by `delim`.
2134 /// Reverts if the variable could not be parsed.
2135 /// Returns `defaultValue` if the variable was not found.
2136 #[cheatcode(group = Environment)]
2137 function envOr(string calldata name, string calldata delim, int256[] calldata defaultValue)
2138 external view
2139 returns (int256[] memory value);
2140 /// Gets the environment variable `name` and parses it as an array of `address`, delimited by `delim`.
2141 /// Reverts if the variable could not be parsed.
2142 /// Returns `defaultValue` if the variable was not found.
2143 #[cheatcode(group = Environment)]
2144 function envOr(string calldata name, string calldata delim, address[] calldata defaultValue)
2145 external view
2146 returns (address[] memory value);
2147 /// Gets the environment variable `name` and parses it as an array of `bytes32`, delimited by `delim`.
2148 /// Reverts if the variable could not be parsed.
2149 /// Returns `defaultValue` if the variable was not found.
2150 #[cheatcode(group = Environment)]
2151 function envOr(string calldata name, string calldata delim, bytes32[] calldata defaultValue)
2152 external view
2153 returns (bytes32[] memory value);
2154 /// Gets the environment variable `name` and parses it as an array of `string`, delimited by `delim`.
2155 /// Reverts if the variable could not be parsed.
2156 /// Returns `defaultValue` if the variable was not found.
2157 #[cheatcode(group = Environment)]
2158 function envOr(string calldata name, string calldata delim, string[] calldata defaultValue)
2159 external view
2160 returns (string[] memory value);
2161 /// Gets the environment variable `name` and parses it as an array of `bytes`, delimited by `delim`.
2162 /// Reverts if the variable could not be parsed.
2163 /// Returns `defaultValue` if the variable was not found.
2164 #[cheatcode(group = Environment)]
2165 function envOr(string calldata name, string calldata delim, bytes[] calldata defaultValue)
2166 external view
2167 returns (bytes[] memory value);
2168
2169 /// Returns true if `forge` command was executed in given context.
2170 #[cheatcode(group = Environment)]
2171 function isContext(ForgeContext context) external view returns (bool result);
2172
2173 // ======== Scripts ========
2174
2175 // -------- Broadcasting Transactions --------
2176
2177 /// Has the next call (at this call depth only) create transactions that can later be signed and sent onchain.
2178 ///
2179 /// Broadcasting address is determined by checking the following in order:
2180 /// 1. If `--sender` argument was provided, that address is used.
2181 /// 2. If exactly one signer (e.g. private key, hw wallet, keystore) is set when `forge broadcast` is invoked, that signer is used.
2182 /// 3. Otherwise, default foundry sender (1804c8AB1F12E6bbf3894d4083f33e07309d1f38) is used.
2183 #[cheatcode(group = Scripting)]
2184 function broadcast() external;
2185
2186 /// Has the next call (at this call depth only) create a transaction with the address provided
2187 /// as the sender that can later be signed and sent onchain.
2188 #[cheatcode(group = Scripting)]
2189 function broadcast(address signer) external;
2190
2191 /// Has the next call (at this call depth only) create a transaction with the private key
2192 /// provided as the sender that can later be signed and sent onchain.
2193 #[cheatcode(group = Scripting)]
2194 function broadcast(uint256 privateKey) external;
2195
2196 /// Has all subsequent calls (at this call depth only) create transactions that can later be signed and sent onchain.
2197 ///
2198 /// Broadcasting address is determined by checking the following in order:
2199 /// 1. If `--sender` argument was provided, that address is used.
2200 /// 2. If exactly one signer (e.g. private key, hw wallet, keystore) is set when `forge broadcast` is invoked, that signer is used.
2201 /// 3. Otherwise, default foundry sender (1804c8AB1F12E6bbf3894d4083f33e07309d1f38) is used.
2202 #[cheatcode(group = Scripting)]
2203 function startBroadcast() external;
2204
2205 /// Has all subsequent calls (at this call depth only) create transactions with the address
2206 /// provided that can later be signed and sent onchain.
2207 #[cheatcode(group = Scripting)]
2208 function startBroadcast(address signer) external;
2209
2210 /// Has all subsequent calls (at this call depth only) create transactions with the private key
2211 /// provided that can later be signed and sent onchain.
2212 #[cheatcode(group = Scripting)]
2213 function startBroadcast(uint256 privateKey) external;
2214
2215 /// Stops collecting onchain transactions.
2216 #[cheatcode(group = Scripting)]
2217 function stopBroadcast() external;
2218
2219 /// Takes a signed transaction and broadcasts it to the network.
2220 #[cheatcode(group = Scripting)]
2221 function broadcastRawTransaction(bytes calldata data) external;
2222
2223 /// Sign an EIP-7702 authorization for delegation
2224 #[cheatcode(group = Scripting)]
2225 function signDelegation(address implementation, uint256 privateKey) external returns (SignedDelegation memory signedDelegation);
2226
2227 /// Sign an EIP-7702 authorization for delegation for specific nonce
2228 #[cheatcode(group = Scripting)]
2229 function signDelegation(address implementation, uint256 privateKey, uint64 nonce) external returns (SignedDelegation memory signedDelegation);
2230
2231 /// Sign an EIP-7702 authorization for delegation, with optional cross-chain validity.
2232 #[cheatcode(group = Scripting)]
2233 function signDelegation(address implementation, uint256 privateKey, bool crossChain) external returns (SignedDelegation memory signedDelegation);
2234
2235 /// Designate the next call as an EIP-7702 transaction
2236 #[cheatcode(group = Scripting)]
2237 function attachDelegation(SignedDelegation calldata signedDelegation) external;
2238
2239 /// Designate the next call as an EIP-7702 transaction, with optional cross-chain validity.
2240 #[cheatcode(group = Scripting)]
2241 function attachDelegation(SignedDelegation calldata signedDelegation, bool crossChain) external;
2242
2243 /// Sign an EIP-7702 authorization and designate the next call as an EIP-7702 transaction
2244 #[cheatcode(group = Scripting)]
2245 function signAndAttachDelegation(address implementation, uint256 privateKey) external returns (SignedDelegation memory signedDelegation);
2246
2247 /// Sign an EIP-7702 authorization and designate the next call as an EIP-7702 transaction for specific nonce
2248 #[cheatcode(group = Scripting)]
2249 function signAndAttachDelegation(address implementation, uint256 privateKey, uint64 nonce) external returns (SignedDelegation memory signedDelegation);
2250
2251 /// Sign an EIP-7702 authorization and designate the next call as an EIP-7702 transaction, with optional cross-chain validity.
2252 #[cheatcode(group = Scripting)]
2253 function signAndAttachDelegation(address implementation, uint256 privateKey, bool crossChain) external returns (SignedDelegation memory signedDelegation);
2254
2255 /// Attach an EIP-4844 blob to the next call
2256 #[cheatcode(group = Scripting)]
2257 function attachBlob(bytes calldata blob) external;
2258
2259 /// Returns addresses of available unlocked wallets in the script environment.
2260 #[cheatcode(group = Scripting)]
2261 function getWallets() external returns (address[] memory wallets);
2262
2263 // ======== Utilities ========
2264
2265 // -------- Strings --------
2266
2267 /// Converts the given value to a `string`.
2268 #[cheatcode(group = String)]
2269 function toString(address value) external pure returns (string memory stringifiedValue);
2270 /// Converts the given value to a `string`.
2271 #[cheatcode(group = String)]
2272 function toString(bytes calldata value) external pure returns (string memory stringifiedValue);
2273 /// Converts the given value to a `string`.
2274 #[cheatcode(group = String)]
2275 function toString(bytes32 value) external pure returns (string memory stringifiedValue);
2276 /// Converts the given value to a `string`.
2277 #[cheatcode(group = String)]
2278 function toString(bool value) external pure returns (string memory stringifiedValue);
2279 /// Converts the given value to a `string`.
2280 #[cheatcode(group = String)]
2281 function toString(uint256 value) external pure returns (string memory stringifiedValue);
2282 /// Converts the given value to a `string`.
2283 #[cheatcode(group = String)]
2284 function toString(int256 value) external pure returns (string memory stringifiedValue);
2285
2286 /// Parses the given `string` into `bytes`.
2287 #[cheatcode(group = String)]
2288 function parseBytes(string calldata stringifiedValue) external pure returns (bytes memory parsedValue);
2289 /// Parses the given `string` into an `address`.
2290 #[cheatcode(group = String)]
2291 function parseAddress(string calldata stringifiedValue) external pure returns (address parsedValue);
2292 /// Parses the given `string` into a `uint256`.
2293 #[cheatcode(group = String)]
2294 function parseUint(string calldata stringifiedValue) external pure returns (uint256 parsedValue);
2295 /// Parses the given `string` into a `int256`.
2296 #[cheatcode(group = String)]
2297 function parseInt(string calldata stringifiedValue) external pure returns (int256 parsedValue);
2298 /// Parses the given `string` into a `bytes32`.
2299 #[cheatcode(group = String)]
2300 function parseBytes32(string calldata stringifiedValue) external pure returns (bytes32 parsedValue);
2301 /// Parses the given `string` into a `bool`.
2302 #[cheatcode(group = String)]
2303 function parseBool(string calldata stringifiedValue) external pure returns (bool parsedValue);
2304
2305 /// Converts the given `string` value to Lowercase.
2306 #[cheatcode(group = String)]
2307 function toLowercase(string calldata input) external pure returns (string memory output);
2308 /// Converts the given `string` value to Uppercase.
2309 #[cheatcode(group = String)]
2310 function toUppercase(string calldata input) external pure returns (string memory output);
2311 /// Trims leading and trailing whitespace from the given `string` value.
2312 #[cheatcode(group = String)]
2313 function trim(string calldata input) external pure returns (string memory output);
2314 /// Replaces occurrences of `from` in the given `string` with `to`.
2315 #[cheatcode(group = String)]
2316 function replace(string calldata input, string calldata from, string calldata to) external pure returns (string memory output);
2317 /// Splits the given `string` into an array of strings divided by the `delimiter`.
2318 #[cheatcode(group = String)]
2319 function split(string calldata input, string calldata delimiter) external pure returns (string[] memory outputs);
2320 /// Returns the index of the first occurrence of a `key` in an `input` string.
2321 /// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `key` is not found.
2322 /// Returns 0 in case of an empty `key`.
2323 #[cheatcode(group = String)]
2324 function indexOf(string calldata input, string calldata key) external pure returns (uint256);
2325 /// Returns true if `search` is found in `subject`, false otherwise.
2326 #[cheatcode(group = String)]
2327 function contains(string calldata subject, string calldata search) external returns (bool result);
2328
2329 // ======== JSON Parsing and Manipulation ========
2330
2331 // -------- Reading --------
2332
2333 // NOTE: Please read https://book.getfoundry.sh/cheatcodes/parse-json to understand the
2334 // limitations and caveats of the JSON parsing cheats.
2335
2336 /// Checks if `key` exists in a JSON object
2337 /// `keyExists` is being deprecated in favor of `keyExistsJson`. It will be removed in future versions.
2338 #[cheatcode(group = Json, status = Deprecated(Some("replaced by `keyExistsJson`")))]
2339 function keyExists(string calldata json, string calldata key) external view returns (bool);
2340 /// Checks if `key` exists in a JSON object.
2341 #[cheatcode(group = Json)]
2342 function keyExistsJson(string calldata json, string calldata key) external view returns (bool);
2343
2344 /// ABI-encodes a JSON object.
2345 #[cheatcode(group = Json)]
2346 function parseJson(string calldata json) external pure returns (bytes memory abiEncodedData);
2347 /// ABI-encodes a JSON object at `key`.
2348 #[cheatcode(group = Json)]
2349 function parseJson(string calldata json, string calldata key) external pure returns (bytes memory abiEncodedData);
2350
2351 // The following parseJson cheatcodes will do type coercion, for the type that they indicate.
2352 // For example, parseJsonUint will coerce all values to a uint256. That includes stringified numbers '12.'
2353 // and hex numbers '0xEF.'.
2354 // Type coercion works ONLY for discrete values or arrays. That means that the key must return a value or array, not
2355 // a JSON object.
2356
2357 /// Parses a string of JSON data at `key` and coerces it to `uint256`.
2358 #[cheatcode(group = Json)]
2359 function parseJsonUint(string calldata json, string calldata key) external pure returns (uint256);
2360 /// Parses a string of JSON data at `key` and coerces it to `uint256[]`.
2361 #[cheatcode(group = Json)]
2362 function parseJsonUintArray(string calldata json, string calldata key) external pure returns (uint256[] memory);
2363 /// Parses a string of JSON data at `key` and coerces it to `int256`.
2364 #[cheatcode(group = Json)]
2365 function parseJsonInt(string calldata json, string calldata key) external pure returns (int256);
2366 /// Parses a string of JSON data at `key` and coerces it to `int256[]`.
2367 #[cheatcode(group = Json)]
2368 function parseJsonIntArray(string calldata json, string calldata key) external pure returns (int256[] memory);
2369 /// Parses a string of JSON data at `key` and coerces it to `bool`.
2370 #[cheatcode(group = Json)]
2371 function parseJsonBool(string calldata json, string calldata key) external pure returns (bool);
2372 /// Parses a string of JSON data at `key` and coerces it to `bool[]`.
2373 #[cheatcode(group = Json)]
2374 function parseJsonBoolArray(string calldata json, string calldata key) external pure returns (bool[] memory);
2375 /// Parses a string of JSON data at `key` and coerces it to `address`.
2376 #[cheatcode(group = Json)]
2377 function parseJsonAddress(string calldata json, string calldata key) external pure returns (address);
2378 /// Parses a string of JSON data at `key` and coerces it to `address[]`.
2379 #[cheatcode(group = Json)]
2380 function parseJsonAddressArray(string calldata json, string calldata key)
2381 external
2382 pure
2383 returns (address[] memory);
2384 /// Parses a string of JSON data at `key` and coerces it to `string`.
2385 #[cheatcode(group = Json)]
2386 function parseJsonString(string calldata json, string calldata key) external pure returns (string memory);
2387 /// Parses a string of JSON data at `key` and coerces it to `string[]`.
2388 #[cheatcode(group = Json)]
2389 function parseJsonStringArray(string calldata json, string calldata key) external pure returns (string[] memory);
2390 /// Parses a string of JSON data at `key` and coerces it to `bytes`.
2391 #[cheatcode(group = Json)]
2392 function parseJsonBytes(string calldata json, string calldata key) external pure returns (bytes memory);
2393 /// Parses a string of JSON data at `key` and coerces it to `bytes[]`.
2394 #[cheatcode(group = Json)]
2395 function parseJsonBytesArray(string calldata json, string calldata key) external pure returns (bytes[] memory);
2396 /// Parses a string of JSON data at `key` and coerces it to `bytes32`.
2397 #[cheatcode(group = Json)]
2398 function parseJsonBytes32(string calldata json, string calldata key) external pure returns (bytes32);
2399 /// Parses a string of JSON data at `key` and coerces it to `bytes32[]`.
2400 #[cheatcode(group = Json)]
2401 function parseJsonBytes32Array(string calldata json, string calldata key)
2402 external
2403 pure
2404 returns (bytes32[] memory);
2405
2406 /// Parses a string of JSON data and coerces it to type corresponding to `typeDescription`.
2407 #[cheatcode(group = Json)]
2408 function parseJsonType(string calldata json, string calldata typeDescription) external pure returns (bytes memory);
2409 /// Parses a string of JSON data at `key` and coerces it to type corresponding to `typeDescription`.
2410 #[cheatcode(group = Json)]
2411 function parseJsonType(string calldata json, string calldata key, string calldata typeDescription) external pure returns (bytes memory);
2412 /// Parses a string of JSON data at `key` and coerces it to type array corresponding to `typeDescription`.
2413 #[cheatcode(group = Json)]
2414 function parseJsonTypeArray(string calldata json, string calldata key, string calldata typeDescription)
2415 external
2416 pure
2417 returns (bytes memory);
2418
2419 /// Returns an array of all the keys in a JSON object.
2420 #[cheatcode(group = Json)]
2421 function parseJsonKeys(string calldata json, string calldata key) external pure returns (string[] memory keys);
2422
2423 // -------- Writing --------
2424
2425 // NOTE: Please read https://book.getfoundry.sh/cheatcodes/serialize-json to understand how
2426 // to use the serialization cheats.
2427
2428 /// Serializes a key and value to a JSON object stored in-memory that can be later written to a file.
2429 /// Returns the stringified version of the specific JSON file up to that moment.
2430 #[cheatcode(group = Json)]
2431 function serializeJson(string calldata objectKey, string calldata value) external returns (string memory json);
2432
2433 /// See `serializeJson`.
2434 #[cheatcode(group = Json)]
2435 function serializeBool(string calldata objectKey, string calldata valueKey, bool value)
2436 external
2437 returns (string memory json);
2438 /// See `serializeJson`.
2439 #[cheatcode(group = Json)]
2440 function serializeUint(string calldata objectKey, string calldata valueKey, uint256 value)
2441 external
2442 returns (string memory json);
2443 /// See `serializeJson`.
2444 #[cheatcode(group = Json)]
2445 function serializeUintToHex(string calldata objectKey, string calldata valueKey, uint256 value)
2446 external
2447 returns (string memory json);
2448 /// See `serializeJson`.
2449 #[cheatcode(group = Json)]
2450 function serializeInt(string calldata objectKey, string calldata valueKey, int256 value)
2451 external
2452 returns (string memory json);
2453 /// See `serializeJson`.
2454 #[cheatcode(group = Json)]
2455 function serializeAddress(string calldata objectKey, string calldata valueKey, address value)
2456 external
2457 returns (string memory json);
2458 /// See `serializeJson`.
2459 #[cheatcode(group = Json)]
2460 function serializeBytes32(string calldata objectKey, string calldata valueKey, bytes32 value)
2461 external
2462 returns (string memory json);
2463 /// See `serializeJson`.
2464 #[cheatcode(group = Json)]
2465 function serializeString(string calldata objectKey, string calldata valueKey, string calldata value)
2466 external
2467 returns (string memory json);
2468 /// See `serializeJson`.
2469 #[cheatcode(group = Json)]
2470 function serializeBytes(string calldata objectKey, string calldata valueKey, bytes calldata value)
2471 external
2472 returns (string memory json);
2473
2474 /// See `serializeJson`.
2475 #[cheatcode(group = Json)]
2476 function serializeBool(string calldata objectKey, string calldata valueKey, bool[] calldata values)
2477 external
2478 returns (string memory json);
2479 /// See `serializeJson`.
2480 #[cheatcode(group = Json)]
2481 function serializeUint(string calldata objectKey, string calldata valueKey, uint256[] calldata values)
2482 external
2483 returns (string memory json);
2484 /// See `serializeJson`.
2485 #[cheatcode(group = Json)]
2486 function serializeInt(string calldata objectKey, string calldata valueKey, int256[] calldata values)
2487 external
2488 returns (string memory json);
2489 /// See `serializeJson`.
2490 #[cheatcode(group = Json)]
2491 function serializeAddress(string calldata objectKey, string calldata valueKey, address[] calldata values)
2492 external
2493 returns (string memory json);
2494 /// See `serializeJson`.
2495 #[cheatcode(group = Json)]
2496 function serializeBytes32(string calldata objectKey, string calldata valueKey, bytes32[] calldata values)
2497 external
2498 returns (string memory json);
2499 /// See `serializeJson`.
2500 #[cheatcode(group = Json)]
2501 function serializeString(string calldata objectKey, string calldata valueKey, string[] calldata values)
2502 external
2503 returns (string memory json);
2504 /// See `serializeJson`.
2505 #[cheatcode(group = Json)]
2506 function serializeBytes(string calldata objectKey, string calldata valueKey, bytes[] calldata values)
2507 external
2508 returns (string memory json);
2509 /// See `serializeJson`.
2510 #[cheatcode(group = Json)]
2511 function serializeJsonType(string calldata typeDescription, bytes calldata value)
2512 external
2513 pure
2514 returns (string memory json);
2515 /// See `serializeJson`.
2516 #[cheatcode(group = Json)]
2517 function serializeJsonType(string calldata objectKey, string calldata valueKey, string calldata typeDescription, bytes calldata value)
2518 external
2519 returns (string memory json);
2520
2521 // NOTE: Please read https://book.getfoundry.sh/cheatcodes/write-json to understand how
2522 // to use the JSON writing cheats.
2523
2524 /// Write a serialized JSON object to a file. If the file exists, it will be overwritten.
2525 #[cheatcode(group = Json)]
2526 function writeJson(string calldata json, string calldata path) external;
2527
2528 /// Write a serialized JSON object to an **existing** JSON file, replacing a value with key = <value_key.>
2529 /// This is useful to replace a specific value of a JSON file, without having to parse the entire thing.
2530 #[cheatcode(group = Json)]
2531 function writeJson(string calldata json, string calldata path, string calldata valueKey) external;
2532
2533 // ======== TOML Parsing and Manipulation ========
2534
2535 // -------- Reading --------
2536
2537 // NOTE: Please read https://book.getfoundry.sh/cheatcodes/parse-toml to understand the
2538 // limitations and caveats of the TOML parsing cheat.
2539
2540 /// Checks if `key` exists in a TOML table.
2541 #[cheatcode(group = Toml)]
2542 function keyExistsToml(string calldata toml, string calldata key) external view returns (bool);
2543
2544 /// ABI-encodes a TOML table.
2545 #[cheatcode(group = Toml)]
2546 function parseToml(string calldata toml) external pure returns (bytes memory abiEncodedData);
2547
2548 /// ABI-encodes a TOML table at `key`.
2549 #[cheatcode(group = Toml)]
2550 function parseToml(string calldata toml, string calldata key) external pure returns (bytes memory abiEncodedData);
2551
2552 // The following parseToml cheatcodes will do type coercion, for the type that they indicate.
2553 // For example, parseTomlUint will coerce all values to a uint256. That includes stringified numbers '12.'
2554 // and hex numbers '0xEF.'.
2555 // Type coercion works ONLY for discrete values or arrays. That means that the key must return a value or array, not
2556 // a TOML table.
2557
2558 /// Parses a string of TOML data at `key` and coerces it to `uint256`.
2559 #[cheatcode(group = Toml)]
2560 function parseTomlUint(string calldata toml, string calldata key) external pure returns (uint256);
2561 /// Parses a string of TOML data at `key` and coerces it to `uint256[]`.
2562 #[cheatcode(group = Toml)]
2563 function parseTomlUintArray(string calldata toml, string calldata key) external pure returns (uint256[] memory);
2564 /// Parses a string of TOML data at `key` and coerces it to `int256`.
2565 #[cheatcode(group = Toml)]
2566 function parseTomlInt(string calldata toml, string calldata key) external pure returns (int256);
2567 /// Parses a string of TOML data at `key` and coerces it to `int256[]`.
2568 #[cheatcode(group = Toml)]
2569 function parseTomlIntArray(string calldata toml, string calldata key) external pure returns (int256[] memory);
2570 /// Parses a string of TOML data at `key` and coerces it to `bool`.
2571 #[cheatcode(group = Toml)]
2572 function parseTomlBool(string calldata toml, string calldata key) external pure returns (bool);
2573 /// Parses a string of TOML data at `key` and coerces it to `bool[]`.
2574 #[cheatcode(group = Toml)]
2575 function parseTomlBoolArray(string calldata toml, string calldata key) external pure returns (bool[] memory);
2576 /// Parses a string of TOML data at `key` and coerces it to `address`.
2577 #[cheatcode(group = Toml)]
2578 function parseTomlAddress(string calldata toml, string calldata key) external pure returns (address);
2579 /// Parses a string of TOML data at `key` and coerces it to `address[]`.
2580 #[cheatcode(group = Toml)]
2581 function parseTomlAddressArray(string calldata toml, string calldata key)
2582 external
2583 pure
2584 returns (address[] memory);
2585 /// Parses a string of TOML data at `key` and coerces it to `string`.
2586 #[cheatcode(group = Toml)]
2587 function parseTomlString(string calldata toml, string calldata key) external pure returns (string memory);
2588 /// Parses a string of TOML data at `key` and coerces it to `string[]`.
2589 #[cheatcode(group = Toml)]
2590 function parseTomlStringArray(string calldata toml, string calldata key) external pure returns (string[] memory);
2591 /// Parses a string of TOML data at `key` and coerces it to `bytes`.
2592 #[cheatcode(group = Toml)]
2593 function parseTomlBytes(string calldata toml, string calldata key) external pure returns (bytes memory);
2594 /// Parses a string of TOML data at `key` and coerces it to `bytes[]`.
2595 #[cheatcode(group = Toml)]
2596 function parseTomlBytesArray(string calldata toml, string calldata key) external pure returns (bytes[] memory);
2597 /// Parses a string of TOML data at `key` and coerces it to `bytes32`.
2598 #[cheatcode(group = Toml)]
2599 function parseTomlBytes32(string calldata toml, string calldata key) external pure returns (bytes32);
2600 /// Parses a string of TOML data at `key` and coerces it to `bytes32[]`.
2601 #[cheatcode(group = Toml)]
2602 function parseTomlBytes32Array(string calldata toml, string calldata key)
2603 external
2604 pure
2605 returns (bytes32[] memory);
2606
2607 /// Parses a string of TOML data and coerces it to type corresponding to `typeDescription`.
2608 #[cheatcode(group = Toml)]
2609 function parseTomlType(string calldata toml, string calldata typeDescription) external pure returns (bytes memory);
2610 /// Parses a string of TOML data at `key` and coerces it to type corresponding to `typeDescription`.
2611 #[cheatcode(group = Toml)]
2612 function parseTomlType(string calldata toml, string calldata key, string calldata typeDescription) external pure returns (bytes memory);
2613 /// Parses a string of TOML data at `key` and coerces it to type array corresponding to `typeDescription`.
2614 #[cheatcode(group = Toml)]
2615 function parseTomlTypeArray(string calldata toml, string calldata key, string calldata typeDescription)
2616 external
2617 pure
2618 returns (bytes memory);
2619
2620 /// Returns an array of all the keys in a TOML table.
2621 #[cheatcode(group = Toml)]
2622 function parseTomlKeys(string calldata toml, string calldata key) external pure returns (string[] memory keys);
2623
2624 // -------- Writing --------
2625
2626 // NOTE: Please read https://book.getfoundry.sh/cheatcodes/write-toml to understand how
2627 // to use the TOML writing cheat.
2628
2629 /// Takes serialized JSON, converts to TOML and write a serialized TOML to a file.
2630 #[cheatcode(group = Toml)]
2631 function writeToml(string calldata json, string calldata path) external;
2632
2633 /// Takes serialized JSON, converts to TOML and write a serialized TOML table to an **existing** TOML file, replacing a value with key = <value_key.>
2634 /// This is useful to replace a specific value of a TOML file, without having to parse the entire thing.
2635 #[cheatcode(group = Toml)]
2636 function writeToml(string calldata json, string calldata path, string calldata valueKey) external;
2637
2638 // ======== Cryptography ========
2639
2640 // -------- Key Management --------
2641
2642 /// Derives a private key from the name, labels the account with that name, and returns the wallet.
2643 #[cheatcode(group = Crypto)]
2644 function createWallet(string calldata walletLabel) external returns (Wallet memory wallet);
2645
2646 /// Generates a wallet from the private key and returns the wallet.
2647 #[cheatcode(group = Crypto)]
2648 function createWallet(uint256 privateKey) external returns (Wallet memory wallet);
2649
2650 /// Generates a wallet from the private key, labels the account with that name, and returns the wallet.
2651 #[cheatcode(group = Crypto)]
2652 function createWallet(uint256 privateKey, string calldata walletLabel) external returns (Wallet memory wallet);
2653
2654 /// Signs data with a `Wallet`.
2655 #[cheatcode(group = Crypto)]
2656 function sign(Wallet calldata wallet, bytes32 digest) external returns (uint8 v, bytes32 r, bytes32 s);
2657
2658 /// Signs data with a `Wallet`.
2659 ///
2660 /// Returns a compact signature (`r`, `vs`) as per EIP-2098, where `vs` encodes both the
2661 /// signature's `s` value, and the recovery id `v` in a single bytes32.
2662 /// This format reduces the signature size from 65 to 64 bytes.
2663 #[cheatcode(group = Crypto)]
2664 function signCompact(Wallet calldata wallet, bytes32 digest) external returns (bytes32 r, bytes32 vs);
2665
2666 /// Signs `digest` with `privateKey` using the secp256k1 curve.
2667 #[cheatcode(group = Crypto)]
2668 function sign(uint256 privateKey, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s);
2669
2670 /// Signs `digest` with `privateKey` using the secp256k1 curve.
2671 ///
2672 /// Returns a compact signature (`r`, `vs`) as per EIP-2098, where `vs` encodes both the
2673 /// signature's `s` value, and the recovery id `v` in a single bytes32.
2674 /// This format reduces the signature size from 65 to 64 bytes.
2675 #[cheatcode(group = Crypto)]
2676 function signCompact(uint256 privateKey, bytes32 digest) external pure returns (bytes32 r, bytes32 vs);
2677
2678 /// Signs `digest` with signer provided to script using the secp256k1 curve.
2679 ///
2680 /// If `--sender` is provided, the signer with provided address is used, otherwise,
2681 /// if exactly one signer is provided to the script, that signer is used.
2682 ///
2683 /// Raises error if signer passed through `--sender` does not match any unlocked signers or
2684 /// if `--sender` is not provided and not exactly one signer is passed to the script.
2685 #[cheatcode(group = Crypto)]
2686 function sign(bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s);
2687
2688 /// Signs `digest` with signer provided to script using the secp256k1 curve.
2689 ///
2690 /// Returns a compact signature (`r`, `vs`) as per EIP-2098, where `vs` encodes both the
2691 /// signature's `s` value, and the recovery id `v` in a single bytes32.
2692 /// This format reduces the signature size from 65 to 64 bytes.
2693 ///
2694 /// If `--sender` is provided, the signer with provided address is used, otherwise,
2695 /// if exactly one signer is provided to the script, that signer is used.
2696 ///
2697 /// Raises error if signer passed through `--sender` does not match any unlocked signers or
2698 /// if `--sender` is not provided and not exactly one signer is passed to the script.
2699 #[cheatcode(group = Crypto)]
2700 function signCompact(bytes32 digest) external pure returns (bytes32 r, bytes32 vs);
2701
2702 /// Signs `digest` with signer provided to script using the secp256k1 curve.
2703 ///
2704 /// Raises error if none of the signers passed into the script have provided address.
2705 #[cheatcode(group = Crypto)]
2706 function sign(address signer, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s);
2707
2708 /// Signs `digest` with signer provided to script using the secp256k1 curve.
2709 ///
2710 /// Returns a compact signature (`r`, `vs`) as per EIP-2098, where `vs` encodes both the
2711 /// signature's `s` value, and the recovery id `v` in a single bytes32.
2712 /// This format reduces the signature size from 65 to 64 bytes.
2713 ///
2714 /// Raises error if none of the signers passed into the script have provided address.
2715 #[cheatcode(group = Crypto)]
2716 function signCompact(address signer, bytes32 digest) external pure returns (bytes32 r, bytes32 vs);
2717
2718 /// Signs `digest` with `privateKey` using the secp256r1 curve.
2719 #[cheatcode(group = Crypto)]
2720 function signP256(uint256 privateKey, bytes32 digest) external pure returns (bytes32 r, bytes32 s);
2721
2722 /// Derives secp256r1 public key from the provided `privateKey`.
2723 #[cheatcode(group = Crypto)]
2724 function publicKeyP256(uint256 privateKey) external pure returns (uint256 publicKeyX, uint256 publicKeyY);
2725
2726 /// Derive a private key from a provided mnenomic string (or mnenomic file path)
2727 /// at the derivation path `m/44'/60'/0'/0/{index}`.
2728 #[cheatcode(group = Crypto)]
2729 function deriveKey(string calldata mnemonic, uint32 index) external pure returns (uint256 privateKey);
2730 /// Derive a private key from a provided mnenomic string (or mnenomic file path)
2731 /// at `{derivationPath}{index}`.
2732 #[cheatcode(group = Crypto)]
2733 function deriveKey(string calldata mnemonic, string calldata derivationPath, uint32 index)
2734 external
2735 pure
2736 returns (uint256 privateKey);
2737 /// Derive a private key from a provided mnenomic string (or mnenomic file path) in the specified language
2738 /// at the derivation path `m/44'/60'/0'/0/{index}`.
2739 #[cheatcode(group = Crypto)]
2740 function deriveKey(string calldata mnemonic, uint32 index, string calldata language)
2741 external
2742 pure
2743 returns (uint256 privateKey);
2744 /// Derive a private key from a provided mnenomic string (or mnenomic file path) in the specified language
2745 /// at `{derivationPath}{index}`.
2746 #[cheatcode(group = Crypto)]
2747 function deriveKey(string calldata mnemonic, string calldata derivationPath, uint32 index, string calldata language)
2748 external
2749 pure
2750 returns (uint256 privateKey);
2751
2752 /// Adds a private key to the local forge wallet and returns the address.
2753 #[cheatcode(group = Crypto)]
2754 function rememberKey(uint256 privateKey) external returns (address keyAddr);
2755
2756 /// Derive a set number of wallets from a mnemonic at the derivation path `m/44'/60'/0'/0/{0..count}`.
2757 ///
2758 /// The respective private keys are saved to the local forge wallet for later use and their addresses are returned.
2759 #[cheatcode(group = Crypto)]
2760 function rememberKeys(string calldata mnemonic, string calldata derivationPath, uint32 count) external returns (address[] memory keyAddrs);
2761
2762 /// Derive a set number of wallets from a mnemonic in the specified language at the derivation path `m/44'/60'/0'/0/{0..count}`.
2763 ///
2764 /// The respective private keys are saved to the local forge wallet for later use and their addresses are returned.
2765 #[cheatcode(group = Crypto)]
2766 function rememberKeys(string calldata mnemonic, string calldata derivationPath, string calldata language, uint32 count)
2767 external
2768 returns (address[] memory keyAddrs);
2769
2770 // -------- Uncategorized Utilities --------
2771
2772 /// Labels an address in call traces.
2773 #[cheatcode(group = Utilities)]
2774 function label(address account, string calldata newLabel) external;
2775
2776 /// Gets the label for the specified address.
2777 #[cheatcode(group = Utilities)]
2778 function getLabel(address account) external view returns (string memory currentLabel);
2779
2780 /// Compute the address a contract will be deployed at for a given deployer address and nonce.
2781 #[cheatcode(group = Utilities)]
2782 function computeCreateAddress(address deployer, uint256 nonce) external pure returns (address);
2783
2784 /// Compute the address of a contract created with CREATE2 using the given CREATE2 deployer.
2785 #[cheatcode(group = Utilities)]
2786 function computeCreate2Address(bytes32 salt, bytes32 initCodeHash, address deployer) external pure returns (address);
2787
2788 /// Compute the address of a contract created with CREATE2 using the default CREATE2 deployer.
2789 #[cheatcode(group = Utilities)]
2790 function computeCreate2Address(bytes32 salt, bytes32 initCodeHash) external pure returns (address);
2791
2792 /// Encodes a `bytes` value to a base64 string.
2793 #[cheatcode(group = Utilities)]
2794 function toBase64(bytes calldata data) external pure returns (string memory);
2795
2796 /// Encodes a `string` value to a base64 string.
2797 #[cheatcode(group = Utilities)]
2798 function toBase64(string calldata data) external pure returns (string memory);
2799
2800 /// Encodes a `bytes` value to a base64url string.
2801 #[cheatcode(group = Utilities)]
2802 function toBase64URL(bytes calldata data) external pure returns (string memory);
2803
2804 /// Encodes a `string` value to a base64url string.
2805 #[cheatcode(group = Utilities)]
2806 function toBase64URL(string calldata data) external pure returns (string memory);
2807
2808 /// Returns ENS namehash for provided string.
2809 #[cheatcode(group = Utilities)]
2810 function ensNamehash(string calldata name) external pure returns (bytes32);
2811
2812 /// Returns a random uint256 value.
2813 #[cheatcode(group = Utilities)]
2814 function randomUint() external returns (uint256);
2815
2816 /// Returns random uint256 value between the provided range (=min..=max).
2817 #[cheatcode(group = Utilities)]
2818 function randomUint(uint256 min, uint256 max) external returns (uint256);
2819
2820 /// Returns a random `uint256` value of given bits.
2821 #[cheatcode(group = Utilities)]
2822 function randomUint(uint256 bits) external view returns (uint256);
2823
2824 /// Returns a random `address`.
2825 #[cheatcode(group = Utilities)]
2826 function randomAddress() external returns (address);
2827
2828 /// Returns a random `int256` value.
2829 #[cheatcode(group = Utilities)]
2830 function randomInt() external view returns (int256);
2831
2832 /// Returns a random `int256` value of given bits.
2833 #[cheatcode(group = Utilities)]
2834 function randomInt(uint256 bits) external view returns (int256);
2835
2836 /// Returns a random `bool`.
2837 #[cheatcode(group = Utilities)]
2838 function randomBool() external view returns (bool);
2839
2840 /// Returns a random byte array value of the given length.
2841 #[cheatcode(group = Utilities)]
2842 function randomBytes(uint256 len) external view returns (bytes memory);
2843
2844 /// Returns a random fixed-size byte array of length 4.
2845 #[cheatcode(group = Utilities)]
2846 function randomBytes4() external view returns (bytes4);
2847
2848 /// Returns a random fixed-size byte array of length 8.
2849 #[cheatcode(group = Utilities)]
2850 function randomBytes8() external view returns (bytes8);
2851
2852 /// Pauses collection of call traces. Useful in cases when you want to skip tracing of
2853 /// complex calls which are not useful for debugging.
2854 #[cheatcode(group = Utilities)]
2855 function pauseTracing() external view;
2856
2857 /// Unpauses collection of call traces.
2858 #[cheatcode(group = Utilities)]
2859 function resumeTracing() external view;
2860
2861 /// Utility cheatcode to copy storage of `from` contract to another `to` contract.
2862 #[cheatcode(group = Utilities)]
2863 function copyStorage(address from, address to) external;
2864
2865 /// Utility cheatcode to set arbitrary storage for given target address.
2866 #[cheatcode(group = Utilities)]
2867 function setArbitraryStorage(address target) external;
2868
2869 /// Utility cheatcode to set arbitrary storage for given target address and overwrite
2870 /// any storage slots that have been previously set.
2871 #[cheatcode(group = Utilities)]
2872 function setArbitraryStorage(address target, bool overwrite) external;
2873
2874 /// Sorts an array in ascending order.
2875 #[cheatcode(group = Utilities)]
2876 function sort(uint256[] calldata array) external returns (uint256[] memory);
2877
2878 /// Randomly shuffles an array.
2879 #[cheatcode(group = Utilities)]
2880 function shuffle(uint256[] calldata array) external returns (uint256[] memory);
2881
2882 /// Causes the next contract creation (via new) to fail and return its initcode in the returndata buffer.
2883 /// This allows type-safe access to the initcode payload that would be used for contract creation.
2884 /// Example usage:
2885 /// vm.interceptInitcode();
2886 /// bytes memory initcode;
2887 /// try new MyContract(param1, param2) { assert(false); }
2888 /// catch (bytes memory interceptedInitcode) { initcode = interceptedInitcode; }
2889 #[cheatcode(group = Utilities, safety = Unsafe)]
2890 function interceptInitcode() external;
2891
2892 /// Generates the hash of the canonical EIP-712 type representation.
2893 ///
2894 /// Supports 2 different inputs:
2895 /// 1. Name of the type (i.e. "Transaction"):
2896 /// * requires previous binding generation with `forge bind-json`.
2897 /// * bindings will be retrieved from the path configured in `foundry.toml`.
2898 ///
2899 /// 2. String representation of the type (i.e. "Foo(Bar bar) Bar(uint256 baz)").
2900 /// * Note: the cheatcode will output the canonical type even if the input is malformated
2901 /// with the wrong order of elements or with extra whitespaces.
2902 #[cheatcode(group = Utilities)]
2903 function eip712HashType(string calldata typeNameOrDefinition) external pure returns (bytes32 typeHash);
2904
2905 /// Generates the hash of the canonical EIP-712 type representation.
2906 /// Requires previous binding generation with `forge bind-json`.
2907 ///
2908 /// Params:
2909 /// * `bindingsPath`: path where the output of `forge bind-json` is stored.
2910 /// * `typeName`: Name of the type (i.e. "Transaction").
2911 #[cheatcode(group = Utilities)]
2912 function eip712HashType(string calldata bindingsPath, string calldata typeName) external pure returns (bytes32 typeHash);
2913
2914 /// Generates the struct hash of the canonical EIP-712 type representation and its abi-encoded data.
2915 ///
2916 /// Supports 2 different inputs:
2917 /// 1. Name of the type (i.e. "PermitSingle"):
2918 /// * requires previous binding generation with `forge bind-json`.
2919 /// * bindings will be retrieved from the path configured in `foundry.toml`.
2920 ///
2921 /// 2. String representation of the type (i.e. "Foo(Bar bar) Bar(uint256 baz)").
2922 /// * Note: the cheatcode will use the canonical type even if the input is malformated
2923 /// with the wrong order of elements or with extra whitespaces.
2924 #[cheatcode(group = Utilities)]
2925 function eip712HashStruct(string calldata typeNameOrDefinition, bytes calldata abiEncodedData) external pure returns (bytes32 typeHash);
2926
2927 /// Generates the struct hash of the canonical EIP-712 type representation and its abi-encoded data.
2928 /// Requires previous binding generation with `forge bind-json`.
2929 ///
2930 /// Params:
2931 /// * `bindingsPath`: path where the output of `forge bind-json` is stored.
2932 /// * `typeName`: Name of the type (i.e. "PermitSingle").
2933 /// * `abiEncodedData`: ABI-encoded data for the struct that is being hashed.
2934 #[cheatcode(group = Utilities)]
2935 function eip712HashStruct(string calldata bindingsPath, string calldata typeName, bytes calldata abiEncodedData) external pure returns (bytes32 typeHash);
2936
2937 /// Generates a ready-to-sign digest of human-readable typed data following the EIP-712 standard.
2938 #[cheatcode(group = Utilities)]
2939 function eip712HashTypedData(string calldata jsonData) external pure returns (bytes32 digest);
2940}
2941}
2942
2943impl PartialEq for ForgeContext {
2944 // Handles test group case (any of test, coverage or snapshot)
2945 // and script group case (any of dry run, broadcast or resume).
2946 fn eq(&self, other: &Self) -> bool {
2947 match (self, other) {
2948 (_, Self::TestGroup) => {
2949 matches!(self, Self::Test | Self::Snapshot | Self::Coverage)
2950 }
2951 (_, Self::ScriptGroup) => {
2952 matches!(self, Self::ScriptDryRun | Self::ScriptBroadcast | Self::ScriptResume)
2953 }
2954 (Self::Test, Self::Test) |
2955 (Self::Snapshot, Self::Snapshot) |
2956 (Self::Coverage, Self::Coverage) |
2957 (Self::ScriptDryRun, Self::ScriptDryRun) |
2958 (Self::ScriptBroadcast, Self::ScriptBroadcast) |
2959 (Self::ScriptResume, Self::ScriptResume) |
2960 (Self::Unknown, Self::Unknown) => true,
2961 _ => false,
2962 }
2963 }
2964}
2965
2966impl fmt::Display for Vm::CheatcodeError {
2967 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2968 self.message.fmt(f)
2969 }
2970}
2971
2972impl fmt::Display for Vm::VmErrors {
2973 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2974 match self {
2975 Self::CheatcodeError(err) => err.fmt(f),
2976 }
2977 }
2978}
2979
2980#[track_caller]
2981const fn panic_unknown_safety() -> ! {
2982 panic!("cannot determine safety from the group, add a `#[cheatcode(safety = ...)]` attribute")
2983}