@@ -119,33 +119,29 @@ export class KeystoneUSBKeyring {
119119 }
120120
121121 async setUpBridge ( ) {
122- if ( ! this . bridgeSetup ) {
123- await this . bridge . init ( this . xfp ) ;
124- this . bridgeSetup = true ;
125- }
122+ await this . bridge . init ( this . xfp ) ;
126123 }
127124
128- setHDPath ( hdPath : string ) {
125+ setHdPath ( hdPath : string ) {
129126 this . hdPath = hdPath ;
130127 }
131128
132129 async readKeyring ( ) : Promise < void > {
133130 await this . setUpBridge ( ) ;
134131 const paths = [ "m/44'/60'/0'" ] ;
135132 paths . push ( ...Array . from ( { length : 10 } , ( _ , i ) => `m/44'/60'/${ i } '/0/0` ) ) ;
136- const results = [ ] ;
137- for ( const path of paths ) {
138- const result = await this . bridge . getKeys ( [ path ] ) ;
139- results . push ( result ) ;
133+ const result = await this . bridge . getKeys ( paths ) ;
134+ if ( result === undefined ) {
135+ throw new Error ( `KeystoneError#getKeys.user_reject: user rejected the request` ) ;
140136 }
141- this . xfp = results [ 0 ] . mfp ;
142- const keys = results . map ( ( result ) => {
143- const key = result . keys [ 0 ] ;
137+ this . xfp = result . mfp ;
138+ const keys = result . keys . map ( ( key ) => {
144139 return {
145140 ...key ,
146141 path : key . path . replace ( "m/" , "" ) . replace ( "M/" , "" ) ,
147142 } ;
148143 } ) ;
144+
149145 const foundKey = keys . find ( ( key ) => key . path === "44'/60'/0'" ) ;
150146 this . hd_account = foundKey ? foundKey . xpub : "" ;
151147 const ledger_live_keys = keys . filter ( ( key ) => key . path !== "44'/60'/0'" ) ;
0 commit comments