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

feat: Added the ability to get a public key for an account #436

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

FroVolod
Copy link
Collaborator

@FroVolod FroVolod commented Jan 16, 2025

Also resolves #371

Screenshot 2025-01-16 at 21 39 20

@FroVolod
Copy link
Collaborator Author

@race-of-sloths

@race-of-sloths
Copy link

@FroVolod Thank you for your contribution! Your pull request is now a part of the Race of Sloths!
Weekly streak is on the road, smart strategy! Secure your streak with another PR!

Shows inviting banner with latest news.

Shows profile picture for the author of the PR

Current status: waiting for scoring

We're waiting for maintainer to score this pull request with @race-of-sloths score [0,1,2,3,5,8,13] command. Alternatively, autoscoring [1,2] will be applied for this pull request

What is the Race of Sloths

Race of Sloths is a friendly competition where you can participate in challenges and compete with other open-source contributors within your normal workflow

For contributors:

  • Tag @race-of-sloths inside your pull requests
  • Wait for the maintainer to review and score your pull request
  • Check out your position in the Leaderboard
  • Keep weekly and monthly streaks to reach higher positions
  • Boast your contributions with a dynamic picture of your Profile

For maintainers:

  • Score pull requests that participate in the Race of Sloths and receive a reward
  • Engage contributors with fair scoring and fast responses so they keep their streaks
  • Promote the Race to the point where the Race starts promoting you
  • Grow the community of your contributors

Feel free to check our website for additional details!

Bot commands
  • For contributors
    • Include a PR: @race-of-sloths include to enter the Race with your PR
  • For maintainers:
    • Invite contributor @race-of-sloths invite to invite the contributor to participate in a race or include it, if it's already a runner.
    • Assign points: @race-of-sloths score [1/2/3/5/8/13] to award points based on your assessment.
    • Reject this PR: @race-of-sloths exclude to send this PR back to the drawing board.
    • Exclude repo: @race-of-sloths pause to stop bot activity in this repo until @race-of-sloths unpause command is called

Copy link
Collaborator

@akorchyn akorchyn left a comment

Choose a reason for hiding this comment

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

Good work. A few comments left to think a bit.

#[strum_discriminants(strum(
message = "from-ledger - Get the public key stored on your Ledger Nano device"
))]
/// Get the public key stored on your Ledger Nano device
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure if these comments have any value as they are repeating text from the message above.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

--help uses these comments:

Screenshot 2025-01-17 at 16 36 18

Copy link
Collaborator

@akorchyn akorchyn Jan 17, 2025

Choose a reason for hiding this comment

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

Doesn't it use strum macro above ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

strum macro processes these messages with various functions

Screenshot 2025-01-17 at 20 46 23

_previous_context: crate::GlobalContext,
scope: &<PublicKeyFromSeedPhrase as interactive_clap::ToInteractiveClapContextScope>::InteractiveClapContextScope,
) -> color_eyre::eyre::Result<Self> {
let seed_phrase_hd_path_default = slipped10::BIP32Path::from_str("m/44'/397'/0'").unwrap();
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe, we could configure BIP32Path in other handlers

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should stay consistent here

Copy link
Collaborator

Choose a reason for hiding this comment

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

Example. It actuallyt seems to be skipped, but we can at least have a structure similar way

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

let signer_access_key_file_path: std::path::PathBuf = {
if previous_context.offline {
eprintln!(
"\nThe signer's public key cannot be verified and retrieved offline."
Copy link
Collaborator

Choose a reason for hiding this comment

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

But why ? I still think we can easily process the directory and return user a key. Just with a warning that this key wasn't checked that it's active on chain

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We can easily process the directory and return the key to the user. But we promised the user that they would be able to get the public key with full access.
For example, an account has 10 key files. We give the user the public key and say that we don't know if it is active or has full access.

#[derive(Debug, Clone, interactive_clap::InteractiveClap)]
#[interactive_clap(input_context = crate::GlobalContext)]
#[interactive_clap(output_context = PublicKeyFromKeychainContext)]
pub struct PublicKeyFromKeychain {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's a bit weird, to be honest. Maybe we shouldn't have that. Because to get a key from a keychain, we need to fetch a key before-hand (e.g., from the chain). So it doesn't really make sense.
Maybe we can iterate somehow over keychain entries and parse it that way....

Copy link
Collaborator Author

@FroVolod FroVolod Jan 17, 2025

Choose a reason for hiding this comment

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

it works:

Screen.Recording.2025-01-17.at.21.01.13.mov

@FroVolod FroVolod marked this pull request as draft January 17, 2025 14:45
@FroVolod FroVolod marked this pull request as ready for review January 17, 2025 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: NEW❗
Development

Successfully merging this pull request may close these issues.

Feature request: display Ledger key connected to specific HD Path
3 participants