-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
send_tx bug: RequestValidation error #141
Comments
After doing some digging, I found out that the params method in send_tx is actually creating an array during serialising the parameters. fn params(&self) -> Result<serde_json::Value, io::Error> {
Ok(json!([
common::serialize_signed_transaction(&self.signed_transaction)?,
self.wait_until
]))
} Which is a problem for the RpcServer, see here and below: impl RpcRequest for RpcSendTransactionRequest {
fn parse(value: Value) -> Result<Self, RpcParseError> {
let tx_request = Params::new(value)
.try_singleton(|value| {
Ok(RpcSendTransactionRequest {
signed_transaction: decode_signed_transaction(value)?,
// will be ignored in `broadcast_tx_async`, `broadcast_tx_commit`
wait_until: Default::default(),
})
})
.try_pair(|_: String, _: String| {
// Here, we restrict serde parsing object from the array
// `wait_until` is a new feature supported only in object
Err(RpcParseError(
"Unable to parse send request: too many params passed".to_string(),
))
})
.unwrap_or_parse()?;
Ok(tx_request)
}
} As you can see arrays are rejected and the error I see is actually thrown here. I could locally fix this with below changes to the params function in send_tx method in rpc client: fn params(&self) -> Result<serde_json::Value, io::Error> {
Ok(json!({
"signed_tx_base64": common::serialize_signed_transaction(&self.signed_transaction)?,
"wait_until": self.wait_until
}))
} Here is a PR for the fix - #142 |
Problem:
When running the send_tx method, I see the below error:
Steps to reproduce:
Run the send_tx example using
cargo run --example send_tx
The text was updated successfully, but these errors were encountered: