Skip to content

Add a function to help TransactionModifyingSigner update lifetimeConstraint #1466

@mcintyre94

Description

@mcintyre94

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions