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

feat: add rpc namespace #994

Merged
merged 3 commits into from
Jul 10, 2024
Merged

Conversation

SozinM
Copy link
Contributor

@SozinM SozinM commented Jun 29, 2024

Motivation

Adds RPC namespace for #926

Considerations

I took the type from reth rpc-types, so it could be migrated to alloy crate later.

The name of the crate came up a little bit silly rpc-types-rpc, so maybe better to rename it to rpc-types-namespaces, or something like that

Both anvil and get do not support rpc_methods, so I did not implement a test to cover the call itself, but the structure is tested on the mock data.

Solution

Usage example. Replace RETH_ENDPOINT with endpoint

use alloy_provider::{ext::RpcApi, ProviderBuilder};


#[tokio::main]
async fn main() {
    let url = String::from("RETH_ENDPOINT");
    let node_url = url::Url::parse(url.as_str()).unwrap();
    let provider = ProviderBuilder::new().on_http(node_url);



    let result = provider
        .rpc_modules()
        .await
        .unwrap();
    println!("{:#?}", result);
}

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

@SozinM SozinM changed the title Add rpc namespace feat: add rpc namespace Jun 29, 2024
@SozinM SozinM marked this pull request as ready for review June 29, 2024 18:05
@SozinM SozinM force-pushed the feature/rpc-namespace branch from 8bebeca to 7ce869b Compare June 29, 2024 18:09
@SozinM SozinM force-pushed the feature/rpc-namespace branch from 7ce869b to 17a5ddf Compare June 29, 2024 18:12
@SozinM
Copy link
Contributor Author

SozinM commented Jul 2, 2024

@mattsse hi!
Feel free to review it when you have spare time :)

@SozinM
Copy link
Contributor Author

SozinM commented Jul 10, 2024

@DaniPopes, maybe you want to take a look until it's gone stale?

Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

sorry about the delay.

let's just move this type to the rpc-types crate, not worth having a standalone crate just for this.

Copy link
Member

Choose a reason for hiding this comment

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

I think this crate is a bit too much,

this only consists of 1 type which we can just move to the rpc-types crate, it's only one type.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed!
One comment is that I didn't hide mod rpc behind the feature flag, because it will cause serde crate to be unused. If the feature flag is needed I could dig deeper into it.

Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

lgtm

@mattsse mattsse merged commit 617aec5 into alloy-rs:main Jul 10, 2024
22 checks passed
ben186 pushed a commit to ben186/alloy that referenced this pull request Jul 27, 2024
* Implement Rpc namespace

* Review comment

* Dependency fix

---------

Co-authored-by: Mikhail Sozin <[email protected]>
j75689 pushed a commit to bnb-chain/alloy that referenced this pull request Aug 1, 2024
* Implement Rpc namespace

* Review comment

* Dependency fix

---------

Co-authored-by: Mikhail Sozin <[email protected]>
@SozinM SozinM deleted the feature/rpc-namespace branch September 30, 2024 08:58
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