anza-xyz / anza-xyz/kit

Add a function to help `TransactionModifyingSigner` update `lifetimeConstraint`

未關閉
#1,466 2 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
TypeScript
星號
695
分支
210
平均合併
21 小時 33 分鐘
30 天內合併 PR
90

描述

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.

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。