(module: &mut RpcModule<Context>)
| 41 | } |
| 42 | |
| 43 | pub(crate) fn eth_get_balance(module: &mut RpcModule<Context>) -> Result<()> { |
| 44 | module.register_async_method("eth_getBalance", move |params, blockchain| async move { |
| 45 | let key = params.one::<Account>()?; |
| 46 | let block = blockchain |
| 47 | .lock() |
| 48 | .await |
| 49 | .get_current_block() |
| 50 | .map_err(|e| JsonRpseeError::Custom(e.to_string()))? |
| 51 | .number; |
| 52 | |
| 53 | let balance = blockchain |
| 54 | .lock() |
| 55 | .await |
| 56 | .accounts |
| 57 | .get_account_balance_by_block(&key, &BlockNumber(block)) |
| 58 | .map_err(|e| Error::Custom(e.to_string()))?; |
| 59 | |
| 60 | Ok(to_hex(balance)) |
| 61 | })?; |
| 62 | |
| 63 | Ok(()) |
| 64 | } |
| 65 | |
| 66 | pub(crate) fn eth_get_transaction_count(module: &mut RpcModule<Context>) -> Result<()> { |
| 67 | module.register_async_method("eth_getTransactionCount", |params, blockchain| async move { |
no test coverage detected