@onekeyfe/hd-core 1.2.0-alpha.66 → 1.2.0-alpha.67

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 (315) hide show
  1. package/__tests__/AllNetworkGetAddressBase.tracing.test.ts +0 -313
  2. package/__tests__/DeviceCommands.test.ts +13 -59
  3. package/__tests__/DeviceEventRegistration.test.ts +0 -6
  4. package/__tests__/check-all-firmware-release-protocol-v2.test.ts +3 -198
  5. package/__tests__/connectSettings.test.ts +47 -5
  6. package/__tests__/device-initialize-timeout.test.ts +56 -0
  7. package/__tests__/device-lifecycle-events.test.ts +3 -105
  8. package/__tests__/device-pool-state.test.ts +0 -22
  9. package/__tests__/device-settings.test.ts +18 -39
  10. package/__tests__/device-state-contract.test.ts +0 -1
  11. package/__tests__/device-state-mapper.test.ts +1 -13
  12. package/__tests__/device-utils.test.ts +1 -48
  13. package/__tests__/deviceSettings.test.ts +1 -11
  14. package/__tests__/firmware-update/check-all-firmware-release.test.ts +175 -0
  15. package/__tests__/firmware-update/device-update-bootloader.test.ts +87 -0
  16. package/__tests__/firmware-update/firmware-artifact-source.test.ts +119 -0
  17. package/__tests__/firmware-update/firmware-host-binding.test.ts +70 -0
  18. package/__tests__/firmware-update/firmware-preparation-error.test.ts +27 -0
  19. package/__tests__/firmware-update/firmware-update-bootloader-poll.test.ts +200 -0
  20. package/__tests__/firmware-update/firmware-update-capabilities.test.ts +13 -0
  21. package/__tests__/firmware-update/firmware-update-plan-bootloader-identity.test.ts +394 -0
  22. package/__tests__/firmware-update/firmware-update-plan.test.ts +593 -0
  23. package/__tests__/firmware-update/firmware-update-prepared-plan.test.ts +231 -0
  24. package/__tests__/firmware-update/firmware-update-v2-download-before-boot.test.ts +59 -31
  25. package/__tests__/firmware-update/firmware-update-v3-reconnect.test.ts +58 -0
  26. package/__tests__/firmware-update/firmware-upload-source.test.ts +70 -0
  27. package/__tests__/get-device-state.test.ts +12 -132
  28. package/__tests__/homescreen.test.ts +1 -41
  29. package/__tests__/kaspa-use-tweak-pro2.test.ts +2 -2
  30. package/__tests__/kaspaSignTransaction.test.ts +26 -3
  31. package/__tests__/logBlockEvent.test.ts +1 -1
  32. package/__tests__/method-protocol-support.test.ts +0 -19
  33. package/__tests__/open-wallet-session.test.ts +37 -568
  34. package/__tests__/protocol-v2-unlock-policy.test.ts +37 -300
  35. package/__tests__/protocol-v2.test.ts +1153 -1458
  36. package/__tests__/protocolV2FileWrite.test.ts +0 -152
  37. package/__tests__/protocolV2UiInteraction.test.ts +0 -63
  38. package/__tests__/public-pro2-api-boundary.test.ts +0 -1
  39. package/__tests__/search-devices.test.ts +3 -12
  40. package/__tests__/tron-sign-message-init.test.ts +2 -2
  41. package/dist/api/BaseMethod.d.ts +1 -3
  42. package/dist/api/BaseMethod.d.ts.map +1 -1
  43. package/dist/api/CheckAllFirmwareRelease.d.ts +1 -2
  44. package/dist/api/CheckAllFirmwareRelease.d.ts.map +1 -1
  45. package/dist/api/FirmwareUpdate.d.ts.map +1 -1
  46. package/dist/api/FirmwareUpdateV2.d.ts +10 -0
  47. package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
  48. package/dist/api/FirmwareUpdateV3.d.ts +7 -3
  49. package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
  50. package/dist/api/FirmwareUpdateV4.d.ts +27 -13
  51. package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
  52. package/dist/api/GetPassphraseState.d.ts.map +1 -1
  53. package/dist/api/OpenWalletSession.d.ts.map +1 -1
  54. package/dist/api/SearchDevices.d.ts.map +1 -1
  55. package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts.map +1 -1
  56. package/dist/api/device/DeviceSettings.d.ts.map +1 -1
  57. package/dist/api/device/DeviceUnlock.d.ts +2 -2
  58. package/dist/api/device/DeviceUnlock.d.ts.map +1 -1
  59. package/dist/api/device/DeviceUpdateBootloader.d.ts +5 -1
  60. package/dist/api/device/DeviceUpdateBootloader.d.ts.map +1 -1
  61. package/dist/api/firmware/FirmwareArtifactSource.d.ts +25 -0
  62. package/dist/api/firmware/FirmwareArtifactSource.d.ts.map +1 -0
  63. package/dist/api/firmware/FirmwareHostBinding.d.ts +6 -0
  64. package/dist/api/firmware/FirmwareHostBinding.d.ts.map +1 -0
  65. package/dist/api/firmware/FirmwarePreparationError.d.ts +3 -0
  66. package/dist/api/firmware/FirmwarePreparationError.d.ts.map +1 -0
  67. package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts +11 -4
  68. package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts.map +1 -1
  69. package/dist/api/firmware/FirmwareUpdateCapabilities.d.ts +3 -0
  70. package/dist/api/firmware/FirmwareUpdateCapabilities.d.ts.map +1 -0
  71. package/dist/api/firmware/FirmwareUpdatePlan.d.ts +25 -0
  72. package/dist/api/firmware/FirmwareUpdatePlan.d.ts.map +1 -0
  73. package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts +32 -0
  74. package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts.map +1 -0
  75. package/dist/api/firmware/getBinary.d.ts +7 -0
  76. package/dist/api/firmware/getBinary.d.ts.map +1 -1
  77. package/dist/api/firmware/progressThrottle.d.ts +3 -0
  78. package/dist/api/firmware/progressThrottle.d.ts.map +1 -0
  79. package/dist/api/firmware/updateBootloader.d.ts +2 -0
  80. package/dist/api/firmware/updateBootloader.d.ts.map +1 -1
  81. package/dist/api/firmware/uploadFirmware.d.ts +9 -1
  82. package/dist/api/firmware/uploadFirmware.d.ts.map +1 -1
  83. package/dist/api/helpers/protocolV2FileWrite.d.ts +0 -9
  84. package/dist/api/helpers/protocolV2FileWrite.d.ts.map +1 -1
  85. package/dist/api/index.d.ts +0 -2
  86. package/dist/api/index.d.ts.map +1 -1
  87. package/dist/api/kaspa/KaspaGetAddress.d.ts +1 -1
  88. package/dist/api/kaspa/KaspaSignTransaction.d.ts +1 -1
  89. package/dist/api/kaspa/KaspaSignTransaction.d.ts.map +1 -1
  90. package/dist/api/polkadot/PolkadotGetAddress.d.ts +1 -1
  91. package/dist/api/polkadot/networks.d.ts +1 -1
  92. package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts.map +1 -1
  93. package/dist/api/protocol-v2/helpers.d.ts.map +1 -1
  94. package/dist/api/solana/SolSignMessage.d.ts +1 -1
  95. package/dist/api/solana/SolSignOffchainMessage.d.ts +1 -1
  96. package/dist/api/solana/SolSignTransaction.d.ts +2 -2
  97. package/dist/api/stellar/StellarSignTransaction.d.ts +1 -1
  98. package/dist/api/sui/SuiGetAddress.d.ts +1 -1
  99. package/dist/api/sui/SuiGetPublicKey.d.ts +1 -1
  100. package/dist/api/sui/SuiSignMessage.d.ts +1 -1
  101. package/dist/api/sui/SuiSignTransaction.d.ts +1 -1
  102. package/dist/api/ton/TonGetAddress.d.ts +1 -1
  103. package/dist/api/ton/TonSignMessage.d.ts +1 -1
  104. package/dist/api/ton/TonSignProof.d.ts +1 -1
  105. package/dist/api/tron/TronSignMessage.d.ts +2 -2
  106. package/dist/api/tron/TronSignTransaction.d.ts +1 -1
  107. package/dist/core/deviceEventRegistration.d.ts +0 -2
  108. package/dist/core/deviceEventRegistration.d.ts.map +1 -1
  109. package/dist/core/index.d.ts.map +1 -1
  110. package/dist/data-manager/DataManager.d.ts +4 -9
  111. package/dist/data-manager/DataManager.d.ts.map +1 -1
  112. package/dist/data-manager/TransportManager.d.ts.map +1 -1
  113. package/dist/data-manager/connectSettings.d.ts.map +1 -1
  114. package/dist/device/Device.d.ts +6 -29
  115. package/dist/device/Device.d.ts.map +1 -1
  116. package/dist/device/DeviceCommands.d.ts +4 -4
  117. package/dist/device/DeviceCommands.d.ts.map +1 -1
  118. package/dist/device/DeviceConnector.d.ts +1 -2
  119. package/dist/device/DeviceConnector.d.ts.map +1 -1
  120. package/dist/device/DevicePool.d.ts.map +1 -1
  121. package/dist/deviceProfile/protocolV2DeviceIdentity.d.ts.map +1 -1
  122. package/dist/events/device.d.ts +0 -4
  123. package/dist/events/device.d.ts.map +1 -1
  124. package/dist/events/logBlockEvent.d.ts.map +1 -1
  125. package/dist/events/ui-promise.d.ts +2 -4
  126. package/dist/events/ui-promise.d.ts.map +1 -1
  127. package/dist/events/ui-request.d.ts +2 -31
  128. package/dist/events/ui-request.d.ts.map +1 -1
  129. package/dist/events/ui-response.d.ts +2 -10
  130. package/dist/events/ui-response.d.ts.map +1 -1
  131. package/dist/index.d.ts +247 -243
  132. package/dist/index.d.ts.map +1 -1
  133. package/dist/index.js +3773 -3054
  134. package/dist/inject.d.ts +1 -6
  135. package/dist/inject.d.ts.map +1 -1
  136. package/dist/lowLevelInject.d.ts.map +1 -1
  137. package/dist/protocols/protocol-v2/features.d.ts +4 -0
  138. package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
  139. package/dist/protocols/protocol-v2/firmware.d.ts.map +1 -1
  140. package/dist/protocols/protocol-v2/lockedError.d.ts +2 -0
  141. package/dist/protocols/protocol-v2/lockedError.d.ts.map +1 -0
  142. package/dist/protocols/protocol-v2/uiInteraction.d.ts +4 -7
  143. package/dist/protocols/protocol-v2/uiInteraction.d.ts.map +1 -1
  144. package/dist/protocols/protocol-v2/unlockPolicy.d.ts +3 -1
  145. package/dist/protocols/protocol-v2/unlockPolicy.d.ts.map +1 -1
  146. package/dist/protocols/protocol-v2/unlockRetry.d.ts +10 -0
  147. package/dist/protocols/protocol-v2/unlockRetry.d.ts.map +1 -0
  148. package/dist/protocols/protocol-v2/walletSession.d.ts +1 -6
  149. package/dist/protocols/protocol-v2/walletSession.d.ts.map +1 -1
  150. package/dist/topLevelInject.d.ts.map +1 -1
  151. package/dist/types/api/checkAllFirmwareRelease.d.ts +5 -3
  152. package/dist/types/api/checkAllFirmwareRelease.d.ts.map +1 -1
  153. package/dist/types/api/deviceUnlock.d.ts +1 -5
  154. package/dist/types/api/deviceUnlock.d.ts.map +1 -1
  155. package/dist/types/api/deviceUpdateBootloader.d.ts +6 -0
  156. package/dist/types/api/deviceUpdateBootloader.d.ts.map +1 -1
  157. package/dist/types/api/export.d.ts +4 -2
  158. package/dist/types/api/export.d.ts.map +1 -1
  159. package/dist/types/api/firmwareUpdate.d.ts +70 -4
  160. package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
  161. package/dist/types/api/firmwareUpdateCapabilities.d.ts +9 -0
  162. package/dist/types/api/firmwareUpdateCapabilities.d.ts.map +1 -0
  163. package/dist/types/api/firmwareUpdatePlan.d.ts +28 -0
  164. package/dist/types/api/firmwareUpdatePlan.d.ts.map +1 -0
  165. package/dist/types/api/firmwareUpdatePreparedPlan.d.ts +42 -0
  166. package/dist/types/api/firmwareUpdatePreparedPlan.d.ts.map +1 -0
  167. package/dist/types/api/index.d.ts +10 -7
  168. package/dist/types/api/index.d.ts.map +1 -1
  169. package/dist/types/api/protocolV2.d.ts +0 -3
  170. package/dist/types/api/protocolV2.d.ts.map +1 -1
  171. package/dist/types/device.d.ts +2 -2
  172. package/dist/types/device.d.ts.map +1 -1
  173. package/dist/types/params.d.ts +0 -1
  174. package/dist/types/params.d.ts.map +1 -1
  175. package/dist/types/settings.d.ts +21 -38
  176. package/dist/types/settings.d.ts.map +1 -1
  177. package/dist/utils/deviceFeaturesCompat.d.ts +1 -0
  178. package/dist/utils/deviceFeaturesCompat.d.ts.map +1 -1
  179. package/dist/utils/deviceFeaturesUtils.d.ts +0 -4
  180. package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
  181. package/dist/utils/deviceInfoUtils.d.ts.map +1 -1
  182. package/dist/utils/deviceSettings.d.ts.map +1 -1
  183. package/dist/utils/homescreen.d.ts +0 -4
  184. package/dist/utils/homescreen.d.ts.map +1 -1
  185. package/dist/utils/index.d.ts +1 -1
  186. package/dist/utils/index.d.ts.map +1 -1
  187. package/dist/utils/patch.d.ts +1 -1
  188. package/dist/utils/patch.d.ts.map +1 -1
  189. package/dist/utils/pro2Wallpaper.d.ts +0 -10
  190. package/dist/utils/pro2Wallpaper.d.ts.map +1 -1
  191. package/package.json +4 -4
  192. package/src/api/BaseMethod.ts +10 -8
  193. package/src/api/CheckAllFirmwareRelease.ts +60 -59
  194. package/src/api/FirmwareUpdate.ts +15 -7
  195. package/src/api/FirmwareUpdateV2.ts +298 -126
  196. package/src/api/FirmwareUpdateV3.ts +265 -63
  197. package/src/api/FirmwareUpdateV4.ts +1017 -602
  198. package/src/api/GetPassphraseState.ts +1 -7
  199. package/src/api/OpenWalletSession.ts +17 -71
  200. package/src/api/SearchDevices.ts +1 -3
  201. package/src/api/allnetwork/AllNetworkGetAddress.ts +21 -21
  202. package/src/api/allnetwork/AllNetworkGetAddressBase.ts +11 -36
  203. package/src/api/device/DeviceSettings.ts +4 -5
  204. package/src/api/device/DeviceUnlock.ts +3 -8
  205. package/src/api/device/DeviceUpdateBootloader.ts +125 -6
  206. package/src/api/firmware/FirmwareArtifactSource.ts +278 -0
  207. package/src/api/firmware/FirmwareHostBinding.ts +100 -0
  208. package/src/api/firmware/FirmwarePreparationError.ts +12 -0
  209. package/src/api/firmware/FirmwareUpdateBaseMethod.ts +83 -27
  210. package/src/api/firmware/FirmwareUpdateCapabilities.ts +9 -0
  211. package/src/api/firmware/FirmwareUpdatePlan.ts +772 -0
  212. package/src/api/firmware/FirmwareUpdatePreparedPlan.ts +449 -0
  213. package/src/api/firmware/progressThrottle.ts +44 -0
  214. package/src/api/firmware/updateBootloader.ts +19 -4
  215. package/src/api/firmware/uploadFirmware.ts +144 -39
  216. package/src/api/helpers/protocolV2FileWrite.ts +63 -202
  217. package/src/api/index.ts +0 -2
  218. package/src/api/kaspa/KaspaGetAddress.ts +1 -1
  219. package/src/api/kaspa/KaspaSignTransaction.ts +13 -2
  220. package/src/api/polkadot/networks.ts +3 -3
  221. package/src/api/protocol-v2/ProtocolInfoRequest.ts +1 -3
  222. package/src/api/protocol-v2/helpers.ts +1 -1
  223. package/src/api/solana/SolSignMessage.ts +1 -1
  224. package/src/api/solana/SolSignOffchainMessage.ts +1 -1
  225. package/src/api/solana/SolSignTransaction.ts +2 -2
  226. package/src/api/sui/SuiGetAddress.ts +1 -1
  227. package/src/api/sui/SuiGetPublicKey.ts +1 -1
  228. package/src/api/sui/SuiSignMessage.ts +1 -1
  229. package/src/api/sui/SuiSignTransaction.ts +1 -1
  230. package/src/api/ton/TonGetAddress.ts +1 -1
  231. package/src/api/ton/TonSignMessage.ts +1 -1
  232. package/src/api/ton/TonSignProof.ts +1 -1
  233. package/src/api/tron/TronSignMessage.ts +2 -2
  234. package/src/api/tron/TronSignTransaction.ts +1 -1
  235. package/src/core/deviceEventRegistration.ts +0 -4
  236. package/src/core/index.ts +111 -213
  237. package/src/data/messages/messages-protocol-v2.json +0 -25
  238. package/src/data-manager/DataManager.ts +41 -113
  239. package/src/data-manager/TransportManager.ts +0 -6
  240. package/src/data-manager/connectSettings.ts +11 -0
  241. package/src/device/Device.ts +49 -274
  242. package/src/device/DeviceCommands.ts +4 -31
  243. package/src/device/DeviceConnector.ts +13 -33
  244. package/src/device/DevicePool.ts +7 -21
  245. package/src/deviceProfile/buildDeviceFeatures.ts +2 -2
  246. package/src/deviceProfile/protocolV2DeviceIdentity.ts +0 -3
  247. package/src/events/device.ts +0 -4
  248. package/src/events/logBlockEvent.ts +0 -1
  249. package/src/events/ui-promise.ts +2 -4
  250. package/src/events/ui-request.ts +2 -36
  251. package/src/events/ui-response.ts +2 -12
  252. package/src/index.ts +5 -0
  253. package/src/inject.ts +24 -60
  254. package/src/lowLevelInject.ts +8 -7
  255. package/src/protocols/protocol-v2/features.ts +7 -10
  256. package/src/protocols/protocol-v2/firmware.ts +0 -2
  257. package/src/protocols/protocol-v2/lockedError.ts +10 -0
  258. package/src/protocols/protocol-v2/uiInteraction.ts +6 -46
  259. package/src/protocols/protocol-v2/unlockPolicy.ts +105 -1
  260. package/src/protocols/protocol-v2/unlockRetry.ts +109 -0
  261. package/src/protocols/protocol-v2/walletSession.ts +36 -214
  262. package/src/topLevelInject.ts +8 -7
  263. package/src/types/api/checkAllFirmwareRelease.ts +5 -3
  264. package/src/types/api/deviceUnlock.ts +1 -12
  265. package/src/types/api/deviceUpdateBootloader.ts +6 -0
  266. package/src/types/api/export.ts +18 -1
  267. package/src/types/api/firmwareUpdate.ts +78 -6
  268. package/src/types/api/firmwareUpdateCapabilities.ts +9 -0
  269. package/src/types/api/firmwareUpdatePlan.ts +38 -0
  270. package/src/types/api/firmwareUpdatePreparedPlan.ts +53 -0
  271. package/src/types/api/index.ts +14 -13
  272. package/src/types/api/protocolV2.ts +0 -13
  273. package/src/types/device.ts +3 -15
  274. package/src/types/params.ts +1 -7
  275. package/src/types/settings.ts +22 -60
  276. package/src/utils/deviceFeaturesCompat.ts +6 -5
  277. package/src/utils/deviceFeaturesUtils.ts +3 -14
  278. package/src/utils/deviceInfoUtils.ts +0 -2
  279. package/src/utils/deviceSettings.ts +0 -3
  280. package/src/utils/homescreen.ts +6 -32
  281. package/src/utils/index.ts +1 -6
  282. package/src/utils/pro2Wallpaper.ts +8 -35
  283. package/__tests__/core-initialization.test.ts +0 -23
  284. package/__tests__/device-connector-protocol.test.ts +0 -81
  285. package/__tests__/deviceUploadNft.test.ts +0 -316
  286. package/__tests__/pro2Nft.test.ts +0 -108
  287. package/__tests__/protocol-binding.test.ts +0 -89
  288. package/__tests__/protocol-v2-resources.test.ts +0 -340
  289. package/__tests__/protocol-v2-ui-lifecycle.test.ts +0 -91
  290. package/__tests__/uiProgressThrottle.test.ts +0 -74
  291. package/__tests__/uiPromiseRegistry.test.ts +0 -115
  292. package/dist/api/DetectDeviceConnectProtocol.d.ts +0 -7
  293. package/dist/api/DetectDeviceConnectProtocol.d.ts.map +0 -1
  294. package/dist/api/protocol-v2/DeviceUploadNft.d.ts +0 -31
  295. package/dist/api/protocol-v2/DeviceUploadNft.d.ts.map +0 -1
  296. package/dist/core/uiPromiseRegistry.d.ts +0 -6
  297. package/dist/core/uiPromiseRegistry.d.ts.map +0 -1
  298. package/dist/protocols/protocol-v2/resources.d.ts +0 -30
  299. package/dist/protocols/protocol-v2/resources.d.ts.map +0 -1
  300. package/dist/protocols/protocol-v2/unlockPolicyRunner.d.ts +0 -22
  301. package/dist/protocols/protocol-v2/unlockPolicyRunner.d.ts.map +0 -1
  302. package/dist/types/api/detectDeviceConnectProtocol.d.ts +0 -4
  303. package/dist/types/api/detectDeviceConnectProtocol.d.ts.map +0 -1
  304. package/dist/utils/pro2Nft.d.ts +0 -31
  305. package/dist/utils/pro2Nft.d.ts.map +0 -1
  306. package/dist/utils/uiProgressThrottle.d.ts +0 -3
  307. package/dist/utils/uiProgressThrottle.d.ts.map +0 -1
  308. package/src/api/DetectDeviceConnectProtocol.ts +0 -18
  309. package/src/api/protocol-v2/DeviceUploadNft.ts +0 -197
  310. package/src/core/uiPromiseRegistry.ts +0 -63
  311. package/src/protocols/protocol-v2/resources.ts +0 -390
  312. package/src/protocols/protocol-v2/unlockPolicyRunner.ts +0 -131
  313. package/src/types/api/detectDeviceConnectProtocol.ts +0 -6
  314. package/src/utils/pro2Nft.ts +0 -142
  315. package/src/utils/uiProgressThrottle.ts +0 -63
@@ -1,4 +1,4 @@
1
- import { EDeviceType, HardwareErrorCode } from '@onekeyfe/hd-shared';
1
+ import { HardwareErrorCode } from '@onekeyfe/hd-shared';
2
2
  import { DeviceType } from '@onekeyfe/hd-transport';
3
3
 
4
4
  import { Device } from '../src/device/Device';
@@ -43,70 +43,6 @@ const getProtocolV2LoaderInfo = (mode: 'bootloader' | 'romloader') => ({
43
43
  });
44
44
 
45
45
  describe('getDeviceState', () => {
46
- test('coalesces concurrent Protocol V2 runtime-context negotiation', async () => {
47
- let resolveProtocolInfo:
48
- | ((value: { message: typeof protocolV2ApplicationInfo }) => void)
49
- | undefined;
50
- const typedCall = jest.fn(
51
- () =>
52
- new Promise<{ message: typeof protocolV2ApplicationInfo }>(resolve => {
53
- resolveProtocolInfo = resolve;
54
- })
55
- );
56
- const device = createV2Device(typedCall);
57
-
58
- const first = device.ensureProtocolV2RuntimeContext();
59
- const second = device.ensureProtocolV2RuntimeContext();
60
- resolveProtocolInfo?.({ message: protocolV2ApplicationInfo });
61
-
62
- await expect(Promise.all([first, second])).resolves.toEqual([
63
- protocolV2ApplicationInfo,
64
- protocolV2ApplicationInfo,
65
- ]);
66
- expect(typedCall).toHaveBeenCalledTimes(1);
67
- expect(typedCall).toHaveBeenCalledWith('ProtocolInfoRequest', 'ProtocolInfo', {
68
- eventless_wallet_session: true,
69
- });
70
- });
71
-
72
- test('renegotiates Protocol V2 runtime context after transport disconnect', async () => {
73
- const typedCall = jest.fn().mockResolvedValue({ message: protocolV2ApplicationInfo });
74
- const device = createV2Device(typedCall);
75
-
76
- await device.ensureProtocolV2RuntimeContext();
77
- await device.ensureProtocolV2RuntimeContext();
78
- device.markTransportDisconnected();
79
- await device.ensureProtocolV2RuntimeContext();
80
-
81
- expect(typedCall).toHaveBeenCalledTimes(2);
82
- });
83
-
84
- test('rejects every waiter when runtime-context negotiation is invalidated', async () => {
85
- let resolveProtocolInfo:
86
- | ((value: { message: typeof protocolV2ApplicationInfo }) => void)
87
- | undefined;
88
- const typedCall = jest.fn(
89
- () =>
90
- new Promise<{ message: typeof protocolV2ApplicationInfo }>(resolve => {
91
- resolveProtocolInfo = resolve;
92
- })
93
- );
94
- const device = createV2Device(typedCall);
95
-
96
- const first = device.ensureProtocolV2RuntimeContext();
97
- const second = device.ensureProtocolV2RuntimeContext();
98
- const firstExpectation = expect(first).rejects.toMatchObject({
99
- errorCode: HardwareErrorCode.DeviceInitializeFailed,
100
- });
101
- const secondExpectation = expect(second).rejects.toMatchObject({
102
- errorCode: HardwareErrorCode.DeviceInitializeFailed,
103
- });
104
- device.markTransportDisconnected();
105
- resolveProtocolInfo?.({ message: protocolV2ApplicationInfo });
106
-
107
- await Promise.all([firstExpectation, secondExpectation]);
108
- });
109
-
110
46
  test('does not expose the internal wallet session', async () => {
111
47
  const device = createV2Device(jest.fn());
112
48
  device.updateState({ protocol: 'V2' }, 'initialize');
@@ -223,20 +159,15 @@ describe('getDeviceState', () => {
223
159
  throw new Error(`Unexpected request: ${requestType}`);
224
160
  });
225
161
  const device = createV2Device(typedCall);
226
- device.updateState(
227
- {
228
- protocol: 'V2',
229
- identity: { deviceType: EDeviceType.Pro2 },
230
- status: { mode },
231
- raw: { protocolV2ProtocolInfo: getProtocolV2LoaderInfo(mode) },
232
- },
233
- 'initialize'
234
- );
162
+ device.updateState({ protocol: 'V2', status: { mode } }, 'initialize');
235
163
 
236
164
  const state = await device.getDeviceState({ refreshSections: ['status'] });
237
165
 
238
166
  expect(state.status.mode).toBe(mode);
239
- expect(typedCall).not.toHaveBeenCalled();
167
+ expect(typedCall.mock.calls.map(call => call[0])).toEqual([
168
+ 'DeviceInfoGet',
169
+ 'ProtocolInfoRequest',
170
+ ]);
240
171
  }
241
172
  );
242
173
 
@@ -256,14 +187,7 @@ describe('getDeviceState', () => {
256
187
  return { message: { init_states: true, unlocked: true, device_id: 'device-1' } };
257
188
  });
258
189
  const device = createV2Device(typedCall);
259
- device.updateState(
260
- {
261
- protocol: 'V2',
262
- status: { mode: 'normal' },
263
- raw: { protocolV2ProtocolInfo: protocolV2ApplicationInfo },
264
- },
265
- 'initialize'
266
- );
190
+ device.updateState({ protocol: 'V2', status: { mode: 'normal' } }, 'initialize');
267
191
 
268
192
  const state = await device.getDeviceState({ refreshSections: ['status'] });
269
193
 
@@ -281,14 +205,7 @@ describe('getDeviceState', () => {
281
205
  },
282
206
  });
283
207
  const device = createV2Device(typedCall);
284
- device.updateState(
285
- {
286
- protocol: 'V2',
287
- status: { mode: 'normal' },
288
- raw: { protocolV2ProtocolInfo: protocolV2ApplicationInfo },
289
- },
290
- 'initialize'
291
- );
208
+ device.updateState({ protocol: 'V2', status: { mode: 'normal' } }, 'initialize');
292
209
  const onState = jest.fn();
293
210
  device.on(DEVICE.STATE, onState);
294
211
 
@@ -333,18 +250,13 @@ describe('getDeviceState', () => {
333
250
  throw new Error(`Unexpected request: ${requestType}`);
334
251
  });
335
252
  const device = createV2Device(typedCall);
336
- device.updateState(
337
- {
338
- protocol: 'V2',
339
- status: { mode: 'normal' },
340
- raw: { protocolV2ProtocolInfo: protocolV2ApplicationInfo },
341
- },
342
- 'initialize'
343
- );
253
+ device.updateState({ protocol: 'V2', status: { mode: 'normal' } }, 'initialize');
344
254
 
345
255
  const state = await device.getDeviceState({ refreshSections: ['status', 'settings'] });
346
256
 
347
257
  expect(typedCall.mock.calls.map(call => call[0])).toEqual([
258
+ 'DeviceInfoGet',
259
+ 'ProtocolInfoRequest',
348
260
  'DeviceStatusGet',
349
261
  'DeviceSettingsGet',
350
262
  ]);
@@ -376,11 +288,7 @@ describe('getDeviceState', () => {
376
288
  });
377
289
  const device = createV2Device(typedCall);
378
290
  device.updateState(
379
- {
380
- protocol: 'V2',
381
- status: { mode: 'normal', unlocked: true },
382
- raw: { protocolV2ProtocolInfo: protocolV2ApplicationInfo },
383
- },
291
+ { protocol: 'V2', status: { mode: 'normal', unlocked: true } },
384
292
  'initialize'
385
293
  );
386
294
 
@@ -466,34 +374,6 @@ describe('getDeviceState', () => {
466
374
  });
467
375
  });
468
376
 
469
- test.each([
470
- EDeviceType.Classic,
471
- EDeviceType.Classic1s,
472
- EDeviceType.ClassicPure,
473
- EDeviceType.Mini,
474
- ])('keeps the GetFeatures-only firmware path for %s', async deviceType => {
475
- const typedCall = jest.fn().mockResolvedValue({
476
- message: {
477
- onekey_device_type: deviceType.toUpperCase(),
478
- initialized: true,
479
- onekey_firmware_version: '3.5.0',
480
- se_ver: '1.1.0.2',
481
- },
482
- });
483
- const device = createV1Device(typedCall);
484
-
485
- const state = await device.getDeviceState({
486
- refreshSections: ['identity', 'versions', 'verification'],
487
- });
488
-
489
- expect(typedCall.mock.calls.map(call => call[0])).toEqual(['GetFeatures']);
490
- expect(state.versions).toMatchObject({
491
- firmware: '3.5.0',
492
- se: '1.1.0.2',
493
- se01: '1.1.0.2',
494
- });
495
- });
496
-
497
377
  test('does not clear Protocol V1 firmware details during a later runtime refresh', async () => {
498
378
  let getFeaturesCount = 0;
499
379
  const typedCall = jest.fn().mockImplementation((requestType: string) => {
@@ -1,6 +1,6 @@
1
1
  import { EDeviceType } from '@onekeyfe/hd-shared';
2
2
 
3
- import { getHomeScreenSize, getNftSize } from '../src/utils/homescreen';
3
+ import { getHomeScreenSize } from '../src/utils/homescreen';
4
4
 
5
5
  describe('getHomeScreenSize', () => {
6
6
  it('returns the Pro 2 wallpaper dimensions', () => {
@@ -21,44 +21,4 @@ describe('getHomeScreenSize', () => {
21
21
  })
22
22
  ).toBeUndefined();
23
23
  });
24
-
25
- it('does not reuse the wallpaper homeScreenType for Pro 2 NFT dimensions', () => {
26
- expect(
27
- getHomeScreenSize({
28
- deviceType: EDeviceType.Pro2,
29
- homeScreenType: 'Nft',
30
- thumbnail: false,
31
- })
32
- ).toEqual({ width: 604, height: 1024 });
33
- expect(
34
- getHomeScreenSize({
35
- deviceType: EDeviceType.Pro2,
36
- homeScreenType: 'Nft',
37
- thumbnail: true,
38
- })
39
- ).toBeUndefined();
40
- });
41
- });
42
-
43
- describe('getNftSize', () => {
44
- it('returns the Pro 2 NFT image and thumbnail dimensions independently', () => {
45
- expect(getNftSize({ deviceType: EDeviceType.Pro2 })).toEqual({ width: 540, height: 540 });
46
- expect(getNftSize({ deviceType: EDeviceType.Pro2, thumbnail: true })).toEqual({
47
- width: 263,
48
- height: 263,
49
- });
50
- });
51
-
52
- it('preserves the legacy NFT dimensions', () => {
53
- expect(getNftSize({ deviceType: EDeviceType.Touch })).toEqual({ width: 480, height: 800 });
54
- expect(getNftSize({ deviceType: EDeviceType.Touch, thumbnail: true })).toEqual({
55
- width: 238,
56
- height: 238,
57
- });
58
- expect(getNftSize({ deviceType: EDeviceType.Pro, thumbnail: true })).toEqual({
59
- width: 226,
60
- height: 226,
61
- radius: 40,
62
- });
63
- });
64
24
  });
@@ -6,7 +6,7 @@ jest.mock('../src/data/config', () => ({
6
6
  DEFAULT_DOMAIN: 'https://jssdk.onekey.so/1.0.0/',
7
7
  }));
8
8
 
9
- describe('Kaspa Pro2 product-family useTweak capability', () => {
9
+ describe('Kaspa Pro2 useTweak capability', () => {
10
10
  test.each([
11
11
  ['get address', KaspaGetAddress],
12
12
  ['sign transaction', KaspaSignTransaction],
@@ -14,7 +14,7 @@ describe('Kaspa Pro2 product-family useTweak capability', () => {
14
14
  const method = new Method({ id: 1, payload: {} } as never);
15
15
 
16
16
  expect(method.getUseTweakVersionRange()).toMatchObject({
17
- model_pro2: { min: '0.0.0' },
17
+ pro2: { min: '0.0.0' },
18
18
  });
19
19
  });
20
20
  });
@@ -465,7 +465,7 @@ describe('KaspaSignTransaction protocol negotiation', () => {
465
465
  expect(mockTypedCall.mock.calls[4][0]).toBe('KaspaTxAckInput');
466
466
  });
467
467
 
468
- describe('streaming error propagation', () => {
468
+ describe('previous-transaction id mismatch', () => {
469
469
  const PREV_ID = 'aa'.repeat(32);
470
470
  const withRefTxs = {
471
471
  outputs: [{ satoshis: 100000, script: SCRIPT, address: ADDRESS }],
@@ -486,7 +486,7 @@ describe('KaspaSignTransaction protocol negotiation', () => {
486
486
  )
487
487
  .mockRejectedValueOnce(error);
488
488
 
489
- it('propagates a previous-transaction id mismatch without retrying', async () => {
489
+ it('surfaces the device rejection under its own error code', async () => {
490
490
  streamThenReject(
491
491
  ERRORS.TypedError(
492
492
  HardwareErrorCode.RuntimeError,
@@ -494,9 +494,32 @@ describe('KaspaSignTransaction protocol negotiation', () => {
494
494
  )
495
495
  );
496
496
 
497
+ await expect(runMethod(withRefTxs)).rejects.toMatchObject({
498
+ errorCode: HardwareErrorCode.KaspaPrevTxIdMismatch,
499
+ });
500
+ // Never silently re-signs without refTxs.
501
+ expect(mockTypedCall).toHaveBeenCalledTimes(2);
502
+ });
503
+
504
+ it('leaves an unrelated device error untouched', async () => {
505
+ streamThenReject(
506
+ ERRORS.TypedError(
507
+ HardwareErrorCode.RuntimeError,
508
+ 'Failure_ProcessError,some other device error'
509
+ )
510
+ );
511
+
497
512
  await expect(runMethod(withRefTxs)).rejects.toMatchObject({
498
513
  errorCode: HardwareErrorCode.RuntimeError,
499
- message: expect.stringContaining('Kaspa previous transaction id mismatch'),
514
+ });
515
+ expect(mockTypedCall).toHaveBeenCalledTimes(2);
516
+ });
517
+
518
+ it('leaves user cancellation untouched', async () => {
519
+ streamThenReject(ERRORS.TypedError(HardwareErrorCode.ActionCancelled));
520
+
521
+ await expect(runMethod(withRefTxs)).rejects.toMatchObject({
522
+ errorCode: HardwareErrorCode.ActionCancelled,
500
523
  });
501
524
  expect(mockTypedCall).toHaveBeenCalledTimes(2);
502
525
  });
@@ -104,7 +104,7 @@ describe('getLogBlockLabel', () => {
104
104
  });
105
105
  });
106
106
 
107
- it.each(['deviceUploadNft', 'deviceUploadWallpaper', 'uploadPortfolio', 'fileWrite', 'fileRead'])(
107
+ it.each(['deviceUploadWallpaper', 'uploadPortfolio', 'fileWrite', 'fileRead'])(
108
108
  'keeps metadata and replaces binary payloads with their size for %s',
109
109
  method => {
110
110
  const request = { method, path: 'resource.bin', data: new Uint8Array(1024) };
@@ -1,7 +1,6 @@
1
1
  import { EFirmwareType, HardwareErrorCode } from '@onekeyfe/hd-shared';
2
2
 
3
3
  import { BaseMethod } from '../src/api/BaseMethod';
4
- import { findMethod } from '../src/api/utils';
5
4
  import BTCGetAddress from '../src/api/btc/BTCGetAddress';
6
5
  import DeviceReboot from '../src/api/protocol-v2/DeviceReboot';
7
6
  import SolGetAddress from '../src/api/solana/SolGetAddress';
@@ -21,24 +20,6 @@ class DefaultMethod extends BaseMethod {
21
20
  }
22
21
 
23
22
  describe('method protocol support', () => {
24
- test('creates a protocol detection method that returns only the current protocol', async () => {
25
- const method = findMethod({
26
- id: 6,
27
- payload: {
28
- method: 'detectDeviceConnectProtocol',
29
- connectId: 'ble-device',
30
- },
31
- } as never);
32
-
33
- method.init();
34
- (method as unknown as { device: unknown }).device = {
35
- getProtocol: () => 'V2',
36
- };
37
-
38
- expect(method.getSupportedProtocols()).toEqual(['V1', 'V2']);
39
- await expect(method.run()).resolves.toBe('V2');
40
- });
41
-
42
23
  test('defaults existing methods to Protocol V1 only', () => {
43
24
  const method = new DefaultMethod({
44
25
  id: 1,