Skip to content

Commit

Permalink
Trim white spaces when reading private key (#77)
Browse files Browse the repository at this point in the history
This solves a common problem when there is an extra new-line in the
private key file. For instance:

    Error: stylus deploy failed

    Caused by:
       0: failed to load wallet
       1: invalid private key
       2: Odd number of digits
  • Loading branch information
gligneul authored Aug 15, 2024
1 parent 1f25518 commit 28b7df4
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions util/src/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use eyre::Result;

pub fn decode0x<T: AsRef<str>>(text: T) -> Result<Vec<u8>> {
let text = text.as_ref();
let text = text.trim();
let text = text.strip_prefix("0x").unwrap_or(text);
Ok(hex::decode(text)?)
}

0 comments on commit 28b7df4

Please sign in to comment.