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

[Bug] Fix unknown/unused cfgs #416

Closed
DaniPopes opened this issue Mar 28, 2024 · 6 comments · Fixed by #419
Closed

[Bug] Fix unknown/unused cfgs #416

DaniPopes opened this issue Mar 28, 2024 · 6 comments · Fixed by #419
Labels
bug Something isn't working

Comments

@DaniPopes
Copy link
Member

DaniPopes commented Mar 28, 2024

Component

consensus, eips, genesis

What version of Alloy are you on?

No response

Operating System

None

Describe the bug

cargo check -Zcheck-cfg reports a lot of unexpected cfg values. Consider also adding this to CI.

@DaniPopes DaniPopes added the bug Something isn't working label Mar 28, 2024
@developeruche
Copy link
Contributor

Additional context:

warning: unexpected cfg condition name: target
--> crates/rpc-client/src/builtin.rs:78:27
|
78 | #[cfg(all(not(target = "wasm"), feature = "was"))]

warning: unexpected cfg condition value: reqwest
--> crates/provider/src/builder.rs:228:11
|
228 | #[cfg(feature = "request")]

warning: unexpected cfg condition value: hyper
--> crates/provider/src/builder.rs:238:11
|
238 | #[cfg(feature = "hyper")]

@developeruche
Copy link
Contributor

developeruche commented Mar 28, 2024

hey @DaniPopes, on enabling the "reqwest" feature

 #[cfg(feature = "reqwest")]
    pub fn reqwest_http(self, url: url::Url) -> TransportResult<RpcClient<L::Service>>
    where
        L: Layer<alloy_transport_http::Http<reqwest::Client>>,
        L::Service: Transport,
    {
        let transport = alloy_transport_http::Http::new(url);
        let is_local = transport.guess_local();

        Ok(self.transport(transport, is_local))
    }

I am get this error;

crates/provider/src/builder.rs:236:27
|
236 | Ok(self.on_client(client))
| --------- ^^^^^^ expected RpcClient<BoxTransport>, found RpcClient<Http<Client>>
| |
| arguments to this method are incorrect
|
= note: expected struct RpcClient<BoxTransport>
found struct RpcClient<alloy_transport_http::Http<Client>>

Could you help me with a reference to creating an RpcClient using the Http as the transport layer

cc: @DaniPopes

@DaniPopes
Copy link
Member Author

cc @yash-atreya

@yash-atreya
Copy link
Member

yash-atreya commented Mar 28, 2024

@developeruche

Could you help me with a reference to creating an RpcClient using the Http as the transport layer

If you've enabled the reqwest feature on alloy-rpc-client then you can do the following to instantiate a RpcClient<Http<Client>>:

let client = RpcClient<Http<Client>>::new_http(URL);

Also can you please share which version of alloy you're using i.e the commit hash you're pinned to?

@yash-atreya
Copy link
Member

yash-atreya commented Mar 28, 2024

hey @DaniPopes, on enabling the "reqwest" feature

 #[cfg(feature = "reqwest")]
    pub fn reqwest_http(self, url: url::Url) -> TransportResult<RpcClient<L::Service>>
    where
        L: Layer<alloy_transport_http::Http<reqwest::Client>>,
        L::Service: Transport,
    {
        let transport = alloy_transport_http::Http::new(url);
        let is_local = transport.guess_local();

        Ok(self.transport(transport, is_local))
    }

I am get this error;

crates/provider/src/builder.rs:236:27 | 236 | Ok(self.on_client(client)) | --------- ^^^^^^ expected RpcClient<BoxTransport>, found RpcClient<Http<Client>> | | | arguments to this method are incorrect | = note: expected struct RpcClient<BoxTransport> found struct RpcClient<alloy_transport_http::Http<Client>>

Could you help me with a reference to creating an RpcClient using the Http as the transport layer

cc: @DaniPopes

@developeruche Implemented a fix here: #419

@developeruche
Copy link
Contributor

hey @DaniPopes, on enabling the "reqwest" feature

 #[cfg(feature = "reqwest")]
    pub fn reqwest_http(self, url: url::Url) -> TransportResult<RpcClient<L::Service>>
    where
        L: Layer<alloy_transport_http::Http<reqwest::Client>>,
        L::Service: Transport,
    {
        let transport = alloy_transport_http::Http::new(url);
        let is_local = transport.guess_local();

        Ok(self.transport(transport, is_local))
    }

I am get this error;
crates/provider/src/builder.rs:236:27 | 236 | Ok(self.on_client(client)) | --------- ^^^^^^ expected RpcClient<BoxTransport>, found RpcClient<Http<Client>> | | | arguments to this method are incorrect | = note: expected struct RpcClient<BoxTransport> found struct RpcClient<alloy_transport_http::Http<Client>>
Could you help me with a reference to creating an RpcClient using the Http as the transport layer
cc: @DaniPopes

@developeruche Implemented a fix here: #419

Awesome 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants