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 6, 2024
1 parent 74276d5 commit 589a03d
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 @@ -70,7 +70,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 @@ -443,4 +443,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 589a03d

Please sign in to comment.