@trezor/connect 9.0.11 → 9.1.2

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 (171) hide show
  1. package/CHANGELOG.md +22 -3
  2. package/README.md +20 -3
  3. package/lib/api/backupDevice.d.ts +1 -1
  4. package/lib/api/binanceGetAddress.d.ts +1 -0
  5. package/lib/api/binanceGetAddress.js +4 -4
  6. package/lib/api/binanceGetPublicKey.d.ts +1 -0
  7. package/lib/api/binanceGetPublicKey.js +3 -1
  8. package/lib/api/binanceSignTransaction.d.ts +2 -1
  9. package/lib/api/binanceSignTransaction.js +3 -1
  10. package/lib/api/bitcoin/Fees.d.ts +2 -2
  11. package/lib/api/bitcoin/Fees.js +32 -90
  12. package/lib/api/bitcoin/TransactionComposer.d.ts +1 -2
  13. package/lib/api/bitcoin/TransactionComposer.js +3 -2
  14. package/lib/api/bitcoin/createPendingTx.d.ts +1 -0
  15. package/lib/api/bitcoin/createPendingTx.js +1 -0
  16. package/lib/api/bitcoin/refTx.d.ts +10 -2
  17. package/lib/api/bitcoin/refTx.js +46 -19
  18. package/lib/api/blockchainDisconnect.d.ts +1 -0
  19. package/lib/api/blockchainDisconnect.js +3 -1
  20. package/lib/api/blockchainEstimateFee.js +1 -1
  21. package/lib/api/blockchainSetCustomBackend.d.ts +1 -0
  22. package/lib/api/blockchainSetCustomBackend.js +3 -1
  23. package/lib/api/cancelCoinjoinAuthorization.d.ts +8 -0
  24. package/lib/api/cancelCoinjoinAuthorization.js +27 -0
  25. package/lib/api/cardanoGetAddress.d.ts +1 -0
  26. package/lib/api/cardanoGetAddress.js +4 -4
  27. package/lib/api/cardanoGetNativeScriptHash.d.ts +1 -0
  28. package/lib/api/cardanoGetNativeScriptHash.js +3 -1
  29. package/lib/api/cardanoGetPublicKey.d.ts +2 -0
  30. package/lib/api/cardanoGetPublicKey.js +12 -1
  31. package/lib/api/cardanoSignTransaction.d.ts +1 -0
  32. package/lib/api/cardanoSignTransaction.js +3 -1
  33. package/lib/api/checkFirmwareAuthenticity.js +2 -1
  34. package/lib/api/cipherKeyValue.d.ts +1 -0
  35. package/lib/api/cipherKeyValue.js +5 -2
  36. package/lib/api/composeTransaction.d.ts +3 -0
  37. package/lib/api/composeTransaction.js +9 -7
  38. package/lib/api/eosGetPublicKey.d.ts +1 -0
  39. package/lib/api/eosGetPublicKey.js +3 -1
  40. package/lib/api/eosSignTransaction.d.ts +1 -0
  41. package/lib/api/eosSignTransaction.js +3 -1
  42. package/lib/api/ethereum/ethereumDefinitions.d.ts +28 -6
  43. package/lib/api/ethereum/ethereumDefinitions.js +60 -1
  44. package/lib/api/ethereum/ethereumSignTx.d.ts +1 -1
  45. package/lib/api/ethereumGetAddress.d.ts +2 -0
  46. package/lib/api/ethereumGetAddress.js +28 -26
  47. package/lib/api/ethereumGetPublicKey.d.ts +1 -0
  48. package/lib/api/ethereumGetPublicKey.js +8 -10
  49. package/lib/api/ethereumSignMessage.d.ts +10 -1
  50. package/lib/api/ethereumSignMessage.js +14 -13
  51. package/lib/api/ethereumSignTransaction.d.ts +6 -0
  52. package/lib/api/ethereumSignTransaction.js +18 -5
  53. package/lib/api/ethereumSignTypedData.d.ts +6 -0
  54. package/lib/api/ethereumSignTypedData.js +15 -13
  55. package/lib/api/ethereumVerifyMessage.d.ts +1 -0
  56. package/lib/api/ethereumVerifyMessage.js +3 -1
  57. package/lib/api/getAccountInfo.d.ts +3 -0
  58. package/lib/api/getAccountInfo.js +3 -1
  59. package/lib/api/getAddress.d.ts +1 -0
  60. package/lib/api/getAddress.js +8 -10
  61. package/lib/api/getFeatures.d.ts +1 -1
  62. package/lib/api/getOwnershipId.d.ts +1 -0
  63. package/lib/api/getOwnershipId.js +3 -1
  64. package/lib/api/getOwnershipProof.d.ts +1 -0
  65. package/lib/api/getOwnershipProof.js +3 -1
  66. package/lib/api/getPublicKey.d.ts +2 -0
  67. package/lib/api/getPublicKey.js +12 -1
  68. package/lib/api/index.d.ts +2 -0
  69. package/lib/api/index.js +6 -2
  70. package/lib/api/nemGetAddress.d.ts +1 -0
  71. package/lib/api/nemGetAddress.js +4 -4
  72. package/lib/api/nemSignTransaction.d.ts +1 -0
  73. package/lib/api/nemSignTransaction.js +3 -1
  74. package/lib/api/rebootToBootloader.d.ts +2 -1
  75. package/lib/api/rebootToBootloader.js +4 -2
  76. package/lib/api/requestLogin.d.ts +1 -0
  77. package/lib/api/requestLogin.js +3 -1
  78. package/lib/api/resetDevice.d.ts +1 -0
  79. package/lib/api/resetDevice.js +3 -1
  80. package/lib/api/rippleGetAddress.d.ts +1 -0
  81. package/lib/api/rippleGetAddress.js +4 -4
  82. package/lib/api/rippleSignTransaction.d.ts +1 -0
  83. package/lib/api/rippleSignTransaction.js +3 -1
  84. package/lib/api/showDeviceTutorial.d.ts +8 -0
  85. package/lib/api/showDeviceTutorial.js +23 -0
  86. package/lib/api/signMessage.d.ts +1 -0
  87. package/lib/api/signMessage.js +5 -1
  88. package/lib/api/signTransaction.d.ts +1 -0
  89. package/lib/api/signTransaction.js +16 -4
  90. package/lib/api/stellarGetAddress.d.ts +1 -0
  91. package/lib/api/stellarGetAddress.js +4 -4
  92. package/lib/api/stellarSignTransaction.d.ts +1 -0
  93. package/lib/api/stellarSignTransaction.js +3 -1
  94. package/lib/api/tezosGetAddress.d.ts +1 -0
  95. package/lib/api/tezosGetAddress.js +4 -4
  96. package/lib/api/tezosGetPublicKey.d.ts +1 -0
  97. package/lib/api/tezosGetPublicKey.js +3 -1
  98. package/lib/api/tezosSignTransaction.d.ts +1 -0
  99. package/lib/api/tezosSignTransaction.js +3 -1
  100. package/lib/api/verifyMessage.d.ts +1 -0
  101. package/lib/api/verifyMessage.js +7 -2
  102. package/lib/api/wipeDevice.d.ts +2 -1
  103. package/lib/api/wipeDevice.js +3 -1
  104. package/lib/backend/Blockchain.d.ts +1 -3
  105. package/lib/backend/Blockchain.js +10 -6
  106. package/lib/constants/errors.d.ts +0 -3
  107. package/lib/constants/errors.js +1 -4
  108. package/lib/constants/index.d.ts +1 -1
  109. package/lib/constants/index.js +1 -1
  110. package/lib/core/AbstractMethod.d.ts +3 -1
  111. package/lib/core/AbstractMethod.js +3 -1
  112. package/lib/core/index.d.ts +5 -6
  113. package/lib/core/index.js +53 -51
  114. package/lib/core/method.d.ts +1 -1
  115. package/lib/data/DataManager.js +4 -1
  116. package/lib/data/analyticsInfo.js +1 -1
  117. package/lib/data/coinInfo.d.ts +9 -1
  118. package/lib/data/coinInfo.js +16 -54
  119. package/lib/data/config.js +12 -2
  120. package/lib/data/defaultFeeLevels.d.ts +17 -0
  121. package/lib/data/defaultFeeLevels.js +84 -0
  122. package/lib/data/version.d.ts +1 -1
  123. package/lib/data/version.js +1 -1
  124. package/lib/device/Device.d.ts +10 -12
  125. package/lib/device/Device.js +69 -102
  126. package/lib/device/DeviceCommands.d.ts +4 -3
  127. package/lib/device/DeviceCommands.js +46 -19
  128. package/lib/device/DeviceList.d.ts +15 -25
  129. package/lib/device/DeviceList.js +224 -258
  130. package/lib/events/popup.d.ts +8 -1
  131. package/lib/events/popup.js +1 -0
  132. package/lib/events/transport.d.ts +2 -9
  133. package/lib/events/transport.js +3 -10
  134. package/lib/events/ui-request.d.ts +2 -2
  135. package/lib/factory.js +2 -0
  136. package/lib/index.js +7 -7
  137. package/lib/types/account.d.ts +1 -20
  138. package/lib/types/api/bitcoin/index.d.ts +2 -0
  139. package/lib/types/api/blockchainEstimateFee.d.ts +2 -5
  140. package/lib/types/api/cancelCoinjoinAuthorization.d.ts +8 -0
  141. package/lib/types/api/cancelCoinjoinAuthorization.js +3 -0
  142. package/lib/types/api/index.d.ts +4 -0
  143. package/lib/types/api/showDeviceTutorial.d.ts +4 -0
  144. package/lib/types/api/showDeviceTutorial.js +3 -0
  145. package/lib/types/coinInfo.d.ts +5 -17
  146. package/lib/types/device.d.ts +5 -2
  147. package/lib/types/device.js +8 -0
  148. package/lib/types/fees.d.ts +26 -0
  149. package/lib/types/fees.js +3 -0
  150. package/lib/types/index.d.ts +2 -1
  151. package/lib/types/index.js +1 -0
  152. package/lib/types/settings.d.ts +1 -1
  153. package/lib/utils/assetUtils.js +3 -1
  154. package/lib/utils/debug.js +2 -1
  155. package/lib/utils/deviceFeaturesUtils.d.ts +2 -1
  156. package/lib/utils/deviceFeaturesUtils.js +12 -1
  157. package/lib/utils/urlUtils.d.ts +10 -3
  158. package/lib/utils/urlUtils.js +5 -9
  159. package/lib/workers/workers-browser.d.ts +1 -3
  160. package/lib/workers/workers-browser.js +1 -7
  161. package/lib/workers/workers-react-native.d.ts +1 -3
  162. package/lib/workers/workers-react-native.js +1 -7
  163. package/lib/workers/workers.d.ts +1 -5
  164. package/lib/workers/workers.js +1 -5
  165. package/package.json +17 -12
  166. package/lib/device/DescriptorStream.d.ts +0 -28
  167. package/lib/device/DescriptorStream.js +0 -139
  168. package/lib/utils/objectUtils.d.ts +0 -10
  169. package/lib/utils/objectUtils.js +0 -37
  170. package/lib/workers/RNUsbPlugin.d.ts +0 -31
  171. package/lib/workers/RNUsbPlugin.js +0 -65
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const AbstractMethod_1 = require("../core/AbstractMethod");
4
+ const paramsValidator_1 = require("./common/paramsValidator");
5
+ const events_1 = require("../events");
6
+ class ShowDeviceTutorial extends AbstractMethod_1.AbstractMethod {
7
+ init() {
8
+ this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, null, this.firmwareRange);
9
+ this.useEmptyPassphrase = true;
10
+ this.useDeviceState = false;
11
+ this.allowDeviceMode = [events_1.UI.INITIALIZE];
12
+ }
13
+ get info() {
14
+ return 'Show device tutorial';
15
+ }
16
+ async run() {
17
+ const cmd = this.device.getCommands();
18
+ const response = await cmd.typedCall('ShowDeviceTutorial', 'Success');
19
+ return response.message;
20
+ }
21
+ }
22
+ exports.default = ShowDeviceTutorial;
23
+ //# sourceMappingURL=showDeviceTutorial.js.map
@@ -2,6 +2,7 @@ import { AbstractMethod } from '../core/AbstractMethod';
2
2
  import type { PROTO } from '../constants';
3
3
  export default class SignMessage extends AbstractMethod<'signMessage', PROTO.SignMessage> {
4
4
  init(): void;
5
+ get info(): string;
5
6
  run(): Promise<PROTO.MessageSignature>;
6
7
  }
7
8
  //# sourceMappingURL=signMessage.d.ts.map
@@ -25,7 +25,6 @@ class SignMessage extends AbstractMethod_1.AbstractMethod {
25
25
  else {
26
26
  coinInfo = (0, coinInfo_1.getBitcoinNetwork)(path);
27
27
  }
28
- this.info = (0, pathUtils_1.getLabel)('Sign #NETWORK message', coinInfo);
29
28
  this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(payload.no_script_type ? 'signMessageNoScriptType' : this.name, coinInfo, this.firmwareRange);
30
29
  const messageHex = payload.hex
31
30
  ? (0, formatUtils_1.messageToHex)(payload.message)
@@ -39,6 +38,11 @@ class SignMessage extends AbstractMethod_1.AbstractMethod {
39
38
  no_script_type: payload.no_script_type,
40
39
  };
41
40
  }
41
+ get info() {
42
+ var _a;
43
+ const coinInfo = (0, coinInfo_1.getBitcoinNetwork)((_a = this.payload.coin) !== null && _a !== void 0 ? _a : this.params.address_n);
44
+ return (0, pathUtils_1.getLabel)('Sign #NETWORK message', coinInfo);
45
+ }
42
46
  async run() {
43
47
  const cmd = this.device.getCommands();
44
48
  const { message } = await cmd.typedCall('SignMessage', 'MessageSignature', this.params);
@@ -16,6 +16,7 @@ type Params = {
16
16
  };
17
17
  export default class SignTransaction extends AbstractMethod<'signTransaction', Params> {
18
18
  init(): void;
19
+ get info(): string;
19
20
  private fetchAddresses;
20
21
  private fetchRefTxs;
21
22
  run(): Promise<import("../types").SignedTransaction>;
@@ -11,8 +11,8 @@ const BlockchainLink_1 = require("../backend/BlockchainLink");
11
11
  const bitcoin_1 = require("./bitcoin");
12
12
  class SignTransaction extends AbstractMethod_1.AbstractMethod {
13
13
  init() {
14
+ var _a, _b, _c;
14
15
  this.requiredPermissions = ['read', 'write'];
15
- this.info = 'Sign transaction';
16
16
  const { payload } = this;
17
17
  (0, paramsValidator_1.validateParams)(payload, [
18
18
  { name: 'coin', type: 'string', required: true },
@@ -48,15 +48,23 @@ class SignTransaction extends AbstractMethod_1.AbstractMethod {
48
48
  }
49
49
  this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, coinInfo, this.firmwareRange);
50
50
  this.preauthorized = payload.preauthorized;
51
- this.info = (0, pathUtils_1.getLabel)('Sign #NETWORK transaction', coinInfo);
52
51
  const inputs = (0, bitcoin_1.validateTrezorInputs)(payload.inputs, coinInfo);
53
52
  const outputs = (0, bitcoin_1.validateTrezorOutputs)(payload.outputs, coinInfo);
54
- const refTxs = (0, bitcoin_1.validateReferencedTransactions)(payload.refTxs, inputs, outputs);
53
+ if (payload.refTxs && ((_a = payload.account) === null || _a === void 0 ? void 0 : _a.transactions)) {
54
+ console.warn('two sources of referential transactions were passed. payload.refTxs have precedence');
55
+ }
56
+ const refTxs = (0, bitcoin_1.validateReferencedTransactions)({
57
+ transactions: payload.refTxs || ((_b = payload.account) === null || _b === void 0 ? void 0 : _b.transactions),
58
+ inputs,
59
+ outputs,
60
+ coinInfo,
61
+ addresses: (_c = payload.account) === null || _c === void 0 ? void 0 : _c.addresses,
62
+ });
55
63
  const outputsWithAmount = outputs.filter(output => typeof output.amount === 'string' &&
56
64
  !Object.prototype.hasOwnProperty.call(output, 'op_return_data'));
57
65
  if (outputsWithAmount.length > 0) {
58
66
  const total = outputsWithAmount.reduce((bn, output) => bn.plus(typeof output.amount === 'string' ? output.amount : '0'), new bignumber_js_1.default(0));
59
- if (total.lte(coinInfo.dustLimit)) {
67
+ if (total.lt(coinInfo.dustLimit)) {
60
68
  throw constants_1.ERRORS.TypedError('Method_InvalidParameter', 'Total amount is below dust limit.');
61
69
  }
62
70
  }
@@ -85,6 +93,10 @@ class SignTransaction extends AbstractMethod_1.AbstractMethod {
85
93
  };
86
94
  this.params.options = (0, bitcoin_1.enhanceSignTx)(this.params.options, coinInfo);
87
95
  }
96
+ get info() {
97
+ const coinInfo = (0, coinInfo_1.getBitcoinNetwork)(this.payload.coin);
98
+ return (0, pathUtils_1.getLabel)('Sign #NETWORK transaction', coinInfo);
99
+ }
88
100
  async fetchAddresses(blockchain) {
89
101
  const { device, params: { inputs, coinInfo }, } = this;
90
102
  const accountPath = inputs.find(i => i.address_n);
@@ -8,6 +8,7 @@ export default class StellarGetAddress extends AbstractMethod<'stellarGetAddress
8
8
  progress: number;
9
9
  confirmed?: boolean;
10
10
  init(): void;
11
+ get info(): string;
11
12
  getButtonRequestData(code: string): {
12
13
  type: "address";
13
14
  serializedPath: string;
@@ -41,12 +41,12 @@ class StellarGetAddress extends AbstractMethod_1.AbstractMethod {
41
41
  this.params[0].show_display;
42
42
  this.confirmed = useEventListener;
43
43
  this.useUi = !useEventListener;
44
+ }
45
+ get info() {
44
46
  if (this.params.length === 1) {
45
- this.info = `Export Stellar address for account #${(0, pathUtils_1.fromHardened)(this.params[0].address_n[2]) + 1}`;
46
- }
47
- else {
48
- this.info = 'Export multiple Stellar addresses';
47
+ return `Export Stellar address for account #${(0, pathUtils_1.fromHardened)(this.params[0].address_n[2]) + 1}`;
49
48
  }
49
+ return 'Export multiple Stellar addresses';
50
50
  }
51
51
  getButtonRequestData(code) {
52
52
  if (code === 'ButtonRequest_Address') {
@@ -11,6 +11,7 @@ declare const StellarSignTransactionFeatures: Readonly<{
11
11
  }>;
12
12
  export default class StellarSignTransaction extends AbstractMethod<'stellarSignTransaction', Params> {
13
13
  init(): void;
14
+ get info(): string;
14
15
  _isFeatureSupported(feature: keyof typeof StellarSignTransactionFeatures): boolean;
15
16
  _ensureFeatureIsSupported(feature: keyof typeof StellarSignTransactionFeatures): void;
16
17
  _ensureFirmwareSupportsParams(): void;
@@ -15,7 +15,6 @@ class StellarSignTransaction extends AbstractMethod_1.AbstractMethod {
15
15
  init() {
16
16
  this.requiredPermissions = ['read', 'write'];
17
17
  this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, (0, coinInfo_1.getMiscNetwork)('Stellar'), this.firmwareRange);
18
- this.info = 'Sign Stellar transaction';
19
18
  const { payload } = this;
20
19
  (0, paramsValidator_1.validateParams)(payload, [
21
20
  { name: 'path', required: true },
@@ -30,6 +29,9 @@ class StellarSignTransaction extends AbstractMethod_1.AbstractMethod {
30
29
  transaction,
31
30
  };
32
31
  }
32
+ get info() {
33
+ return 'Sign Stellar transaction';
34
+ }
33
35
  _isFeatureSupported(feature) {
34
36
  return this.device.atLeast(StellarSignTransactionFeatures[feature]);
35
37
  }
@@ -8,6 +8,7 @@ export default class TezosGetAddress extends AbstractMethod<'tezosGetAddress', P
8
8
  progress: number;
9
9
  confirmed?: boolean;
10
10
  init(): void;
11
+ get info(): string;
11
12
  getButtonRequestData(code: string): {
12
13
  type: "address";
13
14
  serializedPath: string;
@@ -41,12 +41,12 @@ class TezosGetAddress extends AbstractMethod_1.AbstractMethod {
41
41
  this.params[0].show_display;
42
42
  this.confirmed = useEventListener;
43
43
  this.useUi = !useEventListener;
44
+ }
45
+ get info() {
44
46
  if (this.params.length === 1) {
45
- this.info = `Export Tezos address for account #${(0, pathUtils_1.fromHardened)(this.params[0].address_n[2]) + 1}`;
46
- }
47
- else {
48
- this.info = 'Export multiple Tezos addresses';
47
+ return `Export Tezos address for account #${(0, pathUtils_1.fromHardened)(this.params[0].address_n[2]) + 1}`;
49
48
  }
49
+ return 'Export multiple Tezos addresses';
50
50
  }
51
51
  getButtonRequestData(code) {
52
52
  if (code === 'ButtonRequest_Address') {
@@ -4,6 +4,7 @@ export default class TezosGetPublicKey extends AbstractMethod<'tezosGetPublicKey
4
4
  hasBundle?: boolean;
5
5
  confirmed?: boolean;
6
6
  init(): void;
7
+ get info(): string;
7
8
  confirmation(): Promise<boolean>;
8
9
  run(): Promise<import("..").PublicKey | import("..").PublicKey[]>;
9
10
  }
@@ -9,7 +9,6 @@ class TezosGetPublicKey extends AbstractMethod_1.AbstractMethod {
9
9
  init() {
10
10
  this.requiredPermissions = ['read'];
11
11
  this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, (0, coinInfo_1.getMiscNetwork)('Tezos'), this.firmwareRange);
12
- this.info = 'Export Tezos public key';
13
12
  this.hasBundle = !!this.payload.bundle;
14
13
  const payload = !this.payload.bundle
15
14
  ? { ...this.payload, bundle: [this.payload] }
@@ -27,6 +26,9 @@ class TezosGetPublicKey extends AbstractMethod_1.AbstractMethod {
27
26
  };
28
27
  });
29
28
  }
29
+ get info() {
30
+ return 'Export Tezos public key';
31
+ }
30
32
  async confirmation() {
31
33
  if (this.confirmed)
32
34
  return true;
@@ -2,6 +2,7 @@ import { AbstractMethod } from '../core/AbstractMethod';
2
2
  import type { PROTO } from '../constants';
3
3
  export default class TezosSignTransaction extends AbstractMethod<'tezosSignTransaction', PROTO.TezosSignTx> {
4
4
  init(): void;
5
+ get info(): string;
5
6
  run(): Promise<PROTO.TezosSignedTx>;
6
7
  }
7
8
  //# sourceMappingURL=tezosSignTransaction.d.ts.map
@@ -10,7 +10,6 @@ class TezosSignTransaction extends AbstractMethod_1.AbstractMethod {
10
10
  init() {
11
11
  this.requiredPermissions = ['read', 'write'];
12
12
  this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, (0, coinInfo_1.getMiscNetwork)('Tezos'), this.firmwareRange);
13
- this.info = 'Sign Tezos transaction';
14
13
  const { payload } = this;
15
14
  (0, paramsValidator_1.validateParams)(payload, [
16
15
  { name: 'path', required: true },
@@ -20,6 +19,9 @@ class TezosSignTransaction extends AbstractMethod_1.AbstractMethod {
20
19
  const path = (0, pathUtils_1.validatePath)(payload.path, 3);
21
20
  this.params = helper.createTx(path, payload.branch, payload.operation);
22
21
  }
22
+ get info() {
23
+ return 'Sign Tezos transaction';
24
+ }
23
25
  async run() {
24
26
  const cmd = this.device.getCommands();
25
27
  const response = await cmd.typedCall('TezosSignTx', 'TezosSignedTx', this.params);
@@ -2,6 +2,7 @@ import { AbstractMethod } from '../core/AbstractMethod';
2
2
  import { PROTO } from '../constants';
3
3
  export default class VerifyMessage extends AbstractMethod<'verifyMessage', PROTO.VerifyMessage> {
4
4
  init(): void;
5
+ get info(): string;
5
6
  run(): Promise<PROTO.Success>;
6
7
  }
7
8
  //# sourceMappingURL=verifyMessage.d.ts.map
@@ -9,7 +9,6 @@ const constants_1 = require("../constants");
9
9
  class VerifyMessage extends AbstractMethod_1.AbstractMethod {
10
10
  init() {
11
11
  this.requiredPermissions = ['read', 'write'];
12
- this.info = 'Verify message';
13
12
  const { payload } = this;
14
13
  (0, paramsValidator_1.validateParams)(payload, [
15
14
  { name: 'address', type: 'string', required: true },
@@ -24,7 +23,6 @@ class VerifyMessage extends AbstractMethod_1.AbstractMethod {
24
23
  }
25
24
  else {
26
25
  this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, coinInfo, this.firmwareRange);
27
- this.info = (0, pathUtils_1.getLabel)('Verify #NETWORK message', coinInfo);
28
26
  }
29
27
  const messageHex = payload.hex
30
28
  ? (0, formatUtils_1.messageToHex)(payload.message)
@@ -37,6 +35,13 @@ class VerifyMessage extends AbstractMethod_1.AbstractMethod {
37
35
  coin_name: coinInfo.name,
38
36
  };
39
37
  }
38
+ get info() {
39
+ const coinInfo = (0, coinInfo_1.getBitcoinNetwork)(this.payload.coin);
40
+ if (!coinInfo) {
41
+ return 'Verify message';
42
+ }
43
+ return (0, pathUtils_1.getLabel)('Verify #NETWORK message', coinInfo);
44
+ }
40
45
  async run() {
41
46
  const cmd = this.device.getCommands();
42
47
  const response = await cmd.typedCall('VerifyMessage', 'Success', this.params);
@@ -3,6 +3,7 @@ export default class WipeDevice extends AbstractMethod<'wipeDevice'> {
3
3
  confirmed?: boolean;
4
4
  init(): void;
5
5
  confirmation(): Promise<boolean>;
6
- run(): Promise<import("packages/transport/lib/types/messages").Success>;
6
+ get info(): string;
7
+ run(): Promise<import("packages/protobuf/lib/messages").Success>;
7
8
  }
8
9
  //# sourceMappingURL=wipeDevice.d.ts.map
@@ -9,7 +9,6 @@ class WipeDevice extends AbstractMethod_1.AbstractMethod {
9
9
  this.useDeviceState = false;
10
10
  this.requiredPermissions = ['management'];
11
11
  this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, null, this.firmwareRange);
12
- this.info = 'Wipe device';
13
12
  }
14
13
  async confirmation() {
15
14
  if (this.confirmed)
@@ -28,6 +27,9 @@ class WipeDevice extends AbstractMethod_1.AbstractMethod {
28
27
  this.confirmed = uiResp.payload;
29
28
  return this.confirmed;
30
29
  }
30
+ get info() {
31
+ return 'Wipe device';
32
+ }
31
33
  async run() {
32
34
  const cmd = this.device.getCommands();
33
35
  if (this.device.isBootloader()) {
@@ -44,9 +44,7 @@ export declare class Blockchain {
44
44
  getNetworkInfo(): Promise<ServerInfo>;
45
45
  getAccountInfo(request: BlockchainLinkParams<'getAccountInfo'>): Promise<import("@trezor/blockchain-link").AccountInfo>;
46
46
  getAccountUtxo(descriptor: string): Promise<import("@trezor/blockchain-link").Utxo[]>;
47
- estimateFee(request: {
48
- blocks?: number[];
49
- }): Promise<{
47
+ estimateFee(request: Parameters<typeof this.link.estimateFee>[0]): Promise<{
50
48
  feePerUnit: string;
51
49
  feePerTx?: string | undefined;
52
50
  feeLimit?: string | undefined;
@@ -108,17 +108,21 @@ class Blockchain {
108
108
  }
109
109
  async estimateFee(request) {
110
110
  const { blocks } = request;
111
- if (blocks) {
112
- const now = Date.now();
113
- const outdated = now - this.feeTimestamp > 20 * 60 * 1000;
114
- const unknownBlocks = blocks.filter(() => typeof this.feeForBlock !== 'string');
115
- if (!outdated && unknownBlocks.length < 1) {
111
+ const useCache = !request.specific && Array.isArray(blocks) && blocks.length > 0;
112
+ if (useCache) {
113
+ const outdated = Date.now() - this.feeTimestamp > 20 * 60 * 1000;
114
+ const unknownBlocks = outdated
115
+ ? blocks
116
+ : blocks.filter(block => !this.feeForBlock[block]);
117
+ if (unknownBlocks.length < 1) {
118
+ return blocks.map(block => this.feeForBlock[block]);
116
119
  }
120
+ this.feeForBlock = [];
117
121
  const fees = await this.link.estimateFee(request);
118
122
  blocks.forEach((block, index) => {
119
123
  this.feeForBlock[block] = fees[index];
120
124
  });
121
- this.feeTimestamp = now;
125
+ this.feeTimestamp = Date.now();
122
126
  return fees;
123
127
  }
124
128
  return this.link.estimateFee(request);
@@ -41,8 +41,5 @@ export declare class TrezorError extends Error {
41
41
  }
42
42
  export declare const TypedError: (id: keyof typeof ERROR_CODES, message?: string) => TrezorError;
43
43
  export declare const serializeError: (payload: any) => any;
44
- export declare const WRONG_PREVIOUS_SESSION_ERROR_MESSAGE = "wrong previous session";
45
- export declare const INVALID_PIN_ERROR_MESSAGE = "PIN invalid";
46
- export declare const WEBUSB_ERROR_MESSAGE = "NetworkError: Unable to claim interface.";
47
44
  export declare const LIBUSB_ERROR_MESSAGE = "LIBUSB_ERROR";
48
45
  //# sourceMappingURL=errors.d.ts.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LIBUSB_ERROR_MESSAGE = exports.WEBUSB_ERROR_MESSAGE = exports.INVALID_PIN_ERROR_MESSAGE = exports.WRONG_PREVIOUS_SESSION_ERROR_MESSAGE = exports.serializeError = exports.TypedError = exports.TrezorError = exports.ERROR_CODES = void 0;
3
+ exports.LIBUSB_ERROR_MESSAGE = exports.serializeError = exports.TypedError = exports.TrezorError = exports.ERROR_CODES = void 0;
4
4
  exports.ERROR_CODES = {
5
5
  Init_NotInitialized: 'TrezorConnect not initialized',
6
6
  Init_AlreadyInitialized: 'TrezorConnect has been already initialized',
@@ -54,8 +54,5 @@ const serializeError = (payload) => {
54
54
  return payload;
55
55
  };
56
56
  exports.serializeError = serializeError;
57
- exports.WRONG_PREVIOUS_SESSION_ERROR_MESSAGE = 'wrong previous session';
58
- exports.INVALID_PIN_ERROR_MESSAGE = 'PIN invalid';
59
- exports.WEBUSB_ERROR_MESSAGE = 'NetworkError: Unable to claim interface.';
60
57
  exports.LIBUSB_ERROR_MESSAGE = 'LIBUSB_ERROR';
61
58
  //# sourceMappingURL=errors.js.map
@@ -2,5 +2,5 @@ export * as ERRORS from './errors';
2
2
  export * as NETWORK from './network';
3
3
  export * as CARDANO from './cardano';
4
4
  export * as NEM from './nem';
5
- export * as PROTO from '@trezor/transport/lib/types/messages';
5
+ export * as PROTO from '@trezor/protobuf/lib/messages';
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -6,5 +6,5 @@ exports.ERRORS = tslib_1.__importStar(require("./errors"));
6
6
  exports.NETWORK = tslib_1.__importStar(require("./network"));
7
7
  exports.CARDANO = tslib_1.__importStar(require("./cardano"));
8
8
  exports.NEM = tslib_1.__importStar(require("./nem"));
9
- exports.PROTO = tslib_1.__importStar(require("@trezor/transport/lib/types/messages"));
9
+ exports.PROTO = tslib_1.__importStar(require("@trezor/protobuf/lib/messages"));
10
10
  //# sourceMappingURL=index.js.map
@@ -23,7 +23,7 @@ export declare abstract class AbstractMethod<Name extends CallMethodPayload['met
23
23
  overridden: boolean;
24
24
  name: Name;
25
25
  payload: Payload<Name>;
26
- info: string;
26
+ get info(): string;
27
27
  useUi: boolean;
28
28
  useDevice: boolean;
29
29
  useDeviceState: boolean;
@@ -43,6 +43,8 @@ export declare abstract class AbstractMethod<Name extends CallMethodPayload['met
43
43
  getPopupPromise: () => Deferred<void>;
44
44
  createUiPromise: <T extends UiPromiseResponse['type']>(promiseId: T, device?: Device) => UiPromise<T>;
45
45
  removeUiPromise: (promise: Deferred<any>) => void;
46
+ initAsync?(): Promise<void>;
47
+ initAsyncPromise?: Promise<void>;
46
48
  constructor(message: {
47
49
  id?: number;
48
50
  payload: Payload<Name>;
@@ -8,9 +8,11 @@ const events_1 = require("../events");
8
8
  const versionUtils_1 = require("../utils/versionUtils");
9
9
  const urlUtils_1 = require("../utils/urlUtils");
10
10
  class AbstractMethod {
11
+ get info() {
12
+ return '';
13
+ }
11
14
  constructor(message) {
12
15
  var _a, _b;
13
- this.info = '';
14
16
  const { payload } = message;
15
17
  this.name = payload.method;
16
18
  this.payload = payload;
@@ -2,15 +2,14 @@
2
2
  import EventEmitter from 'events';
3
3
  import { TransportInfo, CoreMessage } from '../events';
4
4
  import type { ConnectSettings } from '../types';
5
- export declare const handleMessage: (message: CoreMessage, isTrustedOrigin?: boolean) => void;
5
+ export declare const handleMessage: (message: CoreMessage) => void;
6
6
  export declare const onCall: (message: CoreMessage) => Promise<void>;
7
7
  export declare class Core extends EventEmitter {
8
- handleMessage(message: any, isTrustedOrigin: boolean): void;
8
+ handleMessage(message: any): void;
9
9
  dispose(): Promise<void>;
10
- getCurrentMethod(): (import("../api").applyFlags | import("../api").applySettings | import("../api").authorizeCoinjoin | import("../api").backupDevice | import("../api").binanceGetAddress | import("../api").binanceGetPublicKey | import("../api").binanceSignTransaction | import("../api").blockchainDisconnect | import("../api").blockchainEstimateFee | import("../api").blockchainGetAccountBalanceHistory | import("../api").blockchainGetCurrentFiatRates | import("../api").blockchainGetFiatRatesForTimestamps | import("../api").blockchainGetTransactions | import("../api").blockchainSetCustomBackend | import("../api").blockchainSubscribe | import("../api").blockchainSubscribeFiatRates | import("../api").blockchainUnsubscribe | import("../api").blockchainUnsubscribeFiatRates | import("../api").cardanoGetAddress | import("../api").cardanoGetNativeScriptHash | import("../api").cardanoGetPublicKey | import("../api").cardanoSignTransaction | import("../api").changePin | import("../api").cipherKeyValue | import("../api").composeTransaction | import("../api").eosGetPublicKey | import("../api").eosSignTransaction | import("../api").ethereumGetAddress | import("../api").ethereumGetPublicKey | import("../api").ethereumSignMessage | import("../api").ethereumSignTransaction | import("../api").ethereumSignTypedData | import("../api").ethereumVerifyMessage | import("../api").firmwareUpdate | import("../api").getAccountInfo | import("../api").getAddress | import("../api").getCoinInfo | import("../api").getDeviceState | import("../api").getFeatures | import("../api").getFirmwareHash | import("../api").getOwnershipId | import("../api").getOwnershipProof | import("../api").getPublicKey | import("../api").getSettings | import("../api").nemGetAddress | import("../api").nemSignTransaction | import("../api").pushTransaction | import("../api").rebootToBootloader | import("../api").recoveryDevice | import("../api").requestLogin | import("../api").resetDevice | import("../api").rippleGetAddress | import("../api").rippleSignTransaction | import("../api").setBusy | import("../api").setProxy | import("../api").signMessage | import("../api").signTransaction | import("../api").stellarGetAddress | import("../api").stellarSignTransaction | import("../api").tezosGetAddress | import("../api").tezosGetPublicKey | import("../api").tezosSignTransaction | import("../api").unlockPath | import("../api").verifyMessage | import("../api").wipeDevice | import("../api").checkFirmwareAuthenticity)[];
11
- getTransportInfo(): TransportInfo;
10
+ getCurrentMethod(): (import("../api").applyFlags | import("../api").applySettings | import("../api").authorizeCoinjoin | import("../api").cancelCoinjoinAuthorization | import("../api").showDeviceTutorial | import("../api").backupDevice | import("../api").binanceGetAddress | import("../api").binanceGetPublicKey | import("../api").binanceSignTransaction | import("../api").blockchainDisconnect | import("../api").blockchainEstimateFee | import("../api").blockchainGetAccountBalanceHistory | import("../api").blockchainGetCurrentFiatRates | import("../api").blockchainGetFiatRatesForTimestamps | import("../api").blockchainGetTransactions | import("../api").blockchainSetCustomBackend | import("../api").blockchainSubscribe | import("../api").blockchainSubscribeFiatRates | import("../api").blockchainUnsubscribe | import("../api").blockchainUnsubscribeFiatRates | import("../api").cardanoGetAddress | import("../api").cardanoGetNativeScriptHash | import("../api").cardanoGetPublicKey | import("../api").cardanoSignTransaction | import("../api").changePin | import("../api").cipherKeyValue | import("../api").composeTransaction | import("../api").eosGetPublicKey | import("../api").eosSignTransaction | import("../api").ethereumGetAddress | import("../api").ethereumGetPublicKey | import("../api").ethereumSignMessage | import("../api").ethereumSignTransaction | import("../api").ethereumSignTypedData | import("../api").ethereumVerifyMessage | import("../api").firmwareUpdate | import("../api").getAccountInfo | import("../api").getAddress | import("../api").getCoinInfo | import("../api").getDeviceState | import("../api").getFeatures | import("../api").getFirmwareHash | import("../api").getOwnershipId | import("../api").getOwnershipProof | import("../api").getPublicKey | import("../api").getSettings | import("../api").nemGetAddress | import("../api").nemSignTransaction | import("../api").pushTransaction | import("../api").rebootToBootloader | import("../api").recoveryDevice | import("../api").requestLogin | import("../api").resetDevice | import("../api").rippleGetAddress | import("../api").rippleSignTransaction | import("../api").setBusy | import("../api").setProxy | import("../api").signMessage | import("../api").signTransaction | import("../api").stellarGetAddress | import("../api").stellarSignTransaction | import("../api").tezosGetAddress | import("../api").tezosGetPublicKey | import("../api").tezosSignTransaction | import("../api").unlockPath | import("../api").verifyMessage | import("../api").wipeDevice | import("../api").checkFirmwareAuthenticity)[];
11
+ getTransportInfo(): TransportInfo | undefined;
12
12
  }
13
- export declare const initCore: () => Core;
14
- export declare const init: (settings: ConnectSettings) => Promise<Core>;
13
+ export declare const initCore: (settings: ConnectSettings) => Promise<Core>;
15
14
  export declare const initTransport: (settings: ConnectSettings) => Promise<void>;
16
15
  //# sourceMappingURL=index.d.ts.map