@ledgerhq/coin-cardano 0.1.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (377) hide show
  1. package/.eslintrc.js +20 -0
  2. package/.turbo/turbo-build.log +4 -0
  3. package/.unimportedrc.json +35 -0
  4. package/CHANGELOG.md +19 -0
  5. package/LICENSE.txt +21 -0
  6. package/jest.config.js +8 -0
  7. package/lib/account.d.ts +7 -0
  8. package/lib/account.d.ts.map +1 -0
  9. package/lib/account.js +41 -0
  10. package/lib/account.js.map +1 -0
  11. package/lib/address.unit.test.d.ts +2 -0
  12. package/lib/address.unit.test.d.ts.map +1 -0
  13. package/lib/address.unit.test.js +21 -0
  14. package/lib/address.unit.test.js.map +1 -0
  15. package/lib/api/api-types.d.ts +106 -0
  16. package/lib/api/api-types.d.ts.map +1 -0
  17. package/lib/api/api-types.js +9 -0
  18. package/lib/api/api-types.js.map +1 -0
  19. package/lib/api/getDelegationInfo.d.ts +4 -0
  20. package/lib/api/getDelegationInfo.d.ts.map +1 -0
  21. package/lib/api/getDelegationInfo.js +48 -0
  22. package/lib/api/getDelegationInfo.js.map +1 -0
  23. package/lib/api/getNetworkInfo.d.ts +5 -0
  24. package/lib/api/getNetworkInfo.d.ts.map +1 -0
  25. package/lib/api/getNetworkInfo.js +46 -0
  26. package/lib/api/getNetworkInfo.js.map +1 -0
  27. package/lib/api/getPools.d.ts +5 -0
  28. package/lib/api/getPools.d.ts.map +1 -0
  29. package/lib/api/getPools.js +45 -0
  30. package/lib/api/getPools.js.map +1 -0
  31. package/lib/api/getTransactions.d.ts +10 -0
  32. package/lib/api/getTransactions.d.ts.map +1 -0
  33. package/lib/api/getTransactions.js +139 -0
  34. package/lib/api/getTransactions.js.map +1 -0
  35. package/lib/api/submitTransaction.d.ts +7 -0
  36. package/lib/api/submitTransaction.d.ts.map +1 -0
  37. package/lib/api/submitTransaction.js +34 -0
  38. package/lib/api/submitTransaction.js.map +1 -0
  39. package/lib/bridge/index.d.ts +11 -0
  40. package/lib/bridge/index.d.ts.map +1 -0
  41. package/lib/bridge/index.js +70 -0
  42. package/lib/bridge/index.js.map +1 -0
  43. package/lib/bridge.integration.test.d.ts +4 -0
  44. package/lib/bridge.integration.test.d.ts.map +1 -0
  45. package/lib/bridge.integration.test.js +113 -0
  46. package/lib/bridge.integration.test.js.map +1 -0
  47. package/lib/broadcast.d.ts +8 -0
  48. package/lib/broadcast.d.ts.map +1 -0
  49. package/lib/broadcast.js +28 -0
  50. package/lib/broadcast.js.map +1 -0
  51. package/lib/buildOptimisticOperation.d.ts +4 -0
  52. package/lib/buildOptimisticOperation.d.ts.map +1 -0
  53. package/lib/buildOptimisticOperation.js +125 -0
  54. package/lib/buildOptimisticOperation.js.map +1 -0
  55. package/lib/buildSubAccounts.d.ts +26 -0
  56. package/lib/buildSubAccounts.d.ts.map +1 -0
  57. package/lib/buildSubAccounts.js +124 -0
  58. package/lib/buildSubAccounts.js.map +1 -0
  59. package/lib/buildTransaction.d.ts +11 -0
  60. package/lib/buildTransaction.d.ts.map +1 -0
  61. package/lib/buildTransaction.js +342 -0
  62. package/lib/buildTransaction.js.map +1 -0
  63. package/lib/cli-transaction.d.ts +18 -0
  64. package/lib/cli-transaction.d.ts.map +1 -0
  65. package/lib/cli-transaction.js +66 -0
  66. package/lib/cli-transaction.js.map +1 -0
  67. package/lib/constants.d.ts +8 -0
  68. package/lib/constants.d.ts.map +1 -0
  69. package/lib/constants.js +12 -0
  70. package/lib/constants.js.map +1 -0
  71. package/lib/createTransaction.d.ts +9 -0
  72. package/lib/createTransaction.d.ts.map +1 -0
  73. package/lib/createTransaction.js +23 -0
  74. package/lib/createTransaction.js.map +1 -0
  75. package/lib/datasets/rawAccount.1.d.ts +3 -0
  76. package/lib/datasets/rawAccount.1.d.ts.map +1 -0
  77. package/lib/datasets/rawAccount.1.js +20 -0
  78. package/lib/datasets/rawAccount.1.js.map +1 -0
  79. package/lib/datasets/scanAccounts.d.ts +5 -0
  80. package/lib/datasets/scanAccounts.d.ts.map +1 -0
  81. package/lib/datasets/scanAccounts.js +27 -0
  82. package/lib/datasets/scanAccounts.js.map +1 -0
  83. package/lib/deviceTransactionConfig.d.ts +11 -0
  84. package/lib/deviceTransactionConfig.d.ts.map +1 -0
  85. package/lib/deviceTransactionConfig.js +106 -0
  86. package/lib/deviceTransactionConfig.js.map +1 -0
  87. package/lib/errors.d.ts +22 -0
  88. package/lib/errors.d.ts.map +1 -0
  89. package/lib/errors.js +18 -0
  90. package/lib/errors.js.map +1 -0
  91. package/lib/estimateMaxSpendable.d.ts +9 -0
  92. package/lib/estimateMaxSpendable.d.ts.map +1 -0
  93. package/lib/estimateMaxSpendable.js +53 -0
  94. package/lib/estimateMaxSpendable.js.map +1 -0
  95. package/lib/getTransactionStatus.d.ts +4 -0
  96. package/lib/getTransactionStatus.d.ts.map +1 -0
  97. package/lib/getTransactionStatus.js +214 -0
  98. package/lib/getTransactionStatus.js.map +1 -0
  99. package/lib/getTransactionStatus.unit.test.d.ts +2 -0
  100. package/lib/getTransactionStatus.unit.test.d.ts.map +1 -0
  101. package/lib/getTransactionStatus.unit.test.js +54 -0
  102. package/lib/getTransactionStatus.unit.test.js.map +1 -0
  103. package/lib/hw-getAddress.d.ts +6 -0
  104. package/lib/hw-getAddress.d.ts.map +1 -0
  105. package/lib/hw-getAddress.js +37 -0
  106. package/lib/hw-getAddress.js.map +1 -0
  107. package/lib/logic.d.ts +88 -0
  108. package/lib/logic.d.ts.map +1 -0
  109. package/lib/logic.js +264 -0
  110. package/lib/logic.js.map +1 -0
  111. package/lib/logic.unit.test.d.ts +2 -0
  112. package/lib/logic.unit.test.d.ts.map +1 -0
  113. package/lib/logic.unit.test.js +40 -0
  114. package/lib/logic.unit.test.js.map +1 -0
  115. package/lib/networks.d.ts +3 -0
  116. package/lib/networks.d.ts.map +1 -0
  117. package/lib/networks.js +36 -0
  118. package/lib/networks.js.map +1 -0
  119. package/lib/postSyncPatch.d.ts +6 -0
  120. package/lib/postSyncPatch.d.ts.map +1 -0
  121. package/lib/postSyncPatch.js +35 -0
  122. package/lib/postSyncPatch.js.map +1 -0
  123. package/lib/prepareTransaction.d.ts +10 -0
  124. package/lib/prepareTransaction.d.ts.map +1 -0
  125. package/lib/prepareTransaction.js +44 -0
  126. package/lib/prepareTransaction.js.map +1 -0
  127. package/lib/serialization.d.ts +7 -0
  128. package/lib/serialization.d.ts.map +1 -0
  129. package/lib/serialization.js +146 -0
  130. package/lib/serialization.js.map +1 -0
  131. package/lib/signOperation.d.ts +9 -0
  132. package/lib/signOperation.d.ts.map +1 -0
  133. package/lib/signOperation.js +71 -0
  134. package/lib/signOperation.js.map +1 -0
  135. package/lib/signer.d.ts +92 -0
  136. package/lib/signer.d.ts.map +1 -0
  137. package/lib/signer.js +3 -0
  138. package/lib/signer.js.map +1 -0
  139. package/lib/specs.d.ts +7 -0
  140. package/lib/specs.d.ts.map +1 -0
  141. package/lib/specs.js +218 -0
  142. package/lib/specs.js.map +1 -0
  143. package/lib/speculos-deviceActions.d.ts +4 -0
  144. package/lib/speculos-deviceActions.d.ts.map +1 -0
  145. package/lib/speculos-deviceActions.js +128 -0
  146. package/lib/speculos-deviceActions.js.map +1 -0
  147. package/lib/synchronisation.d.ts +6 -0
  148. package/lib/synchronisation.d.ts.map +1 -0
  149. package/lib/synchronisation.js +237 -0
  150. package/lib/synchronisation.js.map +1 -0
  151. package/lib/synchronisation.unit.test.d.ts +2 -0
  152. package/lib/synchronisation.unit.test.d.ts.map +1 -0
  153. package/lib/synchronisation.unit.test.js +129 -0
  154. package/lib/synchronisation.unit.test.js.map +1 -0
  155. package/lib/transaction.d.ts +15 -0
  156. package/lib/transaction.d.ts.map +1 -0
  157. package/lib/transaction.js +43 -0
  158. package/lib/transaction.js.map +1 -0
  159. package/lib/types.d.ts +188 -0
  160. package/lib/types.d.ts.map +1 -0
  161. package/lib/types.js +18 -0
  162. package/lib/types.js.map +1 -0
  163. package/lib/typhonSerializer.d.ts +17 -0
  164. package/lib/typhonSerializer.d.ts.map +1 -0
  165. package/lib/typhonSerializer.js +213 -0
  166. package/lib/typhonSerializer.js.map +1 -0
  167. package/lib/utils.d.ts +2 -0
  168. package/lib/utils.d.ts.map +1 -0
  169. package/lib/utils.js +8 -0
  170. package/lib/utils.js.map +1 -0
  171. package/lib-es/account.d.ts +7 -0
  172. package/lib-es/account.d.ts.map +1 -0
  173. package/lib-es/account.js +34 -0
  174. package/lib-es/account.js.map +1 -0
  175. package/lib-es/address.unit.test.d.ts +2 -0
  176. package/lib-es/address.unit.test.d.ts.map +1 -0
  177. package/lib-es/address.unit.test.js +19 -0
  178. package/lib-es/address.unit.test.js.map +1 -0
  179. package/lib-es/api/api-types.d.ts +106 -0
  180. package/lib-es/api/api-types.d.ts.map +1 -0
  181. package/lib-es/api/api-types.js +6 -0
  182. package/lib-es/api/api-types.js.map +1 -0
  183. package/lib-es/api/getDelegationInfo.d.ts +4 -0
  184. package/lib-es/api/getDelegationInfo.d.ts.map +1 -0
  185. package/lib-es/api/getDelegationInfo.js +41 -0
  186. package/lib-es/api/getDelegationInfo.js.map +1 -0
  187. package/lib-es/api/getNetworkInfo.d.ts +5 -0
  188. package/lib-es/api/getNetworkInfo.d.ts.map +1 -0
  189. package/lib-es/api/getNetworkInfo.js +39 -0
  190. package/lib-es/api/getNetworkInfo.js.map +1 -0
  191. package/lib-es/api/getPools.d.ts +5 -0
  192. package/lib-es/api/getPools.d.ts.map +1 -0
  193. package/lib-es/api/getPools.js +37 -0
  194. package/lib-es/api/getPools.js.map +1 -0
  195. package/lib-es/api/getTransactions.d.ts +10 -0
  196. package/lib-es/api/getTransactions.d.ts.map +1 -0
  197. package/lib-es/api/getTransactions.js +132 -0
  198. package/lib-es/api/getTransactions.js.map +1 -0
  199. package/lib-es/api/submitTransaction.d.ts +7 -0
  200. package/lib-es/api/submitTransaction.d.ts.map +1 -0
  201. package/lib-es/api/submitTransaction.js +27 -0
  202. package/lib-es/api/submitTransaction.js.map +1 -0
  203. package/lib-es/bridge/index.d.ts +11 -0
  204. package/lib-es/bridge/index.d.ts.map +1 -0
  205. package/lib-es/bridge/index.js +61 -0
  206. package/lib-es/bridge/index.js.map +1 -0
  207. package/lib-es/bridge.integration.test.d.ts +4 -0
  208. package/lib-es/bridge.integration.test.d.ts.map +1 -0
  209. package/lib-es/bridge.integration.test.js +107 -0
  210. package/lib-es/bridge.integration.test.js.map +1 -0
  211. package/lib-es/broadcast.d.ts +8 -0
  212. package/lib-es/broadcast.d.ts.map +1 -0
  213. package/lib-es/broadcast.js +24 -0
  214. package/lib-es/broadcast.js.map +1 -0
  215. package/lib-es/buildOptimisticOperation.d.ts +4 -0
  216. package/lib-es/buildOptimisticOperation.d.ts.map +1 -0
  217. package/lib-es/buildOptimisticOperation.js +118 -0
  218. package/lib-es/buildOptimisticOperation.js.map +1 -0
  219. package/lib-es/buildSubAccounts.d.ts +26 -0
  220. package/lib-es/buildSubAccounts.d.ts.map +1 -0
  221. package/lib-es/buildSubAccounts.js +114 -0
  222. package/lib-es/buildSubAccounts.js.map +1 -0
  223. package/lib-es/buildTransaction.d.ts +11 -0
  224. package/lib-es/buildTransaction.d.ts.map +1 -0
  225. package/lib-es/buildTransaction.js +335 -0
  226. package/lib-es/buildTransaction.js.map +1 -0
  227. package/lib-es/cli-transaction.d.ts +18 -0
  228. package/lib-es/cli-transaction.d.ts.map +1 -0
  229. package/lib-es/cli-transaction.js +60 -0
  230. package/lib-es/cli-transaction.js.map +1 -0
  231. package/lib-es/constants.d.ts +8 -0
  232. package/lib-es/constants.d.ts.map +1 -0
  233. package/lib-es/constants.js +9 -0
  234. package/lib-es/constants.js.map +1 -0
  235. package/lib-es/createTransaction.d.ts +9 -0
  236. package/lib-es/createTransaction.d.ts.map +1 -0
  237. package/lib-es/createTransaction.js +16 -0
  238. package/lib-es/createTransaction.js.map +1 -0
  239. package/lib-es/datasets/rawAccount.1.d.ts +3 -0
  240. package/lib-es/datasets/rawAccount.1.d.ts.map +1 -0
  241. package/lib-es/datasets/rawAccount.1.js +17 -0
  242. package/lib-es/datasets/rawAccount.1.js.map +1 -0
  243. package/lib-es/datasets/scanAccounts.d.ts +5 -0
  244. package/lib-es/datasets/scanAccounts.d.ts.map +1 -0
  245. package/lib-es/datasets/scanAccounts.js +24 -0
  246. package/lib-es/datasets/scanAccounts.js.map +1 -0
  247. package/lib-es/deviceTransactionConfig.d.ts +11 -0
  248. package/lib-es/deviceTransactionConfig.d.ts.map +1 -0
  249. package/lib-es/deviceTransactionConfig.js +101 -0
  250. package/lib-es/deviceTransactionConfig.js.map +1 -0
  251. package/lib-es/errors.d.ts +22 -0
  252. package/lib-es/errors.d.ts.map +1 -0
  253. package/lib-es/errors.js +15 -0
  254. package/lib-es/errors.js.map +1 -0
  255. package/lib-es/estimateMaxSpendable.d.ts +9 -0
  256. package/lib-es/estimateMaxSpendable.d.ts.map +1 -0
  257. package/lib-es/estimateMaxSpendable.js +49 -0
  258. package/lib-es/estimateMaxSpendable.js.map +1 -0
  259. package/lib-es/getTransactionStatus.d.ts +4 -0
  260. package/lib-es/getTransactionStatus.d.ts.map +1 -0
  261. package/lib-es/getTransactionStatus.js +210 -0
  262. package/lib-es/getTransactionStatus.js.map +1 -0
  263. package/lib-es/getTransactionStatus.unit.test.d.ts +2 -0
  264. package/lib-es/getTransactionStatus.unit.test.d.ts.map +1 -0
  265. package/lib-es/getTransactionStatus.unit.test.js +49 -0
  266. package/lib-es/getTransactionStatus.unit.test.js.map +1 -0
  267. package/lib-es/hw-getAddress.d.ts +6 -0
  268. package/lib-es/hw-getAddress.d.ts.map +1 -0
  269. package/lib-es/hw-getAddress.js +35 -0
  270. package/lib-es/hw-getAddress.js.map +1 -0
  271. package/lib-es/logic.d.ts +88 -0
  272. package/lib-es/logic.d.ts.map +1 -0
  273. package/lib-es/logic.js +236 -0
  274. package/lib-es/logic.js.map +1 -0
  275. package/lib-es/logic.unit.test.d.ts +2 -0
  276. package/lib-es/logic.unit.test.d.ts.map +1 -0
  277. package/lib-es/logic.unit.test.js +35 -0
  278. package/lib-es/logic.unit.test.js.map +1 -0
  279. package/lib-es/networks.d.ts +3 -0
  280. package/lib-es/networks.d.ts.map +1 -0
  281. package/lib-es/networks.js +32 -0
  282. package/lib-es/networks.js.map +1 -0
  283. package/lib-es/postSyncPatch.d.ts +6 -0
  284. package/lib-es/postSyncPatch.d.ts.map +1 -0
  285. package/lib-es/postSyncPatch.js +31 -0
  286. package/lib-es/postSyncPatch.js.map +1 -0
  287. package/lib-es/prepareTransaction.d.ts +10 -0
  288. package/lib-es/prepareTransaction.d.ts.map +1 -0
  289. package/lib-es/prepareTransaction.js +40 -0
  290. package/lib-es/prepareTransaction.js.map +1 -0
  291. package/lib-es/serialization.d.ts +7 -0
  292. package/lib-es/serialization.d.ts.map +1 -0
  293. package/lib-es/serialization.js +139 -0
  294. package/lib-es/serialization.js.map +1 -0
  295. package/lib-es/signOperation.d.ts +9 -0
  296. package/lib-es/signOperation.d.ts.map +1 -0
  297. package/lib-es/signOperation.js +64 -0
  298. package/lib-es/signOperation.js.map +1 -0
  299. package/lib-es/signer.d.ts +92 -0
  300. package/lib-es/signer.d.ts.map +1 -0
  301. package/lib-es/signer.js +2 -0
  302. package/lib-es/signer.js.map +1 -0
  303. package/lib-es/specs.d.ts +7 -0
  304. package/lib-es/specs.d.ts.map +1 -0
  305. package/lib-es/specs.js +213 -0
  306. package/lib-es/specs.js.map +1 -0
  307. package/lib-es/speculos-deviceActions.d.ts +4 -0
  308. package/lib-es/speculos-deviceActions.d.ts.map +1 -0
  309. package/lib-es/speculos-deviceActions.js +125 -0
  310. package/lib-es/speculos-deviceActions.js.map +1 -0
  311. package/lib-es/synchronisation.d.ts +6 -0
  312. package/lib-es/synchronisation.d.ts.map +1 -0
  313. package/lib-es/synchronisation.js +230 -0
  314. package/lib-es/synchronisation.js.map +1 -0
  315. package/lib-es/synchronisation.unit.test.d.ts +2 -0
  316. package/lib-es/synchronisation.unit.test.d.ts.map +1 -0
  317. package/lib-es/synchronisation.unit.test.js +124 -0
  318. package/lib-es/synchronisation.unit.test.js.map +1 -0
  319. package/lib-es/transaction.d.ts +15 -0
  320. package/lib-es/transaction.d.ts.map +1 -0
  321. package/lib-es/transaction.js +37 -0
  322. package/lib-es/transaction.js.map +1 -0
  323. package/lib-es/types.d.ts +188 -0
  324. package/lib-es/types.d.ts.map +1 -0
  325. package/lib-es/types.js +15 -0
  326. package/lib-es/types.js.map +1 -0
  327. package/lib-es/typhonSerializer.d.ts +17 -0
  328. package/lib-es/typhonSerializer.d.ts.map +1 -0
  329. package/lib-es/typhonSerializer.js +207 -0
  330. package/lib-es/typhonSerializer.js.map +1 -0
  331. package/lib-es/utils.d.ts +2 -0
  332. package/lib-es/utils.d.ts.map +1 -0
  333. package/lib-es/utils.js +5 -0
  334. package/lib-es/utils.js.map +1 -0
  335. package/package.json +91 -0
  336. package/src/account.ts +39 -0
  337. package/src/address.unit.test.ts +32 -0
  338. package/src/api/api-types.ts +115 -0
  339. package/src/api/getDelegationInfo.ts +39 -0
  340. package/src/api/getNetworkInfo.ts +34 -0
  341. package/src/api/getPools.ts +35 -0
  342. package/src/api/getTransactions.ts +218 -0
  343. package/src/api/submitTransaction.ts +24 -0
  344. package/src/bridge/index.ts +69 -0
  345. package/src/bridge.integration.test.ts +113 -0
  346. package/src/broadcast.ts +21 -0
  347. package/src/buildOptimisticOperation.ts +181 -0
  348. package/src/buildSubAccounts.ts +170 -0
  349. package/src/buildTransaction.ts +435 -0
  350. package/src/cli-transaction.ts +82 -0
  351. package/src/constants.ts +10 -0
  352. package/src/createTransaction.ts +18 -0
  353. package/src/datasets/rawAccount.1.ts +19 -0
  354. package/src/datasets/scanAccounts.ts +23 -0
  355. package/src/deviceTransactionConfig.ts +128 -0
  356. package/src/errors.ts +18 -0
  357. package/src/estimateMaxSpendable.ts +61 -0
  358. package/src/getTransactionStatus.ts +251 -0
  359. package/src/getTransactionStatus.unit.test.ts +45 -0
  360. package/src/hw-getAddress.ts +37 -0
  361. package/src/logic.ts +330 -0
  362. package/src/logic.unit.test.ts +39 -0
  363. package/src/networks.ts +33 -0
  364. package/src/postSyncPatch.ts +42 -0
  365. package/src/prepareTransaction.ts +41 -0
  366. package/src/serialization.ts +219 -0
  367. package/src/signOperation.ts +82 -0
  368. package/src/signer.ts +98 -0
  369. package/src/specs.ts +253 -0
  370. package/src/speculos-deviceActions.ts +132 -0
  371. package/src/synchronisation.ts +347 -0
  372. package/src/synchronisation.unit.test.ts +137 -0
  373. package/src/transaction.ts +66 -0
  374. package/src/types.ts +227 -0
  375. package/src/typhonSerializer.ts +259 -0
  376. package/src/utils.ts +4 -0
  377. package/tsconfig.json +12 -0
@@ -0,0 +1,115 @@
1
+ import { ProtocolParams } from "../types";
2
+
3
+ type APIToken = { assetName: string; policyId: string; value: string };
4
+
5
+ type APIMetadata = { label: string; value: string };
6
+
7
+ export enum HashType {
8
+ ADDRESS = "ADDRESS",
9
+ SCRIPT = "SCRIPT",
10
+ }
11
+
12
+ export type StakeCredential = {
13
+ key: string;
14
+ type: HashType;
15
+ };
16
+
17
+ export type StakeKeyRegistrationCertificate = {
18
+ index: number;
19
+ stakeCredential: StakeCredential;
20
+ };
21
+
22
+ export type StakeKeyDeRegistrationCertificate = {
23
+ index: number;
24
+ stakeCredential: StakeCredential;
25
+ };
26
+
27
+ export type StakeDelegationCertificate = {
28
+ index: number;
29
+ poolKeyHash: string;
30
+ stakeCredential: StakeCredential;
31
+ };
32
+
33
+ export type TransactionCertificate =
34
+ | StakeKeyRegistrationCertificate
35
+ | StakeKeyDeRegistrationCertificate
36
+ | StakeDelegationCertificate;
37
+
38
+ export type TransactionCertificates = {
39
+ stakeRegistrations: Array<StakeKeyRegistrationCertificate>;
40
+ stakeDeRegistrations: Array<StakeKeyDeRegistrationCertificate>;
41
+ stakeDelegations: Array<StakeDelegationCertificate>;
42
+ };
43
+
44
+ export type APITransaction = {
45
+ fees: string;
46
+ hash: string;
47
+ timestamp: string;
48
+ blockHeight: number;
49
+ inputs: Array<{
50
+ txId: string;
51
+ index: number;
52
+ address: string;
53
+ value: string;
54
+ paymentKey: string;
55
+ tokens: Array<APIToken>;
56
+ }>;
57
+ certificate: TransactionCertificates;
58
+ outputs: Array<{
59
+ address: string;
60
+ value: string;
61
+ paymentKey: string;
62
+ tokens: Array<APIToken>;
63
+ }>;
64
+ metadata?: {
65
+ hash: string;
66
+ data: Array<APIMetadata>;
67
+ };
68
+ withdrawals?: Array<{
69
+ stakeCredential: StakeCredential;
70
+ amount: string;
71
+ }>;
72
+ };
73
+
74
+ export type APINetworkInfo = {
75
+ protocolParams: ProtocolParams;
76
+ };
77
+
78
+ export type APIDelegation = {
79
+ status: boolean;
80
+ stakeCredential: {
81
+ key: string;
82
+ type: string;
83
+ };
84
+ stake: string;
85
+ rewardsAvailable: string;
86
+ rewardsWithdrawn: string;
87
+ poolInfo: {
88
+ poolId: string;
89
+ name: string;
90
+ ticker: string;
91
+ };
92
+ };
93
+
94
+ export type StakePool = {
95
+ poolId: string;
96
+ name: string | undefined;
97
+ ticker: string | undefined;
98
+ website: string | undefined;
99
+ margin: string;
100
+ cost: string;
101
+ pledge: string;
102
+ retiredEpoch: number | undefined;
103
+ liveStake: string;
104
+ };
105
+
106
+ export type APIGetPoolList = {
107
+ pageNo: number;
108
+ limit: number;
109
+ count: number;
110
+ pools: Array<StakePool>;
111
+ };
112
+
113
+ export type APIGetPoolsDetail = {
114
+ pools: Array<StakePool>;
115
+ };
@@ -0,0 +1,39 @@
1
+ import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
2
+ import BigNumber from "bignumber.js";
3
+ import network from "@ledgerhq/live-network/network";
4
+ import { CARDANO_API_ENDPOINT, CARDANO_TESTNET_API_ENDPOINT } from "../constants";
5
+ import { isTestnet } from "../logic";
6
+ import { CardanoDelegation } from "../types";
7
+ import { APIDelegation } from "./api-types";
8
+
9
+ async function fetchDelegationInfo(
10
+ currency: CryptoCurrency,
11
+ stakeKey: string,
12
+ ): Promise<APIDelegation> {
13
+ const res = await network({
14
+ method: "GET",
15
+ url: isTestnet(currency)
16
+ ? `${CARDANO_TESTNET_API_ENDPOINT}/v1/delegation`
17
+ : `${CARDANO_API_ENDPOINT}/v1/delegation`,
18
+ params: {
19
+ stakeKey,
20
+ },
21
+ });
22
+ return res && res.data && (res.data.delegation as APIDelegation);
23
+ }
24
+
25
+ export async function getDelegationInfo(
26
+ currency: CryptoCurrency,
27
+ stakeKey: string,
28
+ ): Promise<CardanoDelegation | undefined> {
29
+ const res = await fetchDelegationInfo(currency, stakeKey);
30
+ return (
31
+ res && {
32
+ status: res.status,
33
+ poolId: res.poolInfo?.poolId,
34
+ ticker: res.poolInfo?.ticker,
35
+ name: res.poolInfo?.name,
36
+ rewards: new BigNumber(res.rewardsAvailable),
37
+ }
38
+ );
39
+ }
@@ -0,0 +1,34 @@
1
+ import network from "@ledgerhq/live-network/network";
2
+ import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
3
+ import { CARDANO_API_ENDPOINT, CARDANO_TESTNET_API_ENDPOINT } from "../constants";
4
+ import { getEpoch, isTestnet } from "../logic";
5
+ import { CardanoAccount } from "../types";
6
+ import { APINetworkInfo } from "./api-types";
7
+
8
+ async function fetchNetworkInfo(currency: CryptoCurrency): Promise<APINetworkInfo> {
9
+ const res = await network({
10
+ method: "GET",
11
+ url: isTestnet(currency)
12
+ ? `${CARDANO_TESTNET_API_ENDPOINT}/v1/network/info`
13
+ : `${CARDANO_API_ENDPOINT}/v1/network/info`,
14
+ });
15
+ return res && (res.data as APINetworkInfo);
16
+ }
17
+
18
+ export async function getNetworkInfo(
19
+ a: CardanoAccount | undefined,
20
+ currency: CryptoCurrency,
21
+ ): Promise<APINetworkInfo> {
22
+ if (a && a.cardanoResources) {
23
+ const currencyId = a.currency.id;
24
+ const currentEpoch = getEpoch(currencyId, new Date());
25
+ const lastSyncedEpoch = getEpoch(currencyId, a.lastSyncDate);
26
+
27
+ if (currentEpoch === lastSyncedEpoch) {
28
+ return {
29
+ protocolParams: a.cardanoResources.protocolParams,
30
+ };
31
+ }
32
+ }
33
+ return fetchNetworkInfo(currency);
34
+ }
@@ -0,0 +1,35 @@
1
+ import { APIGetPoolList, APIGetPoolsDetail } from "./api-types";
2
+ import { isTestnet } from "../logic";
3
+ import { CARDANO_API_ENDPOINT, CARDANO_TESTNET_API_ENDPOINT } from "../constants";
4
+ import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
5
+ import network from "@ledgerhq/live-network/network";
6
+
7
+ export async function fetchPoolList(
8
+ currency: CryptoCurrency,
9
+ search: string,
10
+ pageNo: number,
11
+ limit: number,
12
+ ): Promise<APIGetPoolList> {
13
+ const res = await network({
14
+ method: "GET",
15
+ url: isTestnet(currency)
16
+ ? `${CARDANO_TESTNET_API_ENDPOINT}/v1/pool/list`
17
+ : `${CARDANO_API_ENDPOINT}/v1/pool/list`,
18
+ params: { search, pageNo, limit },
19
+ });
20
+ return res && (res.data as APIGetPoolList);
21
+ }
22
+
23
+ export async function fetchPoolDetails(
24
+ currency: CryptoCurrency,
25
+ poolIds: Array<string>,
26
+ ): Promise<APIGetPoolsDetail> {
27
+ const res = await network({
28
+ method: "GET",
29
+ url: isTestnet(currency)
30
+ ? `${CARDANO_TESTNET_API_ENDPOINT}/v1/pool/detail`
31
+ : `${CARDANO_API_ENDPOINT}/v1/pool/detail`,
32
+ params: { poolIds },
33
+ });
34
+ return res && (res.data as APIGetPoolsDetail);
35
+ }
@@ -0,0 +1,218 @@
1
+ import network from "@ledgerhq/live-network/network";
2
+ import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
3
+ import { Bip32PublicKey } from "@stricahq/bip32ed25519";
4
+ import chunk from "lodash/chunk";
5
+ import range from "lodash/range";
6
+ import { getEnv } from "@ledgerhq/live-env";
7
+ import { CARDANO_API_ENDPOINT, CARDANO_TESTNET_API_ENDPOINT } from "../constants";
8
+ import { getBipPath, getCredentialKey, getExtendedPublicKeyFromHex, isTestnet } from "../logic";
9
+ import { CardanoAccount, PaymentChain, PaymentCredential } from "../types";
10
+ import * as ApiTypes from "./api-types";
11
+ import { APITransaction } from "./api-types";
12
+
13
+ async function fetchTransactions(
14
+ paymentKeys: Array<string>,
15
+ pageNo: number,
16
+ blockHeight: number,
17
+ currency: CryptoCurrency,
18
+ ): Promise<{
19
+ pageNo: number;
20
+ limit: number;
21
+ blockHeight: number;
22
+ transactions: Array<APITransaction>;
23
+ }> {
24
+ const res = await network({
25
+ method: "POST",
26
+ url: isTestnet(currency)
27
+ ? `${CARDANO_TESTNET_API_ENDPOINT}/v1/transaction`
28
+ : `${CARDANO_API_ENDPOINT}/v1/transaction`,
29
+ data: {
30
+ paymentKeys,
31
+ pageNo,
32
+ blockHeight,
33
+ },
34
+ });
35
+ return res.data;
36
+ }
37
+
38
+ async function getAllTransactionsByKeys(
39
+ paymentKeys: Array<string>,
40
+ blockHeight: number,
41
+ currency: CryptoCurrency,
42
+ ): Promise<{
43
+ transactions: Array<ApiTypes.APITransaction>;
44
+ blockHeight: number;
45
+ }> {
46
+ const transactions: Array<ApiTypes.APITransaction> = [];
47
+ let latestBlockHeight = 0;
48
+ let isAllTrxFetched = false;
49
+ let pageNo = 1;
50
+
51
+ while (!isAllTrxFetched) {
52
+ const res = await fetchTransactions(paymentKeys, pageNo, blockHeight, currency);
53
+ transactions.push(...res.transactions);
54
+ latestBlockHeight = Math.max(res.blockHeight, latestBlockHeight);
55
+ isAllTrxFetched = res.transactions.length < res.limit;
56
+ pageNo += 1;
57
+ }
58
+ return {
59
+ transactions,
60
+ blockHeight: latestBlockHeight,
61
+ };
62
+ }
63
+
64
+ async function getSyncedTransactionsByChain(
65
+ accountPubKey: Bip32PublicKey,
66
+ accountIndex: number,
67
+ chainType: PaymentChain,
68
+ blockHeight: number,
69
+ initialPaymentCredentials: Array<PaymentCredential>,
70
+ currency: CryptoCurrency,
71
+ ): Promise<{
72
+ transactions: Array<ApiTypes.APITransaction>;
73
+ latestBlockHeight: number;
74
+ paymentCredentials: Array<PaymentCredential>;
75
+ }> {
76
+ const keyChainRange = getEnv("KEYCHAIN_OBSERVABLE_RANGE") || 20;
77
+
78
+ // credentialsMap for efficient use
79
+ const initialPaymentCredentialMap: Record<string, PaymentCredential> = {};
80
+ let maxUsedKeyIndex = -1;
81
+ initialPaymentCredentials.forEach(cred => {
82
+ initialPaymentCredentialMap[cred.key] = cred;
83
+ if (cred.isUsed) maxUsedKeyIndex = cred.path.index;
84
+ });
85
+
86
+ const transactions: Array<ApiTypes.APITransaction> = [];
87
+ let latestBlockHeight = 0;
88
+
89
+ // fetch transactions for existing keys
90
+ const trxsRes = await Promise.all(
91
+ chunk(Object.keys(initialPaymentCredentialMap), keyChainRange).map(keys =>
92
+ getAllTransactionsByKeys(keys, blockHeight, currency),
93
+ ),
94
+ );
95
+ trxsRes.forEach(txRes => {
96
+ transactions.push(...txRes.transactions);
97
+ latestBlockHeight = Math.max(latestBlockHeight, txRes.blockHeight);
98
+ });
99
+
100
+ // fetch transactions for new avaialble keys
101
+ let newPaymentCredentialsMap: Record<string, PaymentCredential> = {};
102
+ let lastSyncedKeyIndex = initialPaymentCredentials.length
103
+ ? initialPaymentCredentials[initialPaymentCredentials.length - 1].path.index
104
+ : -1;
105
+ let syncToKeyIndex = maxUsedKeyIndex + keyChainRange;
106
+ while (syncToKeyIndex !== lastSyncedKeyIndex) {
107
+ const currentPaymentKeysMap: Record<string, PaymentCredential> = {};
108
+ range(lastSyncedKeyIndex + 1, syncToKeyIndex + 1, 1).forEach(keyIndex => {
109
+ const keyPath = getCredentialKey(
110
+ accountPubKey,
111
+ getBipPath({
112
+ account: accountIndex,
113
+ chain: chainType,
114
+ index: keyIndex,
115
+ }),
116
+ );
117
+ currentPaymentKeysMap[keyPath.key] = {
118
+ isUsed: false,
119
+ key: keyPath.key,
120
+ path: keyPath.path,
121
+ };
122
+ });
123
+ const trxRes = await getAllTransactionsByKeys(
124
+ Object.keys(currentPaymentKeysMap),
125
+ blockHeight,
126
+ currency,
127
+ );
128
+ transactions.push(...trxRes.transactions);
129
+
130
+ lastSyncedKeyIndex = syncToKeyIndex;
131
+ latestBlockHeight = Math.max(latestBlockHeight, trxRes.blockHeight);
132
+ newPaymentCredentialsMap = Object.assign({}, newPaymentCredentialsMap, currentPaymentKeysMap);
133
+ maxUsedKeyIndex = trxRes.transactions.reduce(
134
+ (maxIndexA, { inputs, outputs }) =>
135
+ [...inputs, ...outputs].reduce(
136
+ (maxIndexB, io) =>
137
+ Math.max(newPaymentCredentialsMap[io.paymentKey]?.path.index || -1, maxIndexB),
138
+ maxIndexA,
139
+ ),
140
+ maxUsedKeyIndex,
141
+ );
142
+ syncToKeyIndex = maxUsedKeyIndex + keyChainRange;
143
+ }
144
+
145
+ const availablePaymentCredentialsMap = {
146
+ ...initialPaymentCredentialMap,
147
+ ...newPaymentCredentialsMap,
148
+ };
149
+ transactions.forEach(trx => {
150
+ [...trx.inputs, ...trx.outputs].forEach(io => {
151
+ if (availablePaymentCredentialsMap[io.paymentKey]) {
152
+ availablePaymentCredentialsMap[io.paymentKey].isUsed = true;
153
+ }
154
+ });
155
+ });
156
+
157
+ return {
158
+ transactions,
159
+ latestBlockHeight,
160
+ paymentCredentials: Object.values(availablePaymentCredentialsMap).sort(
161
+ (aCred, bCred) => aCred.path.index - bCred.path.index,
162
+ ),
163
+ };
164
+ }
165
+
166
+ export async function getTransactions(
167
+ xpub: string,
168
+ accountIndex: number,
169
+ initialAccount: CardanoAccount | undefined,
170
+ blockHeight: number,
171
+ currency: CryptoCurrency,
172
+ ): Promise<{
173
+ transactions: Array<ApiTypes.APITransaction>;
174
+ blockHeight: number;
175
+ externalCredentials: Array<PaymentCredential>;
176
+ internalCredentials: Array<PaymentCredential>;
177
+ }> {
178
+ const accountPubKey = getExtendedPublicKeyFromHex(xpub);
179
+ const oldExternalCredentials = initialAccount?.cardanoResources?.externalCredentials || [];
180
+ const oldInternalCredentials = initialAccount?.cardanoResources?.internalCredentials || [];
181
+
182
+ const [
183
+ {
184
+ transactions: externalKeyTransactions,
185
+ latestBlockHeight: aBlockHeight,
186
+ paymentCredentials: externalCredentials,
187
+ },
188
+ {
189
+ transactions: internalKeyTransactions,
190
+ latestBlockHeight: bBlockHeight,
191
+ paymentCredentials: internalCredentials,
192
+ },
193
+ ] = await Promise.all([
194
+ getSyncedTransactionsByChain(
195
+ accountPubKey,
196
+ accountIndex,
197
+ PaymentChain.external,
198
+ blockHeight,
199
+ oldExternalCredentials,
200
+ currency,
201
+ ),
202
+ getSyncedTransactionsByChain(
203
+ accountPubKey,
204
+ accountIndex,
205
+ PaymentChain.internal,
206
+ blockHeight,
207
+ oldInternalCredentials,
208
+ currency,
209
+ ),
210
+ ]);
211
+
212
+ return {
213
+ transactions: [...externalKeyTransactions, ...internalKeyTransactions],
214
+ blockHeight: Math.max(aBlockHeight, bBlockHeight),
215
+ externalCredentials,
216
+ internalCredentials,
217
+ };
218
+ }
@@ -0,0 +1,24 @@
1
+ import network from "@ledgerhq/live-network/network";
2
+ import type { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
3
+ import { CARDANO_API_ENDPOINT, CARDANO_TESTNET_API_ENDPOINT } from "../constants";
4
+ import { isTestnet } from "../logic";
5
+ import { APITransaction } from "./api-types";
6
+
7
+ export async function submitTransaction({
8
+ transaction,
9
+ currency,
10
+ }: {
11
+ transaction: string;
12
+ currency: CryptoCurrency;
13
+ }): Promise<APITransaction> {
14
+ const res = await network({
15
+ method: "POST",
16
+ url: isTestnet(currency)
17
+ ? `${CARDANO_TESTNET_API_ENDPOINT}/v1/transaction/submit`
18
+ : `${CARDANO_API_ENDPOINT}/v1/transaction/submit`,
19
+ data: {
20
+ transaction: transaction,
21
+ },
22
+ });
23
+ return res.data.transaction;
24
+ }
@@ -0,0 +1,69 @@
1
+ import {
2
+ defaultUpdateTransaction,
3
+ makeAccountBridgeReceive,
4
+ makeScanAccounts,
5
+ makeSync,
6
+ } from "@ledgerhq/coin-framework/bridge/jsHelpers";
7
+ import { SignerContext } from "@ledgerhq/coin-framework/signer";
8
+ import type { AccountBridge, CurrencyBridge } from "@ledgerhq/types-live";
9
+ import getAddressWrapper from "@ledgerhq/coin-framework/bridge/getAddressWrapper";
10
+ import type { CardanoAccount, Transaction, TransactionStatus } from "../types";
11
+ import { assignToAccountRaw, assignFromAccountRaw } from "../serialization";
12
+ import { estimateMaxSpendable } from "../estimateMaxSpendable";
13
+ import { getTransactionStatus } from "../getTransactionStatus";
14
+ import { prepareTransaction } from "../prepareTransaction";
15
+ import { createTransaction } from "../createTransaction";
16
+ import { makeGetAccountShape } from "../synchronisation";
17
+ import { buildSignOperation } from "../signOperation";
18
+ import { postSyncPatch } from "../postSyncPatch";
19
+ import { CardanoSigner } from "../signer";
20
+ import { broadcast } from "../broadcast";
21
+ import resolver from "../hw-getAddress";
22
+
23
+ export function buildCurrencyBridge(signerContext: SignerContext<CardanoSigner>): CurrencyBridge {
24
+ const getAddress = resolver(signerContext);
25
+ const scanAccounts = makeScanAccounts({
26
+ getAccountShape: makeGetAccountShape(signerContext),
27
+ getAddressFn: getAddressWrapper(getAddress),
28
+ });
29
+
30
+ return {
31
+ scanAccounts,
32
+ preload: async () => ({}),
33
+ hydrate: () => {},
34
+ };
35
+ }
36
+
37
+ export function buildAccountBridge(
38
+ signerContext: SignerContext<CardanoSigner>,
39
+ ): AccountBridge<Transaction, CardanoAccount, TransactionStatus> {
40
+ const sync = makeSync({
41
+ getAccountShape: makeGetAccountShape(signerContext),
42
+ postSync: postSyncPatch,
43
+ });
44
+
45
+ const getAddress = resolver(signerContext);
46
+
47
+ const receive = makeAccountBridgeReceive(getAddressWrapper(getAddress));
48
+
49
+ return {
50
+ estimateMaxSpendable,
51
+ createTransaction,
52
+ updateTransaction: defaultUpdateTransaction,
53
+ getTransactionStatus,
54
+ prepareTransaction,
55
+ sync,
56
+ receive,
57
+ signOperation: buildSignOperation(signerContext),
58
+ broadcast,
59
+ assignToAccountRaw,
60
+ assignFromAccountRaw,
61
+ };
62
+ }
63
+
64
+ export function createBridges(signerContext: SignerContext<CardanoSigner>) {
65
+ return {
66
+ currencyBridge: buildCurrencyBridge(signerContext),
67
+ accountBridge: buildAccountBridge(signerContext),
68
+ };
69
+ }
@@ -0,0 +1,113 @@
1
+ import BigNumber from "bignumber.js";
2
+ import { cardanoRawAccount1 } from "./datasets/rawAccount.1";
3
+ import { cardanoScanAccounts } from "./datasets/scanAccounts";
4
+ import { CardanoInvalidPoolId, CardanoMinAmountError } from "./errors";
5
+ import { fromTransactionRaw } from "./transaction";
6
+ import type { Transaction } from "./types";
7
+ import type { DatasetTest } from "@ledgerhq/types-live";
8
+
9
+ export const dataset: DatasetTest<Transaction> = {
10
+ implementations: ["js"],
11
+ currencies: {
12
+ cardano_testnet: {
13
+ scanAccounts: cardanoScanAccounts,
14
+ accounts: [
15
+ {
16
+ raw: cardanoRawAccount1,
17
+ transactions: [
18
+ {
19
+ name: "amount less then minimum",
20
+ transaction: fromTransactionRaw({
21
+ family: "cardano",
22
+ recipient:
23
+ "addr_test1qpl90kc2jl5kr9tev0s7vays9yhwcdnq8nlylyk4dqsdq3g466elxnxwrzwq72pvp5akenj30t5s9et7frfvrxxx8xcsxrzs87",
24
+ amount: "0.1",
25
+ mode: "send",
26
+ poolId: undefined,
27
+ }),
28
+ expectedStatus: {
29
+ amount: new BigNumber("0.1"),
30
+ errors: {
31
+ amount: new CardanoMinAmountError(),
32
+ },
33
+ },
34
+ },
35
+ /* // FIXME broken test
36
+ {
37
+ name: "token amount more than balance",
38
+ transaction: fromTransactionRaw({
39
+ family: "cardano",
40
+ recipient:
41
+ "addr_test1qpl90kc2jl5kr9tev0s7vays9yhwcdnq8nlylyk4dqsdq3g466elxnxwrzwq72pvp5akenj30t5s9et7frfvrxxx8xcsxrzs87",
42
+ amount: "101",
43
+ subAccountId:
44
+ "js:2:cardano_testnet:806499588e0c4a58f4119f7e6e096bf42c3f774a528d2acec9e82ceebf87d1ceb3d4f3622dd2c77c65cc89c123f79337db22cf8a69f122e36dab1bf5083bf82d:cardano+cardano_testnet%2Fnative%2F47be64fcc8a7fe5321b976282ce4e43e4d29015f6613cfabcea28eab54657374",
45
+ mode: "send",
46
+ poolId: undefined,
47
+ }),
48
+ expectedStatus: {
49
+ amount: new BigNumber("101"),
50
+ errors: {
51
+ amount: new NotEnoughBalance(),
52
+ },
53
+ },
54
+ },
55
+ {
56
+ name: "send max token",
57
+ transaction: fromTransactionRaw({
58
+ family: "cardano",
59
+ recipient:
60
+ "addr_test1qpl90kc2jl5kr9tev0s7vays9yhwcdnq8nlylyk4dqsdq3g466elxnxwrzwq72pvp5akenj30t5s9et7frfvrxxx8xcsxrzs87",
61
+ amount: "0",
62
+ subAccountId:
63
+ "js:2:cardano_testnet:806499588e0c4a58f4119f7e6e096bf42c3f774a528d2acec9e82ceebf87d1ceb3d4f3622dd2c77c65cc89c123f79337db22cf8a69f122e36dab1bf5083bf82d:cardano+cardano_testnet%2Fnative%2F47be64fcc8a7fe5321b976282ce4e43e4d29015f6613cfabcea28eab54657374",
64
+ mode: "send",
65
+ useAllAmount: true,
66
+ poolId: undefined,
67
+ }),
68
+ expectedStatus: {
69
+ amount: new BigNumber("100"),
70
+ totalSpent: new BigNumber("100"),
71
+ errors: {},
72
+ warnings: {},
73
+ },
74
+ },
75
+ */
76
+ {
77
+ name: "delegate to invalid poolId",
78
+ transaction: fromTransactionRaw({
79
+ family: "cardano",
80
+ recipient: "",
81
+ amount: "0",
82
+ mode: "delegate",
83
+ poolId: "efae72c07a26e4542ba55ef59d35ad45ffaaac312865e3a758ede",
84
+ }),
85
+ expectedStatus: {
86
+ errors: {
87
+ poolId: new CardanoInvalidPoolId(),
88
+ },
89
+ },
90
+ },
91
+ {
92
+ name: "delegate valid poolId",
93
+ transaction: fromTransactionRaw({
94
+ family: "cardano",
95
+ recipient: "",
96
+ amount: "0",
97
+ mode: "delegate",
98
+ poolId: "efae72c07a26e4542ba55ef59d35ad45ffaaac312865e3a758ede997",
99
+ }),
100
+ expectedStatus: {},
101
+ },
102
+ ],
103
+ },
104
+ ],
105
+ },
106
+ },
107
+ };
108
+
109
+ describe("Cardano bridge", () => {
110
+ test.todo(
111
+ "This is an empty test to make jest command pass. Remove it once there is a real test.",
112
+ );
113
+ });
@@ -0,0 +1,21 @@
1
+ import type { AccountBridge } from "@ledgerhq/types-live";
2
+ import { patchOperationWithHash } from "@ledgerhq/coin-framework/operation";
3
+ import { submitTransaction } from "./api/submitTransaction";
4
+ import { Transaction } from "./types";
5
+
6
+ /**
7
+ * Broadcast the signed transaction
8
+ * @param {signature: string, operation: string} signedOperation
9
+ */
10
+ export const broadcast: AccountBridge<Transaction>["broadcast"] = async ({
11
+ signedOperation,
12
+ account,
13
+ }) => {
14
+ const signedTx = signedOperation.signature;
15
+ const pendingTransaction = await submitTransaction({
16
+ transaction: signedTx,
17
+ currency: account.currency,
18
+ });
19
+
20
+ return patchOperationWithHash(signedOperation.operation, pendingTransaction.hash);
21
+ };