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: open ledger near app before calling methods #403

Merged
merged 2 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions Cargo.lock

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

7 changes: 7 additions & 0 deletions src/commands/account/add_key/use_ledger/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ impl AddLedgerKeyActionContext {
scope: &<AddLedgerKeyAction as interactive_clap::ToInteractiveClapContextScope>::InteractiveClapContextScope,
) -> color_eyre::eyre::Result<Self> {
let seed_phrase_hd_path = scope.seed_phrase_hd_path.clone();
eprintln!("Opening the NEAR application... Please approve opening the application");
near_ledger::open_near_application().map_err(|ledger_error| {
color_eyre::Report::msg(format!("An error happened while trying to open the NEAR application on the ledger: {ledger_error:?}"))
})?;

std::thread::sleep(std::time::Duration::from_secs(1));

eprintln!(
"Please allow getting the PublicKey on Ledger device (HD Path: {})",
seed_phrase_hd_path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ impl SaveWithLedgerContext {
std::sync::Arc::new({
let seed_phrase_hd_path = scope.seed_phrase_hd_path.clone();
move |folder_path| {
eprintln!(
"Opening the NEAR application... Please approve opening the application"
);
near_ledger::open_near_application().map_err(|ledger_error| {
color_eyre::Report::msg(format!("An error happened while trying to open the NEAR application on the ledger: {ledger_error:?}"))
})?;
std::thread::sleep(std::time::Duration::from_secs(1));

eprintln!(
"Please allow getting the PublicKey on Ledger device (HD Path: {})",
seed_phrase_hd_path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ impl AddAccessWithLedgerContext {
scope: &<AddAccessWithLedger as interactive_clap::ToInteractiveClapContextScope>::InteractiveClapContextScope,
) -> color_eyre::eyre::Result<Self> {
let seed_phrase_hd_path = scope.seed_phrase_hd_path.clone();
eprintln!("Opening the NEAR application... Please approve opening the application");
near_ledger::open_near_application().map_err(|ledger_error| {
color_eyre::Report::msg(format!("An error happened while trying to open the NEAR application on the ledger: {ledger_error:?}"))
})?;

std::thread::sleep(std::time::Duration::from_secs(1));

eprintln!(
"Please allow getting the PublicKey on Ledger device (HD Path: {})",
seed_phrase_hd_path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ impl AddAccessWithLedgerContext {
previous_context: super::super::NewAccountContext,
scope: &<AddAccessWithLedger as interactive_clap::ToInteractiveClapContextScope>::InteractiveClapContextScope,
) -> color_eyre::eyre::Result<Self> {
eprintln!("Opening the NEAR application... Please approve opening the application");
near_ledger::open_near_application().map_err(|ledger_error| {
color_eyre::Report::msg(format!("An error happened while trying to open the NEAR application on the ledger: {ledger_error:?}"))
})?;

std::thread::sleep(std::time::Duration::from_secs(1));

let seed_phrase_hd_path = scope.seed_phrase_hd_path.clone();
eprintln!(
"Please allow getting the PublicKey on Ledger device (HD Path: {})",
Expand Down
9 changes: 9 additions & 0 deletions src/transaction_signature_options/sign_with_ledger/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,15 @@ impl interactive_clap::FromCli for SignLedger {
.clone()
.expect("Unexpected error");

eprintln!("Opening the NEAR application... Please approve opening the application");
if let Err(err) = near_ledger::open_near_application().map_err(|ledger_error| {
color_eyre::Report::msg(format!("An error happened while trying to open the NEAR application on the ledger: {ledger_error:?}"))
}) {
return interactive_clap::ResultFromCli::Err(Some(clap_variant), err);
}

std::thread::sleep(std::time::Duration::from_secs(1));

eprintln!(
"Please allow getting the PublicKey on Ledger device (HD Path: {})",
seed_phrase_hd_path
Expand Down
Loading