Skip to content

Move the account menu rules to wallet_core - #768

Merged
dewabisma merged 4 commits into
mainfrom
beast/account-menu-rules
Nov 21, 2026
Merged

dewabisma merged 4 commits into
mainfrom
beast/account-menu-rules

Conversation

@dewabisma

Copy link
Copy Markdown
Collaborator

What

The phone's account-menu rules move from its widgets to wallet_core, so the desktop's account management (next PR) shares them instead of copying them. The phone behaves as before.

wallet_core/lib/utils/account_menu.dart, all pure functions:

  • accountMenuOf(account, accounts) and multisigMenu: what an account's or a multisig's menu offers, in order (show address, inner hash, rename, recovery phrase, multisig details, disconnect).
  • disconnectPlanOf(account, accounts): how an account is disconnected. It goes alone (DisconnectAccount), as hardware (DisconnectHardware), or with its whole wallet (DisconnectWallet, with the wallet's index and its number among software wallets). Null when it can't be: Encrypted, external, or the last account of wallet 0.
  • orderedSignersOf(multisig): the creator first when it is a signer, the rest as stored.
  • nameEditOf(current, entered): blank, unchanged, or changed with the trimmed name.

Commits

  1. Pins first. mobile-app/test/screens/account_menu_rules_test.dart, 20 tests against today's phone code. They cover the menu of each account kind and of a wallet heading, and what each disconnect confirms and stores, including a second wallet removed with its phrase. They also cover the active account after a removal, multisig details (signer order, Creator/You, threshold), and renaming an account, a multisig and a wallet. They run against the real SettingsService over mocked storage. flutter_secure_storage becomes a direct dev dependency of the phone, at the version it already resolved.
  2. wallet_core gets the rules, with 16 tests.
  3. The phone uses them. The pins are unchanged and still pass.

Phone code that changed (please retest by hand)

  • accounts_screen.dart: the kebab menus of an account and a multisig are built from accountMenuOf / multisigMenu; Disconnect keeps its own group.
  • account_menu_screen.dart: canDisconnect and disconnect follow disconnectPlanOf.
  • multisig_details_screen.dart: the signer order comes from orderedSignersOf.
  • edit_account_screen.dart: saving goes through nameEditOf.

Behaviour changes, invisible in normal use

  • If the account list hasn't loaded, the menus now throw instead of treating the list as empty (requireValue). The rows that open the menus only show once the list has loaded.
  • The wallet number in "Disconnect Wallet N" no longer falls back to the stored index when the wallet isn't found. That is now an error, since a local account's wallet is always a software wallet.

Testing

  • melos run check passed: analyze clean, mobile 859.
  • wallet_core: 207 passing.

Before the account menu rules move to wallet_core for the desktop, pin
today's phone behaviour: which items each account kind and a wallet
heading offer, what each disconnect confirms and removes, the multisig
signer order and labels, and how account, multisig and wallet names are
saved.
What an account's or a multisig's menu offers, how an account is
disconnected (alone, as hardware, or with its whole wallet, numbered
among software wallets), the multisig signer order and what a typed
name amounts to, as pure functions both apps can share.
The accounts screen's menus, Disconnect, multisig details and Rename now
use wallet_core's accountMenuOf, disconnectPlanOf, orderedSignersOf and
nameEditOf. The pins in account_menu_rules_test.dart are unchanged.

@n13 n13 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Verdict: Approve
Reviewer: GPT-6.1 Sol

Reviewed head 1f01b3d563b0c386605bae44ee4d37a4cf7e22c2 against base a76f24e4f1c32d5fc96f0c96c8358236731f382f.

No blocking findings. The extracted rules preserve the phone's menu ordering and availability, primary-wallet protection, account versus whole-wallet removal, hardware and multisig disconnect behavior, signer ordering, and trimmed account/multisig names. Wallet-heading naming retains its distinct empty-name behavior.

Validation with pinned Flutter 3.47.7:

  • Locked Melos bootstrap passed.
  • timeout 60 flutter test --no-pub --reporter=expanded in wallet_core: 207 tests passed, including all 16 new rule tests.
  • timeout 60 flutter test --no-pub --reporter=failures-only test/screens/account_menu_rules_test.dart test/screens/accounts_screen_menu_test.dart in mobile-app: 25 tests passed, including the 20 new behavior pins.
  • Workspace formatting check and git diff --check passed; tracked files were unchanged.
  • timeout 10 dart run melos run analyze stopped at the required limit while analyzing the first package; local analysis is incomplete. GitHub's Analyze job is still in progress. No physical-device testing was performed.

@dewabisma
dewabisma merged commit 73f57bf into main Nov 21, 2026
2 checks passed
@dewabisma
dewabisma deleted the beast/account-menu-rules branch November 21, 2026 02:36
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.

2 participants