implemented eth_call

This commit is contained in:
debris
2016-03-19 21:37:11 +01:00
parent bc5df9c908
commit 521f2a1433
6 changed files with 69 additions and 1 deletions

View File

@@ -397,6 +397,26 @@ impl<C, S, A, M, EM> Eth for EthClient<C, S, A, M, EM>
}
})
}
fn call(&self, params: Params) -> Result<Value, Error> {
from_params::<(TransactionRequest, BlockNumber)>(params)
.and_then(|(transaction_request, _block_number)| {
let accounts = take_weak!(self.accounts);
match accounts.account_secret(&transaction_request.from) {
Ok(secret) => {
let client = take_weak!(self.client);
let transaction: EthTransaction = transaction_request.into();
let signed_transaction = transaction.sign(&secret);
to_value(&client.call(&signed_transaction)
.map(|e| Bytes::new(e.output))
.unwrap_or(Bytes::default()))
},
Err(_) => { to_value(&Bytes::default()) }
}
})
}
}
/// Eth filter rpc implementation.