Fix WalletConnect solana_signAllTransactions support#1827
Fix WalletConnect solana_signAllTransactions support#1827
Conversation
Update core submodule and handle new SignAllTransactions action in iOS.
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a reported issue with WalletConnect's Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new signAllTransactions case within the WalletConnectorService to handle the signing of multiple transactions, and updates a core subproject dependency. A review comment suggests improving the performance of the signAllTransactions method by processing transactions concurrently using TaskGroup instead of sequentially.
| var signedTransactions: [String] = [] | ||
| for data in transactions { | ||
| let simulation = try await simulateSendTransaction(chain: chain, transactionType: type, data: data) | ||
| let transaction = try walletConnect.decodeSendTransaction(transactionType: type, data: data) | ||
| let signed = try await signer.signTransaction(sessionId: sessionId, chain: chain.map(), transaction: transaction.map(), simulation: simulation) | ||
| signedTransactions.append(signed) | ||
| } |
There was a problem hiding this comment.
The current implementation processes transactions sequentially within a for loop. Since each transaction's signing process is an independent asynchronous operation, they can be executed concurrently to improve performance.
Using a TaskGroup will allow these operations to run in parallel, which can significantly reduce the total execution time when signing multiple transactions. The suggested change preserves the order of the signed transactions.
| var signedTransactions: [String] = [] | |
| for data in transactions { | |
| let simulation = try await simulateSendTransaction(chain: chain, transactionType: type, data: data) | |
| let transaction = try walletConnect.decodeSendTransaction(transactionType: type, data: data) | |
| let signed = try await signer.signTransaction(sessionId: sessionId, chain: chain.map(), transaction: transaction.map(), simulation: simulation) | |
| signedTransactions.append(signed) | |
| } | |
| let signedTransactions = try await withThrowingTaskGroup(of: (Int, String).self) { group -> [String] in | |
| for (index, data) in transactions.enumerated() { | |
| group.addTask { | |
| let simulation = try await self.simulateSendTransaction(chain: chain, transactionType: type, data: data) | |
| let transaction = try self.walletConnect.decodeSendTransaction(transactionType: type, data: data) | |
| let signed = try await self.signer.signTransaction(sessionId: sessionId, chain: chain.map(), transaction: transaction.map(), simulation: simulation) | |
| return (index, signed) | |
| } | |
| } | |
| var indexedResults: [(Int, String)] = [] | |
| indexedResults.reserveCapacity(transactions.count) | |
| for try await result in group { | |
| indexedResults.append(result) | |
| } | |
| return indexedResults.sorted { $0.0 < $1.0 }.map { $0.1 } | |
| } |
Fixes #1825
Update core submodule and handle new SignAllTransactions action in iOS.