Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

kumaryash90
Copy link
Member

@kumaryash90 kumaryash90 commented Jan 10, 2024

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

@kumaryash90 kumaryash90 requested a review from a team January 10, 2024 12:26
Copy link

changeset-bot bot commented Jan 10, 2024

🦋 Changeset detected

Latest commit: 29e50ba

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
@thirdweb-dev/sdk Patch
thirdweb Patch
@thirdweb-dev/react-core Patch
@thirdweb-dev/react-native Patch
@thirdweb-dev/react Patch
@thirdweb-dev/unity-js-bridge Patch
@thirdweb-dev/wallets Patch
@thirdweb-dev/auth Patch
@thirdweb-dev/react-native-compat Patch

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

Copy link

codecov bot commented Jan 10, 2024

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (bbc2e09) 67.47% compared to head (29e50ba) 67.46%.
Report is 10 commits behind head on main.

Files Patch % Lines
...feature-detection/resolveContractUriFromAddress.ts 57.14% 2 Missing and 1 partial ⚠️
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.
📢 Have feedback on the report? Share it here.

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;
Copy link
Member

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?

Copy link
Member Author

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
Copy link
Member

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

Copy link
Member Author

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([
Copy link
Member

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(....);

Copy link
Member

@joaquim-verges joaquim-verges left a comment

Choose a reason for hiding this comment

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

lg

@kumaryash90 kumaryash90 enabled auto-merge January 10, 2024 20:46
@kumaryash90 kumaryash90 added this pull request to the merge queue Jan 10, 2024
Merged via the queue into main with commit 756d5cc Jan 10, 2024
@kumaryash90 kumaryash90 deleted the yash/resolve-beacon branch January 10, 2024 21:03
@github-actions github-actions bot mentioned this pull request Jan 10, 2024
jnsdls pushed a commit that referenced this pull request Jun 19, 2024
Fix nft detail page routing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants