From bcb9b3c3f2c3fe4b98be853c14c9a98816dde973 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Mon, 8 Apr 2024 23:14:02 +0400 Subject: [PATCH] update getCode doc --- src/cheatcodes/get-code.md | 11 +++++++++++ src/cheatcodes/get-deployed-code.md | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/cheatcodes/get-code.md b/src/cheatcodes/get-code.md index f857bb7cb..3820fb268 100644 --- a/src/cheatcodes/get-code.md +++ b/src/cheatcodes/get-code.md @@ -49,6 +49,17 @@ assembly { vm.etch(targetAddr, deployed.code); ``` + +### Supported formats + +You can fetch artifacts by either contract path or contract name. Fetching artifacts for a specific version is also supported. If not provided, cheatcode will default to the version of a test being executed or the only version artifact was compiled with. +```solidity +vm.getCode("MyContract.sol:MyContract"); +vm.getCode("MyContract"); +vm.getCode("MyContract.sol:0.8.18"); +vm.getCode("MyContract:0.8.18"); +``` + ### SEE ALSO [`getDeployedCode`](./get-deployed-code.md) diff --git a/src/cheatcodes/get-deployed-code.md b/src/cheatcodes/get-deployed-code.md index 33e4ec72a..b1c122335 100644 --- a/src/cheatcodes/get-deployed-code.md +++ b/src/cheatcodes/get-deployed-code.md @@ -48,6 +48,17 @@ vm.etch(overrideAddress, code); assertEq(overrideAddress.code, code); ``` +### Supported formats + +You can fetch artifacts by either contract path or contract name. Fetching artifacts for a specific version is also supported. If not provided, cheatcode will default to the version of a test being executed or the only version artifact was compiled with. +```solidity +vm.getDeployedCode("MyContract.sol:MyContract"); +vm.getDeployedCode("MyContract"); +vm.getDeployedCode("MyContract.sol:0.8.18"); +vm.getDeployedCode("MyContract:0.8.18"); +``` + + ### SEE ALSO Forge Standard Library