fix error code on method not implemented and error_response user_response bools
This commit is contained in:
parent
36eb520f84
commit
e0f700189b
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -7242,7 +7242,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "web3_proxy"
|
name = "web3_proxy"
|
||||||
version = "1.42.8"
|
version = "1.42.9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"arc-swap",
|
"arc-swap",
|
||||||
@ -7323,7 +7323,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "web3_proxy_cli"
|
name = "web3_proxy_cli"
|
||||||
version = "1.42.8"
|
version = "1.42.9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"env_logger",
|
"env_logger",
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "web3_proxy"
|
name = "web3_proxy"
|
||||||
version = "1.42.8"
|
version = "1.42.9"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
@ -1169,6 +1169,9 @@ impl Web3ProxyApp {
|
|||||||
request_metadata
|
request_metadata
|
||||||
.error_response
|
.error_response
|
||||||
.store(false, Ordering::Release);
|
.store(false, Ordering::Release);
|
||||||
|
request_metadata
|
||||||
|
.user_error_response
|
||||||
|
.store(false, Ordering::Release);
|
||||||
|
|
||||||
(StatusCode::OK, response_data)
|
(StatusCode::OK, response_data)
|
||||||
}
|
}
|
||||||
@ -1176,12 +1179,18 @@ impl Web3ProxyApp {
|
|||||||
request_metadata
|
request_metadata
|
||||||
.error_response
|
.error_response
|
||||||
.store(false, Ordering::Release);
|
.store(false, Ordering::Release);
|
||||||
|
request_metadata
|
||||||
|
.user_error_response
|
||||||
|
.store(false, Ordering::Release);
|
||||||
|
|
||||||
err.as_response_parts()
|
err.as_response_parts()
|
||||||
}
|
}
|
||||||
Err(Web3ProxyError::JsonRpcResponse(response_data)) => {
|
Err(Web3ProxyError::JsonRpcResponse(response_data)) => {
|
||||||
request_metadata
|
request_metadata
|
||||||
.error_response
|
.error_response
|
||||||
|
.store(false, Ordering::Release);
|
||||||
|
request_metadata
|
||||||
|
.user_error_response
|
||||||
.store(response_data.is_error(), Ordering::Release);
|
.store(response_data.is_error(), Ordering::Release);
|
||||||
|
|
||||||
(StatusCode::OK, response_data)
|
(StatusCode::OK, response_data)
|
||||||
@ -1198,6 +1207,9 @@ impl Web3ProxyApp {
|
|||||||
request_metadata
|
request_metadata
|
||||||
.error_response
|
.error_response
|
||||||
.store(true, Ordering::Release);
|
.store(true, Ordering::Release);
|
||||||
|
request_metadata
|
||||||
|
.user_error_response
|
||||||
|
.store(false, Ordering::Release);
|
||||||
|
|
||||||
err.as_response_parts()
|
err.as_response_parts()
|
||||||
}
|
}
|
||||||
@ -1302,12 +1314,10 @@ impl Web3ProxyApp {
|
|||||||
| "shh_post"
|
| "shh_post"
|
||||||
| "shh_uninstallFilter"
|
| "shh_uninstallFilter"
|
||||||
| "shh_version") => {
|
| "shh_version") => {
|
||||||
// i don't think we will ever support these methods. maybe do Forbidden?
|
return Err(Web3ProxyError::MethodNotImplemented(format!(
|
||||||
// TODO: what error code?
|
|
||||||
JsonRpcErrorData::from(format!(
|
|
||||||
"the method {} does not exist/is not available",
|
"the method {} does not exist/is not available",
|
||||||
method
|
method
|
||||||
)).into()
|
).into()));
|
||||||
}
|
}
|
||||||
// TODO: implement these commands
|
// TODO: implement these commands
|
||||||
method @ ("eth_getFilterChanges"
|
method @ ("eth_getFilterChanges"
|
||||||
@ -1317,13 +1327,10 @@ impl Web3ProxyApp {
|
|||||||
| "eth_newPendingTransactionFilter"
|
| "eth_newPendingTransactionFilter"
|
||||||
| "eth_pollSubscriptions"
|
| "eth_pollSubscriptions"
|
||||||
| "eth_uninstallFilter") => {
|
| "eth_uninstallFilter") => {
|
||||||
// TODO: unsupported command stat. use the count to prioritize new features
|
return Err(Web3ProxyError::MethodNotImplemented(format!(
|
||||||
// TODO: what error code?
|
|
||||||
JsonRpcErrorData::from(format!(
|
|
||||||
"the method {} is not yet implemented. contact us if you need this",
|
"the method {} is not yet implemented. contact us if you need this",
|
||||||
method
|
method
|
||||||
))
|
).into()));
|
||||||
.into()
|
|
||||||
}
|
}
|
||||||
method @ ("eth_sendUserOperation"
|
method @ ("eth_sendUserOperation"
|
||||||
| "eth_estimateUserOperationGas"
|
| "eth_estimateUserOperationGas"
|
||||||
|
@ -125,7 +125,7 @@ impl Web3ProxyApp {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// TODO: make sure this gets a CU cost of unimplemented instead of the normal eth_subscribe cost?
|
// TODO: make sure this gets a CU cost of unimplemented instead of the normal eth_subscribe cost?
|
||||||
return Err(Web3ProxyError::NotImplemented(
|
return Err(Web3ProxyError::MethodNotImplemented(
|
||||||
subscribe_to.to_owned().into(),
|
subscribe_to.to_owned().into(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,7 @@ pub enum Web3ProxyError {
|
|||||||
NotFound,
|
NotFound,
|
||||||
#[error(ignore)]
|
#[error(ignore)]
|
||||||
#[from(ignore)]
|
#[from(ignore)]
|
||||||
NotImplemented(Cow<'static, str>),
|
MethodNotImplemented(Cow<'static, str>),
|
||||||
NoVolatileRedisDatabase,
|
NoVolatileRedisDatabase,
|
||||||
/// make it easy to skip caching large results
|
/// make it easy to skip caching large results
|
||||||
#[error(ignore)]
|
#[error(ignore)]
|
||||||
@ -751,18 +751,17 @@ impl Web3ProxyError {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Self::NotImplemented(msg) => {
|
Self::MethodNotImplemented(method) => {
|
||||||
warn!("NotImplemented: {}", msg);
|
warn!("NotImplemented: {}", method);
|
||||||
(
|
(
|
||||||
StatusCode::NOT_IMPLEMENTED,
|
StatusCode::OK,
|
||||||
JsonRpcErrorData {
|
JsonRpcErrorData {
|
||||||
message: format!(
|
message: "Method not found".into(),
|
||||||
"{} is not yet implemented. contact us if you need this",
|
code: -32601,
|
||||||
msg
|
data: Some(json!({
|
||||||
)
|
"method": method,
|
||||||
.into(),
|
"extra": "contact us if you need this",
|
||||||
code: StatusCode::NOT_IMPLEMENTED.as_u16().into(),
|
})),
|
||||||
data: None,
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,9 @@ pub async fn rpc_keys_delete(
|
|||||||
let _user = app.bearer_is_authorized(bearer).await?;
|
let _user = app.bearer_is_authorized(bearer).await?;
|
||||||
|
|
||||||
// TODO: think about how cascading deletes and billing should work
|
// TODO: think about how cascading deletes and billing should work
|
||||||
Err(Web3ProxyError::NotImplemented("rpc_keys_delete".into()))
|
Err(Web3ProxyError::MethodNotImplemented(
|
||||||
|
"rpc_keys_delete".into(),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// the JSON input to the `rpc_keys_management` handler.
|
/// the JSON input to the `rpc_keys_management` handler.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "web3_proxy_cli"
|
name = "web3_proxy_cli"
|
||||||
version = "1.42.8"
|
version = "1.42.9"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
default-run = "web3_proxy_cli"
|
default-run = "web3_proxy_cli"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user