@onekeyfe/hd-core 1.1.27-alpha.41 → 1.1.27-alpha.43

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 (176) hide show
  1. package/__tests__/DeviceCommands.test.ts +99 -0
  2. package/__tests__/evmLedgerLegacySafety.test.ts +261 -0
  3. package/__tests__/logBlockEvent.test.ts +37 -0
  4. package/__tests__/preInitialize.test.ts +22 -0
  5. package/__tests__/protocol-v2.test.ts +139 -27
  6. package/dist/api/BaseMethod.d.ts +7 -1
  7. package/dist/api/BaseMethod.d.ts.map +1 -1
  8. package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
  9. package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
  10. package/dist/api/GetPassphraseState.d.ts.map +1 -1
  11. package/dist/api/alephium/AlephiumSignMessage.d.ts.map +1 -1
  12. package/dist/api/alephium/AlephiumSignTransaction.d.ts.map +1 -1
  13. package/dist/api/algo/AlgoSignTransaction.d.ts.map +1 -1
  14. package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts.map +1 -1
  15. package/dist/api/aptos/AptosSignInMessage.d.ts.map +1 -1
  16. package/dist/api/aptos/AptosSignMessage.d.ts.map +1 -1
  17. package/dist/api/aptos/AptosSignTransaction.d.ts.map +1 -1
  18. package/dist/api/benfen/BenfenSignMessage.d.ts.map +1 -1
  19. package/dist/api/benfen/BenfenSignTransaction.d.ts.map +1 -1
  20. package/dist/api/btc/BTCSignMessage.d.ts.map +1 -1
  21. package/dist/api/btc/BTCSignPsbt.d.ts.map +1 -1
  22. package/dist/api/btc/BTCSignTransaction.d.ts.map +1 -1
  23. package/dist/api/cardano/CardanoSignMessage.d.ts.map +1 -1
  24. package/dist/api/cardano/CardanoSignTransaction.d.ts.map +1 -1
  25. package/dist/api/conflux/ConfluxSignMessage.d.ts.map +1 -1
  26. package/dist/api/conflux/ConfluxSignMessageCIP23.d.ts.map +1 -1
  27. package/dist/api/conflux/ConfluxSignTransaction.d.ts.map +1 -1
  28. package/dist/api/cosmos/CosmosSignTransaction.d.ts.map +1 -1
  29. package/dist/api/device/DeviceLock.d.ts.map +1 -1
  30. package/dist/api/device/PreInitialize.d.ts +6 -0
  31. package/dist/api/device/PreInitialize.d.ts.map +1 -0
  32. package/dist/api/dynex/DnxSignTransaction.d.ts.map +1 -1
  33. package/dist/api/evm/EVMSignMessage.d.ts.map +1 -1
  34. package/dist/api/evm/EVMSignMessageEIP712.d.ts.map +1 -1
  35. package/dist/api/evm/EVMSignTransaction.d.ts.map +1 -1
  36. package/dist/api/evm/EVMSignTypedData.d.ts.map +1 -1
  37. package/dist/api/filecoin/FilecoinSignTransaction.d.ts.map +1 -1
  38. package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts +2 -10
  39. package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts.map +1 -1
  40. package/dist/api/index.d.ts +1 -0
  41. package/dist/api/index.d.ts.map +1 -1
  42. package/dist/api/kaspa/KaspaSignTransaction.d.ts.map +1 -1
  43. package/dist/api/near/NearSignTransaction.d.ts.map +1 -1
  44. package/dist/api/nem/NEMSignTransaction.d.ts.map +1 -1
  45. package/dist/api/neo/NeoSignTransaction.d.ts.map +1 -1
  46. package/dist/api/nervos/NervosSignTransaction.d.ts.map +1 -1
  47. package/dist/api/nexa/NexaSignTransaction.d.ts.map +1 -1
  48. package/dist/api/nostr/NostrSignEvent.d.ts.map +1 -1
  49. package/dist/api/nostr/NostrSignSchnorr.d.ts.map +1 -1
  50. package/dist/api/polkadot/PolkadotSignTransaction.d.ts.map +1 -1
  51. package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts +1 -1
  52. package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts.map +1 -1
  53. package/dist/api/protocol-v2/FilesystemDiskControl.d.ts +1 -1
  54. package/dist/api/scdo/ScdoSignMessage.d.ts.map +1 -1
  55. package/dist/api/scdo/ScdoSignTransaction.d.ts.map +1 -1
  56. package/dist/api/solana/SolSignMessage.d.ts.map +1 -1
  57. package/dist/api/solana/SolSignOffchainMessage.d.ts.map +1 -1
  58. package/dist/api/solana/SolSignTransaction.d.ts.map +1 -1
  59. package/dist/api/starcoin/StarcoinSignMessage.d.ts.map +1 -1
  60. package/dist/api/starcoin/StarcoinSignTransaction.d.ts.map +1 -1
  61. package/dist/api/stellar/StellarSignTransaction.d.ts.map +1 -1
  62. package/dist/api/sui/SuiGetAddress.d.ts +3 -0
  63. package/dist/api/sui/SuiGetAddress.d.ts.map +1 -1
  64. package/dist/api/sui/SuiGetPublicKey.d.ts +3 -0
  65. package/dist/api/sui/SuiGetPublicKey.d.ts.map +1 -1
  66. package/dist/api/sui/SuiSignMessage.d.ts +3 -0
  67. package/dist/api/sui/SuiSignMessage.d.ts.map +1 -1
  68. package/dist/api/sui/SuiSignTransaction.d.ts +3 -0
  69. package/dist/api/sui/SuiSignTransaction.d.ts.map +1 -1
  70. package/dist/api/ton/TonGetAddress.d.ts +3 -0
  71. package/dist/api/ton/TonGetAddress.d.ts.map +1 -1
  72. package/dist/api/ton/TonSignData.d.ts +5 -0
  73. package/dist/api/ton/TonSignData.d.ts.map +1 -1
  74. package/dist/api/ton/TonSignMessage.d.ts +3 -0
  75. package/dist/api/ton/TonSignMessage.d.ts.map +1 -1
  76. package/dist/api/ton/TonSignProof.d.ts +3 -0
  77. package/dist/api/ton/TonSignProof.d.ts.map +1 -1
  78. package/dist/api/tron/TronSignMessage.d.ts.map +1 -1
  79. package/dist/api/tron/TronSignTransaction.d.ts.map +1 -1
  80. package/dist/api/xrp/XrpSignTransaction.d.ts.map +1 -1
  81. package/dist/core/PollingStateManager.d.ts +8 -0
  82. package/dist/core/PollingStateManager.d.ts.map +1 -0
  83. package/dist/core/RequestQueue.d.ts +1 -1
  84. package/dist/core/RequestQueue.d.ts.map +1 -1
  85. package/dist/core/index.d.ts.map +1 -1
  86. package/dist/device/Device.d.ts +17 -2
  87. package/dist/device/Device.d.ts.map +1 -1
  88. package/dist/events/logBlockEvent.d.ts +1 -0
  89. package/dist/events/logBlockEvent.d.ts.map +1 -1
  90. package/dist/index.d.ts +25 -5
  91. package/dist/index.js +928 -407
  92. package/dist/types/api/index.d.ts +2 -0
  93. package/dist/types/api/index.d.ts.map +1 -1
  94. package/dist/types/api/preInitialize.d.ts +3 -0
  95. package/dist/types/api/preInitialize.d.ts.map +1 -0
  96. package/dist/types/api/protocolV2.d.ts +2 -2
  97. package/dist/types/api/protocolV2.d.ts.map +1 -1
  98. package/dist/types/params.d.ts +1 -0
  99. package/dist/types/params.d.ts.map +1 -1
  100. package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
  101. package/dist/utils/patch.d.ts +1 -1
  102. package/dist/utils/patch.d.ts.map +1 -1
  103. package/package.json +4 -4
  104. package/src/api/BaseMethod.ts +82 -2
  105. package/src/api/FirmwareUpdateV3.ts +0 -4
  106. package/src/api/FirmwareUpdateV4.ts +1 -19
  107. package/src/api/GetPassphraseState.ts +4 -3
  108. package/src/api/alephium/AlephiumSignMessage.ts +1 -0
  109. package/src/api/alephium/AlephiumSignTransaction.ts +1 -0
  110. package/src/api/algo/AlgoSignTransaction.ts +1 -0
  111. package/src/api/allnetwork/AllNetworkGetAddressBase.ts +8 -0
  112. package/src/api/aptos/AptosSignInMessage.ts +1 -0
  113. package/src/api/aptos/AptosSignMessage.ts +1 -0
  114. package/src/api/aptos/AptosSignTransaction.ts +1 -0
  115. package/src/api/benfen/BenfenSignMessage.ts +1 -0
  116. package/src/api/benfen/BenfenSignTransaction.ts +1 -0
  117. package/src/api/btc/BTCSignMessage.ts +1 -0
  118. package/src/api/btc/BTCSignPsbt.ts +1 -0
  119. package/src/api/btc/BTCSignTransaction.ts +1 -0
  120. package/src/api/cardano/CardanoSignMessage.ts +1 -0
  121. package/src/api/cardano/CardanoSignTransaction.ts +1 -0
  122. package/src/api/conflux/ConfluxSignMessage.ts +1 -0
  123. package/src/api/conflux/ConfluxSignMessageCIP23.ts +1 -0
  124. package/src/api/conflux/ConfluxSignTransaction.ts +1 -0
  125. package/src/api/cosmos/CosmosSignTransaction.ts +1 -0
  126. package/src/api/device/DeviceLock.ts +1 -3
  127. package/src/api/device/PreInitialize.ts +41 -0
  128. package/src/api/dynex/DnxSignTransaction.ts +1 -0
  129. package/src/api/evm/EVMSignMessage.ts +2 -0
  130. package/src/api/evm/EVMSignMessageEIP712.ts +1 -0
  131. package/src/api/evm/EVMSignTransaction.ts +2 -0
  132. package/src/api/evm/EVMSignTypedData.ts +3 -1
  133. package/src/api/filecoin/FilecoinSignTransaction.ts +1 -0
  134. package/src/api/firmware/FirmwareUpdateBaseMethod.ts +4 -27
  135. package/src/api/index.ts +1 -0
  136. package/src/api/kaspa/KaspaSignTransaction.ts +1 -0
  137. package/src/api/near/NearSignTransaction.ts +1 -0
  138. package/src/api/nem/NEMSignTransaction.ts +1 -0
  139. package/src/api/neo/NeoSignTransaction.ts +1 -0
  140. package/src/api/nervos/NervosSignTransaction.ts +1 -0
  141. package/src/api/nexa/NexaSignTransaction.ts +2 -0
  142. package/src/api/nostr/NostrSignEvent.ts +1 -0
  143. package/src/api/nostr/NostrSignSchnorr.ts +1 -0
  144. package/src/api/polkadot/PolkadotSignTransaction.ts +1 -0
  145. package/src/api/protocol-v2/DeviceGetOnboardingStatus.ts +1 -5
  146. package/src/api/scdo/ScdoSignMessage.ts +1 -0
  147. package/src/api/scdo/ScdoSignTransaction.ts +1 -0
  148. package/src/api/solana/SolSignMessage.ts +1 -0
  149. package/src/api/solana/SolSignOffchainMessage.ts +1 -0
  150. package/src/api/solana/SolSignTransaction.ts +1 -0
  151. package/src/api/starcoin/StarcoinSignMessage.ts +1 -0
  152. package/src/api/starcoin/StarcoinSignTransaction.ts +1 -0
  153. package/src/api/stellar/StellarSignTransaction.ts +1 -0
  154. package/src/api/sui/SuiGetAddress.ts +3 -0
  155. package/src/api/sui/SuiGetPublicKey.ts +3 -0
  156. package/src/api/sui/SuiSignMessage.ts +4 -0
  157. package/src/api/sui/SuiSignTransaction.ts +4 -0
  158. package/src/api/ton/TonGetAddress.ts +3 -0
  159. package/src/api/ton/TonSignData.ts +11 -3
  160. package/src/api/ton/TonSignMessage.ts +4 -0
  161. package/src/api/ton/TonSignProof.ts +4 -0
  162. package/src/api/tron/TronSignMessage.ts +1 -0
  163. package/src/api/tron/TronSignTransaction.ts +1 -0
  164. package/src/api/xrp/XrpSignTransaction.ts +1 -0
  165. package/src/core/PollingStateManager.ts +47 -0
  166. package/src/core/RequestQueue.ts +10 -3
  167. package/src/core/index.ts +153 -34
  168. package/src/data/messages/messages-protocol-v2.json +489 -268
  169. package/src/device/Device.ts +73 -16
  170. package/src/events/logBlockEvent.ts +23 -0
  171. package/src/inject.ts +1 -1
  172. package/src/types/api/index.ts +2 -0
  173. package/src/types/api/preInitialize.ts +3 -0
  174. package/src/types/api/protocolV2.ts +2 -2
  175. package/src/types/params.ts +5 -0
  176. package/src/utils/deviceFeaturesUtils.ts +8 -17
@@ -10,6 +10,7 @@ export default class NearSignTransaction extends BaseMethod<HardwareNearSignTx>
10
10
  init() {
11
11
  this.checkDeviceId = true;
12
12
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
13
+ this.allowUsePreInitialize = true;
13
14
 
14
15
  // check payload
15
16
  validateParams(this.payload, [
@@ -230,6 +230,7 @@ export default class NEMSignTransaction extends BaseMethod<NEMSignTx> {
230
230
  init() {
231
231
  this.checkDeviceId = true;
232
232
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
233
+ this.allowUsePreInitialize = true;
233
234
 
234
235
  validateParams(this.payload, [
235
236
  { name: 'path', required: true },
@@ -11,6 +11,7 @@ export default class NeoSignTransaction extends BaseMethod<NeoSignTx> {
11
11
  init() {
12
12
  this.checkDeviceId = true;
13
13
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
14
+ this.allowUsePreInitialize = true;
14
15
  this.strictCheckDeviceSupport = true;
15
16
 
16
17
  validateParams(this.payload, [
@@ -19,6 +19,7 @@ export default class NervosSignTransaction extends BaseMethod<NervosSignTx> {
19
19
  init() {
20
20
  this.checkDeviceId = true;
21
21
  this.allowDeviceMode = [...this.allowDeviceMode];
22
+ this.allowUsePreInitialize = true;
22
23
 
23
24
  // check payload
24
25
  validateParams(this.payload, [
@@ -12,6 +12,8 @@ export default class NexaSignTransaction extends BaseMethod<NexaSignTransactionP
12
12
  hasBundle = false;
13
13
 
14
14
  init() {
15
+ this.allowUsePreInitialize = true;
16
+
15
17
  const payload = this.payload as NexaSignTransactionParams;
16
18
 
17
19
  payload.inputs.forEach(input => {
@@ -15,6 +15,7 @@ export default class NostrSignEvent extends BaseMethod<SignEvent> {
15
15
  init() {
16
16
  this.checkDeviceId = true;
17
17
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
18
+ this.allowUsePreInitialize = true;
18
19
 
19
20
  const { payload } = this;
20
21
  if (!validateEvent(payload.event)) {
@@ -11,6 +11,7 @@ export default class NostrSignSchnorr extends BaseMethod<SignSchnorr> {
11
11
  init() {
12
12
  this.checkDeviceId = true;
13
13
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
14
+ this.allowUsePreInitialize = true;
14
15
 
15
16
  const { payload } = this;
16
17
  validateParams(payload, [
@@ -13,6 +13,7 @@ export default class PolkadotSignTransaction extends BaseMethod<HardwarePolkadot
13
13
  init() {
14
14
  this.checkDeviceId = true;
15
15
  this.allowDeviceMode = [...this.allowDeviceMode];
16
+ this.allowUsePreInitialize = true;
16
17
 
17
18
  // check payload
18
19
  validateParams(this.payload, [
@@ -8,11 +8,7 @@ export default class DeviceGetOnboardingStatus extends BaseMethod {
8
8
  }
9
9
 
10
10
  async run() {
11
- const res = await this.device.commands.typedCall(
12
- 'DeviceGetOnboardingStatus',
13
- 'DeviceOnboardingStatus',
14
- {}
15
- );
11
+ const res = await this.device.commands.typedCall('GetOnboardingStatus', 'OnboardingStatus', {});
16
12
  return Promise.resolve(res.message);
17
13
  }
18
14
  }
@@ -11,6 +11,7 @@ export default class ScdoSignMessage extends BaseMethod<HardwareScdoSignMessage>
11
11
  init() {
12
12
  this.checkDeviceId = true;
13
13
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
14
+ this.allowUsePreInitialize = true;
14
15
 
15
16
  // check payload
16
17
  validateParams(this.payload, [
@@ -18,6 +18,7 @@ export default class ScdoSignTransaction extends BaseMethod<HardwareScdoSignTx>
18
18
  init() {
19
19
  this.checkDeviceId = true;
20
20
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
21
+ this.allowUsePreInitialize = true;
21
22
 
22
23
  // check payload
23
24
  validateParams(this.payload, [
@@ -10,6 +10,7 @@ export default class SolSignMessage extends BaseMethod<HardwareSolSignUnsafeMess
10
10
  init() {
11
11
  this.checkDeviceId = true;
12
12
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
13
+ this.allowUsePreInitialize = true;
13
14
 
14
15
  // check payload
15
16
  validateParams(this.payload, [
@@ -10,6 +10,7 @@ export default class SolSignOffchainMessage extends BaseMethod<HardwareSolSignOf
10
10
  init() {
11
11
  this.checkDeviceId = true;
12
12
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
13
+ this.allowUsePreInitialize = true;
13
14
 
14
15
  // check payload
15
16
  validateParams(this.payload, [
@@ -13,6 +13,7 @@ export default class SolSignTransaction extends BaseMethod<HardwareSolanaSignTx[
13
13
  init() {
14
14
  this.checkDeviceId = true;
15
15
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
16
+ this.allowUsePreInitialize = true;
16
17
 
17
18
  this.hasBundle = !!this.payload?.bundle;
18
19
  const payload = this.hasBundle ? this.payload : { bundle: [this.payload] };
@@ -10,6 +10,7 @@ export default class StarcoinSignMessage extends BaseMethod<HardwareStarcoinSign
10
10
  init() {
11
11
  this.checkDeviceId = true;
12
12
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
13
+ this.allowUsePreInitialize = true;
13
14
 
14
15
  // check payload
15
16
  validateParams(this.payload, [
@@ -10,6 +10,7 @@ export default class StarcoinSignTransaction extends BaseMethod<StarcoinSignTx>
10
10
  init() {
11
11
  this.checkDeviceId = true;
12
12
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
13
+ this.allowUsePreInitialize = true;
13
14
 
14
15
  // check payload
15
16
  validateParams(this.payload, [
@@ -231,6 +231,7 @@ export default class StellarSignTransaction extends BaseMethod<HardwareStellarSi
231
231
  init() {
232
232
  this.checkDeviceId = true;
233
233
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
234
+ this.allowUsePreInitialize = true;
234
235
 
235
236
  // check payload
236
237
  validateParams(this.payload, [
@@ -49,6 +49,9 @@ export default class SuiGetAddress extends BaseMethod<HardwareSuiGetAddress[]> {
49
49
 
50
50
  getVersionRange() {
51
51
  return {
52
+ pro2: {
53
+ min: '0.0.0',
54
+ },
52
55
  model_mini: {
53
56
  min: '3.0.0',
54
57
  },
@@ -40,6 +40,9 @@ export default class SuiGetPublicKey extends BaseMethod<any> {
40
40
 
41
41
  getVersionRange() {
42
42
  return {
43
+ pro2: {
44
+ min: '0.0.0',
45
+ },
43
46
  model_mini: {
44
47
  min: '3.0.0',
45
48
  },
@@ -10,6 +10,7 @@ export default class SuiSignMessage extends BaseMethod<HardwareSuiSignMessage> {
10
10
  init() {
11
11
  this.checkDeviceId = true;
12
12
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
13
+ this.allowUsePreInitialize = true;
13
14
 
14
15
  // check payload
15
16
  validateParams(this.payload, [
@@ -29,6 +30,9 @@ export default class SuiSignMessage extends BaseMethod<HardwareSuiSignMessage> {
29
30
 
30
31
  getVersionRange() {
31
32
  return {
33
+ pro2: {
34
+ min: '0.0.0',
35
+ },
32
36
  model_mini: {
33
37
  min: '3.4.0',
34
38
  },
@@ -19,6 +19,7 @@ export default class SuiSignTransaction extends BaseMethod<SuiSignTx> {
19
19
  init() {
20
20
  this.checkDeviceId = true;
21
21
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
22
+ this.allowUsePreInitialize = true;
22
23
 
23
24
  // check payload
24
25
  validateParams(this.payload, [
@@ -39,6 +40,9 @@ export default class SuiSignTransaction extends BaseMethod<SuiSignTx> {
39
40
 
40
41
  getVersionRange() {
41
42
  return {
43
+ pro2: {
44
+ min: '0.0.0',
45
+ },
42
46
  model_mini: {
43
47
  min: '3.0.0',
44
48
  },
@@ -57,6 +57,9 @@ export default class TonGetAddress extends BaseMethod<HardwareTonGetAddress[]> {
57
57
 
58
58
  getVersionRange() {
59
59
  return {
60
+ pro2: {
61
+ min: '0.0.0',
62
+ },
60
63
  model_touch: {
61
64
  min: '4.10.0',
62
65
  },
@@ -9,12 +9,12 @@ import type { TonSignDataParams } from '../../types/api/tonSignData';
9
9
 
10
10
  export default class TonSignData extends BaseMethod<HardwareTonSignData> {
11
11
  init() {
12
- // Keep strict-check off until the firmware release that ships TonSignData
13
- // is decided we don't yet know the min versions for touch/classic1s.
14
- // Flip back to true and add getVersionRange() once those numbers land.
12
+ // Keep strict-check off for touch/classic1s until their firmware release
13
+ // versions are decided. Pro2 is explicitly allowed by getVersionRange().
15
14
  this.strictCheckDeviceSupport = false;
16
15
  this.checkDeviceId = true;
17
16
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
17
+ this.allowUsePreInitialize = true;
18
18
 
19
19
  validateParams(this.payload, [
20
20
  { name: 'path', required: true },
@@ -50,6 +50,14 @@ export default class TonSignData extends BaseMethod<HardwareTonSignData> {
50
50
  };
51
51
  }
52
52
 
53
+ getVersionRange() {
54
+ return {
55
+ pro2: {
56
+ min: '0.0.0',
57
+ },
58
+ };
59
+ }
60
+
53
61
  async run() {
54
62
  const res = await this.device.commands.typedCall('TonSignData', 'TonSignedData', {
55
63
  ...this.params,
@@ -26,6 +26,7 @@ export default class TonSignMessage extends BaseMethod<HardwareTonSignMessage> {
26
26
  this.strictCheckDeviceSupport = true;
27
27
  this.checkDeviceId = true;
28
28
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
29
+ this.allowUsePreInitialize = true;
29
30
 
30
31
  // init params
31
32
  validateParams(this.payload, [
@@ -85,6 +86,9 @@ export default class TonSignMessage extends BaseMethod<HardwareTonSignMessage> {
85
86
 
86
87
  getVersionRange() {
87
88
  return {
89
+ pro2: {
90
+ min: '0.0.0',
91
+ },
88
92
  model_touch: {
89
93
  min: '4.10.0',
90
94
  },
@@ -11,6 +11,7 @@ export default class TonSignProof extends BaseMethod<HardwareTonSignProof> {
11
11
  this.strictCheckDeviceSupport = true;
12
12
  this.checkDeviceId = true;
13
13
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
14
+ this.allowUsePreInitialize = true;
14
15
 
15
16
  // init params
16
17
  validateParams(this.payload, [
@@ -43,6 +44,9 @@ export default class TonSignProof extends BaseMethod<HardwareTonSignProof> {
43
44
 
44
45
  getVersionRange() {
45
46
  return {
47
+ pro2: {
48
+ min: '0.0.0',
49
+ },
46
50
  model_touch: {
47
51
  min: '4.10.0',
48
52
  },
@@ -14,6 +14,7 @@ export default class TronSignMessage extends BaseMethod<HardwareTronSignMessage>
14
14
  init() {
15
15
  this.checkDeviceId = true;
16
16
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
17
+ this.allowUsePreInitialize = true;
17
18
 
18
19
  // check payload
19
20
  validateParams(this.payload, [
@@ -123,6 +123,7 @@ export default class TronSignTransaction extends BaseMethod<TronSignTx> {
123
123
  init() {
124
124
  this.checkDeviceId = true;
125
125
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
126
+ this.allowUsePreInitialize = true;
126
127
 
127
128
  // check payload
128
129
  validateParams(this.payload, [
@@ -11,6 +11,7 @@ export default class XrpGetAddress extends BaseMethod<XrpSignTransactionParams>
11
11
  init() {
12
12
  this.checkDeviceId = true;
13
13
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
14
+ this.allowUsePreInitialize = true;
14
15
 
15
16
  const { payload } = this;
16
17
  validateParams(payload, [
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Manages polling state for device connection attempts.
3
+ *
4
+ * Polling is isolated by connectId (device), so:
5
+ * - New request for device A only stops device A's previous polling
6
+ * - Device B's polling is unaffected
7
+ */
8
+ export class PollingStateManager {
9
+ // connectId -> current polling ID
10
+ private activePolls = new Map<string, number>();
11
+
12
+ /**
13
+ * Start a new polling session for a device.
14
+ * Automatically stops the previous polling for the same device.
15
+ * @param connectId - Device identifier (use empty string for USB without connectId)
16
+ * @returns The new polling ID
17
+ */
18
+ start(connectId: string): number {
19
+ const currentId = (this.activePolls.get(connectId) ?? 0) + 1;
20
+ this.activePolls.set(connectId, currentId);
21
+ return currentId;
22
+ }
23
+
24
+ /**
25
+ * Check if a polling session is still active.
26
+ * @param connectId - Device identifier
27
+ * @param pollingId - The polling ID to check
28
+ */
29
+ isActive(connectId: string, pollingId: number): boolean {
30
+ return this.activePolls.get(connectId) === pollingId;
31
+ }
32
+
33
+ /**
34
+ * Stop polling for a specific device.
35
+ * @param connectId - Device identifier
36
+ */
37
+ stop(connectId: string): void {
38
+ this.activePolls.delete(connectId);
39
+ }
40
+
41
+ /**
42
+ * Stop all active polling sessions.
43
+ */
44
+ stopAll(): void {
45
+ this.activePolls.clear();
46
+ }
47
+ }
@@ -113,13 +113,20 @@ export default class RequestQueue {
113
113
 
114
114
  callbackPromise.promise.finally(() => {
115
115
  Log.debug(`Callback task completed for connectId: ${connectId}`);
116
- this.pendingCallbackTasks.delete(connectId);
116
+ // Delete by identity so a newer task that replaced this slot isn't orphaned.
117
+ if (this.pendingCallbackTasks.get(connectId) === callbackPromise) {
118
+ this.pendingCallbackTasks.delete(connectId);
119
+ }
117
120
  });
118
121
  }
119
122
 
120
- public async waitForPendingCallbackTasks(connectId: string): Promise<void> {
123
+ public async waitForPendingCallbackTasks(
124
+ connectId: string,
125
+ exceptTask?: Deferred<void>
126
+ ): Promise<void> {
121
127
  const pendingTask = this.pendingCallbackTasks.get(connectId);
122
- if (pendingTask) {
128
+ // Skip only the caller's own task (self-wait); a different one is still awaited.
129
+ if (pendingTask && pendingTask !== exceptTask) {
123
130
  Log.debug(`Waiting for pending callback task to complete for connectId: ${connectId}`);
124
131
  await pendingTask.promise;
125
132
  }