Skip to content

Commit 16e259f

Browse files
authored
Merge pull request #3093 from input-output-hk/chore/ddw-1179-update-ledgerjs-to-v6.0.0
2 parents 48ef792 + 0254fb7 commit 16e259f

File tree

11 files changed

+129
-113
lines changed

11 files changed

+129
-113
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## vNext
44

5+
### Chores
6+
7+
- Updated `@cardano-foundation/ledgerjs-hw-app-cardano` to version `6.0.0` ([PR 3093](https://github.com/input-output-hk/daedalus/pull/3093))
8+
59
## 5.2.0
610

711
### Features

installers/common/MacInstaller.hs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,6 @@ sign_cmd "$ABS_PATH/Contents/Resources/app/node_modules/blake-hash/prebuilds/dar
156156
sign_cmd "$ABS_PATH/Contents/Resources/app/node_modules/blake-hash/bin/darwin-x64-"*"/blake-hash.node"
157157
sign_cmd "$ABS_PATH/Contents/Resources/app/node_modules/blake-hash/bin/darwin-arm64-"*"/blake-hash.node"
158158
sign_cmd "$ABS_PATH/Contents/Resources/app/node_modules/blake-hash/build/Release/addon.node"
159-
sign_cmd "$ABS_PATH/Contents/Resources/app/node_modules/blake2/build/Release/binding.node"
160-
sign_cmd "$ABS_PATH/Contents/Resources/app/node_modules/blake2/bin/darwin-x64-"*"/blake2.node"
161-
sign_cmd "$ABS_PATH/Contents/Resources/app/node_modules/blake2/bin/darwin-arm64-"*"/blake2.node"
162159
sign_cmd "$ABS_PATH/Contents/Resources/app/node_modules/tiny-secp256k1/build/Release/secp256k1.node"
163160
sign_cmd "$ABS_PATH/Contents/Resources/app/node_modules/tiny-secp256k1/bin/darwin-x64-"*"/tiny-secp256k1.node"
164161
sign_cmd "$ABS_PATH/Contents/Resources/app/node_modules/tiny-secp256k1/bin/darwin-arm64-"*"/tiny-secp256k1.node"
@@ -241,7 +238,6 @@ buildElectronApp darwinConfig@DarwinConfig{dcAppName, dcAppNameApp} installerCon
241238
, "bip66"
242239
, "bitcoin-ops"
243240
, "blake-hash"
244-
, "blake2"
245241
, "blake2b"
246242
, "blake2b-wasm"
247243
, "bn.js"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@
201201
"yarn-lockfile": "1.1.1"
202202
},
203203
"dependencies": {
204-
"@cardano-foundation/ledgerjs-hw-app-cardano": "5.1.0",
204+
"@cardano-foundation/ledgerjs-hw-app-cardano": "6.0.0",
205205
"@iohk-jormungandr/wallet-js": "0.5.0-pre7",
206206
"@ledgerhq/hw-transport-node-hid": "6.27.1",
207207
"@trezor/connect": "9.0.2",

source/common/types/hardware-wallets.types.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
import { BridgeInfo, Device as TrezorDevice, UdevInfo } from '@trezor/connect';
2+
import {
3+
TxOutputDestinationType,
4+
AddressType,
5+
CIP36VoteRegistrationFormat,
6+
TxAuxiliaryDataType,
7+
} from '@cardano-foundation/ledgerjs-hw-app-cardano';
28

39
export type BIP32Path = Array<number>;
410
export type LedgerModel = 'nanoS' | 'nanoSP' | 'nanoX';
@@ -139,14 +145,18 @@ export type LedgerSignTransactionOutputsType =
139145
| []
140146
| Array<LedgerOutputTypeAddress | LedgerOutputTypeChange>;
141147
export type LedgerAuxiliaryDataType = {
142-
type: string;
148+
type: TxAuxiliaryDataType;
143149
params: {
144-
votingPublicKeyHex: string;
150+
format: CIP36VoteRegistrationFormat;
151+
voteKeyHex: string;
145152
stakingPath: BIP32Path;
146-
rewardsDestination: {
147-
type: number;
153+
paymentDestination: {
154+
type: TxOutputDestinationType;
148155
params: {
149-
stakingPath: BIP32Path;
156+
type: AddressType;
157+
params: {
158+
stakingPath: BIP32Path;
159+
};
150160
};
151161
};
152162
nonce: string;
@@ -199,7 +209,7 @@ export type LedgerSignTransactionResponse = {
199209
txHashHex: string;
200210
witnesses: Array<Witness>;
201211
auxiliaryDataSupplement?: {
202-
catalystRegistrationSignatureHex: string;
212+
cip36VoteRegistrationSignatureHex: string;
203213
auxiliaryDataHashHex: string;
204214
type: 'catalyst_registration';
205215
};

source/main/ipc/getHardwareWalletChannel.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import TransportNodeHid, {
33
getDevices,
44
} from '@ledgerhq/hw-transport-node-hid-noevents';
55
import AppAda, { utils } from '@cardano-foundation/ledgerjs-hw-app-cardano';
6+
import { str_to_path } from '@cardano-foundation/ledgerjs-hw-app-cardano/dist/utils/address';
7+
import { HexString } from '@cardano-foundation/ledgerjs-hw-app-cardano/dist/types/internal';
68
import TrezorConnect, {
79
DEVICE,
810
DEVICE_EVENT,
@@ -455,7 +457,7 @@ export const handleHardwareWalletRequests = async (
455457
});
456458
deriveXpubChannel.onRequest(async (params) => {
457459
const { parentXpubHex, lastIndex, derivationScheme } = params;
458-
const parentXpub = utils.hex_to_buf(parentXpubHex);
460+
const parentXpub = utils.hex_to_buf(parentXpubHex as HexString);
459461

460462
try {
461463
const xpub = deriveChildXpub(parentXpub, lastIndex, derivationScheme);
@@ -474,10 +476,8 @@ export const handleHardwareWalletRequests = async (
474476
networkId,
475477
protocolMagic,
476478
} = params;
477-
const spendingPath = utils.str_to_path(spendingPathStr);
478-
const stakingPath = stakingPathStr
479-
? utils.str_to_path(stakingPathStr)
480-
: null;
479+
const spendingPath = str_to_path(spendingPathStr);
480+
const stakingPath = stakingPathStr ? str_to_path(stakingPathStr) : null;
481481

482482
deviceConnection = get(devicesMemo, [devicePath, 'AdaConnection']);
483483

@@ -542,10 +542,8 @@ export const handleHardwareWalletRequests = async (
542542
networkId,
543543
protocolMagic,
544544
} = params;
545-
const spendingPath = utils.str_to_path(spendingPathStr);
546-
const stakingPath = stakingPathStr
547-
? utils.str_to_path(stakingPathStr)
548-
: null;
545+
const spendingPath = str_to_path(spendingPathStr);
546+
const stakingPath = stakingPathStr ? str_to_path(stakingPathStr) : null;
549547

550548
try {
551549
deviceConnection = get(devicesMemo, [devicePath, 'AdaConnection']);
@@ -804,9 +802,8 @@ export const handleHardwareWalletRequests = async (
804802
if (!deviceConnection) {
805803
throw new Error('Ledger device not connected');
806804
}
807-
808805
const extendedPublicKey = await deviceConnection.getExtendedPublicKey({
809-
path: utils.str_to_path(path),
806+
path: str_to_path(path),
810807
});
811808
const deviceSerial = await deviceConnection.getSerial();
812809
return Promise.resolve({

source/renderer/app/components/wallet/receive/WalletReceiveDialog.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React, { Component } from 'react';
22
import { observer } from 'mobx-react';
3-
import { utils } from '@cardano-foundation/ledgerjs-hw-app-cardano';
43
import { map, filter } from 'lodash';
54
import { defineMessages, intlShape, FormattedHTMLMessage } from 'react-intl';
65
import classnames from 'classnames';
@@ -12,6 +11,7 @@ import { PopOver } from 'react-polymorph/lib/components/PopOver';
1211
import QRCode from 'qrcode.react';
1312
import { Checkbox } from 'react-polymorph/lib/components/Checkbox';
1413
import { CheckboxSkin } from 'react-polymorph/lib/skins/simple/CheckboxSkin';
14+
import { str_to_path } from '@cardano-foundation/ledgerjs-hw-app-cardano/dist/utils/address';
1515
import RadioSet from '../../widgets/RadioSet';
1616
import Dialog from '../../widgets/Dialog';
1717
import DialogCloseButton from '../../widgets/DialogCloseButton';
@@ -196,7 +196,7 @@ class WalletReceiveDialog extends Component<Props, State> {
196196
field.value = field.value.replace(/\n/g, '');
197197
};
198198
constructPaths = (address: WalletAddress) => {
199-
const hardenedSpendingPath = utils.str_to_path(address.spendingPath);
199+
const hardenedSpendingPath = str_to_path(address.spendingPath);
200200
const derivationSpendingPath = hardenedPathToDerivationPath(
201201
hardenedSpendingPath
202202
);

source/renderer/app/stores/HardwareWalletsStore.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2639,7 +2639,7 @@ export default class HardwareWalletsStore extends Store {
26392639
txAuxiliaryData = cborizeTxAuxiliaryVotingData(
26402640
unsignedTxAuxiliaryData,
26412641
signedTransaction.auxiliaryDataSupplement
2642-
.catalystRegistrationSignatureHex
2642+
.cip36VoteRegistrationSignatureHex
26432643
);
26442644
}
26452645

source/renderer/app/utils/hardwareWalletUtils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import _ from 'lodash';
22
import { bech32 } from 'bech32';
3-
import { utils } from '@cardano-foundation/ledgerjs-hw-app-cardano';
3+
import { str_to_path } from '@cardano-foundation/ledgerjs-hw-app-cardano/dist/utils/address';
44
import { HARDENED } from '../config/hardwareWalletsConfig';
55
// Types
66
import type { CoinSelectionAssetsType } from '../api/transactions/types';
@@ -73,7 +73,7 @@ export const derivationPathToLedgerPath = (derivationPath: Array<string>) => {
7373

7474
const constructedPath = _.join(transformedPath, '/');
7575

76-
return utils.str_to_path(constructedPath);
76+
return str_to_path(constructedPath);
7777
};
7878
export const getParamsFromPath = (derivationPath: Array<string>) => {
7979
const pathParams = _.takeRight(derivationPath, 2);

source/renderer/app/utils/shelleyLedger.ts

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ import {
44
AddressType,
55
TxAuxiliaryDataType, // CHECK THIS
66
StakeCredentialParamsType,
7+
CIP36VoteRegistrationFormat,
78
} from '@cardano-foundation/ledgerjs-hw-app-cardano';
9+
import {
10+
str_to_path,
11+
base58_decode,
12+
} from '@cardano-foundation/ledgerjs-hw-app-cardano/dist/utils/address';
13+
import { HexString } from '@cardano-foundation/ledgerjs-hw-app-cardano/dist/types/internal';
814
import { encode } from 'borc';
915
import blakejs from 'blakejs';
1016
import _ from 'lodash';
@@ -173,7 +179,7 @@ export function ShelleyTxOutput(
173179
const addressBuff =
174180
addressStyle === AddressStyles.ADDRESS_SHELLEY
175181
? utils.bech32_decodeAddress(address)
176-
: utils.base58_decode(address);
182+
: base58_decode(address);
177183
return encoder.pushAny([addressBuff, coins]);
178184
}
179185

@@ -403,8 +409,7 @@ export const CachedDeriveXpubFactory = (
403409
lastIndex,
404410
derivationScheme: derivationScheme.ed25519Mode,
405411
});
406-
// @ts-ignore
407-
return utils.hex_to_buf(derivedXpub);
412+
return utils.hex_to_buf(derivedXpub as HexString);
408413
} catch (e) {
409414
throw e;
410415
}
@@ -442,7 +447,7 @@ export const prepareLedgerOutput = (
442447
type: AddressType.BASE_PAYMENT_KEY_STAKE_KEY,
443448
params: {
444449
spendingPath: derivationPathToLedgerPath(output.derivationPath),
445-
stakingPath: utils.str_to_path("1852'/1815'/0'/2/0"),
450+
stakingPath: str_to_path("1852'/1815'/0'/2/0"),
446451
},
447452
},
448453
},
@@ -458,7 +463,7 @@ export const prepareLedgerOutput = (
458463
addressHex:
459464
addressStyle === AddressStyles.ADDRESS_SHELLEY
460465
? utils.buf_to_hex(utils.bech32_decodeAddress(output.address))
461-
: utils.buf_to_hex(utils.base58_decode(output.address)),
466+
: utils.buf_to_hex(base58_decode(output.address)),
462467
},
463468
},
464469
amount: output.amount.quantity.toString(),
@@ -469,17 +474,20 @@ export const prepareLedgerAuxiliaryData = (
469474
txAuxiliaryData: TxAuxiliaryData
470475
) => {
471476
const { votingPubKey, rewardDestinationAddress, type } = txAuxiliaryData;
472-
473477
if (type === CATALYST_VOTING_REGISTRATION_TYPE) {
474478
return {
475-
type: TxAuxiliaryDataType.CATALYST_REGISTRATION,
479+
type: TxAuxiliaryDataType.CIP36_REGISTRATION,
476480
params: {
477-
votingPublicKeyHex: votingPubKey,
481+
format: CIP36VoteRegistrationFormat.CIP_15,
482+
voteKeyHex: votingPubKey,
478483
stakingPath: rewardDestinationAddress.stakingPath,
479-
rewardsDestination: {
480-
type: AddressType.REWARD_KEY,
484+
paymentDestination: {
485+
type: TxOutputDestinationType.DEVICE_OWNED,
481486
params: {
482-
stakingPath: rewardDestinationAddress.stakingPath,
487+
type: AddressType.REWARD_KEY,
488+
params: {
489+
stakingPath: rewardDestinationAddress.stakingPath,
490+
},
483491
},
484492
},
485493
nonce: `${txAuxiliaryData.nonce}`,

0 commit comments

Comments
 (0)