mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-02-03 19:45:20 -05:00
feat(rpc): impl accounts handler (#1135)
This commit is contained in:
@@ -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`
|
||||
|
||||
@@ -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> {
|
||||
|
||||
Reference in New Issue
Block a user