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

fix: android test #84

Merged
merged 5 commits into from
Jan 21, 2025
Merged

fix: android test #84

merged 5 commits into from
Jan 21, 2025

Conversation

pedrxlz
Copy link
Contributor

@pedrxlz pedrxlz commented Jan 17, 2025

Summary by CodeRabbit

  • Refactor

    • Simplified EVM transaction and chain options by removing the network type parameter.
    • Updated function signatures and enum variants to streamline chain configuration.
    • Converted integer literals to unsigned integers in test files.
    • Simplified dependency declaration in the build configuration.
  • Tests

    • Added a new test case for signing transactions with updated options.
  • Bug Fixes

    • Enhanced signature processing in the ETH struct to comply with Ethereum signature format.
  • Chores

    • Adjusted support status for several chains within the registry.

Copy link

coderabbitai bot commented Jan 17, 2025

Walkthrough

This pull request involves modifications across multiple files in the KOS mobile and core packages, focusing on simplifying the handling of EVM transaction options and chain configurations. The changes primarily remove the network_type parameter from various enum variants and function signatures, streamlining the approach to defining EVM-related options. Additionally, there are type-related updates in the Kotlin test file, converting integer literals to unsigned integers to align with Kotlin's type system.

Changes

File Change Summary
packages/kos-mobile/android/lib/src/test/kotlin/uniffi/kos_mobile/KOSTest.kt Updated integer literals to unsigned integers (u) for klvChainId, generateWalletFromMnemonic() parameters
packages/kos-mobile/src/lib.rs Removed network_type from TransactionChainOptions::Evm enum variant and simplified new_evm_transaction_options() function
packages/kos/src/chains/mod.rs Removed network_type from ChainOptions::EVM variant and updated create_custom_evm() method signatures
packages/kos/src/chains/eth/mod.rs Modified sign_message method to adjust the last byte of the signature for Ethereum compliance
packages/kos-mobile/android/lib/build.gradle.kts Simplified dependency declaration for libs.java.jna by removing artifact specifications

Possibly related PRs

Suggested reviewers

  • klever-patrick

Poem

🐰 Unsigned integers hop with glee,
Network types now set free!
Simplifying code with rabbit might,
EVM options trimmed just right.
Kotlin and Rust dance in sync,
A cleaner path, without a kink! 🚀


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4718e28 and 1b4b7f6.

📒 Files selected for processing (1)
  • packages/kos-mobile/android/lib/build.gradle.kts (1 hunks)
🔇 Additional comments (1)
packages/kos-mobile/android/lib/build.gradle.kts (1)

37-37: Verify JNA dependency resolution after simplification.

The simplified dependency declaration looks good and aligns with Gradle best practices. However, since JNA is crucial for native code integration, please verify that:

  1. The dependency still resolves to the correct AAR artifact
  2. The native libraries are properly packaged in the final build

Run this script to verify the dependency resolution:

Consider adding a comment explaining why the explicit AAR artifact specification was removed to help future maintainers understand the context of this change.

✅ Verification successful

JNA dependency simplification is correct and beneficial

The simplified dependency declaration is the recommended approach as:

  1. JNA 5.13.0 in MavenCentral properly handles platform-specific artifacts
  2. The default Maven artifact resolution will correctly package native libraries
  3. Explicit AAR configuration was redundant and can be safely removed
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify JNA dependency resolution and artifact type
# Expected: Should show the resolved artifact details including type and path

# Search for any existing verification of JNA dependency resolution
rg -g '*.{kt,kts}' -A 5 'implementation.*jna'

# Look for any related configuration or documentation
fd -g 'README*' -X rg -l 'jna|JNA'

Length of output: 482


Script:

#!/bin/bash
# Find version catalog definition and gradle configuration
fd -g 'libs.versions.toml' -X cat
fd -g 'gradle.properties' -X cat
fd -g 'settings.gradle*' -X cat

# Look for any backup or previous versions of the build file
rg -g '*.{kts,gradle}' -B 3 'artifact.*aar.*jna'

Length of output: 2455


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the rust label Jan 17, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/kos-mobile/src/lib.rs (1)

454-473: LGTM: Added test case for EVM transaction signing.

The new test case verifies that transactions can be signed with the updated options structure.

However, consider adding assertions to verify the signature and chain ID in the test case.

 #[test]
 fn should_sign_transaction_with_options() {
     let chain_id = 61;
     let raw =
         "b302f101819e84ae7937b285035f6cccc58252089498de4c83810b87f0e2cd92d80c9fac28c4ded4818568c696991f80c0808080";

     let account = generate_wallet_from_mnemonic(
         "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about".to_string(),
         chain_id,
         0,
         false,
     )
         .unwrap();

     let options = new_evm_transaction_options(88888);
     let transaction = sign_transaction(account, raw.to_string(), Some(options)).unwrap();

     assert_eq!(transaction.raw, "02f87101819e84ae7937b285035f6cccc58252089498de4c83810b87f0e2cd92d80c9fac28c4ded4818568c696991f80c001a044c69f41bf47ad50dc98c74af68811384c9172055b01fcaa39e70f53df69b632a05e071cf1f9e12500b525f03a29f567520e1ea49a97e6a29d1fd432dc6303353e", "The raw doesn't match");
+    assert_eq!(transaction.chain_id, chain_id, "The chain_id doesn't match");
+    assert!(!transaction.signature.is_empty(), "The signature should not be empty");
 }
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between befcc82 and cd2139a.

📒 Files selected for processing (3)
  • packages/kos-mobile/android/lib/src/test/kotlin/uniffi/kos_mobile/KOSTest.kt (3 hunks)
  • packages/kos-mobile/src/lib.rs (4 hunks)
  • packages/kos/src/chains/mod.rs (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: format
🔇 Additional comments (6)
packages/kos-mobile/android/lib/src/test/kotlin/uniffi/kos_mobile/KOSTest.kt (3)

13-13: LGTM: Chain ID converted to unsigned integer.

The conversion of klvChainId from 38 to 38u aligns with the updated function signatures.


28-28: LGTM: Mnemonic size parameters converted to unsigned integers.

The conversion of mnemonic size parameters from 12 and 24 to 12u and 24u aligns with the updated function signatures.

Also applies to: 31-31


52-52: LGTM: Index parameter converted to unsigned integer.

The conversion of the index parameter from 0 to 0u in generateWalletFromMnemonic aligns with the updated function signatures.

packages/kos-mobile/src/lib.rs (2)

82-83: LGTM: Simplified EVM transaction options.

The removal of the network_type parameter simplifies the API by focusing only on the essential chain_id parameter.


179-179: LGTM: Updated EVM chain options handling.

The chain options handling has been simplified to match the updated EVM options structure.

Also applies to: 192-193

packages/kos/src/chains/mod.rs (1)

Line range hint 706-758: LGTM: Simplified custom EVM chain creation.

The removal of the network_type parameter from custom EVM chain creation aligns with the changes in the mobile package.

@pedrxlz pedrxlz merged commit c945375 into develop Jan 21, 2025
4 checks passed
@pedrxlz pedrxlz deleted the fix/android-test branch January 21, 2025 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants