@onekeyfe/hd-core 1.2.0-alpha.57 → 1.2.0-alpha.58

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 (596) hide show
  1. package/__tests__/AllNetworkGetAddressBase.tracing.test.ts +84 -2
  2. package/__tests__/DeviceCommands.test.ts +17 -6
  3. package/__tests__/core-initialization.test.ts +23 -0
  4. package/__tests__/device-connector-protocol.test.ts +81 -0
  5. package/__tests__/device-settings.test.ts +39 -18
  6. package/__tests__/protocol-v2-resources.test.ts +24 -0
  7. package/__tests__/protocol-v2.test.ts +49 -126
  8. package/__tests__/protocolV2FileWrite.test.ts +113 -0
  9. package/__tests__/public-pro2-api-boundary.test.ts +2 -98
  10. package/dist/api/FirmwareUpdateV4.d.ts +0 -1
  11. package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
  12. package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts.map +1 -1
  13. package/dist/api/device/DeviceSettings.d.ts.map +1 -1
  14. package/dist/api/device/DeviceVerify.d.ts.map +1 -1
  15. package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts +4 -2
  16. package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts.map +1 -1
  17. package/dist/api/helpers/protocolV2FileWrite.d.ts +7 -0
  18. package/dist/api/helpers/protocolV2FileWrite.d.ts.map +1 -1
  19. package/dist/api/index.d.ts +0 -3
  20. package/dist/api/index.d.ts.map +1 -1
  21. package/dist/api/protocol-v2/DeviceFactoryInfoGet.d.ts.map +1 -1
  22. package/dist/api/protocol-v2/DeviceFactoryInfoSet.d.ts.map +1 -1
  23. package/dist/api/protocol-v2/helpers.d.ts +5 -15
  24. package/dist/api/protocol-v2/helpers.d.ts.map +1 -1
  25. package/dist/api/stellar/StellarSignTransaction.d.ts +1 -1
  26. package/dist/api/utils.d.ts +1 -6
  27. package/dist/api/utils.d.ts.map +1 -1
  28. package/dist/core/index.d.ts +4 -10
  29. package/dist/core/index.d.ts.map +1 -1
  30. package/dist/data-manager/DataManager.d.ts +1 -0
  31. package/dist/data-manager/DataManager.d.ts.map +1 -1
  32. package/dist/data-manager/TransportManager.d.ts.map +1 -1
  33. package/dist/device/DeviceCommands.d.ts.map +1 -1
  34. package/dist/device/DeviceConnector.d.ts +2 -1
  35. package/dist/device/DeviceConnector.d.ts.map +1 -1
  36. package/dist/index.d.ts +44 -723
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js +499 -2953
  39. package/dist/inject.d.ts +2 -6
  40. package/dist/inject.d.ts.map +1 -1
  41. package/dist/types/api/index.d.ts +3 -176
  42. package/dist/types/api/index.d.ts.map +1 -1
  43. package/dist/types/api/protocolV2.d.ts +2 -8
  44. package/dist/types/api/protocolV2.d.ts.map +1 -1
  45. package/dist/utils/patch.d.ts +1 -1
  46. package/dist/utils/patch.d.ts.map +1 -1
  47. package/package.json +4 -4
  48. package/src/api/FirmwareUpdateV4.ts +39 -69
  49. package/src/api/allnetwork/AllNetworkGetAddressBase.ts +3 -1
  50. package/src/api/device/DeviceSettings.ts +5 -4
  51. package/src/api/device/DeviceVerify.ts +0 -2
  52. package/src/api/firmware/FirmwareUpdateBaseMethod.ts +12 -1
  53. package/src/api/helpers/protocolV2FileWrite.ts +192 -73
  54. package/src/api/index.ts +0 -3
  55. package/src/api/protocol-v2/DeviceFactoryInfoGet.ts +0 -3
  56. package/src/api/protocol-v2/DeviceFactoryInfoSet.ts +7 -6
  57. package/src/api/protocol-v2/helpers.ts +5 -152
  58. package/src/api/utils.ts +1 -46
  59. package/src/core/index.ts +16 -28
  60. package/src/data-manager/DataManager.ts +25 -4
  61. package/src/data-manager/TransportManager.ts +6 -0
  62. package/src/device/DeviceCommands.ts +20 -2
  63. package/src/device/DeviceConnector.ts +33 -13
  64. package/src/index.ts +0 -5
  65. package/src/inject.ts +7 -209
  66. package/src/types/api/index.ts +2 -288
  67. package/src/types/api/protocolV2.ts +2 -43
  68. package/__tests__/public-test-api-boundary.test.ts +0 -167
  69. package/dist/api/BixinBackupDevice.d.ts +0 -7
  70. package/dist/api/BixinBackupDevice.d.ts.map +0 -1
  71. package/dist/api/BixinLoadDevice.d.ts +0 -7
  72. package/dist/api/BixinLoadDevice.d.ts.map +0 -1
  73. package/dist/api/BixinMessageSE.d.ts +0 -8
  74. package/dist/api/BixinMessageSE.d.ts.map +0 -1
  75. package/dist/api/BixinVerifyDeviceRequest.d.ts +0 -8
  76. package/dist/api/BixinVerifyDeviceRequest.d.ts.map +0 -1
  77. package/dist/api/WebAuthnAddResidentCredential.d.ts +0 -8
  78. package/dist/api/WebAuthnAddResidentCredential.d.ts.map +0 -1
  79. package/dist/api/WebAuthnListResidentCredentials.d.ts +0 -8
  80. package/dist/api/WebAuthnListResidentCredentials.d.ts.map +0 -1
  81. package/dist/api/WebAuthnRemoveResidentCredential.d.ts +0 -8
  82. package/dist/api/WebAuthnRemoveResidentCredential.d.ts.map +0 -1
  83. package/dist/api/binance/BinanceGetAddress.d.ts +0 -8
  84. package/dist/api/binance/BinanceGetAddress.d.ts.map +0 -1
  85. package/dist/api/binance/BinanceGetPublicKey.d.ts +0 -8
  86. package/dist/api/binance/BinanceGetPublicKey.d.ts.map +0 -1
  87. package/dist/api/binance/BinanceSignTx.d.ts +0 -7
  88. package/dist/api/binance/BinanceSignTx.d.ts.map +0 -1
  89. package/dist/api/btc/BTCAuthorizeCoinJoin.d.ts +0 -7
  90. package/dist/api/btc/BTCAuthorizeCoinJoin.d.ts.map +0 -1
  91. package/dist/api/btc/BTCGetOwnershipId.d.ts +0 -7
  92. package/dist/api/btc/BTCGetOwnershipId.d.ts.map +0 -1
  93. package/dist/api/btc/BTCGetOwnershipProof.d.ts +0 -7
  94. package/dist/api/btc/BTCGetOwnershipProof.d.ts.map +0 -1
  95. package/dist/api/crypto/CryptoBatchGetPublickeys.d.ts +0 -8
  96. package/dist/api/crypto/CryptoBatchGetPublickeys.d.ts.map +0 -1
  97. package/dist/api/crypto/CryptoCipherKeyValue.d.ts +0 -8
  98. package/dist/api/crypto/CryptoCipherKeyValue.d.ts.map +0 -1
  99. package/dist/api/crypto/CryptoCosiCommit.d.ts +0 -8
  100. package/dist/api/crypto/CryptoCosiCommit.d.ts.map +0 -1
  101. package/dist/api/crypto/CryptoCosiSign.d.ts +0 -8
  102. package/dist/api/crypto/CryptoCosiSign.d.ts.map +0 -1
  103. package/dist/api/crypto/CryptoGetECDHSessionKey.d.ts +0 -8
  104. package/dist/api/crypto/CryptoGetECDHSessionKey.d.ts.map +0 -1
  105. package/dist/api/crypto/CryptoSignIdentity.d.ts +0 -8
  106. package/dist/api/crypto/CryptoSignIdentity.d.ts.map +0 -1
  107. package/dist/api/debug/DebugLinkDecision.d.ts +0 -7
  108. package/dist/api/debug/DebugLinkDecision.d.ts.map +0 -1
  109. package/dist/api/debug/DebugLinkEraseSdCard.d.ts +0 -7
  110. package/dist/api/debug/DebugLinkEraseSdCard.d.ts.map +0 -1
  111. package/dist/api/debug/DebugLinkFlashErase.d.ts +0 -7
  112. package/dist/api/debug/DebugLinkFlashErase.d.ts.map +0 -1
  113. package/dist/api/debug/DebugLinkGetState.d.ts +0 -7
  114. package/dist/api/debug/DebugLinkGetState.d.ts.map +0 -1
  115. package/dist/api/debug/DebugLinkMemoryRead.d.ts +0 -7
  116. package/dist/api/debug/DebugLinkMemoryRead.d.ts.map +0 -1
  117. package/dist/api/debug/DebugLinkMemoryWrite.d.ts +0 -7
  118. package/dist/api/debug/DebugLinkMemoryWrite.d.ts.map +0 -1
  119. package/dist/api/debug/DebugLinkRecordScreen.d.ts +0 -7
  120. package/dist/api/debug/DebugLinkRecordScreen.d.ts.map +0 -1
  121. package/dist/api/debug/DebugLinkReseedRandom.d.ts +0 -7
  122. package/dist/api/debug/DebugLinkReseedRandom.d.ts.map +0 -1
  123. package/dist/api/debug/DebugLinkStop.d.ts +0 -7
  124. package/dist/api/debug/DebugLinkStop.d.ts.map +0 -1
  125. package/dist/api/debug/DebugLinkWatchLayout.d.ts +0 -7
  126. package/dist/api/debug/DebugLinkWatchLayout.d.ts.map +0 -1
  127. package/dist/api/emmc/EmmcDirList.d.ts +0 -7
  128. package/dist/api/emmc/EmmcDirList.d.ts.map +0 -1
  129. package/dist/api/emmc/EmmcDirMake.d.ts +0 -7
  130. package/dist/api/emmc/EmmcDirMake.d.ts.map +0 -1
  131. package/dist/api/emmc/EmmcDirRemove.d.ts +0 -7
  132. package/dist/api/emmc/EmmcDirRemove.d.ts.map +0 -1
  133. package/dist/api/emmc/EmmcFileDelete.d.ts +0 -7
  134. package/dist/api/emmc/EmmcFileDelete.d.ts.map +0 -1
  135. package/dist/api/emmc/EmmcFileRead.d.ts +0 -7
  136. package/dist/api/emmc/EmmcFileRead.d.ts.map +0 -1
  137. package/dist/api/emmc/EmmcFileWrite.d.ts +0 -7
  138. package/dist/api/emmc/EmmcFileWrite.d.ts.map +0 -1
  139. package/dist/api/emmc/EmmcFixPermission.d.ts +0 -7
  140. package/dist/api/emmc/EmmcFixPermission.d.ts.map +0 -1
  141. package/dist/api/emmc/EmmcPathInfo.d.ts +0 -7
  142. package/dist/api/emmc/EmmcPathInfo.d.ts.map +0 -1
  143. package/dist/api/eos/EosGetPublicKey.d.ts +0 -8
  144. package/dist/api/eos/EosGetPublicKey.d.ts.map +0 -1
  145. package/dist/api/eos/EosSignTx.d.ts +0 -12
  146. package/dist/api/eos/EosSignTx.d.ts.map +0 -1
  147. package/dist/api/evmTrezor/EVMGetAddress.d.ts +0 -10
  148. package/dist/api/evmTrezor/EVMGetAddress.d.ts.map +0 -1
  149. package/dist/api/evmTrezor/EVMGetPublicKey.d.ts +0 -16
  150. package/dist/api/evmTrezor/EVMGetPublicKey.d.ts.map +0 -1
  151. package/dist/api/evmTrezor/EVMSignMessage.d.ts +0 -7
  152. package/dist/api/evmTrezor/EVMSignMessage.d.ts.map +0 -1
  153. package/dist/api/evmTrezor/EVMSignTransaction.d.ts +0 -15
  154. package/dist/api/evmTrezor/EVMSignTransaction.d.ts.map +0 -1
  155. package/dist/api/evmTrezor/EVMSignTypedData.d.ts +0 -43
  156. package/dist/api/evmTrezor/EVMSignTypedData.d.ts.map +0 -1
  157. package/dist/api/evmTrezor/EVMVerifyMessage.d.ts +0 -7
  158. package/dist/api/evmTrezor/EVMVerifyMessage.d.ts.map +0 -1
  159. package/dist/api/evmTrezor/legacyV1/getAddress.d.ts +0 -6
  160. package/dist/api/evmTrezor/legacyV1/getAddress.d.ts.map +0 -1
  161. package/dist/api/evmTrezor/legacyV1/getPublicKey.d.ts +0 -6
  162. package/dist/api/evmTrezor/legacyV1/getPublicKey.d.ts.map +0 -1
  163. package/dist/api/evmTrezor/legacyV1/signMessage.d.ts +0 -6
  164. package/dist/api/evmTrezor/legacyV1/signMessage.d.ts.map +0 -1
  165. package/dist/api/evmTrezor/legacyV1/signTransaction.d.ts +0 -9
  166. package/dist/api/evmTrezor/legacyV1/signTransaction.d.ts.map +0 -1
  167. package/dist/api/evmTrezor/legacyV1/signTypedData.d.ts +0 -10
  168. package/dist/api/evmTrezor/legacyV1/signTypedData.d.ts.map +0 -1
  169. package/dist/api/evmTrezor/legacyV1/signTypedHash.d.ts +0 -11
  170. package/dist/api/evmTrezor/legacyV1/signTypedHash.d.ts.map +0 -1
  171. package/dist/api/evmTrezor/legacyV1/verifyMessage.d.ts +0 -6
  172. package/dist/api/evmTrezor/legacyV1/verifyMessage.d.ts.map +0 -1
  173. package/dist/api/extensionMethodNames.d.ts +0 -3
  174. package/dist/api/extensionMethodNames.d.ts.map +0 -1
  175. package/dist/api/factoryMethods.d.ts +0 -3
  176. package/dist/api/factoryMethods.d.ts.map +0 -1
  177. package/dist/api/firmware/FirmwareErase.d.ts +0 -12
  178. package/dist/api/firmware/FirmwareErase.d.ts.map +0 -1
  179. package/dist/api/firmware/FirmwareEraseEx.d.ts +0 -12
  180. package/dist/api/firmware/FirmwareEraseEx.d.ts.map +0 -1
  181. package/dist/api/firmware/FirmwareUpdateEmmcTest.d.ts +0 -7
  182. package/dist/api/firmware/FirmwareUpdateEmmcTest.d.ts.map +0 -1
  183. package/dist/api/firmware/FirmwareUploadTest.d.ts +0 -7
  184. package/dist/api/firmware/FirmwareUploadTest.d.ts.map +0 -1
  185. package/dist/api/firmware/Reboot.d.ts +0 -7
  186. package/dist/api/firmware/Reboot.d.ts.map +0 -1
  187. package/dist/api/firmware/SelfTest.d.ts +0 -7
  188. package/dist/api/firmware/SelfTest.d.ts.map +0 -1
  189. package/dist/api/manager/DeviceCancelAuthorization.d.ts +0 -7
  190. package/dist/api/manager/DeviceCancelAuthorization.d.ts.map +0 -1
  191. package/dist/api/manager/DeviceChangeWipeCode.d.ts +0 -7
  192. package/dist/api/manager/DeviceChangeWipeCode.d.ts.map +0 -1
  193. package/dist/api/manager/DeviceDoPreauthorized.d.ts +0 -7
  194. package/dist/api/manager/DeviceDoPreauthorized.d.ts.map +0 -1
  195. package/dist/api/manager/DeviceEndSession.d.ts +0 -7
  196. package/dist/api/manager/DeviceEndSession.d.ts.map +0 -1
  197. package/dist/api/manager/DeviceGetEntropy.d.ts +0 -7
  198. package/dist/api/manager/DeviceGetEntropy.d.ts.map +0 -1
  199. package/dist/api/manager/DeviceGetFirmwareHash.d.ts +0 -7
  200. package/dist/api/manager/DeviceGetFirmwareHash.d.ts.map +0 -1
  201. package/dist/api/manager/DeviceInfoSettings.d.ts +0 -7
  202. package/dist/api/manager/DeviceInfoSettings.d.ts.map +0 -1
  203. package/dist/api/manager/DeviceLoad.d.ts +0 -7
  204. package/dist/api/manager/DeviceLoad.d.ts.map +0 -1
  205. package/dist/api/manager/DevicePing.d.ts +0 -7
  206. package/dist/api/manager/DevicePing.d.ts.map +0 -1
  207. package/dist/api/manager/DeviceReadSEPublicCert.d.ts +0 -7
  208. package/dist/api/manager/DeviceReadSEPublicCert.d.ts.map +0 -1
  209. package/dist/api/manager/DeviceSESignMessage.d.ts +0 -7
  210. package/dist/api/manager/DeviceSESignMessage.d.ts.map +0 -1
  211. package/dist/api/manager/DeviceSdProtect.d.ts +0 -7
  212. package/dist/api/manager/DeviceSdProtect.d.ts.map +0 -1
  213. package/dist/api/manager/DeviceSpiFlashRead.d.ts +0 -7
  214. package/dist/api/manager/DeviceSpiFlashRead.d.ts.map +0 -1
  215. package/dist/api/manager/DeviceSpiFlashWrite.d.ts +0 -7
  216. package/dist/api/manager/DeviceSpiFlashWrite.d.ts.map +0 -1
  217. package/dist/api/manager/DeviceUnlockPath.d.ts +0 -7
  218. package/dist/api/manager/DeviceUnlockPath.d.ts.map +0 -1
  219. package/dist/api/manager/DeviceWriteSEPrivateKey.d.ts +0 -7
  220. package/dist/api/manager/DeviceWriteSEPrivateKey.d.ts.map +0 -1
  221. package/dist/api/manager/DeviceWriteSEPublicCert.d.ts +0 -7
  222. package/dist/api/manager/DeviceWriteSEPublicCert.d.ts.map +0 -1
  223. package/dist/api/manager/GetDeviceInfoSettings.d.ts +0 -7
  224. package/dist/api/manager/GetDeviceInfoSettings.d.ts.map +0 -1
  225. package/dist/api/manager/GetPublicKeyMultiple.d.ts +0 -7
  226. package/dist/api/manager/GetPublicKeyMultiple.d.ts.map +0 -1
  227. package/dist/api/manager/ListResDir.d.ts +0 -7
  228. package/dist/api/manager/ListResDir.d.ts.map +0 -1
  229. package/dist/api/manager/NFTWriteData.d.ts +0 -7
  230. package/dist/api/manager/NFTWriteData.d.ts.map +0 -1
  231. package/dist/api/manager/NFTWriteInfo.d.ts +0 -7
  232. package/dist/api/manager/NFTWriteInfo.d.ts.map +0 -1
  233. package/dist/api/manager/ReadSEPublicKey.d.ts +0 -7
  234. package/dist/api/manager/ReadSEPublicKey.d.ts.map +0 -1
  235. package/dist/api/manager/ResourceUpdate.d.ts +0 -6
  236. package/dist/api/manager/ResourceUpdate.d.ts.map +0 -1
  237. package/dist/api/methodExtension.d.ts +0 -13
  238. package/dist/api/methodExtension.d.ts.map +0 -1
  239. package/dist/api/monero/MoneroGetAddress.d.ts +0 -9
  240. package/dist/api/monero/MoneroGetAddress.d.ts.map +0 -1
  241. package/dist/api/monero/MoneroGetWatchKey.d.ts +0 -8
  242. package/dist/api/monero/MoneroGetWatchKey.d.ts.map +0 -1
  243. package/dist/api/nem/NEMDecryptMessage.d.ts +0 -8
  244. package/dist/api/nem/NEMDecryptMessage.d.ts.map +0 -1
  245. package/dist/api/protocol-v2/DeviceFactoryCertificateRead.d.ts +0 -7
  246. package/dist/api/protocol-v2/DeviceFactoryCertificateRead.d.ts.map +0 -1
  247. package/dist/api/protocol-v2/DeviceFactoryCertificateWrite.d.ts +0 -8
  248. package/dist/api/protocol-v2/DeviceFactoryCertificateWrite.d.ts.map +0 -1
  249. package/dist/api/protocol-v2/DeviceFactoryChallengeSign.d.ts +0 -8
  250. package/dist/api/protocol-v2/DeviceFactoryChallengeSign.d.ts.map +0 -1
  251. package/dist/api/testMethods.d.ts +0 -82
  252. package/dist/api/testMethods.d.ts.map +0 -1
  253. package/dist/api/tezos/TezosGetAddress.d.ts +0 -9
  254. package/dist/api/tezos/TezosGetAddress.d.ts.map +0 -1
  255. package/dist/api/tezos/TezosGetPublicKey.d.ts +0 -8
  256. package/dist/api/tezos/TezosGetPublicKey.d.ts.map +0 -1
  257. package/dist/api/tezos/TezosSignTx.d.ts +0 -12
  258. package/dist/api/tezos/TezosSignTx.d.ts.map +0 -1
  259. package/dist/types/api/binanceGetAddress.d.ts +0 -11
  260. package/dist/types/api/binanceGetAddress.d.ts.map +0 -1
  261. package/dist/types/api/binanceGetPublicKey.d.ts +0 -11
  262. package/dist/types/api/binanceGetPublicKey.d.ts.map +0 -1
  263. package/dist/types/api/binanceSignTx.d.ts +0 -7
  264. package/dist/types/api/binanceSignTx.d.ts.map +0 -1
  265. package/dist/types/api/bixinBackupDevice.d.ts +0 -4
  266. package/dist/types/api/bixinBackupDevice.d.ts.map +0 -1
  267. package/dist/types/api/bixinLoadDevice.d.ts +0 -4
  268. package/dist/types/api/bixinLoadDevice.d.ts.map +0 -1
  269. package/dist/types/api/bixinMessageSE.d.ts +0 -4
  270. package/dist/types/api/bixinMessageSE.d.ts.map +0 -1
  271. package/dist/types/api/bixinVerifyDeviceRequest.d.ts +0 -4
  272. package/dist/types/api/bixinVerifyDeviceRequest.d.ts.map +0 -1
  273. package/dist/types/api/btcAuthorizeCoinJoin.d.ts +0 -13
  274. package/dist/types/api/btcAuthorizeCoinJoin.d.ts.map +0 -1
  275. package/dist/types/api/btcGetOwnershipId.d.ts +0 -10
  276. package/dist/types/api/btcGetOwnershipId.d.ts.map +0 -1
  277. package/dist/types/api/btcGetOwnershipProof.d.ts +0 -13
  278. package/dist/types/api/btcGetOwnershipProof.d.ts.map +0 -1
  279. package/dist/types/api/cryptoBatchGetPublickeys.d.ts +0 -12
  280. package/dist/types/api/cryptoBatchGetPublickeys.d.ts.map +0 -1
  281. package/dist/types/api/cryptoCipherKeyValue.d.ts +0 -13
  282. package/dist/types/api/cryptoCipherKeyValue.d.ts.map +0 -1
  283. package/dist/types/api/cryptoCosiCommit.d.ts +0 -8
  284. package/dist/types/api/cryptoCosiCommit.d.ts.map +0 -1
  285. package/dist/types/api/cryptoCosiSign.d.ts +0 -10
  286. package/dist/types/api/cryptoCosiSign.d.ts.map +0 -1
  287. package/dist/types/api/cryptoGetECDHSessionKey.d.ts +0 -4
  288. package/dist/types/api/cryptoGetECDHSessionKey.d.ts.map +0 -1
  289. package/dist/types/api/cryptoSignIdentity.d.ts +0 -4
  290. package/dist/types/api/cryptoSignIdentity.d.ts.map +0 -1
  291. package/dist/types/api/debugLinkDecision.d.ts +0 -4
  292. package/dist/types/api/debugLinkDecision.d.ts.map +0 -1
  293. package/dist/types/api/debugLinkEraseSdCard.d.ts +0 -4
  294. package/dist/types/api/debugLinkEraseSdCard.d.ts.map +0 -1
  295. package/dist/types/api/debugLinkFlashErase.d.ts +0 -4
  296. package/dist/types/api/debugLinkFlashErase.d.ts.map +0 -1
  297. package/dist/types/api/debugLinkGetState.d.ts +0 -4
  298. package/dist/types/api/debugLinkGetState.d.ts.map +0 -1
  299. package/dist/types/api/debugLinkMemoryRead.d.ts +0 -4
  300. package/dist/types/api/debugLinkMemoryRead.d.ts.map +0 -1
  301. package/dist/types/api/debugLinkMemoryWrite.d.ts +0 -4
  302. package/dist/types/api/debugLinkMemoryWrite.d.ts.map +0 -1
  303. package/dist/types/api/debugLinkRecordScreen.d.ts +0 -4
  304. package/dist/types/api/debugLinkRecordScreen.d.ts.map +0 -1
  305. package/dist/types/api/debugLinkReseedRandom.d.ts +0 -4
  306. package/dist/types/api/debugLinkReseedRandom.d.ts.map +0 -1
  307. package/dist/types/api/debugLinkStop.d.ts +0 -4
  308. package/dist/types/api/debugLinkStop.d.ts.map +0 -1
  309. package/dist/types/api/debugLinkWatchLayout.d.ts +0 -4
  310. package/dist/types/api/debugLinkWatchLayout.d.ts.map +0 -1
  311. package/dist/types/api/deviceCancelAuthorization.d.ts +0 -4
  312. package/dist/types/api/deviceCancelAuthorization.d.ts.map +0 -1
  313. package/dist/types/api/deviceChangeWipeCode.d.ts +0 -4
  314. package/dist/types/api/deviceChangeWipeCode.d.ts.map +0 -1
  315. package/dist/types/api/deviceDoPreauthorized.d.ts +0 -4
  316. package/dist/types/api/deviceDoPreauthorized.d.ts.map +0 -1
  317. package/dist/types/api/deviceEndSession.d.ts +0 -4
  318. package/dist/types/api/deviceEndSession.d.ts.map +0 -1
  319. package/dist/types/api/deviceGetEntropy.d.ts +0 -4
  320. package/dist/types/api/deviceGetEntropy.d.ts.map +0 -1
  321. package/dist/types/api/deviceGetFirmwareHash.d.ts +0 -4
  322. package/dist/types/api/deviceGetFirmwareHash.d.ts.map +0 -1
  323. package/dist/types/api/deviceGetInfo.d.ts +0 -4
  324. package/dist/types/api/deviceGetInfo.d.ts.map +0 -1
  325. package/dist/types/api/deviceInfoSettings.d.ts +0 -4
  326. package/dist/types/api/deviceInfoSettings.d.ts.map +0 -1
  327. package/dist/types/api/deviceLoad.d.ts +0 -16
  328. package/dist/types/api/deviceLoad.d.ts.map +0 -1
  329. package/dist/types/api/devicePing.d.ts +0 -4
  330. package/dist/types/api/devicePing.d.ts.map +0 -1
  331. package/dist/types/api/deviceReadSEPublicCert.d.ts +0 -4
  332. package/dist/types/api/deviceReadSEPublicCert.d.ts.map +0 -1
  333. package/dist/types/api/deviceSESignMessage.d.ts +0 -4
  334. package/dist/types/api/deviceSESignMessage.d.ts.map +0 -1
  335. package/dist/types/api/deviceSdProtect.d.ts +0 -4
  336. package/dist/types/api/deviceSdProtect.d.ts.map +0 -1
  337. package/dist/types/api/deviceSpiFlashRead.d.ts +0 -4
  338. package/dist/types/api/deviceSpiFlashRead.d.ts.map +0 -1
  339. package/dist/types/api/deviceSpiFlashWrite.d.ts +0 -4
  340. package/dist/types/api/deviceSpiFlashWrite.d.ts.map +0 -1
  341. package/dist/types/api/deviceUnlockPath.d.ts +0 -11
  342. package/dist/types/api/deviceUnlockPath.d.ts.map +0 -1
  343. package/dist/types/api/deviceWriteSEPrivateKey.d.ts +0 -4
  344. package/dist/types/api/deviceWriteSEPrivateKey.d.ts.map +0 -1
  345. package/dist/types/api/deviceWriteSEPublicCert.d.ts +0 -4
  346. package/dist/types/api/deviceWriteSEPublicCert.d.ts.map +0 -1
  347. package/dist/types/api/emmcDirList.d.ts +0 -4
  348. package/dist/types/api/emmcDirList.d.ts.map +0 -1
  349. package/dist/types/api/emmcDirMake.d.ts +0 -4
  350. package/dist/types/api/emmcDirMake.d.ts.map +0 -1
  351. package/dist/types/api/emmcDirRemove.d.ts +0 -4
  352. package/dist/types/api/emmcDirRemove.d.ts.map +0 -1
  353. package/dist/types/api/emmcFileDelete.d.ts +0 -4
  354. package/dist/types/api/emmcFileDelete.d.ts.map +0 -1
  355. package/dist/types/api/emmcFileRead.d.ts +0 -4
  356. package/dist/types/api/emmcFileRead.d.ts.map +0 -1
  357. package/dist/types/api/emmcFileWrite.d.ts +0 -4
  358. package/dist/types/api/emmcFileWrite.d.ts.map +0 -1
  359. package/dist/types/api/emmcFixPermission.d.ts +0 -4
  360. package/dist/types/api/emmcFixPermission.d.ts.map +0 -1
  361. package/dist/types/api/emmcPathInfo.d.ts +0 -4
  362. package/dist/types/api/emmcPathInfo.d.ts.map +0 -1
  363. package/dist/types/api/eosGetPublicKey.d.ts +0 -8
  364. package/dist/types/api/eosGetPublicKey.d.ts.map +0 -1
  365. package/dist/types/api/eosSignTx.d.ts +0 -7
  366. package/dist/types/api/eosSignTx.d.ts.map +0 -1
  367. package/dist/types/api/evmGetAddressTrezor.d.ts +0 -15
  368. package/dist/types/api/evmGetAddressTrezor.d.ts.map +0 -1
  369. package/dist/types/api/evmGetPublicKeyTrezor.d.ts +0 -20
  370. package/dist/types/api/evmGetPublicKeyTrezor.d.ts.map +0 -1
  371. package/dist/types/api/evmSignMessageTrezor.d.ts +0 -9
  372. package/dist/types/api/evmSignMessageTrezor.d.ts.map +0 -1
  373. package/dist/types/api/evmSignTransactionTrezor.d.ts +0 -40
  374. package/dist/types/api/evmSignTransactionTrezor.d.ts.map +0 -1
  375. package/dist/types/api/evmSignTypedDataTrezor.d.ts +0 -34
  376. package/dist/types/api/evmSignTypedDataTrezor.d.ts.map +0 -1
  377. package/dist/types/api/evmVerifyMessageTrezor.d.ts +0 -10
  378. package/dist/types/api/evmVerifyMessageTrezor.d.ts.map +0 -1
  379. package/dist/types/api/firmwareErase.d.ts +0 -4
  380. package/dist/types/api/firmwareErase.d.ts.map +0 -1
  381. package/dist/types/api/firmwareEraseEx.d.ts +0 -4
  382. package/dist/types/api/firmwareEraseEx.d.ts.map +0 -1
  383. package/dist/types/api/firmwareUpdateEmmcTest.d.ts +0 -4
  384. package/dist/types/api/firmwareUpdateEmmcTest.d.ts.map +0 -1
  385. package/dist/types/api/firmwareUploadTest.d.ts +0 -4
  386. package/dist/types/api/firmwareUploadTest.d.ts.map +0 -1
  387. package/dist/types/api/getPublicKeyMultiple.d.ts +0 -4
  388. package/dist/types/api/getPublicKeyMultiple.d.ts.map +0 -1
  389. package/dist/types/api/listResDir.d.ts +0 -4
  390. package/dist/types/api/listResDir.d.ts.map +0 -1
  391. package/dist/types/api/moneroGetAddress.d.ts +0 -14
  392. package/dist/types/api/moneroGetAddress.d.ts.map +0 -1
  393. package/dist/types/api/moneroGetWatchKey.d.ts +0 -14
  394. package/dist/types/api/moneroGetWatchKey.d.ts.map +0 -1
  395. package/dist/types/api/nemDecryptMessage.d.ts +0 -10
  396. package/dist/types/api/nemDecryptMessage.d.ts.map +0 -1
  397. package/dist/types/api/nftWriteData.d.ts +0 -4
  398. package/dist/types/api/nftWriteData.d.ts.map +0 -1
  399. package/dist/types/api/nftWriteInfo.d.ts +0 -4
  400. package/dist/types/api/nftWriteInfo.d.ts.map +0 -1
  401. package/dist/types/api/readSEPublicKey.d.ts +0 -4
  402. package/dist/types/api/readSEPublicKey.d.ts.map +0 -1
  403. package/dist/types/api/reboot.d.ts +0 -4
  404. package/dist/types/api/reboot.d.ts.map +0 -1
  405. package/dist/types/api/resourceUpdate.d.ts +0 -7
  406. package/dist/types/api/resourceUpdate.d.ts.map +0 -1
  407. package/dist/types/api/selfTest.d.ts +0 -4
  408. package/dist/types/api/selfTest.d.ts.map +0 -1
  409. package/dist/types/api/tezosGetAddress.d.ts +0 -14
  410. package/dist/types/api/tezosGetAddress.d.ts.map +0 -1
  411. package/dist/types/api/tezosGetPublicKey.d.ts +0 -14
  412. package/dist/types/api/tezosGetPublicKey.d.ts.map +0 -1
  413. package/dist/types/api/tezosSignTx.d.ts +0 -7
  414. package/dist/types/api/tezosSignTx.d.ts.map +0 -1
  415. package/dist/types/api/webAuthnAddResidentCredential.d.ts +0 -4
  416. package/dist/types/api/webAuthnAddResidentCredential.d.ts.map +0 -1
  417. package/dist/types/api/webAuthnListResidentCredentials.d.ts +0 -4
  418. package/dist/types/api/webAuthnListResidentCredentials.d.ts.map +0 -1
  419. package/dist/types/api/webAuthnRemoveResidentCredential.d.ts +0 -4
  420. package/dist/types/api/webAuthnRemoveResidentCredential.d.ts.map +0 -1
  421. package/src/api/BixinBackupDevice.ts +0 -15
  422. package/src/api/BixinLoadDevice.ts +0 -22
  423. package/src/api/BixinMessageSE.ts +0 -22
  424. package/src/api/BixinVerifyDeviceRequest.ts +0 -22
  425. package/src/api/WebAuthnAddResidentCredential.ts +0 -22
  426. package/src/api/WebAuthnListResidentCredentials.ts +0 -24
  427. package/src/api/WebAuthnRemoveResidentCredential.ts +0 -22
  428. package/src/api/binance/BinanceGetAddress.ts +0 -26
  429. package/src/api/binance/BinanceGetPublicKey.ts +0 -26
  430. package/src/api/binance/BinanceSignTx.ts +0 -35
  431. package/src/api/btc/BTCAuthorizeCoinJoin.ts +0 -37
  432. package/src/api/btc/BTCGetOwnershipId.ts +0 -34
  433. package/src/api/btc/BTCGetOwnershipProof.ts +0 -37
  434. package/src/api/crypto/CryptoBatchGetPublickeys.ts +0 -30
  435. package/src/api/crypto/CryptoCipherKeyValue.ts +0 -29
  436. package/src/api/crypto/CryptoCosiCommit.ts +0 -24
  437. package/src/api/crypto/CryptoCosiSign.ts +0 -26
  438. package/src/api/crypto/CryptoGetECDHSessionKey.ts +0 -24
  439. package/src/api/crypto/CryptoSignIdentity.ts +0 -25
  440. package/src/api/debug/DebugLinkDecision.ts +0 -25
  441. package/src/api/debug/DebugLinkEraseSdCard.ts +0 -23
  442. package/src/api/debug/DebugLinkFlashErase.ts +0 -23
  443. package/src/api/debug/DebugLinkGetState.ts +0 -21
  444. package/src/api/debug/DebugLinkMemoryRead.ts +0 -24
  445. package/src/api/debug/DebugLinkMemoryWrite.ts +0 -25
  446. package/src/api/debug/DebugLinkRecordScreen.ts +0 -23
  447. package/src/api/debug/DebugLinkReseedRandom.ts +0 -23
  448. package/src/api/debug/DebugLinkStop.ts +0 -25
  449. package/src/api/debug/DebugLinkWatchLayout.ts +0 -23
  450. package/src/api/emmc/EmmcDirList.ts +0 -20
  451. package/src/api/emmc/EmmcDirMake.ts +0 -20
  452. package/src/api/emmc/EmmcDirRemove.ts +0 -20
  453. package/src/api/emmc/EmmcFileDelete.ts +0 -20
  454. package/src/api/emmc/EmmcFileRead.ts +0 -21
  455. package/src/api/emmc/EmmcFileWrite.ts +0 -23
  456. package/src/api/emmc/EmmcFixPermission.ts +0 -17
  457. package/src/api/emmc/EmmcPathInfo.ts +0 -20
  458. package/src/api/eos/EosGetPublicKey.ts +0 -26
  459. package/src/api/eos/EosSignTx.ts +0 -40
  460. package/src/api/evmTrezor/EVMGetAddress.ts +0 -75
  461. package/src/api/evmTrezor/EVMGetPublicKey.ts +0 -106
  462. package/src/api/evmTrezor/EVMSignMessage.ts +0 -40
  463. package/src/api/evmTrezor/EVMSignTransaction.ts +0 -83
  464. package/src/api/evmTrezor/EVMSignTypedData.ts +0 -366
  465. package/src/api/evmTrezor/EVMVerifyMessage.ts +0 -37
  466. package/src/api/evmTrezor/legacyV1/getAddress.ts +0 -16
  467. package/src/api/evmTrezor/legacyV1/getPublicKey.ts +0 -20
  468. package/src/api/evmTrezor/legacyV1/signMessage.ts +0 -22
  469. package/src/api/evmTrezor/legacyV1/signTransaction.ts +0 -24
  470. package/src/api/evmTrezor/legacyV1/signTypedData.ts +0 -36
  471. package/src/api/evmTrezor/legacyV1/signTypedHash.ts +0 -48
  472. package/src/api/evmTrezor/legacyV1/verifyMessage.ts +0 -19
  473. package/src/api/extensionMethodNames.ts +0 -88
  474. package/src/api/factoryMethods.ts +0 -2
  475. package/src/api/firmware/FirmwareErase.ts +0 -18
  476. package/src/api/firmware/FirmwareEraseEx.ts +0 -18
  477. package/src/api/firmware/FirmwareUpdateEmmcTest.ts +0 -18
  478. package/src/api/firmware/FirmwareUploadTest.ts +0 -17
  479. package/src/api/firmware/Reboot.ts +0 -17
  480. package/src/api/firmware/SelfTest.ts +0 -17
  481. package/src/api/manager/DeviceCancelAuthorization.ts +0 -15
  482. package/src/api/manager/DeviceChangeWipeCode.ts +0 -19
  483. package/src/api/manager/DeviceDoPreauthorized.ts +0 -15
  484. package/src/api/manager/DeviceEndSession.ts +0 -19
  485. package/src/api/manager/DeviceGetEntropy.ts +0 -19
  486. package/src/api/manager/DeviceGetFirmwareHash.ts +0 -23
  487. package/src/api/manager/DeviceInfoSettings.ts +0 -23
  488. package/src/api/manager/DeviceLoad.ts +0 -27
  489. package/src/api/manager/DevicePing.ts +0 -19
  490. package/src/api/manager/DeviceReadSEPublicCert.ts +0 -18
  491. package/src/api/manager/DeviceSESignMessage.ts +0 -23
  492. package/src/api/manager/DeviceSdProtect.ts +0 -18
  493. package/src/api/manager/DeviceSpiFlashRead.ts +0 -22
  494. package/src/api/manager/DeviceSpiFlashWrite.ts +0 -22
  495. package/src/api/manager/DeviceUnlockPath.ts +0 -26
  496. package/src/api/manager/DeviceWriteSEPrivateKey.ts +0 -23
  497. package/src/api/manager/DeviceWriteSEPublicCert.ts +0 -23
  498. package/src/api/manager/GetDeviceInfoSettings.ts +0 -20
  499. package/src/api/manager/GetPublicKeyMultiple.ts +0 -24
  500. package/src/api/manager/ListResDir.ts +0 -19
  501. package/src/api/manager/NFTWriteData.ts +0 -21
  502. package/src/api/manager/NFTWriteInfo.ts +0 -23
  503. package/src/api/manager/ReadSEPublicKey.ts +0 -20
  504. package/src/api/manager/ResourceUpdate.ts +0 -22
  505. package/src/api/methodExtension.ts +0 -27
  506. package/src/api/monero/MoneroGetAddress.ts +0 -64
  507. package/src/api/monero/MoneroGetWatchKey.ts +0 -59
  508. package/src/api/nem/NEMDecryptMessage.ts +0 -29
  509. package/src/api/protocol-v2/DeviceFactoryCertificateRead.ts +0 -25
  510. package/src/api/protocol-v2/DeviceFactoryCertificateWrite.ts +0 -30
  511. package/src/api/protocol-v2/DeviceFactoryChallengeSign.ts +0 -28
  512. package/src/api/testMethods.ts +0 -95
  513. package/src/api/tezos/TezosGetAddress.ts +0 -64
  514. package/src/api/tezos/TezosGetPublicKey.ts +0 -63
  515. package/src/api/tezos/TezosSignTx.ts +0 -44
  516. package/src/types/api/binanceGetAddress.ts +0 -17
  517. package/src/types/api/binanceGetPublicKey.ts +0 -17
  518. package/src/types/api/binanceSignTx.ts +0 -15
  519. package/src/types/api/bixinBackupDevice.ts +0 -8
  520. package/src/types/api/bixinLoadDevice.ts +0 -8
  521. package/src/types/api/bixinMessageSE.ts +0 -8
  522. package/src/types/api/bixinVerifyDeviceRequest.ts +0 -8
  523. package/src/types/api/btcAuthorizeCoinJoin.ts +0 -18
  524. package/src/types/api/btcGetOwnershipId.ts +0 -19
  525. package/src/types/api/btcGetOwnershipProof.ts +0 -22
  526. package/src/types/api/cryptoBatchGetPublickeys.ts +0 -18
  527. package/src/types/api/cryptoCipherKeyValue.ts +0 -18
  528. package/src/types/api/cryptoCosiCommit.ts +0 -13
  529. package/src/types/api/cryptoCosiSign.ts +0 -15
  530. package/src/types/api/cryptoGetECDHSessionKey.ts +0 -8
  531. package/src/types/api/cryptoSignIdentity.ts +0 -8
  532. package/src/types/api/debugLinkDecision.ts +0 -7
  533. package/src/types/api/debugLinkEraseSdCard.ts +0 -7
  534. package/src/types/api/debugLinkFlashErase.ts +0 -7
  535. package/src/types/api/debugLinkGetState.ts +0 -7
  536. package/src/types/api/debugLinkMemoryRead.ts +0 -7
  537. package/src/types/api/debugLinkMemoryWrite.ts +0 -7
  538. package/src/types/api/debugLinkRecordScreen.ts +0 -7
  539. package/src/types/api/debugLinkReseedRandom.ts +0 -7
  540. package/src/types/api/debugLinkStop.ts +0 -7
  541. package/src/types/api/debugLinkWatchLayout.ts +0 -7
  542. package/src/types/api/deviceCancelAuthorization.ts +0 -7
  543. package/src/types/api/deviceChangeWipeCode.ts +0 -7
  544. package/src/types/api/deviceDoPreauthorized.ts +0 -7
  545. package/src/types/api/deviceEndSession.ts +0 -7
  546. package/src/types/api/deviceGetEntropy.ts +0 -7
  547. package/src/types/api/deviceGetFirmwareHash.ts +0 -7
  548. package/src/types/api/deviceGetInfo.ts +0 -7
  549. package/src/types/api/deviceInfoSettings.ts +0 -7
  550. package/src/types/api/deviceLoad.ts +0 -19
  551. package/src/types/api/devicePing.ts +0 -7
  552. package/src/types/api/deviceReadSEPublicCert.ts +0 -7
  553. package/src/types/api/deviceSESignMessage.ts +0 -7
  554. package/src/types/api/deviceSdProtect.ts +0 -7
  555. package/src/types/api/deviceSpiFlashRead.ts +0 -7
  556. package/src/types/api/deviceSpiFlashWrite.ts +0 -7
  557. package/src/types/api/deviceUnlockPath.ts +0 -16
  558. package/src/types/api/deviceWriteSEPrivateKey.ts +0 -7
  559. package/src/types/api/deviceWriteSEPublicCert.ts +0 -7
  560. package/src/types/api/emmcDirList.ts +0 -7
  561. package/src/types/api/emmcDirMake.ts +0 -7
  562. package/src/types/api/emmcDirRemove.ts +0 -7
  563. package/src/types/api/emmcFileDelete.ts +0 -7
  564. package/src/types/api/emmcFileRead.ts +0 -7
  565. package/src/types/api/emmcFileWrite.ts +0 -7
  566. package/src/types/api/emmcFixPermission.ts +0 -7
  567. package/src/types/api/emmcPathInfo.ts +0 -7
  568. package/src/types/api/eosGetPublicKey.ts +0 -13
  569. package/src/types/api/eosSignTx.ts +0 -12
  570. package/src/types/api/evmGetAddressTrezor.ts +0 -24
  571. package/src/types/api/evmGetPublicKeyTrezor.ts +0 -31
  572. package/src/types/api/evmSignMessageTrezor.ts +0 -14
  573. package/src/types/api/evmSignTransactionTrezor.ts +0 -49
  574. package/src/types/api/evmSignTypedDataTrezor.ts +0 -42
  575. package/src/types/api/evmVerifyMessageTrezor.ts +0 -15
  576. package/src/types/api/firmwareErase.ts +0 -4
  577. package/src/types/api/firmwareEraseEx.ts +0 -7
  578. package/src/types/api/firmwareUpdateEmmcTest.ts +0 -7
  579. package/src/types/api/firmwareUploadTest.ts +0 -7
  580. package/src/types/api/getPublicKeyMultiple.ts +0 -11
  581. package/src/types/api/listResDir.ts +0 -8
  582. package/src/types/api/moneroGetAddress.ts +0 -23
  583. package/src/types/api/moneroGetWatchKey.ts +0 -26
  584. package/src/types/api/nemDecryptMessage.ts +0 -15
  585. package/src/types/api/nftWriteData.ts +0 -8
  586. package/src/types/api/nftWriteInfo.ts +0 -8
  587. package/src/types/api/readSEPublicKey.ts +0 -8
  588. package/src/types/api/reboot.ts +0 -4
  589. package/src/types/api/resourceUpdate.ts +0 -11
  590. package/src/types/api/selfTest.ts +0 -7
  591. package/src/types/api/tezosGetAddress.ts +0 -23
  592. package/src/types/api/tezosGetPublicKey.ts +0 -23
  593. package/src/types/api/tezosSignTx.ts +0 -12
  594. package/src/types/api/webAuthnAddResidentCredential.ts +0 -8
  595. package/src/types/api/webAuthnListResidentCredentials.ts +0 -8
  596. package/src/types/api/webAuthnRemoveResidentCredential.ts +0 -8
@@ -1,83 +0,0 @@
1
- import { ERRORS } from '@onekeyfe/hd-shared';
2
-
3
- import { UI_REQUEST } from '../../constants/ui-request';
4
- import { validatePath } from '../helpers/pathUtils';
5
- import { BaseMethod } from '../BaseMethod';
6
- import { validateParams } from '../helpers/paramsValidator';
7
- import { formatAnyHex } from '../helpers/hexUtils';
8
- import { signTransaction as signTransactionLegacyV1 } from './legacyV1/signTransaction';
9
-
10
- import type { EVMSignTransactionParams, EVMTransaction, EVMTransactionEIP1559 } from '../../types';
11
- import type { SchemaParam } from '../helpers/paramsValidator';
12
-
13
- export default class EVMSignTransaction extends BaseMethod {
14
- addressN: number[] = [];
15
-
16
- isEIP1559 = false;
17
-
18
- formattedTx: EVMTransaction | EVMTransactionEIP1559 | undefined;
19
-
20
- init() {
21
- this.checkDeviceId = true;
22
- this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
23
-
24
- validateParams(this.payload, [
25
- { name: 'path', required: true },
26
- { name: 'transaction', type: 'object', required: true },
27
- ]);
28
- const { path, transaction } = this.payload;
29
- this.addressN = validatePath(path, 3);
30
-
31
- const tx: EVMSignTransactionParams['transaction'] = transaction;
32
-
33
- this.isEIP1559 = !!tx.maxFeePerGas && !!tx.maxPriorityFeePerGas;
34
-
35
- // check if transaction is valid
36
- const schema: SchemaParam[] = [
37
- { name: 'to', type: 'hexString', required: true },
38
- { name: 'value', type: 'hexString', required: true },
39
- { name: 'gasLimit', type: 'hexString', required: true },
40
- { name: 'nonce', type: 'hexString', required: true },
41
- { name: 'chainId', type: 'number', required: true },
42
- { name: 'data', type: 'hexString' },
43
- ];
44
- if (this.isEIP1559) {
45
- schema.push({ name: 'maxFeePerGas', type: 'hexString', required: true });
46
- schema.push({ name: 'maxPriorityFeePerGas', type: 'hexString', required: true });
47
- } else {
48
- schema.push({ name: 'gasPrice', type: 'hexString', required: true });
49
- schema.push({ name: 'txType', type: 'number' });
50
- }
51
- validateParams(tx, schema);
52
-
53
- this.formattedTx = formatAnyHex(tx);
54
- }
55
-
56
- getVersionRange() {
57
- if (this.isEIP1559) {
58
- return {
59
- model_mini: {
60
- min: '2.1.11',
61
- },
62
- };
63
- }
64
- return {
65
- model_mini: {
66
- min: '1.0.0',
67
- },
68
- };
69
- }
70
-
71
- async run() {
72
- const { addressN, isEIP1559, formattedTx } = this;
73
-
74
- if (formattedTx == null) throw ERRORS.TypedError('Runtime', 'formattedTx is not set');
75
-
76
- return signTransactionLegacyV1({
77
- typedCall: this.device.commands.typedCall.bind(this.device.commands),
78
- addressN,
79
- tx: formattedTx,
80
- isEIP1559,
81
- });
82
- }
83
- }
@@ -1,366 +0,0 @@
1
- import semver from 'semver';
2
- import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
3
- import { get } from 'lodash';
4
-
5
- import { UI_REQUEST } from '../../constants/ui-request';
6
- import { validatePath } from '../helpers/pathUtils';
7
- import { BaseMethod } from '../BaseMethod';
8
- import { validateParams } from '../helpers/paramsValidator';
9
- import { formatAnyHex } from '../helpers/hexUtils';
10
- import { getDeviceFirmwareVersion, getDeviceType } from '../../utils';
11
- import {
12
- DeviceModelToTypes,
13
- type EthereumSignTypedDataMessage,
14
- type EthereumSignTypedDataTypes,
15
- } from '../../types';
16
- import { signTypedHash as signTypedHashLegacyV1 } from './legacyV1/signTypedHash';
17
- import { signTypedData as signTypedDataLegacyV1 } from './legacyV1/signTypedData';
18
- import { encodeData, getFieldType, parseArrayType } from '../helpers/typeNameUtils';
19
-
20
- import type {
21
- EthereumTypedDataSignature,
22
- EthereumTypedDataStructAck,
23
- MessageKey,
24
- MessageResponse,
25
- TypedCall,
26
- } from '@onekeyfe/hd-transport';
27
-
28
- export type EVMSignTypedDataParams = {
29
- addressN: number[];
30
- metamaskV4Compat: boolean;
31
- data: EthereumSignTypedDataMessage<EthereumSignTypedDataTypes>;
32
- domainHash?: string;
33
- messageHash?: string;
34
- chainId?: number;
35
- };
36
-
37
- export default class EVMSignTypedData extends BaseMethod<EVMSignTypedDataParams> {
38
- init() {
39
- this.checkDeviceId = true;
40
- this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
41
-
42
- validateParams(this.payload, [
43
- { name: 'path', required: true },
44
- { name: 'metamaskV4Compat', type: 'boolean' },
45
- { name: 'data', type: 'object' },
46
- { name: 'domainHash', type: 'hexString' },
47
- { name: 'messageHash', type: 'hexString' },
48
- { name: 'chainId', type: 'number' },
49
- ]);
50
-
51
- const { path, data, metamaskV4Compat, domainHash, messageHash, chainId } = this.payload;
52
-
53
- const addressN = validatePath(path, 3);
54
-
55
- this.params = {
56
- addressN,
57
- metamaskV4Compat,
58
- data,
59
- chainId,
60
- };
61
-
62
- if (domainHash) {
63
- this.params.domainHash = formatAnyHex(domainHash);
64
- if (messageHash) {
65
- this.params.messageHash = formatAnyHex(messageHash);
66
- } else if (!!data && (!data.primaryType || data.primaryType !== 'EIP712Domain')) {
67
- throw ERRORS.TypedError(
68
- HardwareErrorCode.CallMethodInvalidParameter,
69
- 'message_hash should only be empty when data.primaryType=EIP712Domain'
70
- );
71
- }
72
- }
73
- }
74
-
75
- async handleSignTypedData({
76
- typedCall,
77
- signData,
78
- response,
79
- }: {
80
- typedCall: TypedCall;
81
- signData: EthereumSignTypedDataMessage<EthereumSignTypedDataTypes>;
82
- response: MessageResponse<MessageKey>;
83
- }) {
84
- const {
85
- types,
86
- primaryType,
87
- domain,
88
- message,
89
- }: EthereumSignTypedDataMessage<EthereumSignTypedDataTypes> = signData;
90
-
91
- while (response.type === 'EthereumTypedDataStructRequest') {
92
- // @ts-ignore
93
- const { name: typeDefinitionName } = response.message;
94
- const typeDefinition = types[typeDefinitionName];
95
- if (typeDefinition === undefined) {
96
- throw ERRORS.TypedError(
97
- 'Runtime',
98
- `Type ${typeDefinitionName} was not defined in types object`
99
- );
100
- }
101
-
102
- const dataStruckAck: EthereumTypedDataStructAck = {
103
- members: typeDefinition.map(({ name, type: typeName }) => ({
104
- name,
105
- type: getFieldType(typeName, types),
106
- })),
107
- };
108
-
109
- response = await typedCall(
110
- 'EthereumTypedDataStructAck',
111
- // @ts-ignore
112
- [
113
- 'EthereumTypedDataStructRequest',
114
- 'EthereumTypedDataValueRequest',
115
- 'EthereumTypedDataSignature',
116
- ],
117
- dataStruckAck
118
- );
119
- }
120
-
121
- while (response.type === 'EthereumTypedDataValueRequest') {
122
- // @ts-ignore
123
- const { member_path } = response.message;
124
-
125
- let memberData;
126
- let memberTypeName: string;
127
-
128
- const [rootIndex, ...nestedMemberPath] = member_path;
129
- switch (rootIndex) {
130
- case 0:
131
- memberData = domain;
132
- memberTypeName = 'EIP712Domain';
133
- break;
134
- case 1:
135
- memberData = message;
136
- memberTypeName = primaryType as string;
137
- break;
138
- default:
139
- throw ERRORS.TypedError('Runtime', 'Root index can only be 0 or 1');
140
- }
141
-
142
- for (const index of nestedMemberPath) {
143
- if (Array.isArray(memberData)) {
144
- memberTypeName = parseArrayType(memberTypeName).entryTypeName;
145
- memberData = memberData[index];
146
- } else if (typeof memberData === 'object' && memberData !== null) {
147
- const memberTypeDefinition = types[memberTypeName][index];
148
- memberTypeName = memberTypeDefinition.type;
149
- memberData = (memberData as Record<string, unknown>)[memberTypeDefinition.name];
150
- } else {
151
- // TODO
152
- }
153
- }
154
-
155
- let encodedData;
156
- if (Array.isArray(memberData)) {
157
- // Sending the length as uint16
158
- encodedData = encodeData('uint16', memberData.length);
159
- } else {
160
- encodedData = encodeData(memberTypeName, memberData);
161
- }
162
-
163
- response = await typedCall(
164
- 'EthereumTypedDataValueAck',
165
- // @ts-ignore
166
- ['EthereumTypedDataValueRequest', 'EthereumTypedDataSignature'],
167
- {
168
- value: encodedData,
169
- }
170
- );
171
- }
172
-
173
- if (response.type !== 'EthereumTypedDataSignature') {
174
- throw ERRORS.TypedError('Runtime', 'Unexpected response type');
175
- }
176
-
177
- // @ts-ignore
178
- const { address, signature }: EthereumTypedDataSignature = response.message;
179
- return {
180
- address,
181
- signature,
182
- };
183
- }
184
-
185
- async signTypedData() {
186
- const { addressN, data, metamaskV4Compat, chainId } = this.params;
187
-
188
- const response = await signTypedDataLegacyV1({
189
- typedCall: this.device.commands.typedCall.bind(this.device.commands),
190
- addressN,
191
- data,
192
- metamaskV4Compat,
193
- chainId,
194
- });
195
-
196
- return this.handleSignTypedData({
197
- typedCall: this.device.commands.typedCall.bind(this.device.commands),
198
- signData: data,
199
- response,
200
- });
201
- }
202
-
203
- signTypedHash({
204
- typedCall,
205
- addressN,
206
- domainHash,
207
- messageHash,
208
- chainId,
209
- }: {
210
- typedCall: TypedCall;
211
- addressN: number[];
212
- domainHash: string | undefined;
213
- messageHash: string | undefined;
214
- chainId: number | undefined;
215
- }) {
216
- if (!domainHash) throw ERRORS.TypedError('Runtime', 'domainHash is required');
217
-
218
- return signTypedHashLegacyV1({
219
- typedCall,
220
- addressN,
221
- chainId,
222
- domainHash,
223
- messageHash,
224
- device: this.device,
225
- });
226
- }
227
-
228
- getVersionRange() {
229
- return {
230
- model_mini: {
231
- min: '2.1.9',
232
- },
233
- };
234
- }
235
-
236
- hasBiggerData(item: EthereumSignTypedDataMessage<EthereumSignTypedDataTypes>) {
237
- const data = get(item.message, 'data', undefined) as string | undefined;
238
- if (!data) return false;
239
-
240
- let biggerLimit = 1024; // 1k
241
-
242
- const currentVersion = getDeviceFirmwareVersion(this.device.features).join('.');
243
- const supportBiggerDataVersion = '4.4.0';
244
-
245
- if (semver.gte(currentVersion, supportBiggerDataVersion)) {
246
- biggerLimit = 1536; // 1.5k
247
- }
248
-
249
- const startIndex = data.startsWith('0x') ? 2 : 0;
250
- return (data.length - startIndex) / 2 > biggerLimit;
251
- }
252
-
253
- hasNestedArrays(item: any): boolean {
254
- if (!item) return false;
255
-
256
- if (Array.isArray(item)) {
257
- // item is an array
258
- for (const element of item) {
259
- if (Array.isArray(element)) {
260
- // element is a nested array
261
- return true;
262
- }
263
- if (typeof element === 'object' && element !== null) {
264
- // element is an object, so check its properties recursively
265
- if (this.hasNestedArrays(element)) {
266
- return true;
267
- }
268
- }
269
- }
270
- } else if (typeof item === 'object' && item !== null) {
271
- // item is an object, so check its properties recursively
272
- // eslint-disable-next-line no-restricted-syntax
273
- for (const property in item) {
274
- if (this.hasNestedArrays(item[property])) {
275
- return true;
276
- }
277
- }
278
- }
279
- // no nested arrays found
280
- return false;
281
- }
282
-
283
- supportSignTyped() {
284
- const deviceType = getDeviceType(this.device.features);
285
- if (DeviceModelToTypes.model_mini.includes(deviceType)) {
286
- const currentVersion = getDeviceFirmwareVersion(this.device.features).join('.');
287
- const supportSignTypedVersion = '2.2.0';
288
-
289
- if (semver.lt(currentVersion, supportSignTypedVersion)) {
290
- return false;
291
- }
292
- }
293
-
294
- return true;
295
- }
296
-
297
- async run() {
298
- if (!this.device.features) {
299
- throw ERRORS.TypedError(
300
- 'Device_InitializeFailed',
301
- 'Device initialization failed. Please try again.'
302
- );
303
- }
304
-
305
- const { addressN, chainId } = this.params;
306
-
307
- // For Classic、Mini device we use EthereumSignTypedData
308
- const deviceType = getDeviceType(this.device.features);
309
- if (DeviceModelToTypes.model_mini.includes(deviceType)) {
310
- validateParams(this.params, [
311
- { name: 'domainHash', type: 'hexString', required: true },
312
- { name: 'messageHash', type: 'hexString', required: true },
313
- ]);
314
-
315
- const { domainHash, messageHash } = this.params;
316
-
317
- let response;
318
- if (this.supportSignTyped()) {
319
- response = await this.signTypedHash({
320
- typedCall: this.device.commands.typedCall.bind(this.device.commands),
321
- addressN,
322
- chainId,
323
- domainHash,
324
- messageHash,
325
- });
326
- } else {
327
- response = await this.device.commands.typedCall(
328
- 'EthereumSignMessageEIP712',
329
- 'EthereumMessageSignature',
330
- {
331
- address_n: addressN,
332
- domain_hash: domainHash ?? '',
333
- message_hash: messageHash ?? '',
334
- }
335
- );
336
- }
337
-
338
- return Promise.resolve(response.message);
339
- }
340
-
341
- // Touch Pro Sign NestedArrays
342
- if (this.hasNestedArrays(this.params.data) || this.hasBiggerData(this.params.data)) {
343
- validateParams(this.params, [
344
- { name: 'domainHash', type: 'hexString', required: true },
345
- { name: 'messageHash', type: 'hexString', required: true },
346
- ]);
347
-
348
- const { domainHash, messageHash } = this.params;
349
-
350
- if (!domainHash) throw ERRORS.TypedError('Runtime', 'domainHash is required');
351
-
352
- const response = await this.signTypedHash({
353
- typedCall: this.device.commands.typedCall.bind(this.device.commands),
354
- addressN,
355
- chainId,
356
- domainHash,
357
- messageHash,
358
- });
359
-
360
- return Promise.resolve(response.message);
361
- }
362
-
363
- // For Touch、Pro we use EthereumSignTypedData
364
- return this.signTypedData();
365
- }
366
- }
@@ -1,37 +0,0 @@
1
- import { UI_REQUEST } from '../../constants/ui-request';
2
- import { BaseMethod } from '../BaseMethod';
3
- import { validateParams } from '../helpers/paramsValidator';
4
- import { formatAnyHex } from '../helpers/hexUtils';
5
- import verifyMessageLegacyV1 from './legacyV1/verifyMessage';
6
-
7
- import type { EthereumVerifyMessageOneKey } from '@onekeyfe/hd-transport';
8
-
9
- export default class EVMSignMessage extends BaseMethod<EthereumVerifyMessageOneKey> {
10
- init() {
11
- this.checkDeviceId = true;
12
- this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
13
-
14
- validateParams(this.payload, [
15
- { name: 'address', type: 'string', required: true },
16
- { name: 'messageHex', type: 'hexString', required: true },
17
- { name: 'signature', type: 'hexString', required: true },
18
- { name: 'chainId', type: 'number' },
19
- ]);
20
-
21
- const { address, messageHex, signature } = formatAnyHex(this.payload);
22
-
23
- this.params = {
24
- address,
25
- message: messageHex,
26
- signature,
27
- chain_id: this.payload.chainId,
28
- };
29
- }
30
-
31
- async run() {
32
- return verifyMessageLegacyV1({
33
- typedCall: this.device.commands.typedCall.bind(this.device.commands),
34
- params: this.params,
35
- });
36
- }
37
- }
@@ -1,16 +0,0 @@
1
- import type { EthereumGetAddressOneKey, MessageResponse, TypedCall } from '@onekeyfe/hd-transport';
2
-
3
- export default async function ({
4
- typedCall,
5
- param,
6
- }: {
7
- typedCall: TypedCall;
8
- param: EthereumGetAddressOneKey;
9
- }): Promise<MessageResponse<'EthereumAddress'>> {
10
- const message = {
11
- address_n: param.address_n,
12
- show_display: param.show_display,
13
- chain_id: param.chain_id,
14
- };
15
- return typedCall('EthereumGetAddress', 'EthereumAddress', message);
16
- }
@@ -1,20 +0,0 @@
1
- import type {
2
- EthereumGetPublicKeyOneKey,
3
- MessageResponse,
4
- TypedCall,
5
- } from '@onekeyfe/hd-transport';
6
-
7
- export default async function ({
8
- typedCall,
9
- param,
10
- }: {
11
- typedCall: TypedCall;
12
- param: EthereumGetPublicKeyOneKey;
13
- }): Promise<MessageResponse<'EthereumPublicKey'>> {
14
- const message = {
15
- address_n: param.address_n,
16
- show_display: param.show_display,
17
- chain_id: param.chain_id,
18
- };
19
- return typedCall('EthereumGetPublicKey', 'EthereumPublicKey', message);
20
- }
@@ -1,22 +0,0 @@
1
- import type {
2
- EthereumMessageSignature,
3
- EthereumSignMessageOneKey,
4
- TypedCall,
5
- } from '@onekeyfe/hd-transport';
6
-
7
- export default async function ({
8
- typedCall,
9
- params,
10
- }: {
11
- typedCall: TypedCall;
12
- params: EthereumSignMessageOneKey;
13
- }): Promise<EthereumMessageSignature> {
14
- const message = {
15
- address_n: params.address_n,
16
- message: params.message,
17
- chain_id: params.chain_id,
18
- };
19
- const res = await typedCall('EthereumSignMessage', 'EthereumMessageSignature', message);
20
-
21
- return Promise.resolve(res.message);
22
- }
@@ -1,24 +0,0 @@
1
- import { evmSignTx, evmSignTxEip1559 } from '../../evm/latest/signTransaction';
2
-
3
- import type { TypedCall } from '@onekeyfe/hd-transport';
4
- import type { EVMTransaction, EVMTransactionEIP1559 } from '../../../types';
5
-
6
- export const signTransaction = async ({
7
- typedCall,
8
- isEIP1559,
9
- addressN,
10
- tx,
11
- }: {
12
- addressN: number[];
13
- tx: EVMTransaction | EVMTransactionEIP1559;
14
- isEIP1559: boolean;
15
- typedCall: TypedCall;
16
- }) =>
17
- isEIP1559
18
- ? evmSignTxEip1559({
19
- typedCall,
20
- addressN,
21
- tx: tx as EVMTransactionEIP1559,
22
- supportTrezor: true,
23
- })
24
- : evmSignTx({ typedCall, addressN, tx: tx as EVMTransaction, supportTrezor: true });
@@ -1,36 +0,0 @@
1
- import type { TypedCall } from '@onekeyfe/hd-transport';
2
- import type { EthereumSignTypedDataMessage, EthereumSignTypedDataTypes } from '../../../types';
3
-
4
- export const signTypedData = async ({
5
- typedCall,
6
- addressN,
7
- data,
8
- metamaskV4Compat,
9
- chainId,
10
- }: {
11
- typedCall: TypedCall;
12
- addressN: number[];
13
- data: EthereumSignTypedDataMessage<EthereumSignTypedDataTypes>;
14
- metamaskV4Compat: boolean;
15
- chainId?: number;
16
- }) => {
17
- const { primaryType }: EthereumSignTypedDataMessage<EthereumSignTypedDataTypes> = data;
18
-
19
- const message = {
20
- address_n: addressN,
21
- primary_type: primaryType as string,
22
- metamask_v4_compat: metamaskV4Compat,
23
- chain_id: chainId,
24
- };
25
- const response = await typedCall(
26
- 'EthereumSignTypedData',
27
- [
28
- 'EthereumTypedDataStructRequest',
29
- 'EthereumTypedDataValueRequest',
30
- 'EthereumTypedDataSignature',
31
- 'EthereumGnosisSafeTxRequest',
32
- ],
33
- message
34
- );
35
- return response;
36
- };
@@ -1,48 +0,0 @@
1
- import semver from 'semver';
2
- import { EDeviceType, ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
3
-
4
- import type { Device } from '../../../device/Device';
5
- import type { MessageResponse, TypedCall } from '@onekeyfe/hd-transport';
6
-
7
- export const signTypedHash = async ({
8
- typedCall,
9
- addressN,
10
- device,
11
- chainId,
12
- domainHash,
13
- messageHash,
14
- }: {
15
- typedCall: TypedCall;
16
- addressN: number[];
17
- device: Device;
18
- chainId: number | undefined;
19
- domainHash: string;
20
- messageHash: string | undefined;
21
- }): Promise<
22
- | MessageResponse<'EthereumTypedDataSignature'>
23
- | MessageResponse<'EthereumTypedDataSignatureOneKey'>
24
- > => {
25
- const deviceType = device.getCurrentDeviceType();
26
- if (deviceType === EDeviceType.Touch || deviceType === EDeviceType.Pro) {
27
- // Touch Pro Sign NestedArrays
28
- const currentVersion = device.getCurrentFirmwareVersionString() ?? '0.0.0';
29
- const supportNestedArraysSignVersion = '4.2.0';
30
-
31
- // 4.2.0 is the first version that supports nested arrays in signTypedData
32
- if (semver.lt(currentVersion, supportNestedArraysSignVersion)) {
33
- throw ERRORS.TypedError(
34
- HardwareErrorCode.CallMethodNeedUpgradeFirmware,
35
- `Device firmware version is too low, please update to ${supportNestedArraysSignVersion}`,
36
- { current: currentVersion, require: supportNestedArraysSignVersion }
37
- );
38
- }
39
- }
40
-
41
- const message = {
42
- address_n: addressN,
43
- domain_separator_hash: domainHash ?? '',
44
- message_hash: messageHash,
45
- chain_id: chainId,
46
- };
47
- return typedCall('EthereumSignTypedHash', 'EthereumTypedDataSignature', message);
48
- };
@@ -1,19 +0,0 @@
1
- import type { EthereumVerifyMessageOneKey, Success, TypedCall } from '@onekeyfe/hd-transport';
2
-
3
- export default async function ({
4
- typedCall,
5
- params,
6
- }: {
7
- typedCall: TypedCall;
8
- params: EthereumVerifyMessageOneKey;
9
- }): Promise<Success> {
10
- const message = {
11
- signature: params.signature,
12
- message: params.message,
13
- address: params.address,
14
- chain_id: params.chain_id,
15
- };
16
- const res = await typedCall('EthereumVerifyMessage', 'Success', message);
17
-
18
- return Promise.resolve(res.message);
19
- }