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: use internalAccount instead of account address for granular updates #4693

Merged
merged 3 commits into from
Sep 12, 2024

Conversation

mathieuartu
Copy link
Contributor

@mathieuartu mathieuartu commented Sep 12, 2024

This PR replaces the parameter for UserStorageController saveInternalAccountToUserStorage from an account address to an InternalAccount.

This helps because we're listening to AccountsController events and they are passing an InternalAccount as their return value. By using this return value directly, we remove some unnecessary logic & queries.

Explanation

References

Changelog

@metamask/profile-sync-controller

  • CHANGED: use InternalAccount instead of account address for saveInternalAccountToUserStorage parameter

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

@mathieuartu mathieuartu added the team-notifications Notification Team changes. https://github.com/orgs/MetaMask/teams/notifications label Sep 12, 2024
@mathieuartu
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": "18.2.0-preview-f054127",
  "@metamask-previews/address-book-controller": "6.0.0-preview-f054127",
  "@metamask-previews/announcement-controller": "7.0.0-preview-f054127",
  "@metamask-previews/approval-controller": "7.0.3-preview-f054127",
  "@metamask-previews/assets-controllers": "38.0.0-preview-f054127",
  "@metamask-previews/base-controller": "7.0.0-preview-f054127",
  "@metamask-previews/build-utils": "3.0.0-preview-f054127",
  "@metamask-previews/chain-controller": "0.1.1-preview-f054127",
  "@metamask-previews/composable-controller": "9.0.0-preview-f054127",
  "@metamask-previews/controller-utils": "11.2.0-preview-f054127",
  "@metamask-previews/ens-controller": "14.0.0-preview-f054127",
  "@metamask-previews/eth-json-rpc-provider": "4.1.3-preview-f054127",
  "@metamask-previews/gas-fee-controller": "20.0.0-preview-f054127",
  "@metamask-previews/json-rpc-engine": "9.0.2-preview-f054127",
  "@metamask-previews/json-rpc-middleware-stream": "8.0.2-preview-f054127",
  "@metamask-previews/keyring-controller": "17.2.0-preview-f054127",
  "@metamask-previews/logging-controller": "6.0.0-preview-f054127",
  "@metamask-previews/message-manager": "10.1.0-preview-f054127",
  "@metamask-previews/name-controller": "8.0.0-preview-f054127",
  "@metamask-previews/network-controller": "21.0.0-preview-f054127",
  "@metamask-previews/notification-controller": "6.0.0-preview-f054127",
  "@metamask-previews/notification-services-controller": "0.5.0-preview-f054127",
  "@metamask-previews/permission-controller": "11.0.1-preview-f054127",
  "@metamask-previews/permission-log-controller": "3.0.0-preview-f054127",
  "@metamask-previews/phishing-controller": "12.0.2-preview-f054127",
  "@metamask-previews/polling-controller": "10.0.0-preview-f054127",
  "@metamask-previews/preferences-controller": "13.0.2-preview-f054127",
  "@metamask-previews/profile-sync-controller": "0.5.0-preview-f054127",
  "@metamask-previews/queued-request-controller": "5.0.0-preview-f054127",
  "@metamask-previews/rate-limit-controller": "6.0.0-preview-f054127",
  "@metamask-previews/selected-network-controller": "18.0.0-preview-f054127",
  "@metamask-previews/signature-controller": "19.0.0-preview-f054127",
  "@metamask-previews/transaction-controller": "36.1.0-preview-f054127",
  "@metamask-previews/user-operation-controller": "15.0.0-preview-f054127"
}

@@ -1104,7 +1104,7 @@ describe('user-storage/user-storage-controller - saveInternalAccountToUserStorag
});

await controller.saveInternalAccountToUserStorage(
MOCK_INTERNAL_ACCOUNTS.ONE[0].address,
MOCK_INTERNAL_ACCOUNTS.ONE[0] as InternalAccount,
Copy link
Contributor

Choose a reason for hiding this comment

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

Just want to make sure, is this assertion valid? If so then all good!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes definitely! It's just that my data doesn't 100% intersect with type InternalAccount since it misses some keys we don't really care about, and I didn't want to bloat up the fixtures.

@mathieuartu
Copy link
Contributor Author

@metamaskbot publish-preview

@mathieuartu mathieuartu marked this pull request as ready for review September 12, 2024 10:48
@mathieuartu mathieuartu requested a review from a team as a code owner September 12, 2024 10:48
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": "18.2.0-preview-c1e764d",
  "@metamask-previews/address-book-controller": "6.0.0-preview-c1e764d",
  "@metamask-previews/announcement-controller": "7.0.0-preview-c1e764d",
  "@metamask-previews/approval-controller": "7.0.3-preview-c1e764d",
  "@metamask-previews/assets-controllers": "38.0.0-preview-c1e764d",
  "@metamask-previews/base-controller": "7.0.0-preview-c1e764d",
  "@metamask-previews/build-utils": "3.0.0-preview-c1e764d",
  "@metamask-previews/chain-controller": "0.1.1-preview-c1e764d",
  "@metamask-previews/composable-controller": "9.0.0-preview-c1e764d",
  "@metamask-previews/controller-utils": "11.2.0-preview-c1e764d",
  "@metamask-previews/ens-controller": "14.0.0-preview-c1e764d",
  "@metamask-previews/eth-json-rpc-provider": "4.1.3-preview-c1e764d",
  "@metamask-previews/gas-fee-controller": "20.0.0-preview-c1e764d",
  "@metamask-previews/json-rpc-engine": "9.0.2-preview-c1e764d",
  "@metamask-previews/json-rpc-middleware-stream": "8.0.2-preview-c1e764d",
  "@metamask-previews/keyring-controller": "17.2.0-preview-c1e764d",
  "@metamask-previews/logging-controller": "6.0.0-preview-c1e764d",
  "@metamask-previews/message-manager": "10.1.0-preview-c1e764d",
  "@metamask-previews/name-controller": "8.0.0-preview-c1e764d",
  "@metamask-previews/network-controller": "21.0.0-preview-c1e764d",
  "@metamask-previews/notification-controller": "6.0.0-preview-c1e764d",
  "@metamask-previews/notification-services-controller": "0.5.0-preview-c1e764d",
  "@metamask-previews/permission-controller": "11.0.1-preview-c1e764d",
  "@metamask-previews/permission-log-controller": "3.0.0-preview-c1e764d",
  "@metamask-previews/phishing-controller": "12.0.2-preview-c1e764d",
  "@metamask-previews/polling-controller": "10.0.0-preview-c1e764d",
  "@metamask-previews/preferences-controller": "13.0.2-preview-c1e764d",
  "@metamask-previews/profile-sync-controller": "0.5.0-preview-c1e764d",
  "@metamask-previews/queued-request-controller": "5.0.0-preview-c1e764d",
  "@metamask-previews/rate-limit-controller": "6.0.0-preview-c1e764d",
  "@metamask-previews/selected-network-controller": "18.0.0-preview-c1e764d",
  "@metamask-previews/signature-controller": "19.0.0-preview-c1e764d",
  "@metamask-previews/transaction-controller": "36.1.0-preview-c1e764d",
  "@metamask-previews/user-operation-controller": "15.0.0-preview-c1e764d"
}

@mathieuartu mathieuartu merged commit 908215f into main Sep 12, 2024
116 checks passed
@mathieuartu mathieuartu deleted the refactor/account_sync_granular_parameter branch September 12, 2024 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-notifications Notification Team changes. https://github.com/orgs/MetaMask/teams/notifications
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants