use fd_bs58
This commit is contained in:
parent
09ce0fdde3
commit
d594a4133e
|
@ -710,7 +710,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "4114279215a005bc675e386011e594e1d9b800918cea18fcadadcce864a2046b"
|
||||
dependencies = [
|
||||
"borsh-derive 0.10.3",
|
||||
"hashbrown 0.12.3",
|
||||
"hashbrown 0.13.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1912,6 +1912,12 @@ dependencies = [
|
|||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fd_bs58"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fdaac1b30ff95de4562a79ae990f91ac7bf2062d7313cc25c58987762c8e8160"
|
||||
|
||||
[[package]]
|
||||
name = "feature-probe"
|
||||
version = "0.1.1"
|
||||
|
@ -6511,13 +6517,13 @@ dependencies = [
|
|||
"blake3",
|
||||
"borsh 0.10.3",
|
||||
"borsh 0.9.3",
|
||||
"bs58",
|
||||
"bv",
|
||||
"bytemuck",
|
||||
"cc",
|
||||
"console_error_panic_hook",
|
||||
"console_log",
|
||||
"curve25519-dalek",
|
||||
"fd_bs58",
|
||||
"getrandom 0.2.10",
|
||||
"itertools",
|
||||
"js-sys",
|
||||
|
|
|
@ -16,7 +16,7 @@ bincode = { workspace = true }
|
|||
blake3 = { workspace = true, features = ["digest", "traits-preview"] }
|
||||
borsh = { workspace = true }
|
||||
borsh0-9 = { package = "borsh", version = "0.9.3" }
|
||||
fd_bs58 = { workspace = true }
|
||||
fd_bs58 = "0.1.0"
|
||||
bv = { workspace = true, features = ["serde"] }
|
||||
bytemuck = { workspace = true, features = ["derive"] }
|
||||
itertools = { workspace = true }
|
||||
|
|
|
@ -63,13 +63,13 @@ impl AsRef<[u8]> for Hash {
|
|||
|
||||
impl fmt::Debug for Hash {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{}", fd_bs58::fd_encode_32::encode_32(self.0))
|
||||
write!(f, "{}", fd_bs58::encode_32(self.0))
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Hash {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{}", fd_bs58::fd_encode_32::encode_32(self.0))
|
||||
write!(f, "{}", fd_bs58::encode_32(self.0))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ impl FromStr for Hash {
|
|||
if s.len() > MAX_BASE58_LEN {
|
||||
return Err(ParseHashError::WrongSize);
|
||||
}
|
||||
let bytes = fd_bs58::fd_decode_32::fd_decode_32(s).map_err(|_| ParseHashError::Invalid)?;
|
||||
let bytes = fd_bs58::decode_32(s).map_err(|_| ParseHashError::Invalid)?;
|
||||
if bytes.len() != mem::size_of::<Hash>() {
|
||||
Err(ParseHashError::WrongSize)
|
||||
} else {
|
||||
|
@ -172,11 +172,11 @@ mod tests {
|
|||
fn test_hash_fromstr() {
|
||||
let hash = hash(&[1u8]);
|
||||
|
||||
let mut hash_base58_str = fd_bs58::fd_encode_32::encode_32(hash);
|
||||
let mut hash_base58_str = fd_bs58::encode_32(hash);
|
||||
|
||||
assert_eq!(hash_base58_str.parse::<Hash>(), Ok(hash));
|
||||
|
||||
hash_base58_str.push_str(&fd_bs58::fd_encode_32::encode_32(hash.0));
|
||||
hash_base58_str.push_str(&fd_bs58::encode_32(hash.0));
|
||||
assert_eq!(
|
||||
hash_base58_str.parse::<Hash>(),
|
||||
Err(ParseHashError::WrongSize)
|
||||
|
@ -198,7 +198,7 @@ mod tests {
|
|||
Err(ParseHashError::WrongSize)
|
||||
);
|
||||
|
||||
let mut hash_base58_str = fd_bs58::fd_encode_32::encode_32(hash.0);
|
||||
let mut hash_base58_str = fd_bs58::encode_32(hash.0);
|
||||
assert_eq!(hash_base58_str.parse::<Hash>(), Ok(hash));
|
||||
|
||||
// throw some non-base58 stuff in there
|
||||
|
|
|
@ -84,13 +84,13 @@ impl AsRef<[u8]> for Hash {
|
|||
|
||||
impl fmt::Debug for Hash {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{}", fd_bs58::fd_encode_32::encode_32(self.0))
|
||||
write!(f, "{}", fd_bs58::encode_32(self.0))
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Hash {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{}", fd_bs58::fd_encode_32::encode_32(self.0))
|
||||
write!(f, "{}", fd_bs58::encode_32(self.0))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ impl FromStr for Hash {
|
|||
if s.len() > MAX_BASE58_LEN {
|
||||
return Err(ParseHashError::WrongSize);
|
||||
}
|
||||
let bytes = fd_bs58::fd_decode_32::fd_decode_32(s).map_err(|_| ParseHashError::Invalid)?;
|
||||
let bytes = fd_bs58::decode_32(s).map_err(|_| ParseHashError::Invalid)?;
|
||||
if bytes.len() != mem::size_of::<Hash>() {
|
||||
Err(ParseHashError::WrongSize)
|
||||
} else {
|
||||
|
@ -193,11 +193,11 @@ mod tests {
|
|||
fn test_hash_fromstr() {
|
||||
let hash = hash(&[1u8]);
|
||||
|
||||
let mut hash_base58_str = fd_bs58::fd_encode_32::encode_32(hash);
|
||||
let mut hash_base58_str = fd_bs58::encode_32(hash);
|
||||
|
||||
assert_eq!(hash_base58_str.parse::<Hash>(), Ok(hash));
|
||||
|
||||
hash_base58_str.push_str(&fd_bs58::fd_encode_32::encode_32(hash.0));
|
||||
hash_base58_str.push_str(&fd_bs58::encode_32(hash.0));
|
||||
assert_eq!(
|
||||
hash_base58_str.parse::<Hash>(),
|
||||
Err(ParseHashError::WrongSize)
|
||||
|
@ -219,7 +219,7 @@ mod tests {
|
|||
Err(ParseHashError::WrongSize)
|
||||
);
|
||||
|
||||
let mut hash_base58_str = fd_bs58::fd_encode_32::encode_32(hash.0);
|
||||
let mut hash_base58_str = fd_bs58::encode_32(hash.0);
|
||||
assert_eq!(hash_base58_str.parse::<Hash>(), Ok(hash));
|
||||
|
||||
// throw some non-base58 stuff in there
|
||||
|
|
|
@ -63,13 +63,13 @@ impl AsRef<[u8]> for Hash {
|
|||
|
||||
impl fmt::Debug for Hash {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{}", fd_bs58::fd_encode_32::encode_32(self.0))
|
||||
write!(f, "{}", fd_bs58::encode_32(self.0))
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Hash {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{}", fd_bs58::fd_encode_32::encode_32(self.0))
|
||||
write!(f, "{}", fd_bs58::encode_32(self.0))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ impl FromStr for Hash {
|
|||
if s.len() > MAX_BASE58_LEN {
|
||||
return Err(ParseHashError::WrongSize);
|
||||
}
|
||||
let bytes = fd_bs58::fd_decode_32::fd_decode_32(s).map_err(|_| ParseHashError::Invalid)?;
|
||||
let bytes = fd_bs58::decode_32(s).map_err(|_| ParseHashError::Invalid)?;
|
||||
if bytes.len() != mem::size_of::<Hash>() {
|
||||
Err(ParseHashError::WrongSize)
|
||||
} else {
|
||||
|
|
|
@ -116,7 +116,7 @@ impl FromStr for Pubkey {
|
|||
return Err(ParsePubkeyError::WrongSize);
|
||||
}
|
||||
let pubkey_bytes =
|
||||
fd_bs58::fd_decode_32::fd_decode_32(s).map_err(|_| ParsePubkeyError::Invalid)?;
|
||||
fd_bs58::decode_32(s).map_err(|_| ParsePubkeyError::Invalid)?;
|
||||
Pubkey::try_from(pubkey_bytes).map_err(|_| ParsePubkeyError::Invalid)
|
||||
}
|
||||
}
|
||||
|
@ -653,13 +653,13 @@ impl AsMut<[u8]> for Pubkey {
|
|||
|
||||
impl fmt::Debug for Pubkey {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{}", fd_bs58::fd_encode_32::encode_32(self.0))
|
||||
write!(f, "{}", fd_bs58::encode_32(self.0))
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Pubkey {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{}", fd_bs58::fd_encode_32::encode_32(self.0))
|
||||
write!(f, "{}", fd_bs58::encode_32(self.0))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -717,11 +717,11 @@ mod tests {
|
|||
#[test]
|
||||
fn pubkey_fromstr() {
|
||||
let pubkey = Pubkey::new_unique();
|
||||
let mut pubkey_base58_str = fd_bs58::fd_encode_32::encode_32(pubkey.0);
|
||||
let mut pubkey_base58_str = fd_bs58::encode_32(pubkey.0);
|
||||
|
||||
assert_eq!(pubkey_base58_str.parse::<Pubkey>(), Ok(pubkey));
|
||||
|
||||
pubkey_base58_str.push_str(&fd_bs58::fd_encode_32::encode_32(pubkey.0));
|
||||
pubkey_base58_str.push_str(&fd_bs58::encode_32(pubkey.0));
|
||||
assert_eq!(
|
||||
pubkey_base58_str.parse::<Pubkey>(),
|
||||
Err(ParsePubkeyError::WrongSize)
|
||||
|
@ -736,7 +736,7 @@ mod tests {
|
|||
Err(ParsePubkeyError::Invalid)
|
||||
);
|
||||
|
||||
let mut pubkey_base58_str = fd_bs58::fd_encode_32::encode_32(pubkey.0);
|
||||
let mut pubkey_base58_str = fd_bs58::encode_32(pubkey.0);
|
||||
assert_eq!(pubkey_base58_str.parse::<Pubkey>(), Ok(pubkey));
|
||||
|
||||
// throw some non-base58 stuff in there
|
||||
|
@ -748,7 +748,7 @@ mod tests {
|
|||
|
||||
// too long input string
|
||||
// longest valid encoding
|
||||
let mut too_long = fd_bs58::fd_encode_32::encode_32(&[255u8; PUBKEY_BYTES]);
|
||||
let mut too_long = fd_bs58::encode_32(&[255u8; PUBKEY_BYTES]);
|
||||
// and one to grow on
|
||||
too_long.push('1');
|
||||
assert_eq!(too_long.parse::<Pubkey>(), Err(ParsePubkeyError::WrongSize));
|
||||
|
|
Loading…
Reference in New Issue