-
-
Notifications
You must be signed in to change notification settings - Fork 238
chore: explicitly pass networkClientId for nftController #5622
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
chore: explicitly pass networkClientId for nftController #5622
Conversation
this.messagingSystem.subscribe( | ||
'NetworkController:networkDidChange', | ||
this.#onNetworkControllerNetworkDidChange.bind(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.
This subscription is removed because the purpose of onNetworkControllerNetworkDidChange
was to populate this.#chainId
which has been removed
selectedNetworkClientId, | ||
); | ||
this.#chainId = chainId; | ||
} |
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.
Removed this because subscription was also removed
return chainId; | ||
} | ||
return this.#chainId; | ||
} |
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 has been removed and we are making a call
to NetworkController:getNetworkClientById
when needed since we no longer fallback to this.#chainId
// TODO: revisit this with Solana support and instead of passing chainId, make sure chainId is read from nftMetadata | ||
const chainIdToAddTo = | ||
chainId || this.#getCorrectChainId({ networkClientId }); | ||
|
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.
Removed this in favor of the mandatory networkClientId
;
This will be called from nftDetectionController
to add NFTs in which case we will take the chainId from the NFT and find the networkClientId. Or directly from clients, in which case they need to provide the networkClientId.
@metamaskbot publish-preview |
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions.
|
TODO: Changelog |
0d5cebc
to
476edcf
Compare
476edcf
to
42bb475
Compare
@metamaskbot publish-preview |
1 similar comment
@metamaskbot publish-preview |
@metamaskbot publish-preview |
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions.
|
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!
## **Description** This PR integrates the changes from this core PR MetaMask/core#5622 Making networkClientId no longer optional for `nftController` and `nftDetectionController` functions. Users should not experience any changes related to NFT flows. [](https://codespaces.new/MetaMask/metamask-extension/pull/31917?quickstart=1) ## **Related issues** Fixes: ## **Manual testing steps** Test autodetection 1. Import a new account that you know has NFTs on linea or Ethereum mainnet 2. Go to NFT tab. 3. You should see a loader then your NFTs will appear correctly 4. Switch between popular networks and current network and it should filter your NFTs correctly Test import/remove NFT 1. Go to NFT tab 2. Click on any NFT 3. Click on options and click remove NFT 4. NFT should be removed successfully 5. Re-import the NFT (whether on the NFT network or another network) 6. NFT should be imported successfully ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.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/main/.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. --------- Co-authored-by: salimtb <[email protected]> Co-authored-by: MetaMask Bot <[email protected]>
## **Description** This PR integrates the changes from this core PR MetaMask/core#5622 Making networkClientId no longer optional for `nftController` and `nftDetectionController` functions. Users should not experience any changes related to NFT flows. [](https://codespaces.new/MetaMask/metamask-extension/pull/31917?quickstart=1) ## **Related issues** Fixes: ## **Manual testing steps** Test autodetection 1. Import a new account that you know has NFTs on linea or Ethereum mainnet 2. Go to NFT tab. 3. You should see a loader then your NFTs will appear correctly 4. Switch between popular networks and current network and it should filter your NFTs correctly Test import/remove NFT 1. Go to NFT tab 2. Click on any NFT 3. Click on options and click remove NFT 4. NFT should be removed successfully 5. Re-import the NFT (whether on the NFT network or another network) 6. NFT should be imported successfully ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.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/main/.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. --------- Co-authored-by: salimtb <[email protected]> Co-authored-by: MetaMask Bot <[email protected]>
Explanation
This PR is part of a larger effort to remove the global network selector.
On this PR:
UI integration:
References
NFTController
: Remove Private Property#chainId
and the fallback on current selected network #5581Changelog
@metamask/assets-controllers
NftController
andNftDetectionController
to eliminate the dependency on the current chain. All functions that previously accepted networkClientId as an optional parameter now require it as a mandatory parameterChecklist