@trezor/connect 10.0.0-alpha.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 (432) hide show
  1. package/CHANGELOG.md +159 -63
  2. package/README.md +5 -3
  3. package/lib/exports.d.ts +1 -0
  4. package/lib/exports.js +1 -0
  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.d.ts +7 -0
  12. package/lib/index.browser.js +10 -0
  13. package/lib/index.d.ts +4 -0
  14. package/lib/index.js +5 -0
  15. package/lib/index.native.d.ts +4 -0
  16. package/lib/index.native.js +5 -0
  17. package/package.json +30 -83
  18. package/libESM/api/applyFlags.d.mts +0 -20
  19. package/libESM/api/applyFlags.mjs +0 -36
  20. package/libESM/api/applySettings.d.mts +0 -20
  21. package/libESM/api/applySettings.mjs +0 -55
  22. package/libESM/api/authenticateDevice.d.mts +0 -9
  23. package/libESM/api/authenticateDevice.mjs +0 -108
  24. package/libESM/api/authorizeCoinjoin.d.mts +0 -11
  25. package/libESM/api/authorizeCoinjoin.mjs +0 -44
  26. package/libESM/api/backupDevice.d.mts +0 -19
  27. package/libESM/api/backupDevice.mjs +0 -36
  28. package/libESM/api/bitcoin/TransactionComposer.d.mts +0 -46
  29. package/libESM/api/bitcoin/TransactionComposer.mjs +0 -139
  30. package/libESM/api/bitcoin/createPendingTx.d.mts +0 -33
  31. package/libESM/api/bitcoin/createPendingTx.mjs +0 -54
  32. package/libESM/api/bitcoin/enhanceSignTx.d.mts +0 -2
  33. package/libESM/api/bitcoin/enhanceSignTx.mjs +0 -23
  34. package/libESM/api/bitcoin/index.d.mts +0 -9
  35. package/libESM/api/bitcoin/index.mjs +0 -9
  36. package/libESM/api/bitcoin/inputs.d.mts +0 -6
  37. package/libESM/api/bitcoin/inputs.mjs +0 -75
  38. package/libESM/api/bitcoin/outputs.d.mts +0 -5
  39. package/libESM/api/bitcoin/outputs.mjs +0 -128
  40. package/libESM/api/bitcoin/refTx.d.mts +0 -17
  41. package/libESM/api/bitcoin/refTx.mjs +0 -252
  42. package/libESM/api/bitcoin/signtx.d.mts +0 -22
  43. package/libESM/api/bitcoin/signtx.mjs +0 -213
  44. package/libESM/api/bitcoin/signtxLegacy.d.mts +0 -3
  45. package/libESM/api/bitcoin/signtxLegacy.mjs +0 -179
  46. package/libESM/api/bitcoin/signtxVerify.d.mts +0 -12
  47. package/libESM/api/bitcoin/signtxVerify.mjs +0 -86
  48. package/libESM/api/bitcoin/transactionBytes.d.mts +0 -3
  49. package/libESM/api/bitcoin/transactionBytes.mjs +0 -65
  50. package/libESM/api/bleUnpair.d.mts +0 -11
  51. package/libESM/api/bleUnpair.mjs +0 -35
  52. package/libESM/api/blockchainDisconnect.d.mts +0 -16
  53. package/libESM/api/blockchainDisconnect.mjs +0 -39
  54. package/libESM/api/blockchainEstimateFee.d.mts +0 -14
  55. package/libESM/api/blockchainEstimateFee.mjs +0 -106
  56. package/libESM/api/blockchainEvmRpcCall.d.mts +0 -17
  57. package/libESM/api/blockchainEvmRpcCall.mjs +0 -61
  58. package/libESM/api/blockchainGetAccountBalanceHistory.d.mts +0 -14
  59. package/libESM/api/blockchainGetAccountBalanceHistory.mjs +0 -64
  60. package/libESM/api/blockchainGetContractInfo.d.mts +0 -14
  61. package/libESM/api/blockchainGetContractInfo.mjs +0 -50
  62. package/libESM/api/blockchainGetCurrentFiatRates.d.mts +0 -18
  63. package/libESM/api/blockchainGetCurrentFiatRates.mjs +0 -53
  64. package/libESM/api/blockchainGetFiatRatesForTimestamps.d.mts +0 -21
  65. package/libESM/api/blockchainGetFiatRatesForTimestamps.mjs +0 -59
  66. package/libESM/api/blockchainGetInfo.d.mts +0 -13
  67. package/libESM/api/blockchainGetInfo.mjs +0 -41
  68. package/libESM/api/blockchainGetTransactions.d.mts +0 -15
  69. package/libESM/api/blockchainGetTransactions.mjs +0 -47
  70. package/libESM/api/blockchainSetCustomBackend.d.mts +0 -13
  71. package/libESM/api/blockchainSetCustomBackend.mjs +0 -41
  72. package/libESM/api/blockchainSubscribe.d.mts +0 -17
  73. package/libESM/api/blockchainSubscribe.mjs +0 -68
  74. package/libESM/api/blockchainSubscribeFiatRates.d.mts +0 -17
  75. package/libESM/api/blockchainSubscribeFiatRates.mjs +0 -47
  76. package/libESM/api/blockchainUnsubscribe.d.mts +0 -17
  77. package/libESM/api/blockchainUnsubscribe.mjs +0 -68
  78. package/libESM/api/blockchainUnsubscribeFiatRates.d.mts +0 -15
  79. package/libESM/api/blockchainUnsubscribeFiatRates.mjs +0 -41
  80. package/libESM/api/blockchainValidateEvmRpcUrl.d.mts +0 -17
  81. package/libESM/api/blockchainValidateEvmRpcUrl.mjs +0 -54
  82. package/libESM/api/cancelCoinjoinAuthorization.d.mts +0 -11
  83. package/libESM/api/cancelCoinjoinAuthorization.mjs +0 -31
  84. package/libESM/api/cardano/api/cardanoComposeTransaction.d.mts +0 -10
  85. package/libESM/api/cardano/api/cardanoComposeTransaction.mjs +0 -79
  86. package/libESM/api/cardano/api/cardanoGetAddress.d.mts +0 -30
  87. package/libESM/api/cardano/api/cardanoGetAddress.mjs +0 -116
  88. package/libESM/api/cardano/api/cardanoGetNativeScriptHash.d.mts +0 -12
  89. package/libESM/api/cardano/api/cardanoGetNativeScriptHash.mjs +0 -66
  90. package/libESM/api/cardano/api/cardanoGetPublicKey.d.mts +0 -20
  91. package/libESM/api/cardano/api/cardanoGetPublicKey.mjs +0 -72
  92. package/libESM/api/cardano/api/cardanoSignMessage.d.mts +0 -27
  93. package/libESM/api/cardano/api/cardanoSignMessage.mjs +0 -96
  94. package/libESM/api/cardano/api/cardanoSignTransaction.d.mts +0 -81
  95. package/libESM/api/cardano/api/cardanoSignTransaction.mjs +0 -298
  96. package/libESM/api/cardano/api/index.d.mts +0 -6
  97. package/libESM/api/cardano/api/index.mjs +0 -6
  98. package/libESM/api/cardano/cardanoAddressParameters.d.mts +0 -6
  99. package/libESM/api/cardano/cardanoAddressParameters.mjs +0 -79
  100. package/libESM/api/cardano/cardanoAuxiliaryData.d.mts +0 -4
  101. package/libESM/api/cardano/cardanoAuxiliaryData.mjs +0 -74
  102. package/libESM/api/cardano/cardanoCertificate.d.mts +0 -13
  103. package/libESM/api/cardano/cardanoCertificate.mjs +0 -142
  104. package/libESM/api/cardano/cardanoInputs.d.mts +0 -25
  105. package/libESM/api/cardano/cardanoInputs.mjs +0 -39
  106. package/libESM/api/cardano/cardanoOutputs.d.mts +0 -40
  107. package/libESM/api/cardano/cardanoOutputs.mjs +0 -70
  108. package/libESM/api/cardano/cardanoTokenBundle.d.mts +0 -12
  109. package/libESM/api/cardano/cardanoTokenBundle.mjs +0 -21
  110. package/libESM/api/cardano/cardanoUtils.d.mts +0 -9
  111. package/libESM/api/cardano/cardanoUtils.mjs +0 -101
  112. package/libESM/api/cardano/cardanoWitnesses.d.mts +0 -4
  113. package/libESM/api/cardano/cardanoWitnesses.mjs +0 -47
  114. package/libESM/api/changeLanguage.d.mts +0 -18
  115. package/libESM/api/changeLanguage.mjs +0 -47
  116. package/libESM/api/changePin.d.mts +0 -11
  117. package/libESM/api/changePin.mjs +0 -25
  118. package/libESM/api/changeWipeCode.d.mts +0 -11
  119. package/libESM/api/changeWipeCode.mjs +0 -27
  120. package/libESM/api/cipherKeyValue.d.mts +0 -15
  121. package/libESM/api/cipherKeyValue.mjs +0 -51
  122. package/libESM/api/common/AbstractMiscGetAddress.d.mts +0 -35
  123. package/libESM/api/common/AbstractMiscGetAddress.mjs +0 -102
  124. package/libESM/api/common/Discovery.d.mts +0 -33
  125. package/libESM/api/common/Discovery.mjs +0 -116
  126. package/libESM/api/common/paramsValidator.d.mts +0 -23
  127. package/libESM/api/common/paramsValidator.mjs +0 -134
  128. package/libESM/api/common/requestExistingAccounts.d.mts +0 -9
  129. package/libESM/api/common/requestExistingAccounts.mjs +0 -20
  130. package/libESM/api/composeTransaction.d.mts +0 -36
  131. package/libESM/api/composeTransaction.mjs +0 -386
  132. package/libESM/api/discoverAccounts.d.mts +0 -38
  133. package/libESM/api/discoverAccounts.mjs +0 -363
  134. package/libESM/api/ethereum/api/ethereumGetAddress.d.mts +0 -28
  135. package/libESM/api/ethereum/api/ethereumGetAddress.mjs +0 -135
  136. package/libESM/api/ethereum/api/ethereumGetPublicKey.d.mts +0 -48
  137. package/libESM/api/ethereum/api/ethereumGetPublicKey.mjs +0 -90
  138. package/libESM/api/ethereum/api/ethereumSignMessage.d.mts +0 -27
  139. package/libESM/api/ethereum/api/ethereumSignMessage.mjs +0 -64
  140. package/libESM/api/ethereum/api/ethereumSignTransaction.d.mts +0 -83
  141. package/libESM/api/ethereum/api/ethereumSignTransaction.mjs +0 -148
  142. package/libESM/api/ethereum/api/ethereumSignTypedData.d.mts +0 -116
  143. package/libESM/api/ethereum/api/ethereumSignTypedData.mjs +0 -202
  144. package/libESM/api/ethereum/api/ethereumVerifyMessage.d.mts +0 -12
  145. package/libESM/api/ethereum/api/ethereumVerifyMessage.mjs +0 -33
  146. package/libESM/api/ethereum/api/index.d.mts +0 -6
  147. package/libESM/api/ethereum/api/index.mjs +0 -6
  148. package/libESM/api/ethereum/ethereumDefinitions.d.mts +0 -46
  149. package/libESM/api/ethereum/ethereumDefinitions.mjs +0 -103
  150. package/libESM/api/ethereum/ethereumSignTx.d.mts +0 -20
  151. package/libESM/api/ethereum/ethereumSignTx.mjs +0 -131
  152. package/libESM/api/ethereum/ethereumSignTypedData.d.mts +0 -32
  153. package/libESM/api/ethereum/ethereumSignTypedData.mjs +0 -169
  154. package/libESM/api/evoluGetDelegatedIdentityKey.d.mts +0 -14
  155. package/libESM/api/evoluGetDelegatedIdentityKey.mjs +0 -26
  156. package/libESM/api/evoluGetNode.d.mts +0 -13
  157. package/libESM/api/evoluGetNode.mjs +0 -27
  158. package/libESM/api/evoluSignRegistrationRequest.d.mts +0 -15
  159. package/libESM/api/evoluSignRegistrationRequest.mjs +0 -31
  160. package/libESM/api/firmware/calculateFirmwareHash.d.mts +0 -13
  161. package/libESM/api/firmware/calculateFirmwareHash.mjs +0 -56
  162. package/libESM/api/firmware/calculateXPubHash.d.mts +0 -10
  163. package/libESM/api/firmware/calculateXPubHash.mjs +0 -14
  164. package/libESM/api/firmware/getBinary.d.mts +0 -10
  165. package/libESM/api/firmware/getBinary.mjs +0 -33
  166. package/libESM/api/firmware/index.d.mts +0 -6
  167. package/libESM/api/firmware/index.mjs +0 -6
  168. package/libESM/api/firmware/modifyFirmware.d.mts +0 -3
  169. package/libESM/api/firmware/modifyFirmware.mjs +0 -13
  170. package/libESM/api/firmware/parseFirmwareHeaders.d.mts +0 -4
  171. package/libESM/api/firmware/parseFirmwareHeaders.mjs +0 -26
  172. package/libESM/api/firmware/uploadFirmware.d.mts +0 -19
  173. package/libESM/api/firmware/uploadFirmware.mjs +0 -99
  174. package/libESM/api/firmware/verifyEntropy.d.mts +0 -18
  175. package/libESM/api/firmware/verifyEntropy.mjs +0 -107
  176. package/libESM/api/getAccountInfo.d.mts +0 -94
  177. package/libESM/api/getAccountInfo.mjs +0 -385
  178. package/libESM/api/getAddress.d.mts +0 -39
  179. package/libESM/api/getAddress.mjs +0 -142
  180. package/libESM/api/getCoinInfo.d.mts +0 -148
  181. package/libESM/api/getCoinInfo.mjs +0 -29
  182. package/libESM/api/getDeviceState.d.mts +0 -8
  183. package/libESM/api/getDeviceState.mjs +0 -16
  184. package/libESM/api/getFeatures.d.mts +0 -70
  185. package/libESM/api/getFeatures.mjs +0 -20
  186. package/libESM/api/getFirmwareHash.d.mts +0 -11
  187. package/libESM/api/getFirmwareHash.mjs +0 -27
  188. package/libESM/api/getNonce.d.mts +0 -10
  189. package/libESM/api/getNonce.mjs +0 -16
  190. package/libESM/api/getOwnershipId.d.mts +0 -15
  191. package/libESM/api/getOwnershipId.mjs +0 -79
  192. package/libESM/api/getOwnershipProof.d.mts +0 -15
  193. package/libESM/api/getOwnershipProof.mjs +0 -86
  194. package/libESM/api/getPublicKey.d.mts +0 -50
  195. package/libESM/api/getPublicKey.mjs +0 -88
  196. package/libESM/api/getSettings.d.mts +0 -8
  197. package/libESM/api/getSettings.mjs +0 -15
  198. package/libESM/api/index.d.mts +0 -59
  199. package/libESM/api/index.mjs +0 -59
  200. package/libESM/api/loadDevice.d.mts +0 -16
  201. package/libESM/api/loadDevice.mjs +0 -44
  202. package/libESM/api/monero/api/index.d.mts +0 -4
  203. package/libESM/api/monero/api/index.mjs +0 -4
  204. package/libESM/api/monero/api/moneroGetAddress.d.mts +0 -30
  205. package/libESM/api/monero/api/moneroGetAddress.mjs +0 -109
  206. package/libESM/api/monero/api/moneroGetWatchKey.d.mts +0 -14
  207. package/libESM/api/monero/api/moneroGetWatchKey.mjs +0 -44
  208. package/libESM/api/monero/api/moneroKeyImageSync.d.mts +0 -17
  209. package/libESM/api/monero/api/moneroKeyImageSync.mjs +0 -127
  210. package/libESM/api/monero/api/moneroSignTransaction.d.mts +0 -17
  211. package/libESM/api/monero/api/moneroSignTransaction.mjs +0 -202
  212. package/libESM/api/pingDevice.d.mts +0 -11
  213. package/libESM/api/pingDevice.mjs +0 -27
  214. package/libESM/api/pushTransaction.d.mts +0 -17
  215. package/libESM/api/pushTransaction.mjs +0 -42
  216. package/libESM/api/recoveryDevice.d.mts +0 -20
  217. package/libESM/api/recoveryDevice.mjs +0 -50
  218. package/libESM/api/requestLogin.d.mts +0 -14
  219. package/libESM/api/requestLogin.mjs +0 -48
  220. package/libESM/api/resetDevice.d.mts +0 -22
  221. package/libESM/api/resetDevice.mjs +0 -131
  222. package/libESM/api/ripple/api/index.d.mts +0 -2
  223. package/libESM/api/ripple/api/index.mjs +0 -2
  224. package/libESM/api/ripple/api/rippleGetAddress.d.mts +0 -15
  225. package/libESM/api/ripple/api/rippleGetAddress.mjs +0 -22
  226. package/libESM/api/ripple/api/rippleSignTransaction.d.mts +0 -13
  227. package/libESM/api/ripple/api/rippleSignTransaction.mjs +0 -52
  228. package/libESM/api/setBrightness.d.mts +0 -12
  229. package/libESM/api/setBrightness.mjs +0 -26
  230. package/libESM/api/setBusy.d.mts +0 -11
  231. package/libESM/api/setBusy.mjs +0 -32
  232. package/libESM/api/showDeviceTutorial.d.mts +0 -11
  233. package/libESM/api/showDeviceTutorial.mjs +0 -21
  234. package/libESM/api/signMessage.d.mts +0 -25
  235. package/libESM/api/signMessage.mjs +0 -71
  236. package/libESM/api/signTransaction.d.mts +0 -197
  237. package/libESM/api/signTransaction.mjs +0 -334
  238. package/libESM/api/solana/api/index.d.mts +0 -4
  239. package/libESM/api/solana/api/index.mjs +0 -4
  240. package/libESM/api/solana/api/solanaComposeTransaction.d.mts +0 -31
  241. package/libESM/api/solana/api/solanaComposeTransaction.mjs +0 -76
  242. package/libESM/api/solana/api/solanaGetAddress.d.mts +0 -15
  243. package/libESM/api/solana/api/solanaGetAddress.mjs +0 -22
  244. package/libESM/api/solana/api/solanaGetPublicKey.d.mts +0 -28
  245. package/libESM/api/solana/api/solanaGetPublicKey.mjs +0 -67
  246. package/libESM/api/solana/api/solanaSignTransaction.d.mts +0 -41
  247. package/libESM/api/solana/api/solanaSignTransaction.mjs +0 -203
  248. package/libESM/api/solana/solanaDefinitions.d.mts +0 -7
  249. package/libESM/api/solana/solanaDefinitions.mjs +0 -33
  250. package/libESM/api/stellar/api/index.d.mts +0 -2
  251. package/libESM/api/stellar/api/index.mjs +0 -2
  252. package/libESM/api/stellar/api/stellarGetAddress.d.mts +0 -15
  253. package/libESM/api/stellar/api/stellarGetAddress.mjs +0 -22
  254. package/libESM/api/stellar/api/stellarSignTransaction.d.mts +0 -26
  255. package/libESM/api/stellar/api/stellarSignTransaction.mjs +0 -66
  256. package/libESM/api/stellar/stellarSignTx.d.mts +0 -7
  257. package/libESM/api/stellar/stellarSignTx.mjs +0 -191
  258. package/libESM/api/telemetryGet.d.mts +0 -14
  259. package/libESM/api/telemetryGet.mjs +0 -24
  260. package/libESM/api/tezos/api/index.d.mts +0 -3
  261. package/libESM/api/tezos/api/index.mjs +0 -3
  262. package/libESM/api/tezos/api/tezosGetAddress.d.mts +0 -15
  263. package/libESM/api/tezos/api/tezosGetAddress.mjs +0 -22
  264. package/libESM/api/tezos/api/tezosGetPublicKey.d.mts +0 -24
  265. package/libESM/api/tezos/api/tezosGetPublicKey.mjs +0 -66
  266. package/libESM/api/tezos/api/tezosSignTransaction.d.mts +0 -14
  267. package/libESM/api/tezos/api/tezosSignTransaction.mjs +0 -30
  268. package/libESM/api/tezos/tezosSignTx.d.mts +0 -71
  269. package/libESM/api/tezos/tezosSignTx.mjs +0 -204
  270. package/libESM/api/thpGetCredentials.d.mts +0 -13
  271. package/libESM/api/thpGetCredentials.mjs +0 -28
  272. package/libESM/api/thpRemoveCredentials.d.mts +0 -15
  273. package/libESM/api/thpRemoveCredentials.mjs +0 -42
  274. package/libESM/api/tron/api/index.d.mts +0 -3
  275. package/libESM/api/tron/api/index.mjs +0 -3
  276. package/libESM/api/tron/api/tronComposeTransaction.d.mts +0 -17
  277. package/libESM/api/tron/api/tronComposeTransaction.mjs +0 -51
  278. package/libESM/api/tron/api/tronGetAddress.d.mts +0 -15
  279. package/libESM/api/tron/api/tronGetAddress.mjs +0 -20
  280. package/libESM/api/tron/api/tronSignTransaction.d.mts +0 -19
  281. package/libESM/api/tron/api/tronSignTransaction.mjs +0 -129
  282. package/libESM/api/tron/tronEncode.d.mts +0 -12
  283. package/libESM/api/tron/tronEncode.mjs +0 -77
  284. package/libESM/api/tron/tronProtobuf.d.mts +0 -5
  285. package/libESM/api/tron/tronProtobuf.mjs +0 -28
  286. package/libESM/api/unlockPath.d.mts +0 -12
  287. package/libESM/api/unlockPath.mjs +0 -31
  288. package/libESM/api/verifyMessage.d.mts +0 -16
  289. package/libESM/api/verifyMessage.mjs +0 -46
  290. package/libESM/api/wipeDevice.d.mts +0 -21
  291. package/libESM/api/wipeDevice.mjs +0 -47
  292. package/libESM/backend/BackendManager.d.mts +0 -24
  293. package/libESM/backend/BackendManager.mjs +0 -137
  294. package/libESM/backend/Blockchain.d.mts +0 -81
  295. package/libESM/backend/Blockchain.mjs +0 -232
  296. package/libESM/backend/BlockchainLink.d.mts +0 -9
  297. package/libESM/backend/BlockchainLink.mjs +0 -13
  298. package/libESM/backend/fees/BitcoinFeeLevels.d.mts +0 -19
  299. package/libESM/backend/fees/BitcoinFeeLevels.mjs +0 -43
  300. package/libESM/backend/fees/EthereumFeeLevels.d.mts +0 -17
  301. package/libESM/backend/fees/EthereumFeeLevels.mjs +0 -52
  302. package/libESM/backend/fees/MiscFeeLevels.d.mts +0 -18
  303. package/libESM/backend/fees/MiscFeeLevels.mjs +0 -25
  304. package/libESM/backend/fees/index.d.mts +0 -5
  305. package/libESM/backend/fees/index.mjs +0 -30
  306. package/libESM/core/AbstractMethod.d.mts +0 -65
  307. package/libESM/core/AbstractMethod.mjs +0 -153
  308. package/libESM/core/index.d.mts +0 -27
  309. package/libESM/core/index.mjs +0 -795
  310. package/libESM/core/method.d.mts +0 -3
  311. package/libESM/core/method.mjs +0 -19
  312. package/libESM/core/method.native.d.mts +0 -2
  313. package/libESM/core/method.native.mjs +0 -29
  314. package/libESM/core/onCallFirmwareUpdate.d.mts +0 -39
  315. package/libESM/core/onCallFirmwareUpdate.mjs +0 -436
  316. package/libESM/data/coinInfo.d.mts +0 -374
  317. package/libESM/data/coinInfo.mjs +0 -183
  318. package/libESM/data/config.d.mts +0 -8
  319. package/libESM/data/config.mjs +0 -265
  320. package/libESM/data/defaultFeeLevels.d.mts +0 -18
  321. package/libESM/data/defaultFeeLevels.mjs +0 -174
  322. package/libESM/data/firmwareInfo.d.mts +0 -41
  323. package/libESM/data/firmwareInfo.mjs +0 -411
  324. package/libESM/data/firmwareReleaseStore.d.mts +0 -10
  325. package/libESM/data/firmwareReleaseStore.mjs +0 -16
  326. package/libESM/data/localFirmwareStore.d.mts +0 -3
  327. package/libESM/data/localFirmwareStore.mjs +0 -8
  328. package/libESM/data/protobufLoader.d.mts +0 -1
  329. package/libESM/data/protobufLoader.mjs +0 -29
  330. package/libESM/data/settingsStore.d.mts +0 -6
  331. package/libESM/data/settingsStore.mjs +0 -21
  332. package/libESM/device/Device.d.mts +0 -237
  333. package/libESM/device/Device.mjs +0 -729
  334. package/libESM/device/DeviceCommands.d.mts +0 -77
  335. package/libESM/device/DeviceCommands.mjs +0 -245
  336. package/libESM/device/DeviceCurrentSession.d.mts +0 -3208
  337. package/libESM/device/DeviceCurrentSession.mjs +0 -240
  338. package/libESM/device/DeviceList.d.mts +0 -68
  339. package/libESM/device/DeviceList.mjs +0 -246
  340. package/libESM/device/TransportList.d.mts +0 -9
  341. package/libESM/device/TransportList.mjs +0 -41
  342. package/libESM/device/TransportManager.d.mts +0 -30
  343. package/libESM/device/TransportManager.mjs +0 -142
  344. package/libESM/device/calculateRevisionForDevice.d.mts +0 -7
  345. package/libESM/device/calculateRevisionForDevice.mjs +0 -19
  346. package/libESM/device/checkFirmwareRevision.d.mts +0 -12
  347. package/libESM/device/checkFirmwareRevision.mjs +0 -75
  348. package/libESM/device/resolveDescriptorForTaproot.d.mts +0 -14
  349. package/libESM/device/resolveDescriptorForTaproot.mjs +0 -25
  350. package/libESM/device/thp/handshake.d.mts +0 -3
  351. package/libESM/device/thp/handshake.mjs +0 -100
  352. package/libESM/device/thp/index.d.mts +0 -5
  353. package/libESM/device/thp/index.mjs +0 -65
  354. package/libESM/device/thp/pairing.d.mts +0 -16
  355. package/libESM/device/thp/pairing.mjs +0 -237
  356. package/libESM/device/thp/session.d.mts +0 -2
  357. package/libESM/device/thp/session.mjs +0 -27
  358. package/libESM/device/thp/thpCall.d.mts +0 -40
  359. package/libESM/device/thp/thpCall.mjs +0 -58
  360. package/libESM/device/validateMessageSize.d.mts +0 -2
  361. package/libESM/device/validateMessageSize.mjs +0 -9
  362. package/libESM/device/workflow/changeLanguage.d.mts +0 -14
  363. package/libESM/device/workflow/changeLanguage.mjs +0 -59
  364. package/libESM/device/workflow/checkFirmwareHash.d.mts +0 -9
  365. package/libESM/device/workflow/checkFirmwareHash.mjs +0 -86
  366. package/libESM/device/workflow/checkFirmwareHashWithRetries.d.mts +0 -8
  367. package/libESM/device/workflow/checkFirmwareHashWithRetries.mjs +0 -36
  368. package/libESM/device/workflow/handshake.d.mts +0 -9
  369. package/libESM/device/workflow/handshake.mjs +0 -55
  370. package/libESM/device/workflow/trezorPushNotification.d.mts +0 -2
  371. package/libESM/device/workflow/trezorPushNotification.mjs +0 -73
  372. package/libESM/device/workflow/validateState.d.mts +0 -2
  373. package/libESM/device/workflow/validateState.mjs +0 -153
  374. package/libESM/events/ui-promise.d.mts +0 -22
  375. package/libESM/events/ui-promise.mjs +0 -1
  376. package/libESM/exports.d.mts +0 -3
  377. package/libESM/exports.mjs +0 -3
  378. package/libESM/impl/core-in-module.d.mts +0 -27
  379. package/libESM/impl/core-in-module.mjs +0 -173
  380. package/libESM/index.browser.d.mts +0 -9
  381. package/libESM/index.browser.mjs +0 -50
  382. package/libESM/index.d.mts +0 -6
  383. package/libESM/index.mjs +0 -32
  384. package/libESM/index.renderer.d.mts +0 -6
  385. package/libESM/index.renderer.mjs +0 -19
  386. package/libESM/tsconfig.libESM.tsbuildinfo +0 -1
  387. package/libESM/types/idevice.d.mts +0 -109
  388. package/libESM/types/idevice.mjs +0 -1
  389. package/libESM/types/typed-call-provider.d.mts +0 -29
  390. package/libESM/types/typed-call-provider.mjs +0 -1
  391. package/libESM/types/workflow.d.mts +0 -16
  392. package/libESM/types/workflow.mjs +0 -1
  393. package/libESM/utils/accountUtils.d.mts +0 -10
  394. package/libESM/utils/accountUtils.mjs +0 -83
  395. package/libESM/utils/addressUtils.d.mts +0 -2
  396. package/libESM/utils/addressUtils.mjs +0 -24
  397. package/libESM/utils/assetUtils.d.mts +0 -13
  398. package/libESM/utils/assetUtils.mjs +0 -56
  399. package/libESM/utils/assets.browser.d.mts +0 -1
  400. package/libESM/utils/assets.browser.mjs +0 -1
  401. package/libESM/utils/assets.d.mts +0 -2
  402. package/libESM/utils/assets.mjs +0 -13
  403. package/libESM/utils/assets.native.d.mts +0 -2
  404. package/libESM/utils/assets.native.mjs +0 -23
  405. package/libESM/utils/assetsTypes.d.mts +0 -5
  406. package/libESM/utils/assetsTypes.mjs +0 -1
  407. package/libESM/utils/buildOutputDescriptor.d.mts +0 -12
  408. package/libESM/utils/buildOutputDescriptor.mjs +0 -67
  409. package/libESM/utils/deviceFeaturesUtils.d.mts +0 -7
  410. package/libESM/utils/deviceFeaturesUtils.mjs +0 -109
  411. package/libESM/utils/ethereumUtils.d.mts +0 -3
  412. package/libESM/utils/ethereumUtils.mjs +0 -7
  413. package/libESM/utils/firmwareReleaseConfigUtils.d.mts +0 -19
  414. package/libESM/utils/firmwareReleaseConfigUtils.mjs +0 -131
  415. package/libESM/utils/firmwareUtils.d.mts +0 -13
  416. package/libESM/utils/firmwareUtils.mjs +0 -54
  417. package/libESM/utils/formatUtils.d.mts +0 -15
  418. package/libESM/utils/formatUtils.mjs +0 -45
  419. package/libESM/utils/hdnodeUtils.d.mts +0 -6
  420. package/libESM/utils/hdnodeUtils.mjs +0 -62
  421. package/libESM/utils/pathUtils.d.mts +0 -17
  422. package/libESM/utils/pathUtils.mjs +0 -141
  423. package/libESM/utils/paymentRequest.d.mts +0 -8
  424. package/libESM/utils/paymentRequest.mjs +0 -25
  425. package/libESM/utils/uiPromiseManager.d.mts +0 -8
  426. package/libESM/utils/uiPromiseManager.mjs +0 -51
  427. package/libESM/workers/workers.browser.d.mts +0 -10
  428. package/libESM/workers/workers.browser.mjs +0 -16
  429. package/libESM/workers/workers.d.mts +0 -10
  430. package/libESM/workers/workers.mjs +0 -8
  431. package/libESM/workers/workers.native.d.mts +0 -7
  432. package/libESM/workers/workers.native.mjs +0 -7
@@ -1,134 +0,0 @@
1
- import { ERRORS } from "@trezor/connect-common/libESM/constants/index.mjs";
2
- import { typedObjectTransformValues, versionUtils } from "@trezor/utils";
3
- import { config } from "../../data/config.mjs";
4
- import { fromHardened } from "../../utils/pathUtils.mjs";
5
- const invalidParameter = message => ERRORS.TypedError('Method_InvalidParameter', message);
6
- export const bundlify = payload => ({
7
- hasBundle: !!payload.bundle,
8
- payload: {
9
- ...payload,
10
- bundle: payload.bundle ?? [payload]
11
- }
12
- });
13
- export function validateParams(params, schema) {
14
- schema.forEach(field => {
15
- const value = params[field.name];
16
- if (field.required && value == null) {
17
- throw invalidParameter(`Parameter "${field.name}" is missing.`);
18
- }
19
- if (!field.type || value == null) return;
20
- const {
21
- name,
22
- type
23
- } = field;
24
- if (Array.isArray(type)) {
25
- const p = {};
26
- p[name] = value;
27
- const success = type.reduce((count, t) => {
28
- try {
29
- validateParams(p, [{
30
- name: field.name,
31
- type: t
32
- }]);
33
- return count + 1;
34
- } catch {
35
- return count;
36
- }
37
- }, 0);
38
- if (!success) {
39
- throw invalidParameter(`Parameter "${name}" has invalid type. Union of "${type.join('|')}" expected.`);
40
- }
41
- return;
42
- }
43
- if (type === 'array') {
44
- if (!Array.isArray(value)) {
45
- throw invalidParameter(`Parameter "${name}" has invalid type. "${type}" expected.`);
46
- }
47
- if (!field.allowEmpty && value.length < 1) {
48
- throw invalidParameter(`Parameter "${name}" is empty.`);
49
- }
50
- } else if (type === 'uint') {
51
- if (typeof value !== 'string' && typeof value !== 'number') {
52
- throw invalidParameter(`Parameter "${name}" has invalid type. "string|number" expected.`);
53
- }
54
- if (typeof value === 'number' && !Number.isSafeInteger(value) || !/^(?:[1-9]\d*|\d)$/.test(value.toString().replace(/^-/, field.allowNegative ? '' : '-'))) {
55
- throw invalidParameter(`Parameter "${name}" has invalid value "${value}". Integer representation expected.`);
56
- }
57
- } else if (type === 'array-buffer') {
58
- if (!(value instanceof ArrayBuffer)) {
59
- throw invalidParameter(`Parameter "${name}" has invalid type. "ArrayBuffer" expected.`);
60
- }
61
- } else if (typeof value !== type) {
62
- throw invalidParameter(`Parameter "${name}" has invalid type. "${type}" expected.`);
63
- }
64
- });
65
- return params;
66
- }
67
- export const validateCoinPath = (path, coinInfo) => {
68
- if (coinInfo && coinInfo.slip44 !== fromHardened(path[1])) {
69
- throw invalidParameter('Parameters "path" and "coin" do not match.');
70
- }
71
- };
72
- export const DEFAULT_FIRMWARE_RANGE = {
73
- UNKNOWN: {
74
- min: '1.0.0',
75
- max: '0'
76
- },
77
- T1B1: {
78
- min: '1.0.0',
79
- max: '0'
80
- },
81
- T2T1: {
82
- min: '2.0.0',
83
- max: '0'
84
- },
85
- T2B1: {
86
- min: '2.6.1',
87
- max: '0'
88
- },
89
- T3B1: {
90
- min: '2.8.1',
91
- max: '0'
92
- },
93
- T3T1: {
94
- min: '2.7.1',
95
- max: '0'
96
- },
97
- T3W1: {
98
- min: '2.7.1',
99
- max: '0'
100
- }
101
- };
102
- const intersectMin = (a, b) => a === '0' || b !== '0' && versionUtils.isNewer(a, b) ? a : b;
103
- const intersectMax = (a, b) => a === '0' || b !== '0' && versionUtils.isNewer(a, b) ? b : a;
104
- const intersectRange = (a, b) => typedObjectTransformValues(a, (value, model) => ({
105
- min: intersectMin(value.min, b[model].min),
106
- max: intersectMax(value.max, b[model].max)
107
- }));
108
- const ensureArray = (item = []) => Array.isArray(item) ? item : [item];
109
- const filterByCoins = coins => {
110
- const coinSet = new Set(coins.map(coin => coin.shortcut.toLowerCase()));
111
- const coinTypeSet = new Set(coins.map(coin => coin.type));
112
- return rule => !rule.coin && !rule.coinType || ensureArray(rule.coin).some(coinSet.has.bind(coinSet)) || ensureArray(rule.coinType).some(coinTypeSet.has.bind(coinTypeSet));
113
- };
114
- const filterByMethods = methodsOrCapabilities => {
115
- const methodSet = new Set(methodsOrCapabilities);
116
- return rule => !rule.methods && !rule.capabilities || ensureArray(rule.methods).some(methodSet.has.bind(methodSet)) || ensureArray(rule.capabilities).some(methodSet.has.bind(methodSet));
117
- };
118
- const getCoinRules = (coins, currentRange) => coins.map(({
119
- support = typedObjectTransformValues(DEFAULT_FIRMWARE_RANGE, () => false)
120
- }) => ({
121
- ...currentRange,
122
- ...typedObjectTransformValues(support, value => ({
123
- min: value || '0',
124
- max: '0'
125
- }))
126
- }));
127
- const getConfigRules = (methodsOrCapabilities, coins, currentRange) => config.supportedFirmware.filter(filterByCoins(coins)).filter(filterByMethods(methodsOrCapabilities)).map(({
128
- min,
129
- max
130
- }) => typedObjectTransformValues(currentRange, (value, key) => ({
131
- min: min?.[key] ?? value.min,
132
- max: max?.[key] ?? value.max
133
- })));
134
- export const getFirmwareRange = (methodsOrCapabilities, coins, currentRange = DEFAULT_FIRMWARE_RANGE) => getCoinRules(coins, currentRange).concat(getConfigRules(methodsOrCapabilities, coins, currentRange)).reduce(intersectRange, currentRange);
@@ -1,9 +0,0 @@
1
- import { type CoinInfo, type CoreEventMessage, type DiscoveryAccount } from '@trezor/connect-common';
2
- import type { UiPromiseCreator } from '../../events/ui-promise';
3
- import type { IDevice } from '../../types/idevice';
4
- export declare const requestExistingAccounts: ({ postMessage, createUiPromise, device, coinInfo, }: {
5
- postMessage: (message: CoreEventMessage) => void;
6
- createUiPromise: UiPromiseCreator;
7
- device: IDevice;
8
- coinInfo: CoinInfo;
9
- }) => Promise<DiscoveryAccount[] | null>;
@@ -1,20 +0,0 @@
1
- import { UI_REQUEST, UI_RESPONSE, createUiMessage } from "@trezor/connect-common";
2
- import { resolveAfter } from "@trezor/utils/libESM/resolveAfter.mjs";
3
- const REQUEST_TIMEOUT_MS = 200;
4
- export const requestExistingAccounts = async ({
5
- postMessage,
6
- createUiPromise,
7
- device,
8
- coinInfo
9
- }) => {
10
- const dfd = createUiPromise(UI_RESPONSE.RECEIVE_DISCOVERY_ACCOUNTS, device);
11
- postMessage(createUiMessage(UI_REQUEST.REQUEST_DISCOVERY_ACCOUNTS, {
12
- coinInfo
13
- }));
14
- const result = await Promise.race([dfd.promise.then(response => response.payload), resolveAfter(REQUEST_TIMEOUT_MS).then(() => null)]);
15
- if (result === null) {
16
- dfd.reject(new Error('No discovery accounts handler'));
17
- return null;
18
- }
19
- return result.accounts.length > 0 ? result.accounts : null;
20
- };
@@ -1,36 +0,0 @@
1
- import { type BitcoinNetworkInfo, type MethodPermission, type PrecomposeParams, type PrecomposedResult, type SignedTransaction } from '@trezor/connect-common';
2
- import { BigNumber } from '@trezor/utils/libESM/bigNumber';
3
- import type { ComposeOutput, TransactionInputOutputSortingStrategy } from '@trezor/utxo-lib';
4
- import type { MethodContext, MethodMessage } from '../core/AbstractMethod';
5
- import { AbstractMethod } from '../core/AbstractMethod';
6
- import { Discovery } from './common/Discovery';
7
- type Params = {
8
- outputs: ComposeOutput[];
9
- coinInfo: BitcoinNetworkInfo;
10
- identity?: string;
11
- push: boolean;
12
- account?: PrecomposeParams['account'];
13
- feeLevels?: PrecomposeParams['feeLevels'];
14
- baseFee?: PrecomposeParams['baseFee'];
15
- floorBaseFee?: PrecomposeParams['floorBaseFee'];
16
- sequence?: PrecomposeParams['sequence'];
17
- total: BigNumber;
18
- sortingStrategy?: TransactionInputOutputSortingStrategy;
19
- };
20
- export default class ComposeTransaction extends AbstractMethod<'composeTransaction', Params> {
21
- constructor(message: MethodMessage<'composeTransaction'>);
22
- discovery?: Discovery;
23
- get requiredPermissions(): MethodPermission[];
24
- get info(): string;
25
- private getBlockchain;
26
- private precompose;
27
- run(context: MethodContext): Promise<SignedTransaction | PrecomposedResult[]>;
28
- private selectAccount;
29
- private selectFromExistingAccounts;
30
- private selectFromDiscovery;
31
- private selectFee;
32
- private _selectFeeUiResponse;
33
- private _sign;
34
- dispose(): void;
35
- }
36
- export {};
@@ -1,386 +0,0 @@
1
- import { DEFAULT_SORTING_STRATEGY, ERRORS, UI_REQUEST, UI_RESPONSE, createUiMessage } from "@trezor/connect-common";
2
- import { BigNumber } from "@trezor/utils/libESM/bigNumber.mjs";
3
- import { promiseAllSequence } from "@trezor/utils/libESM/promiseAllSequence.mjs";
4
- import { resolveAfter } from "@trezor/utils/libESM/resolveAfter.mjs";
5
- import { unique } from "@trezor/utils/libESM/unique.mjs";
6
- import { initBlockchain, isBackendSupported } from "../backend/BlockchainLink.mjs";
7
- import { AbstractMethod } from "../core/AbstractMethod.mjs";
8
- import { requestExistingAccounts } from "./common/requestExistingAccounts.mjs";
9
- import { fixCoinInfoNetwork, getBitcoinNetwork } from "../data/coinInfo.mjs";
10
- import { formatAmount } from "../utils/formatUtils.mjs";
11
- import * as pathUtils from "../utils/pathUtils.mjs";
12
- import { TransactionComposer } from "./bitcoin/TransactionComposer.mjs";
13
- import { enhanceSignTx } from "./bitcoin/enhanceSignTx.mjs";
14
- import { inputToTrezor } from "./bitcoin/inputs.mjs";
15
- import { outputToTrezor, validateHDOutput } from "./bitcoin/outputs.mjs";
16
- import { getReferencedTransactions, parseTransactionHexes, requireReferencedTransactions, transformReferencedTransactions } from "./bitcoin/refTx.mjs";
17
- import { signTx } from "./bitcoin/signtx.mjs";
18
- import { signTxLegacy } from "./bitcoin/signtxLegacy.mjs";
19
- import { deriveOutputScript, verifyTx } from "./bitcoin/signtxVerify.mjs";
20
- import { Discovery } from "./common/Discovery.mjs";
21
- import { validateParams } from "./common/paramsValidator.mjs";
22
- export default class ComposeTransaction extends AbstractMethod {
23
- constructor(message) {
24
- const {
25
- payload
26
- } = message;
27
- validateParams(payload, [{
28
- name: 'outputs',
29
- type: 'array',
30
- required: true
31
- }, {
32
- name: 'coin',
33
- type: 'string',
34
- required: true
35
- }, {
36
- name: 'identity',
37
- type: 'string'
38
- }, {
39
- name: 'push',
40
- type: 'boolean'
41
- }, {
42
- name: 'account',
43
- type: 'object'
44
- }, {
45
- name: 'feeLevels',
46
- type: 'array'
47
- }, {
48
- name: 'baseFee',
49
- type: 'number'
50
- }, {
51
- name: 'floorBaseFee',
52
- type: 'boolean'
53
- }, {
54
- name: 'sequence',
55
- type: 'number'
56
- }, {
57
- name: 'sortingStrategy',
58
- type: 'string'
59
- }]);
60
- const coinInfo = getBitcoinNetwork(payload.coin);
61
- if (!coinInfo) {
62
- throw ERRORS.TypedError('Method_UnknownCoin');
63
- }
64
- isBackendSupported(coinInfo);
65
- const outputs = [];
66
- let total = new BigNumber(0);
67
- payload.outputs.forEach(out => {
68
- const output = validateHDOutput(out, coinInfo);
69
- if ('amount' in output && typeof output.amount === 'string') {
70
- total = total.plus(output.amount);
71
- }
72
- outputs.push(output);
73
- });
74
- const params = {
75
- outputs,
76
- coinInfo,
77
- identity: payload.identity,
78
- account: payload.account,
79
- feeLevels: payload.feeLevels,
80
- baseFee: payload.baseFee,
81
- floorBaseFee: payload.floorBaseFee,
82
- sequence: payload.sequence,
83
- sortingStrategy: payload.sortingStrategy,
84
- push: typeof payload.push === 'boolean' ? payload.push : false,
85
- total
86
- };
87
- super(message, params);
88
- this.useDevice = !payload.account && !payload.feeLevels;
89
- this.useUi = this.useDevice;
90
- this.requiredFirmwareCoins = [coinInfo];
91
- }
92
- discovery;
93
- get requiredPermissions() {
94
- const permissions = ['read', 'write'];
95
- if (this.params.push) {
96
- permissions.push('push_tx');
97
- }
98
- return permissions;
99
- }
100
- get info() {
101
- const sendMax = this.params?.outputs.find(o => o.type === 'send-max') !== undefined;
102
- if (sendMax) {
103
- return 'Send maximum amount';
104
- }
105
- return `Send ${formatAmount(this.params.total.toString(), this.params.coinInfo)}`;
106
- }
107
- getBlockchain(sendCoreMessage) {
108
- return initBlockchain(this.params.coinInfo, sendCoreMessage, this.params.identity);
109
- }
110
- async precompose(account, feeLevels, sendCoreMessage) {
111
- const {
112
- coinInfo,
113
- outputs,
114
- baseFee,
115
- sortingStrategy
116
- } = this.params;
117
- const address_n = pathUtils.validatePath(account.path);
118
- const composer = new TransactionComposer({
119
- account: {
120
- type: pathUtils.getAccountType(address_n),
121
- label: 'Account',
122
- descriptor: account.path,
123
- address_n,
124
- addresses: account.addresses
125
- },
126
- utxos: account.utxo,
127
- coinInfo,
128
- outputs,
129
- baseFee,
130
- sortingStrategy: sortingStrategy ?? DEFAULT_SORTING_STRATEGY
131
- });
132
- const blockchain = await this.getBlockchain(sendCoreMessage);
133
- await composer.init(blockchain);
134
- return feeLevels.map(level => {
135
- composer.composeCustomFee(level.feePerUnit);
136
- const tx = {
137
- ...composer.composed.custom
138
- };
139
- if (tx.type === 'final') {
140
- return {
141
- ...tx,
142
- inputs: tx.inputs.map(inp => inputToTrezor(inp, this.params.sequence)),
143
- outputs: tx.outputs.map(outputToTrezor)
144
- };
145
- }
146
- if (tx.type === 'nonfinal') {
147
- return {
148
- ...tx,
149
- inputs: tx.inputs.map(inp => inputToTrezor(inp, this.params.sequence))
150
- };
151
- }
152
- return tx;
153
- });
154
- }
155
- async run(context) {
156
- if (this.params.account && this.params.feeLevels) {
157
- return this.precompose(this.params.account, this.params.feeLevels, context.sendCoreMessage);
158
- }
159
- const {
160
- account,
161
- utxo
162
- } = await this.selectAccount(context);
163
- const response = await this.selectFee(account, utxo, context);
164
- if (!this.discovery) {
165
- throw ERRORS.TypedError('Runtime', 'ComposeTransaction: selectFee response received after dispose');
166
- }
167
- if (typeof response === 'string') {
168
- return this.run(context);
169
- }
170
- return response;
171
- }
172
- async selectAccount(context) {
173
- const {
174
- coinInfo
175
- } = this.params;
176
- const blockchain = await this.getBlockchain(context.sendCoreMessage);
177
- if (!this.discovery) {
178
- const existingAccounts = await requestExistingAccounts({
179
- postMessage: context.sendCoreMessage,
180
- createUiPromise: context.createUiPromise,
181
- device: this.getDevice(),
182
- coinInfo
183
- });
184
- if (existingAccounts) {
185
- return this.selectFromExistingAccounts(existingAccounts, blockchain, context);
186
- }
187
- }
188
- return this.selectFromDiscovery(blockchain, context);
189
- }
190
- async selectFromExistingAccounts(accounts, blockchain, context) {
191
- const {
192
- coinInfo
193
- } = this.params;
194
- const dfd = context.createUiPromise(UI_RESPONSE.RECEIVE_ACCOUNT, this.getDevice());
195
- context.sendCoreMessage(createUiMessage(UI_REQUEST.SELECT_ACCOUNT, {
196
- type: 'complete',
197
- accountTypes: unique(accounts.map(a => a.type)),
198
- coinInfo,
199
- accounts
200
- }));
201
- const uiResp = await dfd.promise;
202
- const account = accounts[uiResp.payload];
203
- this.params.coinInfo = fixCoinInfoNetwork(this.params.coinInfo, account.address_n);
204
- const utxo = await blockchain.getAccountUtxo(account.descriptor);
205
- return {
206
- account,
207
- utxo
208
- };
209
- }
210
- async selectFromDiscovery(blockchain, context) {
211
- const {
212
- coinInfo
213
- } = this.params;
214
- const dfd = context.createUiPromise(UI_RESPONSE.RECEIVE_ACCOUNT, this.getDevice());
215
- if (this.discovery && this.discovery.completed) {
216
- const {
217
- discovery
218
- } = this;
219
- context.sendCoreMessage(createUiMessage(UI_REQUEST.SELECT_ACCOUNT, {
220
- type: 'end',
221
- coinInfo,
222
- accountTypes: discovery.types.map(t => t.type),
223
- accounts: discovery.accounts
224
- }, {
225
- requestId: dfd.requestId
226
- }));
227
- const uiResp = await dfd.promise;
228
- const account = discovery.accounts[uiResp.payload];
229
- const utxo = await blockchain.getAccountUtxo(account.descriptor);
230
- return {
231
- account,
232
- utxo
233
- };
234
- }
235
- const discovery = this.discovery || new Discovery({
236
- blockchain,
237
- getDescriptor: path => this.getDevice().getCommands().getAccountDescriptor(this.params.coinInfo, path)
238
- });
239
- this.discovery = discovery;
240
- discovery.on('progress', accounts => {
241
- context.sendCoreMessage(createUiMessage(UI_REQUEST.SELECT_ACCOUNT, {
242
- type: 'progress',
243
- coinInfo,
244
- accounts
245
- }, {
246
- requestId: dfd.requestId
247
- }));
248
- });
249
- discovery.on('complete', () => {
250
- context.sendCoreMessage(createUiMessage(UI_REQUEST.SELECT_ACCOUNT, {
251
- type: 'end',
252
- coinInfo
253
- }, {
254
- requestId: dfd.requestId
255
- }));
256
- });
257
- discovery.start('tokens').catch(error => {
258
- dfd.reject(error);
259
- });
260
- context.sendCoreMessage(createUiMessage(UI_REQUEST.SELECT_ACCOUNT, {
261
- type: 'start',
262
- accountTypes: discovery.types.map(t => t.type),
263
- coinInfo
264
- }, {
265
- requestId: dfd.requestId
266
- }));
267
- const uiResp = await dfd.promise;
268
- discovery.removeAllListeners();
269
- discovery.stop();
270
- if (!discovery.completed) {
271
- await resolveAfter(501);
272
- }
273
- const account = discovery.accounts[uiResp.payload];
274
- this.params.coinInfo = fixCoinInfoNetwork(this.params.coinInfo, account.address_n);
275
- const utxo = await blockchain.getAccountUtxo(account.descriptor);
276
- return {
277
- account,
278
- utxo
279
- };
280
- }
281
- async selectFee(account, utxos, context) {
282
- const {
283
- coinInfo,
284
- outputs,
285
- sortingStrategy
286
- } = this.params;
287
- const blockchain = await this.getBlockchain(context.sendCoreMessage);
288
- const composer = new TransactionComposer({
289
- account,
290
- utxos,
291
- coinInfo,
292
- outputs,
293
- sortingStrategy: sortingStrategy ?? DEFAULT_SORTING_STRATEGY
294
- });
295
- await composer.init(blockchain);
296
- const hasFunds = composer.composeAllFeeLevels();
297
- if (!hasFunds) {
298
- context.sendCoreMessage(createUiMessage(UI_REQUEST.INSUFFICIENT_FUNDS));
299
- await resolveAfter(2000);
300
- return 'change-account';
301
- }
302
- context.sendCoreMessage(createUiMessage(UI_REQUEST.SELECT_FEE, {
303
- feeLevels: composer.getFeeLevelList(),
304
- coinInfo: this.params.coinInfo
305
- }));
306
- return this._selectFeeUiResponse(composer, context);
307
- }
308
- async _selectFeeUiResponse(composer, context) {
309
- const resp = await context.createUiPromise(UI_RESPONSE.RECEIVE_FEE, this.getDevice()).promise;
310
- switch (resp.payload.type) {
311
- case 'compose-custom':
312
- composer.composeCustomFee(resp.payload.value);
313
- context.sendCoreMessage(createUiMessage(UI_REQUEST.UPDATE_CUSTOM_FEE, {
314
- feeLevels: composer.getFeeLevelList(),
315
- coinInfo: this.params.coinInfo
316
- }, {
317
- requestId: resp.requestId
318
- }));
319
- return this._selectFeeUiResponse(composer, context);
320
- case 'send':
321
- return this._sign(composer.composed[resp.payload.value], context.sendCoreMessage);
322
- default:
323
- return 'change-account';
324
- }
325
- }
326
- async _sign(tx, sendCoreMessage) {
327
- const device = this.getDevice();
328
- const {
329
- params
330
- } = this;
331
- if (tx.type !== 'final') throw ERRORS.TypedError('Runtime', 'ComposeTransaction: Trying to sign unfinished tx');
332
- const {
333
- coinInfo
334
- } = params;
335
- const options = enhanceSignTx({}, coinInfo);
336
- const inputs = tx.inputs.map(inp => inputToTrezor(inp, params.sequence));
337
- const outputs = tx.outputs.map(outputToTrezor);
338
- let refTxs = [];
339
- const requiredRefTxs = requireReferencedTransactions(inputs, options, coinInfo);
340
- const refTxsIds = getReferencedTransactions(inputs);
341
- if (requiredRefTxs && refTxsIds.length > 0) {
342
- refTxs = await this.getBlockchain(sendCoreMessage).then(blockchain => blockchain.getTransactionHexes(refTxsIds)).then(parseTransactionHexes(coinInfo.network)).then(transformReferencedTransactions);
343
- }
344
- const getHDNode = address_n => device.getCommands().getHDNode({
345
- address_n
346
- }, {
347
- coinInfo: params.coinInfo
348
- });
349
- const outputScripts = await promiseAllSequence(outputs.map(output => () => deriveOutputScript(getHDNode, output, coinInfo.network)));
350
- const signTxMethod = !device.unavailableCapabilities.replaceTransaction ? signTx : signTxLegacy;
351
- const cmd = device.getCommands();
352
- const response = await signTxMethod({
353
- typedCall: cmd.typedCall,
354
- inputs,
355
- outputs,
356
- refTxs,
357
- options,
358
- coinInfo
359
- });
360
- verifyTx(response.serializedTx, {
361
- inputs,
362
- outputs,
363
- outputScripts,
364
- network: coinInfo.network
365
- });
366
- if (params.push) {
367
- const blockchain = await this.getBlockchain(sendCoreMessage);
368
- const txid = await blockchain.pushTransaction(response.serializedTx);
369
- return {
370
- ...response,
371
- txid
372
- };
373
- }
374
- return response;
375
- }
376
- dispose() {
377
- const {
378
- discovery
379
- } = this;
380
- if (discovery) {
381
- discovery.stop();
382
- discovery.removeAllListeners();
383
- this.discovery = undefined;
384
- }
385
- }
386
- }
@@ -1,38 +0,0 @@
1
- import { type AccountTypeItem, type AdditionalParams, CARDANO_DERIVATIONS, type CoinInfo, type EntropyCheckResult, type FirmwareRange, type MethodPermission } from '@trezor/connect-common';
2
- import type { MethodContext, MethodMessage } from '../core/AbstractMethod';
3
- import { AbstractMethod } from '../core/AbstractMethod';
4
- type CardanoDerivation = (typeof CARDANO_DERIVATIONS)[keyof typeof CARDANO_DERIVATIONS];
5
- type Request = AdditionalParams & {
6
- account: AccountTypeItem;
7
- derivation?: CardanoDerivation;
8
- firmwareRange: FirmwareRange;
9
- coinInfo: CoinInfo;
10
- offset: number;
11
- skip: number;
12
- };
13
- type DiscoverAccountsLocalParams = {
14
- coins: Request[];
15
- entropyCheckResult?: EntropyCheckResult;
16
- };
17
- export declare const getTxsPerPage: (account: AccountTypeItem) => 8 | 25;
18
- export default class DiscoverAccounts extends AbstractMethod<'discoverAccounts', DiscoverAccountsLocalParams> {
19
- disposed: boolean;
20
- constructor(message: MethodMessage<'discoverAccounts'>);
21
- get requiredPermissions(): MethodPermission[];
22
- private progress;
23
- private updateProgress;
24
- private sendProgress;
25
- run({ sendCoreMessage }: MethodContext): Promise<{
26
- empty: number;
27
- nonempty: number;
28
- failed: number;
29
- }>;
30
- private filterUnsupportedAccounts;
31
- private filterCardanoDerivations;
32
- private readonly descriptorLock;
33
- private readonly descriptorCache;
34
- private getDescriptor;
35
- private discoverAccount;
36
- dispose(): void;
37
- }
38
- export {};