Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Add more descriptive error when signing/decrypting using hw wallet.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomusdrw committed Aug 15, 2017
1 parent b9c1d0b commit 67a07ad
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions rpc/src/v1/helpers/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,10 @@ pub fn execute<D: Dispatcher + 'static>(
).boxed()
},
ConfirmationPayload::EthSignMessage(address, data) => {
if accounts.is_hardware_address(address) {
return future::err(errors::unsupported("Signing via hardware wallets is not supported.", None)).boxed();
}

let hash = eth_data_hash(data);
let res = signature(&accounts, address, hash, pass)
.map(|result| result
Expand All @@ -522,6 +526,10 @@ pub fn execute<D: Dispatcher + 'static>(
future::done(res).boxed()
},
ConfirmationPayload::Decrypt(address, data) => {
if accounts.is_hardware_address(address) {
return future::err(errors::unsupported("Decrypting via hardware wallets is not supported.", None)).boxed();
}

let res = decrypt(&accounts, address, data, pass)
.map(|result| result
.map(RpcBytes)
Expand Down
8 changes: 8 additions & 0 deletions rpc/src/v1/helpers/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ pub fn public_unsupported(details: Option<String>) -> Error {
}
}

pub fn unsupported<T: Into<String>>(msg: T, details: Option<T>) -> Error {
Error {
code: ErrorCode::ServerError(codes::UNSUPPORTED_REQUEST),
message: msg.into(),
data: details.map(Into::into).map(Value::String),
}
}

pub fn request_not_found() -> Error {
Error {
code: ErrorCode::ServerError(codes::REQUEST_NOT_FOUND),
Expand Down

0 comments on commit 67a07ad

Please sign in to comment.