Skip to content
This repository was archived by the owner on Jun 1, 2026. It is now read-only.

Move Solana signData from swift to rust - #944

Merged
0xh3rman merged 2 commits into
mainfrom
solana-signer-data
Feb 11, 2026
Merged

0xh3rman merged 2 commits into
mainfrom
solana-signer-data

Conversation

@0xh3rman

Copy link
Copy Markdown
Collaborator

No description provided.

@semanticdiff-com

semanticdiff-com Bot commented Feb 11, 2026 •

Copy link
Copy Markdown

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @0xh3rman, 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 focuses on migrating the Solana signData logic to Rust, enhancing the SolanaChainSigner with new signing capabilities. It also includes a significant refactoring of how gas_limit is managed across the codebase, centralizing its derivation and removing it as a direct field from transaction input structures. These changes streamline the Solana integration and improve the overall transaction processing architecture.

Highlights

  • Solana sign_data Migration: The core Solana sign_data functionality has been reimplemented in Rust within the SolanaChainSigner, moving away from a previous Swift implementation. This new function handles deserializing Solana transactions, signing messages with a private key, and returning either the raw signature or the fully encoded transaction based on the requested output type.
  • Refactored gas_limit Handling: The gas_limit field has been removed from the TransactionLoadInput and GemTransactionLoadInput structs across multiple crates. Instead, gas_limit is now derived dynamically from SwapQuoteData via a new gas_limit_as_u32 helper method, centralizing its parsing and validation.
  • New Solana Signer Testkit: A dedicated testkit module (crates/gem_solana/src/signer/testkit.rs) has been introduced to provide constants and helper functions for robust testing of Solana signing operations, including transaction deserialization and sign_data functionality with various output types.
  • Utility Method Additions: New utility methods get_generic_data in TransactionInputType and data_as_str in TransferDataExtra were added to facilitate safer and more explicit access to generic transaction data and its string representation.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • crates/gem_evm/src/provider/preload.rs
    • Removed gas_limit: 0 from TransactionLoadInput initializations in test cases.
  • crates/gem_hypercore/src/signer/core_signer.rs
    • Removed gas_limit: 0 from TransactionLoadInput initializations in test cases.
  • crates/gem_rewards/src/transfer_provider/evm/provider.rs
    • Removed gas_limit: 0 from TransactionLoadInput initialization.
  • crates/gem_solana/src/signer/chain_signer.rs
    • Imported TransferDataOutputType for use in signing logic.
    • Implemented the sign_data method for SolanaChainSigner to handle Solana transaction signing.
    • Updated sign_transaction to derive gas_limit from swap_data.data.gas_limit_as_u32().
    • Added comprehensive unit tests for sign_data functionality, including transaction deserialization and signature verification.
  • crates/gem_solana/src/signer/mod.rs
    • Added conditional pub mod testkit for Solana signer tests.
  • crates/gem_solana/src/signer/testkit.rs
    • Added a new file containing constants and helper functions for Solana signing test data and input mocking.
  • crates/gem_stellar/src/provider/preload.rs
    • Removed gas_limit: 0 from TransactionLoadInput initializations in test cases.
  • crates/gem_sui/src/provider/preload.rs
    • Removed gas_limit: 0 from TransactionLoadInput initialization in a test case.
  • crates/gem_ton/src/provider/preload.rs
    • Removed gas_limit: 0 from TransactionLoadInput initialization in a test case.
  • crates/primitives/src/swap/approval.rs
    • Added gas_limit_as_u32 method to SwapQuoteData to parse gas limit from an optional string.
  • crates/primitives/src/testkit/transaction_load_input_mock.rs
    • Removed gas_limit: 0 from TransactionLoadInput mock instances.
  • crates/primitives/src/transaction_input_type.rs
    • Removed gas_limit: u32 field from TransactionLoadInput struct.
    • Added get_generic_data method to TransactionInputType to safely extract TransferDataExtra.
  • crates/primitives/src/transfer_data_extra.rs
    • Added data_as_str method to TransferDataExtra to convert data bytes to a string slice.
  • gemstone/android/gemstone/src/androidTest/java/com/gemwallet/gemstone/GemstoneTest.kt
    • Removed gasLimit = 0u from GemTransactionLoadInput in a test.
  • gemstone/src/models/transaction.rs
    • Removed gas_limit: u32 field from GemTransactionLoadInput struct and its From implementation.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request successfully moves the Solana signData functionality from Swift to Rust, introducing a new sign_data method in SolanaChainSigner. The implementation is robust, handling different output types and including comprehensive tests. Additionally, a significant refactoring has been done to remove the gas_limit field from TransactionLoadInput and related structures across the codebase, which improves the design by moving the gas limit information to a more appropriate location within SwapQuoteData. The changes are consistent and well-executed. I have one minor suggestion for code conciseness.

Comment thread crates/gem_solana/src/signer/chain_signer.rs Outdated
@0xh3rman
0xh3rman merged commit ac93e47 into main Feb 11, 2026
6 checks passed
@0xh3rman
0xh3rman deleted the solana-signer-data branch February 11, 2026 12:59
}
}

pub fn mock_sign_data_input(data: &str, output_type: TransferDataOutputType) -> TransactionLoadInput {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this supposed to be in primitives testkit

pub const EXPECTED_MESSAGE_HEX: &str = "800100081385fba93ee29c604fa858a351688c01290841eafb19c63a70a475d3c7bc3bef9f17a6f0f3d6070bb69cb379b56142215651adf0bb21e47488668cc43db71a93d944919f938843197442dfbdc96372706dbf709fdb3ea84983819552b4a981098953ef77aaf283792a3e5b0431cc37170c79b20a2e76eae96032abba1bb17dac84751e3bf2e7ffb26759ca4a588592195a02155f72290d05b65a55b1c35017dc2e77047a381c391538f7a3ba42bafe841d453f26d52e71a66443f6af1edd748afd7bb74ea3593632e9e8e49183caf7b0ebf57be433b528f7d501b7b4a4654f9ccbaa8d16435989d07c64af0ebd2f57509a032a819776d3198f3ef839de7db776c7cd1ba08f8ff2944ecade9222507361ef69b8e2e3c44195e0015caab69412a98fcf6ed05454882e258ba08380382b665eabe945788535d45ba7d66f9c8d82ec20e9d4488b07fe399b1a9155e5821b697d43016c0a3c4f3bbca2afb41d0163305700000000000000000000000000000000000000000000000000000000000000000306466fe5211732ffecadba72c39be7bc8ce5bbc5f7126b2c439b3a400000000479d55bf231c06eee74c56ece681507fdb1b2dea3f48e5102b1cda256bc138f06ddf6e1d765a193d9cbe146ceeb79ac1cb485ed5f5b37913a8cf5857eff00a98c97258f4e2489f1bb3d1029148e0d830b5a1399daff1084048e7bd8dbe9f859ac1ae3d087f29237062548f70c4c04aec2a995694986e7cbb467520621d38630b43ffa27f5d7f64a74c09b1f295879de4b09ab36dfc9dd514b321aa7b38ce5e8c6fa7af3bedbad3a3d65f36aabc97431b1bbe4c2d2f6e0e47ca60203452f5d6185f1796860bcb8df9d2010ebc55def1f0658b3646614a9bcec2d47b4eddef8d2070c000502c05c15000f060009002c0b0e01010b0200090c0200000080969800000000000e010901110f06000600120b0e01010d420e100009050a062c12070d110d2a2916190a051718102b0e0d270e2d2e10052122041f20260e1e251d1a1b281c1e1e1e1e1e1e040310230e101403150a130802012432c1209b3341d69c81050400000012003c000403280002076402031101640304809698000000000081a90900000000003200320e03090000010904078b5404952877ec5d2470a56806f07d8d0a72c3f24baa6ebe29f000a23b4b5703f5eeef061ef127367f5c150cabfd3ee71ef870b5d47eb9b845c5bb18c835bd6e65af5e3880f608e8a2a304c3bcbbbe03c0bfc26dfa655d0e72e2e4c32404088d28553d02f3f2ffa67bc53d8c977af083ca8cb905bcbd3cb8ba00ccda99cf882523cab2e63beba47628f15ce1e929aa460b396b41f6000385699c04eaece9e70365edeb";

pub fn mock_app_metadata() -> WalletConnectionSessionAppMetadata {
WalletConnectionSessionAppMetadata {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

same here

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants