Fix WalletConnect solana_signAllTransactions parsing and response format#1027
Fix WalletConnect solana_signAllTransactions parsing and response format#1027
Conversation
Two bugs fixed:
- Parse error: raw base64 was stored as data but decode_send_transaction expects {"transaction":"..."} JSON format
- Wrong response: was returning {"signature":"..."} instead of {"transactions":["..."]}
Added SignAllTransactions action variant with Vec<String> to support multiple transactions.
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 enhances WalletConnect's functionality for Solana by addressing critical issues related to batch transaction signing. It ensures that requests for signing multiple transactions are parsed correctly and that the responses adhere to the expected format, thereby improving the reliability and compatibility of Solana integrations within the WalletConnect ecosystem. 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 the SignAllTransactions action for Solana WalletConnect, enabling the signing of multiple transactions simultaneously. This includes adding the new action type, implementing parsing logic in SolanaRequestHandler::parse_sign_all_transactions, and encoding logic in WalletConnectResponseHandler::encode_sign_all_transactions, along with corresponding tests. Feedback suggests an efficiency improvement in parse_sign_all_transactions by moving the empty array check earlier, and recommends adding more robust test cases for failure scenarios in the same function.
| if transactions.is_empty() { | ||
| return Err("Empty transactions array".to_string()); | ||
| } |
There was a problem hiding this comment.
For efficiency, it's better to check if the transactions array is empty before mapping over it and collecting the results into a new Vec. This check should be performed on the array variable right after it's created on line 44. This avoids unnecessary allocations and processing if the input array is empty.
| #[test] | ||
| fn test_sign_all_transactions() { | ||
| let params: Value = serde_json::from_str(r#"{"transactions":["AQAAA","BBBBB"]}"#).unwrap(); | ||
| let result = SolanaRequestHandler::parse_sign_all_transactions(params).unwrap(); | ||
| assert_eq!( | ||
| result, | ||
| WalletConnectAction::SignAllTransactions { | ||
| chain: Chain::Solana, | ||
| transaction_type: WalletConnectTransactionType::Solana { | ||
| output_type: TransferDataOutputType::EncodedTransaction, | ||
| }, | ||
| transactions: vec![ | ||
| r#"{"transaction":"AQAAA"}"#.to_string(), | ||
| r#"{"transaction":"BBBBB"}"#.to_string(), | ||
| ], | ||
| } | ||
| ); | ||
| } |
There was a problem hiding this comment.
This test covers the happy path well. To make the test suite more robust, consider adding test cases for failure scenarios, such as:
- An empty
transactionsarray. - A
transactionsarray containing non-string elements.
This will ensure that the error handling paths in parse_sign_all_transactions are working as expected.
|
|
||
| #[test] | ||
| fn test_solana_sign_all_transactions_roundtrip() { | ||
| let params = r#"{"transactions":["AQAAAB64encoded","BBBBB64encoded"]}"#; |
There was a problem hiding this comment.
can you move this to file? it could be reused in other unit tests that you above below
Fixes:
Added SignAllTransactions action variant with Vec to support multiple transactions.