Skip to content
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

refactor: update Nft Controllers to use selectedAccountId instead of selectedAddress #4221

Merged

Conversation

montelaidev
Copy link
Contributor

@montelaidev montelaidev commented Apr 26, 2024

Explanation

This PR updates removes selectedAddress and uses the controller messenger to get InternalAccounts in the Nft Controllers

References

Fixes https://github.com/MetaMask/accounts-planning/issues/381

Changelog

@metamask/assets-controllers

  • BREAKING: NftController constructor argument selectedAddress has been removed.
  • BREAKING: NftController now requires AccountsControlelr:get{Account,SelectedAccount} messenger actions.
  • BREAKING: NftController now requires AccountsController:selectedEvmAccountChange event.
  • BREAKING: NftDetectionController now requires AccountsControlelr:getSelectedAccount messenger actions.

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've highlighted breaking changes using the "BREAKING" category above as appropriate

@montelaidev
Copy link
Contributor Author

@metamaskbot publish-preview

Copy link
Contributor

Preview builds have been published. See these instructions for more information about preview builds.

Expand for full list of packages and versions.
{
  "@metamask-previews/accounts-controller": "13.0.0-preview-61ace68c",
  "@metamask-previews/address-book-controller": "4.0.1-preview-61ace68c",
  "@metamask-previews/announcement-controller": "6.1.0-preview-61ace68c",
  "@metamask-previews/approval-controller": "6.0.1-preview-61ace68c",
  "@metamask-previews/assets-controllers": "28.0.0-preview-61ace68c",
  "@metamask-previews/base-controller": "5.0.1-preview-61ace68c",
  "@metamask-previews/build-utils": "2.0.1-preview-61ace68c",
  "@metamask-previews/composable-controller": "6.0.1-preview-61ace68c",
  "@metamask-previews/controller-utils": "9.1.0-preview-61ace68c",
  "@metamask-previews/ens-controller": "10.0.1-preview-61ace68c",
  "@metamask-previews/eth-json-rpc-provider": "3.0.1-preview-61ace68c",
  "@metamask-previews/gas-fee-controller": "15.0.0-preview-61ace68c",
  "@metamask-previews/json-rpc-engine": "8.0.1-preview-61ace68c",
  "@metamask-previews/json-rpc-middleware-stream": "7.0.1-preview-61ace68c",
  "@metamask-previews/keyring-controller": "15.0.0-preview-61ace68c",
  "@metamask-previews/logging-controller": "3.0.1-preview-61ace68c",
  "@metamask-previews/message-manager": "8.0.1-preview-61ace68c",
  "@metamask-previews/name-controller": "6.0.1-preview-61ace68c",
  "@metamask-previews/network-controller": "18.1.0-preview-61ace68c",
  "@metamask-previews/notification-controller": "5.0.1-preview-61ace68c",
  "@metamask-previews/permission-controller": "9.0.2-preview-61ace68c",
  "@metamask-previews/permission-log-controller": "2.0.1-preview-61ace68c",
  "@metamask-previews/phishing-controller": "9.0.1-preview-61ace68c",
  "@metamask-previews/polling-controller": "6.0.1-preview-61ace68c",
  "@metamask-previews/preferences-controller": "10.0.0-preview-61ace68c",
  "@metamask-previews/queued-request-controller": "0.9.0-preview-61ace68c",
  "@metamask-previews/rate-limit-controller": "5.0.1-preview-61ace68c",
  "@metamask-previews/selected-network-controller": "12.0.1-preview-61ace68c",
  "@metamask-previews/signature-controller": "15.0.0-preview-61ace68c",
  "@metamask-previews/transaction-controller": "28.1.0-preview-61ace68c",
  "@metamask-previews/user-operation-controller": "8.0.1-preview-61ace68c"
}

@montelaidev montelaidev changed the title fix: update Nft Controllers to use selectedAccountId instead of selectedAddress refactor: update Nft Controllers to use selectedAccountId instead of selectedAddress Jun 5, 2024
@montelaidev montelaidev force-pushed the fix/ap381/update-nft-controllers-to-use-internal-account branch from 61ace68 to dd6e3e8 Compare June 5, 2024 12:33
@montelaidev montelaidev force-pushed the fix/ap381/update-nft-controllers-to-use-internal-account branch from dd6e3e8 to 42bbf96 Compare June 5, 2024 12:42
@montelaidev montelaidev marked this pull request as ready for review June 5, 2024 12:43
@montelaidev montelaidev requested a review from a team as a code owner June 5, 2024 12:43
@montelaidev montelaidev requested a review from a team June 5, 2024 12:43
packages/assets-controllers/src/NftController.ts Outdated Show resolved Hide resolved
packages/assets-controllers/src/NftController.ts Outdated Show resolved Hide resolved
packages/assets-controllers/src/NftController.ts Outdated Show resolved Hide resolved
packages/assets-controllers/src/NftController.ts Outdated Show resolved Hide resolved
packages/assets-controllers/src/NftController.ts Outdated Show resolved Hide resolved
packages/assets-controllers/src/NftController.ts Outdated Show resolved Hide resolved
packages/assets-controllers/src/NftController.ts Outdated Show resolved Hide resolved
packages/assets-controllers/src/NftController.ts Outdated Show resolved Hide resolved
packages/assets-controllers/src/NftController.ts Outdated Show resolved Hide resolved
@@ -314,7 +323,7 @@ export class NftController extends BaseController<
*/
constructor({
chainId: initialChainId,
selectedAddress = '',
selectedAccountId = '',
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar comment as here — what are your thoughts on using the messenger to get this value from the AccountsController a bit later on in this constructor instead of having the constructor take this argument?

@ccharly ccharly merged commit 4149d47 into main Jun 7, 2024
113 checks passed
@ccharly ccharly deleted the fix/ap381/update-nft-controllers-to-use-internal-account branch June 7, 2024 14:44
legobeat pushed a commit that referenced this pull request Jun 11, 2024
…selectedAddress (#4221)

This PR updates removes `selectedAddress` and uses the controller
messenger to get InternalAccounts in the Nft Controllers

Fixes https://github.com/MetaMask/accounts-planning/issues/381

- **BREAKING**: `NftController` constructor argument `selectedAddress`
has been removed.
- **BREAKING**: `NftController` now requires
`AccountsControlelr:get{Account,SelectedAccount}` messenger actions.
- **BREAKING**: `NftController` now requires
`AccountsController:selectedEvmAccountChange` event.
- **BREAKING**: `NftDetectionController` now requires
`AccountsControlelr:getSelectedAccount` messenger actions.

- [x] I've updated the test suite for new or updated code as appropriate
- [x] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [x] I've highlighted breaking changes using the "BREAKING" category
above as appropriate
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.

3 participants