-
Notifications
You must be signed in to change notification settings - Fork 554
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/multicall #1077
feat/multicall #1077
Conversation
brownie/network/multicall.py
Outdated
queue = [] | ||
yield partial(Caller, queue) | ||
|
||
multicall2 = Contract("0x5BA1e12693Dc8F9c48aAD8770482f4739bEeD696") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: make this a default kwarg for multicall so it's not hard-coded in the framework?
@contextmanager
def multicall(block_identifier=None, multicall2_address="0x5BA1e12693Dc8F9c48aAD8770482f4739bEeD696"):
...
multicall2 = Contract(multicall2_address)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking to make it even more flexible:
- live network => use
eth_call
code override to make it available pre-deploy - dev network => seamlessly deploy a contract and cache it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think eth_call
code override should be optional as some providers don't support them (e.g. infura)
Allows users to specify the location of the multicall2 contract they intend to use. Useful on different networks (development and live). Added Multicall2 abi to data/interfaces to allow for initializing multicall contract via abi. Reordered definitions and add type info.
add Multicall2.sol to brownie test project add multicall2 test fixture
Handled in #1125 |
What I did
Added multicall context manager I initially outlined here.
Related issue: #1011
How I did it
I used Multicall2 and
wrapt
library to replace results with proxies which are updated with actual values as soon as they are available.Special thanks to @nymmrx for help with value wrappers.
How to verify it
Here is a complex example:
Checklist