Skip to content

feat: internal account list in address book#10929

Merged
NeOMakinG merged 47 commits intodevelopfrom
address-book-internal-list
Nov 11, 2025
Merged

feat: internal account list in address book#10929
NeOMakinG merged 47 commits intodevelopfrom
address-book-internal-list

Conversation

@NeOMakinG
Copy link
Collaborator

@NeOMakinG NeOMakinG commented Oct 28, 2025

Description

This PR display the internal accounts in the address book, using quite a similar logic from what we have in the address book already but for accountIds we already know about!

Issue (if applicable)

closes #10920

Risk

Low - UI improvements only, no changes to transaction logic or data handling

What protocols, transaction types, wallets or contract interactions might be affected by this PR?

Display of internal accounts in the Send modal for all chains (particularly UTXO chains: BTC, LTC, DOGE, BCH)

Testing

Manual testing in the Send modal:

  1. Open the Send modal for various chains (BTC, ETH, LTC, etc.)

  2. Verify internal accounts list displays correctly:

    • Non-UTXO accounts show blockies avatars with addresses displayed below labels
    • UTXO accounts show ProfileAvatar (wallet icon) with account type (Legacy/SegWit/Native SegWit) displayed below labels
    • Clicking on UTXO fetch the next receive address and populate it
    • Clicking on any other chains populate the address directly in the input
  3. Test search functionality:

    • Search by account number (e.g., "0", "1", "2")
    • Search by account type for UTXO accounts (e.g., "legacy", "segwit", "native")
    • Search by address for non-UTXO accounts
  4. Verify display logic:

    • Empty input shows all accounts
    • Valid address in input shows all accounts (allows quick switching)
    • Invalid address in input shows filtered search results

Engineering

Created new files:

  • src/components/Modals/Send/AddressBook/InternalAccountsList.tsx - Main list component using selectors instead of useMemo
  • src/components/Modals/Send/AddressBook/InternalAccountButton.tsx - Individual account button component with conditional avatar rendering
  • src/components/Modals/Send/AddressBook/hooks/useInternalAccountReceiveAddress.tsx - Hook for async UTXO address fetching

Modified files:

  • src/state/slices/portfolioSlice/selectors.ts - Added selectInternalAccountsBySearchQuery selector using match-sorter for flexible search by address, account type, and account number
  • src/components/Modals/Send/AddressBook/AddressBook.tsx - Imports and renders new InternalAccountsList component
  • src/assets/translations/en/main.json - Added translation key for "Your Wallets" section header

Technical details:

  • Leverages match-sorter library for fuzzy search across multiple fields
  • Follows established patterns from AddressBook component for consistency
  • Properly handles UTXO vs non-UTXO account differences

Operations

  • My feature doesn't require operations testing

Screenshots (if applicable)

image image image image image image image image image image

Summary by CodeRabbit

  • New Features
    • Added internal wallet accounts to the address book in the Send modal
    • Search functionality to quickly filter and locate accounts by name or address
    • Streamlined account selection with improved visibility of your available wallet accounts

NeOMakinG and others added 30 commits October 3, 2025 18:01
- Gate AddressBook save feature with feature flag in SendAmountDetails
- Add aria-label to back button for accessibility
- Consolidate AddressBookEntry type to single source of truth
- Fix Date.now() timestamp inconsistency in addAddress reducer
- Add duplicate address validation to prevent saving same address twice
- Add defensive chainId validation in selectors

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
NeOMakinG and others added 11 commits October 27, 2025 16:53
Implements selector-based filtering and enhanced UX for internal accounts list in the Send modal.

Key improvements:
- Replace useMemo filtering with Redux selectors (selectInternalAccountsBySearchQuery)
- Display UTXO account type (Legacy, SegWit, Native SegWit) below account name instead of pubkey
- Enhanced search: find accounts by address, account type, or account number
- Show all accounts when input has valid value without errors (improved display logic)
- Add blockies avatars for non-UTXO accounts, ProfileAvatar for UTXO accounts
- Extract InternalAccountButton component for better code organization
- Add useInternalAccountReceiveAddress hook for async UTXO address fetching

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 28, 2025

📝 Walkthrough

Walkthrough

This PR implements functionality to display internal accounts within the address book for the send flow. Changes include new UI components for rendering account lists and buttons, a hook for resolving receive addresses, utility functions for UTXO account operations, translation keys, and Redux selectors for filtering accounts.

Changes

Cohort / File(s) Summary
Translations
src/assets/translations/en/main.json
Added translation keys yourWallets and noInternalAccounts
Address Book Component
src/components/Modals/Send/AddressBook/AddressBook.tsx
Imported InternalAccountsList; increased max height from 200px to 400px; expanded container with scroll behavior and rendered InternalAccountsList below address book entries
Internal Account UI Components
src/components/Modals/Send/AddressBook/InternalAccountButton.tsx, src/components/Modals/Send/AddressBook/InternalAccountsList.tsx
New memoized components for rendering individual account buttons and account lists with UTXO support, avatars, labels, and async address resolution
Internal Account Hook
src/components/Modals/Send/AddressBook/hooks/useInternalAccountReceiveAddress.tsx
New React Query hook to fetch receive addresses for internal accounts with chain validation and UTXO metadata enforcement
Account Utilities
src/lib/utils/accounts.ts
Added type guard isUtxoAccountWithAddresses and utility findUtxoAccountIdByAddress for UTXO account detection and address-based lookup
Redux Selectors
src/state/slices/common-selectors.ts, src/state/slices/portfolioSlice/selectors.ts
Added selectAccountIdsWithoutEvms to filter out EVM accounts; added selectInternalAccountsBySearchQuery to filter accounts by search query using matchSorter
Formatting
src/components/Modals/Send/views/Address.tsx
Minor spacing adjustment between DialogBody and DialogFooter

Sequence Diagram

sequenceDiagram
    participant User as User
    participant AddressBook as AddressBook
    participant InternalList as InternalAccountsList
    participant Button as InternalAccountButton
    participant Hook as useInternalAccountReceiveAddress
    participant FormContext as React Hook Form

    User->>AddressBook: Open address book
    AddressBook->>InternalList: Render with chainId
    InternalList->>InternalList: Filter accounts by chainId & search query
    loop For each internal account
        InternalList->>Button: Render InternalAccountButton
    end
    User->>Button: Click account
    alt UTXO Account
        Button->>Hook: Fetch receive address (enabled)
        Hook->>Hook: Validate chain & metadata
        Hook-->>Button: Return address
        Button->>FormContext: Set address value
        Button->>Button: Mark loading complete
    else Non-UTXO Account
        Button->>FormContext: Set address directly
    end
    Button->>AddressBook: Call onEntryClick callback
    AddressBook->>User: Update recipient field
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • UTXO account detection logic: Review isUtxoAccountWithAddresses type guard and findUtxoAccountIdByAddress cache lookup patterns for correctness
  • React Query hook configuration: Validate useInternalAccountReceiveAddress skipToken conditions, stale time, and error handling
  • Form context integration: Verify form value setting in InternalAccountButton respects existing form state
  • Selector filtering logic: Confirm selectInternalAccountsBySearchQuery matchSorter keys and account metadata integration
  • Component memoization: Ensure proper prop comparison for memoized components to avoid unnecessary renders

Possibly related PRs

Suggested reviewers

  • 0xApotheosis
  • gomesalexandre

Poem

🐰 Internal wallets hop into view,
No more searches—just click and choose!
UTXO addresses resolved with care,
Your funds now listed, bright and fair!
Thump thump—address book complete! 🥕

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Title clearly describes the main feature: adding an internal account list to the address book component.
Linked Issues check ✅ Passed PR implements the core requirement: internal accounts are displayed in address book [#10920] with search support and account selection functionality.
Out of Scope Changes check ✅ Passed All changes are directly related to the linked issue objective of displaying internal accounts in address book.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch address-book-internal-list

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 9f1adab and 028efdf.

📒 Files selected for processing (5)
  • src/assets/translations/en/main.json (1 hunks)
  • src/components/Modals/Send/AddressBook/AddressBook.tsx (4 hunks)
  • src/components/Modals/Send/views/Address.tsx (1 hunks)
  • src/lib/utils/accounts.ts (2 hunks)
  • src/state/slices/common-selectors.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/lib/utils/accounts.ts
  • src/state/slices/common-selectors.ts
  • src/components/Modals/Send/AddressBook/AddressBook.tsx
🧰 Additional context used
📓 Path-based instructions (5)
**/*

📄 CodeRabbit inference engine (.cursor/rules/naming-conventions.mdc)

**/*: ALWAYS use appropriate file extensions
Flag files without kebab-case

Files:

  • src/assets/translations/en/main.json
  • src/components/Modals/Send/views/Address.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/error-handling.mdc)

**/*.{ts,tsx}: ALWAYS use Result<T, E> pattern for error handling in swappers and APIs
ALWAYS use Ok() and Err() from @sniptt/monads for monadic error handling
ALWAYS use custom error classes from @shapeshiftoss/errors
ALWAYS provide meaningful error codes for internationalization
ALWAYS include relevant details in error objects
ALWAYS wrap async operations in try-catch blocks
ALWAYS use AsyncResultOf utility for converting promises to Results
ALWAYS provide fallback error handling
ALWAYS use timeoutMonadic for API calls
ALWAYS provide appropriate timeout values for API calls
ALWAYS handle timeout errors gracefully
ALWAYS validate inputs before processing
ALWAYS provide clear validation error messages
ALWAYS use early returns for validation failures
ALWAYS log errors for debugging
ALWAYS use structured logging for errors
ALWAYS include relevant context in error logs
Throwing errors instead of using monadic patterns is an anti-pattern
Missing try-catch blocks for async operations is an anti-pattern
Generic error messages without context are an anti-pattern
Not handling specific error types is an anti-pattern
Missing timeout handling is an anti-pattern
No input validation is an anti-pattern
Poor error logging is an anti-pattern
Using any for error types is an anti-pattern
Missing error codes for internationalization is an anti-pattern
No fallback error handling is an anti-pattern
Console.error without structured logging is an anti-pattern

**/*.{ts,tsx}: ALWAYS use camelCase for variables, functions, and methods
ALWAYS use descriptive names that explain the purpose for variables and functions
ALWAYS use verb prefixes for functions that perform actions
ALWAYS use PascalCase for types, interfaces, and enums
ALWAYS use descriptive names that indicate the structure for types, interfaces, and enums
ALWAYS use suffixes like Props, State, Config, Type when appropriate for types and interfaces
ALWAYS use UPPER_SNAKE_CASE for constants and configuration values
ALWAYS use d...

Files:

  • src/components/Modals/Send/views/Address.tsx
**/*.tsx

📄 CodeRabbit inference engine (.cursor/rules/error-handling.mdc)

**/*.tsx: ALWAYS wrap components in error boundaries
ALWAYS provide user-friendly fallback components in error boundaries
ALWAYS log errors for debugging in error boundaries
ALWAYS use useErrorToast hook for displaying errors
ALWAYS provide translated error messages in error toasts
ALWAYS handle different error types appropriately in error toasts
Missing error boundaries in React components is an anti-pattern

**/*.tsx: ALWAYS use PascalCase for React component names
ALWAYS use descriptive names that indicate the component's purpose
ALWAYS match the component name to the file name
Flag components without PascalCase
Flag default exports for components

Files:

  • src/components/Modals/Send/views/Address.tsx
**/*.{tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/react-best-practices.mdc)

**/*.{tsx,jsx}: ALWAYS use useMemo for expensive computations, object/array creations, and filtered data
ALWAYS use useMemo for derived values and computed properties
ALWAYS use useMemo for conditional values and simple transformations
ALWAYS use useCallback for event handlers and functions passed as props
ALWAYS use useCallback for any function that could be passed as a prop or dependency
ALWAYS include all dependencies in useEffect, useMemo, useCallback dependency arrays
NEVER use // eslint-disable-next-line react-hooks/exhaustive-deps unless absolutely necessary
ALWAYS explain why dependencies are excluded if using eslint disable
ALWAYS use named exports for components
NEVER use default exports for components
KEEP component files under 200 lines when possible
BREAK DOWN large components into smaller, reusable pieces
EXTRACT complex logic into custom hooks
USE local state for component-level state
LIFT state up when needed across multiple components
USE Context for avoiding prop drilling
ALWAYS wrap components in error boundaries for production
ALWAYS handle async errors properly
ALWAYS provide user-friendly error messages
ALWAYS use virtualization for lists with 100+ items
ALWAYS implement proper key props for list items
ALWAYS lazy load heavy components
ALWAYS use React.lazy for code splitting
Components receiving props are wrapped with memo

Files:

  • src/components/Modals/Send/views/Address.tsx
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/react-best-practices.mdc)

USE Redux only for global state shared across multiple places

Files:

  • src/components/Modals/Send/views/Address.tsx
🧠 Learnings (6)
📓 Common learnings
Learnt from: NeOMakinG
Repo: shapeshift/web PR: 10231
File: src/components/AssetSearch/components/AssetList.tsx:2-2
Timestamp: 2025-08-08T15:00:49.887Z
Learning: Project shapeshift/web: NeOMakinG prefers avoiding minor a11y/UI nitpicks (e.g., adding aria-hidden to decorative icons in empty states like src/components/AssetSearch/components/AssetList.tsx) within feature PRs; defer such suggestions to a follow-up instead of blocking the PR.
Learnt from: premiumjibles
Repo: shapeshift/web PR: 10386
File: src/components/MultiHopTrade/components/VerifyAddresses/VerifyAddresses.tsx:272-294
Timestamp: 2025-08-29T07:07:49.332Z
Learning: In UTXO sell address verification flow in VerifyAddresses.tsx, the user wants address verification to be marked as "verified/complete" before starting the change address fetch, not after. The verification step and change address fetch should be treated as separate sequential operations in the UI flow.
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10871
File: src/components/Modals/Send/hooks/useSendDetails/useSendDetails.tsx:426-428
Timestamp: 2025-10-21T17:11:18.087Z
Learning: In src/components/Modals/Send/hooks/useSendDetails/useSendDetails.tsx, within the handleInputChange function, use .toFixed() without arguments (not .toString()) when converting BigNumber amounts for input field synchronization. This avoids exponential notation in the input while preserving precision for presentational components like <Amount.Crypto /> and <Amount.Fiat /> to format appropriately.
Learnt from: NeOMakinG
Repo: shapeshift/web PR: 10323
File: src/pages/RFOX/components/Stake/components/StakeSummary.tsx:112-114
Timestamp: 2025-08-22T13:00:44.879Z
Learning: NeOMakinG prefers to keep PR changes minimal and focused on the core objectives, avoiding cosmetic or defensive code improvements that aren't directly related to the PR scope, even when they would improve robustness.
Learnt from: NeOMakinG
Repo: shapeshift/web PR: 10128
File: .cursor/rules/error-handling.mdc:266-274
Timestamp: 2025-07-29T10:35:22.059Z
Learning: NeOMakinG prefers less nitpicky suggestions on documentation and best practices files, finding overly detailed suggestions on minor implementation details (like console.error vs logger.error) too granular for cursor rules documentation.
Learnt from: NeOMakinG
Repo: shapeshift/web PR: 10380
File: src/pages/Dashboard/components/AccountList/AccountTable.tsx:60-0
Timestamp: 2025-09-02T08:34:08.157Z
Learning: NeOMakinG prefers code review comments to focus only on actual PR changes, not pre-existing code issues, unless there are critical security or correctness concerns directly related to the new functionality.
Learnt from: NeOMakinG
Repo: shapeshift/web PR: 10234
File: src/components/MultiHopTrade/hooks/useGetTradeQuotes/hooks/useTrackTradeQuotes.ts:42-86
Timestamp: 2025-08-08T11:41:22.794Z
Learning: NeOMakinG prefers not to include refactors in move-only PRs; such suggestions should be deferred to follow-up issues instead of being applied within the same PR.
Learnt from: NeOMakinG
Repo: shapeshift/web PR: 10380
File: src/components/Table/Table.theme.ts:177-180
Timestamp: 2025-09-02T12:38:46.940Z
Learning: NeOMakinG prefers to defer technical debt and CSS correctness issues (like improper hover selectors) to follow-up PRs when the current PR is already large and focused on major feature implementation, even when the issues are valid from a usability/technical perspective.
📚 Learning: 2025-10-21T23:21:22.304Z
Learnt from: premiumjibles
Repo: shapeshift/web PR: 10759
File: src/components/Modals/Send/hooks/useFormSend/useFormSend.tsx:41-50
Timestamp: 2025-10-21T23:21:22.304Z
Learning: In the shapeshift/web repository, the translation workflow follows an "English-first" approach: English translations in src/assets/translations/en/main.json are updated first in PRs, and translations for the other supported languages (de, es, fr, id, ja, ko, pt, ru, tr, uk, zh) are updated "after the fact" in follow-up work. Temporary mismatches between English and other language translation keys/formats during active development are expected and acceptable.
<!--

Applied to files:

  • src/assets/translations/en/main.json
📚 Learning: 2025-07-24T21:05:13.642Z
Learnt from: 0xApotheosis
Repo: shapeshift/web PR: 10073
File: src/components/Layout/Header/ActionCenter/components/Details/ClaimDetails.tsx:10-11
Timestamp: 2025-07-24T21:05:13.642Z
Learning: In the ShapeShift web repository, translation workflow follows a two-step process: 1) First PR adds only English translations to src/assets/translations/en/main.json, 2) Globalization team handles follow-up PRs to add keys to remaining language files (de, es, fr, id, ja, ko, pt, ru, tr, uk, zh). Don't suggest verifying all locale files simultaneously during initial feature PRs.

Applied to files:

  • src/assets/translations/en/main.json
📚 Learning: 2025-08-17T23:39:00.407Z
Learnt from: premiumjibles
Repo: shapeshift/web PR: 10291
File: src/assets/translations/en/main.json:216-218
Timestamp: 2025-08-17T23:39:00.407Z
Learning: In the shapeshift/web project, translations for non-English locales are handled as a separate follow-up process by language experts, not as part of the initial PR that adds English keys to src/assets/translations/en/main.json.

Applied to files:

  • src/assets/translations/en/main.json
📚 Learning: 2025-10-21T17:11:18.087Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10871
File: src/components/Modals/Send/hooks/useSendDetails/useSendDetails.tsx:426-428
Timestamp: 2025-10-21T17:11:18.087Z
Learning: In src/components/Modals/Send/hooks/useSendDetails/useSendDetails.tsx, within the handleInputChange function, use .toFixed() without arguments (not .toString()) when converting BigNumber amounts for input field synchronization. This avoids exponential notation in the input while preserving precision for presentational components like <Amount.Crypto /> and <Amount.Fiat /> to format appropriately.

Applied to files:

  • src/components/Modals/Send/views/Address.tsx
📚 Learning: 2025-08-08T15:00:49.887Z
Learnt from: NeOMakinG
Repo: shapeshift/web PR: 10231
File: src/components/AssetSearch/components/AssetList.tsx:2-2
Timestamp: 2025-08-08T15:00:49.887Z
Learning: Project shapeshift/web: NeOMakinG prefers avoiding minor a11y/UI nitpicks (e.g., adding aria-hidden to decorative icons in empty states like src/components/AssetSearch/components/AssetList.tsx) within feature PRs; defer such suggestions to a follow-up instead of blocking the PR.

Applied to files:

  • src/components/Modals/Send/views/Address.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Install and Cache
🔇 Additional comments (2)
src/components/Modals/Send/views/Address.tsx (1)

247-247: LGTM!

The added blank line improves readability by providing visual separation between the body and footer sections.

src/assets/translations/en/main.json (1)

1102-1103: LGTM!

The new translation keys are well-structured and follow existing naming conventions. "yourWallets" provides a clear section header, and "noInternalAccounts" delivers an appropriate empty state message consistent with other patterns in the file (e.g., "noEntries" at line 1101).


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@NeOMakinG NeOMakinG changed the title feat: improve internal accounts display in Send address book feat: internal account list in address book Oct 28, 2025
@NeOMakinG NeOMakinG changed the base branch from address-book to utxo-match October 28, 2025 16:16
@NeOMakinG NeOMakinG marked this pull request as ready for review October 29, 2025 13:59
@NeOMakinG NeOMakinG requested a review from a team as a code owner October 29, 2025 13:59
@premiumjibles premiumjibles self-requested a review November 9, 2025 23:16
Copy link
Collaborator

@premiumjibles premiumjibles left a comment

Choose a reason for hiding this comment

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

Overall works as advertised and code looks sane 👌 . Few nitpicky things to action if you like but none blocking

Base automatically changed from utxo-match to develop November 11, 2025 01:43
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

🧹 Nitpick comments (4)
src/lib/utils/accounts.ts (1)

37-41: Type guard implementation is correct.

The function properly narrows the type and checks both conditions. The Boolean() wrapper is redundant since the expression already returns a boolean, but this is a minor style preference.

If you prefer a cleaner implementation:

 export const isUtxoAccountWithAddresses = (
   account: Account<KnownChainIds>,
 ): account is Account<UtxoChainId> => {
-  return Boolean(isUtxoChainId(account?.chainId) && 'addresses' in account.chainSpecific)
+  return isUtxoChainId(account?.chainId) && 'addresses' in account.chainSpecific
 }
src/components/Modals/Send/AddressBook/hooks/useInternalAccountReceiveAddress.tsx (2)

40-44: Remove redundant null checks inside queryFn.

The queryFn at line 40 only executes when enabled && !isInitializing && asset && wallet && accountId && accountMetadata are all truthy. The null checks at lines 42-44 are therefore redundant.

Apply this diff to simplify the code:

     queryFn:
       enabled && !isInitializing && asset && wallet && accountId && accountMetadata
         ? async () => {
-            if (!asset || !wallet || !accountId || !accountMetadata) {
-              return null
-            }
-
             const assetChainId = asset.chainId

53-54: Replace error throw with null return for missing accountType.

Throwing an error here will cause the query to fail and potentially crash the UI. For a better user experience, return null to handle the missing accountType gracefully, similar to the chain mismatch handling at lines 49-51.

Apply this diff:

             if (isUtxoAccountId(accountId) && !accountMetadata?.accountType)
-              throw new Error(`Missing accountType for UTXO account ${accountId}`)
+              return null
src/state/slices/portfolioSlice/selectors.ts (1)

1280-1301: Sort results by account number for consistent ordering.

The selector currently returns results sorted by match relevance when a search query is present, and in arbitrary order when no search query is provided. For consistency and better UX, the results should be sorted by account number in ascending order.

Apply this diff to sort by account number:

 export const selectInternalAccountsBySearchQuery = createDeepEqualOutputSelector(
   selectAccountIdsByChainIdFilter,
   selectPortfolioAccountMetadata,
   selectSearchQueryFromFilter,
   (accountIds, accountMetadata, searchQuery): AccountId[] => {
-    if (!searchQuery) return accountIds
+    const filteredAccountIds = searchQuery
+      ? matchSorter(accountIds, searchQuery, {
+          keys: [
+            { key: (accountId: AccountId) => fromAccountId(accountId).account },
+            { key: (accountId: AccountId) => accountIdToLabel(accountId) },
+            {
+              key: (accountId: AccountId) => {
+                const metadata = accountMetadata[accountId]
+                return metadata?.bip44Params?.accountNumber?.toString() ?? ''
+              },
+            },
+          ],
+          threshold: matchSorter.rankings.CONTAINS,
+        })
+      : accountIds
 
-    return matchSorter(accountIds, searchQuery, {
-      keys: [
-        { key: (accountId: AccountId) => fromAccountId(accountId).account },
-        { key: (accountId: AccountId) => accountIdToLabel(accountId) },
-        {
-          key: (accountId: AccountId) => {
-            const metadata = accountMetadata[accountId]
-            return metadata?.bip44Params?.accountNumber?.toString() ?? ''
-          },
-        },
-      ],
-      threshold: matchSorter.rankings.CONTAINS,
-    })
+    // Sort by account number for consistent ordering
+    return filteredAccountIds.sort((a, b) => {
+      const accountNumberA = accountMetadata[a]?.bip44Params?.accountNumber ?? 0
+      const accountNumberB = accountMetadata[b]?.bip44Params?.accountNumber ?? 0
+      return accountNumberA - accountNumberB
+    })
   },
 )

Based on previous review feedback suggesting sorting by account number.

@NeOMakinG NeOMakinG merged commit daa0f72 into develop Nov 11, 2025
4 checks passed
@NeOMakinG NeOMakinG deleted the address-book-internal-list branch November 11, 2025 10:32
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.

Show all internal addresses inside the address book

2 participants