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(provider): make Caller EthCall specific #1620

Merged
merged 6 commits into from
Nov 5, 2024
Merged

Conversation

yash-atreya
Copy link
Member

Motivation

Closes #1471

Solution

  • Change the data and overrides fields in EthCallParams to be Cow.
  • Accept EthCallParams as arg in Caller.call(&self, method, params: EthCallParams<'_, N>).
  • ProviderCall should be used over EthCallParams

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

Comment on lines 32 to 36
fn call(
&self,
method: Cow<'static, str>,
params: Params,
) -> TransportResult<ProviderCall<T, serde_json::Value, Resp>> {
params: EthCallParams<'_, N>,
) -> TransportResult<ProviderCall<T, EthCallParams<'static, N>, Resp>> {
Copy link
Member

@klkvr klkvr Nov 5, 2024

Choose a reason for hiding this comment

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

would be nice to have either enum for method or just separate call/estimate_gas methods on trait so that custom implementations don't have to match on strings

Comment on lines 14 to +18
pub struct EthCallParams<'req, N: Network> {
data: &'req N::TransactionRequest,
data: Cow<'req, N::TransactionRequest>,
block: Option<BlockId>,
overrides: Option<&'req StateOverride>,
overrides: Option<Cow<'req, StateOverride>>,
}
Copy link
Member

Choose a reason for hiding this comment

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

curious what's usecase for Cow and builder methods here? I'd expect that this wouldn always be constructed through EthCall builders and both users and custom Caller implementations wouldn't need to constructor/change this type manually?

Copy link
Member

@klkvr klkvr left a comment

Choose a reason for hiding this comment

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

approach lgtm, this is already pretty useful as is, just left a couple comments

@mattsse mattsse merged commit 91bba27 into main Nov 5, 2024
26 checks passed
@mattsse mattsse deleted the yash/caller-eth-call branch November 5, 2024 17:42
Resp: RpcReturn,
{
/// Method that needs to be implemented to convert to a `ProviderCall`.
///
/// This method handles serialization of the params and sends the request to relevant data
/// source and returns a `ProviderCall`.
/// This method sends the request to relevant data source and returns a `ProviderCall`.
fn call(
Copy link
Member

Choose a reason for hiding this comment

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

@yash-atreya could we make Caller::call always output Bytes and estimate_gas would output u64? Resp generic might be tricky to deal with in custom implementations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

provider: make Caller more EthCall specific
3 participants