Our API for TransactionModifyingSigner requires a lifetime to be returned:
modifyAndSignTransactions(
transactions: readonly (Transaction | (Transaction & TransactionWithLifetime))[],
config?: TransactionModifyingSignerConfig,
): Promise<readonly (Transaction & TransactionWithinSizeLimit & TransactionWithLifetime)[]>;
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:
And this is also used in the PR to add non-react WalletAccount -> Signer functions: #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.
Our API for
TransactionModifyingSignerrequires a lifetime to be returned: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
useWalletAccountTransactionSignerhook:kit/packages/react/src/useWalletAccountTransactionSigner.ts
Line 97 in 874a02f
And this is also used in the PR to add non-react WalletAccount -> Signer functions: #1368
This code is useful for anybody writing a similar
TransactionModifyingSigner. We could extract it to a helper in thetransactionspackage to make it easier for others to write similar signers.