foundry
foundry copied to clipboard
Scripts no longer default to the single contract in a file
Component
Forge
Have you ensured that all of these are up to date?
- [X] Foundry
- [X] Foundryup
What version of Foundry are you on?
forge 0.2.0 (fd87629 2024-02-14T00:16:32.629119532Z)
What command(s) is the bug in?
forge script ./script/SomeScript.s.sol
Operating System
Linux
Describe the bug
Initially if a file had a single contract defined, it'd default to that and you wouldn't require adding target contract name to the command. Now it fails, need to add it forge script ./script/SomeScript.s.sol:SomeScript
instead of just forge script ./script/SomeScript.s.sol
@klkvr this sounds like a regression
can we add a test for this and fix?
@0xdapper I actually can't reproduce this locally, could you please share a repro and/or a error message you are getting?
Error is Could not find target contract: script/onetime/redeployHelper.sol
. The repo is not open source but here's another small script that has same error.
import { AggregateVaultHelper } from "src/peripheral/AggregateVaultHelper.sol";
import { Script } from "forge-std/Script.sol";
import { AggregateVault, Peripheral } from "src/vaults/AggregateVault.sol";
import { Auth } from "src/Auth.sol";
import { DEV_MULTISIG } from "src/constants.sol";
contract redeployHelper is Script {
AggregateVault aggregateVault = AggregateVault(payable(0x0Ca62954b46AfEe430D645dA493C6C783448C4eD));
Auth auth = Auth(0x564D24A04CE86a0873381B560DcC48D603F20f52);
AggregateVaultHelper oldHelper = AggregateVaultHelper(0x2e9A5F248bAFc07F21A6b0aC82d4caC19d196Adf);
function run() external {
vm.startBroadcast();
AggregateVaultHelper helper = new AggregateVaultHelper(auth);
}
function link() external {
address helper = 0x7051fe6bF315A0C8d7e8a21186f645c5f4f3138A;
vm.startBroadcast(DEV_MULTISIG);
aggregateVault.updateHandlerContract(oldHelper, false);
aggregateVault.updateHandlerContract(AggregateVaultHelper(helper), true);
aggregateVault.setPeripheral(Peripheral.AggregateVaultHelper, address(helper));
}
}
Command ran: forge script ./script/onetime/redeployHelper.sol --rpc-url arbitrum --legacy --sig "link()"
hey @0xdapper can you confirm that this is still the case on the latest nightly? (forge 0.2.0 (3cdee82 2024-02-15T00:19:38.655803000Z)
)
If so, could you please check if out/redeployHelper
contains more than one artifact?
Nope, it doesn't work https://github.com/foundry-rs/foundry/pull/7124#issuecomment-1945268037
Yes, there is only one json file in out/redeployHelper.sol
directory.
I still can't reproduce it with your repro. Can you confirm if this issue occurs for any script files or only for the one you've mentioned? And could you try removing cache via forge clean
?
Working for some, not for others
@0xdapper can you please check if this is still the case on latest nightly?
ping @0xdapper, are you still experiencing issues around this?
I think this is fixed now, thanks