Skip to content

Commit

Permalink
fix: add patch for fetching tokenURI for ERC404 (#24029)
Browse files Browse the repository at this point in the history
## **Description**

We have been contacted about an NFT on linea mainnet that was not
showing properly on MM.
There is this core PR that has been merged to fix fetch behavior for
ERC404: MetaMask/core#4136

This PR adds a patch for the core fix.

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/24029?quickstart=1)

## **Related issues**

Fixes:
Related: MetaMask/core#4136

## **Manual testing steps**

1. Go to this page...
2.
3.

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->


https://github.com/MetaMask/metamask-extension/assets/10994169/cea457c3-87f2-4157-9efb-2ebc69176ac0


### **After**

<!-- [screenshots/recordings] -->



https://github.com/MetaMask/metamask-extension/assets/10994169/783d4292-c2c0-4ea9-9c7d-59dde88b4b3d


## **Pre-merge author checklist**

- [ ] I’ve followed [MetaMask Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
  • Loading branch information
sahar-fehri authored Apr 19, 2024
1 parent 7953710 commit af50f46
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 3 deletions.
16 changes: 16 additions & 0 deletions .yarn/patches/@metamask-assets-controllers-patch-0f46262fea.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
diff --git a/dist/Standards/NftStandards/ERC721/ERC721Standard.js b/dist/Standards/NftStandards/ERC721/ERC721Standard.js
index d9286b0c0e607d2857f3ee7dad40d13a6c11d7d7..4e12e4b590b1f34a66602d63035f1905917f8c93 100644
--- a/dist/Standards/NftStandards/ERC721/ERC721Standard.js
+++ b/dist/Standards/NftStandards/ERC721/ERC721Standard.js
@@ -66,7 +66,10 @@ class ERC721Standard {
const contract = new contracts_1.Contract(address, metamask_eth_abis_1.abiERC721, this.provider);
const supportsMetadata = yield this.contractSupportsMetadataInterface(address);
if (!supportsMetadata) {
- throw new Error('Contract does not support ERC721 metadata interface.');
+ // Do not throw error here, supporting Metadata interface is optional even though majority of ERC721 nfts do support it.
+ // This change is made because of instances of NFTs that are ERC404( mixed ERC20 / ERC721 implementation).
+ // As of today, ERC404 is unofficial but some people use it, the contract does not support Metadata interface, but it has the tokenURI() fct.
+ console.error('Contract does not support ERC721 metadata interface.');
}
return contract.tokenURI(tokenId);
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@
"@metamask/address-book-controller": "^3.1.7",
"@metamask/announcement-controller": "^6.1.0",
"@metamask/approval-controller": "^6.0.0",
"@metamask/assets-controllers": "patch:@metamask/assets-controllers@npm%3A26.0.0#~/.yarn/patches/@metamask-assets-controllers-npm-26.0.0-17c0e9432c.patch",
"@metamask/assets-controllers": "patch:@metamask/assets-controllers@patch%3A@metamask/assets-controllers@npm%253A26.0.0%23~/.yarn/patches/@metamask-assets-controllers-npm-26.0.0-17c0e9432c.patch%3A%3Aversion=26.0.0&hash=cf1d54#~/.yarn/patches/@metamask-assets-controllers-patch-0f46262fea.patch",
"@metamask/base-controller": "^4.1.0",
"@metamask/browser-passworder": "^4.3.0",
"@metamask/contract-metadata": "^2.5.0",
Expand Down
46 changes: 44 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4039,7 +4039,7 @@ __metadata:
languageName: node
linkType: hard

"@metamask/assets-controllers@patch:@metamask/assets-controllers@npm%3A26.0.0#~/.yarn/patches/@metamask-assets-controllers-npm-26.0.0-17c0e9432c.patch":
"@metamask/assets-controllers@patch:@metamask/assets-controllers@npm%3A26.0.0#~/.yarn/patches/@metamask-assets-controllers-npm-26.0.0-17c0e9432c.patch::version=26.0.0&hash=cf1d54":
version: 26.0.0
resolution: "@metamask/assets-controllers@patch:@metamask/assets-controllers@npm%3A26.0.0#~/.yarn/patches/@metamask-assets-controllers-npm-26.0.0-17c0e9432c.patch::version=26.0.0&hash=cf1d54"
dependencies:
Expand Down Expand Up @@ -4081,6 +4081,48 @@ __metadata:
languageName: node
linkType: hard

"@metamask/assets-controllers@patch:@metamask/assets-controllers@patch%3A@metamask/assets-controllers@npm%253A26.0.0%23~/.yarn/patches/@metamask-assets-controllers-npm-26.0.0-17c0e9432c.patch%3A%3Aversion=26.0.0&hash=cf1d54#~/.yarn/patches/@metamask-assets-controllers-patch-0f46262fea.patch":
version: 26.0.0
resolution: "@metamask/assets-controllers@patch:@metamask/assets-controllers@patch%3A@metamask/assets-controllers@npm%253A26.0.0%23~/.yarn/patches/@metamask-assets-controllers-npm-26.0.0-17c0e9432c.patch%3A%3Aversion=26.0.0&hash=cf1d54#~/.yarn/patches/@metamask-assets-controllers-patch-0f46262fea.patch::version=26.0.0&hash=8a466a"
dependencies:
"@ethereumjs/util": "npm:^8.1.0"
"@ethersproject/address": "npm:^5.7.0"
"@ethersproject/bignumber": "npm:^5.7.0"
"@ethersproject/contracts": "npm:^5.7.0"
"@ethersproject/providers": "npm:^5.7.0"
"@metamask/abi-utils": "npm:^2.0.2"
"@metamask/accounts-controller": "npm:^11.0.0"
"@metamask/approval-controller": "npm:^5.1.3"
"@metamask/base-controller": "npm:^4.1.1"
"@metamask/contract-metadata": "npm:^2.4.0"
"@metamask/controller-utils": "npm:^8.0.4"
"@metamask/eth-query": "npm:^4.0.0"
"@metamask/keyring-controller": "npm:^13.0.0"
"@metamask/metamask-eth-abis": "npm:3.0.0"
"@metamask/network-controller": "npm:^17.2.1"
"@metamask/polling-controller": "npm:^5.0.1"
"@metamask/preferences-controller": "npm:^8.0.0"
"@metamask/rpc-errors": "npm:^6.2.1"
"@metamask/utils": "npm:^8.3.0"
"@types/bn.js": "npm:^5.1.5"
"@types/uuid": "npm:^8.3.0"
async-mutex: "npm:^0.2.6"
bn.js: "npm:^5.2.1"
cockatiel: "npm:^3.1.2"
lodash: "npm:^4.17.21"
multiformats: "npm:^9.5.2"
single-call-balance-checker-abi: "npm:^1.0.0"
uuid: "npm:^8.3.2"
peerDependencies:
"@metamask/accounts-controller": ^11.0.0
"@metamask/approval-controller": ^5.1.2
"@metamask/keyring-controller": ^13.0.0
"@metamask/network-controller": ^17.2.0
"@metamask/preferences-controller": ^8.0.0
checksum: 411bdcfbda7368c1fdcaea8406597e9e34655b9c62811ce68b7a3acfa94db2d77fdc586f6d6fd65a0b91cb3ff92a8805b7f12556c1c5aaf8f1f815ed49cc18b3
languageName: node
linkType: hard

"@metamask/auto-changelog@npm:^2.1.0":
version: 2.6.1
resolution: "@metamask/auto-changelog@npm:2.6.1"
Expand Down Expand Up @@ -24711,7 +24753,7 @@ __metadata:
"@metamask/address-book-controller": "npm:^3.1.7"
"@metamask/announcement-controller": "npm:^6.1.0"
"@metamask/approval-controller": "npm:^6.0.0"
"@metamask/assets-controllers": "patch:@metamask/assets-controllers@npm%3A26.0.0#~/.yarn/patches/@metamask-assets-controllers-npm-26.0.0-17c0e9432c.patch"
"@metamask/assets-controllers": "patch:@metamask/assets-controllers@patch%3A@metamask/assets-controllers@npm%253A26.0.0%23~/.yarn/patches/@metamask-assets-controllers-npm-26.0.0-17c0e9432c.patch%3A%3Aversion=26.0.0&hash=cf1d54#~/.yarn/patches/@metamask-assets-controllers-patch-0f46262fea.patch"
"@metamask/auto-changelog": "npm:^2.1.0"
"@metamask/base-controller": "npm:^4.1.0"
"@metamask/browser-passworder": "npm:^4.3.0"
Expand Down

0 comments on commit af50f46

Please sign in to comment.