@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
package/src/logic.ts ADDED
@@ -0,0 +1,330 @@
1
+ import {
2
+ CARDANO_COIN_TYPE,
3
+ CARDANO_PURPOSE,
4
+ MEMO_LABEL,
5
+ STAKING_ADDRESS_INDEX,
6
+ TTL_GAP,
7
+ } from "./constants";
8
+
9
+ import {
10
+ utils as TyphonUtils,
11
+ types as TyphonTypes,
12
+ address as TyphonAddress,
13
+ } from "@stricahq/typhonjs";
14
+
15
+ import {
16
+ CardanoAccount,
17
+ BipPath,
18
+ PaymentChain,
19
+ PaymentCredential,
20
+ StakeChain,
21
+ StakeCredential,
22
+ Token,
23
+ } from "./types";
24
+ import { Bip32PublicKey } from "@stricahq/bip32ed25519";
25
+ import BigNumber from "bignumber.js";
26
+ import { getNetworkParameters } from "./networks";
27
+ import groupBy from "lodash/groupBy";
28
+ import { APITransaction } from "./api/api-types";
29
+ import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets";
30
+ import ShelleyTypeAddress from "@stricahq/typhonjs/dist/address/ShelleyTypeAddress";
31
+ import type { OperationType } from "@ledgerhq/types-live";
32
+ import type { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
33
+ import bech32 from "bech32";
34
+
35
+ /**
36
+ * returns BipPath object with account, chain and index field for cardano
37
+ *
38
+ * @param {string} path
39
+ */
40
+ export function getBipPathFromString(path: string): BipPath {
41
+ const regEx = new RegExp(`^${CARDANO_PURPOSE}'/${CARDANO_COIN_TYPE}'/(\\d*)'/([012])/(\\d*)`);
42
+ const result = path.match(regEx);
43
+ if (result == null) {
44
+ throw new Error("Invalid derivation path");
45
+ }
46
+ return getBipPath({
47
+ account: parseInt(result[1]),
48
+ chain: parseInt(result[2]),
49
+ index: parseInt(result[3]),
50
+ });
51
+ }
52
+
53
+ /**
54
+ *
55
+ * @returns true if the account can stake, false otherwise
56
+ */
57
+ export function canStake(account: CardanoAccount): boolean {
58
+ return account.balance.gt(0);
59
+ }
60
+
61
+ /**
62
+ *
63
+ * @returns true if account is staked, false otherwise
64
+ */
65
+ export function isAlreadyStaking(account: CardanoAccount): boolean {
66
+ return !!account.cardanoResources?.delegation?.poolId;
67
+ }
68
+
69
+ /**
70
+ * returns complete bipPath with purpose, coin, account, chain and index for cardano
71
+ */
72
+ export function getBipPath({
73
+ account,
74
+ chain,
75
+ index,
76
+ }: {
77
+ account: number;
78
+ chain: PaymentChain | StakeChain;
79
+ index: number;
80
+ }): BipPath {
81
+ return {
82
+ purpose: CARDANO_PURPOSE,
83
+ coin: CARDANO_COIN_TYPE,
84
+ account,
85
+ chain,
86
+ index,
87
+ };
88
+ }
89
+
90
+ /**
91
+ * returns bipPathString from account, chain and index for cardano
92
+ */
93
+ export function getBipPathString({
94
+ account,
95
+ chain,
96
+ index,
97
+ }: {
98
+ account: number;
99
+ chain: number;
100
+ index: number;
101
+ }): string {
102
+ return `${CARDANO_PURPOSE}'/${CARDANO_COIN_TYPE}'/${account}'/${chain}/${index}`;
103
+ }
104
+
105
+ export function getExtendedPublicKeyFromHex(keyHex: string): Bip32PublicKey {
106
+ return Bip32PublicKey.fromBytes(Buffer.from(keyHex, "hex"));
107
+ }
108
+
109
+ export function getCredentialKey(
110
+ accountKey: Bip32PublicKey,
111
+ path: BipPath,
112
+ ): { key: string; path: BipPath } {
113
+ const keyBytes = accountKey.derive(path.chain).derive(path.index).toPublicKey().hash();
114
+ const pubKeyHex = keyBytes.toString("hex");
115
+ return {
116
+ key: pubKeyHex,
117
+ path,
118
+ };
119
+ }
120
+
121
+ /**
122
+ * returns cardano base address by paymentKey and stakeKey
123
+ */
124
+ export function getBaseAddress({
125
+ networkId,
126
+ paymentCred,
127
+ stakeCred,
128
+ }: {
129
+ networkId: number;
130
+ paymentCred: PaymentCredential;
131
+ stakeCred: StakeCredential;
132
+ }): TyphonAddress.BaseAddress {
133
+ const paymentCredential: TyphonTypes.HashCredential = {
134
+ hash: paymentCred.key,
135
+ type: TyphonTypes.HashType.ADDRESS,
136
+ bipPath: paymentCred.path,
137
+ };
138
+
139
+ const stakeCredential: TyphonTypes.HashCredential = {
140
+ hash: stakeCred.key,
141
+ type: TyphonTypes.HashType.ADDRESS,
142
+ bipPath: stakeCred.path,
143
+ };
144
+ return new TyphonAddress.BaseAddress(networkId, paymentCredential, stakeCredential);
145
+ }
146
+
147
+ /**
148
+ * Returns true if address is a valid
149
+ *
150
+ * @param {string} address
151
+ */
152
+ export const isValidAddress = (address: string, networkId: number): boolean => {
153
+ if (!address) return false;
154
+
155
+ try {
156
+ const cardanoAddress = TyphonUtils.getAddressFromBech32(address);
157
+ if (cardanoAddress instanceof ShelleyTypeAddress) {
158
+ const addressNetworkId = Number(cardanoAddress.getHex().toLowerCase().charAt(1));
159
+ if (addressNetworkId !== networkId) {
160
+ return false;
161
+ }
162
+ }
163
+ } catch (error) {
164
+ return false;
165
+ }
166
+ return true;
167
+ };
168
+
169
+ export const getAbsoluteSlot = function (networkName: string, time: Date): number {
170
+ const networkParams = getNetworkParameters(networkName);
171
+ const byronChainEndSlots = networkParams.shelleyStartEpoch * networkParams.byronSlotsPerEpoch;
172
+ const byronChainEndTime = byronChainEndSlots * networkParams.byronSlotDuration;
173
+
174
+ const shelleyChainTime = time.getTime() - networkParams.chainStartTime - byronChainEndTime;
175
+ const shelleyChainSlots = Math.floor(shelleyChainTime / networkParams.shelleySlotDuration);
176
+ return byronChainEndSlots + shelleyChainSlots;
177
+ };
178
+
179
+ /**
180
+ * Returns the time to live for transaction
181
+ *
182
+ * @returns {number}
183
+ */
184
+ export function getTTL(networkName: string): number {
185
+ return getAbsoluteSlot(networkName, new Date()) + TTL_GAP;
186
+ }
187
+
188
+ export function getEpoch(networkName: string, time: Date): number {
189
+ const networkParams = getNetworkParameters(networkName);
190
+ const chainTime = time.getTime() - networkParams.chainStartTime;
191
+ const epoch = Math.floor(
192
+ chainTime / (networkParams.shelleySlotsPerEpoch * networkParams.shelleySlotDuration),
193
+ );
194
+ return epoch;
195
+ }
196
+
197
+ export function mergeTokens(tokens: Array<TyphonTypes.Token>): Array<TyphonTypes.Token> {
198
+ return Object.values(groupBy(tokens, t => `${t.policyId}${t.assetName}`)).map(similarTokens => ({
199
+ policyId: similarTokens[0].policyId,
200
+ assetName: similarTokens[0].assetName,
201
+ amount: similarTokens.reduce((total, token) => total.plus(token.amount), new BigNumber(0)),
202
+ }));
203
+ }
204
+
205
+ /**
206
+ * @param { Array<TyphonTypes.Token> } b
207
+ * @param { Array<TyphonTypes.Token> } a
208
+ * @returns a - b
209
+ */
210
+ export function getTokenDiff(
211
+ a: Array<TyphonTypes.Token>,
212
+ b: Array<TyphonTypes.Token>,
213
+ ): Array<TyphonTypes.Token> {
214
+ return mergeTokens(a.concat(b.map(t => ({ ...t, amount: t.amount.negated() })))).filter(
215
+ t => !t.amount.eq(0),
216
+ );
217
+ }
218
+
219
+ export function getAccountStakeCredential(xpub: string, index: number): StakeCredential {
220
+ const accountXPubKey = getExtendedPublicKeyFromHex(xpub);
221
+ const keyPath = getCredentialKey(
222
+ accountXPubKey,
223
+ getBipPath({
224
+ account: index,
225
+ chain: StakeChain.stake,
226
+ index: STAKING_ADDRESS_INDEX,
227
+ }),
228
+ );
229
+ return {
230
+ key: keyPath.key,
231
+ path: keyPath.path,
232
+ };
233
+ }
234
+
235
+ export function getOperationType({
236
+ valueChange,
237
+ fees,
238
+ }: {
239
+ valueChange: BigNumber;
240
+ fees: BigNumber;
241
+ }): OperationType {
242
+ return valueChange.isNegative()
243
+ ? valueChange.absoluteValue().eq(fees)
244
+ ? "FEES"
245
+ : "OUT"
246
+ : valueChange.isPositive()
247
+ ? "IN"
248
+ : "NONE";
249
+ }
250
+
251
+ export function isTestnet(currency: CryptoCurrency): boolean {
252
+ return getCryptoCurrencyById(currency.id).isTestnetFor ? true : false;
253
+ }
254
+
255
+ export function getAccountChange(
256
+ t: APITransaction,
257
+ accountCredentialsMap: Record<string, PaymentCredential>,
258
+ ): { ada: BigNumber; tokens: Array<Token> } {
259
+ let accountInputAda = new BigNumber(0);
260
+ const accountInputTokens: Array<Token> = [];
261
+ t.inputs.forEach(i => {
262
+ if (accountCredentialsMap[i.paymentKey]) {
263
+ accountInputAda = accountInputAda.plus(i.value);
264
+ accountInputTokens.push(
265
+ ...i.tokens.map(t => ({
266
+ assetName: t.assetName,
267
+ policyId: t.policyId,
268
+ amount: new BigNumber(t.value),
269
+ })),
270
+ );
271
+ }
272
+ });
273
+
274
+ let accountOutputAda = new BigNumber(0);
275
+ const accountOutputTokens: Array<Token> = [];
276
+ t.outputs.forEach(o => {
277
+ if (accountCredentialsMap[o.paymentKey]) {
278
+ accountOutputAda = accountOutputAda.plus(o.value);
279
+ accountOutputTokens.push(
280
+ ...o.tokens.map(t => ({
281
+ assetName: t.assetName,
282
+ policyId: t.policyId,
283
+ amount: new BigNumber(t.value),
284
+ })),
285
+ );
286
+ }
287
+ });
288
+
289
+ return {
290
+ ada: accountOutputAda.minus(accountInputAda),
291
+ tokens: getTokenDiff(accountOutputTokens, accountInputTokens),
292
+ };
293
+ }
294
+
295
+ export function getMemoFromTx(tx: APITransaction): string | undefined {
296
+ let memo;
297
+ const metadataValue = tx.metadata?.data.find(m => m.label === MEMO_LABEL.toString());
298
+ if (metadataValue) {
299
+ try {
300
+ const parsedValue = JSON.parse(metadataValue.value);
301
+ if (parsedValue.msg && Array.isArray(parsedValue.msg) && parsedValue.msg.length) {
302
+ memo = parsedValue.msg.join(", ");
303
+ }
304
+ // eslint-disable-next-line no-empty
305
+ } catch (e) {}
306
+ }
307
+ return memo;
308
+ }
309
+
310
+ export function isHexString(value: string): boolean {
311
+ const regExp = /^[0-9a-fA-F]+$/;
312
+ return regExp.test(value);
313
+ }
314
+
315
+ export function decodeTokenName(assetName: string): string {
316
+ if (assetName.length > 0) {
317
+ const bytes = [...Buffer.from(assetName, "hex")];
318
+ if (bytes.filter(byte => byte <= 32 || byte >= 127).length === 0) {
319
+ return String.fromCharCode(...bytes);
320
+ }
321
+ }
322
+ return assetName;
323
+ }
324
+
325
+ export function getBech32PoolId(poolId: string, networkName: string): string {
326
+ const networkParams = getNetworkParameters(networkName);
327
+ const words = bech32.toWords(Buffer.from(poolId, "hex"));
328
+ const encoded = bech32.encode(networkParams.poolIdPrefix, words, 1000);
329
+ return encoded;
330
+ }
@@ -0,0 +1,39 @@
1
+ import BigNumber from "bignumber.js";
2
+ import { canStake, isAlreadyStaking } from "./logic";
3
+ import { CardanoAccount } from "./types";
4
+
5
+ describe("canStake", () => {
6
+ it("should return false when acc has no funds", () => {
7
+ const accWithNoFunds = {
8
+ balance: new BigNumber(0),
9
+ } as CardanoAccount;
10
+ expect(canStake(accWithNoFunds)).toEqual(false);
11
+ });
12
+
13
+ it("should return true when acc has funds", () => {
14
+ const accWithFunds = {
15
+ balance: new BigNumber(1),
16
+ } as CardanoAccount;
17
+ expect(canStake(accWithFunds)).toEqual(true);
18
+ });
19
+ });
20
+
21
+ describe("isAlreadyStaking", () => {
22
+ it("should return false when acc isn't delegating", () => {
23
+ const noResourcesAcc = {} as CardanoAccount;
24
+ expect(isAlreadyStaking(noResourcesAcc)).toEqual(false);
25
+ const noDelegationAcc = {
26
+ cardanoResources: {},
27
+ } as CardanoAccount;
28
+ expect(isAlreadyStaking(noDelegationAcc)).toEqual(false);
29
+ const noPoolIdAcc = { cardanoResources: { delegation: {} } } as CardanoAccount;
30
+ expect(isAlreadyStaking(noPoolIdAcc)).toEqual(false);
31
+ });
32
+
33
+ it("should return true when acc is delegating", () => {
34
+ const noResourcesAcc = {
35
+ cardanoResources: { delegation: { poolId: "itspoolid" } },
36
+ } as CardanoAccount;
37
+ expect(isAlreadyStaking(noResourcesAcc)).toEqual(true);
38
+ });
39
+ });
@@ -0,0 +1,33 @@
1
+ import type { CardanoLikeNetworkParameters } from "./types";
2
+
3
+ export const getNetworkParameters = (networkName: string): CardanoLikeNetworkParameters => {
4
+ if (networkName === "cardano") {
5
+ return {
6
+ identifier: "cardano",
7
+ networkId: 1,
8
+ chainStartTime: 1506203091000,
9
+ byronSlotDuration: 20000,
10
+ byronSlotsPerEpoch: 21600,
11
+ shelleyStartEpoch: 208,
12
+ shelleySlotDuration: 1000,
13
+ shelleySlotsPerEpoch: 432000,
14
+ addressPrefix: "addr",
15
+ poolIdPrefix: "pool",
16
+ };
17
+ } else if (networkName === "cardano_testnet") {
18
+ return {
19
+ identifier: "cardano_testnet",
20
+ networkId: 0,
21
+ chainStartTime: 1563999616000,
22
+ byronSlotDuration: 20000,
23
+ byronSlotsPerEpoch: 21600,
24
+ shelleyStartEpoch: 74,
25
+ shelleySlotDuration: 1000,
26
+ shelleySlotsPerEpoch: 432000,
27
+ addressPrefix: "addr_test",
28
+ poolIdPrefix: "pool",
29
+ };
30
+ }
31
+
32
+ throw new Error("No network parameters set for " + networkName);
33
+ };
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Code reference taken from src/families/ethereum/postSyncPatch.ts
3
+ */
4
+
5
+ import type { AccountLike, Operation } from "@ledgerhq/types-live";
6
+ import { CardanoAccount } from "./types";
7
+
8
+ // we need to preserve ADA pendingOperations because there is no mempool to do this
9
+ // we assume we need to preserve until:
10
+ // - that txid appears in operations
11
+ const postSyncPatchGen = <T extends AccountLike>(
12
+ initial: T,
13
+ synced: T,
14
+ parentPendingOperation?: Operation[],
15
+ ): T => {
16
+ const pendingOperations = initial.pendingOperations || [];
17
+ if (pendingOperations.length === 0) return synced;
18
+ const { operations } = synced;
19
+ synced.pendingOperations = pendingOperations.filter(
20
+ op =>
21
+ (!parentPendingOperation || // a child pending parent need to disappear if parent ada op disappear
22
+ parentPendingOperation.some(o => o.hash === op.hash)) &&
23
+ !operations.some(o => o.hash === op.hash), // after retain logic, we need operation to appear
24
+ );
25
+ return synced;
26
+ };
27
+
28
+ export const postSyncPatch = (initial: CardanoAccount, synced: CardanoAccount): CardanoAccount => {
29
+ const acc = postSyncPatchGen(initial, synced);
30
+ const { subAccounts, pendingOperations } = acc;
31
+ const initialSubAccounts = initial.subAccounts;
32
+
33
+ if (subAccounts && initialSubAccounts) {
34
+ acc.subAccounts = subAccounts.map(subAccount => {
35
+ const initialSubAccount = initialSubAccounts.find(a => a.id === subAccount.id);
36
+ if (!initialSubAccount) return subAccount;
37
+ return postSyncPatchGen(initialSubAccount, subAccount, pendingOperations);
38
+ });
39
+ }
40
+
41
+ return acc;
42
+ };
@@ -0,0 +1,41 @@
1
+ import { BigNumber } from "bignumber.js";
2
+ import { types as TyphonTypes, address as TyphonAddress } from "@stricahq/typhonjs";
3
+ import { defaultUpdateTransaction } from "@ledgerhq/coin-framework/bridge/jsHelpers";
4
+
5
+ import { CardanoAccount, Transaction } from "./types";
6
+ import { buildTransaction } from "./buildTransaction";
7
+ import { AccountBridge } from "@ledgerhq/types-live";
8
+
9
+ /**
10
+ * Prepare transaction before checking status
11
+ *
12
+ * @param {Account} account
13
+ * @param {Transaction} transaction
14
+ */
15
+ export const prepareTransaction: AccountBridge<
16
+ Transaction,
17
+ CardanoAccount
18
+ >["prepareTransaction"] = async (account, transaction) => {
19
+ let patch = {};
20
+ try {
21
+ const cardanoTransaction = await buildTransaction(account, transaction);
22
+ const transactionFees = cardanoTransaction.getFee();
23
+ const transactionAmount = transaction.subAccountId
24
+ ? transaction.amount
25
+ : cardanoTransaction
26
+ .getOutputs()
27
+ .filter(
28
+ o =>
29
+ !(o.address instanceof TyphonAddress.BaseAddress) ||
30
+ !(o.address.paymentCredential.type === TyphonTypes.HashType.ADDRESS) ||
31
+ o.address.paymentCredential.bipPath === undefined,
32
+ )
33
+ .reduce((total, o) => total.plus(o.amount), new BigNumber(0));
34
+
35
+ patch = { fees: transactionFees, amount: transactionAmount };
36
+ } catch (error) {
37
+ patch = { fees: new BigNumber(0), amount: transaction.amount };
38
+ }
39
+
40
+ return defaultUpdateTransaction(transaction, patch);
41
+ };
@@ -0,0 +1,219 @@
1
+ import { BigNumber } from "bignumber.js";
2
+ import type {
3
+ BipPath,
4
+ BipPathRaw,
5
+ CardanoDelegation,
6
+ CardanoDelegationRaw,
7
+ CardanoAccount,
8
+ CardanoAccountRaw,
9
+ CardanoOutput,
10
+ CardanoOutputRaw,
11
+ CardanoResources,
12
+ CardanoResourcesRaw,
13
+ PaymentCredential,
14
+ PaymentCredentialRaw,
15
+ ProtocolParams,
16
+ ProtocolParamsRaw,
17
+ Token,
18
+ TokenRaw,
19
+ } from "./types";
20
+ import { Account, AccountRaw } from "@ledgerhq/types-live";
21
+
22
+ function toTokenRaw({ assetName, policyId, amount }: Token): TokenRaw {
23
+ return {
24
+ assetName,
25
+ policyId,
26
+ amount: amount.toString(),
27
+ };
28
+ }
29
+
30
+ function fromTokenRaw({ assetName, policyId, amount }: TokenRaw): Token {
31
+ return {
32
+ assetName,
33
+ policyId,
34
+ amount: new BigNumber(amount),
35
+ };
36
+ }
37
+
38
+ function toBipPathRaw({ purpose, coin, account, chain, index }: BipPath): BipPathRaw {
39
+ return {
40
+ purpose,
41
+ coin,
42
+ account,
43
+ chain,
44
+ index,
45
+ };
46
+ }
47
+
48
+ function fromBipPathRaw({ purpose, coin, account, chain, index }: BipPathRaw): BipPath {
49
+ return {
50
+ purpose,
51
+ coin,
52
+ account,
53
+ chain,
54
+ index,
55
+ };
56
+ }
57
+
58
+ function toPaymentCredentialRaw(r: PaymentCredential): PaymentCredentialRaw {
59
+ return {
60
+ isUsed: r.isUsed,
61
+ key: r.key,
62
+ path: toBipPathRaw(r.path),
63
+ };
64
+ }
65
+
66
+ function fromPaymentCredentialRaw(r: PaymentCredentialRaw): PaymentCredential {
67
+ return {
68
+ isUsed: r.isUsed,
69
+ key: r.key,
70
+ path: fromBipPathRaw(r.path),
71
+ };
72
+ }
73
+
74
+ function toCardanoOutputRaw({
75
+ hash,
76
+ index,
77
+ address,
78
+ amount,
79
+ tokens,
80
+ paymentCredential,
81
+ }: CardanoOutput): CardanoOutputRaw {
82
+ return {
83
+ hash,
84
+ index,
85
+ address,
86
+ amount: amount.toString(),
87
+ tokens: tokens.map(toTokenRaw),
88
+ paymentCredential,
89
+ };
90
+ }
91
+
92
+ function fromCardanoOutputRaw({
93
+ hash,
94
+ index,
95
+ address,
96
+ amount,
97
+ tokens,
98
+ paymentCredential,
99
+ }: CardanoOutputRaw): CardanoOutput {
100
+ return {
101
+ hash,
102
+ index,
103
+ address,
104
+ amount: new BigNumber(amount),
105
+ tokens: tokens.map(fromTokenRaw),
106
+ paymentCredential,
107
+ };
108
+ }
109
+
110
+ function toProtocolParamsRaw({
111
+ minFeeA,
112
+ minFeeB,
113
+ stakeKeyDeposit,
114
+ lovelacePerUtxoWord,
115
+ collateralPercent,
116
+ priceSteps,
117
+ priceMem,
118
+ languageView,
119
+ }: ProtocolParams): ProtocolParamsRaw {
120
+ return {
121
+ minFeeA,
122
+ minFeeB,
123
+ stakeKeyDeposit,
124
+ lovelacePerUtxoWord,
125
+ collateralPercent,
126
+ priceSteps,
127
+ priceMem,
128
+ languageView,
129
+ };
130
+ }
131
+
132
+ function fromProtocolParamsRaw({
133
+ minFeeA,
134
+ minFeeB,
135
+ stakeKeyDeposit,
136
+ lovelacePerUtxoWord,
137
+ collateralPercent,
138
+ priceSteps,
139
+ priceMem,
140
+ languageView,
141
+ }: ProtocolParamsRaw): ProtocolParams {
142
+ return {
143
+ minFeeA,
144
+ minFeeB,
145
+ stakeKeyDeposit,
146
+ lovelacePerUtxoWord,
147
+ collateralPercent,
148
+ priceSteps,
149
+ priceMem,
150
+ languageView,
151
+ };
152
+ }
153
+
154
+ function toDelegationRaw({
155
+ status,
156
+ poolId,
157
+ ticker,
158
+ name,
159
+ rewards,
160
+ }: CardanoDelegation): CardanoDelegationRaw {
161
+ return {
162
+ status,
163
+ poolId,
164
+ ticker,
165
+ name,
166
+ rewards: rewards.toString(),
167
+ };
168
+ }
169
+
170
+ function fromDelegationRaw({
171
+ status,
172
+ poolId,
173
+ ticker,
174
+ name,
175
+ rewards,
176
+ }: CardanoDelegationRaw): CardanoDelegation {
177
+ return {
178
+ status,
179
+ poolId,
180
+ ticker,
181
+ name,
182
+ rewards: new BigNumber(rewards),
183
+ };
184
+ }
185
+
186
+ export function toCardanoResourceRaw(r: CardanoResources): CardanoResourcesRaw {
187
+ return {
188
+ internalCredentials: r.internalCredentials.map(toPaymentCredentialRaw),
189
+ externalCredentials: r.externalCredentials.map(toPaymentCredentialRaw),
190
+ delegation: r.delegation ? toDelegationRaw(r.delegation) : undefined,
191
+ utxos: r.utxos.map(toCardanoOutputRaw),
192
+ protocolParams: toProtocolParamsRaw(r.protocolParams),
193
+ };
194
+ }
195
+
196
+ export function fromCardanoResourceRaw(r: CardanoResourcesRaw): CardanoResources {
197
+ return {
198
+ internalCredentials: r.internalCredentials.map(fromPaymentCredentialRaw),
199
+ externalCredentials: r.externalCredentials.map(fromPaymentCredentialRaw),
200
+ delegation: r.delegation ? fromDelegationRaw(r.delegation) : undefined,
201
+ utxos: r.utxos.map(fromCardanoOutputRaw),
202
+ protocolParams: fromProtocolParamsRaw(r.protocolParams),
203
+ };
204
+ }
205
+
206
+ export function assignToAccountRaw(account: Account, accountRaw: AccountRaw): void {
207
+ const cardanoAccount = account as CardanoAccount;
208
+ if (cardanoAccount.cardanoResources) {
209
+ (accountRaw as CardanoAccountRaw).cardanoResources = toCardanoResourceRaw(
210
+ cardanoAccount.cardanoResources,
211
+ );
212
+ }
213
+ }
214
+
215
+ export function assignFromAccountRaw(accountRaw: AccountRaw, account: Account) {
216
+ const cardanoResourcesRaw = (accountRaw as CardanoAccountRaw).cardanoResources;
217
+ if (cardanoResourcesRaw)
218
+ (account as CardanoAccount).cardanoResources = fromCardanoResourceRaw(cardanoResourcesRaw);
219
+ }