This repository has been archived by the owner on Jun 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #176 from tendermint/ledger-integration_follow_up
Followup on ledger integration PR
- Loading branch information
Showing
13 changed files
with
160 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,5 @@ tmkms.toml | |
|
||
# Ignore VIM swap files | ||
*.swp | ||
|
||
\.idea/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
//! Configuration for Ledger Tendermint signer | ||
/// Ledger Tendermint signer configuration | ||
#[derive(Clone, Deserialize, Debug)] | ||
pub struct LedgerTendermintConfig {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
//! Ledger Tendermint signer | ||
use signatory::PublicKeyed; | ||
use signatory_ledger_tm::{self, Ed25519LedgerTmAppSigner}; | ||
|
||
use crate::{ | ||
config::provider::ledgertm::LedgerTendermintConfig, | ||
error::{KmsError, KmsErrorKind::*}, | ||
keyring::{ed25519::Signer, KeyRing}, | ||
}; | ||
|
||
pub const LEDGER_TM_PROVIDER_LABEL: &str = "ledgertm"; | ||
pub const LEDGER_TM_ID: &str = "ledgertm"; | ||
|
||
/// Create Ledger Tendermint signer object from the given configuration | ||
pub fn init( | ||
keyring: &mut KeyRing, | ||
ledgertm_configs: &[LedgerTendermintConfig], | ||
) -> Result<(), KmsError> { | ||
if ledgertm_configs.is_empty() { | ||
return Ok(()); | ||
} | ||
|
||
if ledgertm_configs.len() != 1 { | ||
fail!( | ||
ConfigError, | ||
"expected one [providers.ledgertm] in config, found: {}", | ||
ledgertm_configs.len() | ||
); | ||
} | ||
let provider = Box::new(Ed25519LedgerTmAppSigner::connect()?); | ||
let pk = provider.public_key()?; | ||
// TODO: key_id shouldn't be a constant here (see LEDGER_TM_ID): | ||
let signer = Signer::new(LEDGER_TM_PROVIDER_LABEL, LEDGER_TM_ID.to_string(), provider); | ||
keyring.add(pk, signer)?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters