@ledgerhq/coin-canton 0.2.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 (424) hide show
  1. package/.env.integ.test.example +2 -0
  2. package/.eslintrc.js +22 -0
  3. package/.turbo/turbo-build.log +4 -0
  4. package/.unimportedrc.json +29 -0
  5. package/CHANGELOG.md +14 -0
  6. package/LICENSE.txt +21 -0
  7. package/jest.config.js +21 -0
  8. package/jest.integ.config.js +8 -0
  9. package/lib/api/index.d.ts +4 -0
  10. package/lib/api/index.d.ts.map +1 -0
  11. package/lib/api/index.js +44 -0
  12. package/lib/api/index.js.map +1 -0
  13. package/lib/api/index.test.d.ts +2 -0
  14. package/lib/api/index.test.d.ts.map +1 -0
  15. package/lib/api/index.test.js +16 -0
  16. package/lib/api/index.test.js.map +1 -0
  17. package/lib/bridge/broadcast.d.ts +4 -0
  18. package/lib/bridge/broadcast.d.ts.map +1 -0
  19. package/lib/bridge/broadcast.js +11 -0
  20. package/lib/bridge/broadcast.js.map +1 -0
  21. package/lib/bridge/broadcast.test.d.ts +2 -0
  22. package/lib/bridge/broadcast.test.d.ts.map +1 -0
  23. package/lib/bridge/broadcast.test.js +35 -0
  24. package/lib/bridge/broadcast.test.js.map +1 -0
  25. package/lib/bridge/createTransaction.d.ts +4 -0
  26. package/lib/bridge/createTransaction.d.ts.map +1 -0
  27. package/lib/bridge/createTransaction.js +19 -0
  28. package/lib/bridge/createTransaction.js.map +1 -0
  29. package/lib/bridge/createTransaction.test.d.ts +2 -0
  30. package/lib/bridge/createTransaction.test.d.ts.map +1 -0
  31. package/lib/bridge/createTransaction.test.js +12 -0
  32. package/lib/bridge/createTransaction.test.js.map +1 -0
  33. package/lib/bridge/deviceTransactionConfig.d.ts +11 -0
  34. package/lib/bridge/deviceTransactionConfig.d.ts.map +1 -0
  35. package/lib/bridge/deviceTransactionConfig.js +21 -0
  36. package/lib/bridge/deviceTransactionConfig.js.map +1 -0
  37. package/lib/bridge/deviceTransactionConfig.test.d.ts +2 -0
  38. package/lib/bridge/deviceTransactionConfig.test.d.ts.map +1 -0
  39. package/lib/bridge/deviceTransactionConfig.test.js +22 -0
  40. package/lib/bridge/deviceTransactionConfig.test.js.map +1 -0
  41. package/lib/bridge/estimateMaxSpendable.d.ts +4 -0
  42. package/lib/bridge/estimateMaxSpendable.d.ts.map +1 -0
  43. package/lib/bridge/estimateMaxSpendable.js +26 -0
  44. package/lib/bridge/estimateMaxSpendable.js.map +1 -0
  45. package/lib/bridge/getTransactionStatus.d.ts +4 -0
  46. package/lib/bridge/getTransactionStatus.d.ts.map +1 -0
  47. package/lib/bridge/getTransactionStatus.js +78 -0
  48. package/lib/bridge/getTransactionStatus.js.map +1 -0
  49. package/lib/bridge/index.d.ts +11 -0
  50. package/lib/bridge/index.d.ts.map +1 -0
  51. package/lib/bridge/index.js +51 -0
  52. package/lib/bridge/index.js.map +1 -0
  53. package/lib/bridge/index.test.d.ts +2 -0
  54. package/lib/bridge/index.test.d.ts.map +1 -0
  55. package/lib/bridge/index.test.js +31 -0
  56. package/lib/bridge/index.test.js.map +1 -0
  57. package/lib/bridge/prepareTransaction.d.ts +4 -0
  58. package/lib/bridge/prepareTransaction.d.ts.map +1 -0
  59. package/lib/bridge/prepareTransaction.js +20 -0
  60. package/lib/bridge/prepareTransaction.js.map +1 -0
  61. package/lib/bridge/prepareTransaction.test.d.ts +2 -0
  62. package/lib/bridge/prepareTransaction.test.d.ts.map +1 -0
  63. package/lib/bridge/prepareTransaction.test.js +30 -0
  64. package/lib/bridge/prepareTransaction.test.js.map +1 -0
  65. package/lib/bridge/signOperation.d.ts +5 -0
  66. package/lib/bridge/signOperation.d.ts.map +1 -0
  67. package/lib/bridge/signOperation.js +71 -0
  68. package/lib/bridge/signOperation.js.map +1 -0
  69. package/lib/bridge/sync.d.ts +3 -0
  70. package/lib/bridge/sync.d.ts.map +1 -0
  71. package/lib/bridge/sync.js +86 -0
  72. package/lib/bridge/sync.js.map +1 -0
  73. package/lib/bridge/transaction.d.ts +15 -0
  74. package/lib/bridge/transaction.d.ts.map +1 -0
  75. package/lib/bridge/transaction.js +50 -0
  76. package/lib/bridge/transaction.js.map +1 -0
  77. package/lib/bridge/updateTransaction.d.ts +4 -0
  78. package/lib/bridge/updateTransaction.d.ts.map +1 -0
  79. package/lib/bridge/updateTransaction.js +17 -0
  80. package/lib/bridge/updateTransaction.js.map +1 -0
  81. package/lib/common-logic/account/getBalance.d.ts +3 -0
  82. package/lib/common-logic/account/getBalance.d.ts.map +1 -0
  83. package/lib/common-logic/account/getBalance.js +10 -0
  84. package/lib/common-logic/account/getBalance.js.map +1 -0
  85. package/lib/common-logic/account/getNextSequence.d.ts +2 -0
  86. package/lib/common-logic/account/getNextSequence.d.ts.map +1 -0
  87. package/lib/common-logic/account/getNextSequence.js +9 -0
  88. package/lib/common-logic/account/getNextSequence.js.map +1 -0
  89. package/lib/common-logic/common.d.ts +3 -0
  90. package/lib/common-logic/common.d.ts.map +1 -0
  91. package/lib/common-logic/common.js +11 -0
  92. package/lib/common-logic/common.js.map +1 -0
  93. package/lib/common-logic/history/lastBlock.d.ts +3 -0
  94. package/lib/common-logic/history/lastBlock.d.ts.map +1 -0
  95. package/lib/common-logic/history/lastBlock.js +13 -0
  96. package/lib/common-logic/history/lastBlock.js.map +1 -0
  97. package/lib/common-logic/history/listOperations.d.ts +11 -0
  98. package/lib/common-logic/history/listOperations.d.ts.map +1 -0
  99. package/lib/common-logic/history/listOperations.js +52 -0
  100. package/lib/common-logic/history/listOperations.js.map +1 -0
  101. package/lib/common-logic/index.d.ts +11 -0
  102. package/lib/common-logic/index.d.ts.map +1 -0
  103. package/lib/common-logic/index.js +24 -0
  104. package/lib/common-logic/index.js.map +1 -0
  105. package/lib/common-logic/transaction/broadcast.d.ts +2 -0
  106. package/lib/common-logic/transaction/broadcast.d.ts.map +1 -0
  107. package/lib/common-logic/transaction/broadcast.js +9 -0
  108. package/lib/common-logic/transaction/broadcast.js.map +1 -0
  109. package/lib/common-logic/transaction/combine.d.ts +2 -0
  110. package/lib/common-logic/transaction/combine.d.ts.map +1 -0
  111. package/lib/common-logic/transaction/combine.js +9 -0
  112. package/lib/common-logic/transaction/combine.js.map +1 -0
  113. package/lib/common-logic/transaction/craftTransaction.d.ts +15 -0
  114. package/lib/common-logic/transaction/craftTransaction.d.ts.map +1 -0
  115. package/lib/common-logic/transaction/craftTransaction.js +20 -0
  116. package/lib/common-logic/transaction/craftTransaction.js.map +1 -0
  117. package/lib/common-logic/transaction/estimateFees.d.ts +2 -0
  118. package/lib/common-logic/transaction/estimateFees.d.ts.map +1 -0
  119. package/lib/common-logic/transaction/estimateFees.js +21 -0
  120. package/lib/common-logic/transaction/estimateFees.js.map +1 -0
  121. package/lib/common-logic/utils.d.ts +6 -0
  122. package/lib/common-logic/utils.d.ts.map +1 -0
  123. package/lib/common-logic/utils.js +22 -0
  124. package/lib/common-logic/utils.js.map +1 -0
  125. package/lib/config.d.ts +12 -0
  126. package/lib/config.d.ts.map +1 -0
  127. package/lib/config.js +9 -0
  128. package/lib/config.js.map +1 -0
  129. package/lib/index.d.ts +4 -0
  130. package/lib/index.d.ts.map +1 -0
  131. package/lib/index.js +21 -0
  132. package/lib/index.js.map +1 -0
  133. package/lib/network/indexer.d.ts +6 -0
  134. package/lib/network/indexer.d.ts.map +1 -0
  135. package/lib/network/indexer.js +19 -0
  136. package/lib/network/indexer.js.map +1 -0
  137. package/lib/network/mock-network.d.ts +5 -0
  138. package/lib/network/mock-network.d.ts.map +1 -0
  139. package/lib/network/mock-network.js +29 -0
  140. package/lib/network/mock-network.js.map +1 -0
  141. package/lib/network/node.d.ts +12 -0
  142. package/lib/network/node.d.ts.map +1 -0
  143. package/lib/network/node.js +92 -0
  144. package/lib/network/node.js.map +1 -0
  145. package/lib/network/types.d.ts +47 -0
  146. package/lib/network/types.d.ts.map +1 -0
  147. package/lib/network/types.js +7 -0
  148. package/lib/network/types.js.map +1 -0
  149. package/lib/signer/getAddress.d.ts +6 -0
  150. package/lib/signer/getAddress.d.ts.map +1 -0
  151. package/lib/signer/getAddress.js +14 -0
  152. package/lib/signer/getAddress.js.map +1 -0
  153. package/lib/signer/index.d.ts +6 -0
  154. package/lib/signer/index.d.ts.map +1 -0
  155. package/lib/signer/index.js +11 -0
  156. package/lib/signer/index.js.map +1 -0
  157. package/lib/test/bot-deviceActions.d.ts +4 -0
  158. package/lib/test/bot-deviceActions.d.ts.map +1 -0
  159. package/lib/test/bot-deviceActions.js +44 -0
  160. package/lib/test/bot-deviceActions.js.map +1 -0
  161. package/lib/test/bot-specs.d.ts +2 -0
  162. package/lib/test/bot-specs.d.ts.map +1 -0
  163. package/lib/test/bot-specs.js +79 -0
  164. package/lib/test/bot-specs.js.map +1 -0
  165. package/lib/test/bridgeDatasetTest.d.ts +5 -0
  166. package/lib/test/bridgeDatasetTest.d.ts.map +1 -0
  167. package/lib/test/bridgeDatasetTest.js +148 -0
  168. package/lib/test/bridgeDatasetTest.js.map +1 -0
  169. package/lib/test/cli.d.ts +26 -0
  170. package/lib/test/cli.d.ts.map +1 -0
  171. package/lib/test/cli.js +36 -0
  172. package/lib/test/cli.js.map +1 -0
  173. package/lib/test/index.d.ts +5 -0
  174. package/lib/test/index.d.ts.map +1 -0
  175. package/lib/test/index.js +26 -0
  176. package/lib/test/index.js.map +1 -0
  177. package/lib/types/bridge.d.ts +23 -0
  178. package/lib/types/bridge.d.ts.map +1 -0
  179. package/lib/types/bridge.js +3 -0
  180. package/lib/types/bridge.js.map +1 -0
  181. package/lib/types/errors.d.ts +4 -0
  182. package/lib/types/errors.d.ts.map +1 -0
  183. package/lib/types/errors.js +6 -0
  184. package/lib/types/errors.js.map +1 -0
  185. package/lib/types/index.d.ts +13 -0
  186. package/lib/types/index.d.ts.map +1 -0
  187. package/lib/types/index.js +19 -0
  188. package/lib/types/index.js.map +1 -0
  189. package/lib/types/signer.d.ts +10 -0
  190. package/lib/types/signer.d.ts.map +1 -0
  191. package/lib/types/signer.js +3 -0
  192. package/lib/types/signer.js.map +1 -0
  193. package/lib-es/api/index.d.ts +4 -0
  194. package/lib-es/api/index.d.ts.map +1 -0
  195. package/lib-es/api/index.js +38 -0
  196. package/lib-es/api/index.js.map +1 -0
  197. package/lib-es/api/index.test.d.ts +2 -0
  198. package/lib-es/api/index.test.d.ts.map +1 -0
  199. package/lib-es/api/index.test.js +14 -0
  200. package/lib-es/api/index.test.js.map +1 -0
  201. package/lib-es/bridge/broadcast.d.ts +4 -0
  202. package/lib-es/bridge/broadcast.d.ts.map +1 -0
  203. package/lib-es/bridge/broadcast.js +7 -0
  204. package/lib-es/bridge/broadcast.js.map +1 -0
  205. package/lib-es/bridge/broadcast.test.d.ts +2 -0
  206. package/lib-es/bridge/broadcast.test.d.ts.map +1 -0
  207. package/lib-es/bridge/broadcast.test.js +33 -0
  208. package/lib-es/bridge/broadcast.test.js.map +1 -0
  209. package/lib-es/bridge/createTransaction.d.ts +4 -0
  210. package/lib-es/bridge/createTransaction.d.ts.map +1 -0
  211. package/lib-es/bridge/createTransaction.js +12 -0
  212. package/lib-es/bridge/createTransaction.js.map +1 -0
  213. package/lib-es/bridge/createTransaction.test.d.ts +2 -0
  214. package/lib-es/bridge/createTransaction.test.d.ts.map +1 -0
  215. package/lib-es/bridge/createTransaction.test.js +10 -0
  216. package/lib-es/bridge/createTransaction.test.js.map +1 -0
  217. package/lib-es/bridge/deviceTransactionConfig.d.ts +11 -0
  218. package/lib-es/bridge/deviceTransactionConfig.d.ts.map +1 -0
  219. package/lib-es/bridge/deviceTransactionConfig.js +19 -0
  220. package/lib-es/bridge/deviceTransactionConfig.js.map +1 -0
  221. package/lib-es/bridge/deviceTransactionConfig.test.d.ts +2 -0
  222. package/lib-es/bridge/deviceTransactionConfig.test.d.ts.map +1 -0
  223. package/lib-es/bridge/deviceTransactionConfig.test.js +17 -0
  224. package/lib-es/bridge/deviceTransactionConfig.test.js.map +1 -0
  225. package/lib-es/bridge/estimateMaxSpendable.d.ts +4 -0
  226. package/lib-es/bridge/estimateMaxSpendable.d.ts.map +1 -0
  227. package/lib-es/bridge/estimateMaxSpendable.js +19 -0
  228. package/lib-es/bridge/estimateMaxSpendable.js.map +1 -0
  229. package/lib-es/bridge/getTransactionStatus.d.ts +4 -0
  230. package/lib-es/bridge/getTransactionStatus.d.ts.map +1 -0
  231. package/lib-es/bridge/getTransactionStatus.js +71 -0
  232. package/lib-es/bridge/getTransactionStatus.js.map +1 -0
  233. package/lib-es/bridge/index.d.ts +11 -0
  234. package/lib-es/bridge/index.d.ts.map +1 -0
  235. package/lib-es/bridge/index.js +45 -0
  236. package/lib-es/bridge/index.js.map +1 -0
  237. package/lib-es/bridge/index.test.d.ts +2 -0
  238. package/lib-es/bridge/index.test.d.ts.map +1 -0
  239. package/lib-es/bridge/index.test.js +29 -0
  240. package/lib-es/bridge/index.test.js.map +1 -0
  241. package/lib-es/bridge/prepareTransaction.d.ts +4 -0
  242. package/lib-es/bridge/prepareTransaction.d.ts.map +1 -0
  243. package/lib-es/bridge/prepareTransaction.js +13 -0
  244. package/lib-es/bridge/prepareTransaction.js.map +1 -0
  245. package/lib-es/bridge/prepareTransaction.test.d.ts +2 -0
  246. package/lib-es/bridge/prepareTransaction.test.d.ts.map +1 -0
  247. package/lib-es/bridge/prepareTransaction.test.js +25 -0
  248. package/lib-es/bridge/prepareTransaction.test.js.map +1 -0
  249. package/lib-es/bridge/signOperation.d.ts +5 -0
  250. package/lib-es/bridge/signOperation.d.ts.map +1 -0
  251. package/lib-es/bridge/signOperation.js +67 -0
  252. package/lib-es/bridge/signOperation.js.map +1 -0
  253. package/lib-es/bridge/sync.d.ts +3 -0
  254. package/lib-es/bridge/sync.d.ts.map +1 -0
  255. package/lib-es/bridge/sync.js +79 -0
  256. package/lib-es/bridge/sync.js.map +1 -0
  257. package/lib-es/bridge/transaction.d.ts +15 -0
  258. package/lib-es/bridge/transaction.d.ts.map +1 -0
  259. package/lib-es/bridge/transaction.js +44 -0
  260. package/lib-es/bridge/transaction.js.map +1 -0
  261. package/lib-es/bridge/updateTransaction.d.ts +4 -0
  262. package/lib-es/bridge/updateTransaction.d.ts.map +1 -0
  263. package/lib-es/bridge/updateTransaction.js +13 -0
  264. package/lib-es/bridge/updateTransaction.js.map +1 -0
  265. package/lib-es/common-logic/account/getBalance.d.ts +3 -0
  266. package/lib-es/common-logic/account/getBalance.d.ts.map +1 -0
  267. package/lib-es/common-logic/account/getBalance.js +7 -0
  268. package/lib-es/common-logic/account/getBalance.js.map +1 -0
  269. package/lib-es/common-logic/account/getNextSequence.d.ts +2 -0
  270. package/lib-es/common-logic/account/getNextSequence.d.ts.map +1 -0
  271. package/lib-es/common-logic/account/getNextSequence.js +6 -0
  272. package/lib-es/common-logic/account/getNextSequence.js.map +1 -0
  273. package/lib-es/common-logic/common.d.ts +3 -0
  274. package/lib-es/common-logic/common.d.ts.map +1 -0
  275. package/lib-es/common-logic/common.js +7 -0
  276. package/lib-es/common-logic/common.js.map +1 -0
  277. package/lib-es/common-logic/history/lastBlock.d.ts +3 -0
  278. package/lib-es/common-logic/history/lastBlock.d.ts.map +1 -0
  279. package/lib-es/common-logic/history/lastBlock.js +10 -0
  280. package/lib-es/common-logic/history/lastBlock.js.map +1 -0
  281. package/lib-es/common-logic/history/listOperations.d.ts +11 -0
  282. package/lib-es/common-logic/history/listOperations.d.ts.map +1 -0
  283. package/lib-es/common-logic/history/listOperations.js +49 -0
  284. package/lib-es/common-logic/history/listOperations.js.map +1 -0
  285. package/lib-es/common-logic/index.d.ts +11 -0
  286. package/lib-es/common-logic/index.d.ts.map +1 -0
  287. package/lib-es/common-logic/index.js +11 -0
  288. package/lib-es/common-logic/index.js.map +1 -0
  289. package/lib-es/common-logic/transaction/broadcast.d.ts +2 -0
  290. package/lib-es/common-logic/transaction/broadcast.d.ts.map +1 -0
  291. package/lib-es/common-logic/transaction/broadcast.js +6 -0
  292. package/lib-es/common-logic/transaction/broadcast.js.map +1 -0
  293. package/lib-es/common-logic/transaction/combine.d.ts +2 -0
  294. package/lib-es/common-logic/transaction/combine.d.ts.map +1 -0
  295. package/lib-es/common-logic/transaction/combine.js +6 -0
  296. package/lib-es/common-logic/transaction/combine.js.map +1 -0
  297. package/lib-es/common-logic/transaction/craftTransaction.d.ts +15 -0
  298. package/lib-es/common-logic/transaction/craftTransaction.d.ts.map +1 -0
  299. package/lib-es/common-logic/transaction/craftTransaction.js +17 -0
  300. package/lib-es/common-logic/transaction/craftTransaction.js.map +1 -0
  301. package/lib-es/common-logic/transaction/estimateFees.d.ts +2 -0
  302. package/lib-es/common-logic/transaction/estimateFees.d.ts.map +1 -0
  303. package/lib-es/common-logic/transaction/estimateFees.js +18 -0
  304. package/lib-es/common-logic/transaction/estimateFees.js.map +1 -0
  305. package/lib-es/common-logic/utils.d.ts +6 -0
  306. package/lib-es/common-logic/utils.d.ts.map +1 -0
  307. package/lib-es/common-logic/utils.js +13 -0
  308. package/lib-es/common-logic/utils.js.map +1 -0
  309. package/lib-es/config.d.ts +12 -0
  310. package/lib-es/config.d.ts.map +1 -0
  311. package/lib-es/config.js +4 -0
  312. package/lib-es/config.js.map +1 -0
  313. package/lib-es/index.d.ts +4 -0
  314. package/lib-es/index.d.ts.map +1 -0
  315. package/lib-es/index.js +3 -0
  316. package/lib-es/index.js.map +1 -0
  317. package/lib-es/network/indexer.d.ts +6 -0
  318. package/lib-es/network/indexer.d.ts.map +1 -0
  319. package/lib-es/network/indexer.js +12 -0
  320. package/lib-es/network/indexer.js.map +1 -0
  321. package/lib-es/network/mock-network.d.ts +5 -0
  322. package/lib-es/network/mock-network.d.ts.map +1 -0
  323. package/lib-es/network/mock-network.js +25 -0
  324. package/lib-es/network/mock-network.js.map +1 -0
  325. package/lib-es/network/node.d.ts +12 -0
  326. package/lib-es/network/node.d.ts.map +1 -0
  327. package/lib-es/network/node.js +80 -0
  328. package/lib-es/network/node.js.map +1 -0
  329. package/lib-es/network/types.d.ts +47 -0
  330. package/lib-es/network/types.d.ts.map +1 -0
  331. package/lib-es/network/types.js +4 -0
  332. package/lib-es/network/types.js.map +1 -0
  333. package/lib-es/signer/getAddress.d.ts +6 -0
  334. package/lib-es/signer/getAddress.d.ts.map +1 -0
  335. package/lib-es/signer/getAddress.js +12 -0
  336. package/lib-es/signer/getAddress.js.map +1 -0
  337. package/lib-es/signer/index.d.ts +6 -0
  338. package/lib-es/signer/index.d.ts.map +1 -0
  339. package/lib-es/signer/index.js +6 -0
  340. package/lib-es/signer/index.js.map +1 -0
  341. package/lib-es/test/bot-deviceActions.d.ts +4 -0
  342. package/lib-es/test/bot-deviceActions.d.ts.map +1 -0
  343. package/lib-es/test/bot-deviceActions.js +41 -0
  344. package/lib-es/test/bot-deviceActions.js.map +1 -0
  345. package/lib-es/test/bot-specs.d.ts +1 -0
  346. package/lib-es/test/bot-specs.d.ts.map +1 -0
  347. package/lib-es/test/bot-specs.js +78 -0
  348. package/lib-es/test/bot-specs.js.map +1 -0
  349. package/lib-es/test/bridgeDatasetTest.d.ts +5 -0
  350. package/lib-es/test/bridgeDatasetTest.d.ts.map +1 -0
  351. package/lib-es/test/bridgeDatasetTest.js +142 -0
  352. package/lib-es/test/bridgeDatasetTest.js.map +1 -0
  353. package/lib-es/test/cli.d.ts +26 -0
  354. package/lib-es/test/cli.d.ts.map +1 -0
  355. package/lib-es/test/cli.js +30 -0
  356. package/lib-es/test/cli.js.map +1 -0
  357. package/lib-es/test/index.d.ts +5 -0
  358. package/lib-es/test/index.d.ts.map +1 -0
  359. package/lib-es/test/index.js +6 -0
  360. package/lib-es/test/index.js.map +1 -0
  361. package/lib-es/types/bridge.d.ts +23 -0
  362. package/lib-es/types/bridge.d.ts.map +1 -0
  363. package/lib-es/types/bridge.js +2 -0
  364. package/lib-es/types/bridge.js.map +1 -0
  365. package/lib-es/types/errors.d.ts +4 -0
  366. package/lib-es/types/errors.d.ts.map +1 -0
  367. package/lib-es/types/errors.js +3 -0
  368. package/lib-es/types/errors.js.map +1 -0
  369. package/lib-es/types/index.d.ts +13 -0
  370. package/lib-es/types/index.d.ts.map +1 -0
  371. package/lib-es/types/index.js +3 -0
  372. package/lib-es/types/index.js.map +1 -0
  373. package/lib-es/types/signer.d.ts +10 -0
  374. package/lib-es/types/signer.d.ts.map +1 -0
  375. package/lib-es/types/signer.js +2 -0
  376. package/lib-es/types/signer.js.map +1 -0
  377. package/package.json +137 -0
  378. package/src/api/index.test.ts +15 -0
  379. package/src/api/index.ts +65 -0
  380. package/src/bridge/broadcast.test.ts +36 -0
  381. package/src/bridge/broadcast.ts +11 -0
  382. package/src/bridge/createTransaction.test.ts +12 -0
  383. package/src/bridge/createTransaction.ts +14 -0
  384. package/src/bridge/deviceTransactionConfig.test.ts +22 -0
  385. package/src/bridge/deviceTransactionConfig.ts +34 -0
  386. package/src/bridge/estimateMaxSpendable.ts +25 -0
  387. package/src/bridge/getTransactionStatus.ts +88 -0
  388. package/src/bridge/index.test.ts +31 -0
  389. package/src/bridge/index.ts +62 -0
  390. package/src/bridge/prepareTransaction.test.ts +29 -0
  391. package/src/bridge/prepareTransaction.ts +25 -0
  392. package/src/bridge/signOperation.ts +93 -0
  393. package/src/bridge/sync.ts +106 -0
  394. package/src/bridge/transaction.ts +61 -0
  395. package/src/bridge/updateTransaction.ts +17 -0
  396. package/src/common-logic/account/getBalance.ts +8 -0
  397. package/src/common-logic/account/getNextSequence.ts +6 -0
  398. package/src/common-logic/common.ts +9 -0
  399. package/src/common-logic/history/lastBlock.ts +11 -0
  400. package/src/common-logic/history/listOperations.ts +64 -0
  401. package/src/common-logic/index.ts +11 -0
  402. package/src/common-logic/transaction/broadcast.ts +6 -0
  403. package/src/common-logic/transaction/combine.ts +6 -0
  404. package/src/common-logic/transaction/craftTransaction.ts +36 -0
  405. package/src/common-logic/transaction/estimateFees.ts +16 -0
  406. package/src/common-logic/utils.ts +18 -0
  407. package/src/config.ts +12 -0
  408. package/src/index.ts +4 -0
  409. package/src/network/indexer.ts +17 -0
  410. package/src/network/mock-network.ts +25 -0
  411. package/src/network/node.ts +94 -0
  412. package/src/network/types.ts +51 -0
  413. package/src/signer/getAddress.ts +20 -0
  414. package/src/signer/index.ts +7 -0
  415. package/src/test/bot-deviceActions.ts +48 -0
  416. package/src/test/bot-specs.ts +76 -0
  417. package/src/test/bridgeDatasetTest.ts +147 -0
  418. package/src/test/cli.ts +44 -0
  419. package/src/test/index.ts +6 -0
  420. package/src/types/bridge.ts +33 -0
  421. package/src/types/errors.ts +3 -0
  422. package/src/types/index.ts +13 -0
  423. package/src/types/signer.ts +11 -0
  424. package/tsconfig.json +12 -0
@@ -0,0 +1,26 @@
1
+ import type { AccountLike } from "@ledgerhq/types-live";
2
+ import type { Transaction } from "../types";
3
+ import BigNumber from "bignumber.js";
4
+ declare function inferTransactions(transactions: Array<{
5
+ account: AccountLike;
6
+ transaction: Transaction;
7
+ }>, opts: {
8
+ tag?: number | null | undefined;
9
+ fee?: string;
10
+ }, { inferAmount, }: {
11
+ inferAmount: (account: AccountLike, fee?: string) => BigNumber | null | undefined;
12
+ }): Transaction[];
13
+ export default function makeCliTools(): {
14
+ options: ({
15
+ name: string;
16
+ type: StringConstructor;
17
+ desc: string;
18
+ } | {
19
+ name: string;
20
+ type: NumberConstructor;
21
+ desc: string;
22
+ })[];
23
+ inferTransactions: typeof inferTransactions;
24
+ };
25
+ export {};
26
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/test/cli.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,SAAS,MAAM,cAAc,CAAC;AAerC,iBAAS,iBAAiB,CACxB,YAAY,EAAE,KAAK,CAAC;IAClB,OAAO,EAAE,WAAW,CAAC;IACrB,WAAW,EAAE,WAAW,CAAC;CAC1B,CAAC,EACF,IAAI,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,EACvD,EACE,WAAW,GACZ,EAAE;IAAE,WAAW,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,CAAC,EAAE,MAAM,KAAK,SAAS,GAAG,IAAI,GAAG,SAAS,CAAA;CAAE,GACvF,WAAW,EAAE,CASf;AAED,MAAM,CAAC,OAAO,UAAU,YAAY;;;;;;;;;;;EAKnC"}
@@ -0,0 +1,30 @@
1
+ import invariant from "invariant";
2
+ const options = [
3
+ {
4
+ name: "fee",
5
+ type: String,
6
+ desc: "how much fee",
7
+ },
8
+ {
9
+ name: "tag",
10
+ type: Number,
11
+ desc: "ripple tag",
12
+ },
13
+ ];
14
+ function inferTransactions(transactions, opts, { inferAmount, }) {
15
+ return transactions.flatMap(({ transaction, account }) => {
16
+ invariant(transaction.family === "canton", "Canton family");
17
+ return {
18
+ ...transaction,
19
+ fee: inferAmount(account, opts.fee || "0.001brp"),
20
+ tag: opts.tag,
21
+ };
22
+ });
23
+ }
24
+ export default function makeCliTools() {
25
+ return {
26
+ options,
27
+ inferTransactions,
28
+ };
29
+ }
30
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/test/cli.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAKlC,MAAM,OAAO,GAAG;IACd;QACE,IAAI,EAAE,KAAK;QACX,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,cAAc;KACrB;IACD;QACE,IAAI,EAAE,KAAK;QACX,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,YAAY;KACnB;CACF,CAAC;AAEF,SAAS,iBAAiB,CACxB,YAGE,EACF,IAAuD,EACvD,EACE,WAAW,GAC2E;IAExF,OAAO,YAAY,CAAC,OAAO,CAAC,CAAC,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE,EAAE;QACvD,SAAS,CAAC,WAAW,CAAC,MAAM,KAAK,QAAQ,EAAE,eAAe,CAAC,CAAC;QAC5D,OAAO;YACL,GAAG,WAAW;YACd,GAAG,EAAE,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,IAAI,UAAU,CAAC;YACjD,GAAG,EAAE,IAAI,CAAC,GAAG;SACd,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,OAAO,UAAU,YAAY;IAClC,OAAO;QACL,OAAO;QACP,iBAAiB;KAClB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,5 @@
1
+ import makeCliTools from "./cli";
2
+ export * from "./bridgeDatasetTest";
3
+ export { makeCliTools };
4
+ export * from "./bot-deviceActions";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,OAAO,CAAC;AAEjC,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,CAAC;AACxB,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,6 @@
1
+ import makeCliTools from "./cli";
2
+ export * from "./bridgeDatasetTest";
3
+ export { makeCliTools };
4
+ export * from "./bot-deviceActions";
5
+ // export * from "./bot-specs";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/test/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,OAAO,CAAC;AAEjC,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,CAAC;AACxB,cAAc,qBAAqB,CAAC;AACpC,+BAA+B"}
@@ -0,0 +1,23 @@
1
+ import type { BigNumber } from "bignumber.js";
2
+ import type { TransactionCommon, TransactionCommonRaw, TransactionStatusCommon, TransactionStatusCommonRaw } from "@ledgerhq/types-live";
3
+ export type NetworkInfo = {
4
+ family: "canton";
5
+ serverFee: BigNumber;
6
+ baseReserve: BigNumber;
7
+ };
8
+ export type NetworkInfoRaw = {
9
+ family: "canton";
10
+ serverFee: string;
11
+ baseReserve: string;
12
+ };
13
+ export type Transaction = TransactionCommon & {
14
+ family: "canton";
15
+ fee: BigNumber | null | undefined;
16
+ };
17
+ export type TransactionRaw = TransactionCommonRaw & {
18
+ family: "canton";
19
+ fee: string | null | undefined;
20
+ };
21
+ export type TransactionStatus = TransactionStatusCommon;
22
+ export type TransactionStatusRaw = TransactionStatusCommonRaw;
23
+ //# sourceMappingURL=bridge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../../src/types/bridge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,KAAK,EACV,iBAAiB,EACjB,oBAAoB,EACpB,uBAAuB,EACvB,0BAA0B,EAC3B,MAAM,sBAAsB,CAAC;AAE9B,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,QAAQ,CAAC;IACjB,SAAS,EAAE,SAAS,CAAC;IACrB,WAAW,EAAE,SAAS,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,QAAQ,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,iBAAiB,GAAG;IAC5C,MAAM,EAAE,QAAQ,CAAC;IACjB,GAAG,EAAE,SAAS,GAAG,IAAI,GAAG,SAAS,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,oBAAoB,GAAG;IAClD,MAAM,EAAE,QAAQ,CAAC;IACjB,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,uBAAuB,CAAC;AACxD,MAAM,MAAM,oBAAoB,GAAG,0BAA0B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=bridge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bridge.js","sourceRoot":"","sources":["../../src/types/bridge.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ export declare const SimulationError: import("@ledgerhq/errors/lib/helpers").LedgerErrorConstructor<{
2
+ [key: string]: unknown;
3
+ }>;
4
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/types/errors.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe;;EAA4C,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { createCustomErrorClass } from "@ledgerhq/errors";
2
+ export const SimulationError = createCustomErrorClass("SimulationError");
3
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/types/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE1D,MAAM,CAAC,MAAM,eAAe,GAAG,sBAAsB,CAAC,iBAAiB,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ export * from "./bridge";
2
+ export * from "./signer";
3
+ export type BoilerplateNativeTransaction = {
4
+ TransactionType: "Payment";
5
+ Account: string;
6
+ Amount: string;
7
+ Destination: string;
8
+ Fee: string;
9
+ Sequence: number;
10
+ SigningPubKey?: string;
11
+ TxnSignature?: string;
12
+ };
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AAEzB,MAAM,MAAM,4BAA4B,GAAG;IACzC,eAAe,EAAE,SAAS,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from "./bridge";
2
+ export * from "./signer";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC"}
@@ -0,0 +1,10 @@
1
+ export type BoilerplateAddress = {
2
+ publicKey: string;
3
+ address: string;
4
+ };
5
+ export type BoilerplateSignature = string;
6
+ export interface BoilerplateSigner {
7
+ getAddress(path: string): Promise<BoilerplateAddress>;
8
+ signTransaction(path: string, rawTx: string): Promise<BoilerplateSignature>;
9
+ }
10
+ //# sourceMappingURL=signer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../src/types/signer.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC;AAE1C,MAAM,WAAW,iBAAiB;IAChC,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACtD,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;CAC7E"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=signer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signer.js","sourceRoot":"","sources":["../../src/types/signer.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,137 @@
1
+ {
2
+ "name": "@ledgerhq/coin-canton",
3
+ "version": "0.2.0-nightly.0",
4
+ "description": "Canton coin integration",
5
+ "keywords": [
6
+ "Ledger",
7
+ "LedgerWallet",
8
+ "canton",
9
+ "Hardware Wallet"
10
+ ],
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/LedgerHQ/ledger-live.git"
14
+ },
15
+ "bugs": {
16
+ "url": "https://github.com/LedgerHQ/ledger-live/issues"
17
+ },
18
+ "homepage": "https://github.com/LedgerHQ/ledger-live/tree/develop/libs/coin-modules/coin-canton",
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "typesVersions": {
23
+ "*": {
24
+ "lib/*": [
25
+ "lib/*"
26
+ ],
27
+ "lib-es/*": [
28
+ "lib-es/*"
29
+ ],
30
+ "api": [
31
+ "lib/api/index"
32
+ ],
33
+ "deviceTransactionConfig": [
34
+ "lib/bridge/deviceTransactionConfig"
35
+ ],
36
+ "logic": [
37
+ "lib/logic/index"
38
+ ],
39
+ "specs": [
40
+ "lib/test/bot-specs"
41
+ ],
42
+ "transaction": [
43
+ "lib/bridge/transaction"
44
+ ],
45
+ "types": [
46
+ "lib/types/index"
47
+ ],
48
+ "*": [
49
+ "lib/*",
50
+ "lib/bridge/*",
51
+ "lib/logic/*",
52
+ "lib/signer/*",
53
+ "lib/test/*",
54
+ "lib/types/*"
55
+ ]
56
+ }
57
+ },
58
+ "exports": {
59
+ "./lib/*": "./lib/*.js",
60
+ "./lib-es/*": "./lib-es/*.js",
61
+ "./api": {
62
+ "require": "./lib/api/index.js",
63
+ "default": "./lib-es/api/index.js"
64
+ },
65
+ "./deviceTransactionConfig": {
66
+ "require": "./lib/bridge/deviceTransactionConfig.js",
67
+ "default": "./lib-es/bridge/deviceTransactionConfig.js"
68
+ },
69
+ "./logic": {
70
+ "require": "./lib/logic/index.js",
71
+ "default": "./lib-es/logic/index.js"
72
+ },
73
+ "./signer": {
74
+ "require": "./lib/signer/index.js",
75
+ "default": "./lib-es/signer/index.js"
76
+ },
77
+ "./specs": {
78
+ "require": "./lib/test/bot-specs.js",
79
+ "default": "./lib-es/test/bot-specs.js"
80
+ },
81
+ "./transaction": {
82
+ "require": "./lib/bridge/transaction.js",
83
+ "default": "./lib-es/bridge/transaction.js"
84
+ },
85
+ "./types": {
86
+ "require": "./lib/types/index.js",
87
+ "default": "./lib-es/types/index.js"
88
+ },
89
+ "./*": {
90
+ "require": "./lib/*.js",
91
+ "default": "./lib-es/*.js"
92
+ },
93
+ ".": {
94
+ "require": "./lib/index.js",
95
+ "default": "./lib-es/index.js"
96
+ },
97
+ "./package.json": "./package.json"
98
+ },
99
+ "license": "Apache-2.0",
100
+ "dependencies": {
101
+ "bignumber.js": "^9.1.2",
102
+ "invariant": "^2.2.4",
103
+ "rxjs": "^7.8.1",
104
+ "@ledgerhq/coin-framework": "^6.0.0-nightly.3",
105
+ "@ledgerhq/cryptoassets": "^13.23.0-nightly.2",
106
+ "@ledgerhq/devices": "8.4.8",
107
+ "@ledgerhq/errors": "^6.23.0",
108
+ "@ledgerhq/live-env": "^2.13.0-nightly.0",
109
+ "@ledgerhq/live-network": "^2.0.14-nightly.0",
110
+ "@ledgerhq/types-live": "^6.79.0-nightly.1"
111
+ },
112
+ "devDependencies": {
113
+ "@types/invariant": "^2.2.37",
114
+ "@types/jest": "^29.5.12",
115
+ "dotenv": "^16.4.5",
116
+ "expect": "^27.4.6",
117
+ "jest": "^29.7.0",
118
+ "ts-jest": "^29.1.1",
119
+ "typescript": "^5.4.5",
120
+ "@ledgerhq/types-cryptoassets": "^7.24.0-nightly.1",
121
+ "@ledgerhq/disable-network-setup": "^0.0.0"
122
+ },
123
+ "scripts": {
124
+ "clean": "rimraf lib lib-es",
125
+ "build": "tsc && tsc -m esnext --moduleResolution bundler --outDir lib-es",
126
+ "coverage": "jest --coverage || true",
127
+ "prewatch": "pnpm build",
128
+ "watch": "tsc --watch",
129
+ "doc": "documentation readme src/** --section=API --pe ts --re ts --re d.ts",
130
+ "lint": "eslint ./src --no-error-on-unmatched-pattern --ext .ts,.tsx --cache",
131
+ "lint:fix": "pnpm lint --fix",
132
+ "test": "jest",
133
+ "test-integ": "DOTENV_CONFIG_PATH=.env.integ.test jest --config=jest.integ.config.js --passWithNoTests",
134
+ "typecheck": "tsc --noEmit",
135
+ "unimported": "unimported"
136
+ }
137
+ }
@@ -0,0 +1,15 @@
1
+ import { createApi } from ".";
2
+ import { CantonConfig } from "../config";
3
+
4
+ describe("createApi", () => {
5
+ it("should return every api methods", () => {
6
+ const api = createApi({} as CantonConfig);
7
+ expect(api.broadcast).toBeDefined();
8
+ expect(api.combine).toBeDefined();
9
+ expect(api.craftTransaction).toBeDefined();
10
+ expect(api.estimateFees).toBeDefined();
11
+ expect(api.getBalance).toBeDefined();
12
+ expect(api.lastBlock).toBeDefined();
13
+ expect(api.listOperations).toBeDefined();
14
+ });
15
+ });
@@ -0,0 +1,65 @@
1
+ import {
2
+ AlpacaApi,
3
+ Block,
4
+ BlockInfo,
5
+ FeeEstimation,
6
+ TransactionIntent,
7
+ } from "@ledgerhq/coin-framework/api/index";
8
+ import coinConfig, { type CantonConfig } from "../config";
9
+ import {
10
+ broadcast,
11
+ combine,
12
+ craftTransaction,
13
+ estimateFees,
14
+ getBalance,
15
+ getNextValidSequence,
16
+ lastBlock,
17
+ listOperations,
18
+ } from "../common-logic";
19
+ import BigNumber from "bignumber.js";
20
+
21
+ export function createApi(config: CantonConfig): AlpacaApi {
22
+ coinConfig.setCoinConfig(() => ({ ...config, status: { type: "active" } }));
23
+
24
+ return {
25
+ broadcast,
26
+ combine,
27
+ craftTransaction: craft,
28
+ estimateFees: estimate,
29
+ getBalance,
30
+ lastBlock,
31
+ listOperations,
32
+ getBlock(_height): Promise<Block> {
33
+ throw new Error("getBlock is not supported");
34
+ },
35
+ getBlockInfo(_height: number): Promise<BlockInfo> {
36
+ throw new Error("getBlockInfo is not supported");
37
+ },
38
+ };
39
+ }
40
+
41
+ async function craft(transactionIntent: TransactionIntent): Promise<string> {
42
+ const nextSequenceNumber = await getNextValidSequence(transactionIntent.sender);
43
+ const tx = await craftTransaction(
44
+ { address: transactionIntent.sender, nextSequenceNumber },
45
+ {
46
+ recipient: transactionIntent.recipient,
47
+ amount: new BigNumber(transactionIntent.amount.toString()),
48
+ },
49
+ );
50
+ return tx.serializedTransaction;
51
+ }
52
+
53
+ async function estimate(transactionIntent: TransactionIntent): Promise<FeeEstimation> {
54
+ const { serializedTransaction } = await craftTransaction(
55
+ { address: transactionIntent.sender },
56
+ {
57
+ recipient: transactionIntent.recipient,
58
+ amount: new BigNumber(transactionIntent.amount.toString()),
59
+ },
60
+ );
61
+
62
+ const value = await estimateFees(serializedTransaction);
63
+
64
+ return { value };
65
+ }
@@ -0,0 +1,36 @@
1
+ import { Account, BroadcastArg } from "@ledgerhq/types-live";
2
+ import { broadcast } from "./broadcast";
3
+ jest.mock("@ledgerhq/coin-framework/operation");
4
+ jest.mock("../common-logic");
5
+ import { patchOperationWithHash } from "@ledgerhq/coin-framework/operation";
6
+ import { broadcast as broadcastLogic } from "../common-logic";
7
+
8
+ describe("broadcast", () => {
9
+ let patchOperationSpy: jest.SpyInstance;
10
+ let broadcastSpy: jest.SpyInstance;
11
+ beforeEach(() => {
12
+ patchOperationSpy = jest.spyOn({ patchOperationWithHash }, "patchOperationWithHash");
13
+ broadcastSpy = jest.spyOn({ broadcastLogic }, "broadcastLogic");
14
+ broadcastSpy.mockResolvedValue("hash");
15
+ });
16
+
17
+ it("should broadcast", () => {
18
+ broadcast({
19
+ signedOperation: {
20
+ signature: undefined,
21
+ operation: undefined,
22
+ },
23
+ } as unknown as BroadcastArg<Account>);
24
+ expect(broadcastLogic).toHaveBeenCalledTimes(1);
25
+ });
26
+
27
+ it("should patch operation with hash", () => {
28
+ broadcast({
29
+ signedOperation: {
30
+ signature: undefined,
31
+ operation: undefined,
32
+ },
33
+ } as unknown as BroadcastArg<Account>);
34
+ expect(patchOperationSpy).toHaveBeenCalledWith(undefined, "hash");
35
+ });
36
+ });
@@ -0,0 +1,11 @@
1
+ import { AccountBridge } from "@ledgerhq/types-live";
2
+ import { patchOperationWithHash } from "@ledgerhq/coin-framework/operation";
3
+ import { broadcast as broadcastLogic } from "../common-logic";
4
+ import { Transaction } from "../types";
5
+
6
+ export const broadcast: AccountBridge<Transaction>["broadcast"] = async ({
7
+ signedOperation: { signature, operation },
8
+ }) => {
9
+ const hash = await broadcastLogic(signature);
10
+ return patchOperationWithHash(operation, hash);
11
+ };
@@ -0,0 +1,12 @@
1
+ import { Account, AccountLike } from "@ledgerhq/types-live";
2
+ import { createTransaction } from "./createTransaction";
3
+
4
+ describe("createTransaction", () => {
5
+ it("should create a 0 amount transaction", () => {
6
+ expect(createTransaction({} as AccountLike<Account>).amount.toNumber()).toEqual(0);
7
+ });
8
+
9
+ it("should create a transaction with boilerplate family", () => {
10
+ expect(createTransaction({} as AccountLike<Account>).family).toEqual("boilerplate");
11
+ });
12
+ });
@@ -0,0 +1,14 @@
1
+ import BigNumber from "bignumber.js";
2
+ import { Transaction } from "../types";
3
+ import { AccountBridge } from "@ledgerhq/types-live";
4
+
5
+ // We create an empty transaction that will be filled later
6
+ export const createTransaction: AccountBridge<Transaction>["createTransaction"] = () => ({
7
+ family: "canton",
8
+ amount: new BigNumber(0),
9
+ recipient: "",
10
+ fee: null,
11
+ memo: undefined,
12
+ networkInfo: null,
13
+ feeCustomUnit: null,
14
+ });
@@ -0,0 +1,22 @@
1
+ import getDeviceTransactionConfig from "./deviceTransactionConfig";
2
+ import BigNumber from "bignumber.js";
3
+
4
+ describe("getDeviceTransactionConfig", () => {
5
+ it("should return amount field when it's more than 0", () => {
6
+ expect(
7
+ getDeviceTransactionConfig({
8
+ transaction: {},
9
+ status: { amount: new BigNumber(1), estimatedFees: new BigNumber(0) },
10
+ } as any)[0],
11
+ ).toEqual({ type: "amount", label: "Amount" });
12
+ });
13
+
14
+ it("should return fee field when it's more than 0", () => {
15
+ expect(
16
+ getDeviceTransactionConfig({
17
+ transaction: {},
18
+ status: { amount: new BigNumber(0), estimatedFees: new BigNumber(1) },
19
+ } as any)[0],
20
+ ).toEqual({ type: "fees", label: "Fees" });
21
+ });
22
+ });
@@ -0,0 +1,34 @@
1
+ import type { AccountLike, Account } from "@ledgerhq/types-live";
2
+ import type { Transaction, TransactionStatus } from "../types";
3
+ import type { CommonDeviceTransactionField } from "@ledgerhq/coin-framework/transaction/common";
4
+
5
+ // This method adds additional fields that need to be reviewed when signing a transaction on the device.
6
+ function getDeviceTransactionConfig({
7
+ transaction: {},
8
+ status: { amount, estimatedFees },
9
+ }: {
10
+ account: AccountLike;
11
+ parentAccount: Account | null | undefined;
12
+ transaction: Transaction;
13
+ status: TransactionStatus;
14
+ }): Array<CommonDeviceTransactionField> {
15
+ const fields: Array<CommonDeviceTransactionField> = [];
16
+
17
+ if (!amount.isZero()) {
18
+ fields.push({
19
+ type: "amount",
20
+ label: "Amount",
21
+ });
22
+ }
23
+
24
+ if (!estimatedFees.isZero()) {
25
+ fields.push({
26
+ type: "fees",
27
+ label: "Fees",
28
+ });
29
+ }
30
+
31
+ return fields;
32
+ }
33
+
34
+ export default getDeviceTransactionConfig;
@@ -0,0 +1,25 @@
1
+ import BigNumber from "bignumber.js";
2
+ import { AccountBridge } from "@ledgerhq/types-live";
3
+ import { getMainAccount } from "@ledgerhq/coin-framework/account/index";
4
+ import { getAbandonSeedAddress } from "@ledgerhq/cryptoassets/abandonseed";
5
+ import { getTransactionStatus } from "./getTransactionStatus";
6
+ import { prepareTransaction } from "./prepareTransaction";
7
+ import { createTransaction } from "./createTransaction";
8
+ import { Transaction } from "../types";
9
+
10
+ export const estimateMaxSpendable: AccountBridge<Transaction>["estimateMaxSpendable"] = async ({
11
+ account,
12
+ parentAccount,
13
+ transaction,
14
+ }) => {
15
+ const mainAccount = getMainAccount(account, parentAccount);
16
+ const newTransaction = await prepareTransaction(mainAccount, {
17
+ ...createTransaction(account),
18
+ ...transaction,
19
+ // fee estimation might require a recipient to work, in that case, we use a dummy one
20
+ recipient: transaction?.recipient || getAbandonSeedAddress("boilerplate"),
21
+ amount: new BigNumber(0),
22
+ });
23
+ const status = await getTransactionStatus(mainAccount, newTransaction);
24
+ return BigNumber.max(0, account.spendableBalance.minus(status.estimatedFees));
25
+ };