fix method not found jsonrpc error codes
This commit is contained in:
parent
6be05bab4b
commit
10a8620044
@ -1314,7 +1314,7 @@ impl Web3ProxyApp {
|
|||||||
| "shh_post"
|
| "shh_post"
|
||||||
| "shh_uninstallFilter"
|
| "shh_uninstallFilter"
|
||||||
| "shh_version") => {
|
| "shh_version") => {
|
||||||
return Err(Web3ProxyError::MethodNotImplemented(format!(
|
return Err(Web3ProxyError::MethodNotFound(format!(
|
||||||
"the method {} does not exist/is not available",
|
"the method {} does not exist/is not available",
|
||||||
method
|
method
|
||||||
).into()));
|
).into()));
|
||||||
@ -1327,7 +1327,7 @@ impl Web3ProxyApp {
|
|||||||
| "eth_newPendingTransactionFilter"
|
| "eth_newPendingTransactionFilter"
|
||||||
| "eth_pollSubscriptions"
|
| "eth_pollSubscriptions"
|
||||||
| "eth_uninstallFilter") => {
|
| "eth_uninstallFilter") => {
|
||||||
return Err(Web3ProxyError::MethodNotImplemented(format!(
|
return Err(Web3ProxyError::MethodNotFound(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()));
|
||||||
|
@ -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::MethodNotImplemented(
|
return Err(Web3ProxyError::MethodNotFound(
|
||||||
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)]
|
||||||
MethodNotImplemented(Cow<'static, str>),
|
MethodNotFound(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)]
|
||||||
@ -618,6 +618,20 @@ impl Web3ProxyError {
|
|||||||
// TODO: do this without clone? the Arc needed it though
|
// TODO: do this without clone? the Arc needed it though
|
||||||
(StatusCode::OK, jsonrpc_error_data.clone())
|
(StatusCode::OK, jsonrpc_error_data.clone())
|
||||||
}
|
}
|
||||||
|
Self::MethodNotFound(method) => {
|
||||||
|
warn!("MethodNotFound: {}", method);
|
||||||
|
(
|
||||||
|
StatusCode::OK,
|
||||||
|
JsonRpcErrorData {
|
||||||
|
message: "Method not found".into(),
|
||||||
|
code: -32601,
|
||||||
|
data: Some(json!({
|
||||||
|
"method": method,
|
||||||
|
"extra": "contact us if you need this",
|
||||||
|
})),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
Self::MsgPackEncode(err) => {
|
Self::MsgPackEncode(err) => {
|
||||||
warn!(?err, "MsgPackEncode");
|
warn!(?err, "MsgPackEncode");
|
||||||
(
|
(
|
||||||
@ -751,20 +765,6 @@ impl Web3ProxyError {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Self::MethodNotImplemented(method) => {
|
|
||||||
warn!("NotImplemented: {}", method);
|
|
||||||
(
|
|
||||||
StatusCode::OK,
|
|
||||||
JsonRpcErrorData {
|
|
||||||
message: "Method not found".into(),
|
|
||||||
code: -32601,
|
|
||||||
data: Some(json!({
|
|
||||||
"method": method,
|
|
||||||
"extra": "contact us if you need this",
|
|
||||||
})),
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
Self::JsonRpcResponse(response_enum) => {
|
Self::JsonRpcResponse(response_enum) => {
|
||||||
// TODO: shame we have to clone, but its an Arc so its not terrible
|
// TODO: shame we have to clone, but its an Arc so its not terrible
|
||||||
return (StatusCode::OK, response_enum.clone());
|
return (StatusCode::OK, response_enum.clone());
|
||||||
|
@ -129,9 +129,7 @@ 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::MethodNotImplemented(
|
Err(Web3ProxyError::MethodNotFound("rpc_keys_delete".into()))
|
||||||
"rpc_keys_delete".into(),
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// the JSON input to the `rpc_keys_management` handler.
|
/// the JSON input to the `rpc_keys_management` handler.
|
||||||
|
Loading…
Reference in New Issue
Block a user