Skip to content

Commit

Permalink
feat: get ledger app version
Browse files Browse the repository at this point in the history
  • Loading branch information
xJonathanLEI committed Jun 29, 2024
1 parent 4fc808d commit 721c433
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 14 deletions.
25 changes: 13 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ serde = { version = "1.0.164", features = ["derive"] }
serde_json = { version = "1.0.99", features = ["preserve_order"] }
serde_with = "2.3.3"
shellexpand = "3.1.0"
starknet = { git = "https://github.com/xJonathanLEI/starknet-rs", rev = "50eed828021365f86d346953ea017587f452aa9e", features = ["ledger"] }
starknet-crypto = { git = "https://github.com/xJonathanLEI/starknet-rs", rev = "50eed828021365f86d346953ea017587f452aa9e" }
starknet = { git = "https://github.com/xJonathanLEI/starknet-rs", rev = "db1fa598232f0698d942cc974f481b5d888ac080", features = ["ledger"] }
starknet-crypto = { git = "https://github.com/xJonathanLEI/starknet-rs", rev = "db1fa598232f0698d942cc974f481b5d888ac080" }
tempfile = "3.8.0"
thiserror = "1.0.40"
tokio = { version = "1.28.2", default-features = false, features = ["macros", "rt-multi-thread"] }
Expand Down
17 changes: 17 additions & 0 deletions src/subcommands/signer/ledger/app_version.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use anyhow::Result;
use clap::Parser;
use starknet::signers::ledger::LedgerStarknetApp;

#[derive(Debug, Parser)]
pub struct AppVersion;

impl AppVersion {
pub async fn run(self) -> Result<()> {
let ledger = LedgerStarknetApp::new().await?;

let version = ledger.get_version().await?;
println!("{}", version);

Ok(())
}
}
6 changes: 6 additions & 0 deletions src/subcommands/signer/ledger/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ use clap::{Parser, Subcommand};
mod get_public_key;
use get_public_key::GetPublicKey;

mod app_version;
use app_version::AppVersion;

#[derive(Debug, Parser)]
pub struct Ledger {
#[clap(subcommand)]
Expand All @@ -14,12 +17,15 @@ pub struct Ledger {
enum Subcommands {
#[clap(about = "Retrieve public key from a Ledger device")]
GetPublicKey(GetPublicKey),
#[clap(about = "Retrieve the Starknet app version on a Ledger device")]
AppVersion(AppVersion),
}

impl Ledger {
pub async fn run(self) -> Result<()> {
match self.command {
Subcommands::GetPublicKey(cmd) => cmd.run().await,
Subcommands::AppVersion(cmd) => cmd.run().await,
}
}
}

0 comments on commit 721c433

Please sign in to comment.