dynamic keys pickup
This commit is contained in:
@@ -340,10 +340,16 @@ impl<C, S: ?Sized, M, EM> Eth for EthClient<C, S, M, EM> where
|
||||
}
|
||||
}
|
||||
|
||||
fn accounts(&self, _: Params) -> Result<Value, Error> {
|
||||
fn accounts(&self, params: Params) -> Result<Value, Error> {
|
||||
try!(self.active());
|
||||
let store = take_weak!(self.accounts);
|
||||
to_value(&store.accounts().into_iter().map(Into::into).collect::<Vec<RpcH160>>())
|
||||
match params {
|
||||
Params::None => {
|
||||
let store = take_weak!(self.accounts);
|
||||
let accounts = try!(store.accounts().map_err(|_| Error::internal_error()));
|
||||
to_value(&accounts.into_iter().map(Into::into).collect::<Vec<RpcH160>>())
|
||||
},
|
||||
_ => Err(Error::invalid_params())
|
||||
}
|
||||
}
|
||||
|
||||
fn block_number(&self, params: Params) -> Result<Value, Error> {
|
||||
|
||||
@@ -62,10 +62,16 @@ impl<C: 'static, M: 'static> Personal for PersonalClient<C, M> where C: MiningBl
|
||||
.unwrap_or_else(|| to_value(&false))
|
||||
}
|
||||
|
||||
fn accounts(&self, _: Params) -> Result<Value, Error> {
|
||||
fn accounts(&self, params: Params) -> Result<Value, Error> {
|
||||
try!(self.active());
|
||||
let store = take_weak!(self.accounts);
|
||||
to_value(&store.accounts().into_iter().map(Into::into).collect::<Vec<RpcH160>>())
|
||||
match params {
|
||||
Params::None => {
|
||||
let store = take_weak!(self.accounts);
|
||||
let accounts = try!(store.accounts().map_err(|_| Error::internal_error()));
|
||||
to_value(&accounts.into_iter().map(Into::into).collect::<Vec<RpcH160>>())
|
||||
},
|
||||
_ => Err(Error::invalid_params())
|
||||
}
|
||||
}
|
||||
|
||||
fn new_account(&self, params: Params) -> Result<Value, Error> {
|
||||
|
||||
@@ -110,7 +110,7 @@ fn new_account() {
|
||||
|
||||
let res = tester.io.handle_request(request);
|
||||
|
||||
let accounts = tester.accounts.accounts();
|
||||
let accounts = tester.accounts.accounts().unwrap();
|
||||
assert_eq!(accounts.len(), 1);
|
||||
let address = accounts[0];
|
||||
let response = r#"{"jsonrpc":"2.0","result":""#.to_owned() + format!("0x{:?}", address).as_ref() + r#"","id":1}"#;
|
||||
@@ -122,7 +122,7 @@ fn new_account() {
|
||||
fn should_be_able_to_get_account_info() {
|
||||
let tester = setup(None);
|
||||
tester.accounts.new_account("").unwrap();
|
||||
let accounts = tester.accounts.accounts();
|
||||
let accounts = tester.accounts.accounts().unwrap();
|
||||
assert_eq!(accounts.len(), 1);
|
||||
let address = accounts[0];
|
||||
|
||||
@@ -140,7 +140,7 @@ fn should_be_able_to_get_account_info() {
|
||||
fn should_be_able_to_set_name() {
|
||||
let tester = setup(None);
|
||||
tester.accounts.new_account("").unwrap();
|
||||
let accounts = tester.accounts.accounts();
|
||||
let accounts = tester.accounts.accounts().unwrap();
|
||||
assert_eq!(accounts.len(), 1);
|
||||
let address = accounts[0];
|
||||
|
||||
@@ -161,7 +161,7 @@ fn should_be_able_to_set_name() {
|
||||
fn should_be_able_to_set_meta() {
|
||||
let tester = setup(None);
|
||||
tester.accounts.new_account("").unwrap();
|
||||
let accounts = tester.accounts.accounts();
|
||||
let accounts = tester.accounts.accounts().unwrap();
|
||||
assert_eq!(accounts.len(), 1);
|
||||
let address = accounts[0];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user