From 8026558b485c561c6d5e4a92c23ac20a077784ab Mon Sep 17 00:00:00 2001 From: Elizabeth Engelman <4752801+elizabethengelman@users.noreply.github.com> Date: Fri, 3 May 2024 13:09:20 -0400 Subject: [PATCH] Add get_transport fn back in --- cmd/crates/stellar-ledger/src/lib.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cmd/crates/stellar-ledger/src/lib.rs b/cmd/crates/stellar-ledger/src/lib.rs index 9226b6a30..1eaede12f 100644 --- a/cmd/crates/stellar-ledger/src/lib.rs +++ b/cmd/crates/stellar-ledger/src/lib.rs @@ -1,6 +1,7 @@ use futures::executor::block_on; +use hidapi::HidApi; use ledger_transport::{APDUCommand, Exchange}; -use ledger_transport_hid::{hidapi::HidError, LedgerHIDError}; +use ledger_transport_hid::{hidapi::HidError, LedgerHIDError, TransportNativeHID}; use sha2::{Digest, Sha256}; use soroban_env_host::xdr::{Hash, Transaction}; @@ -378,6 +379,12 @@ fn hd_path_to_bytes(hd_path: &slip10::BIP32Path) -> Result, LedgerError> Ok(result.into_iter().flatten().collect()) } +pub fn get_transport() -> Result { + // instantiate the connection to Ledger, this will return an error if Ledger is not connected + let hidapi = HidApi::new().map_err(LedgerError::HidApiError)?; + TransportNativeHID::new(&hidapi).map_err(LedgerError::LedgerHidError) +} + #[cfg(test)] mod test { use std::str::FromStr;