kill some bs58 (#4316)

* kill some bs58

* fixup
This commit is contained in:
Rob Walker
2019-05-16 21:43:18 -07:00
committed by GitHub
parent 41156da4ca
commit 39e85a3e53
4 changed files with 17 additions and 29 deletions

View File

@@ -1,4 +1,3 @@
use bs58;
use chrono::prelude::*;
use clap::{App, AppSettings, Arg, ArgMatches, SubCommand};
use log::*;
@@ -33,7 +32,7 @@ use std::io::Read;
use std::net::{IpAddr, SocketAddr};
use std::thread::sleep;
use std::time::Duration;
use std::{error, fmt, mem};
use std::{error, fmt};
const USERDATA_CHUNK_SIZE: usize = 229; // Keep program chunks under PACKET_DATA_SIZE
@@ -169,16 +168,12 @@ pub fn parse_command(
Ok(WalletCommand::Cancel(process_id))
}
("confirm", Some(confirm_matches)) => {
let signatures = bs58::decode(confirm_matches.value_of("signature").unwrap())
.into_vec()
.expect("base58-encoded signature");
if signatures.len() == mem::size_of::<Signature>() {
let signature = Signature::new(&signatures);
Ok(WalletCommand::Confirm(signature))
} else {
eprintln!("{}", confirm_matches.usage());
Err(WalletError::BadParameter("Invalid signature".to_string()))
match confirm_matches.value_of("signature").unwrap().parse() {
Ok(signature) => Ok(WalletCommand::Confirm(signature)),
_ => {
eprintln!("{}", confirm_matches.usage());
Err(WalletError::BadParameter("Invalid signature".to_string()))
}
}
}
("create-vote-account", Some(matches)) => {
@@ -1725,8 +1720,8 @@ mod tests {
.unwrap()
.as_str()
.unwrap();
let program_id_vec = bs58::decode(program_id).into_vec().unwrap();
assert_eq!(program_id_vec.len(), mem::size_of::<Pubkey>());
assert!(program_id.parse::<Pubkey>().is_ok());
// Failure cases
config.rpc_client = Some(RpcClient::new_mock("airdrop".to_string()));