Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Swap 'base58' with 'bs58' #13739

Merged
merged 5 commits into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 4 additions & 10 deletions primitives/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ documentation = "https://docs.rs/sp-core"
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = [
"derive",
"max-encoded-len",
] }
codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive","max-encoded-len"] }
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
log = { version = "0.4.17", default-features = false }
serde = { version = "1.0.136", optional = true, features = ["derive"] }
Expand All @@ -25,7 +22,7 @@ primitive-types = { version = "0.12.0", default-features = false, features = ["c
impl-serde = { version = "0.4.0", optional = true }
hash-db = { version = "0.16.0", default-features = false }
hash256-std-hasher = { version = "0.15.2", default-features = false }
base58 = { version = "0.2.0", optional = true }
bs58 = { version = "0.4.0", optional = true }
davxy marked this conversation as resolved.
Show resolved Hide resolved
rand = { version = "0.8.5", features = ["small_rng"], optional = true }
substrate-bip39 = { version = "0.4.4", optional = true }
tiny-bip39 = { version = "1.0.0", optional = true }
Expand All @@ -47,10 +44,7 @@ bitflags = "1.3"
array-bytes = { version = "4.1", optional = true }
ed25519-zebra = { version = "3.1.0", default-features = false, optional = true }
blake2 = { version = "0.10.4", default-features = false, optional = true }
schnorrkel = { version = "0.9.1", features = [
"preaudit_deprecated",
"u64_backend",
], default-features = false, optional = true }
schnorrkel = { version = "0.9.1", features = ["preaudit_deprecated", "u64_backend"], default-features = false, optional = true }
libsecp256k1 = { version = "0.7", default-features = false, features = ["static-context"], optional = true }
merlin = { version = "2.0", default-features = false, optional = true }
secp256k1 = { version = "0.24.0", default-features = false, features = ["recovery", "alloc"], optional = true }
Expand Down Expand Up @@ -96,7 +90,7 @@ std = [
"blake2/std",
"array-bytes",
"ed25519-zebra/std",
"base58",
"bs58",
"substrate-bip39",
"tiny-bip39",
"rand",
Expand Down
6 changes: 2 additions & 4 deletions primitives/core/src/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

use crate::{ed25519, sr25519};
#[cfg(feature = "std")]
use base58::{FromBase58, ToBase58};
#[cfg(feature = "std")]
use bip39::{Language, Mnemonic, MnemonicType};
use codec::{Decode, Encode, MaxEncodedLen};
#[cfg(feature = "std")]
Expand Down Expand Up @@ -276,7 +274,7 @@ pub trait Ss58Codec: Sized + AsMut<[u8]> + AsRef<[u8]> + ByteArray {
const CHECKSUM_LEN: usize = 2;
let body_len = Self::LEN;

let data = s.from_base58().map_err(|_| PublicError::BadBase58)?;
let data = bs58::decode(s).into_vec().map_err(|_| PublicError::BadBase58)?;
if data.len() < 2 {
return Err(PublicError::BadLength)
}
Expand Down Expand Up @@ -345,7 +343,7 @@ pub trait Ss58Codec: Sized + AsMut<[u8]> + AsRef<[u8]> + ByteArray {
v.extend(self.as_ref());
let r = ss58hash(&v);
v.extend(&r[0..2]);
v.to_base58()
bs58::encode(v).into_string()
}

/// Return the ss58-check string for this key.
Expand Down