@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,225 @@
1
+ import {
2
+ getAccountNumFromPath,
3
+ isValidAddress,
4
+ getMaxAmount,
5
+ getTotalSpent,
6
+ reEncodeRawSignature,
7
+ isValidMemo,
8
+ } from ".";
9
+ import { BigNumber } from "bignumber.js";
10
+ import type { MinaAccount, Transaction } from "../types/common";
11
+ import { MAX_MEMO_LENGTH } from "../consts";
12
+ import { Operation } from "@ledgerhq/types-live";
13
+
14
+ // Create a minimal mock implementation for the tests
15
+ type MockMinaAccount = Pick<MinaAccount, "spendableBalance" | "pendingOperations">;
16
+ type MockTransaction = Partial<Transaction>;
17
+
18
+ // Mock functions to create test objects
19
+ function createMockAccount(overrides: Partial<MockMinaAccount> = {}): MockMinaAccount {
20
+ return {
21
+ spendableBalance: new BigNumber(1000),
22
+ pendingOperations: [],
23
+ ...overrides,
24
+ };
25
+ }
26
+
27
+ function createMockTransaction(overrides: Partial<MockTransaction> = {}): MockTransaction {
28
+ return {
29
+ family: "mina",
30
+ amount: new BigNumber(0),
31
+ recipient: "B62qiVhtBtqakq8sNTHdCTXn6tETSK6gtsmNHRn1WdLqjGLpsHbw1xc",
32
+ ...overrides,
33
+ };
34
+ }
35
+
36
+ describe("getAccountNumFromPath", () => {
37
+ it("should return undefined for invalid account number", () => {
38
+ const account = getAccountNumFromPath("44'/616'/4'/0/0");
39
+ expect(account).toBe(undefined);
40
+ });
41
+
42
+ it("should return undefined for unsupported path", () => {
43
+ const account = getAccountNumFromPath("44'/616'/4/0/0");
44
+ expect(account).toBe(undefined);
45
+ });
46
+
47
+ it("should return the account number", () => {
48
+ const account = getAccountNumFromPath("44'/12586'/4'/0/0");
49
+ expect(account).toBe(4);
50
+ });
51
+ });
52
+
53
+ describe("testingAddress", () => {
54
+ const validAddresses = [
55
+ "B62qiVhtBtqakq8sNTHdCTXn6tETSK6gtsmNHRn1WdLqjGLpsHbw1xc",
56
+ "B62qr5cXFjdnZXYxP5dEwRY7wENxcod4Q2oLxUDiq1QrBXZZyxMH8q4",
57
+ "B62qqmRToRiXZjyLLMJoGnQFXXZuZWdqaNYr43xEDDQzkXMHLouCMZp",
58
+ "B62qnixP59E4vJytpDWZ5YQPrnmqb7YNwhVWiuSAkxbYdX5RauHWwcm",
59
+ "B62qmfBiJx88gM9opov4MDxmDVKMutQsBQ1aGt7TrQYyGQx66fRFxvC",
60
+ "B62qosg21UpwpfPFaxTyirdfUVDHe2Ynsyv1QydE4z34zbLuBZ92ALM",
61
+ "B62qkWUvsVEnXmd4poHbkKujHNnjxkDcZtrLxN1FTa8pp3GkfHMB1gv",
62
+ "B62qoiK7DJurVUUJx1dmJGULdNUmX5bjdiYvoWXEXGugS2Cx3YDsHhy",
63
+ "B62qn1KptFUxxu8aRS52NGQ3GWzn5h8v7U9k571r4LCs5obpoZyd81e",
64
+ "B62qis2tX1rveddCeJeBAZJnXcCwWPp1x9ScZ3iMCxbV29gRbxWo7qi",
65
+ "B62qpBKEDTnS4efjBmou7iztx5x152JEmc29XMR1Y3FVCpnmfKGX4R4",
66
+ "B62qro5bGnk7eCNMA1S5QWmzn5sCcRWckbw83GGaqN3HM2QzP9zYS83",
67
+ "B62qospDjUj43x2yMKiNehojWWRUsE1wpdUDVpfxH8V3n5Y1QgJKFfw",
68
+ "B62qrmYwToypQv8v9cjxJdyhAxKihrqtTtEkYC4Y3u412KCPLGSD93V",
69
+ "B62qj3rpYkGM1T3VN6JDAJs9NccHCRQDYMcQ6UCBc81ff5HXTDjU44d",
70
+ "B62qp2kks3r14P8GWkR2ieT18JobwnmrBFGEoqy3dAReiyM8aDp4be7",
71
+ "B62qpW1SYPcp7TcHJYL6egnN9qzvNtQL5XGyiM8S6UsHvxCYzhhFPjz",
72
+ "B62qospDjUj43x2yMKiNehojWWRUsE1wpdUDVpfxH8V3n5Y1QgJKFfw",
73
+ "B62qj5L8U8A8gexpHLWHxBdfjKuWb8HMguVPecQ5FGqgZAwBAKHvhEy",
74
+ "B62qnt5WShcbVVnVqQqWjkyMJdxMwLq4QbRbgMjoi5nmvQw7dZLRtpx",
75
+ "B62qrGUxqRWn9A8PEJschgLZuS5S1GJiairh65mgTapaK58nkTKHUs8",
76
+ "B62qkS7hmMkzmNDjeCUKyAMZSw1c98MxszZPA7WnvBuh7Pq66ztiwdt",
77
+ "B62qjGWerE9MPNk7E2jEJe9Ex5GxkNR9JCc5mhFeJdGFaNDHnMdGQJQ",
78
+ "B62qpp2DLkLxwFn1QZdkEWgiRFMYnkgh6cj5AJC5pqCYiALh8BmiYJ8",
79
+ "B62qqALaAoEnaJPSNmQaDkUwFGiKwZo4zRK4Ay5eSMxAMVhNxwr2KeM",
80
+ "B62qospDjUj43x2yMKiNehojWWRUsE1wpdUDVpfxH8V3n5Y1QgJKFfw",
81
+ "B62qr3epzHUrxrdminUN4Hzuinuc7aBDAFSR94mPmmxVsbuFpUvDDq6",
82
+ "B62qrJurUKtcqdhQu1XtJJfSH7rR1xrEtSWPQQcFwBJBwVcsFSyVSM3",
83
+ ];
84
+
85
+ const invalidAddresses = [
86
+ "", // Empty address
87
+ null, // Null address
88
+ undefined, // Undefined address
89
+ "123", // Too short
90
+ "B61qiVhtBtqakq8sNTHdCTXn6tETSK6gtsmNHRn1WdLqjGLpsHbw1xc", // Incorrect prefix
91
+ "B62q!@#$%^&*()_+{}|:<>?`~", // Invalid characters
92
+ "B62qj5L8U8A8gexpHLWHxBdfjKuWb8HMguVPecQ5FGqgZAwBAKHvhE", // Too short
93
+ "B62qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq", // Too long
94
+ " B62qiVhtBtqakq8sNTHdCTXn6tETSK6gtsmNHRn1WdLqjGLpsHbw1xc", // Leading whitespace
95
+ "B62qiVhtBtqakq8sNTHdCTXn6tETSK6gtsmNHRn1WdLqjGLpsHbw1xc ", // Trailing whitespace
96
+ "B62qiVhtBtqakq8sNTHdC TXn6tETSK6gtsmNHRn1WdLqjGLpsHbw1xc", // Internal whitespace
97
+ "C62qiVhtBtqakq8sNTHdCTXn6tETSK6gtsmNHRn1WdLqjGLpsHbw1xc", // Incorrect prefix
98
+ ];
99
+
100
+ it("should return true for valid address", () => {
101
+ for (const address of validAddresses) {
102
+ expect(isValidAddress(address)).toBe(true);
103
+ }
104
+ });
105
+
106
+ it("should return false for invalid address", () => {
107
+ for (const address of invalidAddresses) {
108
+ expect(isValidAddress(address as string)).toBe(false);
109
+ }
110
+ });
111
+ });
112
+
113
+ describe("isValidMemo", () => {
114
+ it("should return true for valid memo", () => {
115
+ expect(isValidMemo("")).toBe(true);
116
+ expect(isValidMemo("Valid memo")).toBe(true);
117
+ expect(isValidMemo("A".repeat(MAX_MEMO_LENGTH))).toBe(true);
118
+ });
119
+
120
+ it("should return false for memo exceeding max length", () => {
121
+ expect(isValidMemo("A".repeat(MAX_MEMO_LENGTH + 1))).toBe(false);
122
+ });
123
+ });
124
+
125
+ describe("getMaxAmount", () => {
126
+ it("should calculate correct max amount with no fees", () => {
127
+ const account = createMockAccount({
128
+ spendableBalance: new BigNumber(1000),
129
+ pendingOperations: [],
130
+ });
131
+ const transaction = createMockTransaction();
132
+
133
+ expect(getMaxAmount(account as MinaAccount, transaction as Transaction).toNumber()).toBe(1000);
134
+ });
135
+
136
+ it("should calculate correct max amount with fees", () => {
137
+ const account = createMockAccount({
138
+ spendableBalance: new BigNumber(1000),
139
+ pendingOperations: [],
140
+ });
141
+ const transaction = createMockTransaction();
142
+ const fees = new BigNumber(10);
143
+
144
+ expect(getMaxAmount(account as MinaAccount, transaction as Transaction, fees).toNumber()).toBe(
145
+ 990,
146
+ );
147
+ });
148
+
149
+ it("should subtract pending operations from max amount", () => {
150
+ const account = createMockAccount({
151
+ spendableBalance: new BigNumber(1000),
152
+ pendingOperations: [
153
+ { value: new BigNumber(100) } as Operation,
154
+ { value: new BigNumber(200) } as Operation,
155
+ ],
156
+ });
157
+ const transaction = createMockTransaction();
158
+
159
+ expect(getMaxAmount(account as MinaAccount, transaction as Transaction).toNumber()).toBe(700);
160
+ });
161
+
162
+ it("should return 0 when max amount would be negative", () => {
163
+ const account = createMockAccount({
164
+ spendableBalance: new BigNumber(100),
165
+ pendingOperations: [{ value: new BigNumber(200) } as Operation],
166
+ });
167
+ const transaction = createMockTransaction();
168
+
169
+ expect(getMaxAmount(account as MinaAccount, transaction as Transaction).toNumber()).toBe(0);
170
+ });
171
+ });
172
+
173
+ describe("getTotalSpent", () => {
174
+ it("should return spendable balance when useAllAmount is true", () => {
175
+ const account = createMockAccount({
176
+ spendableBalance: new BigNumber(1000),
177
+ });
178
+ const transaction = createMockTransaction({
179
+ useAllAmount: true,
180
+ amount: new BigNumber(500),
181
+ });
182
+ const fees = new BigNumber(10);
183
+
184
+ expect(getTotalSpent(account as MinaAccount, transaction as Transaction, fees).toNumber()).toBe(
185
+ 1000,
186
+ );
187
+ });
188
+
189
+ it("should return amount plus fees when useAllAmount is false", () => {
190
+ const account = createMockAccount({
191
+ spendableBalance: new BigNumber(1000),
192
+ });
193
+ const transaction = createMockTransaction({
194
+ useAllAmount: false,
195
+ amount: new BigNumber(500),
196
+ });
197
+ const fees = new BigNumber(10);
198
+
199
+ expect(getTotalSpent(account as MinaAccount, transaction as Transaction, fees).toNumber()).toBe(
200
+ 510,
201
+ );
202
+ });
203
+ });
204
+
205
+ describe("reEncodeRawSignature", () => {
206
+ it("should correctly re-encode a valid signature", () => {
207
+ const rawSignature = "a".repeat(64) + "b".repeat(64);
208
+ const result = reEncodeRawSignature(rawSignature);
209
+
210
+ // Check that the result has the correct format (reverse bytes)
211
+ expect(result.length).toBe(128);
212
+
213
+ // Check field part
214
+ const fieldPart = result.substring(0, 64);
215
+ expect(fieldPart).toBe("a".repeat(64).match(/.{2}/g)?.reverse().join(""));
216
+
217
+ // Check scalar part
218
+ const scalarPart = result.substring(64);
219
+ expect(scalarPart).toBe("b".repeat(64).match(/.{2}/g)?.reverse().join(""));
220
+ });
221
+
222
+ it("should throw an error for invalid signature length", () => {
223
+ expect(() => reEncodeRawSignature("too_short")).toThrow("Invalid raw signature input");
224
+ });
225
+ });
@@ -0,0 +1,97 @@
1
+ import { BigNumber } from "bignumber.js";
2
+ import { Transaction, MinaAccount } from "../types/common";
3
+ import { CoinType } from "@ledgerhq/types-cryptoassets";
4
+ import { MAX_MEMO_LENGTH, MINA_DECODED_ADDRESS_LENGTH } from "../consts";
5
+ import bs58check from "bs58check";
6
+
7
+ /*
8
+ * Validate a Mina address.
9
+ */
10
+ export function isValidAddress(address: string) {
11
+ try {
12
+ if (!address.toLowerCase().startsWith("b62")) {
13
+ return false;
14
+ }
15
+ const decodedAddress = Buffer.from(bs58check.decode(address)).toString("hex");
16
+ return !!decodedAddress && decodedAddress.length === MINA_DECODED_ADDRESS_LENGTH;
17
+ } catch (ex) {
18
+ return false;
19
+ }
20
+ }
21
+
22
+ export const isValidMemo = (memo: string): boolean => {
23
+ return memo.length <= MAX_MEMO_LENGTH;
24
+ };
25
+
26
+ // Get the account number from the path
27
+ export const getAccountNumFromPath = (path: string): number | undefined => {
28
+ const parts = path.split("'/");
29
+
30
+ if (parts.length === 3) {
31
+ return;
32
+ }
33
+
34
+ if (parts[1] !== `${CoinType.MINA}`) {
35
+ return;
36
+ }
37
+
38
+ try {
39
+ const acc = parseInt(parts[2], 10);
40
+ if (acc >= 0) {
41
+ return acc;
42
+ }
43
+ return;
44
+ } catch (e) {
45
+ return;
46
+ }
47
+ };
48
+
49
+ /*
50
+ * Get the max amount that can be spent, taking into account tx type and pending operations.
51
+ */
52
+ export const getMaxAmount = (a: MinaAccount, _t: Transaction, fees?: BigNumber): BigNumber => {
53
+ let maxAmount;
54
+
55
+ let pendingDefaultAmount = new BigNumber(0);
56
+
57
+ a.pendingOperations.forEach(({ value }) => {
58
+ pendingDefaultAmount = pendingDefaultAmount.plus(value);
59
+ });
60
+
61
+ maxAmount = a.spendableBalance.minus(pendingDefaultAmount);
62
+ if (fees) {
63
+ maxAmount = maxAmount.minus(fees);
64
+ }
65
+ if (maxAmount === undefined || maxAmount.lt(0)) {
66
+ return new BigNumber(0);
67
+ }
68
+
69
+ return maxAmount;
70
+ };
71
+
72
+ export const getTotalSpent = (a: MinaAccount, t: Transaction, fees: BigNumber): BigNumber => {
73
+ if (t.useAllAmount) {
74
+ return a.spendableBalance;
75
+ }
76
+
77
+ return new BigNumber(t.amount).plus(fees);
78
+ };
79
+
80
+ // reEncodeRawSignature takes a raw signature in the form of a 128-character hex string and returns a re-encoded version of it.
81
+ export function reEncodeRawSignature(rawSignature: string) {
82
+ function shuffleBytes(hex: string) {
83
+ const bytes = hex.match(/.{2}/g);
84
+ if (!bytes) {
85
+ throw "Invalid hex input";
86
+ }
87
+ bytes.reverse();
88
+ return bytes.join("");
89
+ }
90
+
91
+ if (rawSignature.length !== 128) {
92
+ throw "Invalid raw signature input";
93
+ }
94
+ const field = rawSignature.substring(0, 64);
95
+ const scalar = rawSignature.substring(64);
96
+ return shuffleBytes(field) + shuffleBytes(scalar);
97
+ }
package/src/config.ts ADDED
@@ -0,0 +1,21 @@
1
+ import { CurrencyConfig } from "@ledgerhq/coin-framework/config";
2
+
3
+ export type MinaCoinConfig = () => CurrencyConfig & {
4
+ infra: {
5
+ API_MINA_ROSETTA_NODE: string;
6
+ };
7
+ };
8
+
9
+ let coinConfig: MinaCoinConfig | undefined;
10
+
11
+ export const setCoinConfig = (config: MinaCoinConfig): void => {
12
+ coinConfig = config;
13
+ };
14
+
15
+ export const getCoinConfig = (): ReturnType<MinaCoinConfig> => {
16
+ if (!coinConfig?.()) {
17
+ throw new Error("Mina module config not set");
18
+ }
19
+
20
+ return coinConfig();
21
+ };
package/src/consts.ts ADDED
@@ -0,0 +1,18 @@
1
+ export const MAINNET_NETWORK_IDENTIFIER = {
2
+ network_identifier: {
3
+ blockchain: "mina",
4
+ network: "mainnet",
5
+ },
6
+ };
7
+
8
+ export const MINA_MAINNET_NETWORK_ID = 1;
9
+ export const MINA_PAYMENT_TYPE_ID = 0;
10
+ export const MINA_TOKEN_ID = "wSHV2S4qX9jFsLjQo8r1BsMLH2ZRKsZx6EJd1sbozGPieEC4Jf";
11
+ export const MINA_DECIMALS = 9;
12
+ export const MINA_SYMBOL = "MINA";
13
+ export const MINA_CURVE_TYPE = "pallas";
14
+
15
+ export const MAX_MEMO_LENGTH = 32;
16
+ export const MINA_DECODED_ADDRESS_LENGTH = 72;
17
+
18
+ export const MAX_TRANSACTIONS_PER_PAGE = 100;
@@ -0,0 +1,131 @@
1
+ import resolver from "./getAddress";
2
+ import { SignerContext } from "@ledgerhq/coin-framework/signer";
3
+ import { GetAddressOptions } from "@ledgerhq/coin-framework/derivation";
4
+ import { MinaSigner } from "../types/signer";
5
+ import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets/lib/currencies";
6
+ import { DerivationMode } from "@ledgerhq/types-live";
7
+
8
+ describe("Mina getAddress resolver", () => {
9
+ // Mock the signer context
10
+ const mockSigner: MinaSigner = {
11
+ getAddress: jest.fn(),
12
+ signTransaction: jest.fn(),
13
+ };
14
+ const commonOptions = {
15
+ currency: getCryptoCurrencyById("mina"),
16
+ derivationMode: "minabip44" as DerivationMode,
17
+ };
18
+
19
+ const mockSignerContext: SignerContext<MinaSigner> = jest.fn(async (deviceId, callback) => {
20
+ return callback(mockSigner);
21
+ });
22
+
23
+ beforeEach(() => {
24
+ jest.clearAllMocks();
25
+ });
26
+
27
+ it("should call the signer with the correct account number", async () => {
28
+ const options: GetAddressOptions = {
29
+ ...commonOptions,
30
+ path: "44'/12586'/0'/0/0",
31
+ verify: false,
32
+ };
33
+
34
+ // Mock response from signer
35
+ (mockSigner.getAddress as jest.Mock).mockResolvedValue({
36
+ publicKey: "testPublicKey123",
37
+ });
38
+
39
+ const getAddress = resolver(mockSignerContext);
40
+ await getAddress("device1", options);
41
+
42
+ expect(mockSigner.getAddress).toHaveBeenCalledWith(0, false);
43
+ });
44
+
45
+ it("should pass the verify flag correctly", async () => {
46
+ const options: GetAddressOptions = {
47
+ path: "44'/12586'/2'/0/0",
48
+ verify: true,
49
+ ...commonOptions,
50
+ };
51
+
52
+ // Mock response from signer
53
+ (mockSigner.getAddress as jest.Mock).mockResolvedValue({
54
+ publicKey: "testPublicKey456",
55
+ });
56
+
57
+ const getAddress = resolver(mockSignerContext);
58
+ await getAddress("device1", options);
59
+
60
+ expect(mockSigner.getAddress).toHaveBeenCalledWith(2, true);
61
+ });
62
+
63
+ it("should default to verify=false when not provided", async () => {
64
+ const options: GetAddressOptions = {
65
+ path: "44'/12586'/1'/0/0",
66
+ ...commonOptions,
67
+ };
68
+
69
+ // Mock response from signer
70
+ (mockSigner.getAddress as jest.Mock).mockResolvedValue({
71
+ publicKey: "testPublicKey789",
72
+ });
73
+
74
+ const getAddress = resolver(mockSignerContext);
75
+ await getAddress("device1", options);
76
+
77
+ expect(mockSigner.getAddress).toHaveBeenCalledWith(1, false);
78
+ });
79
+
80
+ it("should return the correct address format", async () => {
81
+ const options: GetAddressOptions = {
82
+ path: "44'/12586'/3'/0/0",
83
+ ...commonOptions,
84
+ };
85
+
86
+ const expectedPublicKey = "minaPublicKeyABC123";
87
+
88
+ // Mock response from signer
89
+ (mockSigner.getAddress as jest.Mock).mockResolvedValue({
90
+ publicKey: expectedPublicKey,
91
+ });
92
+
93
+ const getAddress = resolver(mockSignerContext);
94
+ const result = await getAddress("device1", options);
95
+
96
+ expect(result).toEqual({
97
+ address: expectedPublicKey,
98
+ publicKey: expectedPublicKey,
99
+ path: options.path,
100
+ });
101
+ });
102
+
103
+ it("should throw an error for invalid path", async () => {
104
+ const options: GetAddressOptions = {
105
+ path: "44'/789'/0'/0/0", // Invalid coin type for Mina
106
+ verify: false,
107
+ ...commonOptions,
108
+ };
109
+
110
+ const getAddress = resolver(mockSignerContext);
111
+ await expect(getAddress("device1", options)).rejects.toThrow();
112
+ });
113
+
114
+ it("should throw an error when publicKey is undefined", async () => {
115
+ const options: GetAddressOptions = {
116
+ path: "44'/12586'/0'/0/0",
117
+ verify: false,
118
+ ...commonOptions,
119
+ };
120
+
121
+ // Mock response from signer with undefined publicKey
122
+ (mockSigner.getAddress as jest.Mock).mockResolvedValue({
123
+ publicKey: undefined,
124
+ });
125
+
126
+ const getAddress = resolver(mockSignerContext);
127
+ await expect(getAddress("device1", options)).rejects.toThrow(
128
+ "[mina] getAddress: expected publicKey to be defined",
129
+ );
130
+ });
131
+ });
@@ -0,0 +1,24 @@
1
+ import { GetAddressFn } from "@ledgerhq/coin-framework/bridge/getAddressWrapper";
2
+ import { SignerContext } from "@ledgerhq/coin-framework/signer";
3
+ import { GetAddressOptions } from "@ledgerhq/coin-framework/derivation";
4
+ import { GetAddressResponse, MinaSigner } from "../types/signer";
5
+ import { getAccountNumFromPath } from "../common-logic";
6
+ import invariant from "invariant";
7
+
8
+ const resolver = (signerContext: SignerContext<MinaSigner>): GetAddressFn => {
9
+ return async (deviceId: string, { path, verify }: GetAddressOptions) => {
10
+ const account = getAccountNumFromPath(path);
11
+ invariant(account !== undefined, "Invalid account path, supported: 44'/12586'/<account>'/0/0");
12
+ const r = (await signerContext(deviceId, signer =>
13
+ signer.getAddress(account, verify || false),
14
+ )) as GetAddressResponse;
15
+ invariant(r.publicKey, "[mina] getAddress: expected publicKey to be defined");
16
+ return {
17
+ address: r.publicKey,
18
+ publicKey: r.publicKey,
19
+ path,
20
+ };
21
+ };
22
+ };
23
+
24
+ export default resolver;
@@ -0,0 +1,3 @@
1
+ import resolver from "./getAddress";
2
+
3
+ export default resolver;
@@ -0,0 +1,73 @@
1
+ import type { DeviceAction, State } from "@ledgerhq/coin-framework/bot/types";
2
+ import type { Transaction } from "../types/common";
3
+ import { deviceActionFlow, SpeculosButton } from "@ledgerhq/coin-framework/bot/specs";
4
+ import { formatCurrencyUnit } from "@ledgerhq/coin-framework/lib/currencies/formatCurrencyUnit";
5
+
6
+ export const acceptTransaction: DeviceAction<Transaction, State<Transaction>> = deviceActionFlow({
7
+ steps: [
8
+ {
9
+ title: "Sign",
10
+ button: SpeculosButton.RIGHT,
11
+ },
12
+ {
13
+ title: "Type",
14
+ button: SpeculosButton.RIGHT,
15
+ expectedValue: () => "Payment",
16
+ },
17
+ {
18
+ title: "Sender",
19
+ button: SpeculosButton.RIGHT,
20
+ expectedValue: ({ account }) => account.freshAddress,
21
+ },
22
+ {
23
+ title: "Receiver",
24
+ button: SpeculosButton.RIGHT,
25
+ expectedValue: ({ transaction }) => transaction.recipient,
26
+ },
27
+ {
28
+ title: "Amount",
29
+ button: SpeculosButton.RIGHT,
30
+ expectedValue: ({ transaction, account }) =>
31
+ `MINA ${formatCurrencyUnit(account.currency.units[0], transaction.amount, {
32
+ dynamicSignificantDigits: 11,
33
+ staticSignificantDigits: 11,
34
+ })}`,
35
+ },
36
+ {
37
+ title: "Fee",
38
+ button: SpeculosButton.RIGHT,
39
+ expectedValue: ({ transaction, account }) =>
40
+ `MINA ${formatCurrencyUnit(account.currency.units[0], transaction.fees.fee, {
41
+ dynamicSignificantDigits: 11,
42
+ staticSignificantDigits: 11,
43
+ })}`,
44
+ },
45
+ {
46
+ title: "Total",
47
+ button: SpeculosButton.RIGHT,
48
+ expectedValue: ({ transaction, account }) =>
49
+ `MINA ${formatCurrencyUnit(
50
+ account.currency.units[0],
51
+ transaction.fees.fee.plus(transaction.amount),
52
+ {
53
+ dynamicSignificantDigits: 11,
54
+ staticSignificantDigits: 11,
55
+ },
56
+ )}`,
57
+ },
58
+ {
59
+ title: "Memo",
60
+ button: SpeculosButton.RIGHT,
61
+ expectedValue: ({ transaction }) => transaction.memo ?? "",
62
+ },
63
+ {
64
+ title: "Nonce",
65
+ button: SpeculosButton.RIGHT,
66
+ expectedValue: ({ transaction }) => transaction.nonce.toString(),
67
+ },
68
+ {
69
+ title: "Approve",
70
+ button: SpeculosButton.BOTH,
71
+ },
72
+ ],
73
+ });