-
-
Notifications
You must be signed in to change notification settings - Fork 203
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
OpenSea V2 -> V1 compatibility #3654
Conversation
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 there was just one field missing from mapOpenSeaNftV2ToV1
that I noticed, but this looks good to me so far otherwise! A lot of the comments below are just about improving types.
I will strongly type the v2 responses. It could be convenient to generate these from swagger / use the OpenSea typescript SDK. But I've noticed at least 3 places where the spec is wrong, and for quickness i'll just add some types since its only a couple models. |
tokenId: nftV2.identifier, | ||
}), | ||
undefined, | ||
1000, |
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.
In all these examples I found, OS falls back to the original, non-CDN URL when you fetch the NFT individually. V1 also did this when listing, but in a separate field image_original_url
, which is how those used to render.
Alternatively we could fetch metadata_url
and grab the image field, but was more anonying to handle ipfs, arweave. The timeout was more for when I was doing that approach and may not be needed.
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.
Good call on not fetching the metadata. That would have had complicated privacy implications (for metadata URLs that aren't IPFS, at least)
@@ -231,22 +306,30 @@ export class NftController extends BaseControllerV1<NftConfig, NftState> { | |||
|
|||
private readonly messagingSystem: NftControllerMessenger; | |||
|
|||
private getNftApi({ | |||
getNftApi({ |
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.
Hmm, exposing this for another controller to use is typically something we'd avoid. Lately we've been trying to extract network calls from controllers altogether, moving them to separate "API service" classes.
But this seems OK for now, we can refactor this later.
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.
This looks great! Thanks so much for taking care of this.
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.
LGTM!
const nftDetails: OpenSeaV2GetNftResponse | undefined = | ||
await safelyExecute(() => | ||
timeoutFetch( | ||
this.getNftApi({ |
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.
Hmm, this could mean a lot more network requests.
I wonder if we could cache these somehow to prevent this.
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.
Yeah. Although it's not the common case. Saw no occurrences in most wallets, and only on a few tokens when it does occur. I could tally more stats on the %. Also the && metadata_url
avoids doing it some cases where it wouldn't return anything useful.
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.
Good point! OK, maybe we highlight it to the mobile and extension teams as a risk, and we can add caching later if necessary
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.
Was testing occurrences with a script like this:
let next = '', account = '';
do {
const nfts = await(
await fetch(
`https://api.opensea.io/api/v2/chain/ethereum/account/${account}/nfts?limit=200&next=${next}`,
{ headers: { 'x-api-key': '' } }
)).json();
for (nft of nfts.nfts) {
if (!nft.image_url && nft.metadata_url) {
console.log(nft);
}
}
next = nfts.next;
} while (next);
## **Description** Updates the assets controllers package to version 22.0.0. This brings in [PR 3654](MetaMask/core#3654) to migrate from OpenSea V1 to V2 API. ## **Related issues** Fixes: https://github.com/MetaMask/MetaMask-planning/issues/1841 ## **Manual testing steps** 1. Import a wallet containing NFTs on mainnet 2. Manually import an NFT owner by the wallet, verify it appears 3. Enable NFT autodetection in settings, verify the rest of the NFTs appear 4. Verify descriptions, collection/token images are correct 5. Send an NFT, verify it works ## **Screenshots/Recordings** No visible differences ### **Before** ### **After** ## **Pre-merge author checklist** - [x] I’ve followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [x] I've clearly explained what problem this PR is solving and how it is solved. - [x] I've linked related issues - [x] I've included manual testing steps - [ ] I've included screenshots/recordings if applicable - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] 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. - [x] I’ve properly set the pull request status: - [ ] In case it's not yet "ready for review", I've set it to "draft". - [x] In case it's "ready for review", I've changed it from "draft" to "non-draft". ## **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.
## **Description** Migrate to OpenSea V2 API because V1 is being deprecated. Patches this change from core: MetaMask/core#3654 ## **Related issues** Fixes: https://github.com/MetaMask/MetaMask-planning/issues/1841 ## **Manual testing steps** 1. Import a wallet containing NFTs on mainnet 2. Manually import an NFT owner by the wallet, verify it appears 3. Enable NFT autodetection in settings, verify the rest of the NFTs appear 4. Verify descriptions, collection/token images are correct 5. Send an NFT, verify it works ## **Screenshots/Recordings** No visible differences between before and after. ### **Before** <!-- [screenshots/recordings] --> ### **After** https://github.com/MetaMask/metamask-mobile/assets/3500406/88217ecb-c4e2-473f-a360-c40a8f34d331 ## **Pre-merge author checklist** - [x] I’ve followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've clearly explained what problem this PR is solving and how it is solved. - [x] I've linked related issues - [x] I've included manual testing steps - [] I've included screenshots/recordings if applicable - [ ] 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-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. - [x] I’ve properly set the pull request status: - [] In case it's not yet "ready for review", I've set it to "draft". - [x] In case it's "ready for review", I've changed it from "draft" to "non-draft". ## **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. --------- Co-authored-by: Chris Wilcox <[email protected]>
Updates the assets controllers package to version 22.0.0. This brings in [PR 3654](MetaMask/core#3654) to migrate from OpenSea V1 to V2 API. Fixes: MetaMask/MetaMask-planning#1841 1. Import a wallet containing NFTs on mainnet 2. Manually import an NFT owner by the wallet, verify it appears 3. Enable NFT autodetection in settings, verify the rest of the NFTs appear 4. Verify descriptions, collection/token images are correct 5. Send an NFT, verify it works No visible differences - [x] I’ve followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [x] I've clearly explained what problem this PR is solving and how it is solved. - [x] I've linked related issues - [x] I've included manual testing steps - [ ] I've included screenshots/recordings if applicable - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] 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. - [x] I’ve properly set the pull request status: - [ ] In case it's not yet "ready for review", I've set it to "draft". - [x] In case it's "ready for review", I've changed it from "draft" to "non-draft". - [ ] 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.
## **Description** This is a release version of this PR: #8135 Migrate to OpenSea V2 API because V1 is being deprecated. Patches this change from core: MetaMask/core#3654 ## **Related issues** Fixes: https://github.com/MetaMask/MetaMask-planning/issues/1841 ## **Manual testing steps** 1. Import a wallet containing NFTs on mainnet 2. Manually import an NFT owner by the wallet, verify it appears 3. Enable NFT autodetection in settings, verify the rest of the NFTs appear 4. Verify descriptions, collection/token images are correct 5. Send an NFT, verify it works ## **Screenshots/Recordings** No visible differences between before and after. ### **Before** <!-- [screenshots/recordings] --> ### **After** https://github.com/MetaMask/metamask-mobile/assets/3500406/88217ecb-c4e2-473f-a360-c40a8f34d331 ## **Pre-merge author checklist** - [x] I’ve followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've clearly explained what problem this PR is solving and how it is solved. - [x] I've linked related issues - [x] I've included manual testing steps - [] I've included screenshots/recordings if applicable - [ ] 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-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. - [x] I’ve properly set the pull request status: - [] In case it's not yet "ready for review", I've set it to "draft". - [x] In case it's "ready for review", I've changed it from "draft" to "non-draft". ## **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. --------- Co-authored-by: Chris Wilcox <[email protected]>
Updates the assets controllers package to version 22.0.0. This brings in [PR 3654](MetaMask/core#3654) to migrate from OpenSea V1 to V2 API. Fixes: MetaMask/MetaMask-planning#1841 1. Import a wallet containing NFTs on mainnet 2. Manually import an NFT owner by the wallet, verify it appears 3. Enable NFT autodetection in settings, verify the rest of the NFTs appear 4. Verify descriptions, collection/token images are correct 5. Send an NFT, verify it works No visible differences - [x] I’ve followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [x] I've clearly explained what problem this PR is solving and how it is solved. - [x] I've linked related issues - [x] I've included manual testing steps - [ ] I've included screenshots/recordings if applicable - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] 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. - [x] I’ve properly set the pull request status: - [ ] In case it's not yet "ready for review", I've set it to "draft". - [x] In case it's "ready for review", I've changed it from "draft" to "non-draft". - [ ] 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.
Updates the assets controllers package to version 22.0.0. This brings in [PR 3654](MetaMask/core#3654) to migrate from OpenSea V1 to V2 API. Fixes: MetaMask/MetaMask-planning#1841 1. Import a wallet containing NFTs on mainnet 2. Manually import an NFT owner by the wallet, verify it appears 3. Enable NFT autodetection in settings, verify the rest of the NFTs appear 4. Verify descriptions, collection/token images are correct 5. Send an NFT, verify it works No visible differences - [x] I’ve followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [x] I've clearly explained what problem this PR is solving and how it is solved. - [x] I've linked related issues - [x] I've included manual testing steps - [ ] I've included screenshots/recordings if applicable - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] 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. - [x] I’ve properly set the pull request status: - [ ] In case it's not yet "ready for review", I've set it to "draft". - [x] In case it's "ready for review", I've changed it from "draft" to "non-draft". - [ ] 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.
Updates the assets controllers package to version 22.0.0. This brings in [PR 3654](MetaMask/core#3654) to migrate from OpenSea V1 to V2 API. Fixes: MetaMask/MetaMask-planning#1841 1. Import a wallet containing NFTs on mainnet 2. Manually import an NFT owner by the wallet, verify it appears 3. Enable NFT autodetection in settings, verify the rest of the NFTs appear 4. Verify descriptions, collection/token images are correct 5. Send an NFT, verify it works No visible differences - [x] I’ve followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [x] I've clearly explained what problem this PR is solving and how it is solved. - [x] I've linked related issues - [x] I've included manual testing steps - [ ] I've included screenshots/recordings if applicable - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] 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. - [x] I’ve properly set the pull request status: - [ ] In case it's not yet "ready for review", I've set it to "draft". - [x] In case it's "ready for review", I've changed it from "draft" to "non-draft". - [ ] 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.
Explanation
Moves to using OpenSea V2 API, but modifies the responses to keep compatibility with the existing controller state schema.
References
Changelog
@metamask/controller-utils
OPENSEA_PROXY_URL
now points to OpenSea's v2 API.OPENSEA_API_URL
+OPENSEA_TEST_API_URL
have been removed.@metamask/assets-controllers
NftDetectionController
constructor now requires theNftController.getNftApi
function.last_sale
information for NFTs fetched after the OpenSea V2 updateChecklist