@@ -4,45 +4,57 @@ pragma solidity >=0.8.13 <0.9.0;
44import {StdStorage} from "./StdStorage.sol " ;
55import {Vm, VmSafe} from "./Vm.sol " ;
66
7+ /// @notice Base contract shared by `TestBase` and `ScriptBase`, exposing the addresses and
8+ /// instances that every Forge test or script depends on (the cheatcode VM, the console,
9+ /// the deterministic CREATE2 factory, and so on).
710abstract contract CommonBase {
8- /// @dev Cheat code address.
9- /// Calculated as `address(uint160(uint256(keccak256("hevm cheat code"))))`.
11+ /// @notice The cheat code address that exposes Forge's VM API .
12+ /// @dev Calculated as `address(uint160(uint256(keccak256("hevm cheat code"))))`.
1013 address internal constant VM_ADDRESS = 0x7109709ECfa91a80626fF3989D68f67F5b1DD12D ;
1114
12- /// @dev console.sol and console2.sol work by executing a staticcall to this address .
13- /// Calculated as `address(uint160(uint88(bytes11("console.log"))))`.
15+ /// @notice The address used by ` console.sol` / ` console2.sol` to forward log payloads via staticcall .
16+ /// @dev Calculated as `address(uint160(uint88(bytes11("console.log"))))`.
1417 address internal constant CONSOLE = 0x000000000000000000636F6e736F6c652e6c6f67 ;
1518
16- /// @dev Used when deploying with create2.
17- /// Taken from https://github.com/Arachnid/deterministic-deployment-proxy.
19+ /// @notice The deterministic CREATE2 factory used when deploying via create2.
20+ /// @dev Taken from https://github.com/Arachnid/deterministic-deployment-proxy.
1821 address internal constant CREATE2_FACTORY = 0x4e59b44847b379578588920cA78FbF26c0B4956C ;
1922
20- /// @dev The default address for tx.origin and msg.sender.
21- /// Calculated as `address(uint160(uint256(keccak256("foundry default caller"))))`.
23+ /// @notice The default address for ` tx.origin` and ` msg.sender` during Forge tests and scripts .
24+ /// @dev Calculated as `address(uint160(uint256(keccak256("foundry default caller"))))`.
2225 address internal constant DEFAULT_SENDER = 0x1804c8AB1F12E6bbf3894d4083f33e07309d1f38 ;
2326
24- /// @dev The address of the first contract `CREATE`d by a running test contract.
25- /// When running tests, each test contract is `CREATE`d by `DEFAULT_SENDER` with nonce 1.
26- /// Calculated as `VM.computeCreateAddress(VM.computeCreateAddress(DEFAULT_SENDER, 1), 1)`.
27+ /// @notice The address of the first contract `CREATE`d by a running test contract.
28+ /// @dev When running tests, each test contract is `CREATE`d by `DEFAULT_SENDER` with nonce 1.
29+ /// Calculated as `VM.computeCreateAddress(VM.computeCreateAddress(DEFAULT_SENDER, 1), 1)`.
2730 address internal constant DEFAULT_TEST_CONTRACT = 0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f ;
2831
29- /// @dev Deterministic deployment address of the Multicall3 contract.
30- /// Taken from https://www.multicall3.com.
32+ /// @notice The deterministic deployment address of the Multicall3 contract.
33+ /// @dev Taken from https://www.multicall3.com.
3134 address internal constant MULTICALL3_ADDRESS = 0xcA11bde05977b3631167028862bE2a173976CA11 ;
3235
33- /// @dev The order of the secp256k1 curve.
36+ /// @notice The order of the secp256k1 curve, useful when constraining signature components .
3437 uint256 internal constant SECP256K1_ORDER =
3538 115792089237316195423570985008687907852837564279074904382605163141518161494337 ;
3639
40+ /// @notice The largest representable `uint256`, equal to `type(uint256).max`.
3741 uint256 internal constant UINT256_MAX =
3842 115792089237316195423570985008687907853269984665640564039457584007913129639935 ;
3943
44+ /// @notice The cheatcode VM interface, callable from both tests and scripts.
4045 Vm internal constant vm = Vm (VM_ADDRESS);
46+
47+ /// @notice Standard-library helper for reading and writing storage slots by name.
4148 StdStorage internal stdstore;
4249}
4350
51+ /// @notice Base contract that test contracts inherit from. Adds no extra state beyond `CommonBase`
52+ /// but exists as a distinct type so cheatcodes restricted to tests can be gated.
4453abstract contract TestBase is CommonBase {}
4554
55+ /// @notice Base contract that script contracts inherit from. Exposes the safe (script-only)
56+ /// subset of the cheatcode VM in addition to everything provided by `CommonBase`.
4657abstract contract ScriptBase is CommonBase {
58+ /// @notice The safe-cheatcode VM interface available to scripts (no test-only cheatcodes).
4759 VmSafe internal constant vmSafe = VmSafe (VM_ADDRESS);
4860}
0 commit comments