@trezor/connect 9.4.7 → 9.4.8-beta.1

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 (291) hide show
  1. package/CHANGELOG.md +55 -8
  2. package/README.md +1 -1
  3. package/lib/api/applyFlags.d.ts +1 -1
  4. package/lib/api/applyFlags.js +1 -1
  5. package/lib/api/applySettings.d.ts +1 -1
  6. package/lib/api/authenticateDevice.js +1 -1
  7. package/lib/api/authorizeCoinjoin.d.ts +1 -1
  8. package/lib/api/authorizeCoinjoin.js +1 -1
  9. package/lib/api/backupDevice.d.ts +1 -1
  10. package/lib/api/backupDevice.js +1 -1
  11. package/lib/api/binance/api/binanceGetAddress.d.ts +1 -1
  12. package/lib/api/binance/api/binanceGetAddress.js +3 -3
  13. package/lib/api/binance/api/binanceGetPublicKey.d.ts +1 -1
  14. package/lib/api/binance/api/binanceGetPublicKey.js +2 -2
  15. package/lib/api/binance/api/binanceSignTransaction.js +2 -2
  16. package/lib/api/binance/binanceSignTx.d.ts +1 -1
  17. package/lib/api/bitcoin/TransactionComposer.d.ts +1 -1
  18. package/lib/api/bitcoin/inputs.d.ts +1 -1
  19. package/lib/api/bitcoin/inputs.js +1 -1
  20. package/lib/api/bitcoin/outputs.js +2 -2
  21. package/lib/api/bitcoin/refTx.d.ts +2 -2
  22. package/lib/api/bitcoin/refTx.js +4 -4
  23. package/lib/api/bitcoin/signtx.d.ts +2 -2
  24. package/lib/api/bitcoin/signtxLegacy.d.ts +1 -1
  25. package/lib/api/bitcoin/signtxVerify.d.ts +1 -1
  26. package/lib/api/blockchainDisconnect.js +2 -2
  27. package/lib/api/blockchainEstimateFee.d.ts +1 -1
  28. package/lib/api/blockchainEstimateFee.js +3 -2
  29. package/lib/api/blockchainEvmRpcCall.js +2 -2
  30. package/lib/api/blockchainGetAccountBalanceHistory.d.ts +1 -1
  31. package/lib/api/blockchainGetAccountBalanceHistory.js +1 -1
  32. package/lib/api/blockchainGetCurrentFiatRates.d.ts +1 -1
  33. package/lib/api/blockchainGetCurrentFiatRates.js +1 -1
  34. package/lib/api/blockchainGetFiatRatesForTimestamps.d.ts +1 -1
  35. package/lib/api/blockchainGetFiatRatesForTimestamps.js +1 -1
  36. package/lib/api/blockchainGetInfo.js +1 -1
  37. package/lib/api/blockchainGetTransactions.js +1 -1
  38. package/lib/api/blockchainSetCustomBackend.js +1 -1
  39. package/lib/api/blockchainSubscribe.d.ts +1 -1
  40. package/lib/api/blockchainSubscribe.js +1 -1
  41. package/lib/api/blockchainSubscribeFiatRates.d.ts +1 -1
  42. package/lib/api/blockchainSubscribeFiatRates.js +1 -1
  43. package/lib/api/blockchainUnsubscribe.d.ts +1 -1
  44. package/lib/api/blockchainUnsubscribe.js +1 -1
  45. package/lib/api/blockchainUnsubscribeFiatRates.js +1 -1
  46. package/lib/api/cancelCoinjoinAuthorization.d.ts +1 -1
  47. package/lib/api/cardano/api/cardanoComposeTransaction.d.ts +1 -1
  48. package/lib/api/cardano/api/cardanoComposeTransaction.js +3 -11
  49. package/lib/api/cardano/api/cardanoGetAddress.d.ts +1 -1
  50. package/lib/api/cardano/api/cardanoGetAddress.js +4 -4
  51. package/lib/api/cardano/api/cardanoGetNativeScriptHash.js +2 -2
  52. package/lib/api/cardano/api/cardanoGetPublicKey.js +2 -2
  53. package/lib/api/cardano/api/cardanoSignTransaction.d.ts +3 -3
  54. package/lib/api/cardano/api/cardanoSignTransaction.js +4 -4
  55. package/lib/api/cardano/cardanoAddressParameters.js +1 -1
  56. package/lib/api/cardano/cardanoAuxiliaryData.js +1 -1
  57. package/lib/api/cardano/cardanoCertificate.js +1 -1
  58. package/lib/api/cardano/cardanoInputs.js +1 -1
  59. package/lib/api/cardano/cardanoUtils.js +30 -0
  60. package/lib/api/changePin.d.ts +1 -1
  61. package/lib/api/changePin.js +1 -1
  62. package/lib/api/changeWipeCode.d.ts +1 -1
  63. package/lib/api/cipherKeyValue.d.ts +1 -1
  64. package/lib/api/cipherKeyValue.js +3 -3
  65. package/lib/api/common/Discovery.d.ts +2 -2
  66. package/lib/api/common/paramsValidator.js +1 -1
  67. package/lib/api/composeTransaction.d.ts +3 -3
  68. package/lib/api/composeTransaction.js +9 -9
  69. package/lib/api/eos/api/eosGetPublicKey.d.ts +1 -1
  70. package/lib/api/eos/api/eosGetPublicKey.js +2 -2
  71. package/lib/api/eos/api/eosSignTransaction.d.ts +1 -1
  72. package/lib/api/eos/api/eosSignTransaction.js +2 -2
  73. package/lib/api/eos/eosSignTx.d.ts +3 -3
  74. package/lib/api/ethereum/api/ethereumGetAddress.d.ts +3 -3
  75. package/lib/api/ethereum/api/ethereumGetAddress.js +6 -6
  76. package/lib/api/ethereum/api/ethereumGetPublicKey.d.ts +1 -1
  77. package/lib/api/ethereum/api/ethereumGetPublicKey.js +3 -3
  78. package/lib/api/ethereum/api/ethereumSignMessage.d.ts +1 -1
  79. package/lib/api/ethereum/api/ethereumSignMessage.js +3 -3
  80. package/lib/api/ethereum/api/ethereumSignTransaction.d.ts +2 -2
  81. package/lib/api/ethereum/api/ethereumSignTransaction.js +4 -4
  82. package/lib/api/ethereum/api/ethereumSignTypedData.d.ts +2 -1
  83. package/lib/api/ethereum/api/ethereumSignTypedData.js +6 -6
  84. package/lib/api/ethereum/api/ethereumVerifyMessage.d.ts +1 -1
  85. package/lib/api/ethereum/api/ethereumVerifyMessage.js +2 -2
  86. package/lib/api/ethereum/ethereumDefinitions.d.ts +2 -2
  87. package/lib/api/ethereum/ethereumDefinitions.js +1 -0
  88. package/lib/api/firmware/getBinaryForFirmwareUpgrade.js +2 -2
  89. package/lib/api/firmware/parseFirmwareHeaders.d.ts +2 -1
  90. package/lib/api/firmware/uploadFirmware.d.ts +1 -1
  91. package/lib/api/firmware/uploadFirmware.js +1 -1
  92. package/lib/api/firmware/verifyAuthenticityProof.d.ts +1 -1
  93. package/lib/api/firmware/verifyEntropy.d.ts +19 -0
  94. package/lib/api/firmware/verifyEntropy.js +112 -0
  95. package/lib/api/getAccountDescriptor.js +4 -4
  96. package/lib/api/getAccountInfo.d.ts +21 -1
  97. package/lib/api/getAccountInfo.js +7 -7
  98. package/lib/api/getAddress.d.ts +1 -1
  99. package/lib/api/getAddress.js +3 -3
  100. package/lib/api/getCoinInfo.d.ts +3 -0
  101. package/lib/api/getCoinInfo.js +1 -1
  102. package/lib/api/getDeviceState.js +1 -1
  103. package/lib/api/getFirmwareHash.d.ts +1 -1
  104. package/lib/api/getFirmwareHash.js +1 -1
  105. package/lib/api/getOwnershipId.d.ts +1 -1
  106. package/lib/api/getOwnershipId.js +2 -2
  107. package/lib/api/getOwnershipProof.d.ts +1 -1
  108. package/lib/api/getOwnershipProof.js +2 -2
  109. package/lib/api/getPublicKey.d.ts +1 -1
  110. package/lib/api/getPublicKey.js +4 -4
  111. package/lib/api/loadDevice.d.ts +1 -1
  112. package/lib/api/loadDevice.js +1 -1
  113. package/lib/api/nem/api/nemGetAddress.d.ts +1 -1
  114. package/lib/api/nem/api/nemGetAddress.js +3 -3
  115. package/lib/api/nem/api/nemSignTransaction.d.ts +1 -1
  116. package/lib/api/nem/api/nemSignTransaction.js +2 -2
  117. package/lib/api/pushTransaction.js +2 -2
  118. package/lib/api/recoveryDevice.d.ts +1 -1
  119. package/lib/api/requestLogin.d.ts +1 -1
  120. package/lib/api/requestLogin.js +2 -2
  121. package/lib/api/resetDevice.d.ts +3 -1
  122. package/lib/api/resetDevice.js +58 -3
  123. package/lib/api/ripple/api/rippleGetAddress.d.ts +1 -1
  124. package/lib/api/ripple/api/rippleGetAddress.js +3 -3
  125. package/lib/api/ripple/api/rippleSignTransaction.d.ts +1 -1
  126. package/lib/api/ripple/api/rippleSignTransaction.js +2 -2
  127. package/lib/api/setBrightness.d.ts +1 -1
  128. package/lib/api/setBrightness.js +1 -1
  129. package/lib/api/setBusy.d.ts +1 -1
  130. package/lib/api/setBusy.js +1 -1
  131. package/lib/api/setProxy.js +1 -1
  132. package/lib/api/showDeviceTutorial.d.ts +1 -1
  133. package/lib/api/showDeviceTutorial.js +1 -1
  134. package/lib/api/signMessage.d.ts +1 -1
  135. package/lib/api/signMessage.js +2 -2
  136. package/lib/api/signTransaction.d.ts +2 -2
  137. package/lib/api/signTransaction.js +3 -3
  138. package/lib/api/solana/api/index.d.ts +1 -0
  139. package/lib/api/solana/api/index.js +3 -1
  140. package/lib/api/solana/api/solanaComposeTransaction.d.ts +25 -0
  141. package/lib/api/solana/api/solanaComposeTransaction.js +61 -0
  142. package/lib/api/solana/api/solanaGetAddress.js +2 -2
  143. package/lib/api/solana/api/solanaGetPublicKey.js +2 -2
  144. package/lib/api/solana/api/solanaSignTransaction.d.ts +9 -1
  145. package/lib/api/solana/api/solanaSignTransaction.js +20 -2
  146. package/lib/api/solana/solanaUtils.d.ts +48 -0
  147. package/lib/api/solana/solanaUtils.js +213 -0
  148. package/lib/api/stellar/api/stellarGetAddress.d.ts +1 -1
  149. package/lib/api/stellar/api/stellarGetAddress.js +3 -3
  150. package/lib/api/stellar/api/stellarSignTransaction.js +3 -3
  151. package/lib/api/tezos/api/tezosGetAddress.d.ts +1 -1
  152. package/lib/api/tezos/api/tezosGetAddress.js +3 -3
  153. package/lib/api/tezos/api/tezosGetPublicKey.d.ts +1 -1
  154. package/lib/api/tezos/api/tezosGetPublicKey.js +2 -2
  155. package/lib/api/tezos/api/tezosSignTransaction.d.ts +1 -1
  156. package/lib/api/tezos/api/tezosSignTransaction.js +2 -2
  157. package/lib/api/tezos/tezosSignTx.d.ts +17 -17
  158. package/lib/api/unlockPath.d.ts +1 -1
  159. package/lib/api/verifyMessage.d.ts +1 -1
  160. package/lib/api/verifyMessage.js +3 -3
  161. package/lib/backend/BackendManager.d.ts +1 -1
  162. package/lib/backend/BackendManager.js +1 -1
  163. package/lib/backend/Blockchain.d.ts +2 -2
  164. package/lib/backend/Blockchain.js +4 -7
  165. package/lib/constants/errors.d.ts +2 -0
  166. package/lib/constants/errors.js +4 -0
  167. package/lib/core/AbstractMethod.d.ts +2 -2
  168. package/lib/core/AbstractMethod.js +2 -1
  169. package/lib/core/index.d.ts +3 -3
  170. package/lib/core/index.js +44 -48
  171. package/lib/core/onCallFirmwareUpdate.d.ts +3 -8
  172. package/lib/core/onCallFirmwareUpdate.js +63 -21
  173. package/lib/data/DataManager.js +1 -5
  174. package/lib/data/coinInfo.d.ts +15 -131
  175. package/lib/data/coinInfo.js +8 -8
  176. package/lib/data/config.d.ts +23 -0
  177. package/lib/data/config.js +4 -0
  178. package/lib/data/connectSettings.js +1 -1
  179. package/lib/data/defaultFeeLevels.d.ts +2 -2
  180. package/lib/data/defaultFeeLevels.js +34 -14
  181. package/lib/data/deviceAuthenticityConfigTypes.d.ts +1 -0
  182. package/lib/data/deviceAuthenticityConfigTypes.js +2 -2
  183. package/lib/data/firmwareInfo.js +1 -1
  184. package/lib/data/models.js +5 -1
  185. package/lib/data/transportInfo.d.ts +0 -1
  186. package/lib/data/transportInfo.js +41 -28
  187. package/lib/data/udevInfo.d.ts +0 -1
  188. package/lib/data/udevInfo.js +2 -5
  189. package/lib/data/version.d.ts +1 -1
  190. package/lib/data/version.js +1 -1
  191. package/lib/device/Device.d.ts +11 -10
  192. package/lib/device/Device.js +39 -17
  193. package/lib/device/DeviceCommands.d.ts +2 -2
  194. package/lib/device/DeviceCommands.js +42 -27
  195. package/lib/device/DeviceList.d.ts +27 -22
  196. package/lib/device/DeviceList.js +222 -133
  197. package/lib/device/StateStorage.js +11 -13
  198. package/lib/device/prompts.js +28 -36
  199. package/lib/device/resolveDescriptorForTaproot.d.ts +2 -2
  200. package/lib/device/resolveDescriptorForTaproot.js +5 -13
  201. package/lib/events/blockchain.d.ts +1 -1
  202. package/lib/events/call.d.ts +1 -1
  203. package/lib/events/core.d.ts +3 -3
  204. package/lib/events/device.d.ts +11 -1
  205. package/lib/events/device.js +1 -0
  206. package/lib/events/popup.d.ts +2 -2
  207. package/lib/events/transport.d.ts +15 -9
  208. package/lib/events/transport.js +10 -1
  209. package/lib/events/ui-promise.d.ts +1 -1
  210. package/lib/events/ui-request.d.ts +3 -3
  211. package/lib/factory.d.ts +3 -2
  212. package/lib/factory.js +3 -1
  213. package/lib/impl/core-in-module.d.ts +4 -2
  214. package/lib/impl/core-in-module.js +9 -1
  215. package/lib/impl/dynamic.d.ts +4 -2
  216. package/lib/impl/dynamic.js +5 -4
  217. package/lib/index-browser.js +1 -0
  218. package/lib/index.js +11 -3
  219. package/lib/types/account.d.ts +1 -1
  220. package/lib/types/api/authenticateDevice.d.ts +1 -0
  221. package/lib/types/api/authorizeCoinjoin.d.ts +1 -1
  222. package/lib/types/api/authorizeCoinjoin.js +1 -1
  223. package/lib/types/api/binanceGetAddress.d.ts +1 -1
  224. package/lib/types/api/binanceGetPublicKey.d.ts +1 -1
  225. package/lib/types/api/blockchainEstimateFee.d.ts +1 -1
  226. package/lib/types/api/blockchainSetCustomBackend.d.ts +1 -1
  227. package/lib/types/api/blockchainSubscribe.d.ts +1 -1
  228. package/lib/types/api/cardanoComposeTransaction.d.ts +112 -6
  229. package/lib/types/api/cardanoComposeTransaction.js +77 -0
  230. package/lib/types/api/cardanoGetAddress.d.ts +1 -1
  231. package/lib/types/api/cardanoGetPublicKey.d.ts +1 -1
  232. package/lib/types/api/changeLanguage.d.ts +1 -1
  233. package/lib/types/api/cipherKeyValue.d.ts +1 -1
  234. package/lib/types/api/composeTransaction.d.ts +1 -1
  235. package/lib/types/api/eosGetPublicKey.d.ts +1 -1
  236. package/lib/types/api/ethereumGetAddress.d.ts +1 -1
  237. package/lib/types/api/ethereumGetPublicKey.d.ts +1 -1
  238. package/lib/types/api/ethereumSignTypedData.d.ts +1 -1
  239. package/lib/types/api/firmwareUpdate.d.ts +11 -2
  240. package/lib/types/api/getAccountDescriptor.d.ts +1 -1
  241. package/lib/types/api/getAccountInfo.d.ts +1 -1
  242. package/lib/types/api/getAddress.d.ts +2 -1
  243. package/lib/types/api/getCoinInfo.d.ts +1 -1
  244. package/lib/types/api/getDeviceState.d.ts +1 -1
  245. package/lib/types/api/getFeatures.d.ts +1 -1
  246. package/lib/types/api/getOwnershipId.d.ts +2 -1
  247. package/lib/types/api/getOwnershipProof.d.ts +2 -1
  248. package/lib/types/api/getPublicKey.d.ts +1 -1
  249. package/lib/types/api/index.d.ts +7 -3
  250. package/lib/types/api/nem/index.d.ts +1 -1
  251. package/lib/types/api/nemGetAddress.d.ts +1 -1
  252. package/lib/types/api/on.d.ts +1 -1
  253. package/lib/types/api/recoveryDevice.d.ts +1 -1
  254. package/lib/types/api/rippleGetAddress.d.ts +1 -1
  255. package/lib/types/api/setTransports.d.ts +4 -0
  256. package/lib/types/api/setTransports.js +3 -0
  257. package/lib/types/api/solana/index.d.ts +41 -0
  258. package/lib/types/api/solana/index.js +31 -1
  259. package/lib/types/api/solanaComposeTransaction.d.ts +4 -0
  260. package/lib/types/api/solanaComposeTransaction.js +3 -0
  261. package/lib/types/api/solanaGetAddress.d.ts +1 -1
  262. package/lib/types/api/solanaGetPublicKey.d.ts +1 -1
  263. package/lib/types/api/stellarGetAddress.d.ts +1 -1
  264. package/lib/types/api/tezosGetAddress.d.ts +1 -1
  265. package/lib/types/api/tezosGetPublicKey.d.ts +1 -1
  266. package/lib/types/api/unlockPath.d.ts +1 -1
  267. package/lib/types/coinInfo.d.ts +33 -0
  268. package/lib/types/coinInfo.js +8 -2
  269. package/lib/types/params.d.ts +1 -1
  270. package/lib/utils/abortablePromise.d.ts +5 -0
  271. package/lib/utils/abortablePromise.js +17 -0
  272. package/lib/utils/accountUtils.d.ts +1 -1
  273. package/lib/utils/accountUtils.js +1 -1
  274. package/lib/utils/assetUtils.js +1 -2
  275. package/lib/utils/assets-browser.d.ts +1 -1
  276. package/lib/utils/assets.js +1 -1
  277. package/lib/utils/assets.native.d.ts +1 -1
  278. package/lib/utils/deviceFeaturesUtils.d.ts +1 -1
  279. package/lib/utils/deviceFeaturesUtils.js +6 -12
  280. package/lib/utils/ethereumUtils.d.ts +3 -2
  281. package/lib/utils/firmwareUtils.d.ts +1 -1
  282. package/lib/utils/firmwareUtils.js +11 -4
  283. package/lib/utils/pathUtils.d.ts +1 -1
  284. package/lib/utils/urlUtils.js +2 -0
  285. package/lib/workers/workers-browser.d.ts +2 -2
  286. package/lib/workers/workers-browser.js +2 -2
  287. package/lib/workers/workers.native.d.ts +1 -1
  288. package/lib/workers/workers.native.js +2 -2
  289. package/package.json +22 -12
  290. package/lib/utils/promiseUtils.d.ts +0 -5
  291. package/lib/utils/promiseUtils.js +0 -14
@@ -0,0 +1,213 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.fetchAccountOwnerAndTokenInfoForAddress = exports.buildTokenTransferTransaction = exports.getMinimumRequiredTokenAccountsForTransfer = exports.buildCreateAssociatedTokenAccountInstruction = exports.getAssociatedTokenAccountAddress = exports.buildTokenTransferInstruction = exports.buildTransferTransaction = exports.dummyPriorityFeesForFeeEstimation = exports.getLamportsFromSol = void 0;
27
+ exports.createTransactionShim = createTransactionShim;
28
+ exports.createTransactionShimFromHex = createTransactionShimFromHex;
29
+ const ts_belt_1 = require("@mobily/ts-belt");
30
+ const blockchain_link_utils_1 = require("@trezor/blockchain-link-utils");
31
+ const bigNumber_1 = require("@trezor/utils/lib/bigNumber");
32
+ const { SYSTEM_PROGRAM_PUBLIC_KEY, tokenProgramsInfo } = blockchain_link_utils_1.solanaUtils;
33
+ const loadSolanaLib = async () => await Promise.resolve().then(() => __importStar(require('@solana/web3.js')));
34
+ const loadSolanaComputeBudgetProgramLib = async () => await Promise.resolve().then(() => __importStar(require('@solana-program/compute-budget')));
35
+ const loadSolanaSystemProgramLib = async () => await Promise.resolve().then(() => __importStar(require('@solana-program/system')));
36
+ const loadSolanaTokenProgramLib = async (tokenProgramName) => {
37
+ switch (tokenProgramName) {
38
+ case 'spl-token':
39
+ return await Promise.resolve().then(() => __importStar(require('@solana-program/token')));
40
+ case 'spl-token-2022':
41
+ return await Promise.resolve().then(() => __importStar(require('@solana-program/token-2022')));
42
+ default:
43
+ throw new Error(`Unsupported token program: ${tokenProgramName}`);
44
+ }
45
+ };
46
+ const getLamportsFromSol = (amountInSol) => BigInt(new bigNumber_1.BigNumber(amountInSol).times(10 ** 9).toString());
47
+ exports.getLamportsFromSol = getLamportsFromSol;
48
+ exports.dummyPriorityFeesForFeeEstimation = {
49
+ computeUnitPrice: '100000',
50
+ computeUnitLimit: '200000',
51
+ };
52
+ async function createTransactionShimCommon(transaction) {
53
+ const { getBase16Codec, getTransactionEncoder } = await loadSolanaLib();
54
+ return {
55
+ addSignature(signerPubKey, signatureHex) {
56
+ if (signerPubKey in transaction.signatures) {
57
+ const signatureBytes = getBase16Codec().encode(signatureHex);
58
+ transaction = Object.freeze({
59
+ ...transaction,
60
+ signatures: Object.freeze({
61
+ ...transaction.signatures,
62
+ [signerPubKey]: signatureBytes,
63
+ }),
64
+ });
65
+ }
66
+ },
67
+ serializeMessage() {
68
+ return getBase16Codec().decode(transaction.messageBytes);
69
+ },
70
+ serialize() {
71
+ return (0, ts_belt_1.pipe)(transaction, getTransactionEncoder().encode, getBase16Codec().decode);
72
+ },
73
+ };
74
+ }
75
+ async function createTransactionShim(message) {
76
+ const { compileTransaction } = await loadSolanaLib();
77
+ const transaction = compileTransaction(message);
78
+ return createTransactionShimCommon(transaction);
79
+ }
80
+ async function createTransactionShimFromHex(rawTx) {
81
+ const { getBase16Encoder, getTransactionDecoder } = await loadSolanaLib();
82
+ const txByteArray = getBase16Encoder().encode(rawTx);
83
+ const transaction = getTransactionDecoder().decode(txByteArray);
84
+ return createTransactionShimCommon(transaction);
85
+ }
86
+ const addPriorityFees = async (message, priorityFees) => {
87
+ const [{ prependTransactionMessageInstructions }, { getSetComputeUnitLimitInstruction, getSetComputeUnitPriceInstruction },] = await Promise.all([loadSolanaLib(), loadSolanaComputeBudgetProgramLib()]);
88
+ return (0, ts_belt_1.pipe)(message, m => prependTransactionMessageInstructions([
89
+ getSetComputeUnitLimitInstruction({
90
+ units: parseInt(priorityFees.computeUnitLimit, 10),
91
+ }),
92
+ getSetComputeUnitPriceInstruction({
93
+ microLamports: parseInt(priorityFees.computeUnitPrice, 10),
94
+ }),
95
+ ], m));
96
+ };
97
+ const buildTransferTransaction = async (fromAddress, toAddress, amountInSol, blockhash, lastValidBlockHeight, priorityFees) => {
98
+ const [{ address, appendTransactionMessageInstruction, createTransactionMessage, lamports, setTransactionMessageLifetimeUsingBlockhash, setTransactionMessageFeePayer, createNoopSigner, }, { getTransferSolInstruction },] = await Promise.all([loadSolanaLib(), loadSolanaSystemProgramLib()]);
99
+ const message = await (0, ts_belt_1.pipe)(createTransactionMessage({ version: 'legacy' }), m => setTransactionMessageFeePayer(address(fromAddress), m), m => setTransactionMessageLifetimeUsingBlockhash({
100
+ blockhash: blockhash,
101
+ lastValidBlockHeight: BigInt(lastValidBlockHeight !== null && lastValidBlockHeight !== void 0 ? lastValidBlockHeight : '0xFFFFFFFFFFFFFFFF'),
102
+ }, m), m => appendTransactionMessageInstruction(getTransferSolInstruction({
103
+ amount: lamports((0, exports.getLamportsFromSol)(amountInSol)),
104
+ destination: address(toAddress),
105
+ source: createNoopSigner(address(fromAddress)),
106
+ }), m), m => addPriorityFees(m, priorityFees));
107
+ return await createTransactionShim(message);
108
+ };
109
+ exports.buildTransferTransaction = buildTransferTransaction;
110
+ const buildTokenTransferInstruction = async (from, to, owner, amount, mint, decimals, tokenProgramName) => {
111
+ const [{ address, createNoopSigner }, { getTransferCheckedInstruction },] = await Promise.all([loadSolanaLib(), loadSolanaTokenProgramLib(tokenProgramName)]);
112
+ return getTransferCheckedInstruction({
113
+ amount: BigInt(amount.toString()),
114
+ authority: createNoopSigner(address(owner)),
115
+ decimals,
116
+ destination: address(to),
117
+ mint: address(mint),
118
+ source: address(from),
119
+ });
120
+ };
121
+ exports.buildTokenTransferInstruction = buildTokenTransferInstruction;
122
+ const getAssociatedTokenAccountAddress = async (baseAddress, tokenMintAddress, tokenProgramName) => {
123
+ const [{ address }, { findAssociatedTokenPda },] = await Promise.all([loadSolanaLib(), loadSolanaTokenProgramLib(tokenProgramName)]);
124
+ const [pdaAddress] = await findAssociatedTokenPda({
125
+ mint: address(tokenMintAddress),
126
+ owner: address(baseAddress),
127
+ tokenProgram: address(tokenProgramsInfo[tokenProgramName].publicKey),
128
+ });
129
+ return pdaAddress;
130
+ };
131
+ exports.getAssociatedTokenAccountAddress = getAssociatedTokenAccountAddress;
132
+ const buildCreateAssociatedTokenAccountInstruction = async (funderAddress, newOwnerAddress, tokenMintAddress, tokenProgramName) => {
133
+ const [{ address, createNoopSigner }, { getCreateAssociatedTokenInstruction },] = await Promise.all([loadSolanaLib(), loadSolanaTokenProgramLib(tokenProgramName)]);
134
+ const associatedTokenAccountAddress = await (0, exports.getAssociatedTokenAccountAddress)(newOwnerAddress, tokenMintAddress, tokenProgramName);
135
+ const txInstruction = getCreateAssociatedTokenInstruction({
136
+ ata: associatedTokenAccountAddress,
137
+ mint: address(tokenMintAddress),
138
+ owner: address(newOwnerAddress),
139
+ payer: createNoopSigner(address(funderAddress)),
140
+ });
141
+ txInstruction.data = new Uint8Array([]);
142
+ return [txInstruction, associatedTokenAccountAddress];
143
+ };
144
+ exports.buildCreateAssociatedTokenAccountInstruction = buildCreateAssociatedTokenAccountInstruction;
145
+ const getMinimumRequiredTokenAccountsForTransfer = (tokenAccounts, requiredAmount) => {
146
+ let accumulatedBalance = new bigNumber_1.BigNumber('0');
147
+ const requiredAccounts = ts_belt_1.F.toMutable((0, ts_belt_1.pipe)(tokenAccounts, ts_belt_1.A.sort((a, b) => new bigNumber_1.BigNumber(b.balance).comparedTo(new bigNumber_1.BigNumber(a.balance))), ts_belt_1.A.takeWhile(tokenAccount => {
148
+ const needMoreAccounts = accumulatedBalance.lt(requiredAmount);
149
+ accumulatedBalance = accumulatedBalance.plus(tokenAccount.balance);
150
+ return needMoreAccounts;
151
+ })));
152
+ return requiredAccounts;
153
+ };
154
+ exports.getMinimumRequiredTokenAccountsForTransfer = getMinimumRequiredTokenAccountsForTransfer;
155
+ const buildTokenTransferTransaction = async (fromAddress, toAddress, toAddressOwner, tokenMint, tokenUiAmount, tokenDecimals, fromTokenAccounts, toTokenAccount, blockhash, lastValidBlockHeight, priorityFees, tokenProgramName) => {
156
+ const { address, appendTransactionMessageInstruction, appendTransactionMessageInstructions, createTransactionMessage, setTransactionMessageFeePayer, setTransactionMessageLifetimeUsingBlockhash, } = await loadSolanaLib();
157
+ let message = await (0, ts_belt_1.pipe)(createTransactionMessage({ version: 'legacy' }), m => setTransactionMessageFeePayer(address(fromAddress), m), m => setTransactionMessageLifetimeUsingBlockhash({
158
+ blockhash: blockhash,
159
+ lastValidBlockHeight: BigInt(lastValidBlockHeight !== null && lastValidBlockHeight !== void 0 ? lastValidBlockHeight : '0xFFFFFFFFFFFFFFFF'),
160
+ }, m), m => addPriorityFees(m, priorityFees));
161
+ const tokenAmount = new bigNumber_1.BigNumber(tokenUiAmount).times(10 ** tokenDecimals);
162
+ const requiredAccounts = (0, exports.getMinimumRequiredTokenAccountsForTransfer)(fromTokenAccounts, tokenAmount.toString());
163
+ const isReceiverAddressSystemAccount = toAddressOwner === SYSTEM_PROGRAM_PUBLIC_KEY;
164
+ let finalReceiverAddress = toAddress;
165
+ if (isReceiverAddressSystemAccount) {
166
+ if (toTokenAccount) {
167
+ finalReceiverAddress = toTokenAccount.publicKey;
168
+ }
169
+ else {
170
+ const [createAccountInstruction, associatedTokenAccountAddress] = await (0, exports.buildCreateAssociatedTokenAccountInstruction)(fromAddress, toAddress, tokenMint, tokenProgramName);
171
+ message = appendTransactionMessageInstruction(createAccountInstruction, message);
172
+ finalReceiverAddress = associatedTokenAccountAddress;
173
+ }
174
+ }
175
+ let remainingAmount = tokenAmount;
176
+ const instructionPromises = requiredAccounts.map(async (tokenAccount) => {
177
+ const transferAmount = bigNumber_1.BigNumber.min(remainingAmount, new bigNumber_1.BigNumber(tokenAccount.balance));
178
+ const transferInstruction = await (0, exports.buildTokenTransferInstruction)(tokenAccount.publicKey, finalReceiverAddress, fromAddress, transferAmount, tokenMint, tokenDecimals, tokenProgramName);
179
+ remainingAmount = remainingAmount.minus(transferAmount);
180
+ return transferInstruction;
181
+ });
182
+ message = appendTransactionMessageInstructions(await Promise.all(instructionPromises), message);
183
+ return {
184
+ transaction: await createTransactionShim(message),
185
+ destinationAddress: finalReceiverAddress,
186
+ tokenAccountInfo: isReceiverAddressSystemAccount
187
+ ? {
188
+ baseAddress: toAddress,
189
+ tokenProgram: tokenProgramsInfo[tokenProgramName].publicKey,
190
+ tokenMint,
191
+ tokenAccount: finalReceiverAddress,
192
+ }
193
+ : undefined,
194
+ };
195
+ };
196
+ exports.buildTokenTransferTransaction = buildTokenTransferTransaction;
197
+ const fetchAccountOwnerAndTokenInfoForAddress = async (blockchain, address, mint, tokenProgram) => {
198
+ var _a, _b, _c, _d;
199
+ let accountOwner;
200
+ let tokenInfo;
201
+ const accountInfoResponse = await blockchain.getAccountInfo({
202
+ descriptor: address,
203
+ details: 'tokens',
204
+ });
205
+ if (accountInfoResponse) {
206
+ const associatedTokenAccount = await (0, exports.getAssociatedTokenAccountAddress)(address, mint, tokenProgram);
207
+ accountOwner = (_a = accountInfoResponse === null || accountInfoResponse === void 0 ? void 0 : accountInfoResponse.misc) === null || _a === void 0 ? void 0 : _a.owner;
208
+ tokenInfo = (_d = (_c = (_b = accountInfoResponse === null || accountInfoResponse === void 0 ? void 0 : accountInfoResponse.tokens) === null || _b === void 0 ? void 0 : _b.find(token => token.contract === mint)) === null || _c === void 0 ? void 0 : _c.accounts) === null || _d === void 0 ? void 0 : _d.find(account => associatedTokenAccount.toString() === account.publicKey);
209
+ }
210
+ return [accountOwner, tokenInfo];
211
+ };
212
+ exports.fetchAccountOwnerAndTokenInfoForAddress = fetchAccountOwnerAndTokenInfoForAddress;
213
+ //# sourceMappingURL=solanaUtils.js.map
@@ -1,5 +1,5 @@
1
- import { AbstractMethod } from '../../../core/AbstractMethod';
2
1
  import { PROTO } from '../../../constants';
2
+ import { AbstractMethod } from '../../../core/AbstractMethod';
3
3
  type Params = PROTO.StellarGetAddress & {
4
4
  address?: string;
5
5
  };
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const schema_utils_1 = require("@trezor/schema-utils");
4
+ const constants_1 = require("../../../constants");
4
5
  const AbstractMethod_1 = require("../../../core/AbstractMethod");
5
- const paramsValidator_1 = require("../../common/paramsValidator");
6
6
  const coinInfo_1 = require("../../../data/coinInfo");
7
- const pathUtils_1 = require("../../../utils/pathUtils");
8
- const constants_1 = require("../../../constants");
9
7
  const events_1 = require("../../../events");
10
8
  const types_1 = require("../../../types");
11
9
  const getAddress_1 = require("../../../types/api/getAddress");
10
+ const pathUtils_1 = require("../../../utils/pathUtils");
11
+ const paramsValidator_1 = require("../../common/paramsValidator");
12
12
  class StellarGetAddress extends AbstractMethod_1.AbstractMethod {
13
13
  constructor() {
14
14
  super(...arguments);
@@ -2,13 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const schema_utils_1 = require("@trezor/schema-utils");
5
+ const constants_1 = require("../../../constants");
5
6
  const AbstractMethod_1 = require("../../../core/AbstractMethod");
6
- const paramsValidator_1 = require("../../common/paramsValidator");
7
7
  const coinInfo_1 = require("../../../data/coinInfo");
8
+ const stellar_1 = require("../../../types/api/stellar");
8
9
  const pathUtils_1 = require("../../../utils/pathUtils");
10
+ const paramsValidator_1 = require("../../common/paramsValidator");
9
11
  const helper = tslib_1.__importStar(require("../stellarSignTx"));
10
- const constants_1 = require("../../../constants");
11
- const stellar_1 = require("../../../types/api/stellar");
12
12
  const StellarSignTransactionFeatures = Object.freeze({
13
13
  manageBuyOffer: ['1.10.4', '2.4.3'],
14
14
  pathPaymentStrictSend: ['1.10.4', '2.4.3'],
@@ -1,5 +1,5 @@
1
- import { AbstractMethod } from '../../../core/AbstractMethod';
2
1
  import { PROTO } from '../../../constants';
2
+ import { AbstractMethod } from '../../../core/AbstractMethod';
3
3
  type Params = PROTO.TezosGetAddress & {
4
4
  address?: string;
5
5
  };
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const schema_utils_1 = require("@trezor/schema-utils");
4
+ const constants_1 = require("../../../constants");
4
5
  const AbstractMethod_1 = require("../../../core/AbstractMethod");
5
- const paramsValidator_1 = require("../../common/paramsValidator");
6
6
  const coinInfo_1 = require("../../../data/coinInfo");
7
- const pathUtils_1 = require("../../../utils/pathUtils");
8
- const constants_1 = require("../../../constants");
9
7
  const events_1 = require("../../../events");
10
8
  const types_1 = require("../../../types");
11
9
  const getAddress_1 = require("../../../types/api/getAddress");
10
+ const pathUtils_1 = require("../../../utils/pathUtils");
11
+ const paramsValidator_1 = require("../../common/paramsValidator");
12
12
  class TezosGetAddress extends AbstractMethod_1.AbstractMethod {
13
13
  constructor() {
14
14
  super(...arguments);
@@ -1,5 +1,5 @@
1
- import { AbstractMethod } from '../../../core/AbstractMethod';
2
1
  import type { PROTO } from '../../../constants';
2
+ import { AbstractMethod } from '../../../core/AbstractMethod';
3
3
  export default class TezosGetPublicKey extends AbstractMethod<'tezosGetPublicKey', PROTO.TezosGetPublicKey[]> {
4
4
  hasBundle?: boolean;
5
5
  init(): void;
@@ -2,11 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const schema_utils_1 = require("@trezor/schema-utils");
4
4
  const AbstractMethod_1 = require("../../../core/AbstractMethod");
5
- const paramsValidator_1 = require("../../common/paramsValidator");
6
5
  const coinInfo_1 = require("../../../data/coinInfo");
7
- const pathUtils_1 = require("../../../utils/pathUtils");
8
6
  const events_1 = require("../../../events");
9
7
  const types_1 = require("../../../types");
8
+ const pathUtils_1 = require("../../../utils/pathUtils");
9
+ const paramsValidator_1 = require("../../common/paramsValidator");
10
10
  class TezosGetPublicKey extends AbstractMethod_1.AbstractMethod {
11
11
  init() {
12
12
  this.requiredPermissions = ['read'];
@@ -1,5 +1,5 @@
1
- import { AbstractMethod } from '../../../core/AbstractMethod';
2
1
  import type { PROTO } from '../../../constants';
2
+ import { AbstractMethod } from '../../../core/AbstractMethod';
3
3
  export default class TezosSignTransaction extends AbstractMethod<'tezosSignTransaction', PROTO.TezosSignTx> {
4
4
  init(): void;
5
5
  get info(): string;
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const schema_utils_1 = require("@trezor/schema-utils");
5
5
  const AbstractMethod_1 = require("../../../core/AbstractMethod");
6
- const paramsValidator_1 = require("../../common/paramsValidator");
7
6
  const coinInfo_1 = require("../../../data/coinInfo");
7
+ const tezos_1 = require("../../../types/api/tezos");
8
8
  const pathUtils_1 = require("../../../utils/pathUtils");
9
+ const paramsValidator_1 = require("../../common/paramsValidator");
9
10
  const helper = tslib_1.__importStar(require("../tezosSignTx"));
10
- const tezos_1 = require("../../../types/api/tezos");
11
11
  class TezosSignTransaction extends AbstractMethod_1.AbstractMethod {
12
12
  init() {
13
13
  this.requiredPermissions = ['read', 'write'];
@@ -18,31 +18,20 @@ export declare const createTx: (address_n: number[], branch: string, operation:
18
18
  source: Uint8Array;
19
19
  amount: string | number;
20
20
  fee: string | number;
21
- gas_limit: number;
22
21
  destination: {
23
22
  hash: Uint8Array;
24
23
  tag: number;
25
24
  };
26
25
  counter: number;
26
+ gas_limit: number;
27
27
  storage_limit: number;
28
28
  } | undefined;
29
- proposal?: {
30
- source: string;
31
- period: number;
32
- proposals: string[];
33
- } | undefined;
34
- ballot?: {
35
- source: string;
36
- period: number;
37
- proposal: string;
38
- ballot: PROTO.TezosBallotType;
39
- } | undefined;
40
29
  reveal?: {
41
30
  source: Uint8Array;
42
31
  public_key: Uint8Array;
43
32
  fee: string | number;
44
- gas_limit: number;
45
33
  counter: number;
34
+ gas_limit: number;
46
35
  storage_limit: number;
47
36
  } | undefined;
48
37
  origination?: {
@@ -53,18 +42,29 @@ export declare const createTx: (address_n: number[], branch: string, operation:
53
42
  source: Uint8Array;
54
43
  fee: string | number;
55
44
  script: string | number[];
56
- gas_limit: number;
45
+ balance: number;
57
46
  counter: number;
47
+ gas_limit: number;
58
48
  storage_limit: number;
59
- balance: number;
60
49
  } | undefined;
61
50
  delegation?: {
62
51
  source: Uint8Array;
63
52
  fee: string | number;
64
- delegate: Uint8Array;
65
- gas_limit: number;
66
53
  counter: number;
54
+ gas_limit: number;
67
55
  storage_limit: number;
56
+ delegate: Uint8Array;
57
+ } | undefined;
58
+ proposal?: {
59
+ source: string;
60
+ period: number;
61
+ proposals: string[];
62
+ } | undefined;
63
+ ballot?: {
64
+ source: string;
65
+ period: number;
66
+ proposal: string;
67
+ ballot: PROTO.TezosBallotType;
68
68
  } | undefined;
69
69
  address_n: number[];
70
70
  branch: Uint8Array;
@@ -1,5 +1,5 @@
1
- import { AbstractMethod } from '../core/AbstractMethod';
2
1
  import { PROTO } from '../constants';
2
+ import { AbstractMethod } from '../core/AbstractMethod';
3
3
  export default class UnlockPath extends AbstractMethod<'unlockPath', PROTO.UnlockPath> {
4
4
  init(): void;
5
5
  run(): Promise<{
@@ -1,5 +1,5 @@
1
- import { AbstractMethod } from '../core/AbstractMethod';
2
1
  import { PROTO } from '../constants';
2
+ import { AbstractMethod } from '../core/AbstractMethod';
3
3
  export default class VerifyMessage extends AbstractMethod<'verifyMessage', PROTO.VerifyMessage> {
4
4
  init(): void;
5
5
  get info(): string;
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const schema_utils_1 = require("@trezor/schema-utils");
4
+ const constants_1 = require("../constants");
4
5
  const AbstractMethod_1 = require("../core/AbstractMethod");
5
6
  const paramsValidator_1 = require("./common/paramsValidator");
6
7
  const coinInfo_1 = require("../data/coinInfo");
7
- const pathUtils_1 = require("../utils/pathUtils");
8
- const formatUtils_1 = require("../utils/formatUtils");
9
- const constants_1 = require("../constants");
10
8
  const types_1 = require("../types");
9
+ const formatUtils_1 = require("../utils/formatUtils");
10
+ const pathUtils_1 = require("../utils/pathUtils");
11
11
  class VerifyMessage extends AbstractMethod_1.AbstractMethod {
12
12
  init() {
13
13
  this.requiredPermissions = ['read', 'write'];
@@ -1,5 +1,5 @@
1
1
  import { Blockchain, BlockchainOptions } from './Blockchain';
2
- import type { CoinInfo, BlockchainLink } from '../types';
2
+ import type { BlockchainLink, CoinInfo } from '../types';
3
3
  type CoinShortcut = CoinInfo['shortcut'];
4
4
  type BackendParams = Pick<BlockchainOptions, 'coinInfo' | 'postMessage' | 'identity'>;
5
5
  export declare class BackendManager {
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BackendManager = void 0;
4
- const DataManager_1 = require("../data/DataManager");
5
4
  const constants_1 = require("../constants");
6
5
  const Blockchain_1 = require("./Blockchain");
6
+ const DataManager_1 = require("../data/DataManager");
7
7
  const events_1 = require("../events");
8
8
  const DEFAULT_IDENTITY = 'default';
9
9
  class BackendManager {
@@ -1,6 +1,6 @@
1
- import BlockchainLink, { ServerInfo, SubscriptionAccountInfo, BlockchainLinkParams, BlockchainLinkResponse } from '@trezor/blockchain-link';
2
- import { CoreEventMessage } from '../events';
1
+ import BlockchainLink, { BlockchainLinkParams, BlockchainLinkResponse, ServerInfo, SubscriptionAccountInfo } from '@trezor/blockchain-link';
3
2
  import { ERRORS } from '../constants';
3
+ import { CoreEventMessage } from '../events';
4
4
  import type { CoinInfo, Proxy } from '../types';
5
5
  export type BlockchainOptions = {
6
6
  coinInfo: CoinInfo;
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Blockchain = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const blockchain_link_1 = tslib_1.__importDefault(require("@trezor/blockchain-link"));
6
- const events_1 = require("../events");
7
6
  const constants_1 = require("../constants");
7
+ const events_1 = require("../events");
8
8
  const workers_1 = require("../workers/workers");
9
9
  const getWorker = (type) => {
10
10
  switch (type) {
@@ -26,9 +26,6 @@ const getNormalizedTrezorShortcut = (shortcut) => {
26
26
  if (shortcut === 'tXRP') {
27
27
  return 'XRP';
28
28
  }
29
- if (['OP', 'BASE'].includes(shortcut)) {
30
- return 'ETH';
31
- }
32
29
  return shortcut;
33
30
  };
34
31
  class Blockchain {
@@ -81,9 +78,9 @@ class Blockchain {
81
78
  throw constants_1.ERRORS.TypedError('Backend_Error', error.message);
82
79
  }
83
80
  this.serverInfo = info;
84
- const trezorShortcut = getNormalizedTrezorShortcut(this.coinInfo.shortcut);
85
- const backendShortcut = this.serverInfo.shortcut;
86
- if (trezorShortcut.toLowerCase() !== backendShortcut.toLowerCase()) {
81
+ const trezorNetworkShortcut = getNormalizedTrezorShortcut(this.coinInfo.shortcut);
82
+ const backendNetworkShortcut = this.serverInfo.network;
83
+ if (backendNetworkShortcut.toLowerCase() !== trezorNetworkShortcut.toLowerCase()) {
87
84
  throw constants_1.ERRORS.TypedError('Backend_Invalid');
88
85
  }
89
86
  this.link.on('disconnected', () => {
@@ -43,6 +43,7 @@ export declare const ERROR_CODES: {
43
43
  readonly Failure_PinInvalid: "PIN invalid";
44
44
  readonly Failure_PinMismatch: "PIN mismatch";
45
45
  readonly Failure_WipeCodeMismatch: "Wipe code mismatch";
46
+ readonly Failure_EntropyCheck: "";
46
47
  readonly Deeplink_VersionMismatch: "Not compatible with current version of the app";
47
48
  };
48
49
  export type ErrorCode = keyof typeof ERROR_CODES;
@@ -50,6 +51,7 @@ export declare class TrezorError extends Error {
50
51
  code: ErrorCode;
51
52
  message: string;
52
53
  constructor(code: ErrorCode, message: string);
54
+ toString(): string;
53
55
  }
54
56
  export declare const TypedError: (id: ErrorCode, message?: string) => TrezorError;
55
57
  export declare const serializeError: (payload: any) => any;
@@ -46,6 +46,7 @@ exports.ERROR_CODES = {
46
46
  Failure_PinInvalid: 'PIN invalid',
47
47
  Failure_PinMismatch: 'PIN mismatch',
48
48
  Failure_WipeCodeMismatch: 'Wipe code mismatch',
49
+ Failure_EntropyCheck: '',
49
50
  Deeplink_VersionMismatch: 'Not compatible with current version of the app',
50
51
  };
51
52
  class TrezorError extends Error {
@@ -54,6 +55,9 @@ class TrezorError extends Error {
54
55
  this.code = code;
55
56
  this.message = message;
56
57
  }
58
+ toString() {
59
+ return `${this.name} (code: ${this.code}): ${this.message}`;
60
+ }
57
61
  }
58
62
  exports.TrezorError = TrezorError;
59
63
  const TypedError = (id, message) => new TrezorError(id, message || exports.ERROR_CODES[id]);
@@ -1,8 +1,8 @@
1
1
  import { Capability } from '@trezor/protobuf/lib/messages';
2
2
  import { NETWORK } from '../constants';
3
- import { UI, CallMethodPayload, CallMethodResponse, UiRequestButtonData, UiPromiseCreator, CoreEventMessage, UiRequestConfirmation } from '../events';
4
3
  import type { Device } from '../device/Device';
5
- import type { FirmwareRange, DeviceState, ConnectSettings } from '../types';
4
+ import { CallMethodPayload, CallMethodResponse, CoreEventMessage, UI, UiPromiseCreator, UiRequestButtonData, UiRequestConfirmation } from '../events';
5
+ import type { ConnectSettings, DeviceState, FirmwareRange } from '../types';
6
6
  export type Payload<M> = Extract<CallMethodPayload, {
7
7
  method: M;
8
8
  }> & {
@@ -4,10 +4,11 @@ exports.AbstractMethod = exports.DEFAULT_FIRMWARE_RANGE = void 0;
4
4
  const connect_common_1 = require("@trezor/connect-common");
5
5
  const utils_1 = require("@trezor/utils");
6
6
  const constants_1 = require("../constants");
7
+ const config_1 = require("../data/config");
7
8
  const events_1 = require("../events");
8
9
  const urlUtils_1 = require("../utils/urlUtils");
9
- const config_1 = require("../data/config");
10
10
  exports.DEFAULT_FIRMWARE_RANGE = {
11
+ UNKNOWN: { min: '1.0.0', max: '0' },
11
12
  T1B1: { min: '1.0.0', max: '0' },
12
13
  T2T1: { min: '2.0.0', max: '0' },
13
14
  T2B1: { min: '2.6.1', max: '0' },
@@ -1,8 +1,8 @@
1
1
  import EventEmitter from 'events';
2
- import { TransportInfo, CoreRequestMessage, CoreEventMessage } from '../events';
3
2
  import { AbstractMethod } from './AbstractMethod';
4
- import { LogWriter } from '../utils/debug';
3
+ import { CoreEventMessage, CoreRequestMessage, TransportInfo } from '../events';
5
4
  import type { ConnectSettings } from '../types';
5
+ import { LogWriter } from '../utils/debug';
6
6
  export declare class Core extends EventEmitter {
7
7
  private abortController;
8
8
  private callMethods;
@@ -20,7 +20,7 @@ export declare class Core extends EventEmitter {
20
20
  handleMessage(message: CoreRequestMessage): void;
21
21
  dispose(): void;
22
22
  getCurrentMethod(): Promise<AbstractMethod<any, undefined>>;
23
- getTransportInfo(): TransportInfo | undefined;
23
+ getActiveTransports(): TransportInfo[] | undefined;
24
24
  enumerate(): void;
25
25
  init(settings: ConnectSettings, onCoreEvent: (message: CoreEventMessage) => void, logWriterFactory?: () => LogWriter | undefined): Promise<void>;
26
26
  }