@trezor/connect 10.0.0-beta.1 → 10.0.0-beta.2

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 (429) hide show
  1. package/CHANGELOG.md +56 -9
  2. package/README.md +4 -2
  3. package/lib/exports.d.ts +1 -3
  4. package/lib/exports.js +1 -3
  5. package/lib/impl/core-in-module-native.d.ts +7 -0
  6. package/lib/impl/core-in-module-native.js +11 -0
  7. package/lib/impl/core-in-module-node.d.ts +8 -0
  8. package/lib/impl/core-in-module-node.js +12 -0
  9. package/lib/impl/core-in-module-web.d.ts +9 -0
  10. package/lib/impl/core-in-module-web.js +26 -0
  11. package/lib/index.browser.js +2 -26
  12. package/lib/index.js +1 -11
  13. package/lib/index.native.d.ts +4 -0
  14. package/lib/index.native.js +5 -0
  15. package/package.json +16 -67
  16. package/lib/api/applyFlags.d.ts +0 -20
  17. package/lib/api/applyFlags.js +0 -38
  18. package/lib/api/applySettings.d.ts +0 -20
  19. package/lib/api/applySettings.js +0 -57
  20. package/lib/api/authenticateDevice.d.ts +0 -25
  21. package/lib/api/authenticateDevice.js +0 -195
  22. package/lib/api/authorizeCoinjoin.d.ts +0 -11
  23. package/lib/api/authorizeCoinjoin.js +0 -44
  24. package/lib/api/backupDevice.d.ts +0 -19
  25. package/lib/api/backupDevice.js +0 -39
  26. package/lib/api/bitcoin/TransactionComposer.d.ts +0 -46
  27. package/lib/api/bitcoin/TransactionComposer.js +0 -147
  28. package/lib/api/bitcoin/createPendingTx.d.ts +0 -37
  29. package/lib/api/bitcoin/createPendingTx.js +0 -55
  30. package/lib/api/bitcoin/enhanceSignTx.d.ts +0 -2
  31. package/lib/api/bitcoin/enhanceSignTx.js +0 -23
  32. package/lib/api/bitcoin/index.d.ts +0 -9
  33. package/lib/api/bitcoin/index.js +0 -9
  34. package/lib/api/bitcoin/inputs.d.ts +0 -4
  35. package/lib/api/bitcoin/inputs.js +0 -63
  36. package/lib/api/bitcoin/outputs.d.ts +0 -5
  37. package/lib/api/bitcoin/outputs.js +0 -128
  38. package/lib/api/bitcoin/refTx.d.ts +0 -23
  39. package/lib/api/bitcoin/refTx.js +0 -249
  40. package/lib/api/bitcoin/signtx.d.ts +0 -30
  41. package/lib/api/bitcoin/signtx.js +0 -229
  42. package/lib/api/bitcoin/signtxLegacy.d.ts +0 -10
  43. package/lib/api/bitcoin/signtxLegacy.js +0 -186
  44. package/lib/api/bitcoin/signtxVerify.d.ts +0 -12
  45. package/lib/api/bitcoin/signtxVerify.js +0 -95
  46. package/lib/api/bitcoin/transactionBytes.d.ts +0 -3
  47. package/lib/api/bitcoin/transactionBytes.js +0 -65
  48. package/lib/api/bleUnpair.d.ts +0 -11
  49. package/lib/api/bleUnpair.js +0 -37
  50. package/lib/api/blockchainDisconnect.d.ts +0 -16
  51. package/lib/api/blockchainDisconnect.js +0 -37
  52. package/lib/api/blockchainEstimateFee.d.ts +0 -16
  53. package/lib/api/blockchainEstimateFee.js +0 -102
  54. package/lib/api/blockchainEvmRpcCall.d.ts +0 -19
  55. package/lib/api/blockchainEvmRpcCall.js +0 -57
  56. package/lib/api/blockchainGetAccountBalanceHistory.d.ts +0 -16
  57. package/lib/api/blockchainGetAccountBalanceHistory.js +0 -60
  58. package/lib/api/blockchainGetContractInfo.d.ts +0 -16
  59. package/lib/api/blockchainGetContractInfo.js +0 -46
  60. package/lib/api/blockchainGetCurrentFiatRates.d.ts +0 -20
  61. package/lib/api/blockchainGetCurrentFiatRates.js +0 -49
  62. package/lib/api/blockchainGetFiatRatesForTimestamps.d.ts +0 -23
  63. package/lib/api/blockchainGetFiatRatesForTimestamps.js +0 -55
  64. package/lib/api/blockchainGetInfo.d.ts +0 -15
  65. package/lib/api/blockchainGetInfo.js +0 -37
  66. package/lib/api/blockchainGetTransactions.d.ts +0 -18
  67. package/lib/api/blockchainGetTransactions.js +0 -47
  68. package/lib/api/blockchainSetCustomBackend.d.ts +0 -17
  69. package/lib/api/blockchainSetCustomBackend.js +0 -43
  70. package/lib/api/blockchainSubscribe.d.ts +0 -19
  71. package/lib/api/blockchainSubscribe.js +0 -66
  72. package/lib/api/blockchainSubscribeFiatRates.d.ts +0 -19
  73. package/lib/api/blockchainSubscribeFiatRates.js +0 -43
  74. package/lib/api/blockchainUnsubscribe.d.ts +0 -19
  75. package/lib/api/blockchainUnsubscribe.js +0 -66
  76. package/lib/api/blockchainUnsubscribeFiatRates.d.ts +0 -17
  77. package/lib/api/blockchainUnsubscribeFiatRates.js +0 -37
  78. package/lib/api/blockchainValidateEvmRpcUrl.d.ts +0 -17
  79. package/lib/api/blockchainValidateEvmRpcUrl.js +0 -54
  80. package/lib/api/cancelCoinjoinAuthorization.d.ts +0 -11
  81. package/lib/api/cancelCoinjoinAuthorization.js +0 -33
  82. package/lib/api/cardano/api/cardanoComposeTransaction.d.ts +0 -10
  83. package/lib/api/cardano/api/cardanoComposeTransaction.js +0 -84
  84. package/lib/api/cardano/api/cardanoGetAddress.d.ts +0 -34
  85. package/lib/api/cardano/api/cardanoGetAddress.js +0 -130
  86. package/lib/api/cardano/api/cardanoGetNativeScriptHash.d.ts +0 -12
  87. package/lib/api/cardano/api/cardanoGetNativeScriptHash.js +0 -66
  88. package/lib/api/cardano/api/cardanoGetPublicKey.d.ts +0 -22
  89. package/lib/api/cardano/api/cardanoGetPublicKey.js +0 -92
  90. package/lib/api/cardano/api/cardanoSignMessage.d.ts +0 -22
  91. package/lib/api/cardano/api/cardanoSignMessage.js +0 -90
  92. package/lib/api/cardano/api/cardanoSignTransaction.d.ts +0 -81
  93. package/lib/api/cardano/api/cardanoSignTransaction.js +0 -301
  94. package/lib/api/cardano/api/index.d.ts +0 -6
  95. package/lib/api/cardano/api/index.js +0 -6
  96. package/lib/api/cardano/cardanoAddressParameters.d.ts +0 -6
  97. package/lib/api/cardano/cardanoAddressParameters.js +0 -79
  98. package/lib/api/cardano/cardanoAuxiliaryData.d.ts +0 -4
  99. package/lib/api/cardano/cardanoAuxiliaryData.js +0 -74
  100. package/lib/api/cardano/cardanoCertificate.d.ts +0 -13
  101. package/lib/api/cardano/cardanoCertificate.js +0 -142
  102. package/lib/api/cardano/cardanoInputs.d.ts +0 -25
  103. package/lib/api/cardano/cardanoInputs.js +0 -39
  104. package/lib/api/cardano/cardanoOutputs.d.ts +0 -40
  105. package/lib/api/cardano/cardanoOutputs.js +0 -70
  106. package/lib/api/cardano/cardanoTokenBundle.d.ts +0 -12
  107. package/lib/api/cardano/cardanoTokenBundle.js +0 -21
  108. package/lib/api/cardano/cardanoUtils.d.ts +0 -17
  109. package/lib/api/cardano/cardanoUtils.js +0 -100
  110. package/lib/api/cardano/cardanoWitnesses.d.ts +0 -4
  111. package/lib/api/cardano/cardanoWitnesses.js +0 -47
  112. package/lib/api/changeLanguage.d.ts +0 -18
  113. package/lib/api/changeLanguage.js +0 -49
  114. package/lib/api/changePin.d.ts +0 -11
  115. package/lib/api/changePin.js +0 -27
  116. package/lib/api/changeWipeCode.d.ts +0 -11
  117. package/lib/api/changeWipeCode.js +0 -29
  118. package/lib/api/cipherKeyValue.d.ts +0 -17
  119. package/lib/api/cipherKeyValue.js +0 -58
  120. package/lib/api/common/AbstractMiscGetAddress.d.ts +0 -37
  121. package/lib/api/common/AbstractMiscGetAddress.js +0 -126
  122. package/lib/api/common/Discovery.d.ts +0 -33
  123. package/lib/api/common/Discovery.js +0 -119
  124. package/lib/api/common/paramsValidator.d.ts +0 -24
  125. package/lib/api/common/paramsValidator.js +0 -136
  126. package/lib/api/common/requestExistingAccounts.d.ts +0 -14
  127. package/lib/api/common/requestExistingAccounts.js +0 -20
  128. package/lib/api/composeTransaction.d.ts +0 -36
  129. package/lib/api/composeTransaction.js +0 -404
  130. package/lib/api/discoverAccounts.d.ts +0 -40
  131. package/lib/api/discoverAccounts.js +0 -360
  132. package/lib/api/ethereum/api/ethereumGetAddress.d.ts +0 -30
  133. package/lib/api/ethereum/api/ethereumGetAddress.js +0 -150
  134. package/lib/api/ethereum/api/ethereumGetPublicKey.d.ts +0 -52
  135. package/lib/api/ethereum/api/ethereumGetPublicKey.js +0 -100
  136. package/lib/api/ethereum/api/ethereumSignMessage.d.ts +0 -27
  137. package/lib/api/ethereum/api/ethereumSignMessage.js +0 -64
  138. package/lib/api/ethereum/api/ethereumSignTransaction.d.ts +0 -83
  139. package/lib/api/ethereum/api/ethereumSignTransaction.js +0 -148
  140. package/lib/api/ethereum/api/ethereumSignTypedData.d.ts +0 -117
  141. package/lib/api/ethereum/api/ethereumSignTypedData.js +0 -203
  142. package/lib/api/ethereum/api/ethereumVerifyMessage.d.ts +0 -12
  143. package/lib/api/ethereum/api/ethereumVerifyMessage.js +0 -35
  144. package/lib/api/ethereum/api/index.d.ts +0 -6
  145. package/lib/api/ethereum/api/index.js +0 -6
  146. package/lib/api/ethereum/ethereumDefinitions.d.ts +0 -53
  147. package/lib/api/ethereum/ethereumDefinitions.js +0 -135
  148. package/lib/api/ethereum/ethereumSignTx.d.ts +0 -16
  149. package/lib/api/ethereum/ethereumSignTx.js +0 -144
  150. package/lib/api/ethereum/ethereumSignTypedData.d.ts +0 -32
  151. package/lib/api/ethereum/ethereumSignTypedData.js +0 -175
  152. package/lib/api/evoluGetDelegatedIdentityKey.d.ts +0 -14
  153. package/lib/api/evoluGetDelegatedIdentityKey.js +0 -29
  154. package/lib/api/evoluGetNode.d.ts +0 -13
  155. package/lib/api/evoluGetNode.js +0 -29
  156. package/lib/api/evoluSignRegistrationRequest.d.ts +0 -16
  157. package/lib/api/evoluSignRegistrationRequest.js +0 -33
  158. package/lib/api/firmware/calculateFirmwareHash.d.ts +0 -18
  159. package/lib/api/firmware/calculateFirmwareHash.js +0 -56
  160. package/lib/api/firmware/calculateXPubHash.d.ts +0 -14
  161. package/lib/api/firmware/calculateXPubHash.js +0 -16
  162. package/lib/api/firmware/getBinary.d.ts +0 -14
  163. package/lib/api/firmware/getBinary.js +0 -33
  164. package/lib/api/firmware/index.d.ts +0 -6
  165. package/lib/api/firmware/index.js +0 -6
  166. package/lib/api/firmware/modifyFirmware.d.ts +0 -3
  167. package/lib/api/firmware/modifyFirmware.js +0 -13
  168. package/lib/api/firmware/parseFirmwareHeaders.d.ts +0 -4
  169. package/lib/api/firmware/parseFirmwareHeaders.js +0 -26
  170. package/lib/api/firmware/uploadFirmware.d.ts +0 -27
  171. package/lib/api/firmware/uploadFirmware.js +0 -99
  172. package/lib/api/firmware/verifyEntropy.d.ts +0 -25
  173. package/lib/api/firmware/verifyEntropy.js +0 -110
  174. package/lib/api/getAccountInfo.d.ts +0 -21
  175. package/lib/api/getAccountInfo.js +0 -253
  176. package/lib/api/getAddress.d.ts +0 -45
  177. package/lib/api/getAddress.js +0 -153
  178. package/lib/api/getCoinInfo.d.ts +0 -148
  179. package/lib/api/getCoinInfo.js +0 -25
  180. package/lib/api/getDeviceState.d.ts +0 -8
  181. package/lib/api/getDeviceState.js +0 -18
  182. package/lib/api/getFeatures.d.ts +0 -71
  183. package/lib/api/getFeatures.js +0 -22
  184. package/lib/api/getFirmwareHash.d.ts +0 -11
  185. package/lib/api/getFirmwareHash.js +0 -29
  186. package/lib/api/getNonce.d.ts +0 -10
  187. package/lib/api/getNonce.js +0 -18
  188. package/lib/api/getOwnershipId.d.ts +0 -17
  189. package/lib/api/getOwnershipId.js +0 -88
  190. package/lib/api/getOwnershipProof.d.ts +0 -17
  191. package/lib/api/getOwnershipProof.js +0 -95
  192. package/lib/api/getPublicKey.d.ts +0 -54
  193. package/lib/api/getPublicKey.js +0 -106
  194. package/lib/api/getSettings.d.ts +0 -24
  195. package/lib/api/getSettings.js +0 -21
  196. package/lib/api/index.d.ts +0 -62
  197. package/lib/api/index.js +0 -62
  198. package/lib/api/loadDevice.d.ts +0 -16
  199. package/lib/api/loadDevice.js +0 -46
  200. package/lib/api/monero/api/index.d.ts +0 -4
  201. package/lib/api/monero/api/index.js +0 -4
  202. package/lib/api/monero/api/moneroGetAddress.d.ts +0 -32
  203. package/lib/api/monero/api/moneroGetAddress.js +0 -117
  204. package/lib/api/monero/api/moneroGetWatchKey.d.ts +0 -14
  205. package/lib/api/monero/api/moneroGetWatchKey.js +0 -45
  206. package/lib/api/monero/api/moneroKeyImageSync.d.ts +0 -17
  207. package/lib/api/monero/api/moneroKeyImageSync.js +0 -128
  208. package/lib/api/monero/api/moneroSignTransaction.d.ts +0 -17
  209. package/lib/api/monero/api/moneroSignTransaction.js +0 -218
  210. package/lib/api/nostr/nostrGetPublicKey.d.ts +0 -15
  211. package/lib/api/nostr/nostrGetPublicKey.js +0 -38
  212. package/lib/api/nostr/nostrSignEvent.d.ts +0 -13
  213. package/lib/api/nostr/nostrSignEvent.js +0 -36
  214. package/lib/api/pingDevice.d.ts +0 -11
  215. package/lib/api/pingDevice.js +0 -29
  216. package/lib/api/pushTransaction.d.ts +0 -19
  217. package/lib/api/pushTransaction.js +0 -39
  218. package/lib/api/recoveryDevice.d.ts +0 -20
  219. package/lib/api/recoveryDevice.js +0 -52
  220. package/lib/api/requestLogin.d.ts +0 -14
  221. package/lib/api/requestLogin.js +0 -53
  222. package/lib/api/resetDevice.d.ts +0 -22
  223. package/lib/api/resetDevice.js +0 -133
  224. package/lib/api/ripple/api/index.d.ts +0 -2
  225. package/lib/api/ripple/api/index.js +0 -2
  226. package/lib/api/ripple/api/rippleGetAddress.d.ts +0 -17
  227. package/lib/api/ripple/api/rippleGetAddress.js +0 -22
  228. package/lib/api/ripple/api/rippleSignTransaction.d.ts +0 -13
  229. package/lib/api/ripple/api/rippleSignTransaction.js +0 -52
  230. package/lib/api/selectAccount.d.ts +0 -15
  231. package/lib/api/selectAccount.js +0 -42
  232. package/lib/api/setBrightness.d.ts +0 -12
  233. package/lib/api/setBrightness.js +0 -28
  234. package/lib/api/setBusy.d.ts +0 -11
  235. package/lib/api/setBusy.js +0 -31
  236. package/lib/api/showDeviceTutorial.d.ts +0 -11
  237. package/lib/api/showDeviceTutorial.js +0 -21
  238. package/lib/api/signMessage.d.ts +0 -25
  239. package/lib/api/signMessage.js +0 -75
  240. package/lib/api/signTransaction.d.ts +0 -199
  241. package/lib/api/signTransaction.js +0 -331
  242. package/lib/api/solana/api/index.d.ts +0 -4
  243. package/lib/api/solana/api/index.js +0 -4
  244. package/lib/api/solana/api/solanaComposeTransaction.d.ts +0 -33
  245. package/lib/api/solana/api/solanaComposeTransaction.js +0 -73
  246. package/lib/api/solana/api/solanaGetAddress.d.ts +0 -17
  247. package/lib/api/solana/api/solanaGetAddress.js +0 -22
  248. package/lib/api/solana/api/solanaGetPublicKey.d.ts +0 -32
  249. package/lib/api/solana/api/solanaGetPublicKey.js +0 -86
  250. package/lib/api/solana/api/solanaSignTransaction.d.ts +0 -41
  251. package/lib/api/solana/api/solanaSignTransaction.js +0 -204
  252. package/lib/api/solana/solanaDefinitions.d.ts +0 -9
  253. package/lib/api/solana/solanaDefinitions.js +0 -33
  254. package/lib/api/stellar/api/index.d.ts +0 -2
  255. package/lib/api/stellar/api/index.js +0 -2
  256. package/lib/api/stellar/api/stellarGetAddress.d.ts +0 -17
  257. package/lib/api/stellar/api/stellarGetAddress.js +0 -22
  258. package/lib/api/stellar/api/stellarSignTransaction.d.ts +0 -20
  259. package/lib/api/stellar/api/stellarSignTransaction.js +0 -65
  260. package/lib/api/stellar/stellarSignTx.d.ts +0 -7
  261. package/lib/api/stellar/stellarSignTx.js +0 -183
  262. package/lib/api/telemetryGet.d.ts +0 -14
  263. package/lib/api/telemetryGet.js +0 -26
  264. package/lib/api/tezos/api/index.d.ts +0 -3
  265. package/lib/api/tezos/api/index.js +0 -3
  266. package/lib/api/tezos/api/tezosGetAddress.d.ts +0 -17
  267. package/lib/api/tezos/api/tezosGetAddress.js +0 -22
  268. package/lib/api/tezos/api/tezosGetPublicKey.d.ts +0 -28
  269. package/lib/api/tezos/api/tezosGetPublicKey.js +0 -84
  270. package/lib/api/tezos/api/tezosSignTransaction.d.ts +0 -14
  271. package/lib/api/tezos/api/tezosSignTransaction.js +0 -30
  272. package/lib/api/tezos/tezosSignTx.d.ts +0 -71
  273. package/lib/api/tezos/tezosSignTx.js +0 -204
  274. package/lib/api/thpGetCredentials.d.ts +0 -13
  275. package/lib/api/thpGetCredentials.js +0 -30
  276. package/lib/api/thpRemoveCredentials.d.ts +0 -15
  277. package/lib/api/thpRemoveCredentials.js +0 -44
  278. package/lib/api/tron/api/index.d.ts +0 -3
  279. package/lib/api/tron/api/index.js +0 -3
  280. package/lib/api/tron/api/tronComposeTransaction.d.ts +0 -17
  281. package/lib/api/tron/api/tronComposeTransaction.js +0 -52
  282. package/lib/api/tron/api/tronGetAddress.d.ts +0 -17
  283. package/lib/api/tron/api/tronGetAddress.js +0 -22
  284. package/lib/api/tron/api/tronSignTransaction.d.ts +0 -20
  285. package/lib/api/tron/api/tronSignTransaction.js +0 -137
  286. package/lib/api/tron/tronEncode.d.ts +0 -11
  287. package/lib/api/tron/tronEncode.js +0 -157
  288. package/lib/api/tron/tronProtobuf.d.ts +0 -5
  289. package/lib/api/tron/tronProtobuf.js +0 -28
  290. package/lib/api/unlockPath.d.ts +0 -12
  291. package/lib/api/unlockPath.js +0 -33
  292. package/lib/api/verifyMessage.d.ts +0 -16
  293. package/lib/api/verifyMessage.js +0 -46
  294. package/lib/api/wipeDevice.d.ts +0 -21
  295. package/lib/api/wipeDevice.js +0 -49
  296. package/lib/backend/BackendManager.d.ts +0 -30
  297. package/lib/backend/BackendManager.js +0 -145
  298. package/lib/backend/Blockchain.d.ts +0 -81
  299. package/lib/backend/Blockchain.js +0 -235
  300. package/lib/backend/BlockchainLink.d.ts +0 -10
  301. package/lib/backend/BlockchainLink.js +0 -19
  302. package/lib/backend/fees/BitcoinFeeLevels.d.ts +0 -19
  303. package/lib/backend/fees/BitcoinFeeLevels.js +0 -44
  304. package/lib/backend/fees/EthereumFeeLevels.d.ts +0 -17
  305. package/lib/backend/fees/EthereumFeeLevels.js +0 -63
  306. package/lib/backend/fees/MiscFeeLevels.d.ts +0 -18
  307. package/lib/backend/fees/MiscFeeLevels.js +0 -30
  308. package/lib/backend/fees/index.d.ts +0 -5
  309. package/lib/backend/fees/index.js +0 -31
  310. package/lib/core/AbstractMethod.d.ts +0 -63
  311. package/lib/core/AbstractMethod.js +0 -189
  312. package/lib/core/index.d.ts +0 -29
  313. package/lib/core/index.js +0 -805
  314. package/lib/core/method.d.ts +0 -3
  315. package/lib/core/method.js +0 -19
  316. package/lib/core/method.native.d.ts +0 -2
  317. package/lib/core/method.native.js +0 -29
  318. package/lib/core/onCallFirmwareUpdate.d.ts +0 -42
  319. package/lib/core/onCallFirmwareUpdate.js +0 -436
  320. package/lib/data/coinInfo.d.ts +0 -101
  321. package/lib/data/coinInfo.js +0 -195
  322. package/lib/data/config.d.ts +0 -8
  323. package/lib/data/config.js +0 -273
  324. package/lib/data/defaultFeeLevels.d.ts +0 -18
  325. package/lib/data/defaultFeeLevels.js +0 -200
  326. package/lib/data/enabledNetworksStore.d.ts +0 -5
  327. package/lib/data/enabledNetworksStore.js +0 -20
  328. package/lib/data/firmwareInfo.d.ts +0 -55
  329. package/lib/data/firmwareInfo.js +0 -413
  330. package/lib/data/firmwareReleaseStore.d.ts +0 -10
  331. package/lib/data/firmwareReleaseStore.js +0 -16
  332. package/lib/data/localFirmwareStore.d.ts +0 -3
  333. package/lib/data/localFirmwareStore.js +0 -8
  334. package/lib/data/protobufLoader.d.ts +0 -1
  335. package/lib/data/protobufLoader.js +0 -30
  336. package/lib/data/settingsStore.d.ts +0 -6
  337. package/lib/data/settingsStore.js +0 -21
  338. package/lib/device/Device.d.ts +0 -259
  339. package/lib/device/Device.js +0 -765
  340. package/lib/device/DeviceCommands.d.ts +0 -87
  341. package/lib/device/DeviceCommands.js +0 -248
  342. package/lib/device/DeviceCurrentSession.d.ts +0 -750
  343. package/lib/device/DeviceCurrentSession.js +0 -239
  344. package/lib/device/DeviceList.d.ts +0 -75
  345. package/lib/device/DeviceList.js +0 -243
  346. package/lib/device/TransportList.d.ts +0 -3
  347. package/lib/device/TransportList.js +0 -13
  348. package/lib/device/TransportManager.d.ts +0 -33
  349. package/lib/device/TransportManager.js +0 -144
  350. package/lib/device/calculateRevisionForDevice.d.ts +0 -10
  351. package/lib/device/calculateRevisionForDevice.js +0 -19
  352. package/lib/device/checkFirmwareRevision.d.ts +0 -22
  353. package/lib/device/checkFirmwareRevision.js +0 -104
  354. package/lib/device/resolveDescriptorForTaproot.d.ts +0 -17
  355. package/lib/device/resolveDescriptorForTaproot.js +0 -27
  356. package/lib/device/thp/handshake.d.ts +0 -3
  357. package/lib/device/thp/handshake.js +0 -100
  358. package/lib/device/thp/index.d.ts +0 -5
  359. package/lib/device/thp/index.js +0 -65
  360. package/lib/device/thp/pairing.d.ts +0 -16
  361. package/lib/device/thp/pairing.js +0 -242
  362. package/lib/device/thp/session.d.ts +0 -2
  363. package/lib/device/thp/session.js +0 -27
  364. package/lib/device/thp/thpCall.d.ts +0 -31
  365. package/lib/device/thp/thpCall.js +0 -58
  366. package/lib/device/validateMessageSize.d.ts +0 -2
  367. package/lib/device/validateMessageSize.js +0 -9
  368. package/lib/device/workflow/changeLanguage.d.ts +0 -18
  369. package/lib/device/workflow/changeLanguage.js +0 -62
  370. package/lib/device/workflow/checkFirmwareHash.d.ts +0 -12
  371. package/lib/device/workflow/checkFirmwareHash.js +0 -86
  372. package/lib/device/workflow/checkFirmwareHashWithRetries.d.ts +0 -8
  373. package/lib/device/workflow/checkFirmwareHashWithRetries.js +0 -36
  374. package/lib/device/workflow/handshake.d.ts +0 -13
  375. package/lib/device/workflow/handshake.js +0 -55
  376. package/lib/device/workflow/trezorPushNotification.d.ts +0 -5
  377. package/lib/device/workflow/trezorPushNotification.js +0 -73
  378. package/lib/device/workflow/validateState.d.ts +0 -2
  379. package/lib/device/workflow/validateState.js +0 -152
  380. package/lib/events/ui-promise.d.ts +0 -20
  381. package/lib/events/ui-promise.js +0 -1
  382. package/lib/impl/core-in-module.d.ts +0 -33
  383. package/lib/impl/core-in-module.js +0 -194
  384. package/lib/types/idevice.d.ts +0 -110
  385. package/lib/types/idevice.js +0 -1
  386. package/lib/types/typed-call-provider.d.ts +0 -29
  387. package/lib/types/typed-call-provider.js +0 -1
  388. package/lib/types/workflow.d.ts +0 -16
  389. package/lib/types/workflow.js +0 -1
  390. package/lib/utils/accountUtils.d.ts +0 -10
  391. package/lib/utils/accountUtils.js +0 -90
  392. package/lib/utils/addressUtils.d.ts +0 -2
  393. package/lib/utils/addressUtils.js +0 -24
  394. package/lib/utils/assetUtils.d.ts +0 -13
  395. package/lib/utils/assetUtils.js +0 -55
  396. package/lib/utils/assets.browser.d.ts +0 -1
  397. package/lib/utils/assets.browser.js +0 -1
  398. package/lib/utils/assets.d.ts +0 -2
  399. package/lib/utils/assets.js +0 -13
  400. package/lib/utils/assets.native.d.ts +0 -2
  401. package/lib/utils/assets.native.js +0 -23
  402. package/lib/utils/assetsTypes.d.ts +0 -5
  403. package/lib/utils/assetsTypes.js +0 -1
  404. package/lib/utils/buildOutputDescriptor.d.ts +0 -20
  405. package/lib/utils/buildOutputDescriptor.js +0 -67
  406. package/lib/utils/deviceFeaturesUtils.d.ts +0 -7
  407. package/lib/utils/deviceFeaturesUtils.js +0 -109
  408. package/lib/utils/ethereumUtils.d.ts +0 -3
  409. package/lib/utils/ethereumUtils.js +0 -7
  410. package/lib/utils/firmwareReleaseConfigUtils.d.ts +0 -19
  411. package/lib/utils/firmwareReleaseConfigUtils.js +0 -131
  412. package/lib/utils/firmwareUtils.d.ts +0 -15
  413. package/lib/utils/firmwareUtils.js +0 -57
  414. package/lib/utils/formatUtils.d.ts +0 -13
  415. package/lib/utils/formatUtils.js +0 -45
  416. package/lib/utils/hdnodeUtils.d.ts +0 -6
  417. package/lib/utils/hdnodeUtils.js +0 -62
  418. package/lib/utils/pathUtils.d.ts +0 -1
  419. package/lib/utils/pathUtils.js +0 -1
  420. package/lib/utils/paymentRequest.d.ts +0 -8
  421. package/lib/utils/paymentRequest.js +0 -25
  422. package/lib/utils/uiPromiseManager.d.ts +0 -8
  423. package/lib/utils/uiPromiseManager.js +0 -51
  424. package/lib/workers/workers.browser.d.ts +0 -10
  425. package/lib/workers/workers.browser.js +0 -16
  426. package/lib/workers/workers.d.ts +0 -10
  427. package/lib/workers/workers.js +0 -8
  428. package/lib/workers/workers.native.d.ts +0 -7
  429. package/lib/workers/workers.native.js +0 -7
@@ -1,360 +0,0 @@
1
- import { ACCOUNT_TYPES, CARDANO_DERIVATIONS, PAGING, UI_REQUEST, createUiMessage } from "@trezor/connect-common";
2
- import { arrayPartition, getSynchronize, versionUtils } from "@trezor/utils";
3
- import { assertBackendSupported, initBlockchain } from "../backend/BlockchainLink.js";
4
- import { AbstractMethod } from "../core/AbstractMethod.js";
5
- import { getCoinInfoOrThrow } from "../data/coinInfo.js";
6
- import { isUtxoBased } from "../utils/accountUtils.js";
7
- import { validatePath } from "../utils/pathUtils.js";
8
- import { getFirmwareRange, validateParams } from "./common/paramsValidator.js";
9
- import { checkXPubWithHashes } from "./firmware/calculateXPubHash.js";
10
- const {
11
- CARDANO_TXS_PER_PAGE,
12
- DEFAULT_TXS_PER_PAGE,
13
- SOLANA_TXS_PER_PAGE
14
- } = PAGING;
15
- const ACCOUNT_LIMIT = 10;
16
- const DETAILS = 'txs';
17
- const isCardano = account => account.symbol === 'ada';
18
- const isCardanoRequest = request => isCardano(request.account);
19
- const shouldSkipFirstAccountIndex = (account, coinInfo) => (coinInfo.type === 'ethereum' || coinInfo.shortcut === 'TRX') && account.type === 'ledger';
20
- const getAccountTypeKey = ({
21
- symbol,
22
- type
23
- }) => `${symbol}-${type}`;
24
- const substituteBip43Path = (path, index) => path.replace('i', String(index));
25
- export const getTxsPerPage = account => {
26
- switch (account.symbol) {
27
- case 'ada':
28
- return CARDANO_TXS_PER_PAGE;
29
- case 'sol':
30
- return SOLANA_TXS_PER_PAGE;
31
- default:
32
- return DEFAULT_TXS_PER_PAGE;
33
- }
34
- };
35
- export default class DiscoverAccounts extends AbstractMethod {
36
- disposed = false;
37
- constructor(message) {
38
- const {
39
- payload
40
- } = message;
41
- const {
42
- entropyCheckResult
43
- } = payload;
44
- validateParams(payload, [{
45
- name: 'coins',
46
- type: 'array',
47
- required: true,
48
- allowEmpty: true
49
- }, {
50
- name: 'entropyCheckResult',
51
- type: 'object'
52
- }]);
53
- const coins = payload.coins.flatMap(coin => {
54
- validateParams(coin, [{
55
- name: 'symbol',
56
- type: 'string',
57
- required: true
58
- }, {
59
- name: 'known',
60
- type: 'array',
61
- allowEmpty: true
62
- }, {
63
- name: 'knownOnly',
64
- type: 'boolean'
65
- }, {
66
- name: 'identity',
67
- type: 'string'
68
- }, {
69
- name: 'details',
70
- type: 'string'
71
- }, {
72
- name: 'pageSize',
73
- type: 'number'
74
- }, {
75
- name: 'protocols',
76
- type: 'array'
77
- }]);
78
- const {
79
- symbol,
80
- known: knownAccs,
81
- knownOnly,
82
- ...rest
83
- } = coin;
84
- const coinInfo = getCoinInfoOrThrow(symbol);
85
- assertBackendSupported(coinInfo);
86
- const firmwareRange = getFirmwareRange([payload.method], [coinInfo]);
87
- const symbolAccounts = ACCOUNT_TYPES.filter(a => a.symbol === symbol);
88
- knownAccs?.forEach(account => {
89
- validateParams(account, [{
90
- name: 'type',
91
- type: 'string',
92
- required: true
93
- }, {
94
- name: 'skip',
95
- type: 'number'
96
- }]);
97
- if (!symbolAccounts.some(a => a.type === account.type)) {
98
- throw new Error(`Unknown account type: ${symbol}/${account.type}`);
99
- }
100
- });
101
- return symbolAccounts.map(account => [account, knownAccs?.find(t => t.type === account.type)]).filter(([_, known]) => known ? typeof known.skip === 'number' : !knownOnly).map(([account, known]) => ({
102
- pageSize: getTxsPerPage(account),
103
- details: DETAILS,
104
- coinInfo,
105
- firmwareRange,
106
- skip: known?.skip ?? 0,
107
- account,
108
- ...rest,
109
- offset: shouldSkipFirstAccountIndex(account, coinInfo) ? 1 : 0,
110
- derivation: isCardano(account) ? CARDANO_DERIVATIONS[account.type] : undefined
111
- }));
112
- });
113
- const params = {
114
- coins,
115
- entropyCheckResult
116
- };
117
- super(message, params);
118
- this.useDevice = true;
119
- this.useDeviceState = true;
120
- this.useUi = false;
121
- }
122
- get requiredPermissions() {
123
- return this.coinPerms('read_account_info', this.params.coins.map(c => c.coinInfo));
124
- }
125
- progress = {};
126
- updateProgress(account, done, last = false) {
127
- const progress = last ? 1 : done / Math.max(ACCOUNT_LIMIT, done + 1);
128
- const key = getAccountTypeKey(account);
129
- this.progress[key] = progress;
130
- }
131
- sendProgress(response, sendCoreMessage) {
132
- const progress = Object.values(this.progress).reduce((sum, typeProgress) => sum + typeProgress, 0) / (Object.keys(this.progress).length || 1);
133
- sendCoreMessage(createUiMessage(UI_REQUEST.BUNDLE_PROGRESS, {
134
- total: 100,
135
- progress: 100 * progress,
136
- response
137
- }));
138
- }
139
- async run({
140
- sendCoreMessage
141
- }) {
142
- const [unsupported, supported] = this.filterUnsupportedAccounts(this.params.coins);
143
- unsupported.forEach(({
144
- account: {
145
- path: bip43,
146
- ...rest
147
- },
148
- error,
149
- coinInfo,
150
- skip,
151
- offset
152
- }) => {
153
- const path = substituteBip43Path(bip43, skip + offset);
154
- const backendType = coinInfo.blockchainLink?.type;
155
- this.sendProgress({
156
- ...rest,
157
- index: skip,
158
- failed: true,
159
- error,
160
- path,
161
- backendType
162
- }, sendCoreMessage);
163
- });
164
- const [cardanoAccounts, otherAccounts] = arrayPartition(supported, isCardanoRequest);
165
- const [_, filteredCardanoAccounts] = await this.filterCardanoDerivations(cardanoAccounts);
166
- const accounts = [...otherAccounts, ...filteredCardanoAccounts];
167
- accounts.forEach(({
168
- account,
169
- skip
170
- }) => this.updateProgress(account, skip));
171
- const counts = await Promise.all(accounts.map(account => this.discoverAccount(account, sendCoreMessage)));
172
- const nonempty = counts.reduce((sum, acc) => sum + acc.nonempty, 0);
173
- const failed = counts.filter(acc => acc.error).length;
174
- const empty = counts.length - failed;
175
- return {
176
- empty,
177
- nonempty,
178
- failed
179
- };
180
- }
181
- filterUnsupportedAccounts(accounts) {
182
- const version = this.getDevice().getVersion();
183
- const model = this.getDevice().features?.internal_model;
184
- if (!version || !model) return [[], accounts];
185
- return arrayPartition(accounts.map(item => {
186
- const {
187
- min,
188
- max
189
- } = item.firmwareRange[model];
190
- let error;
191
- if (min === '0') {
192
- error = UI_REQUEST.FIRMWARE_NOT_SUPPORTED;
193
- } else if (!versionUtils.isNewerOrEqual(version, min)) {
194
- error = UI_REQUEST.FIRMWARE_OLD;
195
- } else if (max !== '0' && versionUtils.isNewer(version, max)) {
196
- error = UI_REQUEST.FIRMWARE_NOT_COMPATIBLE;
197
- }
198
- return error ? {
199
- ...item,
200
- error
201
- } : item;
202
- }), item => 'error' in item);
203
- }
204
- async filterCardanoDerivations(accounts) {
205
- const legacyRequest = accounts.find(a => a.account.type === 'legacy');
206
- const ledgerRequest = accounts.find(a => a.account.type === 'ledger');
207
- const filterableRequest = legacyRequest ?? ledgerRequest;
208
- const getDescriptor = derivation => filterableRequest && this.getDescriptor(filterableRequest.coinInfo, filterableRequest.account.path, CARDANO_DERIVATIONS[derivation], 0).then(({
209
- descriptor
210
- }) => descriptor);
211
- const normalDescriptor = await getDescriptor('normal');
212
- const omitLegacy = legacyRequest && (await getDescriptor('legacy')) === normalDescriptor;
213
- const omitLedger = ledgerRequest && (!legacyRequest || omitLegacy) && (await getDescriptor('ledger')) === normalDescriptor;
214
- return arrayPartition(accounts.map(item => item.account.type === 'legacy' && omitLegacy || item.account.type === 'ledger' && omitLedger ? {
215
- ...item,
216
- error: 'ignored cardano derivation'
217
- } : item), item => 'error' in item);
218
- }
219
- descriptorLock = getSynchronize();
220
- descriptorCache = {};
221
- async getDescriptor(coinInfo, bip43PathTemplate, derivationType, index) {
222
- const path = substituteBip43Path(bip43PathTemplate, index);
223
- const {
224
- address_n: _,
225
- ...descriptorRest
226
- } = await this.descriptorLock(async () => {
227
- const key = `${path}-${derivationType}`;
228
- if (!this.descriptorCache[key]) {
229
- const address_n = validatePath(path, 3);
230
- const descriptor = await this.getDevice().getCommands().getAccountDescriptor(coinInfo, address_n, derivationType);
231
- this.descriptorCache[key] = descriptor;
232
- const knownXPubHashes = this.params.entropyCheckResult?.xpubHashes;
233
- const {
234
- legacyXpub: xpub
235
- } = descriptor;
236
- const isPassphraseEnabled = this.getDevice().features?.passphrase_protection;
237
- const alwaysPassphrase = this.getDevice().features?.passphrase_always_on_device;
238
- const isStandardWallet = !isPassphraseEnabled || this.useEmptyPassphrase && !alwaysPassphrase;
239
- if (xpub && knownXPubHashes && isStandardWallet) {
240
- const isValid = checkXPubWithHashes({
241
- xpub,
242
- path,
243
- knownXPubHashes
244
- });
245
- if (!isValid) {
246
- console.error(`Entropy check failed at getAccountDescriptor on ${path}`);
247
- }
248
- }
249
- }
250
- return this.descriptorCache[key];
251
- });
252
- return {
253
- path,
254
- ...descriptorRest
255
- };
256
- }
257
- async discoverAccount(request, sendCoreMessage) {
258
- const {
259
- details,
260
- identity,
261
- pageSize,
262
- gap,
263
- protocols,
264
- coinInfo,
265
- derivation,
266
- offset,
267
- skip
268
- } = request;
269
- const {
270
- path: bip43,
271
- ...accountKey
272
- } = request.account;
273
- const backendType = coinInfo.blockchainLink?.type;
274
- const utxoRequired = isUtxoBased(coinInfo) && details && details !== 'basic';
275
- let index = skip;
276
- const sendProgress = response => this.sendProgress(response, sendCoreMessage);
277
- let blockchain;
278
- try {
279
- blockchain = await initBlockchain(coinInfo, sendCoreMessage, identity);
280
- } catch (err) {
281
- const path = substituteBip43Path(bip43, offset + index);
282
- this.updateProgress(accountKey, index + 1, true);
283
- const error = err.message;
284
- sendProgress({
285
- ...accountKey,
286
- index,
287
- failed: true,
288
- error,
289
- path,
290
- backendType
291
- });
292
- return {
293
- nonempty: 0,
294
- error
295
- };
296
- }
297
- let descPromise = this.getDescriptor(coinInfo, bip43, derivation, offset + index);
298
- descPromise.catch(() => {});
299
- while (true) {
300
- try {
301
- const {
302
- descriptor,
303
- ...descRest
304
- } = await descPromise;
305
- descPromise = this.getDescriptor(coinInfo, bip43, derivation, offset + index + 1);
306
- descPromise.catch(() => {});
307
- const info = await blockchain.getAccountInfo({
308
- descriptor,
309
- details,
310
- pageSize,
311
- protocols,
312
- gap
313
- });
314
- const utxo = !utxoRequired ? undefined : info.empty ? [] : await blockchain.getAccountUtxo(descriptor);
315
- this.updateProgress(accountKey, index + 1, info.empty);
316
- sendProgress({
317
- ...info,
318
- descriptor,
319
- ...descRest,
320
- utxo,
321
- ...accountKey,
322
- index,
323
- backendType,
324
- failed: false
325
- });
326
- if (info.empty) {
327
- await descPromise.catch(() => {});
328
- return {
329
- nonempty: index - skip
330
- };
331
- }
332
- } catch (err) {
333
- const path = substituteBip43Path(bip43, offset + index);
334
- const {
335
- message: error,
336
- code
337
- } = err;
338
- const failed = true;
339
- this.updateProgress(accountKey, index + 1, true);
340
- sendProgress({
341
- ...accountKey,
342
- index,
343
- failed,
344
- error,
345
- code,
346
- path,
347
- backendType
348
- });
349
- return {
350
- nonempty: index - skip,
351
- error
352
- };
353
- }
354
- index++;
355
- }
356
- }
357
- dispose() {
358
- this.disposed = true;
359
- }
360
- }
@@ -1,30 +0,0 @@
1
- import type { EthereumNetworkInfoDefinitionValues, PROTO, PermissionRequest } from '@trezor/connect-common';
2
- import type { MethodContext, MethodMessage } from "../../../core/AbstractMethod.js";
3
- import { AbstractMethod } from "../../../core/AbstractMethod.js";
4
- type Params = {
5
- proto: PROTO.EthereumGetAddress;
6
- address?: string;
7
- network?: EthereumNetworkInfoDefinitionValues;
8
- };
9
- export default class EthereumGetAddress extends AbstractMethod<'ethereumGetAddress', Params[]> {
10
- hasBundle?: boolean;
11
- progress: number;
12
- constructor(message: MethodMessage<'ethereumGetAddress'>);
13
- get requiredPermissions(): PermissionRequest[];
14
- initAsync(): Promise<void>;
15
- get info(): string;
16
- getButtonRequestData(code: string): {
17
- type: "address";
18
- serializedPath: string;
19
- address: string;
20
- } | undefined;
21
- get confirmation(): {
22
- view: "export-address";
23
- label: string;
24
- };
25
- private _call;
26
- run({
27
- sendCoreMessage
28
- }: MethodContext): Promise<import("@trezor/connect-common").Address | import("@trezor/connect-common").Address[]>;
29
- }
30
- export {};
@@ -1,150 +0,0 @@
1
- import { Bundle, GetAddress as GetAddressSchema, UI_REQUEST, createUiMessage } from "@trezor/connect-common";
2
- import { ERRORS } from "@trezor/connect-common/lib/constants/index.js";
3
- import { Assert } from "@trezor/schema-utils";
4
- import { AbstractMethod } from "../../../core/AbstractMethod.js";
5
- import { getEthereumNetwork, getUniqueNetworks } from "../../../data/coinInfo.js";
6
- import { getNetworkLabel } from "../../../utils/ethereumUtils.js";
7
- import { stripHexPrefix } from "../../../utils/formatUtils.js";
8
- import { getSerializedPath, getSlip44ByPath, validatePath } from "../../../utils/pathUtils.js";
9
- import { bundlify } from "../../common/paramsValidator.js";
10
- import { decodeEthereumDefinition, ethereumNetworkInfoFromDefinition, getEthereumDefinitions } from "../ethereumDefinitions.js";
11
- export default class EthereumGetAddress extends AbstractMethod {
12
- hasBundle;
13
- progress = 0;
14
- constructor(message) {
15
- const {
16
- hasBundle,
17
- payload
18
- } = bundlify(message.payload);
19
- Assert(Bundle(GetAddressSchema), payload);
20
- const params = payload.bundle.map(batch => {
21
- const path = validatePath(batch.path, 3);
22
- const network = getEthereumNetwork(path);
23
- const proto = {
24
- address_n: path,
25
- show_display: typeof batch.showOnTrezor === 'boolean' ? batch.showOnTrezor : true,
26
- chunkify: typeof batch.chunkify === 'boolean' ? batch.chunkify : false
27
- };
28
- return {
29
- proto,
30
- address: batch.address,
31
- network
32
- };
33
- });
34
- super(message, params);
35
- this.requiredFirmwareCoins = params.map(({
36
- network
37
- }) => network);
38
- this.hasBundle = hasBundle;
39
- this.confirmMissingBackup = true;
40
- this.requiredDeviceCapabilities = ['Capability_Ethereum'];
41
- }
42
- get requiredPermissions() {
43
- return this.coinPerms('read_address', this.requiredFirmwareCoins);
44
- }
45
- async initAsync() {
46
- for (let i = 0; i < this.params.length; i++) {
47
- const {
48
- params
49
- } = this;
50
- const param = params[i];
51
- if (!param.network) {
52
- const slip44 = getSlip44ByPath(param.proto.address_n);
53
- const definitions = await getEthereumDefinitions({
54
- slip44
55
- });
56
- const decoded = decodeEthereumDefinition(definitions);
57
- if (decoded.network) {
58
- param.network = ethereumNetworkInfoFromDefinition(decoded.network);
59
- }
60
- if (definitions.encoded_network) {
61
- param.proto.encoded_network = definitions.encoded_network;
62
- }
63
- }
64
- }
65
- }
66
- get info() {
67
- if (this.params.length === 1) {
68
- const {
69
- params
70
- } = this;
71
- const first = params[0];
72
- return getNetworkLabel('Export #NETWORK address', first.network);
73
- }
74
- const requestedNetworks = this.params.map(b => b.network);
75
- const uniqNetworks = getUniqueNetworks(requestedNetworks);
76
- if (uniqNetworks.length === 1 && uniqNetworks[0]) {
77
- return getNetworkLabel('Export multiple #NETWORK addresses', uniqNetworks[0]);
78
- }
79
- return 'Export multiple addresses';
80
- }
81
- getButtonRequestData(code) {
82
- if (code === 'ButtonRequest_Address') {
83
- const {
84
- params
85
- } = this;
86
- const current = params[this.progress];
87
- return {
88
- type: 'address',
89
- serializedPath: getSerializedPath(current.proto.address_n),
90
- address: current.address || 'not-set'
91
- };
92
- }
93
- }
94
- get confirmation() {
95
- return {
96
- view: 'export-address',
97
- label: this.info
98
- };
99
- }
100
- async _call(params) {
101
- const response = await this.getDevice().getCommands().ethereumGetAddress(params.proto);
102
- return {
103
- path: params.proto.address_n,
104
- serializedPath: getSerializedPath(params.proto.address_n),
105
- address: response.address,
106
- mac: response.mac
107
- };
108
- }
109
- async run({
110
- sendCoreMessage
111
- }) {
112
- const responses = [];
113
- for (let i = 0; i < this.params.length; i++) {
114
- const {
115
- params
116
- } = this;
117
- const batch = params[i];
118
- if (batch.proto.show_display) {
119
- const silent = await this._call({
120
- ...batch,
121
- proto: {
122
- ...batch.proto,
123
- show_display: false
124
- }
125
- });
126
- if (typeof batch.address === 'string') {
127
- if (stripHexPrefix(batch.address).toLowerCase() !== stripHexPrefix(silent.address).toLowerCase()) {
128
- throw ERRORS.TypedError('Method_AddressNotMatch');
129
- }
130
- } else {
131
- batch.address = silent.address;
132
- }
133
- }
134
- const response = await this._call({
135
- ...batch
136
- });
137
- responses.push(response);
138
- if (this.hasBundle) {
139
- sendCoreMessage(createUiMessage(UI_REQUEST.BUNDLE_PROGRESS, {
140
- total: this.params.length,
141
- progress: i,
142
- response
143
- }));
144
- }
145
- this.progress++;
146
- }
147
- const first = responses[0];
148
- return this.hasBundle ? responses : first;
149
- }
150
- }
@@ -1,52 +0,0 @@
1
- import { type EthereumNetworkInfo, type PermissionRequest } from '@trezor/connect-common';
2
- import type { MessagesSchema as PROTO } from '@trezor/protobuf';
3
- import type { MethodContext, MethodMessage } from "../../../core/AbstractMethod.js";
4
- import { AbstractMethod } from "../../../core/AbstractMethod.js";
5
- type Params = {
6
- proto: PROTO.EthereumGetPublicKey;
7
- network?: EthereumNetworkInfo;
8
- };
9
- export default class EthereumGetPublicKey extends AbstractMethod<'ethereumGetPublicKey', Params[]> {
10
- hasBundle?: boolean;
11
- constructor(message: MethodMessage<'ethereumGetPublicKey'>);
12
- get requiredPermissions(): PermissionRequest[];
13
- get info(): string;
14
- get confirmation(): {
15
- view: "export-xpub";
16
- label: string;
17
- };
18
- run({
19
- sendCoreMessage
20
- }: MethodContext): Promise<({
21
- publicKey: string;
22
- path: number[];
23
- serializedPath: string;
24
- displayablePublicKey: string;
25
- } & {
26
- xpubSegwit?: string | undefined;
27
- descriptorChecksum?: string | undefined;
28
- rootFingerprint?: number | undefined;
29
- descriptor?: string | undefined;
30
- childNum: number;
31
- xpub: string;
32
- chainCode: string;
33
- fingerprint: number;
34
- depth: number;
35
- }) | ({
36
- publicKey: string;
37
- path: number[];
38
- serializedPath: string;
39
- displayablePublicKey: string;
40
- } & {
41
- xpubSegwit?: string | undefined;
42
- descriptorChecksum?: string | undefined;
43
- rootFingerprint?: number | undefined;
44
- descriptor?: string | undefined;
45
- childNum: number;
46
- xpub: string;
47
- chainCode: string;
48
- fingerprint: number;
49
- depth: number;
50
- })[]>;
51
- }
52
- export {};
@@ -1,100 +0,0 @@
1
- import { Bundle, GetPublicKey as GetPublicKeySchema, UI_REQUEST, createUiMessage } from "@trezor/connect-common";
2
- import { Assert } from "@trezor/schema-utils";
3
- import { AbstractMethod } from "../../../core/AbstractMethod.js";
4
- import { getEthereumNetwork, getUniqueNetworks } from "../../../data/coinInfo.js";
5
- import { getNetworkLabel } from "../../../utils/ethereumUtils.js";
6
- import { getSerializedPath, validatePath } from "../../../utils/pathUtils.js";
7
- import { bundlify } from "../../common/paramsValidator.js";
8
- export default class EthereumGetPublicKey extends AbstractMethod {
9
- hasBundle;
10
- constructor(message) {
11
- const {
12
- hasBundle,
13
- payload
14
- } = bundlify(message.payload);
15
- Assert(Bundle(GetPublicKeySchema), payload);
16
- const params = payload.bundle.map(batch => {
17
- const path = validatePath(batch.path, 3);
18
- const network = getEthereumNetwork(path);
19
- const proto = {
20
- address_n: path,
21
- show_display: typeof batch.showOnTrezor === 'boolean' ? batch.showOnTrezor : false
22
- };
23
- return {
24
- proto,
25
- network
26
- };
27
- });
28
- super(message, params);
29
- this.requiredFirmwareCoins = params.map(({
30
- network
31
- }) => network);
32
- this.hasBundle = hasBundle;
33
- this.requiredDeviceCapabilities = ['Capability_Ethereum'];
34
- }
35
- get requiredPermissions() {
36
- return this.coinPerms('read_xpub', this.requiredFirmwareCoins);
37
- }
38
- get info() {
39
- if (this.params.length === 1) {
40
- const {
41
- params
42
- } = this;
43
- const first = params[0];
44
- return getNetworkLabel('Export #NETWORK public key', first.network);
45
- }
46
- const requestedNetworks = this.params.map(b => b.network);
47
- const uniqNetworks = getUniqueNetworks(requestedNetworks);
48
- if (uniqNetworks.length === 1 && uniqNetworks[0]) {
49
- return getNetworkLabel('Export multiple #NETWORK public keys', uniqNetworks[0]);
50
- }
51
- return 'Export multiple public keys';
52
- }
53
- get confirmation() {
54
- return {
55
- view: 'export-xpub',
56
- label: this.info
57
- };
58
- }
59
- async run({
60
- sendCoreMessage
61
- }) {
62
- const responses = [];
63
- const cmd = this.getDevice().getCommands();
64
- for (let i = 0; i < this.params.length; i++) {
65
- const {
66
- params
67
- } = this;
68
- const batch = params[i];
69
- const {
70
- address_n,
71
- show_display
72
- } = batch.proto;
73
- const publicKey = await cmd.ethereumGetPublicKey({
74
- address_n,
75
- show_display
76
- });
77
- const response = {
78
- path: address_n,
79
- serializedPath: getSerializedPath(address_n),
80
- childNum: publicKey.node.child_num,
81
- xpub: publicKey.xpub,
82
- chainCode: publicKey.node.chain_code,
83
- publicKey: publicKey.node.public_key,
84
- fingerprint: publicKey.node.fingerprint,
85
- depth: publicKey.node.depth,
86
- displayablePublicKey: publicKey.xpub
87
- };
88
- responses.push(response);
89
- if (this.hasBundle) {
90
- sendCoreMessage(createUiMessage(UI_REQUEST.BUNDLE_PROGRESS, {
91
- total: this.params.length,
92
- progress: i,
93
- response
94
- }));
95
- }
96
- }
97
- const first = responses[0];
98
- return this.hasBundle ? responses : first;
99
- }
100
- }