diff --git a/packages/cli/package.json b/packages/cli/package.json index 56fcafd2c2..86d832c15a 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -52,7 +52,7 @@ "ethers": "^5.7.2", "execa": "^6.1.0", "figlet": "^1.5.2", - "forge-std": "https://github.com/foundry-rs/forge-std.git#f36dab24d63d1c1945a05ed375ce341d3c1a49ed", + "forge-std": "https://github.com/foundry-rs/forge-std.git#b4f121555729b3afb3c5ffccb62ff4b6e2818fd3", "glob": "^8.0.3", "inquirer": "^8.2.4", "inquirer-prompt-suggest": "^0.1.0", diff --git a/packages/cli/src/contracts/BulkUpload.sol b/packages/cli/src/contracts/BulkUpload.sol index 8648678cb9..efa4814287 100644 --- a/packages/cli/src/contracts/BulkUpload.sol +++ b/packages/cli/src/contracts/BulkUpload.sol @@ -1,9 +1,9 @@ // SPDX-License-Identifier: MIT pragma solidity >=0.8.0; -import "ds-test/test.sol"; +import {Script} from "forge-std/Script.sol"; import {console} from "forge-std/console.sol"; -import {Cheats} from "./Cheats.sol"; + import {BulkSetStateSystem, ID as BulkSetStateSystemID, ECSEvent} from "std-contracts/systems/BulkSetStateSystem.sol"; import {World} from "solecs/World.sol"; import {System} from "solecs/System.sol"; @@ -32,24 +32,22 @@ struct State { * Usage: * forge script --sig "run(string, address)" --rpc-url http://localhost:8545 src/contracts/BulkUpload.sol:BulkUpload path/to/ecs-map-test.json */ -contract BulkUpload is DSTest { - Cheats internal immutable vm = Cheats(HEVM_ADDRESS); - +contract BulkUpload is Script { function run( string memory path, address worldAddress, uint256 eventsPerTx ) public { - vm.startBroadcast(); + vmSafe.startBroadcast(); // Read JSON console.log(path); - string memory json = vm.readFile(path); + string memory json = vmSafe.readFile(path); console.log(worldAddress); // Parse JSON - ParsedState memory parsedState = abi.decode(vm.parseJson(json), (ParsedState)); + ParsedState memory parsedState = abi.decode(vmSafe.parseJson(json), (ParsedState)); // Convert component ids uint256[] memory componentIds = new uint256[](parsedState.componentIds.length); @@ -106,7 +104,7 @@ contract BulkUpload is DSTest { bulkSetStateSystem.execute(abi.encode(componentIds, newOverflowEntities, newOverflowEvents)); - vm.stopBroadcast(); + vmSafe.stopBroadcast(); } } diff --git a/packages/cli/src/contracts/Cheats.sol b/packages/cli/src/contracts/Cheats.sol deleted file mode 100644 index f9fb30f399..0000000000 --- a/packages/cli/src/contracts/Cheats.sol +++ /dev/null @@ -1,320 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.0; - -interface Cheats { - // This allows us to getRecordedLogs() - struct Log { - bytes32[] topics; - bytes data; - } - - // Set block.timestamp (newTimestamp) - function warp(uint256) external; - - // Set block.height (newHeight) - function roll(uint256) external; - - // Set block.basefee (newBasefee) - function fee(uint256) external; - - // Set block.coinbase (who) - function coinbase(address) external; - - // Loads a storage slot from an address (who, slot) - function load(address, bytes32) external returns (bytes32); - - // Stores a value to an address' storage slot, (who, slot, value) - function store( - address, - bytes32, - bytes32 - ) external; - - // Signs data, (privateKey, digest) => (v, r, s) - function sign(uint256, bytes32) - external - returns ( - uint8, - bytes32, - bytes32 - ); - - // Gets address for a given private key, (privateKey) => (address) - function addr(uint256) external returns (address); - - // Derive a private key from a provided mnenomic string (or mnenomic file path) at the derivation path m/44'/60'/0'/0/{index} - function deriveKey(string calldata, uint32) external returns (uint256); - - // Derive a private key from a provided mnenomic string (or mnenomic file path) at the derivation path {path}{index} - function deriveKey( - string calldata, - string calldata, - uint32 - ) external returns (uint256); - - // Performs a foreign function call via terminal, (stringInputs) => (result) - function ffi(string[] calldata) external returns (bytes memory); - - // Set environment variables, (name, value) - function setEnv(string calldata, string calldata) external; - - // Read environment variables, (name) => (value) - function envBool(string calldata) external returns (bool); - - function envUint(string calldata) external returns (uint256); - - function envInt(string calldata) external returns (int256); - - function envAddress(string calldata) external returns (address); - - function envBytes32(string calldata) external returns (bytes32); - - function envString(string calldata) external returns (string memory); - - function envBytes(string calldata) external returns (bytes memory); - - // Read environment variables as arrays, (name, delim) => (value[]) - function envBool(string calldata, string calldata) external returns (bool[] memory); - - function envUint(string calldata, string calldata) external returns (uint256[] memory); - - function envInt(string calldata, string calldata) external returns (int256[] memory); - - function envAddress(string calldata, string calldata) external returns (address[] memory); - - function envBytes32(string calldata, string calldata) external returns (bytes32[] memory); - - function envString(string calldata, string calldata) external returns (string[] memory); - - function envBytes(string calldata, string calldata) external returns (bytes[] memory); - - // Sets the *next* call's msg.sender to be the input address - function prank(address) external; - - // Sets all subsequent calls' msg.sender to be the input address until `stopPrank` is called - function startPrank(address) external; - - // Sets the *next* call's msg.sender to be the input address, and the tx.origin to be the second input - function prank(address, address) external; - - // Sets all subsequent calls' msg.sender to be the input address until `stopPrank` is called, and the tx.origin to be the second input - function startPrank(address, address) external; - - // Resets subsequent calls' msg.sender to be `address(this)` - function stopPrank() external; - - // Sets an address' balance, (who, newBalance) - function deal(address, uint256) external; - - // Sets an address' code, (who, newCode) - function etch(address, bytes calldata) external; - - // Expects an error on next call - function expectRevert() external; - - function expectRevert(bytes calldata) external; - - function expectRevert(bytes4) external; - - // Record all storage reads and writes - function record() external; - - // Gets all accessed reads and write slot from a recording session, for a given address - function accesses(address) external returns (bytes32[] memory reads, bytes32[] memory writes); - - // Record all the transaction logs - function recordLogs() external; - - // Gets all the recorded logs - function getRecordedLogs() external returns (Log[] memory); - - // Prepare an expected log with (bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData). - // Call this function, then emit an event, then call a function. Internally after the call, we check if - // logs were emitted in the expected order with the expected topics and data (as specified by the booleans). - // Second form also checks supplied address against emitting contract. - function expectEmit( - bool, - bool, - bool, - bool - ) external; - - function expectEmit( - bool, - bool, - bool, - bool, - address - ) external; - - // Mocks a call to an address, returning specified data. - // Calldata can either be strict or a partial match, e.g. if you only - // pass a Solidity selector to the expected calldata, then the entire Solidity - // function will be mocked. - function mockCall( - address, - bytes calldata, - bytes calldata - ) external; - - // Mocks a call to an address with a specific msg.value, returning specified data. - // Calldata match takes precedence over msg.value in case of ambiguity. - function mockCall( - address, - uint256, - bytes calldata, - bytes calldata - ) external; - - // Clears all mocked calls - function clearMockedCalls() external; - - // Expect a call to an address with the specified calldata. - // Calldata can either be strict or a partial match - function expectCall(address, bytes calldata) external; - - // Expect a call to an address with the specified msg.value and calldata - function expectCall( - address, - uint256, - bytes calldata - ) external; - - // Gets the code from an artifact file. Takes in the relative path to the json file - function getCode(string calldata) external returns (bytes memory); - - // Labels an address in call traces - function label(address, string calldata) external; - - // If the condition is false, discard this run's fuzz inputs and generate new ones - function assume(bool) external; - - // Set nonce for an account - function setNonce(address, uint64) external; - - // Get nonce for an account - function getNonce(address) external returns (uint64); - - // Set block.chainid (newChainId) - function chainId(uint256) external; - - // Using the address that calls the test contract, has the next call (at this call depth only) create a transaction that can later be signed and sent onchain - function broadcast() external; - - // Has the next call (at this call depth only) create a transaction with the address provided as the sender that can later be signed and sent onchain - function broadcast(address) external; - - // Using the address that calls the test contract, has the all subsequent calls (at this call depth only) create transactions that can later be signed and sent onchain - function startBroadcast() external; - - // Has the all subsequent calls (at this call depth only) create transactions that can later be signed and sent onchain - function startBroadcast(address) external; - - // Stops collecting onchain transactions - function stopBroadcast() external; - - // Reads the entire content of file to string. Path is relative to the project root. (path) => (data) - function readFile(string calldata) external returns (string memory); - - // Reads next line of file to string, (path) => (line) - function readLine(string calldata) external returns (string memory); - - // Writes data to file, creating a file if it does not exist, and entirely replacing its contents if it does. - // Path is relative to the project root. (path, data) => () - function writeFile(string calldata, string calldata) external; - - // Writes line to file, creating a file if it does not exist. - // Path is relative to the project root. (path, data) => () - function writeLine(string calldata, string calldata) external; - - // Closes file for reading, resetting the offset and allowing to read it from beginning with readLine. - // Path is relative to the project root. (path) => () - function closeFile(string calldata) external; - - // Removes file. This cheatcode will revert in the following situations, but is not limited to just these cases: - // - Path points to a directory. - // - The file doesn't exist. - // - The user lacks permissions to remove the file. - // Path is relative to the project root. (path) => () - function removeFile(string calldata) external; - - function toString(address) external returns (string memory); - - function toString(bytes calldata) external returns (string memory); - - function toString(bytes32) external returns (string memory); - - function toString(bool) external returns (string memory); - - function toString(uint256) external returns (string memory); - - function toString(int256) external returns (string memory); - - // Snapshot the current state of the evm. - // Returns the id of the snapshot that was created. - // To revert a snapshot use `revertTo` - function snapshot() external returns (uint256); - - // Revert the state of the evm to a previous snapshot - // Takes the snapshot id to revert to. - // This deletes the snapshot and all snapshots taken after the given snapshot id. - function revertTo(uint256) external returns (bool); - - // Creates a new fork with the given endpoint and block and returns the identifier of the fork - function createFork(string calldata, uint256) external returns (uint256); - - // Creates a new fork with the given endpoint and the _latest_ block and returns the identifier of the fork - function createFork(string calldata) external returns (uint256); - - // Creates _and_ also selects a new fork with the given endpoint and block and returns the identifier of the fork - function createSelectFork(string calldata, uint256) external returns (uint256); - - // Creates _and_ also selects a new fork with the given endpoint and the latest block and returns the identifier of the fork - function createSelectFork(string calldata) external returns (uint256); - - // Takes a fork identifier created by `createFork` and sets the corresponding forked state as active. - function selectFork(uint256) external; - - // Returns the currently active fork - // Reverts if no fork is currently active - function activeFork() external returns (uint256); - - // Marks that the account(s) should use persistent storage across fork swaps. - // Meaning, changes made to the state of this account will be kept when switching forks - function makePersistent(address) external; - - function makePersistent(address, address) external; - - function makePersistent( - address, - address, - address - ) external; - - function makePersistent(address[] calldata) external; - - // Revokes persistent status from the address, previously added via `makePersistent` - function revokePersistent(address) external; - - function revokePersistent(address[] calldata) external; - - // Returns true if the account is marked as persistent - function isPersistent(address) external returns (bool); - - // Updates the currently active fork to given block number - // This is similar to `roll` but for the currently active fork - function rollFork(uint256) external; - - // Updates the given fork to given block number - function rollFork(uint256 forkId, uint256 blockNumber) external; - - /// Returns the RPC url for the given alias - function rpcUrl(string calldata) external returns (string memory); - - /// Returns all rpc urls and their aliases `[alias, url][]` - function rpcUrls() external returns (string[2][] memory); - - function parseJson(string calldata, string calldata) external returns (bytes memory); - - function parseJson(string calldata) external returns (bytes memory); -} diff --git a/packages/cli/src/contracts/Deploy.sol b/packages/cli/src/contracts/Deploy.sol index 2537acff5e..1eeb933b91 100644 --- a/packages/cli/src/contracts/Deploy.sol +++ b/packages/cli/src/contracts/Deploy.sol @@ -2,26 +2,22 @@ pragma solidity >=0.8.0; // Foundry -import {DSTest} from "ds-test/test.sol"; -import {Vm} from "forge-std/Vm.sol"; +import {Script} from "forge-std/Script.sol"; import {console} from "forge-std/console.sol"; -import {Cheats} from "./Cheats.sol"; // Libraries import {LibDeploy, DeployResult} from "./LibDeploy.sol"; -contract Deploy is DSTest { - Cheats internal immutable vm = Cheats(HEVM_ADDRESS); - +contract Deploy is Script { function broadcastDeploy( address _deployer, address _world, bool _reuseComponents ) public returns (address world, uint256 initialBlockNumber) { - vm.startBroadcast(_deployer); + vmSafe.startBroadcast(_deployer); initialBlockNumber = block.number; DeployResult memory result = LibDeploy.deploy(_deployer, _world, _reuseComponents); - vm.stopBroadcast(); + vmSafe.stopBroadcast(); world = address(result.world); } } diff --git a/packages/cli/src/contracts/LibDeploy.ejs b/packages/cli/src/contracts/LibDeploy.ejs index 4b9886feab..5e7afc4dd5 100644 --- a/packages/cli/src/contracts/LibDeploy.ejs +++ b/packages/cli/src/contracts/LibDeploy.ejs @@ -4,7 +4,6 @@ pragma solidity >=0.8.0; // NOTE: This file is autogenerated via `mud codegen-libdeploy` from `deploy.json`. Do not edit manually. // Foundry -import { DSTest } from "ds-test/test.sol"; import { console } from "forge-std/console.sol"; // Solecs diff --git a/packages/noise/package.json b/packages/noise/package.json index 726ab06b79..d3308af233 100644 --- a/packages/noise/package.json +++ b/packages/noise/package.json @@ -43,7 +43,7 @@ "chai": "^4.3.6", "ds-test": "https://github.com/dapphub/ds-test.git#c9ce3f25bde29fc5eb9901842bf02850dfd2d084", "ethers": "^5.7.0", - "forge-std": "https://github.com/foundry-rs/forge-std.git#f36dab24d63d1c1945a05ed375ce341d3c1a49ed", + "forge-std": "https://github.com/foundry-rs/forge-std.git#b4f121555729b3afb3c5ffccb62ff4b6e2818fd3", "hardhat": "^2.10.2", "keccak-wasm": "^0.10.3", "mocha": "^10.0.0", diff --git a/packages/solecs/package.json b/packages/solecs/package.json index e941019272..4764fb656c 100644 --- a/packages/solecs/package.json +++ b/packages/solecs/package.json @@ -29,7 +29,7 @@ "@typechain/ethers-v5": "^9.0.0", "@types/mocha": "^9.1.1", "ds-test": "https://github.com/dapphub/ds-test.git#c9ce3f25bde29fc5eb9901842bf02850dfd2d084", - "forge-std": "https://github.com/foundry-rs/forge-std.git#f36dab24d63d1c1945a05ed375ce341d3c1a49ed", + "forge-std": "https://github.com/foundry-rs/forge-std.git#b4f121555729b3afb3c5ffccb62ff4b6e2818fd3", "hardhat": "^2.10.1", "memmove": "https://github.com/dk1a/memmove.git#ffd71cd77b1708574ef46a667b23ca3a5cc9fa27", "prettier": "^2.6.2", @@ -45,7 +45,7 @@ "@rari-capital/solmate": "https://github.com/Rari-Capital/solmate.git#b6ae78e6ff490f8fec7695c7b65d06e5614f1b65", "@solidstate/contracts": "^0.0.52", "ds-test": "https://github.com/dapphub/ds-test.git#c9ce3f25bde29fc5eb9901842bf02850dfd2d084", - "forge-std": "https://github.com/foundry-rs/forge-std.git#f36dab24d63d1c1945a05ed375ce341d3c1a49ed", + "forge-std": "https://github.com/foundry-rs/forge-std.git#b4f121555729b3afb3c5ffccb62ff4b6e2818fd3", "memmove": "https://github.com/dk1a/memmove.git#ffd71cd77b1708574ef46a667b23ca3a5cc9fa27" }, "gitHead": "218f56893d268b0c5157a3e4c603b859e287a343" diff --git a/packages/std-contracts/package.json b/packages/std-contracts/package.json index c33799807d..3589f6843d 100644 --- a/packages/std-contracts/package.json +++ b/packages/std-contracts/package.json @@ -28,7 +28,7 @@ "@rari-capital/solmate": "https://github.com/Rari-Capital/solmate.git#b6ae78e6ff490f8fec7695c7b65d06e5614f1b65", "@typechain/ethers-v5": "^9.0.0", "ds-test": "https://github.com/dapphub/ds-test.git#c9ce3f25bde29fc5eb9901842bf02850dfd2d084", - "forge-std": "https://github.com/foundry-rs/forge-std.git#f36dab24d63d1c1945a05ed375ce341d3c1a49ed", + "forge-std": "https://github.com/foundry-rs/forge-std.git#b4f121555729b3afb3c5ffccb62ff4b6e2818fd3", "hardhat": "^2.10.1", "prettier": "^2.6.2", "prettier-plugin-solidity": "^1.0.0-beta.19", diff --git a/yarn.lock b/yarn.lock index cbf2439125..d591a81d89 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7805,9 +7805,9 @@ forever-agent@~0.6.1: resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" integrity sha512-j0KLYPhm6zeac4lz3oJ3o65qvgQCcPubiyotZrXqEaG4hNagNYO8qdlUrX5vwqv9ohqeT/Z3j6+yW067yWWdUw== -"forge-std@https://github.com/foundry-rs/forge-std.git#f36dab24d63d1c1945a05ed375ce341d3c1a49ed": - version "0.1.0" - resolved "https://github.com/foundry-rs/forge-std.git#f36dab24d63d1c1945a05ed375ce341d3c1a49ed" +"forge-std@https://github.com/foundry-rs/forge-std.git#b4f121555729b3afb3c5ffccb62ff4b6e2818fd3": + version "1.2.0" + resolved "https://github.com/foundry-rs/forge-std.git#b4f121555729b3afb3c5ffccb62ff4b6e2818fd3" form-data@^3.0.0: version "3.0.1"