@trezor/connect 9.0.8 → 9.0.9

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # 9.0.9
2
+
3
+ - fix(connect): prevent .asArray of undefined runtime error
4
+ - fix(connect): add missing currencies param for getFiatRatesForTimestamps
5
+
1
6
  # 9.0.8
2
7
 
3
8
  - feat: support multiple intermediary FWs for model 1 and devkit binaries
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @trezor/connect
2
2
 
3
- API version 9.0.8
3
+ API version 9.0.9
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,8 +1,7 @@
1
1
  import { Transaction as BitcoinJsTransaction } from '@trezor/utxo-lib';
2
2
  import { PROTO } from '../../constants';
3
- import type { AccountAddresses, AccountUtxo } from '../../types';
4
- export declare const createPendingTransaction: (tx: BitcoinJsTransaction, { utxo, addresses, inputs, outputs, }: {
5
- utxo: AccountUtxo[];
3
+ import type { AccountAddresses } from '../../types';
4
+ export declare const createPendingTransaction: (tx: BitcoinJsTransaction, { addresses, inputs, outputs, }: {
6
5
  addresses: AccountAddresses;
7
6
  inputs: PROTO.TxInputType[];
8
7
  outputs: PROTO.TxOutputType[];
@@ -4,9 +4,16 @@ exports.createPendingTransaction = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const bignumber_js_1 = tslib_1.__importDefault(require("bignumber.js"));
6
6
  const pathUtils_1 = require("../../utils/pathUtils");
7
- const createPendingTransaction = (tx, { utxo, addresses, inputs, outputs, }) => {
7
+ const createPendingTransaction = (tx, { addresses, inputs, outputs, }) => {
8
8
  const valueOut = outputs.reduce((sum, out) => (0, bignumber_js_1.default)(sum).plus(out.amount), new bignumber_js_1.default('0'));
9
9
  const valueIn = inputs.reduce((sum, ins) => (0, bignumber_js_1.default)(sum).plus(ins.amount), new bignumber_js_1.default('0'));
10
+ const allAddresses = addresses.unused.concat(addresses.used, addresses.change);
11
+ const findAddress = ({ address_n }) => {
12
+ const path = address_n ? (0, pathUtils_1.getSerializedPath)(address_n) : undefined;
13
+ return allAddresses
14
+ .filter(address => address.path === path)
15
+ .map(address => address.address);
16
+ };
10
17
  return {
11
18
  txid: tx.getId(),
12
19
  hex: tx.toHex(),
@@ -23,9 +30,7 @@ const createPendingTransaction = (tx, { utxo, addresses, inputs, outputs, }) =>
23
30
  txid: ins.prev_hash,
24
31
  vout: ins.prev_index,
25
32
  isAddress: true,
26
- addresses: utxo
27
- .filter(utxo => utxo.txid === ins.prev_hash && utxo.vout === ins.prev_index)
28
- .map(utxo => utxo.address),
33
+ addresses: findAddress(ins),
29
34
  value: ins.amount.toString(),
30
35
  })),
31
36
  vout: outputs.map((out, n) => {
@@ -39,13 +44,7 @@ const createPendingTransaction = (tx, { utxo, addresses, inputs, outputs, }) =>
39
44
  ];
40
45
  }
41
46
  else {
42
- transformedAddresses = [
43
- ...addresses.change,
44
- ...addresses.unused,
45
- ...addresses.used,
46
- ]
47
- .filter(address => out.address_n && address.path === (0, pathUtils_1.getSerializedPath)(out.address_n))
48
- .map(address => address.address);
47
+ transformedAddresses = findAddress(out);
49
48
  }
50
49
  return {
51
50
  n,
@@ -54,18 +54,18 @@ class EthereumSignTypedData extends AbstractMethod_1.AbstractMethod {
54
54
  async run() {
55
55
  const cmd = this.device.getCommands();
56
56
  const { address_n } = this.params;
57
+ const network = (0, coinInfo_1.getEthereumNetwork)(address_n);
58
+ const slip44 = (0, pathUtils_1.getSlip44ByPath)(address_n);
59
+ const definitions = await (0, ethereumDefinitions_1.getEthereumDefinitions)({
60
+ chainId: network === null || network === void 0 ? void 0 : network.chainId,
61
+ slip44,
62
+ });
57
63
  if (this.device.features.model === '1') {
58
64
  (0, paramsValidator_1.validateParams)(this.params, [
59
65
  { name: 'domain_separator_hash', type: 'string', required: true },
60
66
  { name: 'message_hash', type: 'string' },
61
67
  ]);
62
68
  const { domain_separator_hash, message_hash } = this.params;
63
- const network = (0, coinInfo_1.getEthereumNetwork)(address_n);
64
- const slip44 = (0, pathUtils_1.getSlip44ByPath)(address_n);
65
- const definitions = await (0, ethereumDefinitions_1.getEthereumDefinitions)({
66
- chainId: network === null || network === void 0 ? void 0 : network.chainId,
67
- slip44,
68
- });
69
69
  const definitionParams = {
70
70
  ...(definitions.encoded_network && {
71
71
  encoded_network: definitions.encoded_network,
@@ -93,6 +93,7 @@ class EthereumSignTypedData extends AbstractMethod_1.AbstractMethod {
93
93
  address_n,
94
94
  primary_type: primaryType,
95
95
  metamask_v4_compat,
96
+ definitions,
96
97
  });
97
98
  while (response.type === 'EthereumTypedDataStructRequest') {
98
99
  const { name: typeDefinitionName } = response.message;
@@ -1,6 +1,6 @@
1
1
  import { AbstractMethod } from '../core/AbstractMethod';
2
2
  import { PROTO } from '../constants';
3
- import type { BitcoinNetworkInfo, AccountAddresses, AccountUtxo } from '../types';
3
+ import type { BitcoinNetworkInfo, AccountAddresses } from '../types';
4
4
  import type { RefTransaction, TransactionOptions } from '../types/api/bitcoin';
5
5
  type Params = {
6
6
  inputs: PROTO.TxInputType[];
@@ -9,7 +9,6 @@ type Params = {
9
9
  coinjoinRequest?: PROTO.CoinJoinRequest;
10
10
  refTxs?: RefTransaction[];
11
11
  addresses?: AccountAddresses;
12
- utxo?: AccountUtxo[];
13
12
  options: TransactionOptions;
14
13
  coinInfo: BitcoinNetworkInfo;
15
14
  push: boolean;
@@ -66,7 +66,6 @@ class SignTransaction extends AbstractMethod_1.AbstractMethod {
66
66
  paymentRequests: payload.paymentRequests || [],
67
67
  refTxs,
68
68
  addresses: payload.account ? payload.account.addresses : undefined,
69
- utxo: payload.account ? payload.account.utxo : undefined,
70
69
  options: {
71
70
  lock_time: payload.locktime,
72
71
  timestamp: payload.timestamp,
@@ -154,9 +153,8 @@ class SignTransaction extends AbstractMethod_1.AbstractMethod {
154
153
  response.witnesses = bitcoinTx.ins.map((_, i) => { var _a; return (_a = bitcoinTx === null || bitcoinTx === void 0 ? void 0 : bitcoinTx.getWitness(i)) === null || _a === void 0 ? void 0 : _a.toString('hex'); });
155
154
  }
156
155
  }
157
- if (bitcoinTx && params.addresses && params.utxo) {
156
+ if (bitcoinTx && params.addresses) {
158
157
  response.signedTransaction = (0, bitcoin_1.createPendingTransaction)(bitcoinTx, {
159
- utxo: params.utxo,
160
158
  addresses: params.addresses,
161
159
  inputs: params.inputs,
162
160
  outputs: params.outputs,
package/lib/core/index.js CHANGED
@@ -127,6 +127,9 @@ const initDevice = async (method) => {
127
127
  if (showDeviceSelection) {
128
128
  createUiPromise(events_2.UI.RECEIVE_DEVICE);
129
129
  await getPopupPromise().promise;
130
+ if (!_deviceList) {
131
+ throw constants_1.ERRORS.TypedError('Transport_Missing');
132
+ }
130
133
  const devices = _deviceList.asArray();
131
134
  if (devices.length === 1 && devices[0].type !== 'unreadable' && !isWebUsb) {
132
135
  device = _deviceList.getDevice(devices[0].path);
@@ -660,7 +663,7 @@ const disableWebUSBTransport = async () => {
660
663
  return;
661
664
  const settings = DataManager_1.DataManager.getSettings();
662
665
  if ((_a = settings.transports) === null || _a === void 0 ? void 0 : _a.includes('WebUsbTransport')) {
663
- settings.transports.splice(settings.transports.indexOf('WebUsbTransport'));
666
+ settings.transports.splice(settings.transports.indexOf('WebUsbTransport'), 1);
664
667
  }
665
668
  if (!((_b = settings.transports) === null || _b === void 0 ? void 0 : _b.includes('BridgeTransport'))) {
666
669
  settings.transports.unshift('BridgeTransport');
@@ -1,3 +1,3 @@
1
- export declare const VERSION = "9.0.8";
1
+ export declare const VERSION = "9.0.9";
2
2
  export declare const DEFAULT_DOMAIN: string;
3
3
  //# sourceMappingURL=version.d.ts.map
@@ -1,7 +1,7 @@
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.0.8';
4
+ exports.VERSION = '9.0.9';
5
5
  const versionN = exports.VERSION.split('.').map(s => parseInt(s, 10));
6
6
  exports.DEFAULT_DOMAIN = `https://connect.trezor.io/${versionN[0]}/`;
7
7
  //# sourceMappingURL=version.js.map
@@ -1,7 +1,6 @@
1
1
  import type { PROTO } from '../../../constants';
2
2
  import type { AccountAddresses } from '@trezor/blockchain-link';
3
3
  import type { Transaction as BlockbookTransaction } from '@trezor/blockchain-link-types/lib/blockbook';
4
- import { AccountUtxo } from '../../account';
5
4
  export interface SignMessage {
6
5
  path: string | number[];
7
6
  coin: string;
@@ -56,7 +55,6 @@ export interface SignTransaction {
56
55
  refTxs?: RefTransaction[];
57
56
  account?: {
58
57
  addresses: AccountAddresses;
59
- utxo: AccountUtxo[];
60
58
  };
61
59
  coin: string;
62
60
  locktime?: number;
@@ -1,5 +1,6 @@
1
1
  import type { BlockchainSettings } from '@trezor/blockchain-link';
2
2
  import type { Transport } from '@trezor/transport';
3
+ export type { SystemInfo } from '@trezor/connect-common';
3
4
  export interface Manifest {
4
5
  appUrl: string;
5
6
  email: string;
@@ -31,14 +32,4 @@ export interface ConnectSettings {
31
32
  timestamp: number;
32
33
  proxy?: Proxy;
33
34
  }
34
- export interface SystemInfo {
35
- os: {
36
- family?: 'Linux' | 'MacOS' | 'Windows';
37
- mobile: boolean;
38
- };
39
- browser: {
40
- supported: boolean;
41
- outdated: boolean;
42
- };
43
- }
44
35
  //# sourceMappingURL=settings.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trezor/connect",
3
- "version": "9.0.8",
3
+ "version": "9.0.9",
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.",
@@ -49,10 +49,10 @@
49
49
  "prepublish": "yarn tsx ../../scripts/prepublish.js"
50
50
  },
51
51
  "dependencies": {
52
- "@trezor/blockchain-link": "2.1.10",
52
+ "@trezor/blockchain-link": "2.1.11",
53
53
  "@trezor/connect-analytics": "1.0.0",
54
- "@trezor/connect-common": "0.0.13",
55
- "@trezor/transport": "1.1.9",
54
+ "@trezor/connect-common": "0.0.14",
55
+ "@trezor/transport": "1.1.10",
56
56
  "@trezor/utils": "9.0.7",
57
57
  "@trezor/utxo-lib": "1.0.5",
58
58
  "bignumber.js": "^9.1.1",