Add a function to help `TransactionModifyingSigner` update `lifetimeConstraint`
- Dominant language
- TypeScript
- Stars
- 695
- Forks
- 210
- Avg merge
- 21h 33m
- Merged PRs (30d)
- 90
Description
Our API for `TransactionModifyingSigner` requires a lifetime to be returned:
```ts
modifyAndSignTransactions(
transactions: readonly (Transaction | (Transaction & TransactionWithLifetime))[],
config?: TransactionModifyingSignerConfig,
): Promise;
```
As such a signer can modify the transaction, this lifetime may be different from the input one. Identifying the lifetime constraint requires decompiling the transaction and inspecting its first instruction (whether it's advance nonce determines if the token is a blockhash or nonce), so should be avoided if possible.
We have code to help with this in the react `useWalletAccountTransactionSigner` hook: https://github.com/anza-xyz/kit/blob/874a02f2aa5074c3309a66725522ead9e2fec166/packages/react/src/useWalletAccountTransactionSigner.ts#L97
And this is also used in the PR to add non-react WalletAccount -> Signer functions: https://github.com/anza-xyz/kit/pull/1368
This code is useful for anybody writing a similar `TransactionModifyingSigner`. We could extract it to a helper in the `transactions` package to make it easier for others to write similar signers.
Contributor guide
Assessment
This issue has not been assessed yet.