make-software/casper-net-sdk-clients

SetContractPackageHash() works only to call entry points, not to query data from contract

Opened this issue · 3 comments

What happened?
A call to SetContractPackageHash() stores the package hash in the client so that an entry point can be called via package hash instead of contract hash. However, it not permits to read data from the contract. For that, SetContractHash() must be used.

What did you expect to happen?
SetContractPackageHash() may fetch the contract hash and use it to query the named keys.

Are you willing to submit a pull request to fix this bug?

Please fix it asap. It will help a lot. Thank you.

SetContractPackageHash() should work as follows:

  1. At the input of the function we provide Contract Package Hash (as string or GlobalStateKey).
  2. The function extracts and initializes the latest (highest), active version of the contract (contract hash) from the Contract Package Hash from function input, and allows you to operate on the initialized cep47/cep78 data.

Please fix this function for cep47Client and cep78Client.

Thanks @mystraio for your notes. Just a comment about (2). SetContractPackage() accepts a second argument with the version number of the contract. If specified, this version must be used. If omitted, or null, then latest version of the contract must be used.