-
Notifications
You must be signed in to change notification settings - Fork 10
Multi-Transaction Signing for SignTransaction #551
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
Open
mraveux
wants to merge
5
commits into
master
Choose a base branch
from
matheo/multi-tx-sign
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
932abef
Client types: support multi-transaction SignTransactionRequest
mraveux 08afe09
SignTransaction: handle multi-transaction signing and staking
mraveux 01477a9
Add translations keys for multi-transaction signing UI
mraveux e2c2dbc
Update SignTransaction demo for multi-tx testing
mraveux b1005a5
Clean up multi-tx signing: remove dead code, fix types and i18n
mraveux File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,3 +9,4 @@ deployment-keyguard-next | |
| dist | ||
| .ts-out | ||
| src/translations/index.js | ||
| CLAUDE.md | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,6 +55,9 @@ export type TransactionInfo = { | |
| flags?: number, | ||
| }; | ||
|
|
||
| // TransactionInfo without keyPath (keyPath is at request level for multi-transaction support) | ||
| export type TransactionData = Omit<TransactionInfo, 'keyPath'>; | ||
|
|
||
| export enum BitcoinTransactionInputType { | ||
| STANDARD = 'standard', | ||
| HTLC_REDEEM = 'htlc-redeem', | ||
|
|
@@ -167,10 +170,17 @@ export type ExportResult = { | |
|
|
||
| type SignTransactionRequestCommon = SimpleRequest & TransactionInfo; | ||
|
|
||
| export type SignTransactionRequestStandard = SignTransactionRequestCommon & { | ||
| // Standard layout supports both single and multiple transactions | ||
| export type SignTransactionRequestStandard = SimpleRequest & { | ||
| keyPath: string, | ||
| layout?: 'standard', | ||
| recipientLabel?: string, | ||
| }; | ||
| recipientLabel?: string, // Only used for single-tx display | ||
| } & ( | ||
| // Option A: Single transaction (backward compatible - fields directly on request) | ||
| TransactionData | | ||
| // Option B: Multiple transactions | ||
| { transactions: TransactionData[] | Uint8Array[] } | ||
| ); | ||
|
|
||
| export type SignTransactionRequestCheckout = SignTransactionRequestCommon & { | ||
| layout: 'checkout', | ||
|
|
@@ -616,6 +626,8 @@ export type ListLegacyResult = LegacyKeyInfoObject[]; | |
| export type SignTransactionResult = SignatureResult & { | ||
| serializedTx: Uint8Array, | ||
| }; | ||
| // Array result type for multi-transaction signing | ||
| export type SignTransactionResults = SignTransactionResult[]; | ||
|
Comment on lines
+629
to
+630
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure whether it's worth introducing a type alias for this. Imo, just using |
||
| export type SignStakingResult = SignatureResult & { | ||
| transaction: Uint8Array, | ||
| }; | ||
|
|
@@ -653,6 +665,7 @@ export type RedirectResult | |
| | SignatureResult | ||
| | ConnectResult | ||
| | SignTransactionResult | ||
| | SignTransactionResults | ||
| | SignStakingResult[] | ||
| | SignedBitcoinTransaction | ||
| | SignedPolygonTransaction | ||
|
|
@@ -667,7 +680,7 @@ export type Result = RedirectResult | IFrameResult; | |
|
|
||
| export type ResultType<T extends RedirectRequest> = | ||
| T extends Is<T, SignMessageRequest> ? SignatureResult : | ||
| T extends Is<T, SignTransactionRequest> ? SignTransactionResult : | ||
| T extends Is<T, SignTransactionRequest> ? SignTransactionResult | SignTransactionResults : | ||
| T extends Is<T, SignMultisigTransactionRequest> ? SignatureResult : | ||
| T extends Is<T, SignStakingRequest> ? SignStakingResult[] : | ||
| T extends Is<T, ConnectRequest> ? ConnectResult : | ||
|
|
@@ -684,7 +697,7 @@ export type ResultType<T extends RedirectRequest> = | |
|
|
||
| export type ResultByCommand<T extends KeyguardCommand> = | ||
| T extends KeyguardCommand.SIGN_MESSAGE ? SignatureResult : | ||
| T extends KeyguardCommand.SIGN_TRANSACTION ? SignTransactionResult : | ||
| T extends KeyguardCommand.SIGN_TRANSACTION ? SignTransactionResult | SignTransactionResults : | ||
| T extends KeyguardCommand.SIGN_MULTISIG_TRANSACTION ? SignatureResult : | ||
| T extends KeyguardCommand.SIGN_STAKING ? SignStakingResult[] : | ||
| T extends KeyguardCommand.CONNECT_ACCOUNT ? ConnectResult : | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name SignTransactionRequestCommon is not adequate anymore if it's not used in SignTransactionRequestStandard anymore, as it's then in fact not common to all SignTransactionRequests.
This can be circumvented by actually using the type here, as is still proves useful:
Or to go further, and explicitly allow
senderLabelandrecipientLabelonly for a single transaction: