Skip to content

Commit e034c90

Browse files
Tomislav Horačeknikolaglumac
andauthored
Fix Hardware Wallets delegation (#2369)
* Fix Hardware Wallets delegation * Adds CHANGELOG Co-authored-by: Nikola Glumac <niglumac@gmail.com>
1 parent dc14636 commit e034c90

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ Changelog
33

44
## 3.3.0
55

6+
### Fixes
7+
8+
- Fixed issue with hardware wallet delegation ([PR 2369](https://github.com/input-output-hk/daedalus/pull/2369))
9+
610
### Chores
711

812
- Updated `cardano-launcher` to version `0.20210215.0` ([PR 2363](https://github.com/input-output-hk/daedalus/pull/2363))

source/renderer/app/stores/HardwareWalletsStore.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)