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

Forc call help for callable functions #6935

Open
zees-dev opened this issue Feb 17, 2025 · 0 comments
Open

Forc call help for callable functions #6935

zees-dev opened this issue Feb 17, 2025 · 0 comments
Labels
enhancement New feature or request forc forc-call Everything related to the `forc-call` plugin in `forc-client` package team:tooling Tooling Team

Comments

@zees-dev
Copy link
Contributor

zees-dev commented Feb 17, 2025

Description

Since the ABI must be provided for forc call; it would be great if forc call --help could print out all the callable functions of the contract.
This would make it much easier for the user to know what functions are available on the callable contract.
^ All this data is available in the ABI; running the help would also need to parse/process the ABI (if provided).

Additional Improvements

It would be even better if we can provide an example of how to call the function - with each listed function.
For this, we'd need to parse the input params from the ABI - for the respective function; and construct a a string-parsable input for the function (assuming function accepts args).

Example

Running forc call --abi <..> <CONTRACT-ID> --help should parse the ABI; read the functions, and give examples on how to call them; below the current help output.

These should be something which can simply be copy-pasted by the user themselves for execution.
E.g.

> forc call --abi ./out/debug/counter-contract-abi.json 0xe18de7c7c8c61a1c706dccb3533caa00ba5c11b5230da4428582abf1b6831b4d --help
# current help output omitted..

Contract Functions:

add(u32,u32)
> forc call --abi ./out/debug/counter-contract-abi.json 0xe18de7c7c8c61a1c706dccb3533caa00ba5c11b5230da4428582abf1b6831b4d add 1 2

sub(u32,u32)
> forc call --abi ./out/debug/counter-contract-abi.json 0xe18de7c7c8c61a1c706dccb3533caa00ba5c11b5230da4428582abf1b6831b4d sub 1 2

Doesn't have to be perfect; i can imagine some complexity with complex structs/enums/generics - but something along these lines is what's expected.

@zees-dev zees-dev added enhancement New feature or request forc forc-call Everything related to the `forc-call` plugin in `forc-client` package team:tooling Tooling Team labels Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request forc forc-call Everything related to the `forc-call` plugin in `forc-client` package team:tooling Tooling Team
Projects
None yet
Development

No branches or pull requests

1 participant