Skip to content

Releases: foundry-rs/forge-std

v1.8.2

08 May 16:00
978ac6f

Choose a tag to compare

Featured Changes

Expand to see the full set of new cheats
/// Gets the environment variable `name` and returns true if it exists, else returns false.
function envExists(string calldata name) external view returns (bool result);

/// Returns true if `forge` command was executed in given context.
function isContext(ForgeContext context) external view returns (bool result);

/// Gets the current `block.blobbasefee`.
/// You should use this instead of `block.blobbasefee` if you use `vm.blobBaseFee`, as `block.blobbasefee` is assumed to be constant across a transaction,
/// and as a result will get optimized out by the compiler.
/// See https://github.com/foundry-rs/foundry/issues/6180
function getBlobBaseFee() external view returns (uint256 blobBaseFee);

/// Gets the gas used in the last call.
function lastCallGas() external view returns (Gas memory gas);

/// Signs `digest` with signer provided to script using the secp256k1 curve.
/// If `--sender` is provided, the signer with provided address is used, otherwise,
/// if exactly one signer is provided to the script, that signer is used.
/// Raises error if signer passed through `--sender` does not match any unlocked signers or
/// if `--sender` is not provided and not exactly one signer is passed to the script.
function sign(bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s);

/// Signs `digest` with signer provided to script using the secp256k1 curve.
/// Raises error if none of the signers passed into the script have provided address.
function sign(address signer, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s);

/// Prompts the user for a string value in the terminal.
function prompt(string calldata promptText) external returns (string memory input);

/// Prompts the user for an address in the terminal.
function promptAddress(string calldata promptText) external returns (address);

/// Prompts the user for a hidden string value in the terminal.
function promptSecret(string calldata promptText) external returns (string memory input);

/// Prompts the user for uint256 in the terminal.
function promptUint(string calldata promptText) external returns (uint256);

/// See `serializeJson`.
function serializeUintToHex(string calldata objectKey, string calldata valueKey, uint256 value)
    external
    returns (string memory json);

/// Returns the index of the first occurrence of a `key` in an `input` string.
/// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `key` is not found.
/// Returns 0 in case of an empty `key`.
function indexOf(string calldata input, string calldata key) external pure returns (uint256);

/// Returns ENS namehash for provided string.
function ensNamehash(string calldata name) external pure returns (bytes32);

/// Sets `block.blobbasefee`
function blobBaseFee(uint256 newBlobBaseFee) external;

/// Sets the blobhashes in the transaction.
/// Not available on EVM versions before Cancun.
/// If used on unsupported EVM versions it will revert.
function blobhashes(bytes32[] calldata hashes) external;

/// Gets the blockhashes from the current transaction.
/// Not available on EVM versions before Cancun.
/// If used on unsupported EVM versions it will revert.
function getBlobhashes() external view returns (bytes32[] memory hashes);

/// Sets `block.prevrandao`.
/// Not available on EVM versions before Paris. Use `difficulty` instead.
/// If used on unsupported EVM versions it will revert.
function prevrandao(uint256 newPrevrandao) external;

Other Changes

New Contributors

Full Changelog: v1.8.1...v1.8.2

v1.8.1

17 Mar 21:41
bb4ceea

Choose a tag to compare

What's Changed

  • fix: add IS_TEST = true to Test by @mds1 in #523. This is a bug fix to ensure forge build --sizes continues to work as it did prior to forge-std v1.8.0

Full Changelog: v1.8.0...v1.8.1

v1.8.0

11 Mar 23:50
b6a506d

Choose a tag to compare

Featured Changes

  • feat/perf: use native assertions by @klkvr in #514.
    • This replaces forge-std Solidity code with native cheatcode assertions from Foundry, so should give a small performance boost.
    • Assertion failures now cause tests to exit early, instead of continuing with execution.
    • This also will require some visibility modifier changes to tests, as assertion methods no longer set state.
    • NOTE: If you were using the vm.expectSafeMemory cheat, you may need to now use the new vm.stopExpectSafeMemory cheat from #507. See #503 (comment) to learn more, h/t @clabby.
  • feat(stdStorage): support packed variables by @klkvr in #505. This means deal now works with USDC and other variables that reply on packed storage slots.
    • The USDC deal support works out of the box.
    • To avoid breaking changes arbitrary packed slot support is not enabled by default, and can be enabled with stdstore.enable_packed_slots().target(.....
  • feat: add TOML reading/writing cheatcodes by @zerosnacks in #518. These are analogous to their JSON equivalents.
    • NOTE: This adds file specific keyExistsJson and keyExistsToml cheats. The ambiguous keyExists currently is an alias for keyExistsJson and will be deprecated.
  • feat: native string maniupulation cheatcodes of toLowercase, toUppercase, trim, replace and split from foundry-rs/foundry#6891.
  • feat: implement interfaces in mock tokens by @arr00 in #510.

Other Changes

New Contributors

Full Changelog: v1.7.6...v1.8.0

v1.7.6

17 Jan 21:57
ae570fe

Choose a tag to compare

Featured Changes:

Other Changes

Full Changelog: v1.7.5...v1.7.6

v1.7.5

11 Jan 19:11
36c303b

Choose a tag to compare

Featured Changes

Other Changes

  • feat: automatically generate Vm.sol from cheatcodes.json by @DaniPopes in #487
  • chore: bump to v1.7.5 by @mds1 in #492

New Contributors

Full Changelog: v1.7.4...v1.7.5

v1.7.4

15 Dec 16:13
155d547

Choose a tag to compare

Featured Changes

  • Update Vm.sol with changes to AccountAccessKind by @emo-eth in #483.
    • This adds Balance, Extcodesize, Extcodehash, Extcodecopy as account access kinds
  • feat: add new snapshot cheatcodes by @mattsse in #484.
    • The vm.revertTo(snapshotId) cheat does not automatically delete the snapshotId snapshot, which can lead to unbounded memory growth with lots of snapshots. Therefore, vm.revertToAndDelete(snapshotId), vm.deleteSnapshot(snapshotId), and vm.deleteSnapshots() were added as new cheats.

Other Changes

Full Changelog: v1.7.3...v1.7.4

v1.7.3

20 Nov 14:44
2f11269

Choose a tag to compare

Featured Changes

  • feat: add vm.startStateDiffRecording and vm.stopAndReturnStateDiff cheats to record all account accesses and storage accesses, by @Inphi in #481
  • feat: add vm.computeCreateAddress and vm.computeCreate2Address cheats, by @qiweiii in #479
    • These native cheats replace the need for the StdUtils methods of the same now, which will now give a deprecation warning when used.
  • feat: add mock contracts for ERC20 and ERC721, by @andreivladbrg in #470
    • Be aware that these use initializers instead of constructors for compatibility across Solidity versions. Therefore it's recommended to use the deployMockERC20 and deployMockERC721 methods in StdUtils to deploy them.

Other Changes

  • chore: bump version to v1.7.3 by @mds1 in #482

New Contributors

Full Changelog: v1.7.2...v1.7.3

v1.7.2

13 Nov 23:24
bdea49f

Choose a tag to compare

Featured Changes

  • feat: add vm.loadAllocs(string) cheatcode by @tynes in #474. This reads in a JSON file to directly set state for many accounts at once.
  • feat: add vm.eth_getLogs and vm.rpc cheats by @Evalir in #475. The vm.eth_getLogs cheat makes an eth_getLogs RPC call and returns the result, and the vm.rpc cheat allows arbitrary RPC calls to be made. These query the current fork URL.

Other Changes

New Contributors

Full Changelog: v1.7.1...v1.7.2

v1.7.1

05 Oct 20:35
f73c73d

Choose a tag to compare

What's Changed

This release contains no functional changes. It simply resolves #467 by ensuring the version in the package.json matches the release. The package.json file was updated in #468.

Full Changelog: v1.7.0...v1.7.1

v1.7.0

04 Oct 14:55
dcb0d52

Choose a tag to compare

Featured Changes

  • chore(BREAKING CHANGE): Change exit_code to exitCode by @PaulRBerg in #458
    • This is a breaking change for any users who use the exit_code variable in the FfiResult struct1
  • feat: add new vm.serializeJson cheatcode to the Vm and to StdJson by @vdrg in #453
  • feat: add vm.unixTime to VmSafe interface by @Tudmotu in #465
  • perf: mark vm.parseJsonKeys as pure by @PaulRBerg in #460

Other Changes

  • chore: reorder Vm for logical consistency by @mds1 in #464

Full Changelog: v1.6.1...v1.7.0

  1. exit_code was recently introduced, and a sourcegraph search did not reveal many existing users of it. Because this repo uses camelCase, it was determined this breaking change was acceptable to keep things consistent, even though this technically does not follow semver.