TypeChain icon indicating copy to clipboard operation
TypeChain copied to clipboard

call() not being generated on view fns

Open wbt opened this issue 3 years ago • 2 comments

In the description of @truffle/contract under "Calling getters" the documentation makes clear you can do something like

instance.getValue.call().then(function(val) {
  // val represents the `value` storage object in the solidity contract
  // since the contract returns that value.
});

It notes that .call() is optional, but I believe making this explicit is often a good idea. Unfortunately, with the types generated by this library, the .call() is not a valid syntax, because invoking the generic .call() on the CallableFunction being assumed here requires passing a this argument as a first parameter, and .call() doesn't have that.

I would propose adding a call() similar to what is found on non-view functions.

wbt avatar May 02 '22 21:05 wbt

Hi guys, as correctly described by @wbt according with Truffle doc:

truffle-getter

Target:

With Truffle For getter function that aren't "view" or "pure" add an optional method .call() to chain to getter function.

I will report further relevant information about "Truffle" and the "call ()" method in this Thread before approaching the code change and make PR

StefanoGagliardi avatar May 21 '22 22:05 StefanoGagliardi

Thanks for your inquiry @StefanoGagliardi! Were you able to make any progress on this?

wbt avatar Aug 31 '22 02:08 wbt