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: eth_call builder #645

Merged
merged 15 commits into from
May 1, 2024
Merged

feat: eth_call builder #645

merged 15 commits into from
May 1, 2024

Conversation

prestwich
Copy link
Member

Depends on #644

Motivation

Partially addresses #613

Solution

  • Implement a basic builder returned by Provider::call that allows configuration of the
  • delete call_with_overrides
  • remove block arg from Provider::call

If we like the pattern we can apply it to the other rpc reqs that take BlockId as optional param

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

@prestwich prestwich added the enhancement New feature or request label Apr 27, 2024
@prestwich prestwich self-assigned this Apr 27, 2024
@prestwich
Copy link
Member Author

cc @DaniPopes i don't love the amount of lifetime complexity i added to the call with decoder, but it should be invisible to users pretty much all the time i think?

@prestwich prestwich force-pushed the prestwich/eth-call-builder branch from bdab339 to 3fef547 Compare April 28, 2024 12:32
@prestwich
Copy link
Member Author

Notes on why this level of complexity:

  • 'client - we use ClientRef instead of WeakClient because IntoFuture impl would otherwise require upgrading inside into_future() in an awkward way
  • 'req - we borrow the request so that it can be reused for concurrent calls with other overrides, and for sending. this is also consistent with the provider interface
  • 'state - we borrow the state to avoid cloning it, as the clone may be expensive. this also allows it to be used with other concurrent calls. Future we may want to allow state to be a RawValue so that users can share it between calls and also avoid serializing it each time
  • 'coder - we borrow the coder to be consistent with behavior before this PR

@DaniPopes DaniPopes changed the title [Feature] eth_call builder feat: eth_call builder Apr 28, 2024
@prestwich
Copy link
Member Author

okay I have removed the 'client lifetime by making an intermediate future type that handles upgrading a WeakClient

Copy link
Member

@onbjerg onbjerg left a comment

Choose a reason for hiding this comment

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

lgtm, nicer than having call_with_overrides

crates/provider/src/provider/trait.rs Show resolved Hide resolved
@onbjerg
Copy link
Member

onbjerg commented Apr 30, 2024

beautiful

@prestwich prestwich merged commit 595f348 into main May 1, 2024
18 checks passed
@prestwich prestwich deleted the prestwich/eth-call-builder branch May 1, 2024 04:48
@prestwich prestwich mentioned this pull request May 3, 2024
3 tasks
ben186 pushed a commit to ben186/alloy that referenced this pull request Jul 27, 2024
* feature: eth_call via builder pattern

* fix: ethcall and ethcallfut in contract

* lint: clippy

* fix: must_use

* fix: must_use again

* refactor: borrow hashmap instead of cloning

* refactor: use cow and make non-optional

* lint: clippy false positive

* refactor: rename to eth_call

* refactor: remove a lifetime

* fix: useless match

* fix: poll_running instead of yielding forever

* refactor: poll_unpin

* doc: example and aliases

* doc: add a header to the example
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants