@trezor/connect 9.0.3 → 9.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/README.md +1 -1
  3. package/lib/api/authorizeCoinJoin.js +6 -2
  4. package/lib/api/binanceGetAddress.d.ts +1 -1
  5. package/lib/api/binanceSignTransaction.d.ts +1 -1
  6. package/lib/api/bitcoin/Fees.d.ts +1 -1
  7. package/lib/api/bitcoin/TransactionComposer.d.ts +1 -1
  8. package/lib/api/bitcoin/enhanceSignTx.js +1 -1
  9. package/lib/api/bitcoin/inputs.js +3 -2
  10. package/lib/api/bitcoin/refTx.js +3 -3
  11. package/lib/api/bitcoin/signtxVerify.d.ts +1 -1
  12. package/lib/api/blockchainDisconnect.d.ts +1 -1
  13. package/lib/api/blockchainDisconnect.js +1 -1
  14. package/lib/api/blockchainEstimateFee.d.ts +1 -1
  15. package/lib/api/blockchainGetAccountBalanceHistory.d.ts +1 -1
  16. package/lib/api/blockchainGetCurrentFiatRates.d.ts +1 -1
  17. package/lib/api/blockchainGetFiatRatesForTimestamps.d.ts +1 -1
  18. package/lib/api/blockchainGetTransactions.d.ts +1 -1
  19. package/lib/api/blockchainSetCustomBackend.d.ts +1 -1
  20. package/lib/api/blockchainSetCustomBackend.js +1 -1
  21. package/lib/api/blockchainSubscribe.d.ts +1 -1
  22. package/lib/api/blockchainSubscribeFiatRates.d.ts +1 -1
  23. package/lib/api/blockchainUnsubscribe.d.ts +1 -1
  24. package/lib/api/blockchainUnsubscribeFiatRates.d.ts +1 -1
  25. package/lib/api/cardano/cardanoAuxiliaryData.d.ts +1 -1
  26. package/lib/api/cardano/cardanoAuxiliaryData.js +38 -16
  27. package/lib/api/cardano/cardanoCertificate.d.ts +2 -2
  28. package/lib/api/cardano/cardanoInputs.d.ts +3 -3
  29. package/lib/api/cardano/cardanoOutputs.d.ts +1 -1
  30. package/lib/api/cardano/cardanoTokenBundle.d.ts +1 -1
  31. package/lib/api/cardanoGetAddress.d.ts +1 -1
  32. package/lib/api/cardanoSignTransaction.d.ts +2 -1
  33. package/lib/api/cardanoSignTransaction.js +23 -3
  34. package/lib/api/common/Discovery.d.ts +2 -2
  35. package/lib/api/common/paramsValidator.d.ts +2 -2
  36. package/lib/api/composeTransaction.d.ts +1 -1
  37. package/lib/api/eos/eosSignTx.js +1 -1
  38. package/lib/api/eosSignTransaction.d.ts +1 -1
  39. package/lib/api/ethereumGetAddress.d.ts +1 -1
  40. package/lib/api/ethereumGetPublicKey.d.ts +1 -1
  41. package/lib/api/ethereumSignTransaction.d.ts +1 -1
  42. package/lib/api/ethereumSignTypedData.d.ts +1 -1
  43. package/lib/api/firmware/uploadFirmware.d.ts +2 -2
  44. package/lib/api/firmwareUpdate.d.ts +1 -1
  45. package/lib/api/firmwareUpdate.js +1 -1
  46. package/lib/api/getAccountInfo.d.ts +1 -1
  47. package/lib/api/getAddress.d.ts +1 -1
  48. package/lib/api/getCoinInfo.d.ts +2 -2
  49. package/lib/api/getOwnershipProof.d.ts +1 -5
  50. package/lib/api/getOwnershipProof.js +5 -3
  51. package/lib/api/getPublicKey.d.ts +1 -1
  52. package/lib/api/index.d.ts +1 -0
  53. package/lib/api/index.js +3 -1
  54. package/lib/api/nemGetAddress.d.ts +1 -1
  55. package/lib/api/pushTransaction.d.ts +1 -1
  56. package/lib/api/rippleGetAddress.d.ts +1 -1
  57. package/lib/api/setBusy.d.ts +7 -0
  58. package/lib/api/setBusy.js +31 -0
  59. package/lib/api/setProxy.js +3 -4
  60. package/lib/api/signTransaction.d.ts +2 -2
  61. package/lib/api/signTransaction.js +10 -3
  62. package/lib/api/stellarGetAddress.d.ts +1 -1
  63. package/lib/api/stellarSignTransaction.d.ts +1 -1
  64. package/lib/api/tezosGetAddress.d.ts +1 -1
  65. package/lib/backend/BackendManager.d.ts +21 -0
  66. package/lib/backend/BackendManager.js +87 -0
  67. package/lib/backend/Blockchain.d.ts +66 -0
  68. package/lib/backend/Blockchain.js +189 -0
  69. package/lib/backend/BlockchainLink.d.ts +6 -71
  70. package/lib/backend/BlockchainLink.js +12 -288
  71. package/lib/constants/cardano.d.ts +3 -1
  72. package/lib/constants/cardano.js +3 -1
  73. package/lib/constants/network.d.ts +1 -1
  74. package/lib/core/AbstractMethod.d.ts +5 -4
  75. package/lib/core/AbstractMethod.js +7 -5
  76. package/lib/core/index.d.ts +1 -1
  77. package/lib/core/index.js +3 -1
  78. package/lib/core/method.d.ts +1 -1
  79. package/lib/data/DataManager.d.ts +1 -1
  80. package/lib/data/analyticsInfo.d.ts +6 -0
  81. package/lib/data/analyticsInfo.js +37 -0
  82. package/lib/data/config.js +1 -1
  83. package/lib/data/version.d.ts +1 -1
  84. package/lib/data/version.js +1 -1
  85. package/lib/device/AbortController.d.ts +1 -1
  86. package/lib/device/DescriptorStream.d.ts +1 -1
  87. package/lib/device/Device.d.ts +2 -2
  88. package/lib/device/Device.js +11 -2
  89. package/lib/device/DeviceCommands.d.ts +8 -7
  90. package/lib/device/DeviceCommands.js +14 -1
  91. package/lib/device/DeviceList.d.ts +1 -1
  92. package/lib/events/blockchain.d.ts +4 -5
  93. package/lib/events/call.d.ts +10 -10
  94. package/lib/events/core.d.ts +3 -2
  95. package/lib/events/device.d.ts +3 -3
  96. package/lib/events/iframe.d.ts +2 -2
  97. package/lib/events/popup.d.ts +2 -2
  98. package/lib/events/transport.d.ts +3 -3
  99. package/lib/events/ui-promise.d.ts +2 -2
  100. package/lib/events/ui-request.d.ts +8 -6
  101. package/lib/events/ui-response.d.ts +2 -2
  102. package/lib/factory.js +1 -0
  103. package/lib/types/account.d.ts +2 -2
  104. package/lib/types/api/authorizeCoinJoin.d.ts +1 -0
  105. package/lib/types/api/binance/index.d.ts +1 -1
  106. package/lib/types/api/bitcoin/index.d.ts +6 -2
  107. package/lib/types/api/blockchainGetTransactions.d.ts +1 -1
  108. package/lib/types/api/blockchainSetCustomBackend.d.ts +1 -1
  109. package/lib/types/api/blockchainSubscribe.d.ts +1 -1
  110. package/lib/types/api/blockchainSubscribeFiatRates.d.ts +1 -1
  111. package/lib/types/api/cardano/index.d.ts +12 -5
  112. package/lib/types/api/composeTransaction.d.ts +3 -3
  113. package/lib/types/api/eos/index.d.ts +1 -1
  114. package/lib/types/api/getAddress.d.ts +1 -1
  115. package/lib/types/api/index.d.ts +2 -0
  116. package/lib/types/api/nem/index.d.ts +9 -9
  117. package/lib/types/api/off.d.ts +2 -2
  118. package/lib/types/api/on.d.ts +2 -2
  119. package/lib/types/api/pushTransaction.d.ts +1 -1
  120. package/lib/types/api/setBusy.d.ts +4 -0
  121. package/lib/types/api/setBusy.js +3 -0
  122. package/lib/types/api/setProxy.d.ts +1 -2
  123. package/lib/types/api/stellar/index.d.ts +2 -2
  124. package/lib/types/coinInfo.d.ts +3 -3
  125. package/lib/types/device.d.ts +13 -13
  126. package/lib/types/firmware.d.ts +3 -3
  127. package/lib/types/params.d.ts +3 -3
  128. package/lib/types/settings.d.ts +1 -2
  129. package/lib/types/utils.d.ts +2 -2
  130. package/lib/utils/accountUtils.d.ts +1 -1
  131. package/lib/utils/browserUtils.d.ts +2 -2
  132. package/lib/utils/debug.d.ts +1 -1
  133. package/lib/utils/deferred.d.ts +2 -2
  134. package/lib/utils/interactionTimeout.d.ts +1 -1
  135. package/lib/workers/RNUsbPlugin.d.ts +1 -1
  136. package/lib/workers/workers.d.ts +1 -1
  137. package/package.json +83 -78
  138. package/lib/utils/bufferUtils.d.ts +0 -3
  139. package/lib/utils/bufferUtils.js +0 -11
package/CHANGELOG.md ADDED
@@ -0,0 +1,67 @@
1
+ # 9.0.5
2
+
3
+ - added: analytics in popup
4
+ - fixed: `signTransaction` with litecoin mimble wimble pegout inputs
5
+ - fixed: `composeTransaction` cases when composing tx with multiple outputs where at least one is above MAX_SAFE_INTEGER
6
+ - updated: @trezor/blockchain-link 2.6.1
7
+ - updated: @trezor/connect-common 0.0.11
8
+ - updated: @trezor/transport 1.1.6
9
+ - updated: @trezor/utils 9.0.4
10
+ - updated: @trezor/utxo-lib 1.0.2
11
+
12
+ # 9.0.4
13
+
14
+ - @trezor/blockchain-link 2.1.5
15
+ - added `setBusy` method
16
+ - added `goerli` (TGOR) coin support
17
+ - added `serialize` and `coinjoinRequest` option to `signTransaction` method
18
+ - added `preauthorized` option to `authorizeCoinJoin` method
19
+ - Cardano: added support for [CIP36 Catalyst registration format](https://cips.cardano.org/cips/cip36/) in `cardanoSignTransaction` method
20
+ - `auxiliaryData.catalystRegistrationParameters` is deprecated, use `auxiliaryData.governanceRegistrationParameters` instead
21
+
22
+ # 9.0.3
23
+
24
+ - typescript: removed `EosGetPublicKey` type, use `GetPublicKey` type instead
25
+ - fix default bip48 script types. [#6393](https://github.com/trezor/trezor-suite/pull/6393) and [#6407](https://github.com/trezor/trezor-suite/pull/6407)
26
+ - added `unlockPath` method
27
+ - added `SLIP 25` support
28
+ - fixed bitcoin extended descriptor (xpubSegwit) for taproot accounts
29
+
30
+ # 9.0.2
31
+
32
+ - improved passphrase dialog in popup window
33
+ - if popup window does not load in a predefined period of time, error screen with troubleshooting tips is shown
34
+
35
+ # 9.0.1
36
+
37
+ - @trezor/blockchain-link 2.1.4
38
+
39
+ # 9.0.0
40
+
41
+ ## Breaking changes:
42
+
43
+ - Changed codebase to typescript.
44
+ - Removed `Lisk` methods from api.
45
+ - Removed `customMethod` api method.
46
+ - Exported constants:
47
+ - `CARDANO.ADDRESS_TYPE` => `PROTO.CardanoAddressType`
48
+ - `CARDANO.CERTIFICATE_TYPE` => `PROTO.CardanoCertificateType`
49
+ - `CARDANO.POOL_RELAY_TYPE` => `PROTO.CardanoPoolRelayType`
50
+ - `CardanoCertificateType`
51
+ - `CardanoNativeScriptType` => `PROTO.CardanoNativeScriptType`
52
+ - `CardanoNativeScriptHashDisplayFormat` => `PROTO.CardanoNativeScriptHashDisplayFormat`
53
+ - `CardanoPoolRelayType` => `PROTO.CardanoPoolRelayType`
54
+ - `CardanoTxSigningMode` => `PROTO.CardanoTxSigningMode`
55
+ - `CardanoTxWitnessType` => `PROTO.CardanoTxWitnessType`
56
+ - removed unused `DEVICE.WAIT_FOR_SELECTION`
57
+ - removed unused `UI.CHANGE_ACCOUNT`
58
+ - Minimum firmware requirements bumped:
59
+ - 2.4.2 CardanoSignTransaction
60
+
61
+ ## Added:
62
+
63
+ - `getOwnershipId` method
64
+ - `getOwnershipProof` method
65
+ - `authorizeCoinJoin` method
66
+ - `getFirmwareHash` method
67
+ - [support for babbage features in cardano](https://github.com/trezor/trezor-suite/commit/efe9c78a2f74a1b7653b3fddf6cca35ba38d3ae9)
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @trezor/connect
2
2
 
3
- API version 9.0.3
3
+ API version 9.0.5
4
4
 
5
5
  [![Build Status](https://github.com/trezor/trezor-suite/actions/workflows/connect-test.yml/badge.svg)](https://github.com/trezor/trezor-suite/actions/workflows/connect-test.yml)
6
6
  [![NPM](https://img.shields.io/npm/v/@trezor/connect.svg)](https://www.npmjs.org/package/@trezor/connect)
@@ -16,11 +16,13 @@ class AuthorizeCoinJoin extends AbstractMethod_1.AbstractMethod {
16
16
  { name: 'coin', type: 'string' },
17
17
  { name: 'scriptType', type: 'string' },
18
18
  { name: 'amountUnit', type: 'uint' },
19
+ { name: 'preauthorized', type: 'boolean' },
19
20
  ]);
20
21
  const address_n = (0, pathUtils_1.validatePath)(payload.path, 3);
21
22
  const script_type = payload.scriptType || (0, pathUtils_1.getScriptType)(address_n);
22
23
  const coinInfo = (0, coinInfo_1.getBitcoinNetwork)(payload.coin || address_n);
23
24
  this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, coinInfo, this.firmwareRange);
25
+ this.preauthorized = payload.preauthorized;
24
26
  this.params = {
25
27
  coordinator: payload.coordinator,
26
28
  max_rounds: payload.maxRounds,
@@ -34,8 +36,10 @@ class AuthorizeCoinJoin extends AbstractMethod_1.AbstractMethod {
34
36
  }
35
37
  async run() {
36
38
  const cmd = this.device.getCommands();
37
- if (!this.device.features.experimental_features) {
38
- await cmd.typedCall('ApplySettings', 'Success', { experimental_features: true });
39
+ if (this.preauthorized) {
40
+ if (await cmd.preauthorize(false)) {
41
+ return { message: 'Success' };
42
+ }
39
43
  }
40
44
  const response = await cmd.typedCall('AuthorizeCoinJoin', 'Success', this.params);
41
45
  return response.message;
@@ -1,6 +1,6 @@
1
1
  import { AbstractMethod } from '../core/AbstractMethod';
2
2
  import { PROTO } from '../constants';
3
- declare type Params = PROTO.BinanceGetAddress & {
3
+ type Params = PROTO.BinanceGetAddress & {
4
4
  address?: string;
5
5
  };
6
6
  export default class BinanceGetAddress extends AbstractMethod<'binanceGetAddress', Params[]> {
@@ -1,6 +1,6 @@
1
1
  import { AbstractMethod } from '../core/AbstractMethod';
2
2
  import type { BinancePreparedTransaction } from '../types/api/binance';
3
- declare type Params = {
3
+ type Params = {
4
4
  path: number[];
5
5
  transaction: BinancePreparedTransaction;
6
6
  };
@@ -1,7 +1,7 @@
1
1
  import { Blockchain } from '../../backend/BlockchainLink';
2
2
  import type { CoinInfo } from '../../types';
3
3
  import type { FeeLevel } from '../../types/account';
4
- declare type Blocks = Array<string | undefined>;
4
+ type Blocks = Array<string | undefined>;
5
5
  export declare class FeeLevels {
6
6
  coinInfo: CoinInfo;
7
7
  levels: FeeLevel[];
@@ -4,7 +4,7 @@ import { Blockchain } from '../../backend/BlockchainLink';
4
4
  import type { BitcoinNetworkInfo } from '../../types';
5
5
  import type { DiscoveryAccount, SelectFeeLevel } from '../../types/account';
6
6
  import type { PrecomposeParams } from '../../types/api/composeTransaction';
7
- declare type Options = {
7
+ type Options = {
8
8
  account: DiscoveryAccount;
9
9
  utxo: PrecomposeParams['account']['utxo'];
10
10
  outputs: ComposeOutput[];
@@ -15,7 +15,7 @@ const enhanceSignTx = (options, coinInfo) => {
15
15
  options.version_group_id = 0x26a7270a;
16
16
  }
17
17
  if (typeof options.branch_id !== 'number') {
18
- const backend = (0, BlockchainLink_1.findBackend)(coinInfo.name);
18
+ const backend = (0, BlockchainLink_1.findBackend)(coinInfo.shortcut);
19
19
  if (backend && ((_a = backend.serverInfo) === null || _a === void 0 ? void 0 : _a.consensusBranchId)) {
20
20
  options.branch_id = backend.serverInfo.consensusBranchId;
21
21
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.inputToTrezor = exports.enhanceTrezorInputs = exports.validateTrezorInputs = void 0;
4
- const bufferUtils_1 = require("../../utils/bufferUtils");
4
+ const utils_1 = require("@trezor/utils");
5
5
  const pathUtils_1 = require("../../utils/pathUtils");
6
6
  const hdnodeUtils_1 = require("../../utils/hdnodeUtils");
7
7
  const paramsValidator_1 = require("../common/paramsValidator");
@@ -17,6 +17,7 @@ const validateTrezorInputs = (inputs, coinInfo) => inputs
17
17
  { name: 'script_type', type: 'string' },
18
18
  { name: 'sequence', type: 'number' },
19
19
  { name: 'multisig', type: 'object' },
20
+ { name: 'coinjoin_flags', type: 'number' },
20
21
  ]);
21
22
  if (input.script_type === 'EXTERNAL') {
22
23
  (0, paramsValidator_1.validateParams)(input, [
@@ -50,7 +51,7 @@ const inputToTrezor = (input, sequence) => {
50
51
  return {
51
52
  address_n,
52
53
  prev_index: input.index,
53
- prev_hash: (0, bufferUtils_1.reverseBuffer)(input.hash).toString('hex'),
54
+ prev_hash: utils_1.bufferUtils.reverseBuffer(input.hash).toString('hex'),
54
55
  script_type: (0, pathUtils_1.getScriptType)(address_n),
55
56
  amount: input.amount,
56
57
  sequence,
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.validateReferencedTransactions = exports.transformReferencedTransactions = exports.transformOrigTransactions = exports.getOrigTransactions = exports.getReferencedTransactions = exports.requireReferencedTransactions = void 0;
4
4
  const utxo_lib_1 = require("@trezor/utxo-lib");
5
- const bufferUtils_1 = require("../../utils/bufferUtils");
5
+ const utils_1 = require("@trezor/utils");
6
6
  const pathUtils_1 = require("../../utils/pathUtils");
7
7
  const paramsValidator_1 = require("../common/paramsValidator");
8
8
  const errors_1 = require("../../constants/errors");
@@ -72,7 +72,7 @@ const transformOrigTransactions = (txs, coinInfo, addresses) => txs.flatMap(raw
72
72
  const address_n = (0, pathUtils_1.getHDPath)((inputAddress === null || inputAddress === void 0 ? void 0 : inputAddress.path) || '');
73
73
  return {
74
74
  address_n,
75
- prev_hash: (0, bufferUtils_1.reverseBuffer)(input.hash).toString('hex'),
75
+ prev_hash: utils_1.bufferUtils.reverseBuffer(input.hash).toString('hex'),
76
76
  prev_index: input.index,
77
77
  script_sig: input.script.toString('hex'),
78
78
  sequence: input.sequence,
@@ -139,7 +139,7 @@ const transformReferencedTransactions = (txs, coinInfo) => txs.flatMap(raw => {
139
139
  const inputsMap = (input) => ({
140
140
  prev_index: input.index,
141
141
  sequence: input.sequence,
142
- prev_hash: (0, bufferUtils_1.reverseBuffer)(input.hash).toString('hex'),
142
+ prev_hash: utils_1.bufferUtils.reverseBuffer(input.hash).toString('hex'),
143
143
  script_sig: input.script.toString('hex'),
144
144
  });
145
145
  const binOutputsMap = (output) => ({
@@ -1,7 +1,7 @@
1
1
  import { PROTO } from '../../constants';
2
2
  import type { BitcoinNetworkInfo } from '../../types';
3
3
  import type { DeviceCommands } from '../../device/DeviceCommands';
4
- declare type GetHDNode = DeviceCommands['getHDNode'];
4
+ type GetHDNode = DeviceCommands['getHDNode'];
5
5
  export declare const verifyTx: (getHDNode: GetHDNode, inputs: PROTO.TxInputType[], outputs: PROTO.TxOutputType[], serializedTx: string, coinInfo: BitcoinNetworkInfo, unlockPath?: PROTO.UnlockPath) => Promise<import("packages/utxo-lib/lib/transaction/base").TransactionBase<undefined> | import("packages/utxo-lib/lib/transaction/base").TransactionBase<import("packages/utxo-lib/lib/transaction/dash").DashSpecific> | import("packages/utxo-lib/lib/transaction/base").TransactionBase<import("packages/utxo-lib/lib/transaction/zcash").ZcashSpecific>>;
6
6
  export declare const verifyTicketTx: (getHDNode: GetHDNode, inputs: PROTO.TxInputType[], outputs: PROTO.TxOutputType[], serializedTx: string, coinInfo: BitcoinNetworkInfo) => Promise<void>;
7
7
  export {};
@@ -1,6 +1,6 @@
1
1
  import { AbstractMethod } from '../core/AbstractMethod';
2
2
  import type { CoinInfo } from '../types';
3
- declare type Params = {
3
+ type Params = {
4
4
  coinInfo: CoinInfo;
5
5
  };
6
6
  export default class BlockchainDisconnect extends AbstractMethod<'blockchainDisconnect', Params> {
@@ -23,7 +23,7 @@ class BlockchainDisconnect extends AbstractMethod_1.AbstractMethod {
23
23
  };
24
24
  }
25
25
  run() {
26
- const backend = (0, BlockchainLink_1.findBackend)(this.params.coinInfo.name);
26
+ const backend = (0, BlockchainLink_1.findBackend)(this.params.coinInfo.shortcut);
27
27
  if (backend) {
28
28
  backend.disconnect();
29
29
  }
@@ -1,6 +1,6 @@
1
1
  import { Payload, AbstractMethod } from '../core/AbstractMethod';
2
2
  import type { CoinInfo } from '../types';
3
- declare type Params = {
3
+ type Params = {
4
4
  coinInfo: CoinInfo;
5
5
  request: Payload<'blockchainEstimateFee'>['request'];
6
6
  };
@@ -1,6 +1,6 @@
1
1
  import { Payload, AbstractMethod } from '../core/AbstractMethod';
2
2
  import type { CoinInfo } from '../types';
3
- declare type Params = {
3
+ type Params = {
4
4
  coinInfo: CoinInfo;
5
5
  request: Omit<Payload<'blockchainGetAccountBalanceHistory'>, 'method' | 'coin'>;
6
6
  };
@@ -1,6 +1,6 @@
1
1
  import { Payload, AbstractMethod } from '../core/AbstractMethod';
2
2
  import type { CoinInfo } from '../types';
3
- declare type Params = {
3
+ type Params = {
4
4
  coinInfo: CoinInfo;
5
5
  currencies: Payload<'blockchainGetCurrentFiatRates'>['currencies'];
6
6
  };
@@ -1,6 +1,6 @@
1
1
  import { Payload, AbstractMethod } from '../core/AbstractMethod';
2
2
  import type { CoinInfo } from '../types';
3
- declare type Params = {
3
+ type Params = {
4
4
  coinInfo: CoinInfo;
5
5
  timestamps: Payload<'blockchainGetFiatRatesForTimestamps'>['timestamps'];
6
6
  };
@@ -1,6 +1,6 @@
1
1
  import { AbstractMethod } from '../core/AbstractMethod';
2
2
  import type { CoinInfo } from '../types';
3
- declare type Params = {
3
+ type Params = {
4
4
  txs: string[];
5
5
  coinInfo: CoinInfo;
6
6
  };
@@ -1,6 +1,6 @@
1
1
  import { AbstractMethod } from '../core/AbstractMethod';
2
2
  import type { CoinInfo } from '../types';
3
- declare type Params = {
3
+ type Params = {
4
4
  coinInfo: CoinInfo;
5
5
  };
6
6
  export default class BlockchainSetCustomBackend extends AbstractMethod<'blockchainSetCustomBackend', Params> {
@@ -26,7 +26,7 @@ class BlockchainSetCustomBackend extends AbstractMethod_1.AbstractMethod {
26
26
  };
27
27
  }
28
28
  async run() {
29
- const current = (0, BlockchainLink_1.findBackend)(this.params.coinInfo.name);
29
+ const current = (0, BlockchainLink_1.findBackend)(this.params.coinInfo.shortcut);
30
30
  if (current) {
31
31
  current.disconnect();
32
32
  await (0, BlockchainLink_1.initBlockchain)(this.params.coinInfo, this.postMessage);
@@ -1,6 +1,6 @@
1
1
  import { Payload, AbstractMethod } from '../core/AbstractMethod';
2
2
  import type { CoinInfo } from '../types';
3
- declare type Params = {
3
+ type Params = {
4
4
  accounts: Payload<'blockchainSubscribe'>['accounts'];
5
5
  coinInfo: CoinInfo;
6
6
  };
@@ -1,6 +1,6 @@
1
1
  import { Payload, AbstractMethod } from '../core/AbstractMethod';
2
2
  import type { CoinInfo } from '../types';
3
- declare type Params = {
3
+ type Params = {
4
4
  currency: Payload<'blockchainSubscribeFiatRates'>['currency'];
5
5
  coinInfo: CoinInfo;
6
6
  };
@@ -1,6 +1,6 @@
1
1
  import { Payload, AbstractMethod } from '../core/AbstractMethod';
2
2
  import type { CoinInfo } from '../types';
3
- declare type Params = {
3
+ type Params = {
4
4
  accounts: Payload<'blockchainUnsubscribe'>['accounts'];
5
5
  coinInfo: CoinInfo;
6
6
  };
@@ -1,6 +1,6 @@
1
1
  import { AbstractMethod } from '../core/AbstractMethod';
2
2
  import type { CoinInfo } from '../types';
3
- declare type Params = {
3
+ type Params = {
4
4
  coinInfo: CoinInfo;
5
5
  };
6
6
  export default class BlockchainUnsubscribeFiatRates extends AbstractMethod<'blockchainUnsubscribeFiatRates', Params> {
@@ -1,5 +1,5 @@
1
1
  import type { Device } from '../../device/Device';
2
- import type { PROTO } from '../../constants';
2
+ import { PROTO } from '../../constants';
3
3
  import type { CardanoAuxiliaryData } from '../../types/api/cardano';
4
4
  export declare const transformAuxiliaryData: (auxiliaryData: CardanoAuxiliaryData) => PROTO.CardanoTxAuxiliaryData;
5
5
  export declare const modifyAuxiliaryDataForBackwardsCompatibility: (device: Device, auxiliary_data: PROTO.CardanoTxAuxiliaryData) => PROTO.CardanoTxAuxiliaryData;
@@ -4,18 +4,40 @@ exports.modifyAuxiliaryDataForBackwardsCompatibility = exports.transformAuxiliar
4
4
  const cardanoAddressParameters_1 = require("./cardanoAddressParameters");
5
5
  const paramsValidator_1 = require("../common/paramsValidator");
6
6
  const pathUtils_1 = require("../../utils/pathUtils");
7
- const transformCatalystRegistrationParameters = (catalystRegistrationParameters) => {
8
- (0, paramsValidator_1.validateParams)(catalystRegistrationParameters, [
7
+ const constants_1 = require("../../constants");
8
+ const MAX_DELEGATION_COUNT = 32;
9
+ const transformDelegation = (delegation) => {
10
+ (0, paramsValidator_1.validateParams)(delegation, [
9
11
  { name: 'votingPublicKey', type: 'string', required: true },
12
+ { name: 'weight', type: 'uint', required: true },
13
+ ]);
14
+ return {
15
+ voting_public_key: delegation.votingPublicKey,
16
+ weight: delegation.weight,
17
+ };
18
+ };
19
+ const transformGovernanceRegistrationParameters = (governanceRegistrationParameters) => {
20
+ (0, paramsValidator_1.validateParams)(governanceRegistrationParameters, [
21
+ { name: 'votingPublicKey', type: 'string' },
10
22
  { name: 'stakingPath', required: true },
11
23
  { name: 'nonce', type: 'uint', required: true },
24
+ { name: 'format', type: 'number' },
25
+ { name: 'delegations', type: 'array', allowEmpty: true },
26
+ { name: 'votingPurpose', type: 'uint' },
12
27
  ]);
13
- (0, cardanoAddressParameters_1.validateAddressParameters)(catalystRegistrationParameters.rewardAddressParameters);
28
+ (0, cardanoAddressParameters_1.validateAddressParameters)(governanceRegistrationParameters.rewardAddressParameters);
29
+ const { delegations } = governanceRegistrationParameters;
30
+ if (delegations && delegations.length > MAX_DELEGATION_COUNT) {
31
+ throw constants_1.ERRORS.TypedError('Method_InvalidParameter', `At most ${MAX_DELEGATION_COUNT} delegations are allowed in a governance registration`);
32
+ }
14
33
  return {
15
- voting_public_key: catalystRegistrationParameters.votingPublicKey,
16
- staking_path: (0, pathUtils_1.validatePath)(catalystRegistrationParameters.stakingPath, 3),
17
- reward_address_parameters: (0, cardanoAddressParameters_1.addressParametersToProto)(catalystRegistrationParameters.rewardAddressParameters),
18
- nonce: catalystRegistrationParameters.nonce,
34
+ voting_public_key: governanceRegistrationParameters.votingPublicKey,
35
+ staking_path: (0, pathUtils_1.validatePath)(governanceRegistrationParameters.stakingPath, 3),
36
+ reward_address_parameters: (0, cardanoAddressParameters_1.addressParametersToProto)(governanceRegistrationParameters.rewardAddressParameters),
37
+ nonce: governanceRegistrationParameters.nonce,
38
+ format: governanceRegistrationParameters.format,
39
+ delegations: delegations === null || delegations === void 0 ? void 0 : delegations.map(transformDelegation),
40
+ voting_purpose: governanceRegistrationParameters.votingPurpose,
19
41
  };
20
42
  };
21
43
  const transformAuxiliaryData = (auxiliaryData) => {
@@ -25,24 +47,24 @@ const transformAuxiliaryData = (auxiliaryData) => {
25
47
  type: 'string',
26
48
  },
27
49
  ]);
28
- let catalystRegistrationParameters;
29
- if (auxiliaryData.catalystRegistrationParameters) {
30
- catalystRegistrationParameters = transformCatalystRegistrationParameters(auxiliaryData.catalystRegistrationParameters);
50
+ let governanceRegistrationParameters;
51
+ if (auxiliaryData.governanceRegistrationParameters) {
52
+ governanceRegistrationParameters = transformGovernanceRegistrationParameters(auxiliaryData.governanceRegistrationParameters);
31
53
  }
32
54
  return {
33
55
  hash: auxiliaryData.hash,
34
- catalyst_registration_parameters: catalystRegistrationParameters,
56
+ governance_registration_parameters: governanceRegistrationParameters,
35
57
  };
36
58
  };
37
59
  exports.transformAuxiliaryData = transformAuxiliaryData;
38
60
  const modifyAuxiliaryDataForBackwardsCompatibility = (device, auxiliary_data) => {
39
- const { catalyst_registration_parameters } = auxiliary_data;
40
- if (catalyst_registration_parameters) {
41
- catalyst_registration_parameters.reward_address_parameters =
42
- (0, cardanoAddressParameters_1.modifyAddressParametersForBackwardsCompatibility)(device, catalyst_registration_parameters.reward_address_parameters);
61
+ const { governance_registration_parameters } = auxiliary_data;
62
+ if (governance_registration_parameters) {
63
+ governance_registration_parameters.reward_address_parameters =
64
+ (0, cardanoAddressParameters_1.modifyAddressParametersForBackwardsCompatibility)(device, governance_registration_parameters.reward_address_parameters);
43
65
  return {
44
66
  ...auxiliary_data,
45
- catalyst_registration_parameters,
67
+ governance_registration_parameters,
46
68
  };
47
69
  }
48
70
  return auxiliary_data;
@@ -1,11 +1,11 @@
1
1
  import { PROTO } from '../../constants';
2
2
  import type { CardanoCertificate } from '../../types/api/cardano';
3
- export declare type CertificateWithPoolOwnersAndRelays = {
3
+ export type CertificateWithPoolOwnersAndRelays = {
4
4
  certificate: PROTO.CardanoTxCertificate;
5
5
  poolOwners: PROTO.CardanoPoolOwner[];
6
6
  poolRelays: PROTO.CardanoPoolRelayParameters[];
7
7
  };
8
- export declare type PoolParametersWithOwnersAndRelays = {
8
+ export type PoolParametersWithOwnersAndRelays = {
9
9
  poolParameters?: PROTO.CardanoPoolParametersType;
10
10
  poolOwners: PROTO.CardanoPoolOwner[];
11
11
  poolRelays: PROTO.CardanoPoolRelayParameters[];
@@ -1,10 +1,10 @@
1
1
  import type { PROTO } from '../../constants';
2
- export declare type Path = number[];
3
- export declare type InputWithPath = {
2
+ export type Path = number[];
3
+ export type InputWithPath = {
4
4
  input: PROTO.CardanoTxInput;
5
5
  path?: Path;
6
6
  };
7
- export declare type CollateralInputWithPath = {
7
+ export type CollateralInputWithPath = {
8
8
  collateralInput: PROTO.CardanoTxCollateralInput;
9
9
  path?: Path;
10
10
  };
@@ -1,6 +1,6 @@
1
1
  import type { AssetGroupWithTokens } from './cardanoTokenBundle';
2
2
  import { PROTO } from '../../constants';
3
- export declare type OutputWithData = {
3
+ export type OutputWithData = {
4
4
  output: PROTO.CardanoTxOutput;
5
5
  tokenBundle?: AssetGroupWithTokens[];
6
6
  inlineDatum?: string;
@@ -1,6 +1,6 @@
1
1
  import type { PROTO } from '../../constants';
2
2
  import type { CardanoAssetGroup } from '../../types/api/cardano';
3
- export declare type AssetGroupWithTokens = {
3
+ export type AssetGroupWithTokens = {
4
4
  policyId: string;
5
5
  tokens: PROTO.CardanoToken[];
6
6
  };
@@ -1,6 +1,6 @@
1
1
  import { AbstractMethod } from '../core/AbstractMethod';
2
2
  import { PROTO } from '../constants';
3
- declare type Params = PROTO.CardanoGetAddress & {
3
+ type Params = PROTO.CardanoGetAddress & {
4
4
  address?: string;
5
5
  };
6
6
  export default class CardanoGetAddress extends AbstractMethod<'cardanoGetAddress', Params[]> {
@@ -15,8 +15,9 @@ declare const CardanoSignTransactionFeatures: Readonly<{
15
15
  Plutus: string[];
16
16
  KeyHashStakeCredential: string[];
17
17
  Babbage: string[];
18
+ GovernanceRegistrationCIP36: string[];
18
19
  }>;
19
- export declare type CardanoSignTransactionParams = {
20
+ export type CardanoSignTransactionParams = {
20
21
  signingMode: PROTO.CardanoTxSigningMode;
21
22
  inputsWithPath: InputWithPath[];
22
23
  outputsWithData: OutputWithData[];
@@ -21,6 +21,7 @@ const CardanoSignTransactionFeatures = Object.freeze({
21
21
  Plutus: ['0', '2.4.4'],
22
22
  KeyHashStakeCredential: ['0', '2.4.4'],
23
23
  Babbage: ['0', '2.5.2'],
24
+ GovernanceRegistrationCIP36: ['0', '2.5.3'],
24
25
  });
25
26
  class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
26
27
  init() {
@@ -34,6 +35,11 @@ class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
34
35
  if (payload.auxiliaryData && payload.auxiliaryData.blob) {
35
36
  throw constants_1.ERRORS.TypedError('Method_InvalidParameter', 'Auxiliary data can now only be sent as a hash.');
36
37
  }
38
+ if (payload.auxiliaryData && payload.auxiliaryData.catalystRegistrationParameters) {
39
+ console.warn('Please use governanceRegistrationParameters instead of catalystRegistrationParameters.');
40
+ payload.auxiliaryData.governanceRegistrationParameters =
41
+ payload.auxiliaryData.catalystRegistrationParameters;
42
+ }
37
43
  (0, paramsValidator_1.validateParams)(payload, [
38
44
  { name: 'signingMode', type: 'number', required: true },
39
45
  { name: 'inputs', type: 'array', required: true },
@@ -148,6 +154,7 @@ class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
148
154
  }
149
155
  }
150
156
  _ensureFirmwareSupportsParams() {
157
+ var _a;
151
158
  const { params } = this;
152
159
  this._ensureFeatureIsSupported('TransactionStreaming');
153
160
  params.certificatesWithPoolOwnersAndRelays.forEach(({ certificate }) => {
@@ -193,6 +200,18 @@ class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
193
200
  params.referenceInputs.length > 0) {
194
201
  this._ensureFeatureIsSupported('Babbage');
195
202
  }
203
+ if (params.requiredSigners.length > 0 &&
204
+ params.signingMode !== constants_1.PROTO.CardanoTxSigningMode.PLUTUS_TRANSACTION) {
205
+ this._ensureFeatureIsSupported('Babbage');
206
+ }
207
+ if ((_a = params.auxiliaryData) === null || _a === void 0 ? void 0 : _a.governance_registration_parameters) {
208
+ const { format, delegations, voting_purpose } = params.auxiliaryData.governance_registration_parameters;
209
+ if (format === constants_1.PROTO.CardanoGovernanceRegistrationFormat.CIP36 ||
210
+ (delegations === null || delegations === void 0 ? void 0 : delegations.length) ||
211
+ voting_purpose != null) {
212
+ this._ensureFeatureIsSupported('GovernanceRegistrationCIP36');
213
+ }
214
+ }
196
215
  }
197
216
  async _sign_tx() {
198
217
  const typedCall = this.device.getCommands().typedCall.bind(this.device.getCommands());
@@ -242,8 +261,8 @@ class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
242
261
  }
243
262
  let auxiliaryDataSupplement;
244
263
  if (this.params.auxiliaryData) {
245
- const { catalyst_registration_parameters } = this.params.auxiliaryData;
246
- if (catalyst_registration_parameters) {
264
+ const { governance_registration_parameters } = this.params.auxiliaryData;
265
+ if (governance_registration_parameters) {
247
266
  this.params.auxiliaryData = (0, cardanoAuxiliaryData_1.modifyAuxiliaryDataForBackwardsCompatibility)(this.device, this.params.auxiliaryData);
248
267
  }
249
268
  const { message } = await typedCall('CardanoTxAuxiliaryData', 'CardanoTxAuxiliaryDataSupplement', this.params.auxiliaryData);
@@ -252,7 +271,8 @@ class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
252
271
  auxiliaryDataSupplement = {
253
272
  type: auxiliaryDataType,
254
273
  auxiliaryDataHash: message.auxiliary_data_hash,
255
- catalystSignature: message.catalyst_signature,
274
+ governanceSignature: message.governance_signature,
275
+ catalystSignature: message.governance_signature,
256
276
  };
257
277
  }
258
278
  await typedCall('CardanoTxHostAck', 'CardanoTxItemAck');
@@ -5,11 +5,11 @@ import { Blockchain } from '../../backend/BlockchainLink';
5
5
  import { DeviceCommands } from '../../device/DeviceCommands';
6
6
  import type { CoinInfo, DiscoveryAccountType, DiscoveryAccount } from '../../types';
7
7
  import type { GetAccountInfo } from '../../types/api/getAccountInfo';
8
- declare type DiscoveryType = {
8
+ type DiscoveryType = {
9
9
  type: DiscoveryAccountType;
10
10
  getPath: (index: number) => number[];
11
11
  };
12
- declare type DiscoveryOptions = {
12
+ type DiscoveryOptions = {
13
13
  blockchain: Blockchain;
14
14
  commands: DeviceCommands;
15
15
  limit?: number;
@@ -1,6 +1,6 @@
1
1
  import type { CoinInfo, FirmwareRange } from '../../types';
2
- declare type ParamType = 'string' | 'number' | 'array' | 'array-buffer' | 'boolean' | 'uint' | 'object';
3
- declare type Param = {
2
+ type ParamType = 'string' | 'number' | 'array' | 'array-buffer' | 'boolean' | 'uint' | 'object';
3
+ type Param = {
4
4
  name: string;
5
5
  type?: ParamType | ParamType[];
6
6
  required?: boolean;
@@ -4,7 +4,7 @@ import { TransactionComposer } from './bitcoin';
4
4
  import type { ComposeOutput, ComposeResult } from '@trezor/utxo-lib';
5
5
  import type { BitcoinNetworkInfo, DiscoveryAccount, AccountUtxo } from '../types';
6
6
  import type { SignedTransaction, PrecomposeParams, PrecomposedTransaction } from '../types/api/composeTransaction';
7
- declare type Params = {
7
+ type Params = {
8
8
  outputs: ComposeOutput[];
9
9
  coinInfo: BitcoinNetworkInfo;
10
10
  push: boolean;
@@ -99,7 +99,7 @@ const parseQuantity = (s) => {
99
99
  const parseAuth = (a) => {
100
100
  const keyToBuffer = (pk) => {
101
101
  const len = pk.indexOf('EOS') === 0 ? 3 : 7;
102
- const key = bs58.decode(pk.substring(len));
102
+ const key = Buffer.from(bs58.decode(pk.substring(len)));
103
103
  return {
104
104
  type: 0,
105
105
  key: key.slice(0, key.length - 4).toString('hex'),
@@ -1,6 +1,6 @@
1
1
  import { AbstractMethod } from '../core/AbstractMethod';
2
2
  import type { PROTO } from '../constants';
3
- declare type Params = {
3
+ type Params = {
4
4
  path: number[];
5
5
  chain_id: string;
6
6
  header: PROTO.EosTxHeader;
@@ -1,7 +1,7 @@
1
1
  import { AbstractMethod } from '../core/AbstractMethod';
2
2
  import { PROTO } from '../constants';
3
3
  import type { EthereumNetworkInfo } from '../types';
4
- declare type Params = PROTO.EthereumGetAddress & {
4
+ type Params = PROTO.EthereumGetAddress & {
5
5
  address?: string;
6
6
  network?: EthereumNetworkInfo;
7
7
  };