@@ -657,23 +657,21 @@ export class AccountsController extends BaseController<
657657 * @returns The list of accounts associcated with this keyring type.
658658 */
659659 #getAccountsByKeyringType( keyringType : string ) {
660- return this . listAccounts ( ) . filter (
661- ( internalAccount ) => {
662- // We do consider `hd` and `simple` keyrings to be of same type. So we check those 2 types
663- // to group those accounts together!
664- if (
665- keyringType === KeyringTypes . hd ||
666- keyringType === KeyringTypes . simple
667- ) {
668- return (
669- internalAccount . metadata . keyring . type === KeyringTypes . hd ||
670- internalAccount . metadata . keyring . type === KeyringTypes . simple
671- ) ;
672- }
660+ return this . listAccounts ( ) . filter ( ( internalAccount ) => {
661+ // We do consider `hd` and `simple` keyrings to be of same type. So we check those 2 types
662+ // to group those accounts together!
663+ if (
664+ keyringType === KeyringTypes . hd ||
665+ keyringType === KeyringTypes . simple
666+ ) {
667+ return (
668+ internalAccount . metadata . keyring . type === KeyringTypes . hd ||
669+ internalAccount . metadata . keyring . type === KeyringTypes . simple
670+ ) ;
671+ }
673672
674- return internalAccount . metadata . keyring . type === keyringType ;
675- } ,
676- ) ;
673+ return internalAccount . metadata . keyring . type === keyringType ;
674+ } ) ;
677675 }
678676
679677 /**
@@ -687,27 +685,27 @@ export class AccountsController extends BaseController<
687685 } {
688686 const keyringName = keyringTypeToName ( keyringType ) ;
689687 const keyringAccounts = this . #getAccountsByKeyringType( keyringType ) ;
690- const lastDefaultIndexUsedForKeyringType =
691- keyringAccounts
692- . reduce ( ( maxInternalAccountIndex , internalAccount ) => {
693- // We **DO NOT USE** `\d+` here to only consider valid "human"
694- // number (rounded decimal number)
695- const match = ( new RegExp ( `${ keyringName } ([0-9]+)$` , 'u' ) ) . exec (
696- internalAccount . metadata . name ,
697- ) ;
698-
699- if ( match ) {
700- // Quoting `RegExp.exec` documentation:
701- // > The returned array has the matched text as the first item, and then one item for
702- // > each capturing group of the matched text.
703- // So use `match[1]` to get the captured value
704- const internalAccountIndex = parseInt ( match [ 1 ] , 10 ) ;
705- return Math . max ( maxInternalAccountIndex , internalAccountIndex ) ;
706- }
688+ const lastDefaultIndexUsedForKeyringType = keyringAccounts . reduce (
689+ ( maxInternalAccountIndex , internalAccount ) => {
690+ // We **DO NOT USE** `\d+` here to only consider valid "human"
691+ // number (rounded decimal number)
692+ const match = new RegExp ( `${ keyringName } ([0-9]+)$` , 'u' ) . exec (
693+ internalAccount . metadata . name ,
694+ ) ;
707695
708- return maxInternalAccountIndex ;
696+ if ( match ) {
697+ // Quoting `RegExp.exec` documentation:
698+ // > The returned array has the matched text as the first item, and then one item for
699+ // > each capturing group of the matched text.
700+ // So use `match[1]` to get the captured value
701+ const internalAccountIndex = parseInt ( match [ 1 ] , 10 ) ;
702+ return Math . max ( maxInternalAccountIndex , internalAccountIndex ) ;
703+ }
709704
710- } , 0 ) ;
705+ return maxInternalAccountIndex ;
706+ } ,
707+ 0 ,
708+ ) ;
711709
712710 const indexToUse = Math . max (
713711 keyringAccounts . length + 1 ,
0 commit comments