hashgraph / hedera-sdk-js

Hedera™ Hashgraph SDK for JavaScript/TypeScript
https://docs.hedera.com/guides/docs/sdks
Apache License 2.0
277 stars 146 forks source link

ContractCallQuery() inconsistently requires using .setQueryPayment() when function returns a string #1105

Closed ed-marquez closed 2 years ago

ed-marquez commented 2 years ago

Description

Using v2.13.1 of the JS SDK. The zip attached includes the bytecode, the sol, and the js files needed to reproduce the issue.

Lines 107 and 117 show that .setQueryPayment() has to be used in the ContractCallQuery() module, even if the query payment is set to the default max payment amount (which should have worked in the first place without specifying a query payment amount). Note that setting a query payment is not required for other types like numbers and addresses.

For clarity, the issue I'm reporting is that setting the query payment is only required for return values of type strings 1 HBAR is the default max payment amount, which means that the ContractCallQuery() should've worked without having to specify the query payment. I looks like the SDK is requiring specification of any amount (as long as it's greater that the actual payment needed)

Steps to reproduce

  1. open the zip attached
  2. run 5_1_HIP218_FungibleTok.js with and without commenting lines 107 and 117,
  3. observe the error or INSUFFICIENT_TX_PAYMENT

Additional context

5_1_HIP218_FungibleTok_sol_ERC20Contract.zip

Hedera network

testnet

Version

v.0.25

Operating system

Windows

janaakhterov commented 2 years ago

I was slightly aware of this issue (I thought it applied to ContractCallQuery as a whole rather than only when it returns certain responses), but it isn't an SDK issue. The reason I say this is because we query the cost of the query and use the resulting cost as the payment for the actual query if it's less than maxQueryPayment otherwise we use maxQueryPayment. The fact you're getting INSUFFICIENT_TX_PAYMENT despite us using the result of the CostQuery means the cost returned to us is incorrect when it should be correct as it is for all the other queries. I think this may be a bug within https://github.com/hashgraph/hedera-services

ed-marquez commented 2 years ago

Thanks for the response. I opened this issue in the hedera services repo: https://github.com/hashgraph/hedera-services/issues/3288

janaakhterov commented 2 years ago

Closing the issue here. If we end up determining we need to do extra work in the SDK we can reopen.