js-stellar-sdk icon indicating copy to clipboard operation
js-stellar-sdk copied to clipboard

you CAN pass `publicKey` to Contract Client methods

Open chadoh opened this issue 1 year ago • 5 comments

Describe the bug

If I pass publicKey to a specific method call on a contract client, it tells me that's not supported:

image

But it actually is passed through!

What version are you on? 12.3.0

To Reproduce Steps to reproduce the behavior:

  1. Instantiate a contract client, omitting publicKey
  2. For a write method, set publicKey to your sender's address. You may need to add a // @ts-ignore or // @ts-expect-error before the line!
  3. See that the publicKey you set on the method call is set as the invoker on the call.

Expected behavior We need to update the types to let people know they can do this! It's super handy, allowing you to have static contract clients in the project (as set up in our frontend templates), but still override transaction senders for change methods (which are actually fairly rare in apps, in my experience)

Additional context We will need to update the types generated in the TS bindings to match, once this is done.

chadoh avatar Sep 20 '24 20:09 chadoh

Hello @chadoh i will love to take this up when OD hack begins tomorrow

ShantelPeters avatar Sep 25 '24 19:09 ShantelPeters

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

software engineering background and smart contract developer.

How I plan on tackling this issue

I would try updating the typescript bindings to accurately document and support the passing of publickey in contract client methods.

Botdavid avatar Sep 26 '24 10:09 Botdavid

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

i am a blockchain developer and i will like to contribute to this ecosystem.

How I plan on tackling this issue

To approach this issue, i will firstly verify the bug by the following:

  1. Reproduce the Bug
  2. Update Type Definitions
  3. Test Changes
  4. Submit Changes

ShantelPeters avatar Sep 26 '24 12:09 ShantelPeters

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

@chadoh I am a Frontend and a Blockchain Dev

How I plan on tackling this issue

This is the steps i will take to solve the existing bug:

  • I will reproduce the bug to confirm the issue.
  • Move to Identify the source of type mismatch, then update these types to include publicKey as a valid parameter.
  • I will modify the type definitions so that publicKey is recognized as a valid parameter in contract method calls. I’ll ensure the generator can properly handle this behavior.
  • Finally, after updating the types, I’ll test both the static type-checking and the runtime behavior to ensure everything works as expected without having to manually suppress TypeScript errors.

ooochoche avatar Sep 27 '24 03:09 ooochoche

@chadoh I'm creating a PR soon, thank you

ooochoche avatar Oct 02 '24 05:10 ooochoche

Fixed in #1293

Ryang-21 avatar Dec 09 '25 22:12 Ryang-21