Skip to content

Commit

Permalink
Add get_transport fn back in
Browse files Browse the repository at this point in the history
  • Loading branch information
elizabethengelman committed May 3, 2024
1 parent 40d978e commit 8026558
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cmd/crates/stellar-ledger/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -378,6 +379,12 @@ fn hd_path_to_bytes(hd_path: &slip10::BIP32Path) -> Result<Vec<u8>, LedgerError>
Ok(result.into_iter().flatten().collect())
}

pub fn get_transport() -> Result<impl Exchange, LedgerError> {
// 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;
Expand Down

0 comments on commit 8026558

Please sign in to comment.