@ledgerhq/coin-ton 0.3.12-next.0

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 (341) hide show
  1. package/.eslintrc.js +20 -0
  2. package/.turbo/turbo-build.log +4 -0
  3. package/.unimportedrc.json +19 -0
  4. package/CHANGELOG.md +15 -0
  5. package/LICENSE.txt +21 -0
  6. package/jest.config.js +12 -0
  7. package/lib/__tests__/fixtures/api.fixtures.d.ts +4 -0
  8. package/lib/__tests__/fixtures/api.fixtures.d.ts.map +1 -0
  9. package/lib/__tests__/fixtures/api.fixtures.js +33 -0
  10. package/lib/__tests__/fixtures/api.fixtures.js.map +1 -0
  11. package/lib/__tests__/fixtures/common.fixtures.d.ts +29 -0
  12. package/lib/__tests__/fixtures/common.fixtures.d.ts.map +1 -0
  13. package/lib/__tests__/fixtures/common.fixtures.js +124 -0
  14. package/lib/__tests__/fixtures/common.fixtures.js.map +1 -0
  15. package/lib/__tests__/integration/bridge.integration.test.d.ts +14 -0
  16. package/lib/__tests__/integration/bridge.integration.test.d.ts.map +1 -0
  17. package/lib/__tests__/integration/bridge.integration.test.js +136 -0
  18. package/lib/__tests__/integration/bridge.integration.test.js.map +1 -0
  19. package/lib/__tests__/unit/api.unit.test.d.ts +2 -0
  20. package/lib/__tests__/unit/api.unit.test.d.ts.map +1 -0
  21. package/lib/__tests__/unit/api.unit.test.js +77 -0
  22. package/lib/__tests__/unit/api.unit.test.js.map +1 -0
  23. package/lib/__tests__/unit/broadcast.unit.test.d.ts +2 -0
  24. package/lib/__tests__/unit/broadcast.unit.test.d.ts.map +1 -0
  25. package/lib/__tests__/unit/broadcast.unit.test.js +40 -0
  26. package/lib/__tests__/unit/broadcast.unit.test.js.map +1 -0
  27. package/lib/__tests__/unit/createTransaction.unit.test.d.ts +2 -0
  28. package/lib/__tests__/unit/createTransaction.unit.test.d.ts.map +1 -0
  29. package/lib/__tests__/unit/createTransaction.unit.test.js +34 -0
  30. package/lib/__tests__/unit/createTransaction.unit.test.js.map +1 -0
  31. package/lib/__tests__/unit/deviceTransactionConfig.unit.test.d.ts +2 -0
  32. package/lib/__tests__/unit/deviceTransactionConfig.unit.test.d.ts.map +1 -0
  33. package/lib/__tests__/unit/deviceTransactionConfig.unit.test.js +74 -0
  34. package/lib/__tests__/unit/deviceTransactionConfig.unit.test.js.map +1 -0
  35. package/lib/__tests__/unit/estimateMaxSpendable.unit.test.d.ts +2 -0
  36. package/lib/__tests__/unit/estimateMaxSpendable.unit.test.d.ts.map +1 -0
  37. package/lib/__tests__/unit/estimateMaxSpendable.unit.test.js +31 -0
  38. package/lib/__tests__/unit/estimateMaxSpendable.unit.test.js.map +1 -0
  39. package/lib/__tests__/unit/getTransactionStatus.unit.test.d.ts +2 -0
  40. package/lib/__tests__/unit/getTransactionStatus.unit.test.d.ts.map +1 -0
  41. package/lib/__tests__/unit/getTransactionStatus.unit.test.js +96 -0
  42. package/lib/__tests__/unit/getTransactionStatus.unit.test.js.map +1 -0
  43. package/lib/__tests__/unit/hw-getAddress.unit.test.d.ts +2 -0
  44. package/lib/__tests__/unit/hw-getAddress.unit.test.d.ts.map +1 -0
  45. package/lib/__tests__/unit/hw-getAddress.unit.test.js +67 -0
  46. package/lib/__tests__/unit/hw-getAddress.unit.test.js.map +1 -0
  47. package/lib/__tests__/unit/prepareTransaction.unit.test.d.ts +2 -0
  48. package/lib/__tests__/unit/prepareTransaction.unit.test.d.ts.map +1 -0
  49. package/lib/__tests__/unit/prepareTransaction.unit.test.js +42 -0
  50. package/lib/__tests__/unit/prepareTransaction.unit.test.js.map +1 -0
  51. package/lib/__tests__/unit/signOperation.unit.test.d.ts +2 -0
  52. package/lib/__tests__/unit/signOperation.unit.test.d.ts.map +1 -0
  53. package/lib/__tests__/unit/signOperation.unit.test.js +83 -0
  54. package/lib/__tests__/unit/signOperation.unit.test.js.map +1 -0
  55. package/lib/__tests__/unit/txn.unit.test.d.ts +2 -0
  56. package/lib/__tests__/unit/txn.unit.test.d.ts.map +1 -0
  57. package/lib/__tests__/unit/txn.unit.test.js +116 -0
  58. package/lib/__tests__/unit/txn.unit.test.js.map +1 -0
  59. package/lib/__tests__/unit/utils.unit.test.d.ts +2 -0
  60. package/lib/__tests__/unit/utils.unit.test.d.ts.map +1 -0
  61. package/lib/__tests__/unit/utils.unit.test.js +97 -0
  62. package/lib/__tests__/unit/utils.unit.test.js.map +1 -0
  63. package/lib/bridge/bridgeHelpers/api.d.ts +10 -0
  64. package/lib/bridge/bridgeHelpers/api.d.ts.map +1 -0
  65. package/lib/bridge/bridgeHelpers/api.js +104 -0
  66. package/lib/bridge/bridgeHelpers/api.js.map +1 -0
  67. package/lib/bridge/bridgeHelpers/api.types.d.ts +164 -0
  68. package/lib/bridge/bridgeHelpers/api.types.d.ts.map +1 -0
  69. package/lib/bridge/bridgeHelpers/api.types.js +3 -0
  70. package/lib/bridge/bridgeHelpers/api.types.js.map +1 -0
  71. package/lib/bridge/bridgeHelpers/txn.d.ts +5 -0
  72. package/lib/bridge/bridgeHelpers/txn.d.ts.map +1 -0
  73. package/lib/bridge/bridgeHelpers/txn.js +166 -0
  74. package/lib/bridge/bridgeHelpers/txn.js.map +1 -0
  75. package/lib/bridge/js.d.ts +12 -0
  76. package/lib/bridge/js.d.ts.map +1 -0
  77. package/lib/bridge/js.js +65 -0
  78. package/lib/bridge/js.js.map +1 -0
  79. package/lib/broadcast.d.ts +5 -0
  80. package/lib/broadcast.d.ts.map +1 -0
  81. package/lib/broadcast.js +19 -0
  82. package/lib/broadcast.js.map +1 -0
  83. package/lib/cli-transaction.d.ts +12 -0
  84. package/lib/cli-transaction.d.ts.map +1 -0
  85. package/lib/cli-transaction.js +21 -0
  86. package/lib/cli-transaction.js.map +1 -0
  87. package/lib/config.d.ts +9 -0
  88. package/lib/config.d.ts.map +1 -0
  89. package/lib/config.js +16 -0
  90. package/lib/config.js.map +1 -0
  91. package/lib/createTransaction.d.ts +5 -0
  92. package/lib/createTransaction.d.ts.map +1 -0
  93. package/lib/createTransaction.js +16 -0
  94. package/lib/createTransaction.js.map +1 -0
  95. package/lib/deviceTransactionConfig.d.ts +11 -0
  96. package/lib/deviceTransactionConfig.d.ts.map +1 -0
  97. package/lib/deviceTransactionConfig.js +37 -0
  98. package/lib/deviceTransactionConfig.js.map +1 -0
  99. package/lib/errors.d.ts +4 -0
  100. package/lib/errors.d.ts.map +1 -0
  101. package/lib/errors.js +9 -0
  102. package/lib/errors.js.map +1 -0
  103. package/lib/estimateMaxSpendable.d.ts +5 -0
  104. package/lib/estimateMaxSpendable.d.ts.map +1 -0
  105. package/lib/estimateMaxSpendable.js +32 -0
  106. package/lib/estimateMaxSpendable.js.map +1 -0
  107. package/lib/getTransactionStatus.d.ts +5 -0
  108. package/lib/getTransactionStatus.d.ts.map +1 -0
  109. package/lib/getTransactionStatus.js +97 -0
  110. package/lib/getTransactionStatus.js.map +1 -0
  111. package/lib/hw-getAddress.d.ts +6 -0
  112. package/lib/hw-getAddress.d.ts.map +1 -0
  113. package/lib/hw-getAddress.js +31 -0
  114. package/lib/hw-getAddress.js.map +1 -0
  115. package/lib/hw-signMessage.d.ts +12 -0
  116. package/lib/hw-signMessage.d.ts.map +1 -0
  117. package/lib/hw-signMessage.js +33 -0
  118. package/lib/hw-signMessage.js.map +1 -0
  119. package/lib/prepareTransaction.d.ts +5 -0
  120. package/lib/prepareTransaction.d.ts.map +1 -0
  121. package/lib/prepareTransaction.js +29 -0
  122. package/lib/prepareTransaction.js.map +1 -0
  123. package/lib/signOperation.d.ts +11 -0
  124. package/lib/signOperation.d.ts.map +1 -0
  125. package/lib/signOperation.js +96 -0
  126. package/lib/signOperation.js.map +1 -0
  127. package/lib/signer.d.ts +27 -0
  128. package/lib/signer.d.ts.map +1 -0
  129. package/lib/signer.js +3 -0
  130. package/lib/signer.js.map +1 -0
  131. package/lib/specs.d.ts +8 -0
  132. package/lib/specs.d.ts.map +1 -0
  133. package/lib/specs.js +106 -0
  134. package/lib/specs.js.map +1 -0
  135. package/lib/speculos-deviceActions.d.ts +4 -0
  136. package/lib/speculos-deviceActions.d.ts.map +1 -0
  137. package/lib/speculos-deviceActions.js +34 -0
  138. package/lib/speculos-deviceActions.js.map +1 -0
  139. package/lib/synchronisation.d.ts +5 -0
  140. package/lib/synchronisation.d.ts.map +1 -0
  141. package/lib/synchronisation.js +95 -0
  142. package/lib/synchronisation.js.map +1 -0
  143. package/lib/transaction.d.ts +14 -0
  144. package/lib/transaction.d.ts.map +1 -0
  145. package/lib/transaction.js +41 -0
  146. package/lib/transaction.js.map +1 -0
  147. package/lib/types.d.ts +65 -0
  148. package/lib/types.d.ts.map +1 -0
  149. package/lib/types.js +3 -0
  150. package/lib/types.js.map +1 -0
  151. package/lib/utils.d.ts +11 -0
  152. package/lib/utils.d.ts.map +1 -0
  153. package/lib/utils.js +125 -0
  154. package/lib/utils.js.map +1 -0
  155. package/lib-es/__tests__/fixtures/api.fixtures.d.ts +4 -0
  156. package/lib-es/__tests__/fixtures/api.fixtures.d.ts.map +1 -0
  157. package/lib-es/__tests__/fixtures/api.fixtures.js +30 -0
  158. package/lib-es/__tests__/fixtures/api.fixtures.js.map +1 -0
  159. package/lib-es/__tests__/fixtures/common.fixtures.d.ts +29 -0
  160. package/lib-es/__tests__/fixtures/common.fixtures.d.ts.map +1 -0
  161. package/lib-es/__tests__/fixtures/common.fixtures.js +118 -0
  162. package/lib-es/__tests__/fixtures/common.fixtures.js.map +1 -0
  163. package/lib-es/__tests__/integration/bridge.integration.test.d.ts +14 -0
  164. package/lib-es/__tests__/integration/bridge.integration.test.d.ts.map +1 -0
  165. package/lib-es/__tests__/integration/bridge.integration.test.js +130 -0
  166. package/lib-es/__tests__/integration/bridge.integration.test.js.map +1 -0
  167. package/lib-es/__tests__/unit/api.unit.test.d.ts +2 -0
  168. package/lib-es/__tests__/unit/api.unit.test.d.ts.map +1 -0
  169. package/lib-es/__tests__/unit/api.unit.test.js +52 -0
  170. package/lib-es/__tests__/unit/api.unit.test.js.map +1 -0
  171. package/lib-es/__tests__/unit/broadcast.unit.test.d.ts +2 -0
  172. package/lib-es/__tests__/unit/broadcast.unit.test.d.ts.map +1 -0
  173. package/lib-es/__tests__/unit/broadcast.unit.test.js +35 -0
  174. package/lib-es/__tests__/unit/broadcast.unit.test.js.map +1 -0
  175. package/lib-es/__tests__/unit/createTransaction.unit.test.d.ts +2 -0
  176. package/lib-es/__tests__/unit/createTransaction.unit.test.d.ts.map +1 -0
  177. package/lib-es/__tests__/unit/createTransaction.unit.test.js +29 -0
  178. package/lib-es/__tests__/unit/createTransaction.unit.test.js.map +1 -0
  179. package/lib-es/__tests__/unit/deviceTransactionConfig.unit.test.d.ts +2 -0
  180. package/lib-es/__tests__/unit/deviceTransactionConfig.unit.test.d.ts.map +1 -0
  181. package/lib-es/__tests__/unit/deviceTransactionConfig.unit.test.js +69 -0
  182. package/lib-es/__tests__/unit/deviceTransactionConfig.unit.test.js.map +1 -0
  183. package/lib-es/__tests__/unit/estimateMaxSpendable.unit.test.d.ts +2 -0
  184. package/lib-es/__tests__/unit/estimateMaxSpendable.unit.test.d.ts.map +1 -0
  185. package/lib-es/__tests__/unit/estimateMaxSpendable.unit.test.js +26 -0
  186. package/lib-es/__tests__/unit/estimateMaxSpendable.unit.test.js.map +1 -0
  187. package/lib-es/__tests__/unit/getTransactionStatus.unit.test.d.ts +2 -0
  188. package/lib-es/__tests__/unit/getTransactionStatus.unit.test.d.ts.map +1 -0
  189. package/lib-es/__tests__/unit/getTransactionStatus.unit.test.js +91 -0
  190. package/lib-es/__tests__/unit/getTransactionStatus.unit.test.js.map +1 -0
  191. package/lib-es/__tests__/unit/hw-getAddress.unit.test.d.ts +2 -0
  192. package/lib-es/__tests__/unit/hw-getAddress.unit.test.d.ts.map +1 -0
  193. package/lib-es/__tests__/unit/hw-getAddress.unit.test.js +62 -0
  194. package/lib-es/__tests__/unit/hw-getAddress.unit.test.js.map +1 -0
  195. package/lib-es/__tests__/unit/prepareTransaction.unit.test.d.ts +2 -0
  196. package/lib-es/__tests__/unit/prepareTransaction.unit.test.d.ts.map +1 -0
  197. package/lib-es/__tests__/unit/prepareTransaction.unit.test.js +37 -0
  198. package/lib-es/__tests__/unit/prepareTransaction.unit.test.js.map +1 -0
  199. package/lib-es/__tests__/unit/signOperation.unit.test.d.ts +2 -0
  200. package/lib-es/__tests__/unit/signOperation.unit.test.d.ts.map +1 -0
  201. package/lib-es/__tests__/unit/signOperation.unit.test.js +78 -0
  202. package/lib-es/__tests__/unit/signOperation.unit.test.js.map +1 -0
  203. package/lib-es/__tests__/unit/txn.unit.test.d.ts +2 -0
  204. package/lib-es/__tests__/unit/txn.unit.test.d.ts.map +1 -0
  205. package/lib-es/__tests__/unit/txn.unit.test.js +111 -0
  206. package/lib-es/__tests__/unit/txn.unit.test.js.map +1 -0
  207. package/lib-es/__tests__/unit/utils.unit.test.d.ts +2 -0
  208. package/lib-es/__tests__/unit/utils.unit.test.d.ts.map +1 -0
  209. package/lib-es/__tests__/unit/utils.unit.test.js +95 -0
  210. package/lib-es/__tests__/unit/utils.unit.test.js.map +1 -0
  211. package/lib-es/bridge/bridgeHelpers/api.d.ts +10 -0
  212. package/lib-es/bridge/bridgeHelpers/api.d.ts.map +1 -0
  213. package/lib-es/bridge/bridgeHelpers/api.js +93 -0
  214. package/lib-es/bridge/bridgeHelpers/api.js.map +1 -0
  215. package/lib-es/bridge/bridgeHelpers/api.types.d.ts +164 -0
  216. package/lib-es/bridge/bridgeHelpers/api.types.d.ts.map +1 -0
  217. package/lib-es/bridge/bridgeHelpers/api.types.js +2 -0
  218. package/lib-es/bridge/bridgeHelpers/api.types.js.map +1 -0
  219. package/lib-es/bridge/bridgeHelpers/txn.d.ts +5 -0
  220. package/lib-es/bridge/bridgeHelpers/txn.d.ts.map +1 -0
  221. package/lib-es/bridge/bridgeHelpers/txn.js +158 -0
  222. package/lib-es/bridge/bridgeHelpers/txn.js.map +1 -0
  223. package/lib-es/bridge/js.d.ts +12 -0
  224. package/lib-es/bridge/js.d.ts.map +1 -0
  225. package/lib-es/bridge/js.js +56 -0
  226. package/lib-es/bridge/js.js.map +1 -0
  227. package/lib-es/broadcast.d.ts +5 -0
  228. package/lib-es/broadcast.d.ts.map +1 -0
  229. package/lib-es/broadcast.js +17 -0
  230. package/lib-es/broadcast.js.map +1 -0
  231. package/lib-es/cli-transaction.d.ts +12 -0
  232. package/lib-es/cli-transaction.d.ts.map +1 -0
  233. package/lib-es/cli-transaction.js +15 -0
  234. package/lib-es/cli-transaction.js.map +1 -0
  235. package/lib-es/config.d.ts +9 -0
  236. package/lib-es/config.d.ts.map +1 -0
  237. package/lib-es/config.js +11 -0
  238. package/lib-es/config.js.map +1 -0
  239. package/lib-es/createTransaction.d.ts +5 -0
  240. package/lib-es/createTransaction.d.ts.map +1 -0
  241. package/lib-es/createTransaction.js +14 -0
  242. package/lib-es/createTransaction.js.map +1 -0
  243. package/lib-es/deviceTransactionConfig.d.ts +11 -0
  244. package/lib-es/deviceTransactionConfig.d.ts.map +1 -0
  245. package/lib-es/deviceTransactionConfig.js +35 -0
  246. package/lib-es/deviceTransactionConfig.js.map +1 -0
  247. package/lib-es/errors.d.ts +4 -0
  248. package/lib-es/errors.d.ts.map +1 -0
  249. package/lib-es/errors.js +6 -0
  250. package/lib-es/errors.js.map +1 -0
  251. package/lib-es/estimateMaxSpendable.d.ts +5 -0
  252. package/lib-es/estimateMaxSpendable.d.ts.map +1 -0
  253. package/lib-es/estimateMaxSpendable.js +30 -0
  254. package/lib-es/estimateMaxSpendable.js.map +1 -0
  255. package/lib-es/getTransactionStatus.d.ts +5 -0
  256. package/lib-es/getTransactionStatus.d.ts.map +1 -0
  257. package/lib-es/getTransactionStatus.js +93 -0
  258. package/lib-es/getTransactionStatus.js.map +1 -0
  259. package/lib-es/hw-getAddress.d.ts +6 -0
  260. package/lib-es/hw-getAddress.d.ts.map +1 -0
  261. package/lib-es/hw-getAddress.js +29 -0
  262. package/lib-es/hw-getAddress.js.map +1 -0
  263. package/lib-es/hw-signMessage.d.ts +12 -0
  264. package/lib-es/hw-signMessage.d.ts.map +1 -0
  265. package/lib-es/hw-signMessage.js +29 -0
  266. package/lib-es/hw-signMessage.js.map +1 -0
  267. package/lib-es/prepareTransaction.d.ts +5 -0
  268. package/lib-es/prepareTransaction.d.ts.map +1 -0
  269. package/lib-es/prepareTransaction.js +27 -0
  270. package/lib-es/prepareTransaction.js.map +1 -0
  271. package/lib-es/signOperation.d.ts +11 -0
  272. package/lib-es/signOperation.d.ts.map +1 -0
  273. package/lib-es/signOperation.js +91 -0
  274. package/lib-es/signOperation.js.map +1 -0
  275. package/lib-es/signer.d.ts +27 -0
  276. package/lib-es/signer.d.ts.map +1 -0
  277. package/lib-es/signer.js +2 -0
  278. package/lib-es/signer.js.map +1 -0
  279. package/lib-es/specs.d.ts +8 -0
  280. package/lib-es/specs.d.ts.map +1 -0
  281. package/lib-es/specs.js +99 -0
  282. package/lib-es/specs.js.map +1 -0
  283. package/lib-es/speculos-deviceActions.d.ts +4 -0
  284. package/lib-es/speculos-deviceActions.d.ts.map +1 -0
  285. package/lib-es/speculos-deviceActions.js +31 -0
  286. package/lib-es/speculos-deviceActions.js.map +1 -0
  287. package/lib-es/synchronisation.d.ts +5 -0
  288. package/lib-es/synchronisation.d.ts.map +1 -0
  289. package/lib-es/synchronisation.js +88 -0
  290. package/lib-es/synchronisation.js.map +1 -0
  291. package/lib-es/transaction.d.ts +14 -0
  292. package/lib-es/transaction.d.ts.map +1 -0
  293. package/lib-es/transaction.js +33 -0
  294. package/lib-es/transaction.js.map +1 -0
  295. package/lib-es/types.d.ts +65 -0
  296. package/lib-es/types.d.ts.map +1 -0
  297. package/lib-es/types.js +2 -0
  298. package/lib-es/types.js.map +1 -0
  299. package/lib-es/utils.d.ts +11 -0
  300. package/lib-es/utils.d.ts.map +1 -0
  301. package/lib-es/utils.js +112 -0
  302. package/lib-es/utils.js.map +1 -0
  303. package/package.json +86 -0
  304. package/src/__tests__/fixtures/api.fixtures.ts +39 -0
  305. package/src/__tests__/fixtures/common.fixtures.ts +139 -0
  306. package/src/__tests__/integration/bridge.integration.test.ts +135 -0
  307. package/src/__tests__/unit/api.unit.test.ts +60 -0
  308. package/src/__tests__/unit/broadcast.unit.test.ts +36 -0
  309. package/src/__tests__/unit/createTransaction.unit.test.ts +20 -0
  310. package/src/__tests__/unit/deviceTransactionConfig.unit.test.ts +69 -0
  311. package/src/__tests__/unit/estimateMaxSpendable.unit.test.ts +19 -0
  312. package/src/__tests__/unit/getTransactionStatus.unit.test.ts +119 -0
  313. package/src/__tests__/unit/hw-getAddress.unit.test.ts +58 -0
  314. package/src/__tests__/unit/prepareTransaction.unit.test.ts +52 -0
  315. package/src/__tests__/unit/signOperation.unit.test.ts +90 -0
  316. package/src/__tests__/unit/txn.unit.test.ts +121 -0
  317. package/src/__tests__/unit/utils.unit.test.ts +126 -0
  318. package/src/bridge/bridgeHelpers/api.ts +104 -0
  319. package/src/bridge/bridgeHelpers/api.types.ts +178 -0
  320. package/src/bridge/bridgeHelpers/txn.ts +166 -0
  321. package/src/bridge/js.ts +65 -0
  322. package/src/broadcast.ts +13 -0
  323. package/src/cli-transaction.ts +30 -0
  324. package/src/config.ts +21 -0
  325. package/src/createTransaction.ts +17 -0
  326. package/src/deviceTransactionConfig.ts +48 -0
  327. package/src/errors.ts +6 -0
  328. package/src/estimateMaxSpendable.ts +40 -0
  329. package/src/getTransactionStatus.ts +130 -0
  330. package/src/hw-getAddress.ts +28 -0
  331. package/src/hw-signMessage.ts +31 -0
  332. package/src/prepareTransaction.ts +27 -0
  333. package/src/signOperation.ts +115 -0
  334. package/src/signer.ts +32 -0
  335. package/src/specs.ts +122 -0
  336. package/src/speculos-deviceActions.ts +38 -0
  337. package/src/synchronisation.ts +91 -0
  338. package/src/transaction.ts +61 -0
  339. package/src/types.ts +82 -0
  340. package/src/utils.ts +120 -0
  341. package/tsconfig.json +12 -0
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.sync = exports.getAccountShape = void 0;
16
+ const index_1 = require("@ledgerhq/coin-framework/account/index");
17
+ const jsHelpers_1 = require("@ledgerhq/coin-framework/bridge/jsHelpers");
18
+ const logs_1 = require("@ledgerhq/logs");
19
+ const bignumber_js_1 = __importDefault(require("bignumber.js"));
20
+ const flatMap_1 = __importDefault(require("lodash/flatMap"));
21
+ const api_1 = require("./bridge/bridgeHelpers/api");
22
+ const txn_1 = require("./bridge/bridgeHelpers/txn");
23
+ const getAccountShape = (info) => __awaiter(void 0, void 0, void 0, function* () {
24
+ var _a;
25
+ const { address, rest, currency, derivationMode, initialAccount } = info;
26
+ const publicKey = reconciliatePubkey(rest === null || rest === void 0 ? void 0 : rest.publicKey, initialAccount);
27
+ const blockHeight = yield (0, api_1.fetchLastBlockNumber)();
28
+ const accountId = (0, index_1.encodeAccountId)({
29
+ type: "js",
30
+ version: "2",
31
+ currencyId: currency.id,
32
+ xpubOrAddress: publicKey,
33
+ derivationMode,
34
+ });
35
+ (0, logs_1.log)("debug", `Generation account shape for ${address}`);
36
+ const newTxs = { transactions: [], address_book: {} };
37
+ const oldOps = ((_a = initialAccount === null || initialAccount === void 0 ? void 0 : initialAccount.operations) !== null && _a !== void 0 ? _a : []);
38
+ const { last_transaction_lt, balance } = yield (0, api_1.fetchAccountInfo)(address);
39
+ // if last_transaction_lt is empty, then there are no transactions in account
40
+ if (last_transaction_lt != null) {
41
+ if (oldOps.length === 0) {
42
+ const [tmpTxs] = yield Promise.all([(0, txn_1.getTransactions)(address)]);
43
+ newTxs.transactions.push(...tmpTxs.transactions);
44
+ newTxs.address_book = Object.assign(Object.assign({}, newTxs.address_book), tmpTxs.address_book);
45
+ }
46
+ else {
47
+ // if they are the same, we have no new ops
48
+ if (oldOps[0].extra.lt !== last_transaction_lt) {
49
+ const [tmpTxs] = yield Promise.all([(0, txn_1.getTransactions)(address, oldOps[0].extra.lt)]);
50
+ newTxs.transactions.push(...tmpTxs.transactions);
51
+ newTxs.address_book = Object.assign(Object.assign({}, newTxs.address_book), tmpTxs.address_book);
52
+ }
53
+ }
54
+ }
55
+ const newOps = (0, flatMap_1.default)(newTxs.transactions, (0, txn_1.mapTxToOps)(accountId, address, newTxs.address_book));
56
+ const operations = (0, jsHelpers_1.mergeOps)(oldOps, newOps);
57
+ const toReturn = {
58
+ id: accountId,
59
+ balance: new bignumber_js_1.default(balance),
60
+ spendableBalance: new bignumber_js_1.default(balance),
61
+ operations,
62
+ operationsCount: operations.length,
63
+ blockHeight,
64
+ xpub: publicKey,
65
+ lastSyncDate: new Date(),
66
+ };
67
+ return toReturn;
68
+ });
69
+ exports.getAccountShape = getAccountShape;
70
+ const postSync = (initial, synced) => {
71
+ const initialPendingOperations = initial.pendingOperations || [];
72
+ const { operations } = synced;
73
+ const pendingOperations = initialPendingOperations.filter(op => !operations.some(o => o.id === op.id));
74
+ // Set of hashes from the pending operations of the main account
75
+ const coinPendingOperationsHashes = new Set();
76
+ for (const op of pendingOperations) {
77
+ coinPendingOperationsHashes.add(op.hash);
78
+ }
79
+ return Object.assign(Object.assign({}, synced), { pendingOperations });
80
+ };
81
+ function reconciliatePubkey(publicKey, initialAccount) {
82
+ var _a;
83
+ if ((publicKey === null || publicKey === void 0 ? void 0 : publicKey.length) === 64)
84
+ return publicKey;
85
+ if (initialAccount) {
86
+ if (((_a = initialAccount.xpub) === null || _a === void 0 ? void 0 : _a.length) === 64)
87
+ return initialAccount.xpub;
88
+ const { xpubOrAddress } = (0, index_1.decodeAccountId)(initialAccount.id);
89
+ if (xpubOrAddress.length === 64)
90
+ return xpubOrAddress;
91
+ }
92
+ throw Error("[ton] pubkey was not properly restored");
93
+ }
94
+ exports.sync = (0, jsHelpers_1.makeSync)({ getAccountShape: exports.getAccountShape, postSync });
95
+ //# sourceMappingURL=synchronisation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"synchronisation.js","sourceRoot":"","sources":["../src/synchronisation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kEAA0F;AAC1F,yEAAgG;AAChG,yCAAqC;AAErC,gEAAqC;AACrC,6DAAqC;AACrC,oDAAoF;AAEpF,oDAAyE;AAGlE,MAAM,eAAe,GAA6B,CAAM,IAAI,EAAC,EAAE;;IACpE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,cAAc,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC;IAEzE,MAAM,SAAS,GAAG,kBAAkB,CAAC,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,SAAS,EAAE,cAAc,CAAC,CAAC;IAEtE,MAAM,WAAW,GAAG,MAAM,IAAA,0BAAoB,GAAE,CAAC;IACjD,MAAM,SAAS,GAAG,IAAA,uBAAe,EAAC;QAChC,IAAI,EAAE,IAAI;QACV,OAAO,EAAE,GAAG;QACZ,UAAU,EAAE,QAAQ,CAAC,EAAE;QACvB,aAAa,EAAE,SAAS;QACxB,cAAc;KACf,CAAC,CAAC;IAEH,IAAA,UAAG,EAAC,OAAO,EAAE,gCAAgC,OAAO,EAAE,CAAC,CAAC;IAExD,MAAM,MAAM,GAAwB,EAAE,YAAY,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC;IAC3E,MAAM,MAAM,GAAG,CAAC,MAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE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AK,EAAE;YAAE,OAAO,cAAc,CAAC,IAAI,CAAC;QACnE,MAAM,EAAE,aAAa,EAAE,GAAG,IAAA,uBAAe,EAAC,cAAc,CAAC,EAAE,CAAC,CAAC;QAC7D,IAAI,aAAa,CAAC,MAAM,KAAK,EAAE;YAAE,OAAO,aAAa,CAAC;IACxD,CAAC;IACD,MAAM,KAAK,CAAC,wCAAwC,CAAC,CAAC;AACxD,CAAC;AAEY,QAAA,IAAI,GAAG,IAAA,oBAAQ,EAAC,EAAE,eAAe,EAAf,uBAAe,EAAE,QAAQ,EAAE,CAAC,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { Account } from "@ledgerhq/types-live";
2
+ import type { Transaction, TransactionRaw } from "./types";
3
+ export declare const formatTransaction: ({ recipient, useAllAmount, amount }: Transaction, account: Account) => string;
4
+ export declare const fromTransactionRaw: (tr: TransactionRaw) => Transaction;
5
+ declare const _default: {
6
+ formatTransaction: ({ recipient, useAllAmount, amount }: Transaction, account: Account) => string;
7
+ fromTransactionRaw: (tr: TransactionRaw) => Transaction;
8
+ toTransactionRaw: (transaction: Transaction) => TransactionRaw;
9
+ fromTransactionStatusRaw: (ts: import("@ledgerhq/types-live").TransactionStatusCommonRaw) => import("@ledgerhq/types-live").TransactionStatusCommon;
10
+ toTransactionStatusRaw: (ts: import("@ledgerhq/types-live").TransactionStatusCommon) => import("@ledgerhq/types-live").TransactionStatusCommonRaw;
11
+ formatTransactionStatus: (t: import("@ledgerhq/types-live").TransactionCommon, { errors, warnings, estimatedFees, amount, totalSpent }: import("@ledgerhq/types-live").TransactionStatusCommon, mainAccount: Account) => string;
12
+ };
13
+ export default _default;
14
+ //# sourceMappingURL=transaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../src/transaction.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEpD,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE3D,eAAO,MAAM,iBAAiB,wCACS,WAAW,WACvC,OAAO,KACf,MAYa,CAAC;AAEjB,eAAO,MAAM,kBAAkB,OAAQ,cAAc,KAAG,WASvD,CAAC;;;;;;;;;AAcF,wBAOE"}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.fromTransactionRaw = exports.formatTransaction = void 0;
7
+ const index_1 = require("@ledgerhq/coin-framework/account/index");
8
+ const index_2 = require("@ledgerhq/coin-framework/currencies/index");
9
+ const formatters_1 = require("@ledgerhq/coin-framework/formatters");
10
+ const serialization_1 = require("@ledgerhq/coin-framework/serialization");
11
+ const bignumber_js_1 = __importDefault(require("bignumber.js"));
12
+ const formatTransaction = ({ recipient, useAllAmount, amount }, account) => `
13
+ SEND ${useAllAmount
14
+ ? "MAX"
15
+ : amount.isZero()
16
+ ? ""
17
+ : " " +
18
+ (0, index_2.formatCurrencyUnit)((0, index_1.getAccountCurrency)(account).units[0], amount, {
19
+ showCode: true,
20
+ disableRounding: true,
21
+ })}
22
+ TO ${recipient}`;
23
+ exports.formatTransaction = formatTransaction;
24
+ const fromTransactionRaw = (tr) => {
25
+ const common = (0, serialization_1.fromTransactionCommonRaw)(tr);
26
+ return Object.assign(Object.assign({}, common), { family: tr.family, fees: new bignumber_js_1.default(tr.fees), comment: tr.comment });
27
+ };
28
+ exports.fromTransactionRaw = fromTransactionRaw;
29
+ const toTransactionRaw = (transaction) => {
30
+ const common = (0, serialization_1.toTransactionCommonRaw)(transaction);
31
+ return Object.assign(Object.assign({}, common), { family: transaction.family, amount: transaction.amount.toFixed(), fees: transaction.fees.toFixed(), comment: transaction.comment });
32
+ };
33
+ exports.default = {
34
+ formatTransaction: exports.formatTransaction,
35
+ fromTransactionRaw: exports.fromTransactionRaw,
36
+ toTransactionRaw,
37
+ fromTransactionStatusRaw: serialization_1.fromTransactionStatusRawCommon,
38
+ toTransactionStatusRaw: serialization_1.toTransactionStatusRawCommon,
39
+ formatTransactionStatus: formatters_1.formatTransactionStatus,
40
+ };
41
+ //# sourceMappingURL=transaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction.js","sourceRoot":"","sources":["../src/transaction.ts"],"names":[],"mappings":";;;;;;AAAA,kEAA4E;AAC5E,qEAA+E;AAC/E,oEAA8E;AAC9E,0EAKgD;AAEhD,gEAAqC;AAG9B,MAAM,iBAAiB,GAAG,CAC/B,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAe,EAChD,OAAgB,EACR,EAAE,CAAC;OAEX,YAAY;IACV,CAAC,CAAC,KAAK;IACP,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE;QACf,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,GAAG;YACH,IAAA,0BAAkB,EAAC,IAAA,0BAAkB,EAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE;gBAC/D,QAAQ,EAAE,IAAI;gBACd,eAAe,EAAE,IAAI;aACtB,CACT;KACK,SAAS,EAAE,CAAC;AAfJ,QAAA,iBAAiB,qBAeb;AAEV,MAAM,kBAAkB,GAAG,CAAC,EAAkB,EAAe,EAAE;IACpE,MAAM,MAAM,GAAG,IAAA,wCAAwB,EAAC,EAAE,CAAC,CAAC;IAE5C,uCACK,MAAM,KACT,MAAM,EAAE,EAAE,CAAC,MAAM,EACjB,IAAI,EAAE,IAAI,sBAAS,CAAC,EAAE,CAAC,IAAI,CAAC,EAC5B,OAAO,EAAE,EAAE,CAAC,OAAO,IACnB;AACJ,CAAC,CAAC;AATW,QAAA,kBAAkB,sBAS7B;AAEF,MAAM,gBAAgB,GAAG,CAAC,WAAwB,EAAkB,EAAE;IACpE,MAAM,MAAM,GAAG,IAAA,sCAAsB,EAAC,WAAW,CAAC,CAAC;IAEnD,uCACK,MAAM,KACT,MAAM,EAAE,WAAW,CAAC,MAAM,EAC1B,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,OAAO,EAAE,EACpC,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE,EAChC,OAAO,EAAE,WAAW,CAAC,OAAO,IAC5B;AACJ,CAAC,CAAC;AAEF,kBAAe;IACb,iBAAiB,EAAjB,yBAAiB;IACjB,kBAAkB,EAAlB,0BAAkB;IAClB,gBAAgB;IAChB,wBAAwB,EAAxB,8CAAwB;IACxB,sBAAsB,EAAtB,4CAAsB;IACtB,uBAAuB,EAAvB,oCAAuB;CACxB,CAAC"}
package/lib/types.d.ts ADDED
@@ -0,0 +1,65 @@
1
+ import { Operation, TransactionCommon, TransactionCommonRaw, TransactionStatusCommon, TransactionStatusCommonRaw } from "@ledgerhq/types-live";
2
+ import { Address, SendMode, StateInit } from "@ton/core";
3
+ import { Cell } from "@ton/ton";
4
+ import BigNumber from "bignumber.js";
5
+ type FamilyType = "ton";
6
+ export interface TonComment {
7
+ isEncrypted: boolean;
8
+ text: string;
9
+ }
10
+ export type Transaction = TransactionCommon & {
11
+ family: FamilyType;
12
+ fees: BigNumber;
13
+ comment: TonComment;
14
+ };
15
+ export type TransactionRaw = TransactionCommonRaw & {
16
+ family: FamilyType;
17
+ fees: string;
18
+ comment: TonComment;
19
+ };
20
+ export type TransactionStatus = TransactionStatusCommon;
21
+ export type TransactionStatusRaw = TransactionStatusCommonRaw;
22
+ export type TonOperation = Operation<TonOperationExtra>;
23
+ export type TonPayloadJettonTransfer = {
24
+ type: "jetton-transfer";
25
+ queryId: bigint | null;
26
+ amount: bigint;
27
+ destination: Address;
28
+ responseDestination: Address;
29
+ customPayload: TonCell | null;
30
+ forwardAmount: bigint;
31
+ forwardPayload: TonCell | null;
32
+ };
33
+ export type TonPayloadNftTransfer = {
34
+ type: "nft-transfer";
35
+ queryId: bigint | null;
36
+ newOwner: Address;
37
+ responseDestination: Address;
38
+ customPayload: TonCell | null;
39
+ forwardAmount: bigint;
40
+ forwardPayload: TonCell | null;
41
+ };
42
+ export type TonPayloadComment = {
43
+ type: "comment";
44
+ text: string;
45
+ };
46
+ export type TonPayloadFormat = TonPayloadComment | TonPayloadJettonTransfer | TonPayloadNftTransfer;
47
+ export interface TonTransaction {
48
+ to: Address;
49
+ sendMode: SendMode;
50
+ seqno: number;
51
+ timeout: number;
52
+ bounce: boolean;
53
+ amount: bigint;
54
+ stateInit?: StateInit;
55
+ payload?: TonPayloadFormat;
56
+ }
57
+ export interface TonCell extends Cell {
58
+ }
59
+ export type TonOperationExtra = {
60
+ comment: TonComment;
61
+ lt: string;
62
+ explorerHash: string;
63
+ };
64
+ export {};
65
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,oBAAoB,EACpB,uBAAuB,EACvB,0BAA0B,EAC3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,KAAK,UAAU,GAAG,KAAK,CAAC;AAIxB,MAAM,WAAW,UAAU;IACzB,WAAW,EAAE,OAAO,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,WAAW,GAAG,iBAAiB,GAAG;IAC5C,MAAM,EAAE,UAAU,CAAC;IACnB,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,UAAU,CAAC;CACrB,CAAC;AACF,MAAM,MAAM,cAAc,GAAG,oBAAoB,GAAG;IAClD,MAAM,EAAE,UAAU,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,UAAU,CAAC;CACrB,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AE,gBAAgB,CAAC;CAC5B;AAED,MAAM,WAAW,OAAQ,SAAQ,IAAI;CAAG;AAExC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,EAAE,UAAU,CAAC;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC"}
package/lib/types.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/lib/utils.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ import { Account } from "@ledgerhq/types-live";
2
+ import BigNumber from "bignumber.js";
3
+ import { TonComment, TonTransaction, Transaction } from "./types";
4
+ export declare const isAddressValid: (recipient: string) => boolean;
5
+ export declare const addressesAreEqual: (addr1: string, addr2: string) => boolean;
6
+ export declare const buildTonTransaction: (transaction: Transaction, seqno: number) => TonTransaction;
7
+ export declare const commentIsValid: (msg: TonComment) => boolean;
8
+ export declare const getTransferExpirationTime: () => number;
9
+ export declare const getTonEstimatedFees: (account: Account, needsInit: boolean, tx: TonTransaction) => Promise<BigNumber>;
10
+ export declare const getLedgerTonPath: (path: string) => number[];
11
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAElE,eAAO,MAAM,cAAc,cAAe,MAAM,YAS/C,CAAC;AAEF,eAAO,MAAM,iBAAiB,UAAW,MAAM,SAAS,MAAM,YAU7D,CAAC;AAEF,eAAO,MAAM,mBAAmB,gBAAiB,WAAW,SAAS,MAAM,KAAG,cA+B7E,CAAC;AAGF,eAAO,MAAM,cAAc,QAAS,UAAU,YACiC,CAAC;AAGhF,eAAO,MAAM,yBAAyB,cAA2C,CAAC;AAElF,eAAO,MAAM,mBAAmB,YACrB,OAAO,aACL,OAAO,MACd,cAAc,uBA8BnB,CAAC;AAEF,eAAO,MAAM,gBAAgB,SAAU,MAAM,KAAG,MAAM,EAcrD,CAAC"}
package/lib/utils.js ADDED
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.getLedgerTonPath = exports.getTonEstimatedFees = exports.getTransferExpirationTime = exports.commentIsValid = exports.buildTonTransaction = exports.addressesAreEqual = exports.isAddressValid = void 0;
16
+ const index_1 = require("@ledgerhq/coin-framework/account/index");
17
+ const ton_1 = require("@ton/ton");
18
+ const bignumber_js_1 = __importDefault(require("bignumber.js"));
19
+ const api_1 = require("./bridge/bridgeHelpers/api");
20
+ const isAddressValid = (recipient) => {
21
+ try {
22
+ return Boolean((ton_1.Address.isRaw(recipient) || ton_1.Address.isFriendly(recipient)) &&
23
+ ton_1.Address.parse(recipient));
24
+ }
25
+ catch (_a) {
26
+ return false;
27
+ }
28
+ };
29
+ exports.isAddressValid = isAddressValid;
30
+ const addressesAreEqual = (addr1, addr2) => {
31
+ try {
32
+ return ((0, exports.isAddressValid)(addr1) &&
33
+ (0, exports.isAddressValid)(addr2) &&
34
+ ton_1.Address.parse(addr1).equals(ton_1.Address.parse(addr2)));
35
+ }
36
+ catch (_a) {
37
+ return false;
38
+ }
39
+ };
40
+ exports.addressesAreEqual = addressesAreEqual;
41
+ const buildTonTransaction = (transaction, seqno) => {
42
+ const { useAllAmount, amount, comment, recipient } = transaction;
43
+ let recipientParsed = recipient;
44
+ // if recipient is not valid calculate fees with empty address
45
+ // we handle invalid addresses in account bridge
46
+ try {
47
+ ton_1.Address.parse(recipientParsed);
48
+ }
49
+ catch (_a) {
50
+ recipientParsed = new ton_1.Address(0, Buffer.alloc(32)).toRawString();
51
+ }
52
+ const finalAmount = useAllAmount ? BigInt(0) : BigInt(amount.toFixed());
53
+ const tonTransaction = {
54
+ to: ton_1.Address.parse(recipientParsed),
55
+ seqno,
56
+ amount: finalAmount,
57
+ bounce: ton_1.Address.isFriendly(recipientParsed)
58
+ ? ton_1.Address.parseFriendly(recipientParsed).isBounceable
59
+ : true,
60
+ timeout: (0, exports.getTransferExpirationTime)(),
61
+ sendMode: useAllAmount
62
+ ? ton_1.SendMode.CARRY_ALL_REMAINING_BALANCE
63
+ : ton_1.SendMode.IGNORE_ERRORS + ton_1.SendMode.PAY_GAS_SEPARATELY,
64
+ };
65
+ if (comment.text.length) {
66
+ tonTransaction.payload = { type: "comment", text: comment.text };
67
+ }
68
+ return tonTransaction;
69
+ };
70
+ exports.buildTonTransaction = buildTonTransaction;
71
+ // max length is 120 and only ascii allowed
72
+ const commentIsValid = (msg) => !msg.isEncrypted && msg.text.length <= 120 && /^[\x20-\x7F]*$/.test(msg.text);
73
+ exports.commentIsValid = commentIsValid;
74
+ // 1 minute
75
+ const getTransferExpirationTime = () => Math.floor(Date.now() / 1000 + 60);
76
+ exports.getTransferExpirationTime = getTransferExpirationTime;
77
+ const getTonEstimatedFees = (account, needsInit, tx) => __awaiter(void 0, void 0, void 0, function* () {
78
+ var _a, _b;
79
+ const { xpubOrAddress: pubKey } = (0, index_1.decodeAccountId)(account.id);
80
+ if (pubKey.length !== 64)
81
+ throw Error("[ton] pubKey can't be found");
82
+ if (tx.payload && ((_a = tx.payload) === null || _a === void 0 ? void 0 : _a.type) !== "comment") {
83
+ throw Error("[ton] payload kind not expected");
84
+ }
85
+ const contract = ton_1.WalletContractV4.create({ workchain: 0, publicKey: Buffer.from(pubKey, "hex") });
86
+ const transfer = contract.createTransfer({
87
+ seqno: tx.seqno,
88
+ secretKey: Buffer.alloc(64), // secretKey set to 0, signature is not verified
89
+ messages: [
90
+ (0, ton_1.internal)({
91
+ bounce: tx.bounce,
92
+ to: tx.to,
93
+ value: tx.amount,
94
+ body: ((_b = tx.payload) === null || _b === void 0 ? void 0 : _b.text) ? (0, ton_1.comment)(tx.payload.text) : undefined,
95
+ }),
96
+ ],
97
+ sendMode: tx.sendMode,
98
+ });
99
+ const initCode = needsInit ? contract.init.code.toBoc().toString("base64") : undefined;
100
+ const initData = needsInit ? contract.init.data.toBoc().toString("base64") : undefined;
101
+ const fee = yield (0, api_1.estimateFee)(account.freshAddress, transfer.toBoc().toString("base64"), initCode, initData);
102
+ return (0, bignumber_js_1.default)(fee.fwd_fee + fee.gas_fee + fee.in_fwd_fee + fee.storage_fee);
103
+ });
104
+ exports.getTonEstimatedFees = getTonEstimatedFees;
105
+ const getLedgerTonPath = (path) => {
106
+ const numPath = [];
107
+ if (!path)
108
+ throw Error("[ton] Path is empty");
109
+ if (path.startsWith("m/"))
110
+ path = path.slice(2);
111
+ const pathEntries = path.split("/");
112
+ if (pathEntries.length !== 6)
113
+ throw Error(`[ton] Path length is not right ${path}`);
114
+ for (const entry of pathEntries) {
115
+ if (!entry.endsWith("'"))
116
+ throw Error(`[ton] Path entry is not hardened ${path}`);
117
+ const num = parseInt(entry.slice(0, entry.length - 1));
118
+ if (!Number.isInteger(num) || num < 0 || num >= 0x80000000)
119
+ throw Error(`[ton] Path entry is not right ${path}`);
120
+ numPath.push(num);
121
+ }
122
+ return numPath;
123
+ };
124
+ exports.getLedgerTonPath = getLedgerTonPath;
125
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kEAAyE;AAEzE,kCAAgG;AAChG,gEAAqC;AACrC,oDAAyD;AAGlD,MAAM,cAAc,GAAG,CAAC,SAAiB,EAAE,EAAE;IAClD,IAAI,CAAC;QACH,OAAO,OAAO,CACZ,CAAC,aAAU,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,aAAU,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;YAC/D,aAAU,CAAC,KAAK,CAAC,SAAS,CAAC,CAC9B,CAAC;IACJ,CAAC;IAAC,WAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC,CAAC;AATW,QAAA,cAAc,kBASzB;AAEK,MAAM,iBAAiB,GAAG,CAAC,KAAa,EAAE,KAAa,EAAE,EAAE;IAChE,IAAI,CAAC;QACH,OAAO,CACL,IAAA,sBAAc,EAAC,KAAK,CAAC;YACrB,IAAA,sBAAc,EAAC,KAAK,CAAC;YACrB,aAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,aAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CACxD,CAAC;IACJ,CAAC;IAAC,WAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC,CAAC;AAVW,QAAA,iBAAiB,qBAU5B;AAEK,MAAM,mBAAmB,GAAG,CAAC,WAAwB,EAAE,KAAa,EAAkB,EAAE;IAC7F,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,WAAW,CAAC;IACjE,IAAI,eAAe,GAAG,SAAS,CAAC;IAChC,8DAA8D;IAC9D,gDAAgD;IAChD,IAAI,CAAC;QAC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QAChC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC;YAAE,MAAM,KAAK,CAAC,oCAAoC,IAAI,EAAE,CAAC,CAAC;QAClF,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;QACvD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,GAAG,IAAI,UAAU;YACxD,MAAM,KAAK,CAAC,iCAAiC,IAAI,EAAE,CAAC,CAAC;QACvD,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpB,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAdW,QAAA,gBAAgB,oBAc3B"}
@@ -0,0 +1,4 @@
1
+ export declare const API_TON_ENDPOINT = "https://ton.coin.ledger.com/api/v3";
2
+ declare const mockServer: import("msw/lib/node").SetupServerApi;
3
+ export default mockServer;
4
+ //# sourceMappingURL=api.fixtures.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.fixtures.d.ts","sourceRoot":"","sources":["../../../src/__tests__/fixtures/api.fixtures.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,gBAAgB,uCAAuC,CAAC;AAyBrE,QAAA,MAAM,UAAU,uCAA2B,CAAC;AAE5C,eAAe,UAAU,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { HttpResponse, http } from "msw";
2
+ import { setupServer } from "msw/node";
3
+ import { lastBlockNumber, tonAccount, tonEstimateFee, tonTransactionResponse, tonWallet, } from "./common.fixtures";
4
+ // Define the mock base URL for the TON API
5
+ export const API_TON_ENDPOINT = "https://ton.coin.ledger.com/api/v3";
6
+ // Create request handlers for the mock server
7
+ const handlers = [
8
+ // Handle GET request for masterchainInfo endpoint
9
+ http.get(`${API_TON_ENDPOINT}/masterchainInfo`, () => {
10
+ return HttpResponse.json(lastBlockNumber);
11
+ }),
12
+ // Handle GET request for transactions endpoint
13
+ http.get(`${API_TON_ENDPOINT}/transactions`, () => {
14
+ return HttpResponse.json(tonTransactionResponse);
15
+ }),
16
+ // Handle GET request for account endpoint
17
+ http.get(`${API_TON_ENDPOINT}/account`, () => {
18
+ return HttpResponse.json(tonAccount);
19
+ }),
20
+ // Handle GET request for wallet endpoint
21
+ http.get(`${API_TON_ENDPOINT}/wallet`, () => {
22
+ return HttpResponse.json(tonWallet);
23
+ }),
24
+ // Handle POST request for estimate fee endpoint
25
+ http.post(`${API_TON_ENDPOINT}/estimateFee`, () => HttpResponse.json(tonEstimateFee)),
26
+ ];
27
+ // Set up the mock server with the defined handlers
28
+ const mockServer = setupServer(...handlers);
29
+ export default mockServer;
30
+ //# sourceMappingURL=api.fixtures.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.fixtures.js","sourceRoot":"","sources":["../../../src/__tests__/fixtures/api.fixtures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EACL,eAAe,EACf,UAAU,EACV,cAAc,EACd,sBAAsB,EACtB,SAAS,GACV,MAAM,mBAAmB,CAAC;AAE3B,2CAA2C;AAC3C,MAAM,CAAC,MAAM,gBAAgB,GAAG,oCAAoC,CAAC;AAErE,8CAA8C;AAC9C,MAAM,QAAQ,GAAG;IACf,kDAAkD;IAClD,IAAI,CAAC,GAAG,CAAC,GAAG,gBAAgB,kBAAkB,EAAE,GAAG,EAAE;QACnD,OAAO,YAAY,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAC5C,CAAC,CAAC;IACF,+CAA+C;IAC/C,IAAI,CAAC,GAAG,CAAC,GAAG,gBAAgB,eAAe,EAAE,GAAG,EAAE;QAChD,OAAO,YAAY,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;IACnD,CAAC,CAAC;IACF,0CAA0C;IAC1C,IAAI,CAAC,GAAG,CAAC,GAAG,gBAAgB,UAAU,EAAE,GAAG,EAAE;QAC3C,OAAO,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACvC,CAAC,CAAC;IACF,yCAAyC;IACzC,IAAI,CAAC,GAAG,CAAC,GAAG,gBAAgB,SAAS,EAAE,GAAG,EAAE;QAC1C,OAAO,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACtC,CAAC,CAAC;IACF,gDAAgD;IAChD,IAAI,CAAC,IAAI,CAAC,GAAG,gBAAgB,cAAc,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;CACtF,CAAC;AAEF,mDAAmD;AACnD,MAAM,UAAU,GAAG,WAAW,CAAC,GAAG,QAAQ,CAAC,CAAC;AAE5C,eAAe,UAAU,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { Account } from "@ledgerhq/types-live";
2
+ import BigNumber from "bignumber.js";
3
+ import { TonAccountInfo, TonResponseEstimateFee, TonResponseWalletInfo, TonTransactionsList } from "../../bridge/bridgeHelpers/api.types";
4
+ import type { Transaction } from "../../types";
5
+ export declare const mockAddress = "UQDzd8aeBOU-jqYw_ZSuZjceI5p-F4b7HMprAsUJAtRPbMol";
6
+ export declare const mockAccountId = "js:2:ton:b19891a06654f21c64147550b3321bef63acd25b5dd61b688b022c42fac4831d:ton";
7
+ export declare const account: Account;
8
+ export declare const transaction: Transaction;
9
+ export declare const fees: {
10
+ in_fwd_fee: number;
11
+ storage_fee: number;
12
+ gas_fee: number;
13
+ fwd_fee: number;
14
+ };
15
+ export declare const totalFees: BigNumber;
16
+ export declare const lastBlockNumber: {
17
+ last: {
18
+ seqno: number;
19
+ };
20
+ first: {
21
+ seqno: number;
22
+ };
23
+ };
24
+ export declare const tonAccount: TonAccountInfo;
25
+ export declare const tonWallet: TonResponseWalletInfo;
26
+ export declare const tonEstimateFee: TonResponseEstimateFee;
27
+ export declare const tonTransactionResponse: TonTransactionsList;
28
+ export declare const accountInfo: TonAccountInfo;
29
+ //# sourceMappingURL=common.fixtures.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.fixtures.d.ts","sourceRoot":"","sources":["../../../src/__tests__/fixtures/common.fixtures.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,EACpB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,eAAO,MAAM,WAAW,qDAAqD,CAAC;AAC9E,eAAO,MAAM,aAAa,kFACuD,CAAC;AAElF,eAAO,MAAM,OAAO,SAUR,CAAC;AAEb,eAAO,MAAM,WAAW,aAQG,CAAC;AAE5B,eAAO,MAAM,IAAI;;;;;CAKhB,CAAC;AAEF,eAAO,MAAM,SAAS,WAErB,CAAC;AAEF,eAAO,MAAM,eAAe;;;;;;;CAO3B,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,cAMxB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,qBAQvB,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,sBAG5B,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,mBAkDpC,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,cAMzB,CAAC"}
@@ -0,0 +1,118 @@
1
+ import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets/currencies";
2
+ import BigNumber from "bignumber.js";
3
+ export const mockAddress = "UQDzd8aeBOU-jqYw_ZSuZjceI5p-F4b7HMprAsUJAtRPbMol";
4
+ export const mockAccountId = "js:2:ton:b19891a06654f21c64147550b3321bef63acd25b5dd61b688b022c42fac4831d:ton";
5
+ export const account = {
6
+ id: mockAccountId,
7
+ freshAddress: mockAddress,
8
+ freshAddressPath: "44'/607'/0'/0'/0'/0'",
9
+ xpub: "",
10
+ type: "Account",
11
+ currency: getCryptoCurrencyById("ton"),
12
+ spendableBalance: new BigNumber("1000000000"),
13
+ balance: new BigNumber("1000000000"),
14
+ seedIdentifier: "seedIdentifier",
15
+ };
16
+ export const transaction = {
17
+ mode: "send",
18
+ recipient: "UQCOvQLYvTcbi5tL9MaDNzuVl3-J3vATimNm9yO5XPafLfV4",
19
+ amount: new BigNumber("1000000"),
20
+ useAllAmount: false,
21
+ comment: { isEncrypted: false, text: "" },
22
+ payload: "",
23
+ family: "ton",
24
+ };
25
+ export const fees = {
26
+ in_fwd_fee: 10000,
27
+ storage_fee: 10000,
28
+ gas_fee: 10000,
29
+ fwd_fee: 10000,
30
+ };
31
+ export const totalFees = BigNumber(fees.fwd_fee + fees.gas_fee + fees.in_fwd_fee + fees.storage_fee);
32
+ export const lastBlockNumber = {
33
+ last: {
34
+ seqno: 38574413,
35
+ },
36
+ first: {
37
+ seqno: 3,
38
+ },
39
+ };
40
+ export const tonAccount = {
41
+ balance: "1000000000",
42
+ last_transaction_lt: "47055058000008",
43
+ last_transaction_hash: "psVQqt6rf/Lo6xyLzxx0to0jUIx8I2/4znOVf2KhAI0=",
44
+ status: "active",
45
+ seqno: 3,
46
+ };
47
+ export const tonWallet = {
48
+ balance: "7726736262",
49
+ wallet_type: "wallet v4 r2",
50
+ seqno: 22,
51
+ wallet_id: 698983191,
52
+ last_transaction_lt: "47055058000008",
53
+ last_transaction_hash: "psVQqt6rf/Lo6xyLzxx0to0jUIx8I2/4znOVf2KhAI0=",
54
+ status: "active",
55
+ };
56
+ export const tonEstimateFee = {
57
+ source_fees: fees,
58
+ destination_fees: [],
59
+ };
60
+ export const tonTransactionResponse = {
61
+ transactions: [
62
+ {
63
+ account: mockAddress,
64
+ hash: "hash",
65
+ lt: "lt",
66
+ now: 1718241443,
67
+ orig_status: "active",
68
+ end_status: "active",
69
+ total_fees: "0",
70
+ prev_trans_hash: "",
71
+ prev_trans_lt: "",
72
+ description: {
73
+ aborted: true,
74
+ destroyed: false,
75
+ compute_ph: {
76
+ success: false,
77
+ exit_code: -14,
78
+ },
79
+ credit_first: true,
80
+ },
81
+ block_ref: null,
82
+ in_msg: {
83
+ source: "0:959EAA8BD0E3A2662D814278D51A6F997946207D48478008BEBE7F45F3EF781F",
84
+ destination: mockAddress,
85
+ value: "13509565",
86
+ hash: "inMsgHash",
87
+ fwd_fee: "266669",
88
+ ihr_fee: "0",
89
+ created_lt: "47055058000007",
90
+ created_at: "1718241443",
91
+ opcode: "0xd53276db",
92
+ ihr_disabled: true,
93
+ bounce: false,
94
+ bounced: false,
95
+ import_fee: null,
96
+ message_content: {
97
+ hash: "Qa0w2xg42wA9taurO/aCVOqGTzjOeP3EpzD2Sl7tTss=",
98
+ body: "te6cckEBAQEADgAAGNUydtsAAAAAAAAAAfRC8y4=",
99
+ decoded: null,
100
+ },
101
+ init_state: null,
102
+ },
103
+ out_msgs: [],
104
+ account_state_before: null,
105
+ account_state_after: null,
106
+ mc_block_seqno: 3,
107
+ },
108
+ ],
109
+ address_book: {},
110
+ };
111
+ export const accountInfo = {
112
+ balance: "7726736262",
113
+ last_transaction_lt: "47055058000008",
114
+ last_transaction_hash: "lastTransactionHash",
115
+ status: "active",
116
+ seqno: 22,
117
+ };
118
+ //# sourceMappingURL=common.fixtures.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.fixtures.js","sourceRoot":"","sources":["../../../src/__tests__/fixtures/common.fixtures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAE1E,OAAO,SAAS,MAAM,cAAc,CAAC;AASrC,MAAM,CAAC,MAAM,WAAW,GAAG,kDAAkD,CAAC;AAC9E,MAAM,CAAC,MAAM,aAAa,GACxB,+EAA+E,CAAC;AAElF,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,EAAE,EAAE,aAAa;IACjB,YAAY,EAAE,WAA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AQ,EAAE,EAAE;YACZ,oBAAoB,EAAE,IAAI;YAC1B,mBAAmB,EAAE,IAAI;YACzB,cAAc,EAAE,CAAC;SAClB;KACF;IACD,YAAY,EAAE,EAAE;CACjB,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAmB;IACzC,OAAO,EAAE,YAAY;IACrB,mBAAmB,EAAE,gBAAgB;IACrC,qBAAqB,EAAE,qBAAqB;IAC5C,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,EAAE;CACV,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { DatasetTest } from "@ledgerhq/types-live";
2
+ import { Transaction } from "../../types";
3
+ export declare const dataset: DatasetTest<Transaction>;
4
+ /**
5
+ * NOTE: if tests are added to this file,
6
+ * like done in libs/coin-polkadot/src/bridge.integration.test.ts for example,
7
+ * this file fill need to be imported in ledger-live-common
8
+ * libs/ledger-live-common/src/families/ton/bridge.integration.test.ts
9
+ * like done for polkadot.
10
+ * cf.
11
+ * - libs/coin-polkadot/src/bridge.integration.test.ts
12
+ * - libs/ledger-live-common/src/families/polkadot/bridge.integration.test.ts
13
+ */
14
+ //# sourceMappingURL=bridge.integration.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bridge.integration.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/integration/bridge.integration.test.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAInE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAiH1C,eAAO,MAAM,OAAO,EAAE,WAAW,CAAC,WAAW,CAK5C,CAAC;AAEF;;;;;;;;;GASG"}