Skip to content

Conversation

@chadoh
Copy link
Contributor

@chadoh chadoh commented Nov 11, 2025

What

Rather than hard-coding a subset of AssembledTransactionOptions, this imports the type and uses it.

Why

Avoids needing to do goofy things like this in the frontend

const tx = await game.guess(
  { a_number: BigInt(theGuess), guesser: address },
  // @ts-expect-error js-stellar-sdk has bad typings; publicKey is, in fact, allowed
  { publicKey: address },
);

Also ensures that these generated methods will always be up-to-date with AssembledTransactionOptions as it evolves.

Known limitations

TypeScript typeahead in this situation is garbage! You just see AssembledTransactionOptions instead of actually-useful expanded types. This was the reason we originally hard-coded the options, but I think the trade-off is worth it. Also, maybe a future version of TypeScript won't be so stupid?

Captura de pantalla 2025-11-11 a la(s) 11 12 57

Rather than hard-coding a subset of AssembledTransactionOptions, this
imports the type and uses it.
@github-project-automation github-project-automation bot moved this to Backlog (Not Ready) in DevX Nov 11, 2025
Copy link
Member

@fnando fnando left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any documentation that needs to be updated with this on stellar-docs? If the answer is yes, can we prepare those pull requests and leave them in draft mode until we make a CLI release?

@chadoh
Copy link
Contributor Author

chadoh commented Nov 17, 2025

@fnando the biggest effect this will have on docs and consuming projects like Scaffold Stellar is that we can remove a @ts-expect-error directive from examples. I searched the docs and ts-expect-error does not appear. We are happy to update Scaffold Stellar appropriately once this is released.

@fnando fnando merged commit 9bcec7f into stellar:main Nov 17, 2025
31 checks passed
@github-project-automation github-project-automation bot moved this from Backlog (Not Ready) to Done in DevX Nov 17, 2025
chadoh added a commit to theahaco/js-stellar-sdk that referenced this pull request Nov 17, 2025
…ient

With upcoming changes to TS Bindings generation
(stellar/stellar-cli#2283), many more people
will be using `AssembledTransactionOptions`. This currently has the
peculiarity of requiring `contractId`, `rpcUrl`, and `networkPassphrase`
every time you construct an AssembledTransaction. Even if doing so from
a ContractClient, which has already been instantiated with these values!

```
Type `{ publickey: string; }' is missing the following properties from type
'ClientOptions': contractId, networkPassphrase, rpcUrl
```

The root cause, in my opinion, is that `AssembledTransactionOptions`
_flattens in_ `ClientOptions`, rather than accepting a `client`
by reference.

```diff
 export type AssembledTransactionOptions<T = string> = MethodOptions &
-  ClientOptions & {
+  {
+    client: Client;
```

This updates `AssembledTransaction` to instead accept a `client` by
reference, as shown above.

Note that this represents a breaking change! But... only if you were
constructing `AssembledTransaction`s without a `ContractClient` (or TS
Bindings). Which is to say, only if you were doing things _the hard
way._ The _non-standard_ way.

If you use generated TS Bindings, or if you construct a ContractClient
and call its methods directly to create AssembledTransactions,
everything continues to work as it always has. And this code has the
benefit of expressing more clearly what we wanted all along!

If we want to make this backwards-compatible (for the... two? ten?
people out there doing things the hard way), maybe we could do
something like this:

```diff
 export type AssembledTransactionOptions<T = string> = MethodOptions &
-  ClientOptions & {
+  Partial<ClientOptions> & {
+    client: Client;
```

And then, in the AssembledTransaction constructor, we can default each
of these values to the one from `options.client.options`, like the
current change does with `publicKey`.
@chadoh chadoh deleted the fix/client-tx-types branch November 18, 2025 18:57
chadoh added a commit to theahaco/stellar-cli that referenced this pull request Nov 26, 2025
This is an update to stellar#2283, which changed hard-coded `options` to
`AssembledTransactionOptions`. This was not quite correct, it should be
a `MethodOptions`.

This works together with
stellar/js-stellar-sdk#1293 to finally remove
the need for `@ts-expect-error` lines in our canonical write-method
invocation examples.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants