-
Notifications
You must be signed in to change notification settings - Fork 4
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
add get public key method for kos-web package #92
Conversation
WalkthroughThe changes focus on enhancing the Changes
Poem
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/kos-web/src/wallet.rs (1)
325-489
: LGTM! Comprehensive test coverage with clear test cases.The test suite thoroughly covers all aspects of the wallet functionality, including error cases and cross-chain compatibility.
Consider adding a test to verify that the public key derived from a private key matches the expected value. Here's a suggested test case:
+ #[test] + fn test_public_key_derivation() { + let chain_id = 38; + let wallet = Wallet::from_private_key(chain_id, TEST_PRIVATE_KEY.to_string()).unwrap(); + + // Verify that the derived public key matches the test constant + assert_eq!(wallet.get_public_key(), TEST_PUBLIC_KEY); + + // Also verify for mnemonic-derived wallet + let chain = get_chain_by_base_id(chain_id).unwrap(); + let path = chain.get_path(0, false); + let mnemonic_wallet = Wallet::from_mnemonic( + chain_id, + TEST_MNEMONIC.to_string(), + path, + None + ).unwrap(); + + // The mnemonic should derive to the same keypair + assert_eq!(mnemonic_wallet.get_public_key(), TEST_PUBLIC_KEY); + }
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/kos-web/src/wallet.rs
(7 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: format
🔇 Additional comments (3)
packages/kos-web/src/wallet.rs (3)
29-29
: LGTM! Well-structured addition of the public key field.The
public_key
field is appropriately placed and typed, maintaining consistency with the existing field structure.
92-99
: LGTM! Consistent public key handling in constructors.The public key is correctly derived and hex-encoded in both constructors, with proper error handling and memory management.
Also applies to: 141-152
219-224
: LGTM! Well-documented getter implementation.The
get_public_key
method follows the established pattern of other getters, and both methods have clear documentation about the hex encoding of returned keys.Also applies to: 244-244
Summary by CodeRabbit