Alias for personal_sendTransaction (#4554)

This commit is contained in:
Tomasz Drwięga 2017-02-15 16:57:27 +01:00 committed by Gav Wood
parent 494a0de1e2
commit 895298fc49
3 changed files with 21 additions and 2 deletions

View File

@ -127,4 +127,9 @@ impl<D: Dispatcher + 'static> Personal for PersonalClient<D> {
}) })
.boxed() .boxed()
} }
fn sign_and_send_transaction(&self, meta: Metadata, request: TransactionRequest, password: String) -> BoxFuture<RpcH256, Error> {
warn!("Using deprecated personal_signAndSendTransaction, use personal_sendTransaction instead.");
self.send_transaction(meta, request, password)
}
} }

View File

@ -117,16 +117,25 @@ fn sign_and_send_transaction_with_invalid_password() {
assert_eq!(tester.io.handle_request_sync(request.as_ref()), Some(response.into())); assert_eq!(tester.io.handle_request_sync(request.as_ref()), Some(response.into()));
} }
#[test]
fn send_transaction() {
sign_and_send_test("personal_sendTransaction");
}
#[test] #[test]
fn sign_and_send_transaction() { fn sign_and_send_transaction() {
sign_and_send_test("personal_signAndSendTransaction");
}
fn sign_and_send_test(method: &str) {
let tester = setup(); let tester = setup();
let address = tester.accounts.new_account("password123").unwrap(); let address = tester.accounts.new_account("password123").unwrap();
let request = r#"{ let request = r#"{
"jsonrpc": "2.0", "jsonrpc": "2.0",
"method": "personal_sendTransaction", "method": ""#.to_owned() + method + r#"",
"params": [{ "params": [{
"from": ""#.to_owned() + format!("0x{:?}", address).as_ref() + r#"", "from": ""# + format!("0x{:?}", address).as_ref() + r#"",
"to": "0xd46e8dd67c5d32be8058bb8eb970870f07244567", "to": "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
"gas": "0x76c0", "gas": "0x76c0",
"gasPrice": "0x9184e72a000", "gasPrice": "0x9184e72a000",

View File

@ -42,5 +42,10 @@ build_rpc_trait! {
/// Sends transaction and signs it in single call. The account is not unlocked in such case. /// Sends transaction and signs it in single call. The account is not unlocked in such case.
#[rpc(meta, name = "personal_sendTransaction")] #[rpc(meta, name = "personal_sendTransaction")]
fn send_transaction(&self, Self::Metadata, TransactionRequest, String) -> BoxFuture<H256, Error>; fn send_transaction(&self, Self::Metadata, TransactionRequest, String) -> BoxFuture<H256, Error>;
/// Deprecated alias for `personal_sendTransaction`.
#[rpc(meta, name = "personal_signAndSendTransaction")]
fn sign_and_send_transaction(&self, Self::Metadata, TransactionRequest, String) -> BoxFuture<H256, Error>;
} }
} }