Implement new truffle call
command using @truffle/encoder and @truffle/decoder
#5647
Conversation
0ec573c
to
7c25656
Compare
d7d0063
to
468d8e2
Compare
- Rename `sendRequest` to `request` - Make it public - See no evil (re: extra `formatOptions` option)
... using @truffle/encoder and @truffle/decoder
Co-authored-by: David Murdoch <187813+davidmurdoch@users.noreply.github.com> Co-authored-by: cds-amal <cds.sudama@gmail.com>
e5e1b32
to
0151949
Compare
Oops, I also need to just straight-up update the tests, it's failing CI because I didn't... |
OK, I have substantially revised this and I think it should be OK now! I had to leave out a few tests due to the framework making them difficult. Also sorry for how slow the tests are. We can cut some if you like. Or if you know a better way to do it that would be quick to implement... |
Yeah, let's cut all the slow tests for now and open an issue about the lack of automated testing as a result. Or maybe we keep 1-2 basic end-to-end tests just for minimal safety |
|
||
const fromAddress = | ||
options.from ?? config.networks[config.network]?.from ?? config.from; | ||
if (!web3Utils.isAddress(fromAddress)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we skip the need to specify a from
field?
At the very least this error should indicate which address is the problem, since this error now suggests that it might be the contract address that's wrong
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I'm thinking... maybe we can just use 0x0
as the from
address
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good apart from the requirement for from
. Let's use the zero-address for from
instead of erroring.
OK, made those changes! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks!
PR description
This PR adds the
truffle call
command leveraging Truffle's encoding and decoding functionality (including overload resolution). Prior work credit: @gnidan (#5330).Testing instructions
To test this new feature, write a smart contract inside a truffle project with a function that returns some value or you can clone this Test Project with a simple storage contract.
Run
truffle develop
inside a truffle project.In the REPL, run
migrate
to deploy the contract.In the REPL, run
call <contract_name|contract_address> <function_name>
.In the REPL, run
call <contract_name|contract_address> <function_name> <arg>
.In the REPL, run
call <contract_name|contract_address> <function_name>
that returns multiple values of different types.In the REPL, run
call <contract_name|contract_address> <function_signature> <arg>
. NOTE: ABI-style signatures doesn't allow spaces.In the REPL, run
call <contract_name|contract_address> <function_name_that_reverts>
.In the REPL, run
call <contract_name|contract_address> <function_name_that_panics>
.NOTE: This can also be tested in a truffle project outside of truffle REPL with the following steps -
Run a ganache instance in a separate terminal.
Run
truffle migrate
.Run
truffle call <contract_name|contract_address> <function_name>
.Run
truffle call <contract_name|contract_address> <function_name> <arg>
.In the REPL, run
truffle call <contract_name|contract_address> <function_name>
that returns multiple values of different types.Run
call <contract_name|contract_address> <function_signature> <arg>
. NOTE: Function signature should be in""
and without spaces.Run
truffle call <contract_name|contract_address> <function_name_that_reverts>
.Run
truffle call <contract_name|contract_address> <function_name_that_panics>
.Breaking changes and new features
breaking-change
andnew-feature
labels for the appropriate packages.