Skip to content

Commit

Permalink
fix: load substrate signer from env correctly (#349)
Browse files Browse the repository at this point in the history
  • Loading branch information
Serial-ATA authored Oct 15, 2024
1 parent 798d138 commit 61564de
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions cli/src/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,16 @@ generally be equivalent to no password at all.

/// Loads the Substrate Signer from the environment.
pub fn load_signer_from_env() -> Result<TanglePairSigner> {
let secret = std::env::var(SIGNER_ENV)
let s = std::env::var(SIGNER_ENV)
.with_suggestion(|| {
format!(
"Please set the signer SURI in the environment using the `{SIGNER_ENV}` variable.",
)
})
.note(SURI_HELP_MSG)?;

let uri = SecretUri::from_str(&secret)
.with_context(|| "Parsing the SURI into a Secret Key")
.note(SURI_HELP_MSG)?;

let sp_core_keypair = sp_core::sr25519::Pair::from_phrase(
uri.phrase.expose_secret(),
uri.password.as_ref().map(|r| r.expose_secret().as_str()),
)?;
Ok(TanglePairSigner::new(
sp_core_keypair.0.as_ref().clone().into(),
))
let sp_core_keypair = sp_core::sr25519::Pair::from_string(&*s, None)?;
Ok(TanglePairSigner::new(sp_core_keypair))
}

/// Loads the EVM Signer from the environment.
Expand Down

0 comments on commit 61564de

Please sign in to comment.