@ledgerhq/coin-mina 1.1.0-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 (414) hide show
  1. package/.eslintrc.js +20 -0
  2. package/.turbo/turbo-build.log +4 -0
  3. package/.unimportedrc.json +24 -0
  4. package/CHANGELOG.md +15 -0
  5. package/LICENSE.txt +21 -0
  6. package/jest.config.js +8 -0
  7. package/jest.integ.config.js +8 -0
  8. package/lib/api/index.d.ts +13 -0
  9. package/lib/api/index.d.ts.map +1 -0
  10. package/lib/api/index.integ.test.d.ts +2 -0
  11. package/lib/api/index.integ.test.d.ts.map +1 -0
  12. package/lib/api/index.integ.test.js +57 -0
  13. package/lib/api/index.integ.test.js.map +1 -0
  14. package/lib/api/index.js +91 -0
  15. package/lib/api/index.js.map +1 -0
  16. package/lib/api/rosetta/index.d.ts +9 -0
  17. package/lib/api/rosetta/index.d.ts.map +1 -0
  18. package/lib/api/rosetta/index.js +90 -0
  19. package/lib/api/rosetta/index.js.map +1 -0
  20. package/lib/api/rosetta/types.d.ts +143 -0
  21. package/lib/api/rosetta/types.d.ts.map +1 -0
  22. package/lib/api/rosetta/types.js +3 -0
  23. package/lib/api/rosetta/types.js.map +1 -0
  24. package/lib/api/rosetta/utils.d.ts +43 -0
  25. package/lib/api/rosetta/utils.d.ts.map +1 -0
  26. package/lib/api/rosetta/utils.js +60 -0
  27. package/lib/api/rosetta/utils.js.map +1 -0
  28. package/lib/api/rosetta/utils.test.d.ts +2 -0
  29. package/lib/api/rosetta/utils.test.d.ts.map +1 -0
  30. package/lib/api/rosetta/utils.test.js +82 -0
  31. package/lib/api/rosetta/utils.test.js.map +1 -0
  32. package/lib/bridge/broadcast.d.ts +6 -0
  33. package/lib/bridge/broadcast.d.ts.map +1 -0
  34. package/lib/bridge/broadcast.js +11 -0
  35. package/lib/bridge/broadcast.js.map +1 -0
  36. package/lib/bridge/broadcast.test.d.ts +2 -0
  37. package/lib/bridge/broadcast.test.d.ts.map +1 -0
  38. package/lib/bridge/broadcast.test.js +36 -0
  39. package/lib/bridge/broadcast.test.js.map +1 -0
  40. package/lib/bridge/buildTransaction.d.ts +4 -0
  41. package/lib/bridge/buildTransaction.d.ts.map +1 -0
  42. package/lib/bridge/buildTransaction.js +37 -0
  43. package/lib/bridge/buildTransaction.js.map +1 -0
  44. package/lib/bridge/buildTransaction.test.d.ts +2 -0
  45. package/lib/bridge/buildTransaction.test.d.ts.map +1 -0
  46. package/lib/bridge/buildTransaction.test.js +57 -0
  47. package/lib/bridge/buildTransaction.test.js.map +1 -0
  48. package/lib/bridge/cli-transaction.d.ts +18 -0
  49. package/lib/bridge/cli-transaction.d.ts.map +1 -0
  50. package/lib/bridge/cli-transaction.js +37 -0
  51. package/lib/bridge/cli-transaction.js.map +1 -0
  52. package/lib/bridge/createTransaction.d.ts +4 -0
  53. package/lib/bridge/createTransaction.d.ts.map +1 -0
  54. package/lib/bridge/createTransaction.js +21 -0
  55. package/lib/bridge/createTransaction.js.map +1 -0
  56. package/lib/bridge/createTransaction.test.d.ts +2 -0
  57. package/lib/bridge/createTransaction.test.d.ts.map +1 -0
  58. package/lib/bridge/createTransaction.test.js +24 -0
  59. package/lib/bridge/createTransaction.test.js.map +1 -0
  60. package/lib/bridge/deviceTransactionConfig.d.ts +11 -0
  61. package/lib/bridge/deviceTransactionConfig.d.ts.map +1 -0
  62. package/lib/bridge/deviceTransactionConfig.js +8 -0
  63. package/lib/bridge/deviceTransactionConfig.js.map +1 -0
  64. package/lib/bridge/errors.d.ts +10 -0
  65. package/lib/bridge/errors.d.ts.map +1 -0
  66. package/lib/bridge/errors.js +17 -0
  67. package/lib/bridge/errors.js.map +1 -0
  68. package/lib/bridge/estimateMaxSpendable.d.ts +5 -0
  69. package/lib/bridge/estimateMaxSpendable.d.ts.map +1 -0
  70. package/lib/bridge/estimateMaxSpendable.js +26 -0
  71. package/lib/bridge/estimateMaxSpendable.js.map +1 -0
  72. package/lib/bridge/getEstimatedFees.d.ts +8 -0
  73. package/lib/bridge/getEstimatedFees.d.ts.map +1 -0
  74. package/lib/bridge/getEstimatedFees.js +9 -0
  75. package/lib/bridge/getEstimatedFees.js.map +1 -0
  76. package/lib/bridge/getTransactionStatus.d.ts +5 -0
  77. package/lib/bridge/getTransactionStatus.d.ts.map +1 -0
  78. package/lib/bridge/getTransactionStatus.js +62 -0
  79. package/lib/bridge/getTransactionStatus.js.map +1 -0
  80. package/lib/bridge/getTransactionStatus.test.d.ts +2 -0
  81. package/lib/bridge/getTransactionStatus.test.d.ts.map +1 -0
  82. package/lib/bridge/getTransactionStatus.test.js +138 -0
  83. package/lib/bridge/getTransactionStatus.test.js.map +1 -0
  84. package/lib/bridge/index.d.ts +14 -0
  85. package/lib/bridge/index.d.ts.map +1 -0
  86. package/lib/bridge/index.js +59 -0
  87. package/lib/bridge/index.js.map +1 -0
  88. package/lib/bridge/index.test.d.ts +2 -0
  89. package/lib/bridge/index.test.d.ts.map +1 -0
  90. package/lib/bridge/index.test.js +32 -0
  91. package/lib/bridge/index.test.js.map +1 -0
  92. package/lib/bridge/prepareTransaction.d.ts +4 -0
  93. package/lib/bridge/prepareTransaction.d.ts.map +1 -0
  94. package/lib/bridge/prepareTransaction.js +23 -0
  95. package/lib/bridge/prepareTransaction.js.map +1 -0
  96. package/lib/bridge/prepareTransaction.test.d.ts +2 -0
  97. package/lib/bridge/prepareTransaction.test.d.ts.map +1 -0
  98. package/lib/bridge/prepareTransaction.test.js +43 -0
  99. package/lib/bridge/prepareTransaction.test.js.map +1 -0
  100. package/lib/bridge/signOperation.d.ts +12 -0
  101. package/lib/bridge/signOperation.d.ts.map +1 -0
  102. package/lib/bridge/signOperation.js +72 -0
  103. package/lib/bridge/signOperation.js.map +1 -0
  104. package/lib/bridge/signOperation.test.d.ts +2 -0
  105. package/lib/bridge/signOperation.test.d.ts.map +1 -0
  106. package/lib/bridge/signOperation.test.js +129 -0
  107. package/lib/bridge/signOperation.test.js.map +1 -0
  108. package/lib/bridge/synchronisation.d.ts +7 -0
  109. package/lib/bridge/synchronisation.d.ts.map +1 -0
  110. package/lib/bridge/synchronisation.js +155 -0
  111. package/lib/bridge/synchronisation.js.map +1 -0
  112. package/lib/bridge/synchronisation.test.d.ts +2 -0
  113. package/lib/bridge/synchronisation.test.d.ts.map +1 -0
  114. package/lib/bridge/synchronisation.test.js +164 -0
  115. package/lib/bridge/synchronisation.test.js.map +1 -0
  116. package/lib/bridge/transaction.d.ts +14 -0
  117. package/lib/bridge/transaction.d.ts.map +1 -0
  118. package/lib/bridge/transaction.js +61 -0
  119. package/lib/bridge/transaction.js.map +1 -0
  120. package/lib/common-logic/index.d.ts +9 -0
  121. package/lib/common-logic/index.d.ts.map +1 -0
  122. package/lib/common-logic/index.js +96 -0
  123. package/lib/common-logic/index.js.map +1 -0
  124. package/lib/common-logic/index.test.d.ts +2 -0
  125. package/lib/common-logic/index.test.d.ts.map +1 -0
  126. package/lib/common-logic/index.test.js +181 -0
  127. package/lib/common-logic/index.test.js.map +1 -0
  128. package/lib/config.d.ts +9 -0
  129. package/lib/config.d.ts.map +1 -0
  130. package/lib/config.js +16 -0
  131. package/lib/config.js.map +1 -0
  132. package/lib/consts.d.ts +16 -0
  133. package/lib/consts.d.ts.map +1 -0
  134. package/lib/consts.js +19 -0
  135. package/lib/consts.js.map +1 -0
  136. package/lib/signer/getAddress.d.ts +6 -0
  137. package/lib/signer/getAddress.d.ts.map +1 -0
  138. package/lib/signer/getAddress.js +22 -0
  139. package/lib/signer/getAddress.js.map +1 -0
  140. package/lib/signer/getAddress.test.d.ts +2 -0
  141. package/lib/signer/getAddress.test.d.ts.map +1 -0
  142. package/lib/signer/getAddress.test.js +106 -0
  143. package/lib/signer/getAddress.test.js.map +1 -0
  144. package/lib/signer/index.d.ts +3 -0
  145. package/lib/signer/index.d.ts.map +1 -0
  146. package/lib/signer/index.js +8 -0
  147. package/lib/signer/index.js.map +1 -0
  148. package/lib/test/bot-deviceActions.d.ts +4 -0
  149. package/lib/test/bot-deviceActions.d.ts.map +1 -0
  150. package/lib/test/bot-deviceActions.js +67 -0
  151. package/lib/test/bot-deviceActions.js.map +1 -0
  152. package/lib/test/bot-specs.d.ts +7 -0
  153. package/lib/test/bot-specs.d.ts.map +1 -0
  154. package/lib/test/bot-specs.js +107 -0
  155. package/lib/test/bot-specs.js.map +1 -0
  156. package/lib/test/bridgeDatasetTest.d.ts +4 -0
  157. package/lib/test/bridgeDatasetTest.d.ts.map +1 -0
  158. package/lib/test/bridgeDatasetTest.js +174 -0
  159. package/lib/test/bridgeDatasetTest.js.map +1 -0
  160. package/lib/test/fixtures.d.ts +55 -0
  161. package/lib/test/fixtures.d.ts.map +1 -0
  162. package/lib/test/fixtures.js +194 -0
  163. package/lib/test/fixtures.js.map +1 -0
  164. package/lib/test/index.d.ts +4 -0
  165. package/lib/test/index.d.ts.map +1 -0
  166. package/lib/test/index.js +20 -0
  167. package/lib/test/index.js.map +1 -0
  168. package/lib/test/testUtils.d.ts +2 -0
  169. package/lib/test/testUtils.d.ts.map +1 -0
  170. package/lib/test/testUtils.js +8 -0
  171. package/lib/test/testUtils.js.map +1 -0
  172. package/lib/test/testUtils.test.d.ts +2 -0
  173. package/lib/test/testUtils.test.d.ts.map +1 -0
  174. package/lib/test/testUtils.test.js +11 -0
  175. package/lib/test/testUtils.test.js.map +1 -0
  176. package/lib/types/common.d.ts +55 -0
  177. package/lib/types/common.d.ts.map +1 -0
  178. package/lib/types/common.js +3 -0
  179. package/lib/types/common.js.map +1 -0
  180. package/lib/types/index.d.ts +3 -0
  181. package/lib/types/index.d.ts.map +1 -0
  182. package/lib/types/index.js +19 -0
  183. package/lib/types/index.js.map +1 -0
  184. package/lib/types/signer.d.ts +32 -0
  185. package/lib/types/signer.d.ts.map +1 -0
  186. package/lib/types/signer.js +3 -0
  187. package/lib/types/signer.js.map +1 -0
  188. package/lib-es/api/index.d.ts +13 -0
  189. package/lib-es/api/index.d.ts.map +1 -0
  190. package/lib-es/api/index.integ.test.d.ts +2 -0
  191. package/lib-es/api/index.integ.test.d.ts.map +1 -0
  192. package/lib-es/api/index.integ.test.js +55 -0
  193. package/lib-es/api/index.integ.test.js.map +1 -0
  194. package/lib-es/api/index.js +79 -0
  195. package/lib-es/api/index.js.map +1 -0
  196. package/lib-es/api/rosetta/index.d.ts +8 -0
  197. package/lib-es/api/rosetta/index.d.ts.map +1 -0
  198. package/lib-es/api/rosetta/index.js +78 -0
  199. package/lib-es/api/rosetta/index.js.map +1 -0
  200. package/lib-es/api/rosetta/types.d.ts +143 -0
  201. package/lib-es/api/rosetta/types.d.ts.map +1 -0
  202. package/lib-es/api/rosetta/types.js +2 -0
  203. package/lib-es/api/rosetta/types.js.map +1 -0
  204. package/lib-es/api/rosetta/utils.d.ts +43 -0
  205. package/lib-es/api/rosetta/utils.d.ts.map +1 -0
  206. package/lib-es/api/rosetta/utils.js +54 -0
  207. package/lib-es/api/rosetta/utils.js.map +1 -0
  208. package/lib-es/api/rosetta/utils.test.d.ts +2 -0
  209. package/lib-es/api/rosetta/utils.test.d.ts.map +1 -0
  210. package/lib-es/api/rosetta/utils.test.js +80 -0
  211. package/lib-es/api/rosetta/utils.test.js.map +1 -0
  212. package/lib-es/bridge/broadcast.d.ts +6 -0
  213. package/lib-es/bridge/broadcast.d.ts.map +1 -0
  214. package/lib-es/bridge/broadcast.js +9 -0
  215. package/lib-es/bridge/broadcast.js.map +1 -0
  216. package/lib-es/bridge/broadcast.test.d.ts +2 -0
  217. package/lib-es/bridge/broadcast.test.d.ts.map +1 -0
  218. package/lib-es/bridge/broadcast.test.js +31 -0
  219. package/lib-es/bridge/broadcast.test.js.map +1 -0
  220. package/lib-es/bridge/buildTransaction.d.ts +4 -0
  221. package/lib-es/bridge/buildTransaction.d.ts.map +1 -0
  222. package/lib-es/bridge/buildTransaction.js +30 -0
  223. package/lib-es/bridge/buildTransaction.js.map +1 -0
  224. package/lib-es/bridge/buildTransaction.test.d.ts +2 -0
  225. package/lib-es/bridge/buildTransaction.test.d.ts.map +1 -0
  226. package/lib-es/bridge/buildTransaction.test.js +55 -0
  227. package/lib-es/bridge/buildTransaction.test.js.map +1 -0
  228. package/lib-es/bridge/cli-transaction.d.ts +18 -0
  229. package/lib-es/bridge/cli-transaction.d.ts.map +1 -0
  230. package/lib-es/bridge/cli-transaction.js +31 -0
  231. package/lib-es/bridge/cli-transaction.js.map +1 -0
  232. package/lib-es/bridge/createTransaction.d.ts +4 -0
  233. package/lib-es/bridge/createTransaction.d.ts.map +1 -0
  234. package/lib-es/bridge/createTransaction.js +14 -0
  235. package/lib-es/bridge/createTransaction.js.map +1 -0
  236. package/lib-es/bridge/createTransaction.test.d.ts +2 -0
  237. package/lib-es/bridge/createTransaction.test.d.ts.map +1 -0
  238. package/lib-es/bridge/createTransaction.test.js +19 -0
  239. package/lib-es/bridge/createTransaction.test.js.map +1 -0
  240. package/lib-es/bridge/deviceTransactionConfig.d.ts +11 -0
  241. package/lib-es/bridge/deviceTransactionConfig.d.ts.map +1 -0
  242. package/lib-es/bridge/deviceTransactionConfig.js +6 -0
  243. package/lib-es/bridge/deviceTransactionConfig.js.map +1 -0
  244. package/lib-es/bridge/errors.d.ts +10 -0
  245. package/lib-es/bridge/errors.d.ts.map +1 -0
  246. package/lib-es/bridge/errors.js +14 -0
  247. package/lib-es/bridge/errors.js.map +1 -0
  248. package/lib-es/bridge/estimateMaxSpendable.d.ts +5 -0
  249. package/lib-es/bridge/estimateMaxSpendable.d.ts.map +1 -0
  250. package/lib-es/bridge/estimateMaxSpendable.js +21 -0
  251. package/lib-es/bridge/estimateMaxSpendable.js.map +1 -0
  252. package/lib-es/bridge/getEstimatedFees.d.ts +8 -0
  253. package/lib-es/bridge/getEstimatedFees.d.ts.map +1 -0
  254. package/lib-es/bridge/getEstimatedFees.js +7 -0
  255. package/lib-es/bridge/getEstimatedFees.js.map +1 -0
  256. package/lib-es/bridge/getTransactionStatus.d.ts +5 -0
  257. package/lib-es/bridge/getTransactionStatus.d.ts.map +1 -0
  258. package/lib-es/bridge/getTransactionStatus.js +60 -0
  259. package/lib-es/bridge/getTransactionStatus.js.map +1 -0
  260. package/lib-es/bridge/getTransactionStatus.test.d.ts +2 -0
  261. package/lib-es/bridge/getTransactionStatus.test.d.ts.map +1 -0
  262. package/lib-es/bridge/getTransactionStatus.test.js +133 -0
  263. package/lib-es/bridge/getTransactionStatus.test.js.map +1 -0
  264. package/lib-es/bridge/index.d.ts +14 -0
  265. package/lib-es/bridge/index.d.ts.map +1 -0
  266. package/lib-es/bridge/index.js +50 -0
  267. package/lib-es/bridge/index.js.map +1 -0
  268. package/lib-es/bridge/index.test.d.ts +2 -0
  269. package/lib-es/bridge/index.test.d.ts.map +1 -0
  270. package/lib-es/bridge/index.test.js +30 -0
  271. package/lib-es/bridge/index.test.js.map +1 -0
  272. package/lib-es/bridge/prepareTransaction.d.ts +4 -0
  273. package/lib-es/bridge/prepareTransaction.d.ts.map +1 -0
  274. package/lib-es/bridge/prepareTransaction.js +16 -0
  275. package/lib-es/bridge/prepareTransaction.js.map +1 -0
  276. package/lib-es/bridge/prepareTransaction.test.d.ts +2 -0
  277. package/lib-es/bridge/prepareTransaction.test.d.ts.map +1 -0
  278. package/lib-es/bridge/prepareTransaction.test.js +38 -0
  279. package/lib-es/bridge/prepareTransaction.test.js.map +1 -0
  280. package/lib-es/bridge/signOperation.d.ts +12 -0
  281. package/lib-es/bridge/signOperation.d.ts.map +1 -0
  282. package/lib-es/bridge/signOperation.js +64 -0
  283. package/lib-es/bridge/signOperation.js.map +1 -0
  284. package/lib-es/bridge/signOperation.test.d.ts +2 -0
  285. package/lib-es/bridge/signOperation.test.d.ts.map +1 -0
  286. package/lib-es/bridge/signOperation.test.js +127 -0
  287. package/lib-es/bridge/signOperation.test.js.map +1 -0
  288. package/lib-es/bridge/synchronisation.d.ts +7 -0
  289. package/lib-es/bridge/synchronisation.d.ts.map +1 -0
  290. package/lib-es/bridge/synchronisation.js +147 -0
  291. package/lib-es/bridge/synchronisation.js.map +1 -0
  292. package/lib-es/bridge/synchronisation.test.d.ts +2 -0
  293. package/lib-es/bridge/synchronisation.test.d.ts.map +1 -0
  294. package/lib-es/bridge/synchronisation.test.js +159 -0
  295. package/lib-es/bridge/synchronisation.test.js.map +1 -0
  296. package/lib-es/bridge/transaction.d.ts +14 -0
  297. package/lib-es/bridge/transaction.d.ts.map +1 -0
  298. package/lib-es/bridge/transaction.js +53 -0
  299. package/lib-es/bridge/transaction.js.map +1 -0
  300. package/lib-es/common-logic/index.d.ts +9 -0
  301. package/lib-es/common-logic/index.d.ts.map +1 -0
  302. package/lib-es/common-logic/index.js +84 -0
  303. package/lib-es/common-logic/index.js.map +1 -0
  304. package/lib-es/common-logic/index.test.d.ts +2 -0
  305. package/lib-es/common-logic/index.test.d.ts.map +1 -0
  306. package/lib-es/common-logic/index.test.js +179 -0
  307. package/lib-es/common-logic/index.test.js.map +1 -0
  308. package/lib-es/config.d.ts +9 -0
  309. package/lib-es/config.d.ts.map +1 -0
  310. package/lib-es/config.js +11 -0
  311. package/lib-es/config.js.map +1 -0
  312. package/lib-es/consts.d.ts +16 -0
  313. package/lib-es/consts.d.ts.map +1 -0
  314. package/lib-es/consts.js +16 -0
  315. package/lib-es/consts.js.map +1 -0
  316. package/lib-es/signer/getAddress.d.ts +6 -0
  317. package/lib-es/signer/getAddress.d.ts.map +1 -0
  318. package/lib-es/signer/getAddress.js +17 -0
  319. package/lib-es/signer/getAddress.js.map +1 -0
  320. package/lib-es/signer/getAddress.test.d.ts +2 -0
  321. package/lib-es/signer/getAddress.test.d.ts.map +1 -0
  322. package/lib-es/signer/getAddress.test.js +101 -0
  323. package/lib-es/signer/getAddress.test.js.map +1 -0
  324. package/lib-es/signer/index.d.ts +3 -0
  325. package/lib-es/signer/index.d.ts.map +1 -0
  326. package/lib-es/signer/index.js +3 -0
  327. package/lib-es/signer/index.js.map +1 -0
  328. package/lib-es/test/bot-deviceActions.d.ts +4 -0
  329. package/lib-es/test/bot-deviceActions.d.ts.map +1 -0
  330. package/lib-es/test/bot-deviceActions.js +64 -0
  331. package/lib-es/test/bot-deviceActions.js.map +1 -0
  332. package/lib-es/test/bot-specs.d.ts +7 -0
  333. package/lib-es/test/bot-specs.d.ts.map +1 -0
  334. package/lib-es/test/bot-specs.js +102 -0
  335. package/lib-es/test/bot-specs.js.map +1 -0
  336. package/lib-es/test/bridgeDatasetTest.d.ts +4 -0
  337. package/lib-es/test/bridgeDatasetTest.d.ts.map +1 -0
  338. package/lib-es/test/bridgeDatasetTest.js +171 -0
  339. package/lib-es/test/bridgeDatasetTest.js.map +1 -0
  340. package/lib-es/test/fixtures.d.ts +55 -0
  341. package/lib-es/test/fixtures.d.ts.map +1 -0
  342. package/lib-es/test/fixtures.js +182 -0
  343. package/lib-es/test/fixtures.js.map +1 -0
  344. package/lib-es/test/index.d.ts +4 -0
  345. package/lib-es/test/index.d.ts.map +1 -0
  346. package/lib-es/test/index.js +4 -0
  347. package/lib-es/test/index.js.map +1 -0
  348. package/lib-es/test/testUtils.d.ts +2 -0
  349. package/lib-es/test/testUtils.d.ts.map +1 -0
  350. package/lib-es/test/testUtils.js +4 -0
  351. package/lib-es/test/testUtils.js.map +1 -0
  352. package/lib-es/test/testUtils.test.d.ts +2 -0
  353. package/lib-es/test/testUtils.test.d.ts.map +1 -0
  354. package/lib-es/test/testUtils.test.js +9 -0
  355. package/lib-es/test/testUtils.test.js.map +1 -0
  356. package/lib-es/types/common.d.ts +55 -0
  357. package/lib-es/types/common.d.ts.map +1 -0
  358. package/lib-es/types/common.js +2 -0
  359. package/lib-es/types/common.js.map +1 -0
  360. package/lib-es/types/index.d.ts +3 -0
  361. package/lib-es/types/index.d.ts.map +1 -0
  362. package/lib-es/types/index.js +3 -0
  363. package/lib-es/types/index.js.map +1 -0
  364. package/lib-es/types/signer.d.ts +32 -0
  365. package/lib-es/types/signer.d.ts.map +1 -0
  366. package/lib-es/types/signer.js +2 -0
  367. package/lib-es/types/signer.js.map +1 -0
  368. package/package.json +143 -0
  369. package/src/api/index.integ.test.ts +62 -0
  370. package/src/api/index.ts +120 -0
  371. package/src/api/rosetta/index.ts +110 -0
  372. package/src/api/rosetta/types.ts +156 -0
  373. package/src/api/rosetta/utils.test.ts +100 -0
  374. package/src/api/rosetta/utils.ts +71 -0
  375. package/src/bridge/broadcast.test.ts +35 -0
  376. package/src/bridge/broadcast.ts +17 -0
  377. package/src/bridge/buildTransaction.test.ts +68 -0
  378. package/src/bridge/buildTransaction.ts +34 -0
  379. package/src/bridge/cli-transaction.ts +43 -0
  380. package/src/bridge/createTransaction.test.ts +21 -0
  381. package/src/bridge/createTransaction.ts +19 -0
  382. package/src/bridge/deviceTransactionConfig.ts +15 -0
  383. package/src/bridge/errors.ts +16 -0
  384. package/src/bridge/estimateMaxSpendable.ts +31 -0
  385. package/src/bridge/getEstimatedFees.ts +17 -0
  386. package/src/bridge/getTransactionStatus.test.ts +175 -0
  387. package/src/bridge/getTransactionStatus.ts +87 -0
  388. package/src/bridge/index.test.ts +39 -0
  389. package/src/bridge/index.ts +72 -0
  390. package/src/bridge/prepareTransaction.test.ts +43 -0
  391. package/src/bridge/prepareTransaction.ts +24 -0
  392. package/src/bridge/signOperation.test.ts +158 -0
  393. package/src/bridge/signOperation.ts +112 -0
  394. package/src/bridge/synchronisation.test.ts +184 -0
  395. package/src/bridge/synchronisation.ts +168 -0
  396. package/src/bridge/transaction.ts +69 -0
  397. package/src/common-logic/index.test.ts +225 -0
  398. package/src/common-logic/index.ts +97 -0
  399. package/src/config.ts +21 -0
  400. package/src/consts.ts +18 -0
  401. package/src/signer/getAddress.test.ts +131 -0
  402. package/src/signer/getAddress.ts +24 -0
  403. package/src/signer/index.ts +3 -0
  404. package/src/test/bot-deviceActions.ts +73 -0
  405. package/src/test/bot-specs.ts +130 -0
  406. package/src/test/bridgeDatasetTest.ts +180 -0
  407. package/src/test/fixtures.ts +226 -0
  408. package/src/test/index.ts +3 -0
  409. package/src/test/testUtils.test.ts +9 -0
  410. package/src/test/testUtils.ts +3 -0
  411. package/src/types/common.ts +70 -0
  412. package/src/types/index.ts +2 -0
  413. package/src/types/signer.ts +29 -0
  414. package/tsconfig.json +13 -0
@@ -0,0 +1,112 @@
1
+ import { BigNumber } from "bignumber.js";
2
+ import { Observable } from "rxjs";
3
+ import { FeeNotLoaded } from "@ledgerhq/errors";
4
+ import type { MinaOperation, MinaSignedTransaction, Transaction } from "../types/common";
5
+ import type {
6
+ Account,
7
+ DeviceId,
8
+ SignOperationEvent,
9
+ OperationType,
10
+ AccountBridge,
11
+ } from "@ledgerhq/types-live";
12
+ import { encodeOperationId } from "@ledgerhq/coin-framework/operation";
13
+ import { MinaSignature, MinaSigner } from "../types/signer";
14
+ import { SignerContext } from "@ledgerhq/coin-framework/signer";
15
+ import { buildTransaction } from "./buildTransaction";
16
+ import { reEncodeRawSignature } from "../common-logic";
17
+ import invariant from "invariant";
18
+
19
+ export const buildOptimisticOperation = (
20
+ account: Account,
21
+ transaction: Transaction,
22
+ fee: BigNumber,
23
+ ): MinaOperation => {
24
+ let value = new BigNumber(transaction.amount).plus(fee);
25
+
26
+ if (transaction.fees?.accountCreationFee.gt(0)) {
27
+ value = value.minus(transaction.fees.accountCreationFee);
28
+ }
29
+
30
+ const type: OperationType = "OUT";
31
+
32
+ const operation: MinaOperation = {
33
+ id: encodeOperationId(account.id, "", type),
34
+ hash: "",
35
+ type,
36
+ value,
37
+ fee,
38
+ blockHash: null,
39
+ blockHeight: null,
40
+ senders: [account.freshAddress],
41
+ recipients: [transaction.recipient].filter(Boolean),
42
+ accountId: account.id,
43
+ date: new Date(),
44
+ extra: {
45
+ memo: transaction.memo,
46
+ accountCreationFee: transaction.fees.accountCreationFee.toString(),
47
+ },
48
+ };
49
+
50
+ return operation;
51
+ };
52
+
53
+ /**
54
+ * Sign Transaction with Ledger hardware
55
+ */
56
+ export const buildSignOperation =
57
+ (signerContext: SignerContext<MinaSigner>): AccountBridge<Transaction>["signOperation"] =>
58
+ ({
59
+ account,
60
+ transaction,
61
+ deviceId,
62
+ }: {
63
+ account: Account;
64
+ transaction: Transaction;
65
+ deviceId: DeviceId;
66
+ }): Observable<SignOperationEvent> =>
67
+ new Observable(o => {
68
+ async function main() {
69
+ o.next({ type: "device-signature-requested" });
70
+
71
+ if (!transaction.fees) {
72
+ throw new FeeNotLoaded();
73
+ }
74
+
75
+ const unsigned = await buildTransaction(account, transaction);
76
+
77
+ const { signature } = (await signerContext(deviceId, signer =>
78
+ signer.signTransaction(unsigned),
79
+ )) as MinaSignature;
80
+ invariant(signature, "signature should be defined if user accepted");
81
+ const encodedSignature = reEncodeRawSignature(signature);
82
+
83
+ const signedTransaction: MinaSignedTransaction = {
84
+ transaction: unsigned,
85
+ signature: encodedSignature,
86
+ };
87
+
88
+ o.next({ type: "device-signature-granted" });
89
+
90
+ const operation = buildOptimisticOperation(
91
+ account,
92
+ transaction,
93
+ transaction.fees.fee ?? new BigNumber(0),
94
+ );
95
+ const signedSerializedTx = JSON.stringify(signedTransaction);
96
+
97
+ o.next({
98
+ type: "signed",
99
+ signedOperation: {
100
+ operation,
101
+ signature: signedSerializedTx,
102
+ },
103
+ });
104
+ }
105
+
106
+ main().then(
107
+ () => o.complete(),
108
+ e => o.error(e),
109
+ );
110
+ });
111
+
112
+ export default buildSignOperation;
@@ -0,0 +1,184 @@
1
+ import { getAccountShape, mapRosettaTxnToOperation } from "./synchronisation";
2
+ jest.mock("@ledgerhq/coin-framework/account/accountId");
3
+ jest.mock("@ledgerhq/coin-framework/bridge/jsHelpers");
4
+ jest.mock("@ledgerhq/coin-framework/operation");
5
+ jest.mock("../api");
6
+
7
+ import { encodeAccountId } from "@ledgerhq/coin-framework/account/accountId";
8
+ import { mergeOps } from "@ledgerhq/coin-framework/bridge/jsHelpers";
9
+ import { encodeOperationId } from "@ledgerhq/coin-framework/operation";
10
+ import { getAccount, getTransactions, getBlockInfo } from "../api";
11
+ import BigNumber from "bignumber.js";
12
+ import {
13
+ createMockTxn,
14
+ createMockAccountInfo,
15
+ mockBlockInfo,
16
+ mockAccountData,
17
+ } from "../test/fixtures";
18
+
19
+ describe("synchronisation", () => {
20
+ beforeEach(() => {
21
+ jest.clearAllMocks();
22
+ });
23
+
24
+ describe("mapRosettaTxnToOperation", () => {
25
+ const mockAccountId = "account_id";
26
+ const mockAddress = "sender_address";
27
+
28
+ beforeEach(() => {
29
+ jest.spyOn({ getBlockInfo }, "getBlockInfo").mockResolvedValue(mockBlockInfo);
30
+ jest
31
+ .spyOn({ encodeOperationId }, "encodeOperationId")
32
+ .mockReturnValue("encoded_operation_id");
33
+ });
34
+
35
+ it("should map payment transaction (OUT)", async () => {
36
+ const mockTxn = createMockTxn({
37
+ type: "OUT",
38
+ senderAddress: mockAddress,
39
+ receiverAddress: "receiver_address",
40
+ status: "Success",
41
+ });
42
+
43
+ const result = await mapRosettaTxnToOperation(mockAccountId, mockAddress, mockTxn);
44
+
45
+ expect(result).toHaveLength(1);
46
+ expect(result[0]).toEqual({
47
+ id: "encoded_operation_id",
48
+ type: "OUT",
49
+ hash: "tx_hash",
50
+ value: new BigNumber(900),
51
+ fee: new BigNumber(-100),
52
+ blockHeight: 123,
53
+ hasFailed: false,
54
+ blockHash: "block_hash",
55
+ accountId: mockAccountId,
56
+ senders: [mockAddress],
57
+ recipients: ["receiver_address"],
58
+ date: new Date(1672531200000),
59
+ extra: {
60
+ memo: "test memo",
61
+ accountCreationFee: "0",
62
+ },
63
+ });
64
+ });
65
+
66
+ it("should map payment transaction (IN)", async () => {
67
+ const mockTxn = createMockTxn({
68
+ type: "IN",
69
+ senderAddress: "sender_other",
70
+ receiverAddress: mockAddress,
71
+ status: "Success",
72
+ });
73
+
74
+ const result = await mapRosettaTxnToOperation(mockAccountId, mockAddress, mockTxn);
75
+
76
+ expect(result).toHaveLength(1);
77
+ expect(result[0]).toEqual({
78
+ id: "encoded_operation_id",
79
+ type: "IN",
80
+ hash: "tx_hash",
81
+ value: new BigNumber(1000),
82
+ fee: new BigNumber(-100),
83
+ blockHeight: 123,
84
+ hasFailed: false,
85
+ blockHash: "block_hash",
86
+ accountId: mockAccountId,
87
+ senders: ["sender_other"],
88
+ recipients: [mockAddress],
89
+ date: new Date(1672531200000),
90
+ extra: {
91
+ memo: "test memo",
92
+ accountCreationFee: "0",
93
+ },
94
+ });
95
+ });
96
+
97
+ it("should map redelegate transaction", async () => {
98
+ const mockTxn = createMockTxn({
99
+ type: "REDELEGATE",
100
+ senderAddress: mockAddress,
101
+ receiverAddress: "not_used",
102
+ memo: "redelegate",
103
+ status: "Success",
104
+ });
105
+
106
+ const result = await mapRosettaTxnToOperation(mockAccountId, mockAddress, mockTxn);
107
+
108
+ expect(result).toHaveLength(1);
109
+ expect(result[0]).toEqual({
110
+ id: "encoded_operation_id",
111
+ type: "REDELEGATE",
112
+ hash: "tx_hash",
113
+ value: new BigNumber(0),
114
+ fee: new BigNumber(0),
115
+ blockHeight: 123,
116
+ hasFailed: false,
117
+ blockHash: "block_hash",
118
+ accountId: mockAccountId,
119
+ senders: [mockAddress],
120
+ recipients: ["unknown"],
121
+ date: new Date(1672531200000),
122
+ extra: {
123
+ memo: "redelegate",
124
+ accountCreationFee: "0",
125
+ },
126
+ });
127
+ });
128
+
129
+ it("should handle failed transactions", async () => {
130
+ const mockTxn = createMockTxn({
131
+ type: "OUT",
132
+ senderAddress: mockAddress,
133
+ receiverAddress: "receiver_address",
134
+ status: "Failed",
135
+ memo: "failed",
136
+ });
137
+
138
+ const result = await mapRosettaTxnToOperation(mockAccountId, mockAddress, mockTxn);
139
+
140
+ expect(result).toHaveLength(1);
141
+ expect(result[0].hasFailed).toBe(true);
142
+ });
143
+ });
144
+
145
+ describe("getAccountShape", () => {
146
+ beforeEach(() => {
147
+ jest.spyOn({ encodeAccountId }, "encodeAccountId").mockReturnValue("account_id");
148
+ jest.spyOn({ getAccount }, "getAccount").mockResolvedValue(mockAccountData);
149
+ jest.spyOn({ getTransactions }, "getTransactions").mockResolvedValue([]);
150
+ jest.spyOn({ mergeOps }, "mergeOps").mockReturnValue([]);
151
+ });
152
+
153
+ it("should get account shape with correct data", async () => {
154
+ const mockInfo = createMockAccountInfo();
155
+ const result = await getAccountShape(mockInfo, {
156
+ paginationConfig: {
157
+ operationsPerAccountId: {
158
+ account_id: 10,
159
+ },
160
+ },
161
+ });
162
+
163
+ expect(encodeAccountId).toHaveBeenCalledWith({
164
+ type: "js",
165
+ version: "2",
166
+ currencyId: "mina",
167
+ xpubOrAddress: "test_address",
168
+ derivationMode: "minabip44",
169
+ });
170
+
171
+ expect(getAccount).toHaveBeenCalledWith("test_address");
172
+ expect(getTransactions).toHaveBeenCalledWith("test_address", 0);
173
+
174
+ expect(result).toEqual({
175
+ id: "account_id",
176
+ balance: mockAccountData.balance,
177
+ spendableBalance: mockAccountData.spendableBalance,
178
+ blockHeight: mockAccountData.blockHeight,
179
+ operationsCount: 0,
180
+ operations: [],
181
+ });
182
+ });
183
+ });
184
+ });
@@ -0,0 +1,168 @@
1
+ import { encodeAccountId } from "@ledgerhq/coin-framework/account/accountId";
2
+ import type { GetAccountShape } from "@ledgerhq/coin-framework/bridge/jsHelpers";
3
+ import { makeSync, mergeOps } from "@ledgerhq/coin-framework/bridge/jsHelpers";
4
+ import { getAccount, getBlockInfo, getTransactions } from "../api";
5
+ import { MinaAccount, MinaOperation } from "../types/common";
6
+ import { encodeOperationId } from "@ledgerhq/coin-framework/operation";
7
+ import BigNumber from "bignumber.js";
8
+ import { log } from "@ledgerhq/logs";
9
+ import invariant from "invariant";
10
+ import { RosettaTransaction } from "../api/rosetta/types";
11
+
12
+ export const mapRosettaTxnToOperation = async (
13
+ accountId: string,
14
+ address: string,
15
+ txn: RosettaTransaction,
16
+ ): Promise<MinaOperation[]> => {
17
+ try {
18
+ const hash = txn.transaction.transaction_identifier.hash;
19
+ const blockHeight = txn.block_identifier.index;
20
+ const blockHash = txn.block_identifier.hash;
21
+ const date = new Date(txn.timestamp ?? (await getBlockInfo(blockHeight)).block.timestamp);
22
+ const memo = txn.transaction.metadata?.memo || "";
23
+
24
+ let value = new BigNumber(0);
25
+ let fee = new BigNumber(0);
26
+ let accountCreationFee = new BigNumber(0);
27
+
28
+ let fromAccount: string = "";
29
+ let toAccount: string = "";
30
+ let isSending = false;
31
+ let failed = false;
32
+ let redelegateTransaction = false;
33
+
34
+ for (const op of txn.transaction.operations) {
35
+ failed = failed || op.status === "Failed";
36
+ const opValue = failed ? new BigNumber(0) : new BigNumber(op.amount?.value ?? 0);
37
+ switch (op.type) {
38
+ case "fee_payment": {
39
+ fee = fee.plus(opValue.times(-1));
40
+ continue;
41
+ }
42
+ case "payment_receiver_inc": {
43
+ toAccount = op.account.address;
44
+ value = value.plus(opValue);
45
+ continue;
46
+ }
47
+ case "payment_source_dec": {
48
+ fromAccount = op.account.address;
49
+ if (fromAccount === address) {
50
+ isSending = true;
51
+ }
52
+ continue;
53
+ }
54
+ case "zkapp_fee_payer_dec": {
55
+ fromAccount = op.account.address;
56
+ continue;
57
+ }
58
+ case "zkapp_balance_update": {
59
+ toAccount = op.account.address;
60
+ value = value.plus(opValue);
61
+ continue;
62
+ }
63
+ case "delegate_change": {
64
+ fromAccount = op.account.address;
65
+ toAccount = op.metadata?.delegate_change_target || toAccount || "unknown";
66
+ redelegateTransaction = true;
67
+ continue;
68
+ }
69
+ case "account_creation_fee_via_payment": {
70
+ accountCreationFee = opValue.times(-1);
71
+ continue;
72
+ }
73
+ }
74
+ }
75
+
76
+ invariant(fromAccount, "mina: missing fromAccount");
77
+ invariant(toAccount, "mina: missing toAccount");
78
+
79
+ const op: MinaOperation = {
80
+ id: "",
81
+ type: "NONE",
82
+ hash,
83
+ value,
84
+ fee,
85
+ blockHeight,
86
+ hasFailed: failed,
87
+ blockHash,
88
+ accountId,
89
+ senders: [fromAccount],
90
+ recipients: [toAccount],
91
+ date,
92
+ extra: {
93
+ memo,
94
+ accountCreationFee: accountCreationFee.toString(),
95
+ },
96
+ };
97
+
98
+ const ops: MinaOperation[] = [];
99
+ if (isSending) {
100
+ const type = "OUT";
101
+ ops.push({
102
+ ...op,
103
+ value: value.minus(accountCreationFee).plus(fee),
104
+ type,
105
+ id: encodeOperationId(accountId, hash, type),
106
+ });
107
+ } else if (redelegateTransaction) {
108
+ // delegate change
109
+ const type = "REDELEGATE";
110
+ ops.push({
111
+ ...op,
112
+ value: new BigNumber(0),
113
+ type,
114
+ id: encodeOperationId(accountId, hash, type),
115
+ });
116
+ } else {
117
+ const type = "IN";
118
+ ops.push({
119
+ ...op,
120
+ value: value.minus(accountCreationFee),
121
+ type,
122
+ id: encodeOperationId(accountId, hash, type),
123
+ });
124
+ }
125
+
126
+ return ops;
127
+ } catch (e) {
128
+ log("error", "mina: failed to convert txn to operation", {
129
+ error: e,
130
+ transaction: txn,
131
+ });
132
+ return [];
133
+ }
134
+ };
135
+
136
+ export const getAccountShape: GetAccountShape<MinaAccount> = async info => {
137
+ const { address, initialAccount, currency, derivationMode } = info;
138
+ const oldOperations = initialAccount?.operations || [];
139
+
140
+ const accountId = encodeAccountId({
141
+ type: "js",
142
+ version: "2",
143
+ currencyId: currency.id,
144
+ xpubOrAddress: address,
145
+ derivationMode,
146
+ });
147
+
148
+ const { blockHeight, balance, spendableBalance } = await getAccount(address);
149
+
150
+ const rosettaTxns = await getTransactions(address, initialAccount?.operations.length);
151
+ const newOperations = await Promise.all(
152
+ rosettaTxns.flatMap(t => mapRosettaTxnToOperation(accountId, address, t)),
153
+ );
154
+
155
+ const operations = mergeOps(oldOperations, newOperations.flat());
156
+
157
+ const shape: Partial<MinaAccount> = {
158
+ id: accountId,
159
+ balance,
160
+ spendableBalance,
161
+ operationsCount: operations.length,
162
+ blockHeight,
163
+ };
164
+
165
+ return { ...shape, operations };
166
+ };
167
+
168
+ export const sync = makeSync({ getAccountShape });
@@ -0,0 +1,69 @@
1
+ import type { Transaction, TransactionRaw } from "../types/common";
2
+ import { formatTransactionStatus } from "@ledgerhq/coin-framework/formatters";
3
+ import {
4
+ fromTransactionCommonRaw,
5
+ fromTransactionStatusRawCommon as fromTransactionStatusRaw,
6
+ toTransactionCommonRaw,
7
+ toTransactionStatusRawCommon as toTransactionStatusRaw,
8
+ } from "@ledgerhq/coin-framework/serialization";
9
+ import type { Account } from "@ledgerhq/types-live";
10
+ import { getAccountCurrency } from "@ledgerhq/coin-framework/account/index";
11
+ import { formatCurrencyUnit } from "@ledgerhq/coin-framework/currencies/index";
12
+ import BigNumber from "bignumber.js";
13
+
14
+ export const formatTransaction = (
15
+ { recipient, useAllAmount, amount }: Transaction,
16
+ account: Account,
17
+ ): string => `
18
+ SEND ${
19
+ useAllAmount
20
+ ? "MAX"
21
+ : amount.isZero()
22
+ ? ""
23
+ : " " +
24
+ formatCurrencyUnit(getAccountCurrency(account).units[0], amount, {
25
+ showCode: true,
26
+ disableRounding: true,
27
+ })
28
+ }
29
+ TO ${recipient}`;
30
+
31
+ export const fromTransactionRaw = (tr: TransactionRaw): Transaction => {
32
+ const common = fromTransactionCommonRaw(tr);
33
+ return {
34
+ ...common,
35
+ family: tr.family,
36
+ fees: {
37
+ fee: new BigNumber(tr.fees.fee),
38
+ accountCreationFee: new BigNumber(tr.fees.accountCreationFee),
39
+ },
40
+ amount: new BigNumber(tr.amount),
41
+ memo: tr.memo,
42
+ nonce: tr.nonce,
43
+ };
44
+ };
45
+
46
+ const toTransactionRaw = (t: Transaction): TransactionRaw => {
47
+ const common = toTransactionCommonRaw(t);
48
+
49
+ return {
50
+ ...common,
51
+ family: t.family,
52
+ amount: t.amount.toFixed(),
53
+ fees: {
54
+ fee: t.fees.fee.toString(),
55
+ accountCreationFee: t.fees.accountCreationFee.toString(),
56
+ },
57
+ memo: t.memo ?? undefined,
58
+ nonce: t.nonce,
59
+ };
60
+ };
61
+
62
+ export default {
63
+ formatTransaction,
64
+ fromTransactionRaw,
65
+ toTransactionRaw,
66
+ fromTransactionStatusRaw,
67
+ toTransactionStatusRaw,
68
+ formatTransactionStatus,
69
+ };