Skip to content

Forc call help for callable functions #6935

Open
@zees-dev

Description

@zees-dev

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.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestforcforc-callEverything related to the `forc-call` plugin in `forc-client` packageteam:toolingTooling Team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions