Skip to content

Commit 13f6432

Browse files
committed
Address most review comments.
What's left is extracting JS Signer interface to a separate file and include_str! it and extracting the MetaMask implementation to a separate PR.
1 parent 16ab4fa commit 13f6432

File tree

7 files changed

+34
-3712
lines changed

7 files changed

+34
-3712
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@
2525
# Helm
2626
kubernetes/linera-validator/working/*
2727
node_modules
28-
**dist/
28+
**/dist/

linera-base/src/crypto/secp256k1/evm.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,7 @@ impl FromStr for EvmSignature {
7272

7373
fn from_str(s: &str) -> Result<Self, Self::Err> {
7474
// If the string starts with "0x", we remove it before decoding.
75-
let s = if let Some(stripped) = s.strip_prefix("0x") {
76-
stripped
77-
} else {
78-
s
79-
};
80-
let bytes = hex::decode(s)?;
75+
let bytes = hex::decode(s.strip_prefix("0x").unwrap_or(s))?;
8176
let sig = Signature::from_erc2098(&bytes);
8277
Ok(EvmSignature(sig))
8378
}
@@ -200,13 +195,9 @@ impl FromStr for EvmPublicKey {
200195
type Err = CryptoError;
201196

202197
fn from_str(s: &str) -> Result<Self, Self::Err> {
203-
// If the string starts with "0x", we remove it to decode the hex string.
204-
let s = if let Some(stripped) = s.strip_prefix("0x") {
205-
stripped
206-
} else {
207-
s
208-
};
209-
hex::decode(s)?.as_slice().try_into()
198+
hex::decode(s.strip_prefix("0x").unwrap_or(s))?
199+
.as_slice()
200+
.try_into()
210201
}
211202
}
212203

0 commit comments

Comments
 (0)