In this PR we improve the code generator to support more functions from the contracts.
Support bool and uint*
For each of the params, we need to find out which function should be used
to parse a string argument to a type expected by the contract's Go
binding.
If any of the method's (function's) input params type is not associated with
any parsing function the function is not callable as a command (see
default path in the switch statement). This caused a lot of
functions not to be exposed in the generated Ethereum CLI commands.
In this PR we want to support more types, to have more functions
exposed in the CLI.
We add support of:
bool
uint* with bit size greater or equal to 64
To be able to use strconv.ParseUint we had to introduce the parsingFn as a format for printf function, where %s will be replaced with an argument.
Structs as functions's input params
Some of the contract's methods accept tuples (structures) as arguments.
We want to support such functions and generate ethereum CLI commands for
them.
When a param is a tuple we expect that it's string value in the CLI
execution be provided as a JSON. In the generated code we will parse the
JSON to a Go type defined for the structure.
We add _json suffix to such parameters to be printed in the CLI help
and add some context what is expected to be provided when calling it.
In this PR we improve the code generator to support more functions from the contracts.
Support
bool
anduint*
For each of the params, we need to find out which function should be used to parse a string argument to a type expected by the contract's Go binding.
If any of the method's (function's) input params type is not associated with any parsing function the function is not callable as a command (see
default
path in theswitch
statement). This caused a lot of functions not to be exposed in the generated Ethereum CLI commands.In this PR we want to support more types, to have more functions exposed in the CLI.
We add support of:
bool
uint*
with bit size greater or equal to 64To be able to use
strconv.ParseUint
we had to introduce theparsingFn
as a format forprintf
function, where%s
will be replaced with an argument.Structs as functions's input params
Some of the contract's methods accept tuples (structures) as arguments. We want to support such functions and generate ethereum CLI commands for them.
When a param is a tuple we expect that it's string value in the CLI execution be provided as a JSON. In the generated code we will parse the JSON to a Go type defined for the structure.
We add
_json
suffix to such parameters to be printed in the CLI help and add some context what is expected to be provided when calling it.See the generated code in https://github.com/keep-network/keep-core/pull/3253