@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
@@ -7,12 +7,15 @@ const BlockchainLink_1 = require("../backend/BlockchainLink");
7
7
  const coinInfo_1 = require("../data/coinInfo");
8
8
  class BlockchainSubscribe extends AbstractMethod_1.AbstractMethod {
9
9
  init() {
10
+ var _a;
10
11
  this.useDevice = false;
11
12
  this.useUi = false;
12
13
  const { payload } = this;
13
14
  (0, paramsValidator_1.validateParams)(payload, [
14
15
  { name: 'accounts', type: 'array', allowEmpty: true },
16
+ { name: 'blocks', type: 'boolean' },
15
17
  { name: 'coin', type: 'string', required: true },
18
+ { name: 'identity', type: 'string' },
16
19
  ]);
17
20
  if (payload.accounts) {
18
21
  payload.accounts.forEach(account => {
@@ -26,12 +29,20 @@ class BlockchainSubscribe extends AbstractMethod_1.AbstractMethod {
26
29
  (0, BlockchainLink_1.isBackendSupported)(coinInfo);
27
30
  this.params = {
28
31
  accounts: payload.accounts,
32
+ blocks: (_a = payload.blocks) !== null && _a !== void 0 ? _a : true,
29
33
  coinInfo,
34
+ identity: payload.identity,
30
35
  };
31
36
  }
32
37
  async run() {
33
- const backend = await (0, BlockchainLink_1.initBlockchain)(this.params.coinInfo, this.postMessage);
34
- return backend.subscribe(this.params.accounts);
38
+ const backend = await (0, BlockchainLink_1.initBlockchain)(this.params.coinInfo, this.postMessage, this.params.identity);
39
+ const { blocks, accounts } = this.params;
40
+ let result = { subscribed: false };
41
+ if (blocks)
42
+ result = await backend.subscribeBlocks();
43
+ if (accounts)
44
+ result = await backend.subscribeAccounts(accounts);
45
+ return result;
35
46
  }
36
47
  }
37
48
  exports.default = BlockchainSubscribe;
@@ -3,6 +3,7 @@ import type { CoinInfo } from '../types';
3
3
  type Params = {
4
4
  currency: Payload<'blockchainSubscribeFiatRates'>['currency'];
5
5
  coinInfo: CoinInfo;
6
+ identity?: string;
6
7
  };
7
8
  export default class BlockchainSubscribeFiatRates extends AbstractMethod<'blockchainSubscribeFiatRates', Params> {
8
9
  init(): void;
@@ -13,6 +13,7 @@ class BlockchainSubscribeFiatRates extends AbstractMethod_1.AbstractMethod {
13
13
  (0, paramsValidator_1.validateParams)(payload, [
14
14
  { name: 'currency', type: 'string', required: false },
15
15
  { name: 'coin', type: 'string', required: true },
16
+ { name: 'identity', type: 'string' },
16
17
  ]);
17
18
  const coinInfo = (0, coinInfo_1.getCoinInfo)(payload.coin);
18
19
  if (!coinInfo) {
@@ -22,10 +23,11 @@ class BlockchainSubscribeFiatRates extends AbstractMethod_1.AbstractMethod {
22
23
  this.params = {
23
24
  currency: payload.currency,
24
25
  coinInfo,
26
+ identity: payload.identity,
25
27
  };
26
28
  }
27
29
  async run() {
28
- const backend = await (0, BlockchainLink_1.initBlockchain)(this.params.coinInfo, this.postMessage);
30
+ const backend = await (0, BlockchainLink_1.initBlockchain)(this.params.coinInfo, this.postMessage, this.params.identity);
29
31
  return backend.subscribeFiatRates(this.params.currency);
30
32
  }
31
33
  }
@@ -3,6 +3,7 @@ import type { CoinInfo } from '../types';
3
3
  type Params = {
4
4
  accounts: Payload<'blockchainUnsubscribe'>['accounts'];
5
5
  coinInfo: CoinInfo;
6
+ identity?: string;
6
7
  };
7
8
  export default class BlockchainUnsubscribe extends AbstractMethod<'blockchainUnsubscribe', Params> {
8
9
  init(): void;
@@ -13,6 +13,7 @@ class BlockchainUnsubscribe extends AbstractMethod_1.AbstractMethod {
13
13
  (0, paramsValidator_1.validateParams)(payload, [
14
14
  { name: 'accounts', type: 'array', allowEmpty: true },
15
15
  { name: 'coin', type: 'string', required: true },
16
+ { name: 'identity', type: 'string' },
16
17
  ]);
17
18
  if (payload.accounts) {
18
19
  payload.accounts.forEach(account => {
@@ -27,11 +28,13 @@ class BlockchainUnsubscribe extends AbstractMethod_1.AbstractMethod {
27
28
  this.params = {
28
29
  accounts: payload.accounts,
29
30
  coinInfo,
31
+ identity: payload.identity,
30
32
  };
31
33
  }
32
34
  async run() {
33
- const backend = await (0, BlockchainLink_1.initBlockchain)(this.params.coinInfo, this.postMessage);
34
- return backend.unsubscribe(this.params.accounts);
35
+ const backend = await (0, BlockchainLink_1.initBlockchain)(this.params.coinInfo, this.postMessage, this.params.identity);
36
+ const { accounts } = this.params;
37
+ return accounts ? backend.unsubscribeAccounts(accounts) : backend.unsubscribeAll();
35
38
  }
36
39
  }
37
40
  exports.default = BlockchainUnsubscribe;
@@ -2,6 +2,7 @@ import { AbstractMethod } from '../core/AbstractMethod';
2
2
  import type { CoinInfo } from '../types';
3
3
  type Params = {
4
4
  coinInfo: CoinInfo;
5
+ identity?: string;
5
6
  };
6
7
  export default class BlockchainUnsubscribeFiatRates extends AbstractMethod<'blockchainUnsubscribeFiatRates', Params> {
7
8
  init(): void;
@@ -10,7 +10,10 @@ class BlockchainUnsubscribeFiatRates extends AbstractMethod_1.AbstractMethod {
10
10
  this.useDevice = false;
11
11
  this.useUi = false;
12
12
  const { payload } = this;
13
- (0, paramsValidator_1.validateParams)(payload, [{ name: 'coin', type: 'string', required: true }]);
13
+ (0, paramsValidator_1.validateParams)(payload, [
14
+ { name: 'coin', type: 'string', required: true },
15
+ { name: 'identity', type: 'string' },
16
+ ]);
14
17
  const coinInfo = (0, coinInfo_1.getCoinInfo)(payload.coin);
15
18
  if (!coinInfo) {
16
19
  throw constants_1.ERRORS.TypedError('Method_UnknownCoin');
@@ -18,10 +21,11 @@ class BlockchainUnsubscribeFiatRates extends AbstractMethod_1.AbstractMethod {
18
21
  (0, BlockchainLink_1.isBackendSupported)(coinInfo);
19
22
  this.params = {
20
23
  coinInfo,
24
+ identity: payload.identity,
21
25
  };
22
26
  }
23
27
  async run() {
24
- const backend = await (0, BlockchainLink_1.initBlockchain)(this.params.coinInfo, this.postMessage);
28
+ const backend = await (0, BlockchainLink_1.initBlockchain)(this.params.coinInfo, this.postMessage, this.params.identity);
25
29
  return backend.unsubscribeFiatRates();
26
30
  }
27
31
  }
@@ -6,7 +6,6 @@ type Params = PROTO.CardanoGetAddress & {
6
6
  export default class CardanoGetAddress extends AbstractMethod<'cardanoGetAddress', Params[]> {
7
7
  hasBundle?: boolean;
8
8
  progress: number;
9
- confirmed?: boolean;
10
9
  init(): void;
11
10
  get info(): string;
12
11
  getButtonRequestData(code: string): {
@@ -14,8 +13,10 @@ export default class CardanoGetAddress extends AbstractMethod<'cardanoGetAddress
14
13
  serializedPath: string;
15
14
  address: string;
16
15
  } | undefined;
17
- confirmation(): Promise<boolean>;
18
- noBackupConfirmation(): Promise<boolean>;
16
+ get confirmation(): {
17
+ view: "export-address";
18
+ label: string;
19
+ } | undefined;
19
20
  _call({ address_parameters, protocol_magic, network_id, derivation_type, show_display, chunkify, }: Params): Promise<{
20
21
  address: string;
21
22
  }>;
@@ -16,6 +16,7 @@ class CardanoGetAddress extends AbstractMethod_1.AbstractMethod {
16
16
  this.progress = 0;
17
17
  }
18
18
  init() {
19
+ this.noBackupConfirmationMode = 'always';
19
20
  this.requiredPermissions = ['read'];
20
21
  this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, (0, coinInfo_1.getMiscNetwork)('Cardano'), this.firmwareRange);
21
22
  this.hasBundle = !!this.payload.bundle;
@@ -41,7 +42,6 @@ class CardanoGetAddress extends AbstractMethod_1.AbstractMethod {
41
42
  this.params.length === 1 &&
42
43
  typeof this.params[0].address === 'string' &&
43
44
  this.params[0].show_display;
44
- this.confirmed = useEventListener;
45
45
  this.useUi = !useEventListener;
46
46
  }
47
47
  get info() {
@@ -59,27 +59,13 @@ class CardanoGetAddress extends AbstractMethod_1.AbstractMethod {
59
59
  };
60
60
  }
61
61
  }
62
- async confirmation() {
63
- if (this.confirmed)
64
- return true;
65
- await this.getPopupPromise().promise;
66
- const uiPromise = this.createUiPromise(events_1.UI.RECEIVE_CONFIRMATION);
67
- this.postMessage((0, events_1.createUiMessage)(events_1.UI.REQUEST_CONFIRMATION, {
68
- view: 'export-address',
69
- label: this.info,
70
- }));
71
- const uiResp = await uiPromise.promise;
72
- this.confirmed = uiResp.payload;
73
- return this.confirmed;
74
- }
75
- async noBackupConfirmation() {
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;
62
+ get confirmation() {
63
+ return !this.useUi
64
+ ? undefined
65
+ : {
66
+ view: 'export-address',
67
+ label: this.info,
68
+ };
83
69
  }
84
70
  async _call({ address_parameters, protocol_magic, network_id, derivation_type, show_display, chunkify, }) {
85
71
  const cmd = this.device.getCommands();
@@ -5,11 +5,12 @@ interface Params extends PROTO.CardanoGetPublicKey {
5
5
  }
6
6
  export default class CardanoGetPublicKey extends AbstractMethod<'cardanoGetPublicKey', Params[]> {
7
7
  hasBundle?: boolean;
8
- confirmed?: boolean;
9
8
  init(): void;
10
9
  get info(): string;
11
- confirmation(): Promise<boolean>;
12
- noBackupConfirmation(allowSuppression?: boolean): Promise<boolean>;
10
+ get confirmation(): {
11
+ view: "export-xpub";
12
+ label: string;
13
+ };
13
14
  run(): Promise<import("../../../types").CardanoPublicKey | import("../../../types").CardanoPublicKey[]>;
14
15
  }
15
16
  export {};
@@ -29,42 +29,20 @@ class CardanoGetPublicKey extends AbstractMethod_1.AbstractMethod {
29
29
  suppress_backup_warning: batch.suppressBackupWarning,
30
30
  };
31
31
  });
32
+ this.noBackupConfirmationMode = this.params.every(batch => batch.suppressBackupWarning || !batch.show_display)
33
+ ? 'popup-only'
34
+ : 'always';
32
35
  }
33
36
  get info() {
34
37
  return 'Export Cardano public key';
35
38
  }
36
- async confirmation() {
37
- if (this.confirmed)
38
- return true;
39
- await this.getPopupPromise().promise;
40
- const uiPromise = this.createUiPromise(events_1.UI.RECEIVE_CONFIRMATION);
41
- let label;
42
- if (this.params.length > 1) {
43
- label = 'Export multiple Cardano public keys';
44
- }
45
- else {
46
- label = `Export Cardano public key for account #${(0, pathUtils_1.fromHardened)(this.params[0].address_n[2]) + 1}`;
47
- }
48
- this.postMessage((0, events_1.createUiMessage)(events_1.UI.REQUEST_CONFIRMATION, {
39
+ get confirmation() {
40
+ return {
49
41
  view: 'export-xpub',
50
- label,
51
- }));
52
- const uiResp = await uiPromise.promise;
53
- this.confirmed = uiResp.payload;
54
- return this.confirmed;
55
- }
56
- async noBackupConfirmation(allowSuppression) {
57
- if (allowSuppression &&
58
- this.params.every(batch => batch.suppressBackupWarning || !batch.show_display)) {
59
- return true;
60
- }
61
- await this.getPopupPromise().promise;
62
- const uiPromise = this.createUiPromise(events_1.UI.RECEIVE_CONFIRMATION);
63
- this.postMessage((0, events_1.createUiMessage)(events_1.UI.REQUEST_CONFIRMATION, {
64
- view: 'no-backup',
65
- }));
66
- const uiResp = await uiPromise.promise;
67
- return uiResp.payload;
42
+ label: this.params.length > 1
43
+ ? 'Export multiple Cardano public keys'
44
+ : `Export Cardano public key for account #${(0, pathUtils_1.fromHardened)(this.params[0].address_n[2]) + 1}`,
45
+ };
68
46
  }
69
47
  async run() {
70
48
  const responses = [];
@@ -2,8 +2,14 @@ import { AbstractMethod } from '../core/AbstractMethod';
2
2
  import { ChangeLanguage as ChangeLanguageSchema } from '../types/api/changeLanguage';
3
3
  export default class ChangeLanguage extends AbstractMethod<'changeLanguage', ChangeLanguageSchema> {
4
4
  init(): void;
5
- confirmation(): Promise<boolean>;
6
- private uploadTranslationData;
5
+ get confirmation(): {
6
+ view: "device-management";
7
+ customConfirmButton: {
8
+ className: string;
9
+ label: string;
10
+ };
11
+ label: string;
12
+ };
7
13
  run(): Promise<{
8
14
  message: string;
9
15
  }>;
@@ -1,11 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const AbstractMethod_1 = require("../core/AbstractMethod");
4
- const constants_1 = require("../constants");
5
4
  const events_1 = require("../events");
6
5
  const schema_utils_1 = require("@trezor/schema-utils");
7
6
  const changeLanguage_1 = require("../types/api/changeLanguage");
8
- const assets_1 = require("../utils/assets");
9
7
  class ChangeLanguage extends AbstractMethod_1.AbstractMethod {
10
8
  init() {
11
9
  this.allowDeviceMode = [events_1.UI.INITIALIZE, events_1.UI.SEEDLESS];
@@ -14,65 +12,26 @@ class ChangeLanguage extends AbstractMethod_1.AbstractMethod {
14
12
  this.useDeviceState = false;
15
13
  const { payload } = this;
16
14
  (0, schema_utils_1.Assert)(changeLanguage_1.ChangeLanguage, payload);
17
- if (payload.binary) {
18
- this.params = {
19
- binary: payload.binary,
20
- };
21
- }
22
- else {
23
- this.params = {
24
- language: payload.language,
25
- baseUrl: payload.baseUrl || 'https://data.trezor.io',
26
- };
27
- }
15
+ this.params = payload;
28
16
  }
29
- async confirmation() {
30
- await this.getPopupPromise().promise;
31
- const uiPromise = this.createUiPromise(events_1.UI.RECEIVE_CONFIRMATION);
32
- this.postMessage((0, events_1.createUiMessage)(events_1.UI.REQUEST_CONFIRMATION, {
17
+ get confirmation() {
18
+ return {
33
19
  view: 'device-management',
34
20
  customConfirmButton: {
35
21
  className: 'confirm',
36
22
  label: 'Proceed',
37
23
  },
38
24
  label: 'Do you want to change language?',
39
- }));
40
- const uiResp = await uiPromise.promise;
41
- return uiResp.payload;
42
- }
43
- async uploadTranslationData(payload) {
44
- if (!this.device.commands) {
45
- throw constants_1.ERRORS.TypedError('Runtime', 'uploadTranslationData: device.commands is not set');
46
- }
47
- if (payload === null) {
48
- const response = await this.device.commands.typedCall('ChangeLanguage', ['Success'], { data_length: 0 });
49
- return response.message;
50
- }
51
- const length = payload.byteLength;
52
- let response = await this.device.commands.typedCall('ChangeLanguage', ['TranslationDataRequest', 'Success'], { data_length: length });
53
- while (response.type !== 'Success') {
54
- const start = response.message.data_offset;
55
- const end = response.message.data_offset + response.message.data_length;
56
- const chunk = payload.slice(start, end);
57
- response = await this.device.commands.typedCall('TranslationDataAck', ['TranslationDataRequest', 'Success'], {
58
- data_chunk: Buffer.from(chunk).toString('hex'),
59
- });
60
- }
61
- return response.message;
25
+ };
62
26
  }
63
- async run() {
64
- const { language, binary, baseUrl } = this.params;
65
- if (language === 'en-US') {
66
- return this.uploadTranslationData(null);
67
- }
27
+ run() {
28
+ const { language, binary } = this.params;
68
29
  if (binary) {
69
- return this.uploadTranslationData(binary);
30
+ return this.device.changeLanguage({ binary });
31
+ }
32
+ else {
33
+ return this.device.changeLanguage({ language });
70
34
  }
71
- const version = this.device.getVersion().join('.');
72
- const model = this.device.features.internal_model;
73
- const url = `${baseUrl}/firmware/translations/${model.toLowerCase()}/translation-${model.toUpperCase()}-${language}-${version}.bin`;
74
- const downloadedBinary = await (0, assets_1.httpRequest)(url, 'binary');
75
- return this.uploadTranslationData(downloadedBinary);
76
35
  }
77
36
  }
78
37
  exports.default = ChangeLanguage;
@@ -8,6 +8,7 @@ import type { SignedTransaction, PrecomposeParams, ComposeResult, PrecomposedRes
8
8
  type Params = {
9
9
  outputs: ComposeOutput[];
10
10
  coinInfo: BitcoinNetworkInfo;
11
+ identity?: string;
11
12
  push: boolean;
12
13
  account?: PrecomposeParams['account'];
13
14
  feeLevels?: PrecomposeParams['feeLevels'];
@@ -21,6 +22,7 @@ export default class ComposeTransaction extends AbstractMethod<'composeTransacti
21
22
  discovery?: Discovery;
22
23
  init(): void;
23
24
  get info(): string;
25
+ private getBlockchain;
24
26
  precompose(account: PrecomposeParams['account'], feeLevels: PrecomposeParams['feeLevels']): Promise<PrecomposedResult[]>;
25
27
  run(): Promise<SignedTransaction | PrecomposedResult[]>;
26
28
  selectAccount(): Promise<{
@@ -20,6 +20,7 @@ class ComposeTransaction extends AbstractMethod_1.AbstractMethod {
20
20
  (0, paramsValidator_1.validateParams)(payload, [
21
21
  { name: 'outputs', type: 'array', required: true },
22
22
  { name: 'coin', type: 'string', required: true },
23
+ { name: 'identity', type: 'string' },
23
24
  { name: 'push', type: 'boolean' },
24
25
  { name: 'account', type: 'object' },
25
26
  { name: 'feeLevels', type: 'array' },
@@ -48,6 +49,7 @@ class ComposeTransaction extends AbstractMethod_1.AbstractMethod {
48
49
  this.params = {
49
50
  outputs,
50
51
  coinInfo,
52
+ identity: payload.identity,
51
53
  account: payload.account,
52
54
  feeLevels: payload.feeLevels,
53
55
  baseFee: payload.baseFee,
@@ -66,6 +68,9 @@ class ComposeTransaction extends AbstractMethod_1.AbstractMethod {
66
68
  }
67
69
  return `Send ${(0, formatUtils_1.formatAmount)(this.params.total.toString(), this.params.coinInfo)}`;
68
70
  }
71
+ getBlockchain() {
72
+ return (0, BlockchainLink_1.initBlockchain)(this.params.coinInfo, this.postMessage, this.params.identity);
73
+ }
69
74
  async precompose(account, feeLevels) {
70
75
  const { coinInfo, outputs, baseFee, skipPermutation } = this.params;
71
76
  const address_n = pathUtils.validatePath(account.path);
@@ -83,7 +88,7 @@ class ComposeTransaction extends AbstractMethod_1.AbstractMethod {
83
88
  baseFee,
84
89
  skipPermutation,
85
90
  });
86
- const blockchain = await (0, BlockchainLink_1.initBlockchain)(this.params.coinInfo, this.postMessage);
91
+ const blockchain = await this.getBlockchain();
87
92
  await composer.init(blockchain);
88
93
  return feeLevels.map(level => {
89
94
  composer.composeCustomFee(level.feePerUnit);
@@ -120,7 +125,7 @@ class ComposeTransaction extends AbstractMethod_1.AbstractMethod {
120
125
  }
121
126
  async selectAccount() {
122
127
  const { coinInfo } = this.params;
123
- const blockchain = await (0, BlockchainLink_1.initBlockchain)(coinInfo, this.postMessage);
128
+ const blockchain = await this.getBlockchain();
124
129
  const dfd = this.createUiPromise(events_1.UI.RECEIVE_ACCOUNT);
125
130
  if (this.discovery && this.discovery.completed) {
126
131
  const { discovery } = this;
@@ -181,7 +186,7 @@ class ComposeTransaction extends AbstractMethod_1.AbstractMethod {
181
186
  }
182
187
  async selectFee(account, utxos) {
183
188
  const { coinInfo, outputs } = this.params;
184
- const blockchain = await (0, BlockchainLink_1.initBlockchain)(coinInfo, this.postMessage);
189
+ const blockchain = await this.getBlockchain();
185
190
  const composer = new bitcoin_1.TransactionComposer({
186
191
  account,
187
192
  utxos,
@@ -228,7 +233,7 @@ class ComposeTransaction extends AbstractMethod_1.AbstractMethod {
228
233
  const requiredRefTxs = (0, bitcoin_1.requireReferencedTransactions)(inputs, options, coinInfo);
229
234
  const refTxsIds = (0, bitcoin_1.getReferencedTransactions)(inputs);
230
235
  if (requiredRefTxs && refTxsIds.length > 0) {
231
- refTxs = await (0, BlockchainLink_1.initBlockchain)(coinInfo, this.postMessage)
236
+ refTxs = await this.getBlockchain()
232
237
  .then(blockchain => blockchain.getTransactionHexes(refTxsIds))
233
238
  .then((0, bitcoin_1.parseTransactionHexes)(coinInfo.network))
234
239
  .then(bitcoin_1.transformReferencedTransactions);
@@ -246,7 +251,7 @@ class ComposeTransaction extends AbstractMethod_1.AbstractMethod {
246
251
  });
247
252
  await (0, bitcoin_1.verifyTx)(this.device.getCommands().getHDNode.bind(this.device.getCommands()), inputs, outputs, response.serializedTx, coinInfo);
248
253
  if (this.params.push) {
249
- const blockchain = await (0, BlockchainLink_1.initBlockchain)(coinInfo, this.postMessage);
254
+ const blockchain = await this.getBlockchain();
250
255
  const txid = await blockchain.pushTransaction(response.serializedTx);
251
256
  return {
252
257
  ...response,
@@ -2,10 +2,12 @@ import { AbstractMethod } from '../../../core/AbstractMethod';
2
2
  import type { PROTO } from '../../../constants';
3
3
  export default class EosGetPublicKey extends AbstractMethod<'eosGetPublicKey', PROTO.EosGetPublicKey[]> {
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<{
10
12
  path: number[];
11
13
  serializedPath: string;
@@ -28,25 +28,13 @@ class EosGetPublicKey extends AbstractMethod_1.AbstractMethod {
28
28
  get info() {
29
29
  return 'Export Eos public key';
30
30
  }
31
- async confirmation() {
32
- if (this.confirmed)
33
- return true;
34
- await this.getPopupPromise().promise;
35
- const uiPromise = this.createUiPromise(events_1.UI.RECEIVE_CONFIRMATION);
36
- let label;
37
- if (this.params.length > 1) {
38
- label = 'Export multiple Eos public keys';
39
- }
40
- else {
41
- label = `Export Eos public key for account #${(0, pathUtils_1.fromHardened)(this.params[0].address_n[2]) + 1}`;
42
- }
43
- this.postMessage((0, events_1.createUiMessage)(events_1.UI.REQUEST_CONFIRMATION, {
31
+ get confirmation() {
32
+ return {
44
33
  view: 'export-address',
45
- label,
46
- }));
47
- const uiResp = await uiPromise.promise;
48
- this.confirmed = uiResp.payload;
49
- return this.confirmed;
34
+ label: this.params.length > 1
35
+ ? 'Export multiple Eos public keys'
36
+ : `Export Eos public key for account #${(0, pathUtils_1.fromHardened)(this.params[0].address_n[2]) + 1}`,
37
+ };
50
38
  }
51
39
  async run() {
52
40
  const responses = [];
@@ -21,13 +21,13 @@ export declare const validate: (tx: EosSDKTransaction) => {
21
21
  sender: string;
22
22
  receiver: string;
23
23
  } | undefined;
24
- refund?: {
25
- owner: string;
26
- } | undefined;
27
24
  unknown?: {
28
25
  data_size: number;
29
26
  data_chunk: string;
30
27
  } | undefined;
28
+ refund?: {
29
+ owner: string;
30
+ } | undefined;
31
31
  new_account?: {
32
32
  name: string;
33
33
  owner: {
@@ -9,7 +9,6 @@ type Params = PROTO.EthereumGetAddress & {
9
9
  export default class EthereumGetAddress extends AbstractMethod<'ethereumGetAddress', Params[]> {
10
10
  hasBundle?: boolean;
11
11
  progress: number;
12
- confirmed?: boolean;
13
12
  init(): void;
14
13
  initAsync(): Promise<void>;
15
14
  get info(): string;
@@ -18,8 +17,10 @@ export default class EthereumGetAddress extends AbstractMethod<'ethereumGetAddre
18
17
  serializedPath: string;
19
18
  address: string;
20
19
  } | undefined;
21
- confirmation(): Promise<boolean>;
22
- noBackupConfirmation(): Promise<boolean>;
20
+ get confirmation(): {
21
+ view: "export-address";
22
+ label: string;
23
+ };
23
24
  _call({ address_n, show_display, encoded_network, chunkify }: Params): Promise<{
24
25
  path: number[];
25
26
  serializedPath: string;
@@ -18,6 +18,7 @@ class EthereumGetAddress extends AbstractMethod_1.AbstractMethod {
18
18
  this.progress = 0;
19
19
  }
20
20
  init() {
21
+ this.noBackupConfirmationMode = 'always';
21
22
  this.requiredPermissions = ['read'];
22
23
  this.hasBundle = !!this.payload.bundle;
23
24
  const payload = !this.payload.bundle
@@ -40,7 +41,6 @@ class EthereumGetAddress extends AbstractMethod_1.AbstractMethod {
40
41
  this.params.length === 1 &&
41
42
  typeof this.params[0].address === 'string' &&
42
43
  this.params[0].show_display;
43
- this.confirmed = useEventListener;
44
44
  this.useUi = !useEventListener;
45
45
  }
46
46
  async initAsync() {
@@ -80,27 +80,11 @@ class EthereumGetAddress extends AbstractMethod_1.AbstractMethod {
80
80
  };
81
81
  }
82
82
  }
83
- async confirmation() {
84
- if (this.confirmed)
85
- return true;
86
- await this.getPopupPromise().promise;
87
- const uiPromise = this.createUiPromise(events_1.UI.RECEIVE_CONFIRMATION);
88
- this.postMessage((0, events_1.createUiMessage)(events_1.UI.REQUEST_CONFIRMATION, {
83
+ get confirmation() {
84
+ return {
89
85
  view: 'export-address',
90
86
  label: this.info,
91
- }));
92
- const uiResp = await uiPromise.promise;
93
- this.confirmed = uiResp.payload;
94
- return this.confirmed;
95
- }
96
- async noBackupConfirmation() {
97
- await this.getPopupPromise().promise;
98
- const uiPromise = this.createUiPromise(events_1.UI.RECEIVE_CONFIRMATION);
99
- this.postMessage((0, events_1.createUiMessage)(events_1.UI.REQUEST_CONFIRMATION, {
100
- view: 'no-backup',
101
- }));
102
- const uiResp = await uiPromise.promise;
103
- return uiResp.payload;
87
+ };
104
88
  }
105
89
  _call({ address_n, show_display, encoded_network, chunkify }) {
106
90
  const cmd = this.device.getCommands();
@@ -6,10 +6,12 @@ type Params = PROTO.EthereumGetPublicKey & {
6
6
  };
7
7
  export default class EthereumGetPublicKey extends AbstractMethod<'ethereumGetPublicKey', Params[]> {
8
8
  hasBundle?: boolean;
9
- confirmed?: boolean;
10
9
  init(): void;
11
10
  get info(): string;
12
- confirmation(): Promise<boolean>;
11
+ get confirmation(): {
12
+ view: "export-xpub";
13
+ label: string;
14
+ };
13
15
  run(): Promise<{
14
16
  xpubSegwit?: string | undefined;
15
17
  descriptorChecksum?: string | undefined;
@@ -38,18 +38,11 @@ class EthereumGetPublicKey extends AbstractMethod_1.AbstractMethod {
38
38
  }
39
39
  return 'Export multiple public keys';
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);
46
- this.postMessage((0, events_1.createUiMessage)(events_1.UI.REQUEST_CONFIRMATION, {
41
+ get confirmation() {
42
+ return {
47
43
  view: 'export-xpub',
48
44
  label: this.info,
49
- }));
50
- const uiResp = await uiPromise.promise;
51
- this.confirmed = uiResp.payload;
52
- return this.confirmed;
45
+ };
53
46
  }
54
47
  async run() {
55
48
  const responses = [];