Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add cheatcodes introduced in foundry-rs/foundry#9107. ```solidity // Returns the most recent broadcast for the given contract on `chainId` matching `txType`. function getBroadcast(string memory contractName, uint64 chainId, BroadcastTxType txType) external returns (BroadcastTxSummary memory); // Returns all broadcasts for the given contract on `chainId` with the specified `txType`. // Sorted such that the most recent broadcast is the first element, and the oldest is the last. i.e descending order of BroadcastTxSummary.blockNumber. function getBroadcasts(string memory contractName, uint64 chainId, BroadcastTxType txType) external returns (BroadcastTxSummary[] memory); // Returns all broadcasts for the given contract on `chainId`. // Sorted such that the most recent broadcast is the first element, and the oldest is the last. i.e descending order of BroadcastTxSummary.blockNumber. function getBroadcasts(string memory contractName, uint64 chainId) external returns (BroadcastTxSummary[] memory); // Returns the most recent deployment for the current `chainId`. function getDeployment(string memory contractName) external returns (address deployedAddress); // Returns the most recent deployment for the given contract on `chainId` function getDeployment(string memory contractName, uint64 chainId) external returns (address deployedAddress); // Returns all deployments for the given contract on `chainId` // Sorted in descending order of deployment time i.e descending order of BroadcastTxSummary.blockNumber. // The most recent deployment is the first element, and the oldest is the last. function getDeployments(string memory contractName, uint64 chainId) external returns (address[] memory deployedAddresses); ``` These cheatcodes enable the following behaviour: - Deploy a contract `forge script CounterDeployScript --broadcast` - Access the broadcast artifacts `forge script BroadcastCollector` ```solidity contract BroadcastCollector is Script { function run() public { // Get the most recent counter deployment Vm.BroadcastTxSummary memory broadcast = Vm(address(vm)).getBroadcast( "Counter", 31337, Vm.BroadcastTxType.Create ); console.logBytes32(broadcast.txHash); console.logAddress(broadcast.contractAddress); // New contract address } } ```
- Loading branch information