@trezor/connect 9.2.4-beta.1 → 9.2.4

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 (38) hide show
  1. package/CHANGELOG.md +54 -17
  2. package/README.md +1 -1
  3. package/lib/api/bitcoin/Fees.js +3 -4
  4. package/lib/api/bitcoin/TransactionComposer.js +3 -4
  5. package/lib/api/bitcoin/createPendingTx.js +3 -4
  6. package/lib/api/blockchainGetCurrentFiatRates.d.ts +1 -1
  7. package/lib/api/blockchainGetFiatRatesForTimestamps.d.ts +1 -1
  8. package/lib/api/cardano/api/cardanoGetAddress.d.ts +0 -1
  9. package/lib/api/cardano/api/cardanoGetAddress.js +1 -17
  10. package/lib/api/cardano/api/cardanoSignTransaction.d.ts +1 -13
  11. package/lib/api/cardano/api/cardanoSignTransaction.js +2 -75
  12. package/lib/api/cardano/cardanoAddressParameters.d.ts +1 -2
  13. package/lib/api/cardano/cardanoAddressParameters.js +4 -10
  14. package/lib/api/cardano/cardanoAuxiliaryData.d.ts +1 -2
  15. package/lib/api/cardano/cardanoAuxiliaryData.js +2 -2
  16. package/lib/api/composeTransaction.d.ts +1 -1
  17. package/lib/api/composeTransaction.js +2 -2
  18. package/lib/api/ethereum/ethereumSignTypedData.js +4 -5
  19. package/lib/api/signTransaction.js +2 -3
  20. package/lib/backend/Blockchain.d.ts +2 -2
  21. package/lib/core/index.js +9 -6
  22. package/lib/core/onCallFirmwareUpdate.js +8 -1
  23. package/lib/data/DataManager.d.ts +10 -0
  24. package/lib/data/config.d.ts +10 -0
  25. package/lib/data/config.js +20 -5
  26. package/lib/data/version.d.ts +1 -1
  27. package/lib/data/version.js +5 -2
  28. package/lib/device/Device.d.ts +4 -4
  29. package/lib/device/Device.js +6 -8
  30. package/lib/device/DeviceCommands.d.ts +5 -5
  31. package/lib/device/DeviceCommands.js +9 -29
  32. package/lib/device/DeviceList.d.ts +6 -3
  33. package/lib/device/DeviceList.js +26 -25
  34. package/lib/events/blockchain.d.ts +2 -2
  35. package/lib/types/index.d.ts +1 -1
  36. package/lib/types/settings.d.ts +1 -1
  37. package/lib/utils/formatUtils.js +3 -4
  38. package/package.json +11 -12
package/CHANGELOG.md CHANGED
@@ -1,12 +1,31 @@
1
1
  | Package | stable | canary |
2
2
  | -------------------------------- | :----: | :----------: |
3
- | npm @trezor/connect | 9.2.2 | 9.2.4-beta.1 |
4
- | npm @trezor/connect-web | 9.2.2 | 9.2.4-beta.1 |
5
- | npm @trezor/connect-webextension | 9.2.2 | 9.2.4-beta.1 |
6
- | connect.trezor.io/9 | 9.2.2 | x |
7
-
8
- # 9.2.4-beta.1
9
-
3
+ | npm @trezor/connect | 9.2.4 | 9.2.4-beta.2 |
4
+ | npm @trezor/connect-web | 9.2.4 | 9.2.4-beta.2 |
5
+ | npm @trezor/connect-webextension | 9.2.4 | 9.2.4-beta.2 |
6
+
7
+ | Connect explorer | stable | canary |
8
+ | ------------------- | :----: | :----------: |
9
+ | connect.trezor.io/9 | 9.2.4 | 9.2.4-beta.2 |
10
+
11
+ User the persistent link connect.trezor.io/9 to access the latest stable version of Connect Explorer.
12
+
13
+ # 9.2.4
14
+
15
+ - chore: BigNumber wrapper (d18ba9a879)
16
+ - chore(connect): add Rabby to knownHosts (1ec4c5bfc5)
17
+ - chore(transport): make Session type literal (72570f2219)
18
+ - chore(connect): re-add feature support checking in cardanoSignTransaction (acf9ffc2cb)
19
+ - chore(connect): fw-update: add error message when binary is too small (b0c1173f8d)
20
+ - chore(connect): remove legacyresults from cardano fixtures (acd9e1e510)
21
+ - chore(connect): bump fw versions required for cardano (c3d96b3ca7)
22
+ - chore(connect): remove validation in cardanoSignTransaction, cardanoAddressParameters, cardanoGetAddress, device.validateState (33efb4b8bd,013047bdb1, 21fadd17a6, 29311b5d61)
23
+ - feat(connect): use full version in URL when beta (26c70f48f7)
24
+ - fix(connect): simultaneous read of connected devices (f181c988a4)
25
+ - chore(connect): DeviceList now has two params - full settings object and messages (b6167266c9)
26
+ - chore(connect): remove DataManager from DeviceList (afc8760213)
27
+ - chore(connect): remove DataManager dependency from DeviceList constructor (7971515d71)
28
+ - chore(connect): simplify reduce code duplication in DeviceList (0cf8a04ed0)
10
29
  - feat(connect): BackupDevice now has params (4120912)
11
30
  - chore(connect): update protobuf messages (41bff13)
12
31
  - chore(connect): add new TS3 CA pubkeys and update timestamp (3ae06ac)
@@ -15,10 +34,23 @@
15
34
  - fix(connect): intermediary reconnect improved, device authenticity, multi-apps synchronization, reading translations, bin_outputs in txcache (115c718, de1b969, 140ec9a a881142, 88d7608, 0bb13d3)
16
35
  - fix(connect): bin_outputs in txcache (0bb13d3)
17
36
 
37
+ ## connect-examples
38
+
39
+ - Update building process to allow multiple lines replacing of url mv2 and mv3 (e88b6f6f47)
40
+
41
+ ## connect-explorer
42
+
43
+ Connect-explorer has been completely revamped into a new design :tada:
44
+
45
+ - feat(connect-explorer): use relative paths for assets and connect (f6f7cdf32c)
46
+ - fix(connect-explorer): method testing tool scrollbars (f15f6487d8)
47
+ - fix(connect-explorer): support GitHub emoji (fda80e5aa3)
48
+
18
49
  ## connect-popup
19
50
 
20
51
  In general measures to address popup closing unexpectedly were taken. Update of content-script.js will be needed to make these changes effective.
21
52
 
53
+ - fix(connect-popup): use PassphraseTypeCardLegacy (629d6f8671)
22
54
  - fix(connect-popup): update text in selectAccount (21f4382)
23
55
  - fix(connect-popup): add delay before popup bootstrap to allow contentscript load (00b2056)
24
56
  - fix(connect-popup): webextension example e2e (b9cce02)
@@ -27,20 +59,25 @@ In general measures to address popup closing unexpectedly were taken. Update of
27
59
  - fix(connect-popup): delay popup.js loading to allow content script to init (92d15bc)
28
60
  - fix(connect-popup): wait for POPUP.LOADED in webextension (cb18673)
29
61
 
30
- ## connect-explorer
62
+ ## transport
31
63
 
32
- Connect-explorer has been completely revamped into a new design :tada:
64
+ - feat(transport): make signal required param in constructor (4b82f8d505)
33
65
 
34
66
  ## Dependencies update
35
67
 
36
- - npm-release: @trezor/blockchain-link-utils 1.0.18-beta.1
37
- - npm-release: @trezor/blockchain-link-types 1.0.17-beta.1
38
- - npm-release: @trezor/analytics 1.0.17-beta.1
39
- - npm-release: @trezor/connect-common 0.0.33-beta.1
40
- - npm-release: @trezor/env-utils 1.0.17-beta.1
41
- - npm-release: @trezor/protobuf 1.0.13-beta.1
42
- - npm-release: @trezor/schema-utils 1.0.4-beta.1
43
- - npm-release: @trezor/protocol 1.0.9-beta.1
68
+ - npm-release: @trezor/blockchain-link 2.1.30
69
+ - npm-release: @trezor/blockchain-link-utils 1.0.18
70
+ - npm-release: @trezor/blockchain-link-types 1.0.17
71
+ - npm-release: @trezor/connect-analytics 1.0.15
72
+ - npm-release: @trezor/analytics 1.0.17
73
+ - npm-release: @trezor/connect-common 0.0.33
74
+ - npm-release: @trezor/env-utils 1.0.17
75
+ - npm-release: @trezor/transport 1.1.29
76
+ - npm-release: @trezor/protobuf 1.0.13
77
+ - npm-release: @trezor/schema-utils 1.0.4
78
+ - npm-release: @trezor/protocol 1.0.9
79
+ - npm-release: @trezor/utxo-lib 2.0.10
80
+ - npm-release: @trezor/utils 9.0.24
44
81
 
45
82
  # 9.2.3
46
83
 
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @trezor/connect
2
2
 
3
- API version 9.2.4-beta.1
3
+ API version 9.2.4
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)
@@ -1,10 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FeeLevels = void 0;
4
- const tslib_1 = require("tslib");
5
- const bignumber_js_1 = tslib_1.__importDefault(require("bignumber.js"));
4
+ const bigNumber_1 = require("@trezor/utils/lib/bigNumber");
6
5
  const convertFeeRate = (fee, minFee) => {
7
- const feePerKB = new bignumber_js_1.default(fee);
6
+ const feePerKB = new bigNumber_1.BigNumber(fee);
8
7
  if (feePerKB.isNaN() || feePerKB.lte('0'))
9
8
  return;
10
9
  const feePerB = feePerKB.div(1000);
@@ -41,7 +40,7 @@ const findLowest = (blocks) => blocks
41
40
  .reverse()
42
41
  .find(item => typeof item === 'string');
43
42
  const findBlocksForFee = (feePerUnit, blocks) => {
44
- const bn = new bignumber_js_1.default(feePerUnit);
43
+ const bn = new bigNumber_1.BigNumber(feePerUnit);
45
44
  const lower = blocks.find(b => typeof b === 'string' && bn.gte(b));
46
45
  if (!lower)
47
46
  return -1;
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TransactionComposer = void 0;
4
- const tslib_1 = require("tslib");
5
- const bignumber_js_1 = tslib_1.__importDefault(require("bignumber.js"));
4
+ const bigNumber_1 = require("@trezor/utils/lib/bigNumber");
6
5
  const utxo_lib_1 = require("@trezor/utxo-lib");
7
6
  const Fees_1 = require("./Fees");
8
7
  class TransactionComposer {
@@ -24,7 +23,7 @@ class TransactionComposer {
24
23
  .concat(addresses.change)
25
24
  .map(a => a.address);
26
25
  this.utxos = options.utxos.flatMap(u => {
27
- if (!u.required && new bignumber_js_1.default(u.amount).lte(this.coinInfo.dustLimit))
26
+ if (!u.required && new bigNumber_1.BigNumber(u.amount).lte(this.coinInfo.dustLimit))
28
27
  return [];
29
28
  return {
30
29
  ...u,
@@ -55,7 +54,7 @@ class TransactionComposer {
55
54
  });
56
55
  if (!atLeastOneValid) {
57
56
  const lastLevel = levels[levels.length - 1];
58
- let lastFee = new bignumber_js_1.default(lastLevel.feePerUnit);
57
+ let lastFee = new bigNumber_1.BigNumber(lastLevel.feePerUnit);
59
58
  while (lastFee.gt(this.coinInfo.minFee) && this.composed.custom === undefined) {
60
59
  lastFee = lastFee.minus(1);
61
60
  const tx = this.compose(lastFee.toString());
@@ -1,12 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createPendingTransaction = void 0;
4
- const tslib_1 = require("tslib");
5
- const bignumber_js_1 = tslib_1.__importDefault(require("bignumber.js"));
4
+ const bigNumber_1 = require("@trezor/utils/lib/bigNumber");
6
5
  const pathUtils_1 = require("../../utils/pathUtils");
7
6
  const createPendingTransaction = (tx, { addresses, inputs, outputs, }) => {
8
- const valueOut = outputs.reduce((sum, out) => (0, bignumber_js_1.default)(sum).plus(out.amount), new bignumber_js_1.default('0'));
9
- const valueIn = inputs.reduce((sum, ins) => (0, bignumber_js_1.default)(sum).plus(ins.amount), new bignumber_js_1.default('0'));
7
+ const valueOut = outputs.reduce((sum, out) => (0, bigNumber_1.BigNumber)(sum).plus(out.amount), new bigNumber_1.BigNumber('0'));
8
+ const valueIn = inputs.reduce((sum, ins) => (0, bigNumber_1.BigNumber)(sum).plus(ins.amount), new bigNumber_1.BigNumber('0'));
10
9
  const allAddresses = addresses.unused.concat(addresses.used, addresses.change);
11
10
  const findAddress = ({ address_n }) => {
12
11
  const path = address_n ? (0, pathUtils_1.getSerializedPath)(address_n) : undefined;
@@ -10,7 +10,7 @@ export default class BlockchainGetCurrentFiatRates extends AbstractMethod<'block
10
10
  init(): void;
11
11
  run(): Promise<{
12
12
  ts: number;
13
- rates: import("@trezor/blockchain-link-types/lib/common").FiatRatesLegacy;
13
+ rates: import("@trezor/blockchain-link-types/lib/common").FiatRatesBySymbol;
14
14
  }>;
15
15
  }
16
16
  export {};
@@ -12,7 +12,7 @@ export default class BlockchainGetFiatRatesForTimestamps extends AbstractMethod<
12
12
  run(): Promise<{
13
13
  tickers: {
14
14
  ts: number;
15
- rates: import("@trezor/blockchain-link-types/lib/common").FiatRatesLegacy;
15
+ rates: import("@trezor/blockchain-link-types/lib/common").FiatRatesBySymbol;
16
16
  }[];
17
17
  }>;
18
18
  }
@@ -20,7 +20,6 @@ export default class CardanoGetAddress extends AbstractMethod<'cardanoGetAddress
20
20
  _call({ address_parameters, protocol_magic, network_id, derivation_type, show_display, chunkify, }: Params): Promise<{
21
21
  address: string;
22
22
  }>;
23
- _ensureFirmwareSupportsBatch(batch: Params): void;
24
23
  run(): Promise<import("../../../types").CardanoAddress | import("../../../types").CardanoAddress[]>;
25
24
  }
26
25
  export {};
@@ -79,27 +79,11 @@ class CardanoGetAddress extends AbstractMethod_1.AbstractMethod {
79
79
  });
80
80
  return response.message;
81
81
  }
82
- _ensureFirmwareSupportsBatch(batch) {
83
- const SCRIPT_ADDRESSES_TYPES = [
84
- constants_1.PROTO.CardanoAddressType.BASE_SCRIPT_KEY,
85
- constants_1.PROTO.CardanoAddressType.BASE_KEY_SCRIPT,
86
- constants_1.PROTO.CardanoAddressType.BASE_SCRIPT_SCRIPT,
87
- constants_1.PROTO.CardanoAddressType.POINTER_SCRIPT,
88
- constants_1.PROTO.CardanoAddressType.ENTERPRISE_SCRIPT,
89
- constants_1.PROTO.CardanoAddressType.REWARD_SCRIPT,
90
- ];
91
- if (SCRIPT_ADDRESSES_TYPES.includes(batch.address_parameters.address_type)) {
92
- if (!this.device.atLeast(['0', '2.4.3'])) {
93
- throw constants_1.ERRORS.TypedError('Method_InvalidParameter', `Address type not supported by device firmware`);
94
- }
95
- }
96
- }
97
82
  async run() {
98
83
  const responses = [];
99
84
  for (let i = 0; i < this.params.length; i++) {
100
85
  const batch = this.params[i];
101
- this._ensureFirmwareSupportsBatch(batch);
102
- batch.address_parameters = (0, cardanoAddressParameters_1.modifyAddressParametersForBackwardsCompatibility)(this.device, batch.address_parameters);
86
+ batch.address_parameters = (0, cardanoAddressParameters_1.modifyAddressParametersForBackwardsCompatibility)(batch.address_parameters);
103
87
  if (batch.show_display) {
104
88
  const silent = await this._call({
105
89
  ...batch,
@@ -5,19 +5,7 @@ import type { OutputWithData } from '../cardanoOutputs';
5
5
  import { PROTO } from '../../../constants';
6
6
  import { type CardanoSignedTxData } from '../../../types/api/cardano';
7
7
  import type { AssetGroupWithTokens } from '../cardanoTokenBundle';
8
- declare const CardanoSignTransactionFeatures: Readonly<{
9
- TransactionStreaming: string[];
10
- TokenMinting: string[];
11
- Multisig: string[];
12
- NetworkIdInTxBody: string[];
13
- OutputDatumHash: string[];
14
- ScriptDataHash: string[];
15
- Plutus: string[];
16
- KeyHashStakeCredential: string[];
17
- Babbage: string[];
18
- CIP36Registration: string[];
19
- CIP36RegistrationExternalPaymentAddress: string[];
20
- }>;
8
+ declare const CardanoSignTransactionFeatures: Readonly<{}>;
21
9
  export type CardanoSignTransactionParams = {
22
10
  signingMode: PROTO.CardanoTxSigningMode;
23
11
  inputsWithPath: InputWithPath[];
@@ -14,19 +14,7 @@ const cardano_1 = require("../../../types/api/cardano");
14
14
  const cardanoWitnesses_1 = require("../cardanoWitnesses");
15
15
  const cardanoTokenBundle_1 = require("../cardanoTokenBundle");
16
16
  const schema_utils_1 = require("@trezor/schema-utils");
17
- const CardanoSignTransactionFeatures = Object.freeze({
18
- TransactionStreaming: ['0', '2.4.2'],
19
- TokenMinting: ['0', '2.4.3'],
20
- Multisig: ['0', '2.4.3'],
21
- NetworkIdInTxBody: ['0', '2.4.4'],
22
- OutputDatumHash: ['0', '2.4.4'],
23
- ScriptDataHash: ['0', '2.4.4'],
24
- Plutus: ['0', '2.4.4'],
25
- KeyHashStakeCredential: ['0', '2.4.4'],
26
- Babbage: ['0', '2.5.2'],
27
- CIP36Registration: ['0', '2.5.3'],
28
- CIP36RegistrationExternalPaymentAddress: ['0', '2.5.4'],
29
- });
17
+ const CardanoSignTransactionFeatures = Object.freeze({});
30
18
  class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
31
19
  init() {
32
20
  this.requiredPermissions = ['read', 'write'];
@@ -138,67 +126,6 @@ class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
138
126
  }
139
127
  }
140
128
  _ensureFirmwareSupportsParams() {
141
- var _a;
142
- const { params } = this;
143
- this._ensureFeatureIsSupported('TransactionStreaming');
144
- params.certificatesWithPoolOwnersAndRelays.forEach(({ certificate }) => {
145
- if (certificate.key_hash) {
146
- this._ensureFeatureIsSupported('KeyHashStakeCredential');
147
- }
148
- });
149
- params.outputsWithData.forEach(({ output }) => {
150
- if (output.datum_hash) {
151
- this._ensureFeatureIsSupported('OutputDatumHash');
152
- }
153
- });
154
- params.withdrawals.forEach(withdrawal => {
155
- if (withdrawal.key_hash) {
156
- this._ensureFeatureIsSupported('KeyHashStakeCredential');
157
- }
158
- });
159
- if (params.mint.length > 0) {
160
- this._ensureFeatureIsSupported('TokenMinting');
161
- }
162
- if (params.additionalWitnessRequests.length > 0 ||
163
- params.signingMode === constants_1.PROTO.CardanoTxSigningMode.MULTISIG_TRANSACTION) {
164
- this._ensureFeatureIsSupported('Multisig');
165
- }
166
- if (params.includeNetworkId) {
167
- this._ensureFeatureIsSupported('NetworkIdInTxBody');
168
- }
169
- if (params.scriptDataHash) {
170
- this._ensureFeatureIsSupported('ScriptDataHash');
171
- }
172
- if (params.signingMode === constants_1.PROTO.CardanoTxSigningMode.PLUTUS_TRANSACTION) {
173
- this._ensureFeatureIsSupported('Plutus');
174
- }
175
- params.outputsWithData.forEach(({ output, inlineDatum, referenceScript }) => {
176
- if (output.format === constants_1.PROTO.CardanoTxOutputSerializationFormat.MAP_BABBAGE ||
177
- inlineDatum ||
178
- referenceScript) {
179
- this._ensureFeatureIsSupported('Babbage');
180
- }
181
- });
182
- if (params.collateralReturnWithData ||
183
- params.totalCollateral != null ||
184
- params.referenceInputs.length > 0) {
185
- this._ensureFeatureIsSupported('Babbage');
186
- }
187
- if (params.requiredSigners.length > 0 &&
188
- params.signingMode !== constants_1.PROTO.CardanoTxSigningMode.PLUTUS_TRANSACTION) {
189
- this._ensureFeatureIsSupported('Babbage');
190
- }
191
- if ((_a = params.auxiliaryData) === null || _a === void 0 ? void 0 : _a.cvote_registration_parameters) {
192
- const { format, delegations, voting_purpose, payment_address } = params.auxiliaryData.cvote_registration_parameters;
193
- if (format === constants_1.PROTO.CardanoCVoteRegistrationFormat.CIP36 ||
194
- (delegations === null || delegations === void 0 ? void 0 : delegations.length) ||
195
- voting_purpose != null) {
196
- this._ensureFeatureIsSupported('CIP36Registration');
197
- }
198
- if (payment_address) {
199
- this._ensureFeatureIsSupported('CIP36RegistrationExternalPaymentAddress');
200
- }
201
- }
202
129
  }
203
130
  async _sign_tx() {
204
131
  const typedCall = this.device.getCommands().typedCall.bind(this.device.getCommands());
@@ -251,7 +178,7 @@ class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
251
178
  if (this.params.auxiliaryData) {
252
179
  const { cvote_registration_parameters } = this.params.auxiliaryData;
253
180
  if (cvote_registration_parameters) {
254
- this.params.auxiliaryData = (0, cardanoAuxiliaryData_1.modifyAuxiliaryDataForBackwardsCompatibility)(this.device, this.params.auxiliaryData);
181
+ this.params.auxiliaryData = (0, cardanoAuxiliaryData_1.modifyAuxiliaryDataForBackwardsCompatibility)(this.params.auxiliaryData);
255
182
  }
256
183
  const { message } = await typedCall('CardanoTxAuxiliaryData', 'CardanoTxAuxiliaryDataSupplement', this.params.auxiliaryData);
257
184
  const auxiliaryDataType = constants_1.PROTO.CardanoTxAuxiliaryDataSupplementType[message.type];
@@ -1,8 +1,7 @@
1
1
  import { PROTO } from '../../constants';
2
- import type { Device } from '../../device/Device';
3
2
  import { CardanoAddressParameters } from '../../types/api/cardano';
4
3
  export declare const validateAddressParameters: (addressParameters: CardanoAddressParameters) => void;
5
- export declare const modifyAddressParametersForBackwardsCompatibility: (device: Device, address_parameters: PROTO.CardanoAddressParametersType) => PROTO.CardanoAddressParametersType;
4
+ export declare const modifyAddressParametersForBackwardsCompatibility: (address_parameters: PROTO.CardanoAddressParametersType) => PROTO.CardanoAddressParametersType;
6
5
  export declare const addressParametersToProto: (addressParameters: CardanoAddressParameters) => PROTO.CardanoAddressParametersType;
7
6
  export declare const addressParametersFromProto: (addressParameters: PROTO.CardanoAddressParametersType) => CardanoAddressParameters;
8
7
  //# sourceMappingURL=cardanoAddressParameters.d.ts.map
@@ -15,21 +15,15 @@ const validateAddressParameters = (addressParameters) => {
15
15
  }
16
16
  };
17
17
  exports.validateAddressParameters = validateAddressParameters;
18
- const modifyAddressParametersForBackwardsCompatibility = (device, address_parameters) => {
18
+ const modifyAddressParametersForBackwardsCompatibility = (address_parameters) => {
19
19
  if (address_parameters.address_type === constants_1.PROTO.CardanoAddressType.REWARD) {
20
20
  let { address_n, address_n_staking } = address_parameters;
21
21
  if (address_n.length > 0 && address_n_staking.length > 0) {
22
22
  throw constants_1.ERRORS.TypedError('Method_InvalidParameter', `Only stakingPath is allowed for CardanoAddressType.REWARD`);
23
23
  }
24
- if (device.atLeast(['0', '2.4.3'])) {
25
- if (address_n.length > 0) {
26
- address_n_staking = address_n;
27
- address_n = [];
28
- }
29
- }
30
- else if (address_n_staking.length > 0) {
31
- address_n = address_n_staking;
32
- address_n_staking = [];
24
+ if (address_n.length > 0) {
25
+ address_n_staking = address_n;
26
+ address_n = [];
33
27
  }
34
28
  return {
35
29
  ...address_parameters,
@@ -1,6 +1,5 @@
1
- import type { Device } from '../../device/Device';
2
1
  import { PROTO } from '../../constants';
3
2
  import { CardanoAuxiliaryData } from '../../types/api/cardano';
4
3
  export declare const transformAuxiliaryData: (auxiliaryData: CardanoAuxiliaryData) => PROTO.CardanoTxAuxiliaryData;
5
- export declare const modifyAuxiliaryDataForBackwardsCompatibility: (device: Device, auxiliary_data: PROTO.CardanoTxAuxiliaryData) => PROTO.CardanoTxAuxiliaryData;
4
+ export declare const modifyAuxiliaryDataForBackwardsCompatibility: (auxiliary_data: PROTO.CardanoTxAuxiliaryData) => PROTO.CardanoTxAuxiliaryData;
6
5
  //# sourceMappingURL=cardanoAuxiliaryData.d.ts.map
@@ -62,11 +62,11 @@ const transformAuxiliaryData = (auxiliaryData) => {
62
62
  };
63
63
  };
64
64
  exports.transformAuxiliaryData = transformAuxiliaryData;
65
- const modifyAuxiliaryDataForBackwardsCompatibility = (device, auxiliary_data) => {
65
+ const modifyAuxiliaryDataForBackwardsCompatibility = (auxiliary_data) => {
66
66
  const { cvote_registration_parameters } = auxiliary_data;
67
67
  if (cvote_registration_parameters === null || cvote_registration_parameters === void 0 ? void 0 : cvote_registration_parameters.payment_address_parameters) {
68
68
  cvote_registration_parameters.payment_address_parameters =
69
- (0, cardanoAddressParameters_1.modifyAddressParametersForBackwardsCompatibility)(device, cvote_registration_parameters.payment_address_parameters);
69
+ (0, cardanoAddressParameters_1.modifyAddressParametersForBackwardsCompatibility)(cvote_registration_parameters.payment_address_parameters);
70
70
  return {
71
71
  ...auxiliary_data,
72
72
  cvote_registration_parameters,
@@ -1,4 +1,4 @@
1
- import BigNumber from 'bignumber.js';
1
+ import { BigNumber } from '@trezor/utils/lib/bigNumber';
2
2
  import { AbstractMethod } from '../core/AbstractMethod';
3
3
  import { Discovery } from './common/Discovery';
4
4
  import { TransactionComposer } from './bitcoin';
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- const bignumber_js_1 = tslib_1.__importDefault(require("bignumber.js"));
4
+ const bigNumber_1 = require("@trezor/utils/lib/bigNumber");
5
5
  const AbstractMethod_1 = require("../core/AbstractMethod");
6
6
  const constants_1 = require("../constants");
7
7
  const events_1 = require("../events");
@@ -36,7 +36,7 @@ class ComposeTransaction extends AbstractMethod_1.AbstractMethod {
36
36
  (0, BlockchainLink_1.isBackendSupported)(coinInfo);
37
37
  this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, coinInfo, this.firmwareRange);
38
38
  const outputs = [];
39
- let total = new bignumber_js_1.default(0);
39
+ let total = new bigNumber_1.BigNumber(0);
40
40
  payload.outputs.forEach(out => {
41
41
  const output = (0, bitcoin_1.validateHDOutput)(out, coinInfo);
42
42
  if ('amount' in output && typeof output.amount === 'string') {
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getFieldType = exports.encodeData = exports.parseArrayType = void 0;
4
- const tslib_1 = require("tslib");
5
- const bignumber_js_1 = tslib_1.__importDefault(require("bignumber.js"));
4
+ const bigNumber_1 = require("@trezor/utils/lib/bigNumber");
6
5
  const constants_1 = require("../../constants");
7
6
  const formatUtils_1 = require("../../utils/formatUtils");
8
7
  const paramTypeArray = new RegExp(/^(.*)\[([0-9]*)\]$/);
@@ -24,9 +23,9 @@ function twosComplement(number, bytes) {
24
23
  if (bytes < 1 || bytes > 32) {
25
24
  throw constants_1.ERRORS.TypedError('Runtime', 'Int byte size must be between 1 and 32 (8 and 256 bits)');
26
25
  }
27
- const minValue = new bignumber_js_1.default(2).exponentiatedBy(bytes * 8 - 1).negated();
26
+ const minValue = new bigNumber_1.BigNumber(2).exponentiatedBy(bytes * 8 - 1).negated();
28
27
  const maxValue = minValue.negated().minus(1);
29
- const bigNumber = new bignumber_js_1.default(number);
28
+ const bigNumber = new bigNumber_1.BigNumber(number);
30
29
  if (bigNumber.isGreaterThan(maxValue) || bigNumber.isLessThan(minValue)) {
31
30
  throw constants_1.ERRORS.TypedError('Runtime', `Overflow when trying to convert number ${number} into ${bytes} bytes`);
32
31
  }
@@ -36,7 +35,7 @@ function twosComplement(number, bytes) {
36
35
  return bigNumber.minus(minValue).minus(minValue);
37
36
  }
38
37
  function intToHex(number, bytes, signed) {
39
- let bigNumber = new bignumber_js_1.default(number);
38
+ let bigNumber = new bigNumber_1.BigNumber(number);
40
39
  if (signed) {
41
40
  bigNumber = twosComplement(bigNumber, bytes);
42
41
  }
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const bignumber_js_1 = tslib_1.__importDefault(require("bignumber.js"));
3
+ const bigNumber_1 = require("@trezor/utils/lib/bigNumber");
5
4
  const AbstractMethod_1 = require("../core/AbstractMethod");
6
5
  const paramsValidator_1 = require("./common/paramsValidator");
7
6
  const coinInfo_1 = require("../data/coinInfo");
@@ -65,7 +64,7 @@ class SignTransaction extends AbstractMethod_1.AbstractMethod {
65
64
  const outputsWithAmount = outputs.filter(output => typeof output.amount === 'string' &&
66
65
  !Object.prototype.hasOwnProperty.call(output, 'op_return_data'));
67
66
  if (outputsWithAmount.length > 0) {
68
- const total = outputsWithAmount.reduce((bn, output) => bn.plus(typeof output.amount === 'string' ? output.amount : '0'), new bignumber_js_1.default(0));
67
+ const total = outputsWithAmount.reduce((bn, output) => bn.plus(typeof output.amount === 'string' ? output.amount : '0'), new bigNumber_1.BigNumber(0));
69
68
  if (total.lt(coinInfo.dustLimit)) {
70
69
  throw constants_1.ERRORS.TypedError('Method_InvalidParameter', 'Total amount is below dust limit.');
71
70
  }
@@ -31,7 +31,7 @@ export declare class Blockchain {
31
31
  token?: string;
32
32
  }): Promise<{
33
33
  ts: number;
34
- rates: import("@trezor/blockchain-link").FiatRatesLegacy;
34
+ rates: import("@trezor/blockchain-link").FiatRatesBySymbol;
35
35
  }>;
36
36
  getFiatRatesForTimestamps(params: {
37
37
  currencies?: string[];
@@ -40,7 +40,7 @@ export declare class Blockchain {
40
40
  }): Promise<{
41
41
  tickers: {
42
42
  ts: number;
43
- rates: import("@trezor/blockchain-link").FiatRatesLegacy;
43
+ rates: import("@trezor/blockchain-link").FiatRatesBySymbol;
44
44
  }[];
45
45
  }>;
46
46
  getAccountBalanceHistory(params: BlockchainLinkParams<'getAccountBalanceHistory'>): Promise<import("@trezor/blockchain-link").AccountBalanceHistory[]>;
package/lib/core/index.js CHANGED
@@ -126,10 +126,10 @@ const initDevice = async (devicePath) => {
126
126
  return device;
127
127
  };
128
128
  const MAX_PIN_TRIES = 3;
129
- const getInvalidDeviceState = async (device, network, preauthorized) => {
129
+ const getInvalidDeviceState = async (device, preauthorized) => {
130
130
  for (let i = 0; i < MAX_PIN_TRIES - 1; ++i) {
131
131
  try {
132
- return await device.validateState(network, preauthorized);
132
+ return await device.validateState(preauthorized);
133
133
  }
134
134
  catch (error) {
135
135
  if (error.message.includes('PIN invalid')) {
@@ -140,7 +140,7 @@ const getInvalidDeviceState = async (device, network, preauthorized) => {
140
140
  }
141
141
  }
142
142
  }
143
- return device.validateState(network, preauthorized);
143
+ return device.validateState(preauthorized);
144
144
  };
145
145
  const inner = async (method, device) => {
146
146
  var _a;
@@ -232,7 +232,7 @@ const inner = async (method, device) => {
232
232
  const isDeviceUnlocked = device.features.unlocked;
233
233
  if (method.useDeviceState) {
234
234
  try {
235
- let invalidDeviceState = await getInvalidDeviceState(device, method.network, method.preauthorized);
235
+ let invalidDeviceState = await getInvalidDeviceState(device, method.preauthorized);
236
236
  if (isUsingPopup) {
237
237
  while (invalidDeviceState) {
238
238
  const uiPromise = uiPromises.create(events_2.UI.INVALID_PASSPHRASE_ACTION, device);
@@ -243,7 +243,7 @@ const inner = async (method, device) => {
243
243
  if (uiResp.payload) {
244
244
  device.setInternalState(undefined);
245
245
  await device.initialize(method.useEmptyPassphrase, method.useCardanoDerivation);
246
- invalidDeviceState = await getInvalidDeviceState(device, method.network, method.preauthorized);
246
+ invalidDeviceState = await getInvalidDeviceState(device, method.preauthorized);
247
247
  }
248
248
  else {
249
249
  device.setExternalState(invalidDeviceState);
@@ -587,7 +587,10 @@ const handleDeviceSelectionChanges = (interruptDevice) => {
587
587
  };
588
588
  const initDeviceList = async (transportReconnect) => {
589
589
  try {
590
- _deviceList = new DeviceList_1.DeviceList();
590
+ _deviceList = new DeviceList_1.DeviceList({
591
+ settings: DataManager_1.DataManager.getSettings(),
592
+ messages: DataManager_1.DataManager.getProtobufMessages(),
593
+ });
591
594
  _deviceList.on(events_2.DEVICE.CONNECT, device => {
592
595
  handleDeviceSelectionChanges();
593
596
  postMessage((0, events_2.createDeviceMessage)(events_2.DEVICE.CONNECT, device));
@@ -119,7 +119,14 @@ const getBinaryHelper = (device, params, log, postMessage, intermediaryVersion)
119
119
  version: device.firmwareRelease.release.version,
120
120
  btcOnly,
121
121
  intermediaryVersion,
122
- }).then(res => {
122
+ })
123
+ .then(res => {
124
+ if (res.byteLength < 200) {
125
+ throw constants_1.ERRORS.TypedError('Runtime', 'Firmware binary is too small');
126
+ }
127
+ return res;
128
+ })
129
+ .then(res => {
123
130
  postMessage((0, events_1.createUiMessage)(events_1.UI.FIRMWARE_PROGRESS, {
124
131
  device: device.toMessageObject(),
125
132
  operation: 'downloading',
@@ -56,6 +56,16 @@ export declare class DataManager {
56
56
  download: string;
57
57
  update: string;
58
58
  };
59
+ brave: {
60
+ version: number;
61
+ download: string;
62
+ update: string;
63
+ };
64
+ edge: {
65
+ version: number;
66
+ download: string;
67
+ update: string;
68
+ };
59
69
  };
60
70
  supportedFirmware: ({
61
71
  coin: string[];
@@ -44,6 +44,16 @@ export declare const config: {
44
44
  download: string;
45
45
  update: string;
46
46
  };
47
+ brave: {
48
+ version: number;
49
+ download: string;
50
+ update: string;
51
+ };
52
+ edge: {
53
+ version: number;
54
+ download: string;
55
+ update: string;
56
+ };
47
57
  };
48
58
  supportedFirmware: ({
49
59
  coin: string[];
@@ -46,6 +46,11 @@ exports.config = {
46
46
  label: 'Rainbow',
47
47
  icon: '',
48
48
  },
49
+ {
50
+ origin: 'acmacodkjbdgmoleebolmdjonilkdbch',
51
+ label: 'Rabby',
52
+ icon: '',
53
+ },
49
54
  { origin: 'file://', label: ' ', icon: '' },
50
55
  ],
51
56
  onionDomains: {
@@ -103,6 +108,16 @@ exports.config = {
103
108
  download: 'https://www.mozilla.org/en-US/firefox/new/',
104
109
  update: 'https://support.mozilla.org/en-US/kb/update-firefox-latest-version',
105
110
  },
111
+ brave: {
112
+ version: 59,
113
+ download: 'https://brave.com/download/',
114
+ update: 'https://brave.com/download/',
115
+ },
116
+ edge: {
117
+ version: 79,
118
+ download: 'https://www.microsoft.com/en-us/edge',
119
+ update: 'https://www.microsoft.com/en-us/edge',
120
+ },
106
121
  },
107
122
  supportedFirmware: [
108
123
  {
@@ -140,18 +155,18 @@ exports.config = {
140
155
  },
141
156
  {
142
157
  methods: ['cardanoGetAddress', 'cardanoGetPublicKey'],
143
- min: { T1B1: '0', T2T1: '2.3.2' },
144
- comment: ['Shelley fork support since firmware 2.3.2'],
158
+ min: { T1B1: '0', T2T1: '2.4.3' },
159
+ comment: ['Since 2.4.3 Cardano derivation behavior has changed'],
145
160
  },
146
161
  {
147
162
  methods: ['cardanoSignTransaction'],
148
- min: { T1B1: '0', T2T1: '2.4.2' },
149
- comment: ['Non-streamed signing no longer supported'],
163
+ min: { T1B1: '0', T2T1: '2.6.0' },
164
+ comment: ['Before 2.6.0 not all Cardano transactions were supported'],
150
165
  },
151
166
  {
152
167
  methods: ['cardanoGetNativeScriptHash'],
153
168
  min: { T1B1: '0', T2T1: '2.4.3' },
154
- comment: ['Cardano GetNativeScriptHash call added in 2.4.3'],
169
+ comment: ['Since 2.4.3 Cardano derivation behavior has changed'],
155
170
  },
156
171
  {
157
172
  methods: ['tezosSignTransaction'],
@@ -1,3 +1,3 @@
1
- export declare const VERSION = "9.2.4-beta.1";
1
+ export declare const VERSION = "9.2.4";
2
2
  export declare const DEFAULT_DOMAIN: string;
3
3
  //# sourceMappingURL=version.d.ts.map
@@ -1,7 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DEFAULT_DOMAIN = exports.VERSION = void 0;
4
- exports.VERSION = '9.2.4-beta.1';
4
+ exports.VERSION = '9.2.4';
5
5
  const versionN = exports.VERSION.split('.').map(s => parseInt(s, 10));
6
- exports.DEFAULT_DOMAIN = `https://connect.trezor.io/${versionN[0]}/`;
6
+ const isBeta = exports.VERSION.includes('beta');
7
+ exports.DEFAULT_DOMAIN = isBeta
8
+ ? `https://connect.trezor.io/${exports.VERSION}/`
9
+ : `https://connect.trezor.io/${versionN[0]}/`;
7
10
  //# sourceMappingURL=version.js.map
@@ -1,5 +1,5 @@
1
- import { TypedEmitter } from '@trezor/utils';
2
- import { Deferred } from '@trezor/utils';
1
+ import { Deferred, TypedEmitter } from '@trezor/utils';
2
+ import { Session } from '@trezor/transport';
3
3
  import { TransportProtocol } from '@trezor/protocol';
4
4
  import { DeviceCommands, PassphrasePromptResponse } from './DeviceCommands';
5
5
  import { PROTO, NETWORK } from '../constants';
@@ -40,7 +40,7 @@ export declare class Device extends TypedEmitter<DeviceEvents> {
40
40
  loaded: boolean;
41
41
  inconsistent: boolean;
42
42
  firstRunPromise: Deferred<boolean>;
43
- activitySessionID?: string | null;
43
+ activitySessionID?: Session | null;
44
44
  commands?: DeviceCommands;
45
45
  keepSession: boolean;
46
46
  instance: number;
@@ -70,7 +70,7 @@ export declare class Device extends TypedEmitter<DeviceEvents> {
70
70
  getInternalState(): string;
71
71
  setExternalState(state?: string): void;
72
72
  getExternalState(): string;
73
- validateState(networkType?: NETWORK.NetworkType, preauthorized?: boolean): Promise<string | undefined>;
73
+ validateState(preauthorized?: boolean): Promise<string | undefined>;
74
74
  useLegacyPassphrase(): boolean;
75
75
  initialize(useEmptyPassphrase: boolean, useCardanoDerivation: boolean): Promise<void>;
76
76
  getFeatures(): Promise<void>;
@@ -2,8 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Device = exports.GET_FEATURES_TIMEOUT = void 0;
4
4
  const utils_1 = require("@trezor/utils");
5
- const utils_2 = require("@trezor/utils");
6
- const utils_3 = require("@trezor/utils");
7
5
  const protocol_1 = require("@trezor/protocol");
8
6
  const DeviceCommands_1 = require("./DeviceCommands");
9
7
  const constants_1 = require("../constants");
@@ -47,7 +45,7 @@ class Device extends utils_1.TypedEmitter {
47
45
  }
48
46
  this.transport = transport;
49
47
  this.originalDescriptor = descriptor;
50
- this.firstRunPromise = (0, utils_2.createDeferred)();
48
+ this.firstRunPromise = (0, utils_1.createDeferred)();
51
49
  }
52
50
  static fromDescriptor(transport, originalDescriptor) {
53
51
  const descriptor = { ...originalDescriptor, session: null };
@@ -124,7 +122,7 @@ class Device extends utils_1.TypedEmitter {
124
122
  throw constants_1.ERRORS.TypedError('Device_CallInProgress');
125
123
  }
126
124
  options = parseRunOptions(options);
127
- const runPromise = (0, utils_2.createDeferred)();
125
+ const runPromise = (0, utils_1.createDeferred)();
128
126
  this.runPromise = runPromise;
129
127
  this._runInner(fn, options).catch(err => {
130
128
  runPromise.reject(err);
@@ -265,7 +263,7 @@ class Device extends utils_1.TypedEmitter {
265
263
  getExternalState() {
266
264
  return this.externalState[this.instance];
267
265
  }
268
- async validateState(networkType, preauthorized = false) {
266
+ async validateState(preauthorized = false) {
269
267
  if (!this.features)
270
268
  return;
271
269
  if (!this.features.unlocked && preauthorized) {
@@ -274,7 +272,7 @@ class Device extends utils_1.TypedEmitter {
274
272
  }
275
273
  }
276
274
  const expectedState = this.getExternalState();
277
- const state = await this.getCommands().getDeviceState(networkType);
275
+ const state = await this.getCommands().getDeviceState();
278
276
  const uniqueState = `${state}@${this.features.device_id || 'device_id'}:${this.instance}`;
279
277
  if (!this.useLegacyPassphrase() && this.features.session_id) {
280
278
  this.setInternalState(this.features.session_id);
@@ -380,7 +378,7 @@ class Device extends utils_1.TypedEmitter {
380
378
  feat.minor_version,
381
379
  feat.patch_version,
382
380
  ];
383
- if (!utils_3.versionUtils.isEqual(version, this.getVersion())) {
381
+ if (!utils_1.versionUtils.isEqual(version, this.getVersion())) {
384
382
  this.unavailableCapabilities = (0, deviceFeaturesUtils_1.getUnavailableCapabilities)(feat, (0, coinInfo_1.getAllNetworks)());
385
383
  this.firmwareStatus = (0, firmwareInfo_1.getFirmwareStatus)(feat);
386
384
  this.firmwareRelease = (0, firmwareInfo_1.getRelease)(feat);
@@ -448,7 +446,7 @@ class Device extends utils_1.TypedEmitter {
448
446
  if (!this.features)
449
447
  return false;
450
448
  const modelVersion = typeof versions === 'string' ? versions : versions[this.features.major_version - 1];
451
- return utils_3.versionUtils.isNewerOrEqual(this.getVersion().join('.'), modelVersion);
449
+ return utils_1.versionUtils.isNewerOrEqual(this.getVersion().join('.'), modelVersion);
452
450
  }
453
451
  isUsed() {
454
452
  return typeof this.originalDescriptor.session === 'string';
@@ -1,4 +1,4 @@
1
- import { Transport } from '@trezor/transport';
1
+ import { Transport, Session } from '@trezor/transport';
2
2
  import { MessagesSchema as Messages } from '@trezor/protobuf';
3
3
  import { Device } from './Device';
4
4
  import type { CoinInfo, BitcoinNetworkInfo } from '../types';
@@ -21,12 +21,12 @@ export type PassphrasePromptResponse = {
21
21
  export declare class DeviceCommands {
22
22
  device: Device;
23
23
  transport: Transport;
24
- sessionId: string;
24
+ sessionId: Session;
25
25
  disposed: boolean;
26
26
  callPromise?: ReturnType<Transport['call']>;
27
27
  _cancelableRequest?: (error?: any) => void;
28
28
  _cancelableRequestBySend?: boolean;
29
- constructor(device: Device, transport: Transport, sessionId: string);
29
+ constructor(device: Device, transport: Transport, sessionId: Session);
30
30
  dispose(): void;
31
31
  isDisposed(): boolean;
32
32
  unlockPath(params?: Messages.UnlockPath): Promise<TypedResponseMessage<"UnlockedPathRequest">>;
@@ -71,13 +71,13 @@ export declare class DeviceCommands {
71
71
  }>;
72
72
  ethereumGetPublicKey({ address_n, show_display, }: Messages.EthereumGetPublicKey): Promise<HDNodeResponse>;
73
73
  preauthorize(throwError: boolean): Promise<boolean>;
74
- getDeviceState(networkType?: string): Promise<string>;
74
+ getDeviceState(): Promise<string>;
75
75
  private call;
76
76
  typedCall<T extends MessageKey, R extends MessageKey[]>(type: T, resType: R, msg?: MessageType[T]): Promise<TypedCallResponseMap[R[number]]>;
77
77
  typedCall<T extends MessageKey, R extends MessageKey>(type: T, resType: R, msg?: MessageType[T]): Promise<TypedResponseMessage<R>>;
78
78
  _commonCall(type: MessageKey, msg?: DefaultMessageResponse['message']): Promise<DefaultMessageResponse>;
79
79
  _filterCommonTypes(res: DefaultMessageResponse): Promise<DefaultMessageResponse>;
80
- _getAddressForNetworkType(networkType?: string): Promise<string>;
80
+ private _getAddress;
81
81
  _promptPin(type?: Messages.PinMatrixRequestType): Promise<string>;
82
82
  _promptPassphrase(): Promise<PassphrasePromptResponse>;
83
83
  _promptWord(type: Messages.WordRequestType): Promise<string>;
@@ -197,11 +197,8 @@ class DeviceCommands {
197
197
  return false;
198
198
  }
199
199
  }
200
- getDeviceState(networkType) {
201
- if (!this.device.atLeast('2.4.3')) {
202
- return this._getAddressForNetworkType(networkType);
203
- }
204
- return this._getAddressForNetworkType();
200
+ getDeviceState() {
201
+ return this._getAddress();
205
202
  }
206
203
  async call(type, msg = {}) {
207
204
  logger.debug('Sending', type, filterForLog(type, msg));
@@ -324,30 +321,13 @@ class DeviceCommands {
324
321
  }
325
322
  return Promise.resolve(res);
326
323
  }
327
- async _getAddressForNetworkType(networkType) {
328
- switch (networkType) {
329
- case constants_1.NETWORK.TYPES.cardano: {
330
- const { message } = await this.typedCall('CardanoGetAddress', 'CardanoAddress', {
331
- address_parameters: {
332
- address_type: 8,
333
- address_n: [(0, pathUtils_1.toHardened)(44), (0, pathUtils_1.toHardened)(1815), (0, pathUtils_1.toHardened)(0), 0, 0],
334
- address_n_staking: [],
335
- },
336
- protocol_magic: 42,
337
- network_id: 0,
338
- derivation_type: 2,
339
- });
340
- return message.address;
341
- }
342
- default: {
343
- const { message } = await this.typedCall('GetAddress', 'Address', {
344
- address_n: [(0, pathUtils_1.toHardened)(44), (0, pathUtils_1.toHardened)(1), (0, pathUtils_1.toHardened)(0), 0, 0],
345
- coin_name: 'Testnet',
346
- script_type: 'SPENDADDRESS',
347
- });
348
- return message.address;
349
- }
350
- }
324
+ async _getAddress() {
325
+ const { message } = await this.typedCall('GetAddress', 'Address', {
326
+ address_n: [(0, pathUtils_1.toHardened)(44), (0, pathUtils_1.toHardened)(1), (0, pathUtils_1.toHardened)(0), 0, 0],
327
+ coin_name: 'Testnet',
328
+ script_type: 'SPENDADDRESS',
329
+ });
330
+ return message.address;
351
331
  }
352
332
  _promptPin(type) {
353
333
  return new Promise((resolve, reject) => {
@@ -2,7 +2,7 @@ import { TypedEmitter } from '@trezor/utils';
2
2
  import { Transport, TRANSPORT, Descriptor } from '@trezor/transport';
3
3
  import { DEVICE, TransportInfo } from '../events';
4
4
  import { Device } from './Device';
5
- import type { Device as DeviceTyped } from '../types';
5
+ import type { ConnectSettings, Device as DeviceTyped } from '../types';
6
6
  interface DeviceListEvents {
7
7
  [TRANSPORT.START]: TransportInfo;
8
8
  [TRANSPORT.ERROR]: string;
@@ -19,7 +19,6 @@ export declare class DeviceList extends TypedEmitter<DeviceListEvents> {
19
19
  devices: {
20
20
  [path: string]: Device;
21
21
  };
22
- messages: JSON | Record<string, any>;
23
22
  creatingDevicesDescriptors: {
24
23
  [k: string]: Descriptor;
25
24
  };
@@ -28,7 +27,11 @@ export declare class DeviceList extends TypedEmitter<DeviceListEvents> {
28
27
  [deviceID: string]: number;
29
28
  };
30
29
  transportFirstEventPromise: Promise<void> | undefined;
31
- constructor();
30
+ private settings;
31
+ constructor({ settings, messages, }: {
32
+ settings: ConnectSettings;
33
+ messages: Record<string, any>;
34
+ });
32
35
  init(): Promise<void>;
33
36
  private resolveTransportEvent;
34
37
  waitForTransportFirstEvent(): Promise<void>;
@@ -6,62 +6,62 @@ const transport_1 = require("@trezor/transport");
6
6
  const constants_1 = require("../constants");
7
7
  const events_1 = require("../events");
8
8
  const Device_1 = require("./Device");
9
- const DataManager_1 = require("../data/DataManager");
10
9
  const transportInfo_1 = require("../data/transportInfo");
11
10
  const debug_1 = require("../utils/debug");
12
11
  const promiseUtils_1 = require("../utils/promiseUtils");
13
12
  const _log = (0, debug_1.initLog)('DeviceList');
14
13
  let autoResolveTransportEventTimeout;
15
14
  class DeviceList extends utils_1.TypedEmitter {
16
- constructor() {
15
+ constructor({ settings, messages, }) {
17
16
  super();
18
17
  this.transports = [];
19
18
  this.devices = {};
20
19
  this.creatingDevicesDescriptors = {};
21
20
  this.transportStartPending = 0;
22
21
  this.penalizedDevices = {};
23
- let { transports } = DataManager_1.DataManager.getSettings();
24
- const { debug } = DataManager_1.DataManager.getSettings();
25
- this.messages = DataManager_1.DataManager.getProtobufMessages();
26
- if (!(transports === null || transports === void 0 ? void 0 : transports.length)) {
27
- transports = ['BridgeTransport'];
22
+ this.settings = settings;
23
+ const transports = [...(settings.transports || [])];
24
+ if (!transports.length) {
25
+ transports.push('BridgeTransport');
28
26
  }
29
- const transportLogger = (0, debug_1.initLog)('@trezor/transport', debug);
27
+ const transportLogger = (0, debug_1.initLog)('@trezor/transport', this.settings.debug);
28
+ const abortController = new AbortController();
29
+ const transportCommonArgs = {
30
+ messages,
31
+ logger: transportLogger,
32
+ signal: abortController.signal,
33
+ };
30
34
  transports.forEach(transportType => {
31
35
  if (typeof transportType === 'string') {
32
36
  switch (transportType) {
33
37
  case 'WebUsbTransport':
34
- this.transports.push(new transport_1.WebUsbTransport({
35
- messages: this.messages,
36
- logger: transportLogger,
37
- }));
38
+ this.transports.push(new transport_1.WebUsbTransport(transportCommonArgs));
38
39
  break;
39
40
  case 'NodeUsbTransport':
40
- this.transports.push(new transport_1.NodeUsbTransport({
41
- messages: this.messages,
42
- logger: transportLogger,
43
- }));
41
+ this.transports.push(new transport_1.NodeUsbTransport(transportCommonArgs));
44
42
  break;
45
43
  case 'BridgeTransport':
46
44
  this.transports.push(new transport_1.BridgeTransport({
47
45
  latestVersion: (0, transportInfo_1.getBridgeInfo)().version.join('.'),
48
- messages: this.messages,
49
- logger: transportLogger,
46
+ ...transportCommonArgs,
50
47
  }));
51
48
  break;
52
49
  case 'UdpTransport':
53
- this.transports.push(new transport_1.UdpTransport({
54
- logger: transportLogger,
55
- messages: this.messages,
56
- }));
50
+ this.transports.push(new transport_1.UdpTransport(transportCommonArgs));
57
51
  break;
58
52
  default:
59
53
  throw constants_1.ERRORS.TypedError('Runtime', `DeviceList.init: transports[] of unexpected type: ${transportType}`);
60
54
  }
61
55
  }
56
+ else if (typeof transportType === 'function' && 'prototype' in transportType) {
57
+ const transportInstance = new transportType(transportCommonArgs);
58
+ if ((0, transport_1.isTransportInstance)(transportInstance)) {
59
+ this.transports.push(transportInstance);
60
+ }
61
+ }
62
62
  else if ((0, transport_1.isTransportInstance)(transportType)) {
63
63
  if (!transportType.getMessage()) {
64
- transportType.updateMessages(this.messages);
64
+ transportType.updateMessages(messages);
65
65
  }
66
66
  this.transports.push(transportType);
67
67
  }
@@ -102,7 +102,7 @@ class DeviceList extends utils_1.TypedEmitter {
102
102
  diff.connected.forEach(async (descriptor) => {
103
103
  const path = descriptor.path.toString();
104
104
  this.creatingDevicesDescriptors[path] = descriptor;
105
- const priority = DataManager_1.DataManager.getSettings('priority');
105
+ const { priority } = this.settings;
106
106
  const penalty = this.getAuthPenalty();
107
107
  if (priority || penalty) {
108
108
  await (0, promiseUtils_1.resolveAfter)(501 + penalty + 100 * priority, null).promise;
@@ -188,7 +188,7 @@ class DeviceList extends utils_1.TypedEmitter {
188
188
  return;
189
189
  }
190
190
  const descriptors = enumerateResult.payload;
191
- if (descriptors.length > 0 && DataManager_1.DataManager.getSettings('pendingTransportEvent')) {
191
+ if (descriptors.length > 0 && this.settings.pendingTransportEvent) {
192
192
  this.transportStartPending = descriptors.length;
193
193
  this.on(events_1.DEVICE.CONNECT, this.resolveTransportEvent.bind(this));
194
194
  this.on(events_1.DEVICE.CONNECT_UNACQUIRED, this.resolveTransportEvent.bind(this));
@@ -329,6 +329,7 @@ class DeviceList extends utils_1.TypedEmitter {
329
329
  error.message === transport_1.TRANSPORT_ERROR.DEVICE_NOT_FOUND ||
330
330
  error.message === transport_1.TRANSPORT_ERROR.DEVICE_DISCONNECTED_DURING_ACTION ||
331
331
  error.message === transport_1.TRANSPORT_ERROR.UNEXPECTED_ERROR ||
332
+ error.message === transport_1.TRANSPORT_ERROR.DESCRIPTOR_NOT_FOUND ||
332
333
  error.message === transport_1.TRANSPORT_ERROR.HTTP_ERROR) {
333
334
  delete this.devices[path];
334
335
  }
@@ -1,4 +1,4 @@
1
- import type { ServerInfo, BlockEvent, FiatRatesLegacy, NotificationEvent } from '@trezor/blockchain-link';
1
+ import type { ServerInfo, BlockEvent, FiatRatesBySymbol, NotificationEvent } from '@trezor/blockchain-link';
2
2
  import type { CoinInfo } from '../types/coinInfo';
3
3
  import type { MessageFactoryFn } from '../types/utils';
4
4
  export declare const BLOCKCHAIN_EVENT = "BLOCKCHAIN_EVENT";
@@ -37,7 +37,7 @@ export interface BlockchainNotification {
37
37
  }
38
38
  export interface BlockchainFiatRatesUpdate {
39
39
  coin: CoinInfo;
40
- rates: FiatRatesLegacy;
40
+ rates: FiatRatesBySymbol;
41
41
  }
42
42
  export type BlockchainEvent = {
43
43
  type: typeof BLOCKCHAIN.CONNECT;
@@ -19,5 +19,5 @@ export type { ComposeOutput, PrecomposeResultError, PrecomposeResultNonFinal, Pr
19
19
  export type { PrecomposedTransactionCardano, PrecomposedTransactionErrorCardano, PrecomposedTransactionFinalCardano, PrecomposedTransactionNonFinalCardano, } from './api/cardanoComposeTransaction';
20
20
  export type { RecoveryDevice } from './api/recoveryDevice';
21
21
  export type { AuthenticateDeviceResult } from './api/authenticateDevice';
22
- export type { TokenInfo, TokenTransfer, InternalTransfer, FiatRatesLegacy, Target as TransactionTarget, AccountBalanceHistory as BlockchainAccountBalanceHistory, } from '@trezor/blockchain-link';
22
+ export type { TokenInfo, TokenTransfer, InternalTransfer, FiatRatesBySymbol, Target as TransactionTarget, AccountBalanceHistory as BlockchainAccountBalanceHistory, } from '@trezor/blockchain-link';
23
23
  //# sourceMappingURL=index.d.ts.map
@@ -15,7 +15,7 @@ export interface ConnectSettings {
15
15
  popup?: boolean;
16
16
  transportReconnect?: boolean;
17
17
  webusb?: boolean;
18
- transports?: (Transport['name'] | Transport)[];
18
+ transports?: (Transport['name'] | Transport | (new (...args: any[]) => Transport))[];
19
19
  pendingTransportEvent?: boolean;
20
20
  lazyLoad?: boolean;
21
21
  interactionTimeout?: number;
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.deepTransform = exports.messageToHex = exports.addHexPrefix = exports.stripHexPrefix = exports.hasHexPrefix = exports.btckb2satoshib = exports.formatTime = exports.formatAmount = void 0;
4
- const tslib_1 = require("tslib");
5
- const bignumber_js_1 = tslib_1.__importDefault(require("bignumber.js"));
6
- const formatAmount = (n, coinInfo) => `${new bignumber_js_1.default(n).div(10 ** coinInfo.decimals).toString(10)} ${coinInfo.shortcut}`;
4
+ const bigNumber_1 = require("@trezor/utils/lib/bigNumber");
5
+ const formatAmount = (n, coinInfo) => `${new bigNumber_1.BigNumber(n).div(10 ** coinInfo.decimals).toString(10)} ${coinInfo.shortcut}`;
7
6
  exports.formatAmount = formatAmount;
8
7
  const formatTime = (n) => {
9
8
  if (!n || n <= 0)
@@ -24,7 +23,7 @@ const formatTime = (n) => {
24
23
  return res;
25
24
  };
26
25
  exports.formatTime = formatTime;
27
- const btckb2satoshib = (n) => new bignumber_js_1.default(n).times(1e5).toFixed(0, bignumber_js_1.default.ROUND_HALF_UP);
26
+ const btckb2satoshib = (n) => new bigNumber_1.BigNumber(n).times(1e5).toFixed(0, bigNumber_1.BigNumber.ROUND_HALF_UP);
28
27
  exports.btckb2satoshib = btckb2satoshib;
29
28
  const hasHexPrefix = (str) => str.slice(0, 2).toLowerCase() === '0x';
30
29
  exports.hasHexPrefix = hasHexPrefix;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trezor/connect",
3
- "version": "9.2.4-beta.1",
3
+ "version": "9.2.4",
4
4
  "author": "Trezor <info@trezor.io>",
5
5
  "homepage": "https://github.com/trezor/trezor-suite/tree/develop/packages/connect",
6
6
  "description": "High-level javascript interface for Trezor hardware wallet.",
@@ -70,17 +70,16 @@
70
70
  "@ethereumjs/common": "^4.2.0",
71
71
  "@ethereumjs/tx": "^5.2.1",
72
72
  "@fivebinaries/coin-selection": "2.2.1",
73
- "@trezor/blockchain-link": "2.1.29",
74
- "@trezor/blockchain-link-types": "1.0.17-beta.1",
75
- "@trezor/connect-analytics": "1.0.14",
76
- "@trezor/connect-common": "0.0.33-beta.1",
77
- "@trezor/protobuf": "1.0.13-beta.1",
78
- "@trezor/protocol": "1.0.9-beta.1",
79
- "@trezor/schema-utils": "1.0.4-beta.1",
80
- "@trezor/transport": "1.1.28",
81
- "@trezor/utils": "9.0.23",
82
- "@trezor/utxo-lib": "2.0.9",
83
- "bignumber.js": "^9.1.2",
73
+ "@trezor/blockchain-link": "2.1.30",
74
+ "@trezor/blockchain-link-types": "1.0.17",
75
+ "@trezor/connect-analytics": "1.0.15",
76
+ "@trezor/connect-common": "0.0.33",
77
+ "@trezor/protobuf": "1.0.13",
78
+ "@trezor/protocol": "1.0.9",
79
+ "@trezor/schema-utils": "1.0.4",
80
+ "@trezor/transport": "1.1.29",
81
+ "@trezor/utils": "9.0.24",
82
+ "@trezor/utxo-lib": "2.0.10",
84
83
  "blakejs": "^1.2.1",
85
84
  "bs58": "^5.0.0",
86
85
  "bs58check": "^3.0.1",