@ledgerhq/coin-mina 1.1.0-nightly.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 +7 -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,175 @@
1
+ import { BigNumber } from "bignumber.js";
2
+ import {
3
+ NotEnoughBalance,
4
+ RecipientRequired,
5
+ InvalidAddress,
6
+ FeeNotLoaded,
7
+ AmountRequired,
8
+ InvalidAddressBecauseDestinationIsAlsoSource,
9
+ } from "@ledgerhq/errors";
10
+ import { AccountCreationFeeWarning, InvalidMemoMina, AmountTooSmall } from "./errors";
11
+ import getTransactionStatus from "./getTransactionStatus";
12
+ import { createMockAccount, createMockTransaction } from "../test/fixtures";
13
+ import { formatCurrencyUnit } from "@ledgerhq/coin-framework/currencies";
14
+ import { Transaction } from "../types/common";
15
+ import getEstimatedFees from "./getEstimatedFees";
16
+
17
+ // Mock dependencies
18
+ jest.mock("@ledgerhq/coin-framework/currencies", () => ({
19
+ formatCurrencyUnit: jest.fn().mockReturnValue("0.1 MINA"),
20
+ }));
21
+ jest.mock("./getEstimatedFees");
22
+
23
+ describe("getTransactionStatus", () => {
24
+ // Standard test fixtures
25
+ const mockAccount = createMockAccount();
26
+ const mockTransaction = createMockTransaction({ amount: new BigNumber(800) });
27
+
28
+ beforeEach(() => {
29
+ jest.clearAllMocks();
30
+ });
31
+
32
+ it("should return a valid transaction status with no errors for valid inputs", async () => {
33
+ const result = await getTransactionStatus(mockAccount, mockTransaction);
34
+
35
+ expect(result.errors).toEqual({});
36
+ expect(result.warnings).toEqual({});
37
+ expect(result.estimatedFees).toEqual(new BigNumber(10));
38
+ expect(result.amount).toEqual(new BigNumber(800));
39
+ expect(result.totalSpent).toEqual(new BigNumber(810)); // amount + fee
40
+ });
41
+
42
+ it("should handle missing fees with FeeNotLoaded error", async () => {
43
+ (getEstimatedFees as jest.Mock).mockResolvedValue({
44
+ fee: new BigNumber(10),
45
+ accountCreationFee: new BigNumber(0),
46
+ });
47
+ // Using Type casting to handle the null fees for testing purposes
48
+ const txWithoutFees: Transaction = {
49
+ ...mockTransaction,
50
+ fees: {
51
+ fee: new BigNumber(0),
52
+ accountCreationFee: new BigNumber(0),
53
+ },
54
+ };
55
+
56
+ const result = await getTransactionStatus(mockAccount, txWithoutFees);
57
+
58
+ expect(result.errors.fees).toBeInstanceOf(FeeNotLoaded);
59
+ });
60
+
61
+ it("should handle missing recipient with RecipientRequired error", async () => {
62
+ const txWithoutRecipient = {
63
+ ...mockTransaction,
64
+ recipient: "",
65
+ };
66
+
67
+ const result = await getTransactionStatus(mockAccount, txWithoutRecipient);
68
+
69
+ expect(result.errors.recipient).toBeInstanceOf(RecipientRequired);
70
+ });
71
+
72
+ it("should handle invalid recipient address with InvalidAddress error", async () => {
73
+ const txWithInvalidRecipient = {
74
+ ...mockTransaction,
75
+ recipient: "invalid-address",
76
+ };
77
+
78
+ const result = await getTransactionStatus(mockAccount, txWithInvalidRecipient);
79
+
80
+ expect(result.errors.recipient).toBeInstanceOf(InvalidAddress);
81
+ });
82
+
83
+ it("should handle self-transfer with InvalidAddressBecauseDestinationIsAlsoSource error", async () => {
84
+ const txWithSelfTransfer = {
85
+ ...mockTransaction,
86
+ recipient: mockAccount.freshAddress,
87
+ };
88
+
89
+ const result = await getTransactionStatus(mockAccount, txWithSelfTransfer);
90
+
91
+ expect(result.errors.recipient).toBeInstanceOf(InvalidAddressBecauseDestinationIsAlsoSource);
92
+ });
93
+
94
+ it("should handle invalid memo with InvalidMemoMina error", async () => {
95
+ const veryLongMemo = "a".repeat(33); // Create memo longer than MAX_MEMO_LENGTH (32)
96
+ const txWithInvalidMemo = {
97
+ ...mockTransaction,
98
+ memo: veryLongMemo,
99
+ };
100
+
101
+ const result = await getTransactionStatus(mockAccount, txWithInvalidMemo);
102
+
103
+ expect(result.errors.transaction).toBeInstanceOf(InvalidMemoMina);
104
+ });
105
+
106
+ it("should add AccountCreationFeeWarning when account creation fee is present", async () => {
107
+ const txWithAccountCreationFee = {
108
+ ...mockTransaction,
109
+ fees: {
110
+ fee: new BigNumber(10),
111
+ accountCreationFee: new BigNumber(100),
112
+ },
113
+ };
114
+
115
+ const result = await getTransactionStatus(mockAccount, txWithAccountCreationFee);
116
+
117
+ expect(result.warnings.recipient).toBeInstanceOf(AccountCreationFeeWarning);
118
+ expect(formatCurrencyUnit).toHaveBeenCalled();
119
+ });
120
+
121
+ it("should add AmountTooSmall error when amount is less than account creation fee", async () => {
122
+ const txWithSmallAmount = {
123
+ ...mockTransaction,
124
+ amount: new BigNumber(50),
125
+ fees: {
126
+ fee: new BigNumber(10),
127
+ accountCreationFee: new BigNumber(100),
128
+ },
129
+ };
130
+
131
+ const result = await getTransactionStatus(mockAccount, txWithSmallAmount);
132
+
133
+ expect(result.errors.amount).toBeInstanceOf(AmountTooSmall);
134
+ });
135
+
136
+ it("should handle zero amount with AmountRequired error when useAllAmount is false", async () => {
137
+ const txWithZeroAmount = {
138
+ ...mockTransaction,
139
+ amount: new BigNumber(0),
140
+ useAllAmount: false,
141
+ };
142
+
143
+ const result = await getTransactionStatus(mockAccount, txWithZeroAmount);
144
+
145
+ expect(result.errors.amount).toBeInstanceOf(AmountRequired);
146
+ });
147
+
148
+ it("should handle amount greater than max with NotEnoughBalance error", async () => {
149
+ // Account has spendable balance of 900
150
+ const txWithTooLargeAmount = {
151
+ ...mockTransaction,
152
+ amount: new BigNumber(1000),
153
+ useAllAmount: false,
154
+ };
155
+
156
+ const result = await getTransactionStatus(mockAccount, txWithTooLargeAmount);
157
+
158
+ expect(result.errors.amount).toBeInstanceOf(NotEnoughBalance);
159
+ });
160
+
161
+ it("should calculate correct amount and totalSpent when useAllAmount is true", async () => {
162
+ const txWithUseAllAmount = {
163
+ ...mockTransaction,
164
+ amount: new BigNumber(0), // Amount should be ignored when useAllAmount is true
165
+ useAllAmount: true,
166
+ };
167
+
168
+ const result = await getTransactionStatus(mockAccount, txWithUseAllAmount);
169
+
170
+ // Should return spendableBalance - fee as the amount
171
+ expect(result.amount).toEqual(new BigNumber(890)); // spendableBalance(900) - fee(10)
172
+ expect(result.totalSpent).toEqual(new BigNumber(900)); // spendableBalance
173
+ expect(result.errors).toEqual({});
174
+ });
175
+ });
@@ -0,0 +1,87 @@
1
+ import { BigNumber } from "bignumber.js";
2
+ import {
3
+ NotEnoughBalance,
4
+ RecipientRequired,
5
+ InvalidAddress,
6
+ FeeNotLoaded,
7
+ AmountRequired,
8
+ InvalidAddressBecauseDestinationIsAlsoSource,
9
+ } from "@ledgerhq/errors";
10
+ import type { Transaction, MinaAccount, TransactionStatus, StatusErrorMap } from "../types/common";
11
+ import { isValidAddress, isValidMemo, getMaxAmount, getTotalSpent } from "../common-logic";
12
+ import { AccountBridge } from "@ledgerhq/types-live";
13
+ import { AccountCreationFeeWarning, InvalidMemoMina, AmountTooSmall } from "./errors";
14
+ import { formatCurrencyUnit } from "@ledgerhq/coin-framework/currencies";
15
+
16
+ const getTransactionStatus: AccountBridge<
17
+ Transaction,
18
+ MinaAccount,
19
+ TransactionStatus
20
+ >["getTransactionStatus"] = async (a: MinaAccount, t: Transaction): Promise<TransactionStatus> => {
21
+ const errors: StatusErrorMap = {};
22
+ const warnings: StatusErrorMap = {};
23
+ const useAllAmount = !!t.useAllAmount;
24
+
25
+ if (t.fees.fee.lte(0)) {
26
+ errors.fees = new FeeNotLoaded();
27
+ }
28
+
29
+ if (!t.recipient) {
30
+ errors.recipient = new RecipientRequired();
31
+ }
32
+
33
+ if (t.recipient && !isValidAddress(t.recipient)) {
34
+ errors.recipient = new InvalidAddress("", {
35
+ currencyName: a.currency.name,
36
+ });
37
+ }
38
+
39
+ if (t.memo && !isValidMemo(t.memo)) {
40
+ errors.transaction = new InvalidMemoMina();
41
+ }
42
+
43
+ if (t.recipient === a.freshAddress) {
44
+ errors.recipient = new InvalidAddressBecauseDestinationIsAlsoSource();
45
+ }
46
+
47
+ if (t.fees?.accountCreationFee.gt(0)) {
48
+ const fee = formatCurrencyUnit(a.currency.units[0], t.fees.accountCreationFee, {
49
+ showCode: true,
50
+ disableRounding: true,
51
+ });
52
+ warnings.recipient = new AccountCreationFeeWarning(undefined, {
53
+ fee,
54
+ });
55
+
56
+ if (t.amount.lt(t.fees.accountCreationFee) && t.amount.gt(0)) {
57
+ errors.amount = new AmountTooSmall(undefined, {
58
+ amount: fee,
59
+ });
60
+ }
61
+ }
62
+
63
+ const estimatedFees = t.fees.fee || new BigNumber(0);
64
+
65
+ const maxAmountWithFees = getMaxAmount(a, t, estimatedFees);
66
+
67
+ const totalSpent = getTotalSpent(a, t, estimatedFees);
68
+ const amount = useAllAmount ? maxAmountWithFees : new BigNumber(t.amount);
69
+
70
+ if (amount.lte(0) && !t.useAllAmount) {
71
+ errors.amount = new AmountRequired();
72
+ }
73
+
74
+ if (amount.gt(maxAmountWithFees)) {
75
+ errors.amount = new NotEnoughBalance();
76
+ }
77
+
78
+ return Promise.resolve({
79
+ errors,
80
+ warnings,
81
+ estimatedFees,
82
+ amount,
83
+ totalSpent,
84
+ });
85
+ };
86
+
87
+ export default getTransactionStatus;
@@ -0,0 +1,39 @@
1
+ import { SignerContext } from "@ledgerhq/coin-framework/lib/signer";
2
+ import { createBridges } from ".";
3
+ import { MinaSigner } from "../types";
4
+ import { MinaCoinConfig } from "../config";
5
+
6
+ describe("createBridges", () => {
7
+ let bridges: ReturnType<typeof createBridges>;
8
+ beforeEach(() => {
9
+ bridges = createBridges(
10
+ undefined as unknown as SignerContext<MinaSigner>,
11
+ {} as unknown as MinaCoinConfig,
12
+ );
13
+ });
14
+
15
+ it("should return both bridges interface", () => {
16
+ expect(bridges.accountBridge).toBeDefined();
17
+ expect(bridges.currencyBridge).toBeDefined();
18
+ });
19
+
20
+ it("should have a currency bridge with required methods", () => {
21
+ expect(bridges.currencyBridge).toBeDefined();
22
+ expect(bridges.currencyBridge.preload).toBeDefined();
23
+ expect(bridges.currencyBridge.hydrate).toBeDefined();
24
+ expect(bridges.currencyBridge.scanAccounts).toBeDefined();
25
+ });
26
+
27
+ it("should have an account bridge with required methods", () => {
28
+ expect(bridges.accountBridge).toBeDefined();
29
+ expect(bridges.accountBridge.broadcast).toBeDefined();
30
+ expect(bridges.accountBridge.createTransaction).toBeDefined();
31
+ expect(bridges.accountBridge.estimateMaxSpendable).toBeDefined();
32
+ expect(bridges.accountBridge.getTransactionStatus).toBeDefined();
33
+ expect(bridges.accountBridge.prepareTransaction).toBeDefined();
34
+ expect(bridges.accountBridge.receive).toBeDefined();
35
+ expect(bridges.accountBridge.signOperation).toBeDefined();
36
+ expect(bridges.accountBridge.sync).toBeDefined();
37
+ expect(bridges.accountBridge.updateTransaction).toBeDefined();
38
+ });
39
+ });
@@ -0,0 +1,72 @@
1
+ import type { AccountBridge, CurrencyBridge } from "@ledgerhq/types-live";
2
+ import {
3
+ makeAccountBridgeReceive,
4
+ getSerializedAddressParameters,
5
+ updateTransaction,
6
+ makeScanAccounts,
7
+ } from "@ledgerhq/coin-framework/bridge/jsHelpers";
8
+ import { SignerContext } from "@ledgerhq/coin-framework/signer";
9
+ import getAddressWrapper from "@ledgerhq/coin-framework/bridge/getAddressWrapper";
10
+ import type { Transaction } from "../types/common";
11
+ import resolver from "../signer/getAddress";
12
+ import { sync, getAccountShape } from "./synchronisation";
13
+ import { MinaSigner } from "../types/signer";
14
+ import { MinaCoinConfig, setCoinConfig } from "../config";
15
+ import broadcast from "./broadcast";
16
+ import { createTransaction } from "./createTransaction";
17
+ import estimateMaxSpendable from "./estimateMaxSpendable";
18
+ import getTransactionStatus from "./getTransactionStatus";
19
+ import { prepareTransaction } from "./prepareTransaction";
20
+ import buildSignOperation from "./signOperation";
21
+ import makeCliTools from "./cli-transaction";
22
+
23
+ export { makeCliTools };
24
+
25
+ export function buildCurrencyBridge(signerContext: SignerContext<MinaSigner>): CurrencyBridge {
26
+ const getAddress = resolver(signerContext);
27
+
28
+ const scanAccounts = makeScanAccounts({
29
+ getAccountShape,
30
+ getAddressFn: getAddress,
31
+ });
32
+
33
+ return {
34
+ preload: async () => Promise.resolve({}),
35
+ hydrate: () => {},
36
+ scanAccounts,
37
+ };
38
+ }
39
+
40
+ export function buildAccountBridge(
41
+ signerContext: SignerContext<MinaSigner>,
42
+ ): AccountBridge<Transaction> {
43
+ const getAddress = resolver(signerContext);
44
+
45
+ const receive = makeAccountBridgeReceive(getAddressWrapper(getAddress));
46
+ const signOperation = buildSignOperation(signerContext);
47
+
48
+ return {
49
+ estimateMaxSpendable,
50
+ createTransaction,
51
+ updateTransaction,
52
+ getTransactionStatus,
53
+ prepareTransaction,
54
+ sync,
55
+ receive,
56
+ signOperation,
57
+ broadcast,
58
+ getSerializedAddressParameters,
59
+ };
60
+ }
61
+
62
+ export function createBridges(
63
+ signerContext: SignerContext<MinaSigner>,
64
+ coinConfig: MinaCoinConfig,
65
+ ) {
66
+ setCoinConfig(coinConfig);
67
+
68
+ return {
69
+ currencyBridge: buildCurrencyBridge(signerContext),
70
+ accountBridge: buildAccountBridge(signerContext),
71
+ };
72
+ }
@@ -0,0 +1,43 @@
1
+ import BigNumber from "bignumber.js";
2
+ import estimateFees from "./getEstimatedFees";
3
+ import { getNonce } from "../api";
4
+ import { prepareTransaction } from "./prepareTransaction";
5
+ import { Account } from "@ledgerhq/types-live";
6
+ import { Transaction } from "../types";
7
+
8
+ jest.mock("../api");
9
+ jest.mock("./getEstimatedFees");
10
+
11
+ describe("prepareTransaction", () => {
12
+ let estimateFeesSpy: jest.SpyInstance;
13
+ let getNonceSpy: jest.SpyInstance;
14
+ beforeEach(() => {
15
+ getNonceSpy = jest.spyOn({ getNonce }, "getNonce");
16
+ estimateFeesSpy = jest.spyOn({ estimateFees }, "estimateFees");
17
+ estimateFeesSpy.mockResolvedValue({
18
+ fee: new BigNumber(1),
19
+ accountCreationFee: new BigNumber(1),
20
+ });
21
+ getNonceSpy.mockResolvedValue(1);
22
+ });
23
+
24
+ it("should update fee fields if it's different", async () => {
25
+ const oldTx = {
26
+ fees: { fee: new BigNumber(0), accountCreationFee: new BigNumber(0) },
27
+ };
28
+ const newTx = await prepareTransaction({} as Account, oldTx as Transaction);
29
+ expect(newTx.fees.fee).toEqual(new BigNumber(1));
30
+ expect(newTx.fees.accountCreationFee).toEqual(new BigNumber(1));
31
+ expect(getNonceSpy).toHaveBeenCalledTimes(1);
32
+ expect(getNonceSpy).toHaveBeenCalledWith(oldTx, undefined);
33
+ });
34
+
35
+ it("should update nonce if it's different", async () => {
36
+ const oldTx = {
37
+ nonce: 0,
38
+ fees: { fee: new BigNumber(0), accountCreationFee: new BigNumber(0) },
39
+ };
40
+ const newTx = await prepareTransaction({} as Account, oldTx as Transaction);
41
+ expect(newTx.nonce).toEqual(1);
42
+ });
43
+ });
@@ -0,0 +1,24 @@
1
+ import { updateTransaction } from "@ledgerhq/coin-framework/bridge/jsHelpers";
2
+ import { Account, AccountBridge } from "@ledgerhq/types-live";
3
+ import estimateMaxSpendable from "./estimateMaxSpendable";
4
+ import getEstimatedFees from "./getEstimatedFees";
5
+ import { MinaAccount, Transaction } from "../types/common";
6
+ import { getNonce } from "../api";
7
+
8
+ export const prepareTransaction: AccountBridge<
9
+ Transaction,
10
+ MinaAccount
11
+ >["prepareTransaction"] = async (a: Account, t: Transaction) => {
12
+ const { fee, accountCreationFee } = await getEstimatedFees(t, a.freshAddress);
13
+
14
+ const amount = t.useAllAmount
15
+ ? await estimateMaxSpendable({
16
+ account: a,
17
+ transaction: t,
18
+ })
19
+ : t.amount;
20
+
21
+ const nonce = await getNonce(t, a.freshAddress);
22
+
23
+ return updateTransaction(t, { fees: { fee, accountCreationFee }, amount, nonce });
24
+ };
@@ -0,0 +1,158 @@
1
+ import { BigNumber } from "bignumber.js";
2
+ import { firstValueFrom } from "rxjs";
3
+ import { encodeOperationId } from "@ledgerhq/coin-framework/operation";
4
+ import { buildSignOperation, buildOptimisticOperation } from "./signOperation";
5
+ import { buildTransaction } from "./buildTransaction";
6
+ import { reEncodeRawSignature } from "../common-logic";
7
+ import {
8
+ createMockAccount,
9
+ createMockTransaction,
10
+ createMockUnsignedTransaction,
11
+ mockDeviceId,
12
+ createMockSignerContext,
13
+ } from "../test/fixtures";
14
+
15
+ // Mock dependencies
16
+ jest.mock("@ledgerhq/coin-framework/operation");
17
+ jest.mock("./buildTransaction");
18
+ jest.mock("../common-logic");
19
+
20
+ describe("signOperation", () => {
21
+ // Mock reset before each test
22
+ beforeEach(() => {
23
+ jest.clearAllMocks();
24
+ // Setup mocks
25
+ (encodeOperationId as jest.Mock).mockReturnValue("mock_operation_id");
26
+ (buildTransaction as jest.Mock).mockResolvedValue(mockUnsignedTransaction);
27
+ (reEncodeRawSignature as jest.Mock).mockReturnValue("encoded_signature");
28
+ });
29
+
30
+ // Use fixtures instead of defining mock data locally
31
+ const mockAccount = createMockAccount();
32
+ const mockTransaction = createMockTransaction();
33
+ const mockUnsignedTransaction = createMockUnsignedTransaction(mockAccount, mockTransaction);
34
+ const mockSignerContext = createMockSignerContext();
35
+
36
+ describe("buildOptimisticOperation", () => {
37
+ it("should build operation with correct values", () => {
38
+ const result = buildOptimisticOperation(mockAccount, mockTransaction, new BigNumber(10));
39
+
40
+ expect(result).toEqual({
41
+ id: "mock_operation_id",
42
+ hash: "",
43
+ type: "OUT",
44
+ value: new BigNumber(1010), // amount + fee
45
+ fee: new BigNumber(10),
46
+ blockHash: null,
47
+ blockHeight: null,
48
+ senders: [mockAccount.freshAddress],
49
+ recipients: [mockTransaction.recipient],
50
+ accountId: mockAccount.id,
51
+ date: expect.any(Date),
52
+ extra: {
53
+ memo: "test memo",
54
+ accountCreationFee: "0",
55
+ },
56
+ });
57
+
58
+ expect(encodeOperationId).toHaveBeenCalledWith(mockAccount.id, "", "OUT");
59
+ });
60
+
61
+ it("should subtract account creation fee from value when present", () => {
62
+ const txWithCreationFee = createMockTransaction({
63
+ fees: {
64
+ fee: new BigNumber(10),
65
+ accountCreationFee: new BigNumber(5),
66
+ },
67
+ });
68
+
69
+ const result = buildOptimisticOperation(mockAccount, txWithCreationFee, new BigNumber(10));
70
+
71
+ // Value should be amount + fee - accountCreationFee = 1000 + 10 - 5 = 1005
72
+ expect(result.value).toEqual(new BigNumber(1005));
73
+ expect(result.extra.accountCreationFee).toBe("5");
74
+ });
75
+ });
76
+
77
+ describe("buildSignOperation", () => {
78
+ it("should emit correct events and return signed operation", done => {
79
+ const signOperation = buildSignOperation(mockSignerContext);
80
+
81
+ const events: string[] = [];
82
+ const observable = signOperation({
83
+ account: mockAccount,
84
+ transaction: mockTransaction,
85
+ deviceId: mockDeviceId,
86
+ });
87
+
88
+ observable.subscribe({
89
+ next: event => {
90
+ events.push(event.type);
91
+
92
+ if (event.type === "signed") {
93
+ const { operation, signature } = event.signedOperation;
94
+
95
+ // Check operation
96
+ expect(operation).toEqual(
97
+ expect.objectContaining({
98
+ id: "mock_operation_id",
99
+ type: "OUT",
100
+ value: new BigNumber(1010),
101
+ fee: new BigNumber(10),
102
+ senders: [mockAccount.freshAddress],
103
+ recipients: [mockTransaction.recipient],
104
+ }),
105
+ );
106
+
107
+ // Check signature
108
+ const parsedSignature = JSON.parse(signature);
109
+ expect(parsedSignature).toEqual({
110
+ transaction: mockUnsignedTransaction,
111
+ signature: "encoded_signature",
112
+ });
113
+ }
114
+ },
115
+ complete: () => {
116
+ // Check all events were emitted in the correct order
117
+ expect(events).toEqual([
118
+ "device-signature-requested",
119
+ "device-signature-granted",
120
+ "signed",
121
+ ]);
122
+ done();
123
+ },
124
+ error: error => done(error),
125
+ });
126
+ });
127
+
128
+ it("should build transaction with correct parameters", async () => {
129
+ const signOperation = buildSignOperation(mockSignerContext);
130
+
131
+ const observable = signOperation({
132
+ account: mockAccount,
133
+ transaction: mockTransaction,
134
+ deviceId: mockDeviceId,
135
+ });
136
+
137
+ await firstValueFrom(observable.pipe());
138
+
139
+ expect(buildTransaction).toHaveBeenCalledWith(mockAccount, mockTransaction);
140
+ });
141
+
142
+ it("should call signer with correct parameters", async () => {
143
+ const mockSignerContextSpy = createMockSignerContext();
144
+
145
+ const signOperation = buildSignOperation(mockSignerContextSpy);
146
+
147
+ const observable = signOperation({
148
+ account: mockAccount,
149
+ transaction: mockTransaction,
150
+ deviceId: mockDeviceId,
151
+ });
152
+
153
+ await firstValueFrom(observable.pipe());
154
+
155
+ expect(mockSignerContextSpy).toHaveBeenCalledWith(mockDeviceId, expect.any(Function));
156
+ });
157
+ });
158
+ });