foundry icon indicating copy to clipboard operation
foundry copied to clipboard

Scripts no longer default to the single contract in a file

Open 0xdapper opened this issue 1 year ago • 7 comments

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

0xdapper avatar Feb 14 '24 06:02 0xdapper

@klkvr this sounds like a regression

can we add a test for this and fix?

mattsse avatar Feb 14 '24 13:02 mattsse

@0xdapper I actually can't reproduce this locally, could you please share a repro and/or a error message you are getting?

klkvr avatar Feb 14 '24 13:02 klkvr

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()"

0xdapper avatar Feb 14 '24 14:02 0xdapper

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?

klkvr avatar Feb 15 '24 12:02 klkvr

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.

0xdapper avatar Feb 16 '24 04:02 0xdapper

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?

klkvr avatar Feb 16 '24 12:02 klkvr

Working for some, not for others

0xdapper avatar Feb 17 '24 16:02 0xdapper

@0xdapper can you please check if this is still the case on latest nightly?

klkvr avatar Mar 14 '24 18:03 klkvr

ping @0xdapper, are you still experiencing issues around this?

zerosnacks avatar Jul 11 '24 10:07 zerosnacks

I think this is fixed now, thanks

0xdapper avatar Jul 12 '24 05:07 0xdapper