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