-
Notifications
You must be signed in to change notification settings - Fork 30
Add Ledger signer provider #1946
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
base: feature/ledger_signer
Are you sure you want to change the base?
Conversation
abe8a88
to
89285d1
Compare
10d2120
to
a8231af
Compare
4c64407
to
10bd693
Compare
5b2cae2
to
2de6ff8
Compare
ab50373
to
b304ef1
Compare
d4a8f4d
to
32a8870
Compare
61292c5
to
eeb6484
Compare
5d3edf0
to
d6fd484
Compare
32a8870
to
39d3e58
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to look at this code one more time later. But perhaps it's better to merge it to the parent PR first, to review all the changes together.
TEXT_SIZE + 2. * VERTICAL_PADDING | ||
// Same as Trezor | ||
+ 4. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plz don't duplicate the value.
} | ||
#[cfg(feature = "ledger")] | ||
WalletExtraInfo::LedgerWallet { firmware_version } => { | ||
use iced::widget::{rich_text, span}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this out of the function? (for the trezor case too).
row![rich_text([ | ||
span("Firmware version: ").font(bold_font), | ||
span(firmware_version.clone()) | ||
]) | ||
.size(TEXT_SIZE),] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO we should be able to obtain the device name for the ledger too (which will be the model name, not the label set in Ledger Live, but it's still better than nothing).
As I've mentioned in the ledger app PR, it seems like the APDU 0xE0/0x01 is "get device info" (need to check if it works when an app is opened though). One of the returned values is targetId, from which the model name can be deduced.
Ledger Live sometimes calls this endpoint - https://manager.api.live.ledger.com/api/devices - to get the device model name (by comparing obtained the device's targetId with target_id
inside device_versions
of the returned json.)
(I'm not suggesting to use their endpoint, but we might just take its current values and hardcode them).
And it also has a hardcoded array of device infos and this function obtains them by targetId - https://github.com/LedgerHQ/ledger-live/blob/2dddf3a308ec6bd9fa436c7bc5bc02bcb33593e6/libs/ledgerjs/packages/devices/src/index.ts#L176-L182
|
||
#[cfg(feature = "ledger")] | ||
#[derive(Debug, Clone, PartialEq, Eq, Encode, Decode)] | ||
pub struct LedgerDataFullInfo { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LedgerFullInfo
P.S. plz also add doc comments to LedgerData and LedgerFullInfo, similar to those for TrezorData and TrezorFullInfo. Or, if you think they're redundant, then remove them for Trezor too, for consistency.
let firmware_version = match ver.as_slice() { | ||
[major, minor, patch] => common::primitives::semver::SemVer { | ||
major: *major, | ||
minor: *minor, | ||
patch: *patch as u16, | ||
}, | ||
_ => return Err(SignerError::LedgerError(LedgerError::InvalidResponse)), | ||
}; | ||
|
||
Ok(LedgerDataFullInfo { firmware_version }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a mintlayer app version, not firmware version
#[derive(Clone)] | ||
pub struct LedgerSignerProvider { | ||
client: Arc<Mutex<LedgerHandle>>, | ||
data: LedgerDataFullInfo, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since LedgerDataFullInfo should be renamed to LedgerFullInfo, this is "info", not "data".
|
||
if let Some(info) = signer_provider.get_hardware_wallet_info() { | ||
db_tx.set_hardware_wallet_data(info.into())?; | ||
if let Some(data) = signer_provider.get_hardware_wallet_info() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well it's actually "info", not "data".
) | ||
} | ||
WalletExtraInfo::LedgerWallet { firmware_version } => format!( | ||
"This is a ledger wallet' firmware version {}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Broken text.
Also, currently this is not really a firmware version.
use async_trait::async_trait; | ||
use common::{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plz put 3rd-party imports in a separate group
}, | ||
#[cfg(feature = "ledger")] | ||
LedgerWallet { | ||
firmware_version: String, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, this is not the firmware version, it's the version of the ledger app.
No description provided.