@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,36 @@
1
+ import BigNumber from "bignumber.js";
2
+ import { BoilerplateNativeTransaction } from "../../types";
3
+
4
+ const encodeNativeTx = (nativeTx: BoilerplateNativeTransaction) => JSON.stringify(nativeTx);
5
+
6
+ export async function craftTransaction(
7
+ account: {
8
+ address: string;
9
+ nextSequenceNumber?: number;
10
+ publicKey?: string;
11
+ },
12
+ transaction: {
13
+ recipient?: string;
14
+ amount: BigNumber;
15
+ fee?: BigNumber;
16
+ },
17
+ ): Promise<{
18
+ nativeTransaction: BoilerplateNativeTransaction;
19
+ serializedTransaction: string;
20
+ }> {
21
+ const nativeTransaction: BoilerplateNativeTransaction = {
22
+ TransactionType: "Payment",
23
+ Account: account.address,
24
+ Amount: transaction.amount.toString(),
25
+ Destination: transaction.recipient || "",
26
+ Fee: transaction.fee?.toString() || "0",
27
+ Sequence: account.nextSequenceNumber || 0,
28
+ };
29
+
30
+ const serializedTransaction = encodeNativeTx(nativeTransaction);
31
+
32
+ return {
33
+ nativeTransaction,
34
+ serializedTransaction,
35
+ };
36
+ }
@@ -0,0 +1,16 @@
1
+ import { simulate } from "../../network/node";
2
+ import { SimulationError } from "../../types/errors";
3
+
4
+ export async function estimateFees(serializedTransaction: string): Promise<bigint> {
5
+ try {
6
+ // We call the node to do a dry run and estimate fees
7
+ return BigInt(await simulate(serializedTransaction));
8
+ } catch (e) {
9
+ // default value is required in case of simulation error, else user will encounter an error in the flow
10
+ if (e instanceof SimulationError) {
11
+ return BigInt(1000);
12
+ } else {
13
+ throw new Error("Unexpected error while estimating fees.");
14
+ }
15
+ }
16
+ }
@@ -0,0 +1,18 @@
1
+ import BigNumber from "bignumber.js";
2
+
3
+ export const UINT32_MAX = new BigNumber(2).pow(32).minus(1);
4
+
5
+ export const validateTag = (tag: BigNumber) => {
6
+ return (
7
+ !tag.isNaN() && tag.isFinite() && tag.isInteger() && tag.isPositive() && tag.lte(UINT32_MAX)
8
+ );
9
+ };
10
+
11
+ export function isRecipientValid(recipient: string): boolean {
12
+ return recipient.length > 0;
13
+ }
14
+
15
+ export const encode = (transaction: string, signature: string, publicKey?: string) => {
16
+ // sample encoding
17
+ return `${transaction}${publicKey}${signature}encodedTx`;
18
+ };
package/src/config.ts ADDED
@@ -0,0 +1,12 @@
1
+ import buildCoinConfig, { type CurrencyConfig } from "@ledgerhq/coin-framework/config";
2
+
3
+ export type CantonConfig = {
4
+ nodeUrl: string;
5
+ minReserve: number;
6
+ };
7
+
8
+ export type CantonCoinConfig = CurrencyConfig & CantonConfig;
9
+
10
+ const coinConfig = buildCoinConfig<CantonCoinConfig>();
11
+
12
+ export default coinConfig;
package/src/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ export * from "./types";
2
+
3
+ export { createBridges } from "./bridge/index";
4
+ export type { CantonCoinConfig } from "./config";
@@ -0,0 +1,17 @@
1
+ import { AccountTxResponse } from "./types";
2
+ import network from "@ledgerhq/live-network/network";
3
+ import { getEnv } from "@ledgerhq/live-env";
4
+
5
+ export const getTransactions = async (
6
+ address: string,
7
+ params: { from: number; size?: number },
8
+ ): Promise<AccountTxResponse["transactions"]> => {
9
+ const { data } = await network<AccountTxResponse>({
10
+ // NOTE: add INDEXER_BOILERPLATE to libs/env/src/env.ts
11
+ // @ts-expect-error: add INDEXER_BOILERPLATE to libs/env/src/env.ts
12
+ url: `${getEnv("INDEXER_BOILERPLATE")}/account/${address}/transactions`,
13
+ method: "GET",
14
+ });
15
+
16
+ return data.transactions;
17
+ };
@@ -0,0 +1,25 @@
1
+ /*
2
+
3
+ In a real use case you should use live-network library like this :
4
+
5
+ import network from "@ledgerhq/live-network/network";
6
+
7
+
8
+ instead of this mocked method
9
+
10
+ */
11
+
12
+ export const network = (params: { url: string; method: "GET" | "POST" }) => {
13
+ switch (true) {
14
+ case params.url.includes("simulate"):
15
+ break;
16
+ case params.url.includes("submit"):
17
+ break;
18
+ case params.url.includes("account_info"):
19
+ break;
20
+ case params.url.includes("transactions"):
21
+ break;
22
+ default:
23
+ throw new Error("Mock network 404");
24
+ }
25
+ };
@@ -0,0 +1,94 @@
1
+ import { SimulationError } from "../types/errors";
2
+ import network from "@ledgerhq/live-network/network";
3
+ import { getEnv } from "@ledgerhq/live-env";
4
+ import coinConfig from "../config";
5
+ import { AccountInfoResponse, SubmitReponse } from "./types";
6
+
7
+ const getNodeUrl = () => coinConfig.getCoinConfig().nodeUrl;
8
+
9
+ // NOTE: add NODE_BOILERPLATE to libs/env/src/env.ts
10
+
11
+ // txPayload needs to be unsigned
12
+ export const simulate = async (serializedTx: string): Promise<number> => {
13
+ // @ts-expect-error: add NODE_BOILERPLATE to libs/env/src/env.ts
14
+ const url = `${getEnv("NODE_BOILERPLATE")}/simulate`;
15
+ const { data } = await network({
16
+ url,
17
+ method: "POST",
18
+ data: {
19
+ txPayload: serializedTx,
20
+ },
21
+ });
22
+ if (data.error) {
23
+ throw new SimulationError();
24
+ }
25
+ return data.fees;
26
+ };
27
+
28
+ // can be called nonce or sequence
29
+ export const getNextSequence = async (address: string): Promise<number> => {
30
+ // @ts-expect-error: add NODE_BOILERPLATE to libs/env/src/env.ts
31
+ const url = `${getEnv("NODE_BOILERPLATE")}/${address}/sequence`;
32
+ try {
33
+ const { data } = await network({
34
+ url,
35
+ method: "GET",
36
+ });
37
+ return data.sequence;
38
+ } catch (e) {
39
+ return 0;
40
+ }
41
+ };
42
+
43
+ export const getBlockHeight = async (): Promise<number> => {
44
+ // @ts-expect-error: add NODE_BOILERPLATE to libs/env/src/env.ts
45
+ const url = `${getEnv("NODE_BOILERPLATE")}/blockheight`;
46
+ const { data } = await network({
47
+ url,
48
+ method: "GET",
49
+ });
50
+ return data.blockHeight;
51
+ };
52
+
53
+ export const getLastBlock = async (): Promise<{
54
+ blockHeight: number;
55
+ blockHash: string;
56
+ timestamp: number;
57
+ }> => {
58
+ // @ts-expect-error: add NODE_BOILERPLATE to libs/env/src/env.ts
59
+ const url = `${getEnv("NODE_BOILERPLATE")}/block/current`;
60
+ const { data } = await network({
61
+ url,
62
+ method: "GET",
63
+ });
64
+ return data;
65
+ };
66
+
67
+ export const submit = async (signedTx: string): Promise<SubmitReponse> => {
68
+ // @ts-expect-error: add NODE_BOILERPLATE to libs/env/src/env.ts
69
+ const url = `${getEnv("NODE_BOILERPLATE")}/submit`;
70
+ const { data } = await network<SubmitReponse>({
71
+ url,
72
+ method: "GET",
73
+ });
74
+ return data;
75
+ };
76
+
77
+ export const getAccountInfo = async (address: string): Promise<AccountInfoResponse> => {
78
+ const {
79
+ data: { result },
80
+ } = await network<{ result: AccountInfoResponse }>({
81
+ method: "POST",
82
+ url: getNodeUrl(),
83
+ data: {
84
+ method: "account_info",
85
+ params: [
86
+ {
87
+ account: address,
88
+ },
89
+ ],
90
+ },
91
+ });
92
+
93
+ return result;
94
+ };
@@ -0,0 +1,51 @@
1
+ export type BoilerplateOperation = {
2
+ meta: {
3
+ delivered_amount: string;
4
+ };
5
+ tx: {
6
+ Account: string;
7
+ Amount: string;
8
+ Destination: string;
9
+ Fee: string;
10
+ Memo: string;
11
+ Sequence: number;
12
+ SigningPubKey: string;
13
+ TransactionType: string;
14
+ TxnSignature: string;
15
+ date: number;
16
+ hash: string;
17
+ inLedger: number;
18
+ };
19
+ validated: boolean;
20
+ };
21
+
22
+ export type ResponseStatus =
23
+ | { status: string; error?: never }
24
+ | {
25
+ status?: never;
26
+ error: string;
27
+ };
28
+ export function isResponseStatus(obj: object): obj is ResponseStatus {
29
+ return "status" in obj || "error" in obj;
30
+ }
31
+
32
+ export type NewAccount = "NewAccount";
33
+ export type AccountInfoResponse = {
34
+ account_data: {
35
+ Account: string;
36
+ Balance: string;
37
+ };
38
+ ledger_hash: string;
39
+ ledger_index: number;
40
+ validated: boolean;
41
+ } & ResponseStatus;
42
+
43
+ export type SubmitReponse = {
44
+ accepted: boolean;
45
+ tx_hash: string;
46
+ };
47
+
48
+ export type AccountTxResponse = {
49
+ account: string;
50
+ transactions: BoilerplateOperation[];
51
+ } & ResponseStatus;
@@ -0,0 +1,20 @@
1
+ import { GetAddressOptions } from "@ledgerhq/coin-framework/derivation";
2
+ import { GetAddressFn } from "@ledgerhq/coin-framework/bridge/getAddressWrapper";
3
+ import { SignerContext } from "@ledgerhq/coin-framework/signer";
4
+ import { BoilerplateAddress, BoilerplateSigner } from "../types";
5
+
6
+ const getAddress = (signerContext: SignerContext<BoilerplateSigner>): GetAddressFn => {
7
+ return async (deviceId: string, { path, verify }: GetAddressOptions) => {
8
+ const { address, publicKey } = (await signerContext(deviceId, signer =>
9
+ signer.getAddress(path),
10
+ )) as BoilerplateAddress;
11
+
12
+ return {
13
+ path,
14
+ address,
15
+ publicKey,
16
+ };
17
+ };
18
+ };
19
+
20
+ export default getAddress;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * This directory is the home for all types and logic based on Ledgers signer.
3
+ */
4
+
5
+ import getAddress from "./getAddress";
6
+
7
+ export default getAddress;
@@ -0,0 +1,48 @@
1
+ import type { DeviceAction } from "@ledgerhq/coin-framework/bot/types";
2
+ import type { Transaction } from "../types";
3
+ import {
4
+ deviceActionFlow,
5
+ formatDeviceAmount,
6
+ SpeculosButton,
7
+ } from "@ledgerhq/coin-framework/bot/specs";
8
+
9
+ export const acceptTransaction: DeviceAction<Transaction, any> = deviceActionFlow({
10
+ steps: [
11
+ {
12
+ title: "Transaction Type",
13
+ button: SpeculosButton.RIGHT,
14
+ expectedValue: () => "Payment",
15
+ },
16
+ {
17
+ title: "Amount",
18
+ button: SpeculosButton.RIGHT,
19
+ expectedValue: ({ account, status }) => formatDeviceAmount(account.currency, status.amount),
20
+ },
21
+ {
22
+ title: "Fee",
23
+ button: SpeculosButton.RIGHT,
24
+ expectedValue: ({ account, status }) =>
25
+ formatDeviceAmount(account.currency, status.estimatedFees),
26
+ },
27
+ {
28
+ title: "Destination",
29
+ button: SpeculosButton.RIGHT,
30
+ trimValue: true,
31
+ expectedValue: ({ transaction }) => transaction.recipient,
32
+ },
33
+ {
34
+ title: "Account",
35
+ button: SpeculosButton.RIGHT,
36
+ trimValue: true,
37
+ expectedValue: ({ account }) => account.freshAddress,
38
+ },
39
+ {
40
+ title: "Accept",
41
+ button: SpeculosButton.BOTH,
42
+ },
43
+ {
44
+ title: "Sign transaction",
45
+ button: SpeculosButton.BOTH,
46
+ },
47
+ ],
48
+ });
@@ -0,0 +1,76 @@
1
+ /*
2
+
3
+ import invariant from "invariant";
4
+ import expect from "expect";
5
+ import { DeviceModelId } from "@ledgerhq/devices";
6
+ import type { AppSpec } from "@ledgerhq/coin-framework/bot/types";
7
+ import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets/currencies";
8
+ import { parseCurrencyUnit } from "@ledgerhq/coin-framework/currencies/index";
9
+ import { botTest, genericTestDestination, pickSiblings } from "@ledgerhq/coin-framework/bot/specs";
10
+ import { acceptTransaction } from "./bot-deviceActions";
11
+ import type { Transaction } from "../types";
12
+
13
+ const currency = getCryptoCurrencyById("boilerplate");
14
+ const minAmountCutoff = parseCurrencyUnit(currency.units[0], "0.1");
15
+ const reserve = parseCurrencyUnit(currency.units[0], "20");
16
+
17
+ const boilerplateSpec: AppSpec<Transaction> = {
18
+ name: "BOILERPLATE",
19
+ currency,
20
+ appQuery: {
21
+ model: DeviceModelId.nanoS,
22
+ appName: "BOILERPLATE_APP_NAME",
23
+ },
24
+ genericDeviceAction: acceptTransaction,
25
+ minViableAmount: minAmountCutoff,
26
+ mutations: [
27
+ {
28
+ name: "move ~50%",
29
+ maxRun: 2,
30
+ testDestination: genericTestDestination,
31
+ transaction: ({ account, siblings, bridge, maxSpendable }) => {
32
+ invariant(maxSpendable.gt(minAmountCutoff), "balance is too low");
33
+ const transaction = bridge.createTransaction(account);
34
+ const sibling = pickSiblings(siblings, 3);
35
+ const recipient = sibling.freshAddress;
36
+ let amount = maxSpendable.div(1.9 + 0.2 * Math.random()).integerValue();
37
+
38
+ if (!sibling.used && amount.lt(reserve)) {
39
+ invariant(
40
+ maxSpendable.gt(reserve.plus(minAmountCutoff)),
41
+ "not enough funds to send to new account",
42
+ );
43
+ amount = reserve;
44
+ }
45
+
46
+ return {
47
+ transaction,
48
+ updates: [
49
+ {
50
+ amount,
51
+ },
52
+ {
53
+ recipient,
54
+ },
55
+ Math.random() > 0.5
56
+ ? {
57
+ tag: 123,
58
+ }
59
+ : null,
60
+ ],
61
+ };
62
+ },
63
+ test: ({ account, accountBeforeTransaction, operation }) => {
64
+ botTest("account balance moved with operation.value", () =>
65
+ expect(account.balance.toString()).toBe(
66
+ accountBeforeTransaction.balance.minus(operation.value).toString(),
67
+ ),
68
+ );
69
+ },
70
+ },
71
+ ],
72
+ };
73
+ export default {
74
+ boilerplateSpec,
75
+ };
76
+ */
@@ -0,0 +1,147 @@
1
+ import BigNumber from "bignumber.js";
2
+ import { DatasetTest } from "@ledgerhq/types-live";
3
+ import { InvalidAddressBecauseDestinationIsAlsoSource } from "@ledgerhq/errors";
4
+ import { fromTransactionRaw } from "../bridge/transaction";
5
+ import { Transaction } from "../types";
6
+
7
+ export const newAddress1 = "rZvBc5e2YR1A9otS3r9DyGh3NDP8XLLp4";
8
+
9
+ export const dataset: DatasetTest<Transaction> = {
10
+ implementations: ["mock", "ripplejs"],
11
+ currencies: {
12
+ ripple: {
13
+ scanAccounts: [
14
+ {
15
+ name: "ripple seed 1",
16
+ unstableAccounts: true,
17
+ // our account is getting spammed...
18
+ apdus: `
19
+ => e00200400d038000002c8000009080000000
20
+ <= 2103c73f64083463fa923e1530af6f558204853873c6a45cbfb1f2f1e2ac2a5d989c2272734a4675764165634c333153513750594864504b6b3335625a456f78446d5231789000
21
+ => e002004015058000002c80000090800000000000000000000000
22
+ <= 2103d1adcff3e0cf1232b1416a75cd6f23b49dd6a25c69bc291a1f6783ec6825ec062272616765584842365134566276765764547a4b414e776a65435434485846434b58379000
23
+ => e002004015058000002c80000090800000010000000000000000
24
+ <= 21036da109ee84825eab0f55fb57bcf9ef0b05621e71fb0400266fb42d6f68f9487c2272425065393169766d67384347573450414e6f657555555173756d337470786a55469000
25
+ => e002004015058000002c80000090800000020000000000000000
26
+ <= 2102df9a55b79fb3668dac70fee7372806195841cd713ab8da9fba82240f9db8a23921725a76426335653259523141396f745333723944794768334e445038584c4c70349000
27
+ `,
28
+ },
29
+ ],
30
+ accounts: [
31
+ {
32
+ transactions: [
33
+ // FIXME
34
+
35
+ /*
36
+ {
37
+ name: "not enough spendable balance with base reserve",
38
+ transaction: fromTransactionRaw({
39
+ family: "xrp",
40
+ recipient: "rB6pwovsyrFWhPYUsjj9V3CHck985QjiXi",
41
+ amount: "15000000",
42
+ tag: null,
43
+ fee: "1",
44
+ feeCustomUnit: null,
45
+ networkInfo: null,
46
+ }),
47
+ expectedStatus: {
48
+ amount: BigNumber("15000000"),
49
+ estimatedFees: BigNumber("1"),
50
+ errors: {
51
+ amount: new NotEnoughSpendableBalance(null, {
52
+ minimumAmount: formatCurrencyUnit(
53
+ rippleUnit,
54
+ BigNumber("20"),
55
+ {
56
+ disableRounding: true,
57
+ useGrouping: false,
58
+ showCode: true,
59
+ }
60
+ ),
61
+ }),
62
+ },
63
+ warnings: {},
64
+ totalSpent: BigNumber("15000001"),
65
+ },
66
+ },
67
+ */
68
+ // FIXME
69
+
70
+ /*
71
+ {
72
+ name: "operation amount to low to create the recipient account",
73
+ transaction: fromTransactionRaw({
74
+ family: "xrp",
75
+ recipient: newAddress1,
76
+ amount: "10000000",
77
+ tag: null,
78
+ fee: "1",
79
+ feeCustomUnit: null,
80
+ networkInfo: null
81
+ }),
82
+ expectedStatus: {
83
+ amount: BigNumber("10000000"),
84
+ estimatedFees: BigNumber("1"),
85
+ errors: {
86
+ amount: new NotEnoughBalanceBecauseDestinationNotCreated()
87
+ },
88
+ warnings: {},
89
+ totalSpent: BigNumber("10000001")
90
+ }
91
+ },
92
+ */
93
+ {
94
+ name: "recipient and sender must not be the same",
95
+ transaction: fromTransactionRaw({
96
+ family: "canton",
97
+ recipient: "rageXHB6Q4VbvvWdTzKANwjeCT4HXFCKX7",
98
+ amount: "10000000",
99
+ fee: "1",
100
+ }),
101
+ expectedStatus: {
102
+ amount: new BigNumber("10000000"),
103
+ estimatedFees: new BigNumber("1"),
104
+ errors: {
105
+ recipient: new InvalidAddressBecauseDestinationIsAlsoSource(),
106
+ },
107
+ warnings: {},
108
+ totalSpent: new BigNumber("10000001"),
109
+ },
110
+ },
111
+ {
112
+ name: "Operation with tag succeed",
113
+ transaction: fromTransactionRaw({
114
+ family: "canton",
115
+ recipient: "rB6pwovsyrFWhPYUsjj9V3CHck985QjiXi",
116
+ amount: "10000000",
117
+ fee: "1",
118
+ }),
119
+ expectedStatus: {
120
+ amount: new BigNumber("10000000"),
121
+ estimatedFees: new BigNumber("1"),
122
+ errors: {},
123
+ warnings: {},
124
+ totalSpent: new BigNumber("10000001"),
125
+ },
126
+ },
127
+ ],
128
+ raw: {
129
+ id: "ripplejs:2:ripple:rageXHB6Q4VbvvWdTzKANwjeCT4HXFCKX7:",
130
+ seedIdentifier: "rageXHB6Q4VbvvWdTzKANwjeCT4HXFCKX7",
131
+ name: "XRP 1",
132
+ derivationMode: "",
133
+ index: 0,
134
+ freshAddress: "rageXHB6Q4VbvvWdTzKANwjeCT4HXFCKX7",
135
+ freshAddressPath: "44'/144'/0'/0/0",
136
+ blockHeight: 0,
137
+ operations: [],
138
+ pendingOperations: [],
139
+ currencyId: "ripple",
140
+ lastSyncDate: "",
141
+ balance: "21000310",
142
+ },
143
+ },
144
+ ],
145
+ },
146
+ },
147
+ };
@@ -0,0 +1,44 @@
1
+ import invariant from "invariant";
2
+ import type { AccountLike } from "@ledgerhq/types-live";
3
+ import type { Transaction } from "../types";
4
+ import BigNumber from "bignumber.js";
5
+
6
+ const options = [
7
+ {
8
+ name: "fee",
9
+ type: String,
10
+ desc: "how much fee",
11
+ },
12
+ {
13
+ name: "tag",
14
+ type: Number,
15
+ desc: "ripple tag",
16
+ },
17
+ ];
18
+
19
+ function inferTransactions(
20
+ transactions: Array<{
21
+ account: AccountLike;
22
+ transaction: Transaction;
23
+ }>,
24
+ opts: { tag?: number | null | undefined; fee?: string },
25
+ {
26
+ inferAmount,
27
+ }: { inferAmount: (account: AccountLike, fee?: string) => BigNumber | null | undefined },
28
+ ): Transaction[] {
29
+ return transactions.flatMap(({ transaction, account }) => {
30
+ invariant(transaction.family === "canton", "Canton family");
31
+ return {
32
+ ...transaction,
33
+ fee: inferAmount(account, opts.fee || "0.001brp"),
34
+ tag: opts.tag,
35
+ };
36
+ });
37
+ }
38
+
39
+ export default function makeCliTools() {
40
+ return {
41
+ options,
42
+ inferTransactions,
43
+ };
44
+ }
@@ -0,0 +1,6 @@
1
+ import makeCliTools from "./cli";
2
+
3
+ export * from "./bridgeDatasetTest";
4
+ export { makeCliTools };
5
+ export * from "./bot-deviceActions";
6
+ // export * from "./bot-specs";
@@ -0,0 +1,33 @@
1
+ import type { BigNumber } from "bignumber.js";
2
+ import type { Unit } from "@ledgerhq/types-cryptoassets";
3
+ import type {
4
+ TransactionCommon,
5
+ TransactionCommonRaw,
6
+ TransactionStatusCommon,
7
+ TransactionStatusCommonRaw,
8
+ } from "@ledgerhq/types-live";
9
+
10
+ export type NetworkInfo = {
11
+ family: "canton";
12
+ serverFee: BigNumber;
13
+ baseReserve: BigNumber;
14
+ };
15
+
16
+ export type NetworkInfoRaw = {
17
+ family: "canton";
18
+ serverFee: string;
19
+ baseReserve: string;
20
+ };
21
+
22
+ export type Transaction = TransactionCommon & {
23
+ family: "canton";
24
+ fee: BigNumber | null | undefined;
25
+ };
26
+
27
+ export type TransactionRaw = TransactionCommonRaw & {
28
+ family: "canton";
29
+ fee: string | null | undefined;
30
+ };
31
+
32
+ export type TransactionStatus = TransactionStatusCommon;
33
+ export type TransactionStatusRaw = TransactionStatusCommonRaw;
@@ -0,0 +1,3 @@
1
+ import { createCustomErrorClass } from "@ledgerhq/errors";
2
+
3
+ export const SimulationError = createCustomErrorClass("SimulationError");