feat(rpc): impl accounts handler (#1135)

This commit is contained in:
Matthias Seitz
2023-02-02 20:00:47 +01:00
committed by GitHub
parent d050e47a8a
commit 66aa94732b
2 changed files with 9 additions and 2 deletions

View File

@@ -7,7 +7,7 @@ use crate::eth::signer::EthSigner;
use async_trait::async_trait;
use reth_interfaces::Result;
use reth_network_api::NetworkInfo;
use reth_primitives::{ChainInfo, U64};
use reth_primitives::{Address, ChainInfo, U64};
use reth_provider::{BlockProvider, StateProviderFactory};
use reth_rpc_types::Transaction;
use reth_transaction_pool::TransactionPool;
@@ -29,6 +29,9 @@ pub trait EthApiSpec: Send + Sync {
/// Returns client chain info
fn chain_info(&self) -> Result<ChainInfo>;
/// Returns a list of addresses owned by client.
fn accounts(&self) -> Vec<Address>;
}
/// `Eth` API implementation.
@@ -93,6 +96,10 @@ where
fn chain_info(&self) -> Result<ChainInfo> {
self.client().chain_info()
}
fn accounts(&self) -> Vec<Address> {
self.inner.signers.iter().flat_map(|s| s.accounts()).collect()
}
}
/// Container type `EthApi`

View File

@@ -42,7 +42,7 @@ where
}
async fn accounts(&self) -> Result<Vec<Address>> {
Err(internal_rpc_err("unimplemented"))
Ok(EthApiSpec::accounts(self))
}
fn block_number(&self) -> Result<U256> {