Fix keybase wallet listener call ()

* fix keybase adapter call

* rustfmt
This commit is contained in:
Yeastplume 2018-12-06 17:51:53 +00:00 committed by GitHub
parent 995c5a38e5
commit 7ff323c882
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 8 deletions

View file

@ -99,8 +99,8 @@ pub fn wallet_command(wallet_args: &ArgMatches, config: GlobalWalletConfig) -> i
("listen", Some(args)) => {
let mut c = wallet_config.clone();
let mut g = global_wallet_args.clone();
arg_parse!(command_args::parse_listen_args(&mut c, &mut g, &args));
command::listen(&wallet_config, &g)
let a = arg_parse!(command_args::parse_listen_args(&mut c, &mut g, &args));
command::listen(&wallet_config, &a, &g)
}
("owner_api", Some(_)) => {
let mut g = global_wallet_args.clone();

View file

@ -30,7 +30,10 @@ use keychain;
use error::{Error, ErrorKind};
use {controller, display, HTTPNodeClient, WalletConfig, WalletInst, WalletSeed};
use {FileWalletCommAdapter, HTTPWalletCommAdapter, LMDBBackend, NullWalletCommAdapter};
use {
FileWalletCommAdapter, HTTPWalletCommAdapter, KeybaseWalletCommAdapter, LMDBBackend,
NullWalletCommAdapter,
};
pub type WalletRef = Arc<Mutex<WalletInst<HTTPNodeClient, keychain::ExtKeychain>>>;
@ -99,17 +102,22 @@ pub fn recover(config: &WalletConfig, args: RecoverArgs) -> Result<(), Error> {
/// Arguments for listen command
pub struct ListenArgs {
pub port: String,
pub method: String,
}
pub fn listen(config: &WalletConfig, g_args: &GlobalArgs) -> Result<(), Error> {
pub fn listen(config: &WalletConfig, args: &ListenArgs, g_args: &GlobalArgs) -> Result<(), Error> {
let mut params = HashMap::new();
params.insert("api_listen_addr".to_owned(), config.api_listen_addr());
if let Some(t) = g_args.tls_conf.as_ref() {
params.insert("certificate".to_owned(), t.certificate.clone());
params.insert("private_key".to_owned(), t.private_key.clone());
}
let adapter = HTTPWalletCommAdapter::new();
let adapter = match args.method.as_str() {
"http" => HTTPWalletCommAdapter::new(),
"keybase" => KeybaseWalletCommAdapter::new(),
_ => NullWalletCommAdapter::new(),
};
let res = adapter.listen(
params,
config.clone(),
@ -213,6 +221,7 @@ pub fn send(wallet: WalletRef, args: SendArgs) -> Result<(), Error> {
let adapter = match args.method.as_str() {
"http" => HTTPWalletCommAdapter::new(),
"file" => FileWalletCommAdapter::new(),
"keybase" => KeybaseWalletCommAdapter::new(),
"self" => NullWalletCommAdapter::new(),
_ => NullWalletCommAdapter::new(),
};

View file

@ -197,7 +197,7 @@ pub fn parse_listen_args(
config: &mut WalletConfig,
g_args: &mut command::GlobalArgs,
args: &ArgMatches,
) -> Result<(), Error> {
) -> Result<command::ListenArgs, Error> {
// listen args
let pass = match g_args.password.clone() {
Some(p) => Some(p.to_owned()),
@ -207,7 +207,10 @@ pub fn parse_listen_args(
if let Some(port) = args.value_of("port") {
config.api_listen_port = port.parse().unwrap();
}
Ok(())
let method = parse_required(args, "method")?;
Ok(command::ListenArgs {
method: method.to_owned(),
})
}
pub fn parse_account_args(account_args: &ArgMatches) -> Result<command::AccountArgs, Error> {