Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maintain transaction lifetime on transactions #2484

Merged
merged 2 commits into from
Apr 16, 2024
Merged

Conversation

mcintyre94
Copy link
Collaborator

@mcintyre94 mcintyre94 commented Apr 15, 2024

This PR updates the usages of NewTransaction to maintain the transaction lifetime. I should have realised we'd have to extend it!

  • The sign functions in the transactions package now take a T extends NewTransaction and maintain the type T. This means that if you input a transaction with a lifetime, the output transaction will have the same lifetime.

  • The signers now return NewTransaction & TransactionWithLifetime. I haven't calculated the diff here because they take a transaction message as input and call compileTransactionMessage, so their output isn't based on the transaction message input.

Copy link

changeset-bot bot commented Apr 15, 2024

⚠️ No Changeset found

Latest commit: e24a32b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@mcintyre94 mcintyre94 changed the title refactor transaction signing to maintain attached lifetime Maintain transaction lifetime on transactions Apr 15, 2024
@mcintyre94 mcintyre94 marked this pull request as ready for review April 15, 2024 11:39
packages/transactions/src/new-signatures.ts Outdated Show resolved Hide resolved
Comment on lines 27 to 64
export async function partiallySignTransactionMessageWithSigners<
TTransactionMessage extends CompilableTransactionMessageWithSigners = CompilableTransactionMessageWithSigners,
>(transactionMessage: TTransactionMessage, config: { abortSignal?: AbortSignal } = {}): Promise<NewTransaction> {
>(
transactionMessage: TTransactionMessage,
config: { abortSignal?: AbortSignal } = {},
): Promise<NewTransaction & TransactionWithLifetime> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we have a helper type like GetTransactionLifetimeFromTransactionMessage<TTransactionMessage>?

Then here we can return Promise<NewTransaction & GetTransactionLifetimeFromTransactionMessage<TTransactionMessage>> which means TypeScript doesn't loose that information?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I tried to do this (playground) but it doesn't seem to want to be that clever

I've added type overloads for the lifetime types instead to mirror what we do with compileTransactionMessage, and updated the typetests

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh weird. I thought that's what we were doing with TClusterUrl on RPC packages but there must be some subtle change there that makes TS happy. 🤷‍♂️

Base automatically changed from tx-lifetime to master April 15, 2024 14:11
Copy link
Contributor

🎉 This PR is included in version 1.91.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

Copy link
Contributor

github-actions bot commented May 2, 2024

Because there has been no activity on this PR for 14 days since it was merged, it has been automatically locked. Please open a new issue if it requires a follow up.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants