Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/ddw-645-update-react-pol…
Browse files Browse the repository at this point in the history
…ymorph-and-implement-the-search-style-variables' into feature/ddw-645-update-react-polymorph-and-implement-the-search-style-variables
  • Loading branch information
DeeJayElly committed Apr 15, 2021
2 parents 8eb1f96 + 67b6f04 commit be47158
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
@@ -1,6 +1,12 @@
Changelog
=========

## vNext

### Fixes

- Fixed hardware wallets spending password issue ([PR 2519](https://github.com/input-output-hk/daedalus/pull/2519))

## 4.0.5

### Features
Expand Down
14 changes: 10 additions & 4 deletions source/renderer/app/api/api.js
Expand Up @@ -255,12 +255,21 @@ export default class AdaApi {

getWallets = async (): Promise<Array<Wallet>> => {
logger.debug('AdaApi::getWallets called');
const {
getHardwareWalletLocalData,
getHardwareWalletsLocalData,
} = global.daedalus.api.localStorage;
try {
const wallets: AdaWallets = await getWallets(this.config);
const legacyWallets: LegacyAdaWallets = await getLegacyWallets(
this.config
);
logger.debug('AdaApi::getWallets success', { wallets, legacyWallets });
const hwLocalData = await getHardwareWalletsLocalData();
logger.debug('AdaApi::getWallets success', {
wallets,
legacyWallets,
hwLocalData: filterLogData(hwLocalData),
});
map(legacyWallets, (legacyAdaWallet) => {
const extraLegacyWalletProps = {
address_pool_gap: 0, // Not needed for legacy wallets
Expand All @@ -281,9 +290,6 @@ export default class AdaApi {
return await Promise.all(
wallets.map(async (wallet) => {
const { id } = wallet;
const {
getHardwareWalletLocalData,
} = global.daedalus.api.localStorage;
const walletData = await getHardwareWalletLocalData(id);
return _createWalletFromServerData({
...wallet,
Expand Down
24 changes: 24 additions & 0 deletions source/renderer/app/stores/HardwareWalletsStore.js
Expand Up @@ -482,6 +482,9 @@ export default class HardwareWalletsStore extends Store {
logger.debug(
'[HW-DEBUG] HWStore - Establish connection:: Transaction initiated - Recognized device found'
);
logger.debug('[HW-DEBUG] HWStore - Set transport device 1', {
recognizedPairedHardwareWallet,
});
runInAction('HardwareWalletsStore:: Set transport device', () => {
this.transportDevice = recognizedPairedHardwareWallet;
});
Expand Down Expand Up @@ -532,6 +535,9 @@ export default class HardwareWalletsStore extends Store {
isTrezor,
}
);
logger.debug('[HW-DEBUG] HWStore - Set transport device 2', {
lastDeviceTransport,
});
runInAction('HardwareWalletsStore:: Set transport device', () => {
this.transportDevice = lastDeviceTransport;
});
Expand Down Expand Up @@ -649,6 +655,9 @@ export default class HardwareWalletsStore extends Store {
}

// All Checks pass - mark device as connected (set transport device for this session)
logger.debug('[HW-DEBUG] HWStore - Set transport device 3', {
transportDevice,
});
runInAction('HardwareWalletsStore:: set HW device CONNECTED', () => {
this.transportDevice = transportDevice;
});
Expand Down Expand Up @@ -1001,6 +1010,17 @@ export default class HardwareWalletsStore extends Store {
}

// Software Wallet not recognized, create new one with default name
logger.debug('[HW-DEBUG] HWStore - Initiate HW create / restore', {
transportDevice,
device: {
deviceId,
deviceType,
deviceModel,
deviceName,
path: forcedPath || path,
firmwareVersion: null,
},
});
await this.actions.wallets.createHardwareWallet.trigger({
walletName: deviceName || DEFAULT_HW_NAME,
extendedPublicKey,
Expand All @@ -1013,6 +1033,7 @@ export default class HardwareWalletsStore extends Store {
firmwareVersion: null,
},
});
logger.debug('[HW-DEBUG] HWStore - HW created / restored');

// Get all Pending devices with this path and delete
const recognizedPendingDevice = find(
Expand Down Expand Up @@ -1503,6 +1524,9 @@ export default class HardwareWalletsStore extends Store {
logger.debug('[HW-DEBUG] Sign Trezor: ', { id });
const transportDevice = await this.establishHardwareWalletConnection();
if (transportDevice) {
logger.debug('[HW-DEBUG] HWStore - Set transport device 4', {
transportDevice,
});
runInAction(
'HardwareWalletsStore:: Set transport device fomr tx init',
() => {
Expand Down
13 changes: 13 additions & 0 deletions source/renderer/app/stores/WalletsStore.js
Expand Up @@ -586,7 +586,18 @@ export default class WalletsStore extends Store {
const { deviceId, deviceType, deviceModel, deviceName, path } = device;
const accountPublicKey =
extendedPublicKey.publicKeyHex + extendedPublicKey.chainCodeHex;

logger.debug('[HW-DEBUG] HWStore - Execute HW create / restore', {
deviceId,
deviceType,
deviceModel,
deviceName,
path,
walletName,
});

try {
await this._pausePolling();
const wallet = await this.createHardwareWalletRequest.execute({
walletName,
accountPublicKey,
Expand Down Expand Up @@ -620,6 +631,8 @@ export default class WalletsStore extends Store {
}
} catch (error) {
throw error;
} finally {
this._resumePolling();
}
};

Expand Down

0 comments on commit be47158

Please sign in to comment.