@@ -160,6 +160,7 @@ export default class HardwareWalletsStore extends Store {
160160 @observable isListeningForDevice: boolean = false ;
161161 @observable isConnectInitiated: boolean = false ;
162162 @observable isExportKeyAborted: boolean = false ;
163+ @observable activeDelegationWalletId: ?string = null ;
163164
164165 cardanoAdaAppPollingInterval: ?IntervalID = null ;
165166 checkTransactionTimeInterval: ?IntervalID = null ;
@@ -432,7 +433,16 @@ export default class HardwareWalletsStore extends Store {
432433 // Check if active wallet exist - this means that hw exist but we need to check if relevant device connected to it
433434 let recognizedPairedHardwareWallet ;
434435 let relatedConnectionData ;
435- const activeWalletId = get ( this . stores . wallets , [ 'active' , 'id' ] ) ;
436+
437+ let activeWalletId ;
438+ if ( this . activeDelegationWalletId && this . isTransactionInitiated ) {
439+ // Active wallet can be different that wallet we want to delegate
440+ activeWalletId = this . activeDelegationWalletId ;
441+ } else {
442+ // For regular tx we are using active wallet
443+ activeWalletId = get ( this . stores . wallets , [ 'active' , 'id' ] ) ;
444+ }
445+
436446 if ( activeWalletId ) {
437447 // Check if device connected to wallet
438448 logger . debug ( '[HW-DEBUG] HWStore - active wallet exists' ) ;
@@ -1375,11 +1385,12 @@ export default class HardwareWalletsStore extends Store {
13751385 } ;
13761386
13771387 initiateTransaction = async ( params : { walletId : ?string } ) = > {
1388+ const { walletId } = params ;
13781389 runInAction ( 'HardwareWalletsStore:: Initiate Transaction' , ( ) => {
13791390 this . isTransactionInitiated = true ;
13801391 this . hwDeviceStatus = HwDeviceStatuses . CONNECTING ;
1392+ this . activeDelegationWalletId = walletId ;
13811393 } ) ;
1382- const { walletId } = params ;
13831394 const hardwareWalletConnectionData = get (
13841395 this . hardwareWalletsConnectionData ,
13851396 walletId
@@ -1444,7 +1455,6 @@ export default class HardwareWalletsStore extends Store {
14441455 throw e ;
14451456 }
14461457 }
1447-
14481458 runInAction (
14491459 'HardwareWalletsStore:: Set active device path for Transaction send' ,
14501460 ( ) => {
@@ -1455,7 +1465,6 @@ export default class HardwareWalletsStore extends Store {
14551465 // Add more cases / edge cases if needed
14561466 if ( deviceType === DeviceTypes . TREZOR && walletId ) {
14571467 logger . debug ( '[HW-DEBUG] Sign Trezor: ' , { id } ) ;
1458-
14591468 const transportDevice = await this . establishHardwareWalletConnection ( ) ;
14601469 if ( transportDevice ) {
14611470 runInAction (
@@ -1505,6 +1514,7 @@ export default class HardwareWalletsStore extends Store {
15051514 this . txBody = null ;
15061515 this . activeDevicePath = null ;
15071516 this . unfinishedWalletTxSigning = null ;
1517+ this . activeDelegationWalletId = null ;
15081518 } ) ;
15091519 } ;
15101520
0 commit comments