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

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 (359) hide show
  1. package/__tests__/DeviceCommands.test.ts +99 -0
  2. package/__tests__/evmLedgerLegacySafety.test.ts +261 -0
  3. package/__tests__/evmSignTransaction.test.ts +1 -1
  4. package/__tests__/evmSignTypedData.test.ts +1 -1
  5. package/__tests__/preInitialize.test.ts +22 -0
  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 +0 -1
  9. package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
  10. package/dist/api/GetFeatures.d.ts +1 -1
  11. package/dist/api/GetOnekeyFeatures.d.ts.map +1 -1
  12. package/dist/api/GetPassphraseState.d.ts +1 -6
  13. package/dist/api/GetPassphraseState.d.ts.map +1 -1
  14. package/dist/api/SearchDevices.d.ts +1 -2
  15. package/dist/api/SearchDevices.d.ts.map +1 -1
  16. package/dist/api/alephium/AlephiumGetAddress.d.ts +6 -2
  17. package/dist/api/alephium/AlephiumGetAddress.d.ts.map +1 -1
  18. package/dist/api/alephium/AlephiumSignMessage.d.ts +5 -2
  19. package/dist/api/alephium/AlephiumSignMessage.d.ts.map +1 -1
  20. package/dist/api/alephium/AlephiumSignTransaction.d.ts +5 -2
  21. package/dist/api/alephium/AlephiumSignTransaction.d.ts.map +1 -1
  22. package/dist/api/algo/AlgoSignTransaction.d.ts.map +1 -1
  23. package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts.map +1 -1
  24. package/dist/api/aptos/AptosSignInMessage.d.ts.map +1 -1
  25. package/dist/api/aptos/AptosSignMessage.d.ts.map +1 -1
  26. package/dist/api/aptos/AptosSignTransaction.d.ts.map +1 -1
  27. package/dist/api/benfen/BenfenGetAddress.d.ts +9 -2
  28. package/dist/api/benfen/BenfenGetAddress.d.ts.map +1 -1
  29. package/dist/api/benfen/BenfenGetPublicKey.d.ts +9 -2
  30. package/dist/api/benfen/BenfenGetPublicKey.d.ts.map +1 -1
  31. package/dist/api/benfen/BenfenSignMessage.d.ts +8 -2
  32. package/dist/api/benfen/BenfenSignMessage.d.ts.map +1 -1
  33. package/dist/api/benfen/BenfenSignTransaction.d.ts +8 -2
  34. package/dist/api/benfen/BenfenSignTransaction.d.ts.map +1 -1
  35. package/dist/api/btc/BTCGetAddress.d.ts +11 -1
  36. package/dist/api/btc/BTCGetAddress.d.ts.map +1 -1
  37. package/dist/api/btc/BTCGetPublicKey.d.ts +11 -1
  38. package/dist/api/btc/BTCGetPublicKey.d.ts.map +1 -1
  39. package/dist/api/btc/BTCSignMessage.d.ts +15 -1
  40. package/dist/api/btc/BTCSignMessage.d.ts.map +1 -1
  41. package/dist/api/btc/BTCSignPsbt.d.ts.map +1 -1
  42. package/dist/api/btc/BTCSignTransaction.d.ts +11 -1
  43. package/dist/api/btc/BTCSignTransaction.d.ts.map +1 -1
  44. package/dist/api/btc/BTCVerifyMessage.d.ts +11 -1
  45. package/dist/api/btc/BTCVerifyMessage.d.ts.map +1 -1
  46. package/dist/api/btc/helpers/versionLimit.d.ts +11 -2
  47. package/dist/api/btc/helpers/versionLimit.d.ts.map +1 -1
  48. package/dist/api/cardano/CardanoSignMessage.d.ts.map +1 -1
  49. package/dist/api/cardano/CardanoSignTransaction.d.ts.map +1 -1
  50. package/dist/api/conflux/ConfluxSignMessage.d.ts.map +1 -1
  51. package/dist/api/conflux/ConfluxSignMessageCIP23.d.ts.map +1 -1
  52. package/dist/api/conflux/ConfluxSignTransaction.d.ts.map +1 -1
  53. package/dist/api/cosmos/CosmosSignTransaction.d.ts.map +1 -1
  54. package/dist/api/device/DeviceRebootToBoardloader.d.ts +1 -1
  55. package/dist/api/device/DeviceRebootToBoardloader.d.ts.map +1 -1
  56. package/dist/api/device/DeviceRebootToBootloader.d.ts.map +1 -1
  57. package/dist/api/device/PreInitialize.d.ts +6 -0
  58. package/dist/api/device/PreInitialize.d.ts.map +1 -0
  59. package/dist/api/dynex/DnxGetAddress.d.ts.map +1 -1
  60. package/dist/api/dynex/DnxSignTransaction.d.ts.map +1 -1
  61. package/dist/api/evm/EVMSignMessage.d.ts.map +1 -1
  62. package/dist/api/evm/EVMSignMessageEIP712.d.ts +8 -2
  63. package/dist/api/evm/EVMSignMessageEIP712.d.ts.map +1 -1
  64. package/dist/api/evm/EVMSignTransaction.d.ts.map +1 -1
  65. package/dist/api/evm/EVMSignTypedData.d.ts.map +1 -1
  66. package/dist/api/evm/latest/signTypedData.d.ts +1 -1
  67. package/dist/api/evm/latest/signTypedData.d.ts.map +1 -1
  68. package/dist/api/evm/legacyV1/signTypedData.d.ts +1 -1
  69. package/dist/api/evm/legacyV1/signTypedData.d.ts.map +1 -1
  70. package/dist/api/filecoin/FilecoinSignTransaction.d.ts.map +1 -1
  71. package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts +2 -10
  72. package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts.map +1 -1
  73. package/dist/api/index.d.ts +1 -28
  74. package/dist/api/index.d.ts.map +1 -1
  75. package/dist/api/kaspa/KaspaSignTransaction.d.ts.map +1 -1
  76. package/dist/api/near/NearSignTransaction.d.ts.map +1 -1
  77. package/dist/api/nem/NEMSignTransaction.d.ts.map +1 -1
  78. package/dist/api/neo/NeoGetAddress.d.ts +8 -2
  79. package/dist/api/neo/NeoGetAddress.d.ts.map +1 -1
  80. package/dist/api/neo/NeoSignTransaction.d.ts +8 -2
  81. package/dist/api/neo/NeoSignTransaction.d.ts.map +1 -1
  82. package/dist/api/nervos/NervosGetAddress.d.ts +9 -2
  83. package/dist/api/nervos/NervosGetAddress.d.ts.map +1 -1
  84. package/dist/api/nervos/NervosSignTransaction.d.ts +9 -2
  85. package/dist/api/nervos/NervosSignTransaction.d.ts.map +1 -1
  86. package/dist/api/nexa/NexaGetAddress.d.ts +8 -2
  87. package/dist/api/nexa/NexaGetAddress.d.ts.map +1 -1
  88. package/dist/api/nexa/NexaSignTransaction.d.ts +9 -2
  89. package/dist/api/nexa/NexaSignTransaction.d.ts.map +1 -1
  90. package/dist/api/nostr/NostrSignEvent.d.ts.map +1 -1
  91. package/dist/api/nostr/NostrSignSchnorr.d.ts.map +1 -1
  92. package/dist/api/polkadot/PolkadotSignTransaction.d.ts.map +1 -1
  93. package/dist/api/scdo/ScdoGetAddress.d.ts +6 -2
  94. package/dist/api/scdo/ScdoGetAddress.d.ts.map +1 -1
  95. package/dist/api/scdo/ScdoSignMessage.d.ts +5 -2
  96. package/dist/api/scdo/ScdoSignMessage.d.ts.map +1 -1
  97. package/dist/api/scdo/ScdoSignTransaction.d.ts +5 -2
  98. package/dist/api/scdo/ScdoSignTransaction.d.ts.map +1 -1
  99. package/dist/api/solana/SolGetAddress.d.ts +0 -1
  100. package/dist/api/solana/SolGetAddress.d.ts.map +1 -1
  101. package/dist/api/solana/SolSignMessage.d.ts +0 -4
  102. package/dist/api/solana/SolSignMessage.d.ts.map +1 -1
  103. package/dist/api/solana/SolSignOffchainMessage.d.ts +0 -4
  104. package/dist/api/solana/SolSignOffchainMessage.d.ts.map +1 -1
  105. package/dist/api/solana/SolSignTransaction.d.ts +0 -8
  106. package/dist/api/solana/SolSignTransaction.d.ts.map +1 -1
  107. package/dist/api/starcoin/StarcoinSignMessage.d.ts.map +1 -1
  108. package/dist/api/starcoin/StarcoinSignTransaction.d.ts.map +1 -1
  109. package/dist/api/stellar/StellarGetAddress.d.ts +1 -2
  110. package/dist/api/stellar/StellarGetAddress.d.ts.map +1 -1
  111. package/dist/api/stellar/StellarSignTransaction.d.ts +1 -2
  112. package/dist/api/stellar/StellarSignTransaction.d.ts.map +1 -1
  113. package/dist/api/sui/SuiSignMessage.d.ts.map +1 -1
  114. package/dist/api/sui/SuiSignTransaction.d.ts +2 -2
  115. package/dist/api/sui/SuiSignTransaction.d.ts.map +1 -1
  116. package/dist/api/ton/TonSignData.d.ts.map +1 -1
  117. package/dist/api/ton/TonSignMessage.d.ts.map +1 -1
  118. package/dist/api/ton/TonSignProof.d.ts.map +1 -1
  119. package/dist/api/tron/TronSignMessage.d.ts +0 -4
  120. package/dist/api/tron/TronSignMessage.d.ts.map +1 -1
  121. package/dist/api/tron/TronSignTransaction.d.ts +0 -4
  122. package/dist/api/tron/TronSignTransaction.d.ts.map +1 -1
  123. package/dist/api/xrp/XrpSignTransaction.d.ts.map +1 -1
  124. package/dist/core/PollingStateManager.d.ts +8 -0
  125. package/dist/core/PollingStateManager.d.ts.map +1 -0
  126. package/dist/core/RequestQueue.d.ts +1 -1
  127. package/dist/core/RequestQueue.d.ts.map +1 -1
  128. package/dist/core/index.d.ts.map +1 -1
  129. package/dist/data-manager/DataManager.d.ts +4 -7
  130. package/dist/data-manager/DataManager.d.ts.map +1 -1
  131. package/dist/data-manager/MessagesConfig.d.ts +2 -2
  132. package/dist/data-manager/MessagesConfig.d.ts.map +1 -1
  133. package/dist/data-manager/TransportManager.d.ts +4 -5
  134. package/dist/data-manager/TransportManager.d.ts.map +1 -1
  135. package/dist/device/Device.d.ts +18 -5
  136. package/dist/device/Device.d.ts.map +1 -1
  137. package/dist/device/DeviceCommands.d.ts +8 -8
  138. package/dist/device/DeviceCommands.d.ts.map +1 -1
  139. package/dist/device/DeviceConnector.d.ts +1 -2
  140. package/dist/device/DeviceConnector.d.ts.map +1 -1
  141. package/dist/events/ui-request.d.ts +0 -8
  142. package/dist/events/ui-request.d.ts.map +1 -1
  143. package/dist/index.d.ts +43 -292
  144. package/dist/index.js +1009 -16201
  145. package/dist/inject.d.ts.map +1 -1
  146. package/dist/types/api/export.d.ts +1 -1
  147. package/dist/types/api/export.d.ts.map +1 -1
  148. package/dist/types/api/firmwareUpdate.d.ts +0 -7
  149. package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
  150. package/dist/types/api/getPassphraseState.d.ts +1 -10
  151. package/dist/types/api/getPassphraseState.d.ts.map +1 -1
  152. package/dist/types/api/index.d.ts +3 -33
  153. package/dist/types/api/index.d.ts.map +1 -1
  154. package/dist/types/api/preInitialize.d.ts +3 -0
  155. package/dist/types/api/preInitialize.d.ts.map +1 -0
  156. package/dist/types/api/searchDevices.d.ts +2 -2
  157. package/dist/types/api/searchDevices.d.ts.map +1 -1
  158. package/dist/types/device.d.ts +2 -6
  159. package/dist/types/device.d.ts.map +1 -1
  160. package/dist/types/params.d.ts +1 -2
  161. package/dist/types/params.d.ts.map +1 -1
  162. package/dist/types/settings.d.ts +1 -1
  163. package/dist/types/settings.d.ts.map +1 -1
  164. package/dist/utils/deviceFeaturesUtils.d.ts +3 -5
  165. package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
  166. package/dist/utils/deviceInfoUtils.d.ts +0 -1
  167. package/dist/utils/deviceInfoUtils.d.ts.map +1 -1
  168. package/dist/utils/index.d.ts +1 -1
  169. package/dist/utils/index.d.ts.map +1 -1
  170. package/dist/utils/patch.d.ts +1 -1
  171. package/dist/utils/patch.d.ts.map +1 -1
  172. package/dist/utils/versionUtils.d.ts +1 -1
  173. package/package.json +4 -4
  174. package/src/api/BaseMethod.ts +82 -7
  175. package/src/api/FirmwareUpdateV3.ts +4 -21
  176. package/src/api/GetOnekeyFeatures.ts +3 -75
  177. package/src/api/GetPassphraseState.ts +7 -16
  178. package/src/api/SearchDevices.ts +2 -7
  179. package/src/api/alephium/AlephiumGetAddress.ts +2 -6
  180. package/src/api/alephium/AlephiumSignMessage.ts +2 -6
  181. package/src/api/alephium/AlephiumSignTransaction.ts +3 -6
  182. package/src/api/algo/AlgoSignTransaction.ts +1 -0
  183. package/src/api/allnetwork/AllNetworkGetAddressBase.ts +9 -18
  184. package/src/api/aptos/AptosSignInMessage.ts +1 -0
  185. package/src/api/aptos/AptosSignMessage.ts +1 -0
  186. package/src/api/aptos/AptosSignTransaction.ts +1 -0
  187. package/src/api/benfen/BenfenGetAddress.ts +2 -6
  188. package/src/api/benfen/BenfenGetPublicKey.ts +2 -6
  189. package/src/api/benfen/BenfenSignMessage.ts +2 -6
  190. package/src/api/benfen/BenfenSignTransaction.ts +2 -6
  191. package/src/api/btc/BTCSignMessage.ts +1 -0
  192. package/src/api/btc/BTCSignPsbt.ts +1 -0
  193. package/src/api/btc/BTCSignTransaction.ts +1 -0
  194. package/src/api/btc/helpers/versionLimit.ts +1 -7
  195. package/src/api/cardano/CardanoSignMessage.ts +1 -0
  196. package/src/api/cardano/CardanoSignTransaction.ts +1 -0
  197. package/src/api/conflux/ConfluxSignMessage.ts +1 -0
  198. package/src/api/conflux/ConfluxSignMessageCIP23.ts +1 -0
  199. package/src/api/conflux/ConfluxSignTransaction.ts +3 -5
  200. package/src/api/cosmos/CosmosSignTransaction.ts +1 -0
  201. package/src/api/device/DeviceRebootToBoardloader.ts +1 -10
  202. package/src/api/device/DeviceRebootToBootloader.ts +1 -10
  203. package/src/api/device/PreInitialize.ts +41 -0
  204. package/src/api/dynex/DnxGetAddress.ts +0 -7
  205. package/src/api/dynex/DnxSignTransaction.ts +1 -7
  206. package/src/api/evm/EVMGetAddress.ts +1 -1
  207. package/src/api/evm/EVMGetPublicKey.ts +1 -1
  208. package/src/api/evm/EVMSignMessage.ts +3 -1
  209. package/src/api/evm/EVMSignMessageEIP712.ts +2 -14
  210. package/src/api/evm/EVMSignTransaction.ts +3 -1
  211. package/src/api/evm/EVMSignTypedData.ts +8 -6
  212. package/src/api/evm/EVMVerifyMessage.ts +1 -1
  213. package/src/api/filecoin/FilecoinSignTransaction.ts +1 -0
  214. package/src/api/firmware/FirmwareUpdateBaseMethod.ts +4 -27
  215. package/src/api/index.ts +1 -30
  216. package/src/api/kaspa/KaspaSignTransaction.ts +1 -0
  217. package/src/api/near/NearSignTransaction.ts +1 -0
  218. package/src/api/nem/NEMSignTransaction.ts +1 -0
  219. package/src/api/neo/NeoGetAddress.ts +1 -6
  220. package/src/api/neo/NeoSignTransaction.ts +2 -6
  221. package/src/api/nervos/NervosGetAddress.ts +2 -6
  222. package/src/api/nervos/NervosSignTransaction.ts +3 -6
  223. package/src/api/nexa/NexaGetAddress.ts +2 -6
  224. package/src/api/nexa/NexaSignTransaction.ts +4 -6
  225. package/src/api/nostr/NostrSignEvent.ts +1 -0
  226. package/src/api/nostr/NostrSignSchnorr.ts +1 -0
  227. package/src/api/polkadot/PolkadotSignTransaction.ts +1 -0
  228. package/src/api/scdo/ScdoGetAddress.ts +2 -6
  229. package/src/api/scdo/ScdoSignMessage.ts +2 -6
  230. package/src/api/scdo/ScdoSignTransaction.ts +3 -6
  231. package/src/api/solana/SolGetAddress.ts +0 -4
  232. package/src/api/solana/SolSignMessage.ts +1 -4
  233. package/src/api/solana/SolSignOffchainMessage.ts +1 -4
  234. package/src/api/solana/SolSignTransaction.ts +1 -8
  235. package/src/api/starcoin/StarcoinSignMessage.ts +1 -0
  236. package/src/api/starcoin/StarcoinSignTransaction.ts +1 -0
  237. package/src/api/stellar/StellarGetAddress.ts +1 -10
  238. package/src/api/stellar/StellarSignTransaction.ts +2 -14
  239. package/src/api/sui/SuiSignMessage.ts +1 -0
  240. package/src/api/sui/SuiSignTransaction.ts +10 -12
  241. package/src/api/ton/TonSignData.ts +1 -0
  242. package/src/api/ton/TonSignMessage.ts +1 -0
  243. package/src/api/ton/TonSignProof.ts +1 -0
  244. package/src/api/tron/TronSignMessage.ts +2 -5
  245. package/src/api/tron/TronSignTransaction.ts +1 -4
  246. package/src/api/xrp/XrpSignTransaction.ts +2 -1
  247. package/src/core/PollingStateManager.ts +47 -0
  248. package/src/core/RequestQueue.ts +10 -3
  249. package/src/core/index.ts +153 -62
  250. package/src/data-manager/DataManager.ts +7 -12
  251. package/src/data-manager/MessagesConfig.ts +14 -14
  252. package/src/data-manager/TransportManager.ts +12 -38
  253. package/src/device/Device.ts +82 -98
  254. package/src/device/DeviceCommands.ts +26 -166
  255. package/src/device/DeviceConnector.ts +4 -29
  256. package/src/device/DevicePool.ts +1 -1
  257. package/src/events/ui-request.ts +0 -8
  258. package/src/inject.ts +2 -46
  259. package/src/types/api/export.ts +0 -1
  260. package/src/types/api/firmwareUpdate.ts +0 -12
  261. package/src/types/api/getPassphraseState.ts +2 -13
  262. package/src/types/api/index.ts +3 -80
  263. package/src/types/api/preInitialize.ts +3 -0
  264. package/src/types/api/searchDevices.ts +2 -2
  265. package/src/types/device.ts +2 -33
  266. package/src/types/params.ts +2 -4
  267. package/src/types/settings.ts +1 -1
  268. package/src/utils/deviceFeaturesUtils.ts +21 -62
  269. package/src/utils/deviceInfoUtils.ts +8 -15
  270. package/src/utils/index.ts +0 -1
  271. package/__tests__/protocol-v2.test.ts +0 -1688
  272. package/dist/api/DirList.d.ts +0 -10
  273. package/dist/api/DirList.d.ts.map +0 -1
  274. package/dist/api/DirMake.d.ts +0 -9
  275. package/dist/api/DirMake.d.ts.map +0 -1
  276. package/dist/api/DirRemove.d.ts +0 -9
  277. package/dist/api/DirRemove.d.ts.map +0 -1
  278. package/dist/api/FileDelete.d.ts +0 -9
  279. package/dist/api/FileDelete.d.ts.map +0 -1
  280. package/dist/api/FileRead.d.ts +0 -19
  281. package/dist/api/FileRead.d.ts.map +0 -1
  282. package/dist/api/FileWrite.d.ts +0 -23
  283. package/dist/api/FileWrite.d.ts.map +0 -1
  284. package/dist/api/FirmwareUpdateV4.d.ts +0 -32
  285. package/dist/api/FirmwareUpdateV4.d.ts.map +0 -1
  286. package/dist/api/GetDeviceInfo.d.ts +0 -9
  287. package/dist/api/GetDeviceInfo.d.ts.map +0 -1
  288. package/dist/api/PathInfo.d.ts +0 -9
  289. package/dist/api/PathInfo.d.ts.map +0 -1
  290. package/dist/api/helpers/deviceInfo.d.ts +0 -15
  291. package/dist/api/helpers/deviceInfo.d.ts.map +0 -1
  292. package/dist/api/helpers/filesystemValidation.d.ts +0 -7
  293. package/dist/api/helpers/filesystemValidation.d.ts.map +0 -1
  294. package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts +0 -7
  295. package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts.map +0 -1
  296. package/dist/api/protocol-v2/DeviceGetDeviceInfo.d.ts +0 -7
  297. package/dist/api/protocol-v2/DeviceGetDeviceInfo.d.ts.map +0 -1
  298. package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts +0 -6
  299. package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts.map +0 -1
  300. package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts +0 -6
  301. package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts.map +0 -1
  302. package/dist/api/protocol-v2/DeviceReboot.d.ts +0 -7
  303. package/dist/api/protocol-v2/DeviceReboot.d.ts.map +0 -1
  304. package/dist/api/protocol-v2/FactoryDeviceInfoSettings.d.ts +0 -7
  305. package/dist/api/protocol-v2/FactoryDeviceInfoSettings.d.ts.map +0 -1
  306. package/dist/api/protocol-v2/FactoryGetDeviceInfo.d.ts +0 -6
  307. package/dist/api/protocol-v2/FactoryGetDeviceInfo.d.ts.map +0 -1
  308. package/dist/api/protocol-v2/FilesystemDiskControl.d.ts +0 -10
  309. package/dist/api/protocol-v2/FilesystemDiskControl.d.ts.map +0 -1
  310. package/dist/api/protocol-v2/FilesystemFixPermission.d.ts +0 -6
  311. package/dist/api/protocol-v2/FilesystemFixPermission.d.ts.map +0 -1
  312. package/dist/api/protocol-v2/FilesystemFormat.d.ts +0 -6
  313. package/dist/api/protocol-v2/FilesystemFormat.d.ts.map +0 -1
  314. package/dist/api/protocol-v2/GetProtoVersion.d.ts +0 -6
  315. package/dist/api/protocol-v2/GetProtoVersion.d.ts.map +0 -1
  316. package/dist/api/protocol-v2/Ping.d.ts +0 -8
  317. package/dist/api/protocol-v2/Ping.d.ts.map +0 -1
  318. package/dist/api/protocol-v2/helpers.d.ts +0 -49
  319. package/dist/api/protocol-v2/helpers.d.ts.map +0 -1
  320. package/dist/protocols/protocol-v2/features.d.ts +0 -104
  321. package/dist/protocols/protocol-v2/features.d.ts.map +0 -1
  322. package/dist/protocols/protocol-v2/firmware.d.ts +0 -12
  323. package/dist/protocols/protocol-v2/firmware.d.ts.map +0 -1
  324. package/dist/protocols/protocol-v2/index.d.ts +0 -3
  325. package/dist/protocols/protocol-v2/index.d.ts.map +0 -1
  326. package/dist/types/api/getDeviceInfo.d.ts +0 -84
  327. package/dist/types/api/getDeviceInfo.d.ts.map +0 -1
  328. package/dist/types/api/protocolV2.d.ts +0 -127
  329. package/dist/types/api/protocolV2.d.ts.map +0 -1
  330. package/src/api/DirList.ts +0 -29
  331. package/src/api/DirMake.ts +0 -21
  332. package/src/api/DirRemove.ts +0 -21
  333. package/src/api/FileDelete.ts +0 -21
  334. package/src/api/FileRead.ts +0 -165
  335. package/src/api/FileWrite.ts +0 -203
  336. package/src/api/FirmwareUpdateV4.ts +0 -810
  337. package/src/api/GetDeviceInfo.ts +0 -161
  338. package/src/api/PathInfo.ts +0 -25
  339. package/src/api/helpers/deviceInfo.ts +0 -205
  340. package/src/api/helpers/filesystemValidation.ts +0 -51
  341. package/src/api/protocol-v2/DeviceFirmwareUpdate.ts +0 -50
  342. package/src/api/protocol-v2/DeviceGetDeviceInfo.ts +0 -35
  343. package/src/api/protocol-v2/DeviceGetFirmwareUpdateStatus.ts +0 -18
  344. package/src/api/protocol-v2/DeviceGetOnboardingStatus.ts +0 -18
  345. package/src/api/protocol-v2/DeviceReboot.ts +0 -22
  346. package/src/api/protocol-v2/FactoryDeviceInfoSettings.ts +0 -27
  347. package/src/api/protocol-v2/FactoryGetDeviceInfo.ts +0 -18
  348. package/src/api/protocol-v2/FilesystemDiskControl.ts +0 -34
  349. package/src/api/protocol-v2/FilesystemFixPermission.ts +0 -14
  350. package/src/api/protocol-v2/FilesystemFormat.ts +0 -14
  351. package/src/api/protocol-v2/GetProtoVersion.ts +0 -14
  352. package/src/api/protocol-v2/Ping.ts +0 -16
  353. package/src/api/protocol-v2/helpers.ts +0 -161
  354. package/src/data/messages/messages-protocol-v2.json +0 -13128
  355. package/src/protocols/protocol-v2/features.ts +0 -287
  356. package/src/protocols/protocol-v2/firmware.ts +0 -26
  357. package/src/protocols/protocol-v2/index.ts +0 -2
  358. package/src/types/api/getDeviceInfo.ts +0 -97
  359. package/src/types/api/protocolV2.ts +0 -226
@@ -4,76 +4,6 @@ import { UI_REQUEST } from '../constants/ui-request';
4
4
  import { fixVersion } from '../utils/deviceFeaturesUtils';
5
5
  import { BaseMethod } from './BaseMethod';
6
6
 
7
- import type { OnekeyFeatures } from '../types';
8
-
9
- const ONEKEY_FEATURE_KEYS: Array<keyof OnekeyFeatures> = [
10
- 'onekey_device_type',
11
- 'onekey_board_version',
12
- 'onekey_boot_version',
13
- 'onekey_firmware_version',
14
- 'onekey_board_hash',
15
- 'onekey_boot_hash',
16
- 'onekey_firmware_hash',
17
- 'onekey_board_build_id',
18
- 'onekey_boot_build_id',
19
- 'onekey_firmware_build_id',
20
- 'onekey_serial_no',
21
- 'onekey_ble_name',
22
- 'onekey_ble_version',
23
- 'onekey_ble_build_id',
24
- 'onekey_ble_hash',
25
- 'onekey_se_type',
26
- 'onekey_se01_state',
27
- 'onekey_se02_state',
28
- 'onekey_se03_state',
29
- 'onekey_se04_state',
30
- 'onekey_se01_version',
31
- 'onekey_se02_version',
32
- 'onekey_se03_version',
33
- 'onekey_se04_version',
34
- 'onekey_se01_hash',
35
- 'onekey_se02_hash',
36
- 'onekey_se03_hash',
37
- 'onekey_se04_hash',
38
- 'onekey_se01_build_id',
39
- 'onekey_se02_build_id',
40
- 'onekey_se03_build_id',
41
- 'onekey_se04_build_id',
42
- 'onekey_se01_boot_version',
43
- 'onekey_se02_boot_version',
44
- 'onekey_se03_boot_version',
45
- 'onekey_se04_boot_version',
46
- 'onekey_se01_boot_hash',
47
- 'onekey_se02_boot_hash',
48
- 'onekey_se03_boot_hash',
49
- 'onekey_se04_boot_hash',
50
- 'onekey_se01_boot_build_id',
51
- 'onekey_se02_boot_build_id',
52
- 'onekey_se03_boot_build_id',
53
- 'onekey_se04_boot_build_id',
54
- ];
55
-
56
- function normalizeOnekeyFirmwareVersion(message: OnekeyFeatures) {
57
- if (message.onekey_firmware_version && !semver.valid(message.onekey_firmware_version)) {
58
- message.onekey_firmware_version = fixVersion(message.onekey_firmware_version);
59
- }
60
- }
61
-
62
- function pickOnekeyFeatures(features?: OnekeyFeatures | null): OnekeyFeatures {
63
- const message: OnekeyFeatures = {};
64
- if (!features) return message;
65
-
66
- for (const key of ONEKEY_FEATURE_KEYS) {
67
- const value = features[key];
68
- if (value !== undefined && value !== null) {
69
- (message as Record<string, unknown>)[key] = value;
70
- }
71
- }
72
-
73
- normalizeOnekeyFirmwareVersion(message);
74
- return message;
75
- }
76
-
77
7
  export default class GetOnekeyFeatures extends BaseMethod {
78
8
  init() {
79
9
  this.allowDeviceMode = [
@@ -86,12 +16,10 @@ export default class GetOnekeyFeatures extends BaseMethod {
86
16
  }
87
17
 
88
18
  async run() {
89
- if (this.device.originalDescriptor?.protocolType === 'V2') {
90
- return Promise.resolve(pickOnekeyFeatures(this.device.features as OnekeyFeatures));
91
- }
92
-
93
19
  const { message } = await this.device.commands.typedCall('OnekeyGetFeatures', 'OnekeyFeatures');
94
- normalizeOnekeyFirmwareVersion(message);
20
+ if (!!message.onekey_firmware_version && !semver.valid(message.onekey_firmware_version)) {
21
+ message.onekey_firmware_version = fixVersion(message.onekey_firmware_version);
22
+ }
95
23
  return Promise.resolve(message);
96
24
  }
97
25
  }
@@ -1,8 +1,7 @@
1
- import { EDeviceType, ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
1
+ import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
2
2
 
3
3
  import { UI_REQUEST } from '../constants/ui-request';
4
4
  import { getPassphraseStateWithRefreshDeviceInfo } from '../utils/deviceFeaturesUtils';
5
- import { getDeviceType } from '../utils/deviceInfoUtils';
6
5
  import { BaseMethod } from './BaseMethod';
7
6
 
8
7
  export default class GetPassphraseState extends BaseMethod {
@@ -15,23 +14,15 @@ export default class GetPassphraseState extends BaseMethod {
15
14
  if (!this.device.features)
16
15
  return Promise.reject(ERRORS.TypedError(HardwareErrorCode.DeviceInitializeFailed));
17
16
 
18
- const { passphraseState, newSession, unlockedAttachPin } =
19
- await getPassphraseStateWithRefreshDeviceInfo(this.device, {
20
- expectPassphraseState: this.payload.passphraseState,
21
- onlyMainPin: this.payload.useEmptyPassphrase,
22
- allowCreateAttachPin: this.payload.allowCreateAttachPin,
23
- });
17
+ const { passphraseState } = await getPassphraseStateWithRefreshDeviceInfo(this.device);
24
18
 
25
19
  const { features } = this.device;
26
- const isPro2 = getDeviceType(features) === EDeviceType.Pro2;
27
- const passphraseProtection = features?.passphrase_protection ?? null;
28
20
 
29
21
  // refresh device info
30
- return Promise.resolve({
31
- passphrase_state: isPro2 || passphraseProtection === true ? passphraseState : undefined,
32
- session_id: newSession ?? features?.session_id ?? undefined,
33
- unlocked_attach_pin: unlockedAttachPin ?? features?.unlocked_attach_pin,
34
- passphrase_protection: passphraseProtection,
35
- });
22
+ if (features && features.passphrase_protection === true) {
23
+ return Promise.resolve(passphraseState);
24
+ }
25
+
26
+ return Promise.resolve(undefined);
36
27
  }
37
28
  }
@@ -34,22 +34,17 @@ export default class SearchDevices extends BaseMethod {
34
34
  const lowerId = device.id?.toLowerCase();
35
35
  if (!seenIds.has(lowerId)) {
36
36
  seenIds.add(lowerId);
37
- const bleName =
38
- device.name ?? (device as unknown as { localName?: string }).localName ?? '';
39
37
  devices.push({
40
38
  ...device,
41
39
  connectId: device.id,
42
- name: bleName || device.name,
43
- deviceType: getDeviceTypeByBleName(bleName),
40
+ deviceType: getDeviceTypeByBleName(device.name ?? ''),
44
41
  });
45
42
  }
46
43
  }
47
44
  return devices;
48
45
  }
49
46
 
50
- const { deviceList } = await DevicePool.getDevices(devicesDescriptor, undefined, {
51
- connectProtocol: this.payload.connectProtocol,
52
- });
47
+ const { deviceList } = await DevicePool.getDevices(devicesDescriptor);
53
48
  return deviceList.map(device => device.toMessageObject());
54
49
  }
55
50
  }
@@ -4,7 +4,7 @@ import { BaseMethod } from '../BaseMethod';
4
4
  import { validateParams, validateResult } from '../helpers/paramsValidator';
5
5
 
6
6
  import type { AlephiumGetAddress as HardwareAlephiumGetAddress } from '@onekeyfe/hd-transport';
7
- import type { AlephiumAddress, AlephiumGetAddressParams, DeviceFirmwareRange } from '../../types';
7
+ import type { AlephiumAddress, AlephiumGetAddressParams } from '../../types';
8
8
 
9
9
  export default class AlephiumGetAddress extends BaseMethod<HardwareAlephiumGetAddress[]> {
10
10
  hasBundle = false;
@@ -43,12 +43,8 @@ export default class AlephiumGetAddress extends BaseMethod<HardwareAlephiumGetAd
43
43
  });
44
44
  }
45
45
 
46
- getVersionRange(): DeviceFirmwareRange {
46
+ getVersionRange() {
47
47
  return {
48
- pro2: {
49
- min: '0.0.0',
50
- unsupported: true,
51
- },
52
48
  model_touch: {
53
49
  min: '4.10.0',
54
50
  },
@@ -5,12 +5,12 @@ import { validateParams } from '../helpers/paramsValidator';
5
5
  import { stripHexPrefix } from '../helpers/hexUtils';
6
6
 
7
7
  import type { AlephiumSignMessage as HardwareAlephiumSignMessage } from '@onekeyfe/hd-transport';
8
- import type { DeviceFirmwareRange } from '../../types';
9
8
 
10
9
  export default class AlephiumSignMessage extends BaseMethod<HardwareAlephiumSignMessage> {
11
10
  init() {
12
11
  this.checkDeviceId = true;
13
12
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
13
+ this.allowUsePreInitialize = true;
14
14
 
15
15
  // check payload
16
16
  validateParams(this.payload, [
@@ -30,12 +30,8 @@ export default class AlephiumSignMessage extends BaseMethod<HardwareAlephiumSign
30
30
  };
31
31
  }
32
32
 
33
- getVersionRange(): DeviceFirmwareRange {
33
+ getVersionRange() {
34
34
  return {
35
- pro2: {
36
- min: '0.0.0',
37
- unsupported: true,
38
- },
39
35
  model_touch: {
40
36
  min: '4.10.0',
41
37
  },
@@ -11,13 +11,14 @@ import type {
11
11
  AlephiumSignTx as HardwareAlephiumSignTx,
12
12
  TypedCall,
13
13
  } from '@onekeyfe/hd-transport';
14
- import type { AlephiumSignTransactionParams, DeviceFirmwareRange } from '../../types';
14
+ import type { AlephiumSignTransactionParams } from '../../types';
15
15
  import type { TypedResponseMessage } from '../../device/DeviceCommands';
16
16
 
17
17
  export default class AlephiumSignTransaction extends BaseMethod<HardwareAlephiumSignTx> {
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, [
@@ -38,12 +39,8 @@ export default class AlephiumSignTransaction extends BaseMethod<HardwareAlephium
38
39
  };
39
40
  }
40
41
 
41
- getVersionRange(): DeviceFirmwareRange {
42
+ getVersionRange() {
42
43
  return {
43
- pro2: {
44
- min: '0.0.0',
45
- unsupported: true,
46
- },
47
44
  model_touch: {
48
45
  min: '4.10.0',
49
46
  },
@@ -12,6 +12,7 @@ export default class AlgoSignTransaction extends BaseMethod<HardwareAlgorandSign
12
12
  init() {
13
13
  this.checkDeviceId = true;
14
14
  this.allowDeviceMode = [...this.allowDeviceMode];
15
+ this.allowUsePreInitialize = true;
15
16
 
16
17
  // check payload
17
18
  validateParams(this.payload, [
@@ -12,12 +12,7 @@ import { validateParams } from '../helpers/paramsValidator';
12
12
  import { PROTO } from '../../constants';
13
13
  import { findMethod } from '../utils';
14
14
  import { DEVICE, IFRAME, createUiMessage } from '../../events';
15
- import {
16
- getDeviceFirmwareVersion,
17
- getFirmwareType,
18
- getMethodVersionRange,
19
- isMethodVersionRangeUnsupported,
20
- } from '../../utils';
15
+ import { getDeviceFirmwareVersion, getFirmwareType, getMethodVersionRange } from '../../utils';
21
16
  import { UI_REQUEST } from '../../constants/ui-request';
22
17
  import { onDeviceButtonHandler } from '../../core';
23
18
  import {
@@ -376,6 +371,14 @@ export default abstract class AllNetworkGetAddressBase extends BaseMethod<
376
371
  this.device.on(DEVICE.PASSPHRASE, onSignalAbort);
377
372
 
378
373
  preCheckDeviceSupport(this.device, method);
374
+ if (this.temporarySafetyCheckPrompted) {
375
+ method.temporarySafetyCheckPrompted = true;
376
+ } else {
377
+ const appliedTemporarySafetyCheck = await method.checkSafetyLevelOnTestNet();
378
+ if (appliedTemporarySafetyCheck) {
379
+ this.temporarySafetyCheckPrompted = true;
380
+ }
381
+ }
379
382
 
380
383
  const response = await method.run();
381
384
 
@@ -466,10 +469,6 @@ function preCheckDeviceSupport(device: Device, method: BaseMethod) {
466
469
  );
467
470
  const currentVersion = getDeviceFirmwareVersion(device.features).join('.');
468
471
 
469
- if (isMethodVersionRangeUnsupported(versionRange)) {
470
- throw ERRORS.createDeviceNotSupportMethodError(method.name, getFirmwareType(device.features));
471
- }
472
-
473
472
  if (
474
473
  versionRange &&
475
474
  semver.valid(versionRange.min) &&
@@ -510,14 +509,6 @@ function handleSkippableHardwareError(
510
509
  );
511
510
  const currentVersion = getDeviceFirmwareVersion(device.features).join('.');
512
511
 
513
- if (isMethodVersionRangeUnsupported(versionRange)) {
514
- error = ERRORS.createDeviceNotSupportMethodError(
515
- method.name,
516
- getFirmwareType(device.features)
517
- );
518
- return error;
519
- }
520
-
521
512
  if (
522
513
  versionRange &&
523
514
  semver.valid(versionRange.min) &&
@@ -10,6 +10,7 @@ export default class AptosSignInMessage extends BaseMethod<AptosSignSIWAMessage>
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 AptosSignMessage extends BaseMethod<HardwareAptosSignMessag
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 AptosSignTransaction extends BaseMethod<HardwareAptosSignTx
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, [
@@ -6,7 +6,7 @@ import { hex2BfcAddress, publicKeyToAddress } from './normalize';
6
6
  import { supportBatchPublicKey } from '../../utils/deviceFeaturesUtils';
7
7
  import { batchGetPublickeys } from '../helpers/batchGetPublickeys';
8
8
 
9
- import type { BenfenAddress, BenfenGetAddressParams, DeviceFirmwareRange } from '../../types';
9
+ import type { BenfenAddress, BenfenGetAddressParams } from '../../types';
10
10
  import type { BenfenGetAddress as HardwareBenfenGetAddress } from '@onekeyfe/hd-transport';
11
11
 
12
12
  export default class BenfenGetAddress extends BaseMethod<HardwareBenfenGetAddress[]> {
@@ -47,12 +47,8 @@ export default class BenfenGetAddress extends BaseMethod<HardwareBenfenGetAddres
47
47
  });
48
48
  }
49
49
 
50
- getVersionRange(): DeviceFirmwareRange {
50
+ getVersionRange() {
51
51
  return {
52
- pro2: {
53
- min: '0.0.0',
54
- unsupported: true,
55
- },
56
52
  pro: {
57
53
  min: '4.12.0',
58
54
  },
@@ -4,7 +4,7 @@ import { serializedPath, validatePath } from '../helpers/pathUtils';
4
4
  import { UI_REQUEST } from '../../constants/ui-request';
5
5
  import { batchGetPublickeys } from '../helpers/batchGetPublickeys';
6
6
 
7
- import type { BenfenGetPublicKeyParams, BenfenPublicKey, DeviceFirmwareRange } from '../../types';
7
+ import type { BenfenGetPublicKeyParams, BenfenPublicKey } from '../../types';
8
8
 
9
9
  export default class BenfenGetPublicKey extends BaseMethod<any> {
10
10
  hasBundle = false;
@@ -38,12 +38,8 @@ export default class BenfenGetPublicKey extends BaseMethod<any> {
38
38
  });
39
39
  }
40
40
 
41
- getVersionRange(): DeviceFirmwareRange {
41
+ getVersionRange() {
42
42
  return {
43
- pro2: {
44
- min: '0.0.0',
45
- unsupported: true,
46
- },
47
43
  pro: {
48
44
  min: '4.12.0',
49
45
  },
@@ -5,12 +5,12 @@ import { validateParams } from '../helpers/paramsValidator';
5
5
  import { stripHexPrefix } from '../helpers/hexUtils';
6
6
 
7
7
  import type { BenfenSignMessage as HardwareBenfenSignMessage } from '@onekeyfe/hd-transport';
8
- import type { DeviceFirmwareRange } from '../../types';
9
8
 
10
9
  export default class BenfenSignMessage extends BaseMethod<HardwareBenfenSignMessage> {
11
10
  init() {
12
11
  this.checkDeviceId = true;
13
12
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
13
+ this.allowUsePreInitialize = true;
14
14
 
15
15
  validateParams(this.payload, [
16
16
  { name: 'path', required: true },
@@ -26,12 +26,8 @@ export default class BenfenSignMessage extends BaseMethod<HardwareBenfenSignMess
26
26
  };
27
27
  }
28
28
 
29
- getVersionRange(): DeviceFirmwareRange {
29
+ getVersionRange() {
30
30
  return {
31
- pro2: {
32
- min: '0.0.0',
33
- unsupported: true,
34
- },
35
31
  pro: {
36
32
  min: '4.12.0',
37
33
  },
@@ -8,12 +8,12 @@ import { formatAnyHex } from '../helpers/hexUtils';
8
8
 
9
9
  import type { BenfenSignTx, BenfenSignedTx, MessageType, TypedCall } from '@onekeyfe/hd-transport';
10
10
  import type { TypedResponseMessage } from '../../device/DeviceCommands';
11
- import type { DeviceFirmwareRange } from '../../types';
12
11
 
13
12
  export default class BenfenSignTransaction extends BaseMethod<BenfenSignTx> {
14
13
  init() {
15
14
  this.checkDeviceId = true;
16
15
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
16
+ this.allowUsePreInitialize = true;
17
17
 
18
18
  validateParams(this.payload, [
19
19
  { name: 'path', required: true },
@@ -33,12 +33,8 @@ export default class BenfenSignTransaction extends BaseMethod<BenfenSignTx> {
33
33
  };
34
34
  }
35
35
 
36
- getVersionRange(): DeviceFirmwareRange {
36
+ getVersionRange() {
37
37
  return {
38
- pro2: {
39
- min: '0.0.0',
40
- unsupported: true,
41
- },
42
38
  pro: {
43
39
  min: '4.12.0',
44
40
  },
@@ -12,6 +12,7 @@ export default class BTCSignMessage extends BaseMethod<SignMessage> {
12
12
  init() {
13
13
  this.checkDeviceId = true;
14
14
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
15
+ this.allowUsePreInitialize = true;
15
16
 
16
17
  validateParams(this.payload, [
17
18
  { name: 'path', required: true },
@@ -13,6 +13,7 @@ export default class BTCSignPsbt extends BaseMethod<SignPsbt> {
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
  validateParams(this.payload, [
18
19
  { name: 'psbt', type: 'hexString', required: true },
@@ -29,6 +29,7 @@ export default class BTCSignTransaction extends BaseMethod<Params> {
29
29
  init() {
30
30
  this.checkDeviceId = true;
31
31
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
32
+ this.allowUsePreInitialize = true;
32
33
 
33
34
  validateParams(this.payload, [
34
35
  { name: 'coin', type: 'string', required: true },
@@ -1,5 +1,3 @@
1
- import type { DeviceFirmwareRange } from '../../../types';
2
-
3
1
  function isCoinNameInList(coinName: string, coinNames: (string | undefined)[]) {
4
2
  for (let i = 0; i < coinNames.length; i++) {
5
3
  const coin_name = coinNames[i];
@@ -10,13 +8,9 @@ function isCoinNameInList(coinName: string, coinNames: (string | undefined)[]) {
10
8
  return false;
11
9
  }
12
10
 
13
- export function getBitcoinForkVersionRange(params: (string | undefined)[]): DeviceFirmwareRange {
11
+ export function getBitcoinForkVersionRange(params: (string | undefined)[]) {
14
12
  if (isCoinNameInList('Neurai', params)) {
15
13
  return {
16
- pro2: {
17
- min: '0.0.0',
18
- unsupported: true,
19
- },
20
14
  model_mini: {
21
15
  min: '3.7.0',
22
16
  },
@@ -14,6 +14,7 @@ export default class CardanoSignMessage extends BaseMethod<CardanoSignMessagePar
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
  const { payload } = this;
19
20
  validateParams(payload, [
@@ -49,6 +49,7 @@ export default class CardanoSignTransaction extends BaseMethod<any> {
49
49
  init() {
50
50
  this.checkDeviceId = true;
51
51
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
52
+ this.allowUsePreInitialize = true;
52
53
 
53
54
  this.hasBundle = !!this.payload?.bundle;
54
55
 
@@ -9,6 +9,7 @@ import type { ConfluxSignMessage as HardwareConfluxSignMessage } from '@onekeyfe
9
9
  export default class ConfluxSignMessage extends BaseMethod<HardwareConfluxSignMessage> {
10
10
  init() {
11
11
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
12
+ this.allowUsePreInitialize = true;
12
13
 
13
14
  // check payload
14
15
  validateParams(this.payload, [
@@ -9,6 +9,7 @@ import type { ConfluxSignMessageCIP23 as HardwareConfluxSignMessageCIP23 } from
9
9
  export default class ConfluxSignMessageCIP23 extends BaseMethod<HardwareConfluxSignMessageCIP23> {
10
10
  init() {
11
11
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
12
+ this.allowUsePreInitialize = true;
12
13
 
13
14
  validateParams(this.payload, [
14
15
  { name: 'path', required: true },
@@ -22,6 +22,7 @@ export default class ConfluxSignTransaction extends BaseMethod {
22
22
 
23
23
  init() {
24
24
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
25
+ this.allowUsePreInitialize = true;
25
26
 
26
27
  validateParams(this.payload, [
27
28
  { name: 'path', required: true },
@@ -34,7 +35,7 @@ export default class ConfluxSignTransaction extends BaseMethod {
34
35
 
35
36
  // check if transaction is valid
36
37
  const schema: SchemaParam[] = [
37
- { name: 'to', type: 'string', required: true },
38
+ { name: 'to', type: 'hexString', required: true },
38
39
  { name: 'value', type: 'hexString', required: true },
39
40
  { name: 'gasLimit', type: 'hexString', required: true },
40
41
  { name: 'gasPrice', type: 'hexString', required: true },
@@ -47,10 +48,7 @@ export default class ConfluxSignTransaction extends BaseMethod {
47
48
 
48
49
  validateParams(tx, schema);
49
50
 
50
- this.formattedTx = {
51
- ...formatAnyHex(tx),
52
- to: tx.to,
53
- };
51
+ this.formattedTx = formatAnyHex(tx);
54
52
  }
55
53
 
56
54
  processTxRequest = async (request: ConfluxTxRequest, data: string): Promise<ConfluxSignedTx> => {
@@ -14,6 +14,7 @@ export default class CosmosSignTransaction extends BaseMethod<HardwareCosmosSign
14
14
  init() {
15
15
  this.checkDeviceId = true;
16
16
  this.allowDeviceMode = [...this.allowDeviceMode];
17
+ this.allowUsePreInitialize = true;
17
18
 
18
19
  // check payload
19
20
  validateParams(this.payload, [
@@ -1,5 +1,3 @@
1
- import { DeviceRebootType } from '@onekeyfe/hd-transport';
2
-
3
1
  import { BaseMethod } from '../BaseMethod';
4
2
 
5
3
  import type { RebootToBoardloaderParams } from '../../types/api/deviceRebootToBoardloader';
@@ -23,17 +21,10 @@ export default class DeviceRebootToBoardloader extends BaseMethod<RebootToBoardl
23
21
  }
24
22
 
25
23
  async run() {
26
- // Protocol V2 uses DeviceReboot with reboot_type enum.
27
- if (this.device.originalDescriptor?.protocolType === 'V2') {
28
- const res = await this.device.commands.typedCall('DeviceReboot', 'Success', {
29
- reboot_type: DeviceRebootType.Boardloader,
30
- });
31
- return Promise.resolve(res.message);
32
- }
33
-
34
24
  // On Touch devices, messsage code 904 is RebootToBoardloader
35
25
  // so BininOutMessageSE message code 904 is used here
36
26
  const res = await this.device.commands.typedCall('BixinOutMessageSE', 'Success');
27
+
37
28
  return Promise.resolve(res.message);
38
29
  }
39
30
  }
@@ -1,5 +1,3 @@
1
- import { DeviceRebootType } from '@onekeyfe/hd-transport';
2
-
3
1
  import { BaseMethod } from '../BaseMethod';
4
2
 
5
3
  import type { RebootToBootloader } from '@onekeyfe/hd-transport';
@@ -23,15 +21,8 @@ export default class DeviceRebootToBootloader extends BaseMethod<RebootToBootloa
23
21
  }
24
22
 
25
23
  async run() {
26
- // Protocol V2 uses DeviceReboot with reboot_type enum.
27
- if (this.device.originalDescriptor?.protocolType === 'V2') {
28
- const res = await this.device.commands.typedCall('DeviceReboot', 'Success', {
29
- reboot_type: DeviceRebootType.Bootloader,
30
- });
31
- return Promise.resolve(res.message);
32
- }
33
-
34
24
  const res = await this.device.commands.typedCall('RebootToBootloader', 'Success');
25
+
35
26
  return Promise.resolve(res.message);
36
27
  }
37
28
  }
@@ -0,0 +1,41 @@
1
+ import { BaseMethod } from '../BaseMethod';
2
+ import { LoggerNames, getLogger } from '../../utils';
3
+
4
+ import type { InitOptions } from '../../device/Device';
5
+
6
+ // Core prefix (@onekey/hd-core) so the host app's LOG_EVENT bridge forwards
7
+ // this into the collected hardware log scope (like [PRE-INIT][HIT]/[MISS]).
8
+ const Log = getLogger(LoggerNames.Core);
9
+
10
+ const parseInitOptions = (payload?: {
11
+ initSession?: boolean;
12
+ passphraseState?: string;
13
+ deriveCardano?: boolean;
14
+ }): InitOptions => ({
15
+ initSession: payload?.initSession,
16
+ passphraseState: payload?.passphraseState,
17
+ deriveCardano: payload?.deriveCardano,
18
+ });
19
+
20
+ export default class PreInitialize extends BaseMethod {
21
+ init() {
22
+ this.skipForceUpdateCheck = true;
23
+ this.useDevicePassphraseState = false;
24
+ // Fire-and-forget warm-up signal (core dedups + hangs up for the next call)
25
+ this.isPreWarmSignal = true;
26
+ }
27
+
28
+ async run() {
29
+ try {
30
+ await this.device.preInitialize(parseInitOptions(this.payload));
31
+ if (this.device.hasDeviceAcquire()) {
32
+ await this.device.release();
33
+ }
34
+ return true;
35
+ } catch {
36
+ this.device.clearPreInitialized();
37
+ Log.debug('[PRE-INIT][FAILED]');
38
+ return false;
39
+ }
40
+ }
41
+ }