Skip to content
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

fix(providers): some methods have invalid formats for parameters #103

Merged
merged 4 commits into from
Jan 11, 2024

Conversation

kallydev
Copy link
Contributor

@kallydev kallydev commented Jan 11, 2024

Motivation

The formats of parameters in the eth_sendRawTransaction, trace_block, and eth_getBlockReceipts methods are invalid.

- self.inner.prepare("trace_block", block).await
+ self.inner.prepare("trace_block", (block, )).await
{
  "method": "trace_block",
- "params": "latest",
+ "params": [
+   "latest"
+ ],
  "id": 0,
  "jsonrpc": "2.0"
}

Example

use alloy_providers::provider::{Provider, TempProvider};
use alloy_rpc_types::BlockNumberOrTag;
use anyhow::Result;

#[tokio::main]
async fn main() -> Result<()> {
    let provider = Provider::try_from("https://rpc.ankr.com/eth/")?;
    let traces = provider.trace_block(BlockNumberOrTag::Latest).await?;

    for trace in traces {
        println!("{:?}", trace)
    }

    Ok(())
}

Output

Error: Server returned an error response: ErrorPayload code -32600, message: "invalid request", contains payload: false

I'm currently working on implementing the eth_getBlockReceipts method for Anvil, but this issue is hindering my progress.

Solution

Corrected the wrong parameters format and added unit tests.

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

Copy link
Contributor

@Evalir Evalir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pending fmt

@Evalir Evalir merged commit 4db40b0 into alloy-rs:main Jan 11, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants