@trezor/connect 9.2.2 → 9.2.4-beta.1

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 (174) hide show
  1. package/CHANGELOG.md +102 -0
  2. package/README.md +1 -1
  3. package/lib/api/applyFlags.d.ts +8 -1
  4. package/lib/api/applyFlags.js +3 -8
  5. package/lib/api/applySettings.d.ts +8 -1
  6. package/lib/api/applySettings.js +3 -8
  7. package/lib/api/backupDevice.d.ts +10 -2
  8. package/lib/api/backupDevice.js +12 -9
  9. package/lib/api/binance/api/binanceGetAddress.d.ts +4 -3
  10. package/lib/api/binance/api/binanceGetAddress.js +8 -22
  11. package/lib/api/binance/api/binanceGetPublicKey.d.ts +4 -2
  12. package/lib/api/binance/api/binanceGetPublicKey.js +6 -18
  13. package/lib/api/blockchainDisconnect.d.ts +1 -0
  14. package/lib/api/blockchainDisconnect.js +3 -4
  15. package/lib/api/blockchainEstimateFee.d.ts +1 -0
  16. package/lib/api/blockchainEstimateFee.js +6 -4
  17. package/lib/api/blockchainGetAccountBalanceHistory.d.ts +1 -0
  18. package/lib/api/blockchainGetAccountBalanceHistory.js +3 -1
  19. package/lib/api/blockchainGetCurrentFiatRates.d.ts +1 -0
  20. package/lib/api/blockchainGetCurrentFiatRates.js +3 -1
  21. package/lib/api/blockchainGetFiatRatesForTimestamps.d.ts +1 -0
  22. package/lib/api/blockchainGetFiatRatesForTimestamps.js +3 -1
  23. package/lib/api/blockchainGetTransactions.d.ts +1 -0
  24. package/lib/api/blockchainGetTransactions.js +3 -1
  25. package/lib/api/blockchainSetCustomBackend.js +1 -5
  26. package/lib/api/blockchainSubscribe.d.ts +2 -0
  27. package/lib/api/blockchainSubscribe.js +13 -2
  28. package/lib/api/blockchainSubscribeFiatRates.d.ts +1 -0
  29. package/lib/api/blockchainSubscribeFiatRates.js +3 -1
  30. package/lib/api/blockchainUnsubscribe.d.ts +1 -0
  31. package/lib/api/blockchainUnsubscribe.js +5 -2
  32. package/lib/api/blockchainUnsubscribeFiatRates.d.ts +1 -0
  33. package/lib/api/blockchainUnsubscribeFiatRates.js +6 -2
  34. package/lib/api/cardano/api/cardanoGetAddress.d.ts +4 -3
  35. package/lib/api/cardano/api/cardanoGetAddress.js +8 -22
  36. package/lib/api/cardano/api/cardanoGetPublicKey.d.ts +4 -3
  37. package/lib/api/cardano/api/cardanoGetPublicKey.js +9 -31
  38. package/lib/api/changeLanguage.d.ts +8 -2
  39. package/lib/api/changeLanguage.js +10 -51
  40. package/lib/api/composeTransaction.d.ts +2 -0
  41. package/lib/api/composeTransaction.js +10 -5
  42. package/lib/api/eos/api/eosGetPublicKey.d.ts +4 -2
  43. package/lib/api/eos/api/eosGetPublicKey.js +6 -18
  44. package/lib/api/eos/eosSignTx.d.ts +3 -3
  45. package/lib/api/ethereum/api/ethereumGetAddress.d.ts +4 -3
  46. package/lib/api/ethereum/api/ethereumGetAddress.js +4 -20
  47. package/lib/api/ethereum/api/ethereumGetPublicKey.d.ts +4 -2
  48. package/lib/api/ethereum/api/ethereumGetPublicKey.js +3 -10
  49. package/lib/api/ethereum/api/ethereumSignTypedData.d.ts +2 -1
  50. package/lib/api/ethereum/ethereumDefinitions.js +1 -0
  51. package/lib/api/firmware/index.d.ts +2 -0
  52. package/lib/api/firmware/index.js +5 -1
  53. package/lib/api/firmware/parseFirmwareHeaders.d.ts +5 -0
  54. package/lib/api/firmware/parseFirmwareHeaders.js +35 -0
  55. package/lib/api/firmware/uploadFirmware.d.ts +1 -1
  56. package/lib/api/firmware/uploadFirmware.js +9 -1
  57. package/lib/api/getAccountDescriptor.d.ts +5 -3
  58. package/lib/api/getAccountDescriptor.js +8 -21
  59. package/lib/api/getAccountInfo.d.ts +23 -7
  60. package/lib/api/getAccountInfo.js +16 -28
  61. package/lib/api/getAddress.d.ts +4 -3
  62. package/lib/api/getAddress.js +8 -22
  63. package/lib/api/getCoinInfo.d.ts +3 -0
  64. package/lib/api/getFeatures.d.ts +1 -0
  65. package/lib/api/getOwnershipId.d.ts +4 -2
  66. package/lib/api/getOwnershipId.js +4 -15
  67. package/lib/api/getOwnershipProof.d.ts +4 -2
  68. package/lib/api/getOwnershipProof.js +4 -15
  69. package/lib/api/getPublicKey.d.ts +5 -4
  70. package/lib/api/getPublicKey.js +12 -35
  71. package/lib/api/index.d.ts +0 -1
  72. package/lib/api/index.js +1 -3
  73. package/lib/api/nem/api/nemGetAddress.d.ts +4 -3
  74. package/lib/api/nem/api/nemGetAddress.js +4 -20
  75. package/lib/api/pushTransaction.d.ts +1 -0
  76. package/lib/api/pushTransaction.js +2 -1
  77. package/lib/api/rebootToBootloader.d.ts +8 -2
  78. package/lib/api/rebootToBootloader.js +3 -10
  79. package/lib/api/recoveryDevice.d.ts +8 -1
  80. package/lib/api/recoveryDevice.js +3 -7
  81. package/lib/api/resetDevice.d.ts +5 -3
  82. package/lib/api/resetDevice.js +5 -12
  83. package/lib/api/ripple/api/rippleGetAddress.d.ts +4 -3
  84. package/lib/api/ripple/api/rippleGetAddress.js +4 -20
  85. package/lib/api/signTransaction.d.ts +1 -0
  86. package/lib/api/signTransaction.js +5 -3
  87. package/lib/api/solana/api/solanaGetAddress.d.ts +4 -3
  88. package/lib/api/solana/api/solanaGetAddress.js +7 -28
  89. package/lib/api/solana/api/solanaGetPublicKey.d.ts +4 -3
  90. package/lib/api/solana/api/solanaGetPublicKey.js +7 -27
  91. package/lib/api/stellar/api/stellarGetAddress.d.ts +4 -3
  92. package/lib/api/stellar/api/stellarGetAddress.js +4 -20
  93. package/lib/api/tezos/api/tezosGetAddress.d.ts +4 -3
  94. package/lib/api/tezos/api/tezosGetAddress.js +4 -20
  95. package/lib/api/tezos/api/tezosGetPublicKey.d.ts +4 -2
  96. package/lib/api/tezos/api/tezosGetPublicKey.js +6 -18
  97. package/lib/api/wipeDevice.d.ts +8 -2
  98. package/lib/api/wipeDevice.js +3 -10
  99. package/lib/backend/BackendManager.d.ts +6 -4
  100. package/lib/backend/BackendManager.js +36 -28
  101. package/lib/backend/Blockchain.d.ts +15 -4
  102. package/lib/backend/Blockchain.js +27 -17
  103. package/lib/backend/BlockchainLink.d.ts +3 -3
  104. package/lib/backend/BlockchainLink.js +3 -3
  105. package/lib/constants/errors.d.ts +1 -0
  106. package/lib/constants/errors.js +1 -0
  107. package/lib/core/AbstractMethod.d.ts +4 -8
  108. package/lib/core/AbstractMethod.js +7 -28
  109. package/lib/core/index.d.ts +2 -1
  110. package/lib/core/index.js +260 -231
  111. package/lib/core/onCallFirmwareUpdate.d.ts +31 -0
  112. package/lib/core/onCallFirmwareUpdate.js +259 -0
  113. package/lib/data/DataManager.d.ts +22 -0
  114. package/lib/data/DataManager.js +7 -3
  115. package/lib/data/analyticsInfo.d.ts +2 -2
  116. package/lib/data/analyticsInfo.js +6 -7
  117. package/lib/data/coinInfo.d.ts +14 -0
  118. package/lib/data/config.d.ts +22 -0
  119. package/lib/data/config.js +5 -1
  120. package/lib/data/connectSettings.js +3 -0
  121. package/lib/data/deviceAuthenticityConfig.d.ts +9 -0
  122. package/lib/data/deviceAuthenticityConfig.js +27 -3
  123. package/lib/data/firmwareInfo.js +2 -6
  124. package/lib/data/getLanguage.d.ts +6 -0
  125. package/lib/data/getLanguage.js +10 -0
  126. package/lib/data/models.d.ts +9 -0
  127. package/lib/data/models.js +9 -0
  128. package/lib/data/version.d.ts +1 -1
  129. package/lib/data/version.js +1 -1
  130. package/lib/device/Device.d.ts +13 -2
  131. package/lib/device/Device.js +55 -7
  132. package/lib/device/DeviceCommands.d.ts +3 -15
  133. package/lib/device/DeviceCommands.js +1 -43
  134. package/lib/device/DeviceList.d.ts +1 -1
  135. package/lib/device/DeviceList.js +22 -19
  136. package/lib/events/blockchain.d.ts +3 -0
  137. package/lib/events/index.d.ts +1 -0
  138. package/lib/events/ui-request.d.ts +13 -1
  139. package/lib/events/ui-request.js +1 -0
  140. package/lib/index.js +2 -2
  141. package/lib/types/api/authenticateDevice.d.ts +9 -0
  142. package/lib/types/api/backupDevice.d.ts +2 -2
  143. package/lib/types/api/bitcoin/index.d.ts +1 -0
  144. package/lib/types/api/blockchainSetCustomBackend.d.ts +3 -2
  145. package/lib/types/api/blockchainSubscribe.d.ts +1 -0
  146. package/lib/types/api/composeTransaction.d.ts +2 -0
  147. package/lib/types/api/dispose.d.ts +1 -1
  148. package/lib/types/api/firmwareUpdate.d.ts +7 -6
  149. package/lib/types/api/firmwareUpdate.js +1 -3
  150. package/lib/types/api/getAccountInfo.d.ts +1 -0
  151. package/lib/types/api/getCoinInfo.d.ts +4 -2
  152. package/lib/types/api/nemGetAddress.d.ts +11 -4
  153. package/lib/types/api/nemGetAddress.js +9 -0
  154. package/lib/types/api/pushTransaction.d.ts +1 -0
  155. package/lib/types/api/pushTransaction.js +1 -0
  156. package/lib/types/api/resetDevice.d.ts +1 -15
  157. package/lib/types/api/resetDevice.js +0 -9
  158. package/lib/types/api/setBusy.d.ts +2 -2
  159. package/lib/types/coinInfo.d.ts +15 -7
  160. package/lib/types/coinInfo.js +8 -6
  161. package/lib/types/firmware.d.ts +5 -15
  162. package/lib/types/params.d.ts +1 -0
  163. package/lib/types/params.js +1 -2
  164. package/lib/types/settings.d.ts +1 -0
  165. package/lib/utils/assetUtils.js +18 -8
  166. package/lib/utils/popupPromiseManager.d.ts +8 -0
  167. package/lib/utils/popupPromiseManager.js +21 -0
  168. package/lib/utils/uiPromiseManager.d.ts +38 -0
  169. package/lib/utils/uiPromiseManager.js +47 -0
  170. package/lib/workers/workers-browser.d.ts +3 -1
  171. package/lib/workers/workers-browser.js +2 -2
  172. package/package.json +10 -10
  173. package/lib/api/firmwareUpdate.d.ts +0 -19
  174. package/lib/api/firmwareUpdate.js +0 -78
@@ -57,10 +57,11 @@ declare const Params: import("@sinclair/typebox").TIntersect<[import("@sinclair/
57
57
  shortcut: import("@sinclair/typebox").TString;
58
58
  slip44: import("@sinclair/typebox").TNumber;
59
59
  support: import("@sinclair/typebox").TObject<{
60
- connect: import("@sinclair/typebox").TBoolean;
61
60
  T1B1: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TLiteral<false>]>;
62
61
  T2T1: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TLiteral<false>]>;
63
62
  T2B1: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TLiteral<false>]>;
63
+ T3T1: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TLiteral<false>]>;
64
+ connect: import("@sinclair/typebox").TBoolean;
64
65
  }>;
65
66
  decimals: import("@sinclair/typebox").TNumber;
66
67
  blockchainLink: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
@@ -102,6 +102,7 @@ const ethereumNetworkInfoFromDefinition = (definition) => ({
102
102
  T1B1: '1.6.2',
103
103
  T2T1: '2.0.7',
104
104
  T2B1: '2.6.1',
105
+ T3T1: '2.7.1',
105
106
  },
106
107
  blockchainLink: undefined,
107
108
  });
@@ -1,5 +1,7 @@
1
1
  export { getBinary } from './getBinary';
2
+ export { getLanguage } from '../../data/getLanguage';
2
3
  export { shouldStripFwHeaders, stripFwHeaders } from './modifyFirmware';
3
4
  export { uploadFirmware } from './uploadFirmware';
4
5
  export { calculateFirmwareHash } from './calculateFirmwareHash';
6
+ export { parseFirmwareHeaders } from './parseFirmwareHeaders';
5
7
  //# sourceMappingURL=index.d.ts.map
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.calculateFirmwareHash = exports.uploadFirmware = exports.stripFwHeaders = exports.shouldStripFwHeaders = exports.getBinary = void 0;
3
+ exports.parseFirmwareHeaders = exports.calculateFirmwareHash = exports.uploadFirmware = exports.stripFwHeaders = exports.shouldStripFwHeaders = exports.getLanguage = exports.getBinary = void 0;
4
4
  var getBinary_1 = require("./getBinary");
5
5
  Object.defineProperty(exports, "getBinary", { enumerable: true, get: function () { return getBinary_1.getBinary; } });
6
+ var getLanguage_1 = require("../../data/getLanguage");
7
+ Object.defineProperty(exports, "getLanguage", { enumerable: true, get: function () { return getLanguage_1.getLanguage; } });
6
8
  var modifyFirmware_1 = require("./modifyFirmware");
7
9
  Object.defineProperty(exports, "shouldStripFwHeaders", { enumerable: true, get: function () { return modifyFirmware_1.shouldStripFwHeaders; } });
8
10
  Object.defineProperty(exports, "stripFwHeaders", { enumerable: true, get: function () { return modifyFirmware_1.stripFwHeaders; } });
@@ -10,4 +12,6 @@ var uploadFirmware_1 = require("./uploadFirmware");
10
12
  Object.defineProperty(exports, "uploadFirmware", { enumerable: true, get: function () { return uploadFirmware_1.uploadFirmware; } });
11
13
  var calculateFirmwareHash_1 = require("./calculateFirmwareHash");
12
14
  Object.defineProperty(exports, "calculateFirmwareHash", { enumerable: true, get: function () { return calculateFirmwareHash_1.calculateFirmwareHash; } });
15
+ var parseFirmwareHeaders_1 = require("./parseFirmwareHeaders");
16
+ Object.defineProperty(exports, "parseFirmwareHeaders", { enumerable: true, get: function () { return parseFirmwareHeaders_1.parseFirmwareHeaders; } });
13
17
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,5 @@
1
+ /// <reference types="node" />
2
+ export declare const parseFirmwareHeaders: (buff: Buffer) => {
3
+ version: [number, number, number];
4
+ };
5
+ //# sourceMappingURL=parseFirmwareHeaders.d.ts.map
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseFirmwareHeaders = void 0;
4
+ const parseFirmwareHeaders = (buff) => {
5
+ const vendorHeader = buff.subarray(0, 4).toString('utf8');
6
+ let trezorImageHeader = '';
7
+ let restbuff;
8
+ if (vendorHeader === 'TRZV') {
9
+ const vendorHeaderLength = buff.readUInt32LE(4);
10
+ trezorImageHeader = buff
11
+ .subarray(vendorHeaderLength, vendorHeaderLength + 4)
12
+ .toString('utf8');
13
+ restbuff = buff.subarray(vendorHeaderLength + 4);
14
+ }
15
+ else if (vendorHeader === 'TRZR') {
16
+ restbuff = buff.subarray(256 + 4);
17
+ trezorImageHeader = buff.subarray(256, 256 + 4).toString('utf8');
18
+ }
19
+ else {
20
+ restbuff = buff.subarray(4);
21
+ trezorImageHeader = buff.subarray(0, 4).toString('utf8');
22
+ }
23
+ if (trezorImageHeader !== 'TRZF') {
24
+ throw new Error(`unexpected header ${vendorHeader}`);
25
+ }
26
+ const version_major = restbuff.readInt8(12);
27
+ const version_minor = restbuff.readInt8(13);
28
+ const version_patch = restbuff.readInt8(14);
29
+ const version = [version_major, version_minor, version_patch];
30
+ return {
31
+ version,
32
+ };
33
+ };
34
+ exports.parseFirmwareHeaders = parseFirmwareHeaders;
35
+ //# sourceMappingURL=parseFirmwareHeaders.js.map
@@ -2,7 +2,7 @@ import { CoreEventMessage } from '../../events';
2
2
  import { PROTO } from '../../constants';
3
3
  import type { Device } from '../../device/Device';
4
4
  import type { TypedCall } from '../../device/DeviceCommands';
5
- export declare const uploadFirmware: (typedCall: TypedCall, postMessage: (message: CoreEventMessage) => void, device: Device, { payload }: PROTO.FirmwareUpload) => Promise<{
5
+ export declare const uploadFirmware: (typedCall: TypedCall, postMessage: (message: CoreEventMessage) => void, device: Device, { payload }: PROTO.FirmwareUpload) => Promise<import("../../device/DeviceCommands").TypedResponseMessage<"Success"> | {
6
6
  message: string;
7
7
  }>;
8
8
  //# sourceMappingURL=uploadFirmware.d.ts.map
@@ -11,6 +11,7 @@ const postConfirmationMessage = (device) => {
11
11
  const postProgressMessage = (device, progress, postMessage) => {
12
12
  postMessage((0, events_1.createUiMessage)(events_1.UI.FIRMWARE_PROGRESS, {
13
13
  device: device.toMessageObject(),
14
+ operation: 'flashing',
14
15
  progress,
15
16
  }));
16
17
  };
@@ -19,8 +20,15 @@ const uploadFirmware = async (typedCall, postMessage, device, { payload }) => {
19
20
  postConfirmationMessage(device);
20
21
  await typedCall('FirmwareErase', 'Success', {});
21
22
  postProgressMessage(device, 0, postMessage);
22
- const { message } = await typedCall('FirmwareUpload', 'Success', {
23
+ let i = 0;
24
+ const progressTimer = setInterval(() => {
25
+ i++;
26
+ postProgressMessage(device, Math.min(i * 2, 99), postMessage);
27
+ }, 300);
28
+ const message = await typedCall('FirmwareUpload', 'Success', {
23
29
  payload,
30
+ }).finally(() => {
31
+ clearInterval(progressTimer);
24
32
  });
25
33
  postProgressMessage(device, 100, postMessage);
26
34
  return message;
@@ -10,9 +10,11 @@ export default class GetAccountDescriptor extends AbstractMethod<'getAccountDesc
10
10
  hasBundle?: boolean;
11
11
  init(): void;
12
12
  get info(): string;
13
- confirmation(): Promise<boolean>;
14
- noBackupConfirmation(allowSuppression?: boolean): Promise<boolean>;
15
- checkFirmwareRange(_isUsingPopup: boolean): Promise<undefined>;
13
+ get confirmation(): {
14
+ view: "export-account-info";
15
+ label: string;
16
+ };
17
+ checkFirmwareRange(): undefined;
16
18
  run(): Promise<GetAccountDescriptorResponse | (GetAccountDescriptorResponse | null)[]>;
17
19
  dispose(): void;
18
20
  }
@@ -37,13 +37,14 @@ class GetAccountDescriptor extends AbstractMethod_1.AbstractMethod {
37
37
  coinInfo,
38
38
  };
39
39
  });
40
+ this.noBackupConfirmationMode = this.params.every(batch => batch.suppressBackupWarning)
41
+ ? 'popup-only'
42
+ : 'always';
40
43
  }
41
44
  get info() {
42
45
  return 'Export account descriptor';
43
46
  }
44
- async confirmation() {
45
- await this.getPopupPromise().promise;
46
- const uiPromise = this.createUiPromise(events_1.UI.RECEIVE_CONFIRMATION);
47
+ get confirmation() {
47
48
  const keys = {};
48
49
  this.params.forEach(b => {
49
50
  if (!keys[b.coinInfo.label]) {
@@ -70,30 +71,16 @@ class GetAccountDescriptor extends AbstractMethod_1.AbstractMethod {
70
71
  str.push('</span>');
71
72
  });
72
73
  });
73
- this.postMessage((0, events_1.createUiMessage)(events_1.UI.REQUEST_CONFIRMATION, {
74
+ return {
74
75
  view: 'export-account-info',
75
76
  label: `Export descriptor for: ${str.join('')}`,
76
- }));
77
- const uiResp = await uiPromise.promise;
78
- return uiResp.payload;
79
- }
80
- async noBackupConfirmation(allowSuppression) {
81
- if (allowSuppression && this.params.every(batch => batch.suppressBackupWarning)) {
82
- return true;
83
- }
84
- await this.getPopupPromise().promise;
85
- const uiPromise = this.createUiPromise(events_1.UI.RECEIVE_CONFIRMATION);
86
- this.postMessage((0, events_1.createUiMessage)(events_1.UI.REQUEST_CONFIRMATION, {
87
- view: 'no-backup',
88
- }));
89
- const uiResp = await uiPromise.promise;
90
- return uiResp.payload;
77
+ };
91
78
  }
92
- async checkFirmwareRange(_isUsingPopup) {
79
+ checkFirmwareRange() {
93
80
  const invalid = [];
94
81
  for (let i = 0; i < this.params.length; i++) {
95
82
  this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, this.params[i].coinInfo, AbstractMethod_1.DEFAULT_FIRMWARE_RANGE);
96
- const exception = await super.checkFirmwareRange(false);
83
+ const exception = super.checkFirmwareRange();
97
84
  if (exception) {
98
85
  invalid.push({
99
86
  index: i,
@@ -12,9 +12,19 @@ export default class GetAccountInfo extends AbstractMethod<'getAccountInfo', Req
12
12
  discovery?: Discovery;
13
13
  init(): void;
14
14
  get info(): string;
15
- confirmation(): Promise<boolean>;
16
- noBackupConfirmation(allowSuppression?: boolean): Promise<boolean>;
17
- checkFirmwareRange(isUsingPopup: boolean): Promise<"ui-device_firmware_old" | "ui-device_firmware_unsupported" | "ui-device_firmware_not_compatible" | "ui-device_firmware_not_installed" | undefined>;
15
+ get confirmation(): {
16
+ view: "export-account-info";
17
+ label: string;
18
+ customConfirmButton: {
19
+ label: string;
20
+ className: string;
21
+ };
22
+ } | {
23
+ view: "export-account-info";
24
+ label: string;
25
+ customConfirmButton?: undefined;
26
+ };
27
+ checkFirmwareRange(): "ui-device_firmware_old" | "ui-device_firmware_unsupported" | "ui-device_firmware_not_compatible" | "ui-device_firmware_not_installed" | undefined;
18
28
  run(): Promise<AccountInfo | (AccountInfo | null)[] | {
19
29
  utxo: AccountUtxo[] | undefined;
20
30
  descriptor: string;
@@ -33,7 +43,11 @@ export default class GetAccountInfo extends AbstractMethod<'getAccountInfo', Req
33
43
  };
34
44
  misc?: {
35
45
  nonce?: string | undefined;
36
- erc20Contract?: import("@trezor/blockchain-link-types/lib/common").TokenInfo | undefined;
46
+ contractInfo?: import("@trezor/blockchain-link-types/lib/blockbook-api").ContractInfo | undefined;
47
+ stakingPools?: import("@trezor/blockchain-link-types/lib/blockbook-api").StakingPool[] | undefined;
48
+ addressAliases?: {
49
+ [key: string]: import("@trezor/blockchain-link-types/lib/blockbook-api").AddressAlias;
50
+ } | undefined;
37
51
  sequence?: number | undefined;
38
52
  reserve?: string | undefined;
39
53
  rewards?: string | undefined;
@@ -54,7 +68,6 @@ export default class GetAccountInfo extends AbstractMethod<'getAccountInfo', Req
54
68
  ledger: number;
55
69
  seq: number;
56
70
  } | undefined;
57
- stakingPools?: import("@trezor/blockchain-link-types").StakingPool[] | undefined;
58
71
  path: string;
59
72
  }>;
60
73
  discover(request: Request): Promise<{
@@ -75,7 +88,11 @@ export default class GetAccountInfo extends AbstractMethod<'getAccountInfo', Req
75
88
  };
76
89
  misc?: {
77
90
  nonce?: string | undefined;
78
- erc20Contract?: import("@trezor/blockchain-link-types/lib/common").TokenInfo | undefined;
91
+ contractInfo?: import("@trezor/blockchain-link-types/lib/blockbook-api").ContractInfo | undefined;
92
+ stakingPools?: import("@trezor/blockchain-link-types/lib/blockbook-api").StakingPool[] | undefined;
93
+ addressAliases?: {
94
+ [key: string]: import("@trezor/blockchain-link-types/lib/blockbook-api").AddressAlias;
95
+ } | undefined;
79
96
  sequence?: number | undefined;
80
97
  reserve?: string | undefined;
81
98
  rewards?: string | undefined;
@@ -96,7 +113,6 @@ export default class GetAccountInfo extends AbstractMethod<'getAccountInfo', Req
96
113
  ledger: number;
97
114
  seq: number;
98
115
  } | undefined;
99
- stakingPools?: import("@trezor/blockchain-link-types").StakingPool[] | undefined;
100
116
  path: string;
101
117
  }>;
102
118
  dispose(): void;
@@ -28,6 +28,7 @@ class GetAccountInfo extends AbstractMethod_1.AbstractMethod {
28
28
  this.params = payload.bundle.map(batch => {
29
29
  (0, paramsValidator_1.validateParams)(batch, [
30
30
  { name: 'coin', type: 'string', required: true },
31
+ { name: 'identity', type: 'string' },
31
32
  { name: 'descriptor', type: 'string' },
32
33
  { name: 'path', type: 'string' },
33
34
  { name: 'details', type: 'string' },
@@ -68,22 +69,23 @@ class GetAccountInfo extends AbstractMethod_1.AbstractMethod {
68
69
  });
69
70
  this.useDevice = willUseDevice;
70
71
  this.useUi = willUseDevice;
72
+ this.noBackupConfirmationMode = this.params.every(batch => batch.suppressBackupWarning)
73
+ ? 'popup-only'
74
+ : 'always';
71
75
  }
72
76
  get info() {
73
77
  return 'Export account info';
74
78
  }
75
- async confirmation() {
76
- await this.getPopupPromise().promise;
77
- const uiPromise = this.createUiPromise(events_1.UI.RECEIVE_CONFIRMATION);
79
+ get confirmation() {
78
80
  if (this.params.length === 1 && !this.params[0].path && !this.params[0].descriptor) {
79
- this.postMessage((0, events_1.createUiMessage)(events_1.UI.REQUEST_CONFIRMATION, {
81
+ return {
80
82
  view: 'export-account-info',
81
83
  label: `Export info for ${this.params[0].coinInfo.label} account of your selection`,
82
84
  customConfirmButton: {
83
85
  label: 'Proceed to account selection',
84
86
  className: 'not-empty-css',
85
87
  },
86
- }));
88
+ };
87
89
  }
88
90
  else {
89
91
  const keys = {};
@@ -112,34 +114,20 @@ class GetAccountInfo extends AbstractMethod_1.AbstractMethod {
112
114
  str.push('</span>');
113
115
  });
114
116
  });
115
- this.postMessage((0, events_1.createUiMessage)(events_1.UI.REQUEST_CONFIRMATION, {
117
+ return {
116
118
  view: 'export-account-info',
117
119
  label: `Export info for: ${str.join('')}`,
118
- }));
119
- }
120
- const uiResp = await uiPromise.promise;
121
- return uiResp.payload;
122
- }
123
- async noBackupConfirmation(allowSuppression) {
124
- if (allowSuppression && this.params.every(batch => batch.suppressBackupWarning)) {
125
- return true;
120
+ };
126
121
  }
127
- await this.getPopupPromise().promise;
128
- const uiPromise = this.createUiPromise(events_1.UI.RECEIVE_CONFIRMATION);
129
- this.postMessage((0, events_1.createUiMessage)(events_1.UI.REQUEST_CONFIRMATION, {
130
- view: 'no-backup',
131
- }));
132
- const uiResp = await uiPromise.promise;
133
- return uiResp.payload;
134
122
  }
135
- async checkFirmwareRange(isUsingPopup) {
136
- if (isUsingPopup || this.params.length === 1) {
137
- return super.checkFirmwareRange(isUsingPopup);
123
+ checkFirmwareRange() {
124
+ if (this.params.length === 1) {
125
+ return super.checkFirmwareRange();
138
126
  }
139
127
  const invalid = [];
140
128
  for (let i = 0; i < this.params.length; i++) {
141
129
  this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, this.params[i].coinInfo, AbstractMethod_1.DEFAULT_FIRMWARE_RANGE);
142
- const exception = await super.checkFirmwareRange(false);
130
+ const exception = super.checkFirmwareRange();
143
131
  if (exception) {
144
132
  invalid.push({
145
133
  index: i,
@@ -204,7 +192,7 @@ class GetAccountInfo extends AbstractMethod_1.AbstractMethod {
204
192
  if (typeof descriptor !== 'string') {
205
193
  throw constants_1.ERRORS.TypedError('Runtime', 'GetAccountInfo: descriptor not found');
206
194
  }
207
- const blockchain = await (0, BlockchainLink_1.initBlockchain)(request.coinInfo, this.postMessage);
195
+ const blockchain = await (0, BlockchainLink_1.initBlockchain)(request.coinInfo, this.postMessage, request.identity);
208
196
  if (this.disposed)
209
197
  break;
210
198
  const info = await blockchain.getAccountInfo({
@@ -256,8 +244,8 @@ class GetAccountInfo extends AbstractMethod_1.AbstractMethod {
256
244
  return this.hasBundle ? responses : responses[0];
257
245
  }
258
246
  async discover(request) {
259
- const { coinInfo, defaultAccountType } = request;
260
- const blockchain = await (0, BlockchainLink_1.initBlockchain)(coinInfo, this.postMessage);
247
+ const { coinInfo, identity, defaultAccountType } = request;
248
+ const blockchain = await (0, BlockchainLink_1.initBlockchain)(coinInfo, this.postMessage, identity);
261
249
  const dfd = this.createUiPromise(events_1.UI.RECEIVE_ACCOUNT);
262
250
  const discovery = new Discovery_1.Discovery({
263
251
  blockchain,
@@ -9,7 +9,6 @@ type Params = PROTO.GetAddress & {
9
9
  export default class GetAddress extends AbstractMethod<'getAddress', Params[]> {
10
10
  hasBundle?: boolean;
11
11
  progress: number;
12
- confirmed?: boolean;
13
12
  init(): void;
14
13
  get info(): string;
15
14
  getButtonRequestData(code: string): {
@@ -17,8 +16,10 @@ export default class GetAddress extends AbstractMethod<'getAddress', Params[]> {
17
16
  serializedPath: string;
18
17
  address: string;
19
18
  } | undefined;
20
- confirmation(): Promise<boolean>;
21
- noBackupConfirmation(): Promise<boolean>;
19
+ get confirmation(): {
20
+ view: "export-address";
21
+ label: string;
22
+ } | undefined;
22
23
  _call({ address_n, show_display, multisig, script_type, coinInfo, unlockPath, chunkify, }: Params): Promise<{
23
24
  path: number[];
24
25
  serializedPath: string;
@@ -15,6 +15,7 @@ class GetAddress extends AbstractMethod_1.AbstractMethod {
15
15
  this.progress = 0;
16
16
  }
17
17
  init() {
18
+ this.noBackupConfirmationMode = 'always';
18
19
  this.requiredPermissions = ['read'];
19
20
  this.hasBundle = !!this.payload.bundle;
20
21
  const payload = !this.payload.bundle
@@ -61,7 +62,6 @@ class GetAddress extends AbstractMethod_1.AbstractMethod {
61
62
  this.params.length === 1 &&
62
63
  typeof this.params[0].address === 'string' &&
63
64
  this.params[0].show_display;
64
- this.confirmed = useEventListener;
65
65
  this.useUi = !useEventListener;
66
66
  }
67
67
  get info() {
@@ -84,27 +84,13 @@ class GetAddress extends AbstractMethod_1.AbstractMethod {
84
84
  };
85
85
  }
86
86
  }
87
- async confirmation() {
88
- if (this.confirmed)
89
- return true;
90
- await this.getPopupPromise().promise;
91
- const uiPromise = this.createUiPromise(events_1.UI.RECEIVE_CONFIRMATION);
92
- this.postMessage((0, events_1.createUiMessage)(events_1.UI.REQUEST_CONFIRMATION, {
93
- view: 'export-address',
94
- label: this.info,
95
- }));
96
- const uiResp = await uiPromise.promise;
97
- this.confirmed = uiResp.payload;
98
- return this.confirmed;
99
- }
100
- async noBackupConfirmation() {
101
- await this.getPopupPromise().promise;
102
- const uiPromise = this.createUiPromise(events_1.UI.RECEIVE_CONFIRMATION);
103
- this.postMessage((0, events_1.createUiMessage)(events_1.UI.REQUEST_CONFIRMATION, {
104
- view: 'no-backup',
105
- }));
106
- const uiResp = await uiPromise.promise;
107
- return uiResp.payload;
87
+ get confirmation() {
88
+ return !this.useUi
89
+ ? undefined
90
+ : {
91
+ view: 'export-address',
92
+ label: this.info,
93
+ };
108
94
  }
109
95
  async _call({ address_n, show_display, multisig, script_type, coinInfo, unlockPath, chunkify, }) {
110
96
  const cmd = this.device.getCommands();
@@ -21,6 +21,7 @@ export default class GetCoinInfo extends AbstractMethod<'getCoinInfo', Params> {
21
21
  T1B1: string | false;
22
22
  T2T1: string | false;
23
23
  T2B1: string | false;
24
+ T3T1: string | false;
24
25
  connect: boolean;
25
26
  };
26
27
  decimals: number;
@@ -76,6 +77,7 @@ export default class GetCoinInfo extends AbstractMethod<'getCoinInfo', Params> {
76
77
  T1B1: string | false;
77
78
  T2T1: string | false;
78
79
  T2B1: string | false;
80
+ T3T1: string | false;
79
81
  connect: boolean;
80
82
  };
81
83
  decimals: number;
@@ -106,6 +108,7 @@ export default class GetCoinInfo extends AbstractMethod<'getCoinInfo', Params> {
106
108
  T1B1: string | false;
107
109
  T2T1: string | false;
108
110
  T2B1: string | false;
111
+ T3T1: string | false;
109
112
  connect: boolean;
110
113
  };
111
114
  decimals: number;
@@ -12,6 +12,7 @@ export default class GetFeatures extends AbstractMethod<'getFeatures'> {
12
12
  homescreen_height?: number | undefined;
13
13
  bootloader_locked?: boolean | undefined;
14
14
  language_version_matches?: boolean | undefined;
15
+ unit_packaging?: number | undefined;
15
16
  flags: number | null;
16
17
  language: string | null;
17
18
  label: string | null;
@@ -2,10 +2,12 @@ import { AbstractMethod } from '../core/AbstractMethod';
2
2
  import { PROTO } from '../constants';
3
3
  export default class GetOwnershipId extends AbstractMethod<'getOwnershipId', PROTO.GetOwnershipId[]> {
4
4
  hasBundle?: boolean;
5
- confirmed?: boolean;
6
5
  init(): void;
7
6
  get info(): string;
8
- confirmation(): Promise<boolean>;
7
+ get confirmation(): {
8
+ view: "export-address";
9
+ label: string;
10
+ };
9
11
  run(): Promise<import("../types/api/getOwnershipId").OwnershipId | import("../types/api/getOwnershipId").OwnershipId[]>;
10
12
  }
11
13
  //# sourceMappingURL=getOwnershipId.d.ts.map
@@ -32,22 +32,11 @@ class GetOwnershipId extends AbstractMethod_1.AbstractMethod {
32
32
  get info() {
33
33
  return 'Export ownership id';
34
34
  }
35
- async confirmation() {
36
- if (this.confirmed)
37
- return true;
38
- await this.getPopupPromise().promise;
39
- const uiPromise = this.createUiPromise(events_1.UI.RECEIVE_CONFIRMATION, this.device);
40
- let label = this.info;
41
- if (this.params.length > 1) {
42
- label = 'Export multiple ownership proof ids';
43
- }
44
- this.postMessage((0, events_1.createUiMessage)(events_1.UI.REQUEST_CONFIRMATION, {
35
+ get confirmation() {
36
+ return {
45
37
  view: 'export-address',
46
- label,
47
- }));
48
- const uiResp = await uiPromise.promise;
49
- this.confirmed = uiResp.payload;
50
- return this.confirmed;
38
+ label: this.params.length > 1 ? 'Export multiple ownership proof ids' : this.info,
39
+ };
51
40
  }
52
41
  async run() {
53
42
  const responses = [];
@@ -2,10 +2,12 @@ import { AbstractMethod } from '../core/AbstractMethod';
2
2
  import { PROTO } from '../constants';
3
3
  export default class GetOwnershipProof extends AbstractMethod<'getOwnershipProof', PROTO.GetOwnershipProof[]> {
4
4
  hasBundle?: boolean;
5
- confirmed?: boolean;
6
5
  init(): void;
7
6
  get info(): string;
8
- confirmation(): Promise<boolean>;
7
+ get confirmation(): {
8
+ view: "export-address";
9
+ label: string;
10
+ };
9
11
  run(): Promise<import("../types/api/getOwnershipProof").OwnershipProof | import("../types/api/getOwnershipProof").OwnershipProof[]>;
10
12
  }
11
13
  //# sourceMappingURL=getOwnershipProof.d.ts.map
@@ -38,22 +38,11 @@ class GetOwnershipProof extends AbstractMethod_1.AbstractMethod {
38
38
  get info() {
39
39
  return 'Export ownership proof';
40
40
  }
41
- async confirmation() {
42
- if (this.confirmed)
43
- return true;
44
- await this.getPopupPromise().promise;
45
- const uiPromise = this.createUiPromise(events_1.UI.RECEIVE_CONFIRMATION, this.device);
46
- let label = this.info;
47
- if (this.params.length > 1) {
48
- label = 'Export multiple ownership proofs';
49
- }
50
- this.postMessage((0, events_1.createUiMessage)(events_1.UI.REQUEST_CONFIRMATION, {
41
+ get confirmation() {
42
+ return {
51
43
  view: 'export-address',
52
- label,
53
- }));
54
- const uiResp = await uiPromise.promise;
55
- this.confirmed = uiResp.payload;
56
- return this.confirmed;
44
+ label: this.params.length > 1 ? 'Export multiple ownership proofs' : this.info,
45
+ };
57
46
  }
58
47
  async run() {
59
48
  const responses = [];
@@ -2,17 +2,18 @@ import { AbstractMethod } from '../core/AbstractMethod';
2
2
  import type { BitcoinNetworkInfo } from '../types';
3
3
  import type { PROTO } from '../constants';
4
4
  type Params = PROTO.GetPublicKey & {
5
- coinInfo?: BitcoinNetworkInfo;
5
+ coinInfo: BitcoinNetworkInfo;
6
6
  suppressBackupWarning?: boolean;
7
7
  unlockPath?: PROTO.UnlockPath;
8
8
  };
9
9
  export default class GetPublicKey extends AbstractMethod<'getPublicKey', Params[]> {
10
10
  hasBundle?: boolean;
11
- confirmed?: boolean;
12
11
  init(): void;
13
12
  get info(): string;
14
- confirmation(): Promise<boolean>;
15
- noBackupConfirmation(allowSuppression?: boolean): Promise<boolean>;
13
+ get confirmation(): {
14
+ view: "export-xpub";
15
+ label: string;
16
+ };
16
17
  run(): Promise<{
17
18
  xpubSegwit?: string | undefined;
18
19
  descriptorChecksum?: string | undefined;
@@ -18,6 +18,7 @@ class GetPublicKey extends AbstractMethod_1.AbstractMethod {
18
18
  : this.payload;
19
19
  (0, schema_utils_1.Assert)((0, types_1.Bundle)(getPublicKey_1.GetPublicKey), payload);
20
20
  this.params = payload.bundle.map(batch => {
21
+ var _a;
21
22
  let coinInfo;
22
23
  if (batch.coin) {
23
24
  coinInfo = (0, coinInfo_1.getBitcoinNetwork)(batch.coin);
@@ -27,11 +28,9 @@ class GetPublicKey extends AbstractMethod_1.AbstractMethod {
27
28
  (0, paramsValidator_1.validateCoinPath)(address_n, coinInfo);
28
29
  }
29
30
  else if (!coinInfo) {
30
- coinInfo = (0, coinInfo_1.getBitcoinNetwork)(address_n);
31
- }
32
- if (coinInfo) {
33
- this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, coinInfo, this.firmwareRange);
31
+ coinInfo = (_a = (0, coinInfo_1.getBitcoinNetwork)(address_n)) !== null && _a !== void 0 ? _a : (0, coinInfo_1.getBitcoinNetwork)('btc');
34
32
  }
33
+ this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, coinInfo, this.firmwareRange);
35
34
  return {
36
35
  address_n,
37
36
  coin_name: coinInfo === null || coinInfo === void 0 ? void 0 : coinInfo.name,
@@ -44,42 +43,20 @@ class GetPublicKey extends AbstractMethod_1.AbstractMethod {
44
43
  suppress_backup_warning: batch.suppressBackupWarning,
45
44
  };
46
45
  });
46
+ this.noBackupConfirmationMode = this.params.every(batch => batch.suppressBackupWarning || !batch.show_display)
47
+ ? 'popup-only'
48
+ : 'always';
47
49
  }
48
50
  get info() {
49
51
  return 'Export public key';
50
52
  }
51
- async confirmation() {
52
- if (this.confirmed)
53
- return true;
54
- await this.getPopupPromise().promise;
55
- const uiPromise = this.createUiPromise(events_1.UI.RECEIVE_CONFIRMATION);
56
- let label;
57
- if (this.params.length > 1) {
58
- label = 'Export multiple public keys';
59
- }
60
- else {
61
- label = (0, accountUtils_1.getPublicKeyLabel)(this.params[0].address_n, this.params[0].coinInfo);
62
- }
63
- this.postMessage((0, events_1.createUiMessage)(events_1.UI.REQUEST_CONFIRMATION, {
53
+ get confirmation() {
54
+ return {
64
55
  view: 'export-xpub',
65
- label,
66
- }));
67
- const uiResp = await uiPromise.promise;
68
- this.confirmed = uiResp.payload;
69
- return this.confirmed;
70
- }
71
- async noBackupConfirmation(allowSuppression) {
72
- if (allowSuppression &&
73
- this.params.every(batch => batch.suppressBackupWarning || !batch.show_display)) {
74
- return true;
75
- }
76
- await this.getPopupPromise().promise;
77
- const uiPromise = this.createUiPromise(events_1.UI.RECEIVE_CONFIRMATION);
78
- this.postMessage((0, events_1.createUiMessage)(events_1.UI.REQUEST_CONFIRMATION, {
79
- view: 'no-backup',
80
- }));
81
- const uiResp = await uiPromise.promise;
82
- return uiResp.payload;
56
+ label: this.params.length > 1
57
+ ? 'Export multiple public keys'
58
+ : (0, accountUtils_1.getPublicKeyLabel)(this.params[0].address_n, this.params[0].coinInfo),
59
+ };
83
60
  }
84
61
  async run() {
85
62
  const responses = [];