2022-06-05 22:58:47 +03:00
|
|
|
use axum::{http::StatusCode, response::IntoResponse, Extension, Json};
|
|
|
|
use std::sync::Arc;
|
|
|
|
|
2022-06-16 05:53:37 +03:00
|
|
|
use super::errors::handle_anyhow_error;
|
|
|
|
use crate::{app::Web3ProxyApp, jsonrpc::JsonRpcRequestEnum};
|
|
|
|
|
2022-06-05 22:58:47 +03:00
|
|
|
pub async fn proxy_web3_rpc(
|
|
|
|
payload: Json<JsonRpcRequestEnum>,
|
|
|
|
app: Extension<Arc<Web3ProxyApp>>,
|
|
|
|
) -> impl IntoResponse {
|
2022-06-16 23:57:48 +03:00
|
|
|
match app.proxy_web3_rpc(payload.0).await {
|
2022-06-05 22:58:47 +03:00
|
|
|
Ok(response) => (StatusCode::OK, Json(&response)).into_response(),
|
|
|
|
Err(err) => handle_anyhow_error(err, None).await.into_response(),
|
|
|
|
}
|
|
|
|
}
|