cebe8ed1ea
* wip * AsRef finally works like i wanted * actually return the block * start adding async trait * remove stale import * include id in the error response when possible * remove stale comments
29 lines
918 B
Rust
29 lines
918 B
Rust
use crate::app::Web3ProxyApp;
|
|
// use crate::frontend::errors::Web3ProxyError;
|
|
use ethers::providers::{JsonRpcClient, ProviderError};
|
|
use serde::{de::DeserializeOwned, Serialize};
|
|
use std::fmt::Debug;
|
|
use std::sync::Arc;
|
|
|
|
/// use the app as an ether's JsonRpcClient
|
|
#[derive(Debug)]
|
|
struct Web3ProxyAppClient(Arc<Web3ProxyApp>);
|
|
|
|
#[async_trait::async_trait]
|
|
impl JsonRpcClient for Web3ProxyAppClient {
|
|
type Error = ProviderError;
|
|
|
|
async fn request<T, R>(&self, method: &str, params: T) -> Result<R, Self::Error>
|
|
where
|
|
T: Debug + Serialize + Send + Sync,
|
|
R: DeserializeOwned + Send,
|
|
{
|
|
todo!("figure out traits");
|
|
// match self.0.internal_request(method, ¶ms).await {
|
|
// Ok(x) => Ok(x),
|
|
// Err(Web3ProxyError::EthersProvider(err)) => Err(err),
|
|
// Err(err) => Err(ProviderError::CustomError(format!("{}", err))),
|
|
// }
|
|
}
|
|
}
|