-
-
Notifications
You must be signed in to change notification settings - Fork 250
feat(multichain-account-service): basic functionality management #6332
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
Conversation
packages/multichain-account-service/src/providers/SolAccountProvider.ts
Outdated
Show resolved
Hide resolved
packages/multichain-account-service/src/providers/BaseAccountProvider.ts
Outdated
Show resolved
Hide resolved
packages/multichain-account-service/src/providers/BaseAccountProvider.ts
Outdated
Show resolved
Hide resolved
packages/multichain-account-service/src/MultichainAccountService.ts
Outdated
Show resolved
Hide resolved
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 we also need to make sure we return an empty array or throw for getAccounts
and getAccount
based on isDisabled
.
packages/multichain-account-service/src/MultichainAccountService.ts
Outdated
Show resolved
Hide resolved
packages/multichain-account-service/src/MultichainAccountService.test.ts
Outdated
Show resolved
Hide resolved
* | ||
* @param enabled - Whether basic functionality is enabled. | ||
*/ | ||
async setBasicFunctionality(enabled: boolean): Promise<void> { |
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.
IDK if we should have this as part of the public API 🤔
My initial idea was to have the "account provider wrapper" to "react" to some events (or maybe a runtime callback) and adapt each of their methods to return all accounts or no accounts (based on the "basic functionality flag").
Though, I haven't checked of this was done on both clients, so maybe it's not that easy to do
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 is something to discuss @ccharly . It's an architectural decision, and I chose the simplest path (multichain account service was already available to both places where basicFunctionality is toggled in extension and mobile).
Are you suggesting we use MultichainAccountServiceMessenger
to dispatch a MultichainAccountServiceSetBasicFunctionalityAction
? I'm not sure how to get a ref to that messenger in mobile tbh.
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.
Well, let's be pragmatic here and keep your implementation for now. It's simple enough and does get the job done, so that's ok! 👍
We can re-visit that later once we have a bit more time.
packages/multichain-account-service/src/providers/ProviderWrapper.ts
Outdated
Show resolved
Hide resolved
packages/multichain-account-service/src/providers/ProviderWrapper.ts
Outdated
Show resolved
Hide resolved
packages/multichain-account-service/src/providers/ProviderWrapper.ts
Outdated
Show resolved
Hide resolved
packages/multichain-account-service/src/providers/ProviderWrapper.ts
Outdated
Show resolved
Hide resolved
packages/multichain-account-service/src/MultichainAccountService.ts
Outdated
Show resolved
Hide resolved
packages/multichain-account-service/src/providers/BaseAccountProvider.ts
Show resolved
Hide resolved
packages/multichain-account-service/src/providers/ProviderWrapper.ts
Outdated
Show resolved
Hide resolved
@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.
|
packages/multichain-account-service/src/providers/AccountProviderWrapper.ts
Outdated
Show resolved
Hide resolved
packages/multichain-account-service/src/MultichainAccountService.test.ts
Outdated
Show resolved
Hide resolved
@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.
|
Co-authored-by: Charly Chevalier <charly.chevalier@consensys.net>
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!
…18472) <!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** Add multichain account provider state management when basic functionality toggle changes on mobile. When users toggle the "Basic Functionality" setting on mobile, account providers need to be managed appropriately - non-EVM providers should be disabled when basic functionality is OFF, and all providers should be enabled with wallet alignment when basic functionality is ON. ## **Changelog** CHANGELOG entry: null This PR integrates with the `MultichainAccountService.setBasicFunctionality()` method to: - Update provider disabled states based on basic functionality preference - Trigger multichain wallet alignment when basic functionality is enabled 1. **BasicFunctionalityModal** - Main settings toggle modal 2. **ConfirmTurnOnBackupAndSyncModal** - Backup & sync confirmation flow Both now call `Engine.context.MultichainAccountService.setBasicFunctionality({ enabled })` after updating Redux state. ## **Related issues** [MUL-343](https://consensyssoftware.atlassian.net/browse/MUL-343) Relates to: MetaMask/metamask-extension#35190, MetaMask/core#6332 ## **Manual testing steps** Scenario: user enables basic functionality from settings Given basic functionality is currently disabled And user is in Settings > Security & Privacy > Basic Functionality When user toggles "Basic Functionality" to ON Then Redux state updates to basicFunctionalityEnabled: true And MultichainAccountService.setBasicFunctionality is called with enabled: true And console shows "MultichainAccountService: Setting basic functionality enabled" And console shows "Triggered wallet alignment..." And all multichain account providers are enabled --- Scenario: user disables basic functionality from settings Given basic functionality is currently enabled And user is in Settings > Security & Privacy > Basic Functionality When user toggles "Basic Functionality" to OFF Then confirmation modal appears When user confirms the action Then Redux state updates to basicFunctionalityEnabled: false And MultichainAccountService.setBasicFunctionality is called with enabled: false And console shows "MultichainAccountService: Setting basic functionality disabled" And EVM provider remains active And non-EVM providers (Solana, etc.) are disabled --- Scenario: user enables basic functionality via backup sync flow Given basic functionality is disabled And user is in backup & sync confirmation modal When user confirms "Turn On" Then MultichainAccountService.setBasicFunctionality is called with enabled: true And providers are enabled and alignment is triggered ## **Screenshots/Recordings** <img width="1127" height="1011" alt="image" src="https://github.com/user-attachments/assets/f5be2102-1b18-4b70-aee6-f36223d1be82" /> ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [ ] I've included tests if applicable - [x] 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-mobile/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. [MUL-343]: https://consensyssoftware.atlassian.net/browse/MUL-343?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
Explanation
What is the current state and why does it need to change?
Currently, the
MultichainAccountService
has no mechanism to manage provider states based on user preferences like the "basic functionality" toggle. When users disable advanced features (basic functionality OFF), all providers (EVM, Solana, Bitcoin, etc.) remain active and continue creating multichain accounts, which goes against the user's preference for a simplified wallet experience.The extension's
PreferencesController
manages the basic functionality toggle (useExternalServices
), but there was no way to communicate this state change to the coreMultichainAccountService
to disable non-essential providers.What is the solution and how does it work?
This PR introduces a clean provider state management system that allows clients to control which providers are active based on user preferences:
Provider-Level Disable Mechanism: Added
setDisabled(disabled: boolean)
method toBaseAccountProvider
. Providers now can / should checkthis.isDisabled
in theircreateAccounts
methods and return empty arrays when disabled, preventing new account creation.EvmAccountProvider
could be disabled, for other reasons in the future, but does not depend on basic functionality, at all.Added
setBasicFunctionality({ enabled: boolean })
method toMultichainAccountService
that:setDisabled(!enabled)
on all providersExtension Integration: The extension's
PreferencesController
now calls this method when the basic functionality toggle changes.References
Alignment method provided by: #6326
Stories:
Checklist