Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(forge): script should not default to run() if contract has only one function with another signature #5282

Closed
klkvr opened this issue Jul 3, 2023 · 2 comments
Labels
T-feature Type: feature

Comments

@klkvr
Copy link
Member

klkvr commented Jul 3, 2023

Component

Forge

Describe the feature you would like

Let's take following script as an example:

contract MintTokens is Script {
    function run(address token, uint256 amountToMint) {
        ...
    }
}

Right now, to run it I have to run following command:
forge script MintTokens <token_address> <amount_to_mint> --sig 'run(address,uint256)'

If I run just forge script MintTokens <token_address> <amount_to_mint> it fails with error Function run() is not implemented in your script.

It would be handy if in case when script contract has only one function, forge defaulted to it and not to run()

Additional context

No response

@klkvr klkvr added the T-feature Type: feature label Jul 3, 2023
@klkvr klkvr changed the title forge script should look for another function to execute in script contract if run() is not present feat(forge): forge script should not default to run() if contract has only one function with another signature Jul 3, 2023
@klkvr klkvr changed the title feat(forge): forge script should not default to run() if contract has only one function with another signature feat(forge): script should not default to run() if contract has only one function with another signature Jul 3, 2023
@Evalir
Copy link
Member

Evalir commented Jul 3, 2023

I don't think we'd wanna do this—it's good for consistency and determinism's sake to always default to a certain function and let the user explicitly override this. This would be a very minimal UX gain that could introduce footguns.

Closing for lack of appetite for now.

@Evalir Evalir closed this as completed Jul 3, 2023
@mds1
Copy link
Collaborator

mds1 commented Jul 3, 2023

+1 to @Evalir, this would introduce a footgun where the behavior of a forge script invocation is dependent on the code itself, so adding a second method called run at a later date changes behavior, which seems dangerous

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-feature Type: feature
Projects
No open projects
Archived in project
Development

No branches or pull requests

3 participants