-
Notifications
You must be signed in to change notification settings - Fork 589
Resolve beacon from beacon-proxy #2139
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
Conversation
🦋 Changeset detectedLatest commit: 29e50ba The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #2139 +/- ##
==========================================
- Coverage 67.47% 67.46% -0.02%
==========================================
Files 292 291 -1
Lines 11017 11021 +4
Branches 1512 1513 +1
==========================================
+ Hits 7434 7435 +1
- Misses 2961 2963 +2
- Partials 622 623 +1 ☔ View full report in Codecov by Sentry. |
if (beacon && beacon !== constants.AddressZero) { | ||
// In case of a BeaconProxy, it is setup as BeaconProxy --> Beacon --> Implementation | ||
// Hence we replace the proxy address with Beacon address, and continue further resolving below | ||
address = beacon as string; |
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.
why do you need as string
here?
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.
fixed
} | ||
|
||
// check other proxy types | ||
const beacon = await getBeaconFromStorageSlot(address, provider); // if the contract is BeaconProxy |
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.
would be nice to parallelize this with fetchBytecode
- you can promise all both
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.
Updated
provider: providers.Provider, | ||
): Promise<{ address: string; bytecode: string }> { | ||
const bytecode = await fetchBytecode(address, provider); | ||
const fetched = await Promise.all([ |
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.
its cleaner to destructure here instead of fetched[0]
to access the values, you can do
const [bytecode, beacon] = await Promise.all(....);
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.
lg
Check if the contract is a beacon-proxy, resolve beacon contract from beacon-slot, and then find out implementation address from beacon.
Ref: https://eips.ethereum.org/EIPS/eip-1967#beacon-contract-address