File tree Expand file tree Collapse file tree 1 file changed +19
-4
lines changed
packages/keyring-controller/src Expand file tree Collapse file tree 1 file changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -856,12 +856,27 @@ export class KeyringController extends BaseController<
856
856
* Gets the seed phrase of the HD keyring.
857
857
*
858
858
* @param password - Password of the keyring.
859
+ * @param typeIndex - Hd keyring identifier
859
860
* @returns Promise resolving to the seed phrase.
860
861
*/
861
- async exportSeedPhrase ( password : string ) : Promise < Uint8Array > {
862
+ async exportSeedPhrase (
863
+ password : string ,
864
+ typeIndex : number ,
865
+ ) : Promise < Uint8Array > {
862
866
await this . verifyPassword ( password ) ;
863
- assertHasUint8ArrayMnemonic ( this . #keyrings[ 0 ] ) ;
864
- return this . #keyrings[ 0 ] . mnemonic ;
867
+
868
+ const keyring = this . getKeyringsByType ( KeyringTypes . hd ) . find (
869
+ ( innerKeyring ) =>
870
+ ( innerKeyring as EthKeyring < Json > & { opts : { typeIndex : number } } )
871
+ . opts . typeIndex === typeIndex ,
872
+ ) as EthKeyring < Json > ;
873
+
874
+ if ( ! keyring ) {
875
+ throw new Error ( KeyringControllerError . KeyringNotFound ) ;
876
+ }
877
+
878
+ assertHasUint8ArrayMnemonic ( keyring ) ;
879
+ return keyring . mnemonic ;
865
880
}
866
881
867
882
/**
@@ -2247,7 +2262,7 @@ export class KeyringController extends BaseController<
2247
2262
if ( type === KeyringTypes . hd ) {
2248
2263
await keyring . deserialize ( {
2249
2264
...( data ?? { } ) ,
2250
- typeIndex : lastIndexOfType ,
2265
+ typeIndex : lastIndexOfType + 1 ,
2251
2266
id : ulid ( ) ,
2252
2267
} ) ;
2253
2268
} else {
You can’t perform that action at this time.
0 commit comments