Skip to content

Commit

Permalink
fix to_base58_string
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinheavey committed Nov 5, 2024
1 parent d58a9de commit 06e29a8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion sdk/keypair/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl Keypair {

/// Returns this `Keypair` as a base58-encoded string
pub fn to_base58_string(&self) -> String {
bs58::encode(&self.0.to_bytes()).into_string()
bs58::encode(&self.to_bytes()).into_string()
}

/// Gets this `Keypair`'s SecretKey
Expand Down Expand Up @@ -440,4 +440,12 @@ mod tests {
keypair_from_seed_phrase_and_passphrase(mnemonic.phrase(), passphrase).unwrap();
assert_eq!(keypair.pubkey(), expected_keypair.pubkey());
}

#[test]
fn test_base58() {
let keypair = keypair_from_seed(&[0u8; 32]).unwrap();
let as_base58 = keypair.to_base58_string();
let parsed = Keypair::from_base58_string(&as_base58);
assert_eq!(keypair, parsed);
}
}

0 comments on commit 06e29a8

Please sign in to comment.