@ledgerhq/coin-framework 0.0.2

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 (471) hide show
  1. package/lib/account/accountId.d.ts +16 -0
  2. package/lib/account/accountId.d.ts.map +1 -0
  3. package/lib/account/accountId.js +85 -0
  4. package/lib/account/accountId.js.map +1 -0
  5. package/lib/account/accountName.d.ts +14 -0
  6. package/lib/account/accountName.d.ts.map +1 -0
  7. package/lib/account/accountName.js +17 -0
  8. package/lib/account/accountName.js.map +1 -0
  9. package/lib/account/addAccounts.d.ts +35 -0
  10. package/lib/account/addAccounts.d.ts.map +1 -0
  11. package/lib/account/addAccounts.js +209 -0
  12. package/lib/account/addAccounts.js.map +1 -0
  13. package/lib/account/balanceHistoryCache.d.ts +25 -0
  14. package/lib/account/balanceHistoryCache.d.ts.map +1 -0
  15. package/lib/account/balanceHistoryCache.js +115 -0
  16. package/lib/account/balanceHistoryCache.js.map +1 -0
  17. package/lib/account/groupOperations.d.ts +17 -0
  18. package/lib/account/groupOperations.d.ts.map +1 -0
  19. package/lib/account/groupOperations.js +127 -0
  20. package/lib/account/groupOperations.js.map +1 -0
  21. package/lib/account/helpers.d.ts +44 -0
  22. package/lib/account/helpers.d.ts.map +1 -0
  23. package/lib/account/helpers.js +333 -0
  24. package/lib/account/helpers.js.map +1 -0
  25. package/lib/account/helpers.test.d.ts +2 -0
  26. package/lib/account/helpers.test.d.ts.map +1 -0
  27. package/lib/account/helpers.test.js +366 -0
  28. package/lib/account/helpers.test.js.map +1 -0
  29. package/lib/account/index.d.ts +11 -0
  30. package/lib/account/index.d.ts.map +1 -0
  31. package/lib/account/index.js +27 -0
  32. package/lib/account/index.js.map +1 -0
  33. package/lib/account/ordering.d.ts +10 -0
  34. package/lib/account/ordering.d.ts.map +1 -0
  35. package/lib/account/ordering.js +110 -0
  36. package/lib/account/ordering.js.map +1 -0
  37. package/lib/account/pending.d.ts +33 -0
  38. package/lib/account/pending.d.ts.map +1 -0
  39. package/lib/account/pending.js +64 -0
  40. package/lib/account/pending.js.map +1 -0
  41. package/lib/account/serialization.d.ts +6 -0
  42. package/lib/account/serialization.d.ts.map +1 -0
  43. package/lib/account/serialization.js +118 -0
  44. package/lib/account/serialization.js.map +1 -0
  45. package/lib/account/support.d.ts +9 -0
  46. package/lib/account/support.d.ts.map +1 -0
  47. package/lib/account/support.js +72 -0
  48. package/lib/account/support.js.map +1 -0
  49. package/lib/account.test.d.ts +2 -0
  50. package/lib/account.test.d.ts.map +1 -0
  51. package/lib/account.test.js +257 -0
  52. package/lib/account.test.js.map +1 -0
  53. package/lib/bot/bot-test-context.d.ts +3 -0
  54. package/lib/bot/bot-test-context.d.ts.map +1 -0
  55. package/lib/bot/bot-test-context.js +26 -0
  56. package/lib/bot/bot-test-context.js.map +1 -0
  57. package/lib/bot/bot-test-context.test.d.ts +2 -0
  58. package/lib/bot/bot-test-context.test.d.ts.map +1 -0
  59. package/lib/bot/bot-test-context.test.js +41 -0
  60. package/lib/bot/bot-test-context.test.js.map +1 -0
  61. package/lib/bot/formatters.d.ts +2 -0
  62. package/lib/bot/formatters.d.ts.map +1 -0
  63. package/lib/bot/formatters.js +31 -0
  64. package/lib/bot/formatters.js.map +1 -0
  65. package/lib/bot/specs.d.ts +50 -0
  66. package/lib/bot/specs.d.ts.map +1 -0
  67. package/lib/bot/specs.js +204 -0
  68. package/lib/bot/specs.js.map +1 -0
  69. package/lib/bot/types.d.ts +178 -0
  70. package/lib/bot/types.d.ts.map +1 -0
  71. package/lib/bot/types.js +3 -0
  72. package/lib/bot/types.js.map +1 -0
  73. package/lib/bridge/getAddressWrapper.d.ts +6 -0
  74. package/lib/bridge/getAddressWrapper.d.ts.map +1 -0
  75. package/lib/bridge/getAddressWrapper.js +27 -0
  76. package/lib/bridge/getAddressWrapper.js.map +1 -0
  77. package/lib/bridge/jsHelpers.d.ts +63 -0
  78. package/lib/bridge/jsHelpers.d.ts.map +1 -0
  79. package/lib/bridge/jsHelpers.js +574 -0
  80. package/lib/bridge/jsHelpers.js.map +1 -0
  81. package/lib/cache.d.ts +10 -0
  82. package/lib/cache.d.ts.map +1 -0
  83. package/lib/cache.js +100 -0
  84. package/lib/cache.js.map +1 -0
  85. package/lib/cross.d.ts +42 -0
  86. package/lib/cross.d.ts.map +1 -0
  87. package/lib/cross.js +254 -0
  88. package/lib/cross.js.map +1 -0
  89. package/lib/cross.test.d.ts +2 -0
  90. package/lib/cross.test.d.ts.map +1 -0
  91. package/lib/cross.test.js +99 -0
  92. package/lib/cross.test.js.map +1 -0
  93. package/lib/currencies/BigNumberToLocaleString.d.ts +8 -0
  94. package/lib/currencies/BigNumberToLocaleString.d.ts.map +1 -0
  95. package/lib/currencies/BigNumberToLocaleString.js +65 -0
  96. package/lib/currencies/BigNumberToLocaleString.js.map +1 -0
  97. package/lib/currencies/BigNumberToLocaleString.test.d.ts +2 -0
  98. package/lib/currencies/BigNumberToLocaleString.test.d.ts.map +1 -0
  99. package/lib/currencies/BigNumberToLocaleString.test.js +108 -0
  100. package/lib/currencies/BigNumberToLocaleString.test.js.map +1 -0
  101. package/lib/currencies/CurrencyURIScheme.d.ts +13 -0
  102. package/lib/currencies/CurrencyURIScheme.d.ts.map +1 -0
  103. package/lib/currencies/CurrencyURIScheme.js +124 -0
  104. package/lib/currencies/CurrencyURIScheme.js.map +1 -0
  105. package/lib/currencies/chopCurrencyUnitDecimals.d.ts +3 -0
  106. package/lib/currencies/chopCurrencyUnitDecimals.d.ts.map +1 -0
  107. package/lib/currencies/chopCurrencyUnitDecimals.js +29 -0
  108. package/lib/currencies/chopCurrencyUnitDecimals.js.map +1 -0
  109. package/lib/currencies/formatCurrencyUnit.d.ts +33 -0
  110. package/lib/currencies/formatCurrencyUnit.d.ts.map +1 -0
  111. package/lib/currencies/formatCurrencyUnit.js +126 -0
  112. package/lib/currencies/formatCurrencyUnit.js.map +1 -0
  113. package/lib/currencies/formatShort.d.ts +8 -0
  114. package/lib/currencies/formatShort.d.ts.map +1 -0
  115. package/lib/currencies/formatShort.js +27 -0
  116. package/lib/currencies/formatShort.js.map +1 -0
  117. package/lib/currencies/index.d.ts +13 -0
  118. package/lib/currencies/index.d.ts.map +1 -0
  119. package/lib/currencies/index.js +65 -0
  120. package/lib/currencies/index.js.map +1 -0
  121. package/lib/currencies/localeUtility.d.ts +8 -0
  122. package/lib/currencies/localeUtility.d.ts.map +1 -0
  123. package/lib/currencies/localeUtility.js +49 -0
  124. package/lib/currencies/localeUtility.js.map +1 -0
  125. package/lib/currencies/parseCurrencyUnit.d.ts +4 -0
  126. package/lib/currencies/parseCurrencyUnit.d.ts.map +1 -0
  127. package/lib/currencies/parseCurrencyUnit.js +18 -0
  128. package/lib/currencies/parseCurrencyUnit.js.map +1 -0
  129. package/lib/currencies/sanitizeValueString.d.ts +6 -0
  130. package/lib/currencies/sanitizeValueString.d.ts.map +1 -0
  131. package/lib/currencies/sanitizeValueString.js +56 -0
  132. package/lib/currencies/sanitizeValueString.js.map +1 -0
  133. package/lib/currencies/support.d.ts +8 -0
  134. package/lib/currencies/support.d.ts.map +1 -0
  135. package/lib/currencies/support.js +101 -0
  136. package/lib/currencies/support.js.map +1 -0
  137. package/lib/currencies/valueFromUnit.d.ts +9 -0
  138. package/lib/currencies/valueFromUnit.d.ts.map +1 -0
  139. package/lib/currencies/valueFromUnit.js +14 -0
  140. package/lib/currencies/valueFromUnit.js.map +1 -0
  141. package/lib/derivation.d.ts +232 -0
  142. package/lib/derivation.d.ts.map +1 -0
  143. package/lib/derivation.js +501 -0
  144. package/lib/derivation.js.map +1 -0
  145. package/lib/env.d.ts +30 -0
  146. package/lib/env.d.ts.map +1 -0
  147. package/lib/env.js +773 -0
  148. package/lib/env.js.map +1 -0
  149. package/lib/errors.d.ts +7 -0
  150. package/lib/errors.d.ts.map +1 -0
  151. package/lib/errors.js +7 -0
  152. package/lib/errors.js.map +1 -0
  153. package/lib/errors.test.d.ts +2 -0
  154. package/lib/errors.test.d.ts.map +1 -0
  155. package/lib/errors.test.js +20 -0
  156. package/lib/errors.test.js.map +1 -0
  157. package/lib/mocks/account.d.ts +25 -0
  158. package/lib/mocks/account.d.ts.map +1 -0
  159. package/lib/mocks/account.js +368 -0
  160. package/lib/mocks/account.js.map +1 -0
  161. package/lib/mocks/fixtures/nfts.d.ts +27 -0
  162. package/lib/mocks/fixtures/nfts.d.ts.map +1 -0
  163. package/lib/mocks/fixtures/nfts.js +398 -0
  164. package/lib/mocks/fixtures/nfts.js.map +1 -0
  165. package/lib/mocks/fixtures/nfts.test.d.ts +2 -0
  166. package/lib/mocks/fixtures/nfts.test.d.ts.map +1 -0
  167. package/lib/mocks/fixtures/nfts.test.js +20 -0
  168. package/lib/mocks/fixtures/nfts.test.js.map +1 -0
  169. package/lib/mocks/helpers.d.ts +15 -0
  170. package/lib/mocks/helpers.d.ts.map +1 -0
  171. package/lib/mocks/helpers.js +32 -0
  172. package/lib/mocks/helpers.js.map +1 -0
  173. package/lib/network.d.ts +5 -0
  174. package/lib/network.d.ts.map +1 -0
  175. package/lib/network.js +125 -0
  176. package/lib/network.js.map +1 -0
  177. package/lib/nft/nftId.d.ts +8 -0
  178. package/lib/nft/nftId.d.ts.map +1 -0
  179. package/lib/nft/nftId.js +34 -0
  180. package/lib/nft/nftId.js.map +1 -0
  181. package/lib/operation.d.ts +24 -0
  182. package/lib/operation.d.ts.map +1 -0
  183. package/lib/operation.js +183 -0
  184. package/lib/operation.js.map +1 -0
  185. package/lib/promise.d.ts +21 -0
  186. package/lib/promise.d.ts.map +1 -0
  187. package/lib/promise.js +187 -0
  188. package/lib/promise.js.map +1 -0
  189. package/lib/promise.test.d.ts +2 -0
  190. package/lib/promise.test.d.ts.map +1 -0
  191. package/lib/promise.test.js +72 -0
  192. package/lib/promise.test.js.map +1 -0
  193. package/lib/rangeDates.d.ts +29 -0
  194. package/lib/rangeDates.d.ts.map +1 -0
  195. package/lib/rangeDates.js +94 -0
  196. package/lib/rangeDates.js.map +1 -0
  197. package/lib/rangeDates.test.d.ts +2 -0
  198. package/lib/rangeDates.test.d.ts.map +1 -0
  199. package/lib/rangeDates.test.js +51 -0
  200. package/lib/rangeDates.test.js.map +1 -0
  201. package/lib/test-helpers/staticTime.d.ts +2 -0
  202. package/lib/test-helpers/staticTime.d.ts.map +1 -0
  203. package/lib/test-helpers/staticTime.js +10 -0
  204. package/lib/test-helpers/staticTime.js.map +1 -0
  205. package/lib/transaction/common.d.ts +26 -0
  206. package/lib/transaction/common.d.ts.map +1 -0
  207. package/lib/transaction/common.js +123 -0
  208. package/lib/transaction/common.js.map +1 -0
  209. package/lib-es/account/accountId.d.ts +16 -0
  210. package/lib-es/account/accountId.d.ts.map +1 -0
  211. package/lib-es/account/accountId.js +74 -0
  212. package/lib-es/account/accountId.js.map +1 -0
  213. package/lib-es/account/accountName.d.ts +14 -0
  214. package/lib-es/account/accountName.d.ts.map +1 -0
  215. package/lib-es/account/accountName.js +12 -0
  216. package/lib-es/account/accountName.js.map +1 -0
  217. package/lib-es/account/addAccounts.d.ts +35 -0
  218. package/lib-es/account/addAccounts.d.ts.map +1 -0
  219. package/lib-es/account/addAccounts.js +200 -0
  220. package/lib-es/account/addAccounts.js.map +1 -0
  221. package/lib-es/account/balanceHistoryCache.d.ts +25 -0
  222. package/lib-es/account/balanceHistoryCache.d.ts.map +1 -0
  223. package/lib-es/account/balanceHistoryCache.js +109 -0
  224. package/lib-es/account/balanceHistoryCache.js.map +1 -0
  225. package/lib-es/account/groupOperations.d.ts +17 -0
  226. package/lib-es/account/groupOperations.d.ts.map +1 -0
  227. package/lib-es/account/groupOperations.js +122 -0
  228. package/lib-es/account/groupOperations.js.map +1 -0
  229. package/lib-es/account/helpers.d.ts +44 -0
  230. package/lib-es/account/helpers.d.ts.map +1 -0
  231. package/lib-es/account/helpers.js +303 -0
  232. package/lib-es/account/helpers.js.map +1 -0
  233. package/lib-es/account/helpers.test.d.ts +2 -0
  234. package/lib-es/account/helpers.test.d.ts.map +1 -0
  235. package/lib-es/account/helpers.test.js +361 -0
  236. package/lib-es/account/helpers.test.js.map +1 -0
  237. package/lib-es/account/index.d.ts +11 -0
  238. package/lib-es/account/index.d.ts.map +1 -0
  239. package/lib-es/account/index.js +11 -0
  240. package/lib-es/account/index.js.map +1 -0
  241. package/lib-es/account/ordering.d.ts +10 -0
  242. package/lib-es/account/ordering.d.ts.map +1 -0
  243. package/lib-es/account/ordering.js +103 -0
  244. package/lib-es/account/ordering.js.map +1 -0
  245. package/lib-es/account/pending.d.ts +33 -0
  246. package/lib-es/account/pending.d.ts.map +1 -0
  247. package/lib-es/account/pending.js +59 -0
  248. package/lib-es/account/pending.js.map +1 -0
  249. package/lib-es/account/serialization.d.ts +6 -0
  250. package/lib-es/account/serialization.d.ts.map +1 -0
  251. package/lib-es/account/serialization.js +112 -0
  252. package/lib-es/account/serialization.js.map +1 -0
  253. package/lib-es/account/support.d.ts +9 -0
  254. package/lib-es/account/support.d.ts.map +1 -0
  255. package/lib-es/account/support.js +64 -0
  256. package/lib-es/account/support.js.map +1 -0
  257. package/lib-es/account.test.d.ts +2 -0
  258. package/lib-es/account.test.d.ts.map +1 -0
  259. package/lib-es/account.test.js +252 -0
  260. package/lib-es/account.test.js.map +1 -0
  261. package/lib-es/bot/bot-test-context.d.ts +3 -0
  262. package/lib-es/bot/bot-test-context.d.ts.map +1 -0
  263. package/lib-es/bot/bot-test-context.js +21 -0
  264. package/lib-es/bot/bot-test-context.js.map +1 -0
  265. package/lib-es/bot/bot-test-context.test.d.ts +2 -0
  266. package/lib-es/bot/bot-test-context.test.d.ts.map +1 -0
  267. package/lib-es/bot/bot-test-context.test.js +39 -0
  268. package/lib-es/bot/bot-test-context.test.js.map +1 -0
  269. package/lib-es/bot/formatters.d.ts +2 -0
  270. package/lib-es/bot/formatters.d.ts.map +1 -0
  271. package/lib-es/bot/formatters.js +27 -0
  272. package/lib-es/bot/formatters.js.map +1 -0
  273. package/lib-es/bot/specs.d.ts +50 -0
  274. package/lib-es/bot/specs.d.ts.map +1 -0
  275. package/lib-es/bot/specs.js +193 -0
  276. package/lib-es/bot/specs.js.map +1 -0
  277. package/lib-es/bot/types.d.ts +178 -0
  278. package/lib-es/bot/types.d.ts.map +1 -0
  279. package/lib-es/bot/types.js +2 -0
  280. package/lib-es/bot/types.js.map +1 -0
  281. package/lib-es/bridge/getAddressWrapper.d.ts +6 -0
  282. package/lib-es/bridge/getAddressWrapper.d.ts.map +1 -0
  283. package/lib-es/bridge/getAddressWrapper.js +25 -0
  284. package/lib-es/bridge/getAddressWrapper.js.map +1 -0
  285. package/lib-es/bridge/jsHelpers.d.ts +63 -0
  286. package/lib-es/bridge/jsHelpers.d.ts.map +1 -0
  287. package/lib-es/bridge/jsHelpers.js +562 -0
  288. package/lib-es/bridge/jsHelpers.js.map +1 -0
  289. package/lib-es/cache.d.ts +10 -0
  290. package/lib-es/cache.d.ts.map +1 -0
  291. package/lib-es/cache.js +93 -0
  292. package/lib-es/cache.js.map +1 -0
  293. package/lib-es/cross.d.ts +42 -0
  294. package/lib-es/cross.d.ts.map +1 -0
  295. package/lib-es/cross.js +244 -0
  296. package/lib-es/cross.js.map +1 -0
  297. package/lib-es/cross.test.d.ts +2 -0
  298. package/lib-es/cross.test.d.ts.map +1 -0
  299. package/lib-es/cross.test.js +97 -0
  300. package/lib-es/cross.test.js.map +1 -0
  301. package/lib-es/currencies/BigNumberToLocaleString.d.ts +8 -0
  302. package/lib-es/currencies/BigNumberToLocaleString.d.ts.map +1 -0
  303. package/lib-es/currencies/BigNumberToLocaleString.js +61 -0
  304. package/lib-es/currencies/BigNumberToLocaleString.js.map +1 -0
  305. package/lib-es/currencies/BigNumberToLocaleString.test.d.ts +2 -0
  306. package/lib-es/currencies/BigNumberToLocaleString.test.d.ts.map +1 -0
  307. package/lib-es/currencies/BigNumberToLocaleString.test.js +106 -0
  308. package/lib-es/currencies/BigNumberToLocaleString.test.js.map +1 -0
  309. package/lib-es/currencies/CurrencyURIScheme.d.ts +13 -0
  310. package/lib-es/currencies/CurrencyURIScheme.d.ts.map +1 -0
  311. package/lib-es/currencies/CurrencyURIScheme.js +116 -0
  312. package/lib-es/currencies/CurrencyURIScheme.js.map +1 -0
  313. package/lib-es/currencies/chopCurrencyUnitDecimals.d.ts +3 -0
  314. package/lib-es/currencies/chopCurrencyUnitDecimals.d.ts.map +1 -0
  315. package/lib-es/currencies/chopCurrencyUnitDecimals.js +25 -0
  316. package/lib-es/currencies/chopCurrencyUnitDecimals.js.map +1 -0
  317. package/lib-es/currencies/formatCurrencyUnit.d.ts +33 -0
  318. package/lib-es/currencies/formatCurrencyUnit.d.ts.map +1 -0
  319. package/lib-es/currencies/formatCurrencyUnit.js +121 -0
  320. package/lib-es/currencies/formatCurrencyUnit.js.map +1 -0
  321. package/lib-es/currencies/formatShort.d.ts +8 -0
  322. package/lib-es/currencies/formatShort.d.ts.map +1 -0
  323. package/lib-es/currencies/formatShort.js +20 -0
  324. package/lib-es/currencies/formatShort.js.map +1 -0
  325. package/lib-es/currencies/index.d.ts +13 -0
  326. package/lib-es/currencies/index.d.ts.map +1 -0
  327. package/lib-es/currencies/index.js +16 -0
  328. package/lib-es/currencies/index.js.map +1 -0
  329. package/lib-es/currencies/localeUtility.d.ts +8 -0
  330. package/lib-es/currencies/localeUtility.d.ts.map +1 -0
  331. package/lib-es/currencies/localeUtility.js +43 -0
  332. package/lib-es/currencies/localeUtility.js.map +1 -0
  333. package/lib-es/currencies/parseCurrencyUnit.d.ts +4 -0
  334. package/lib-es/currencies/parseCurrencyUnit.d.ts.map +1 -0
  335. package/lib-es/currencies/parseCurrencyUnit.js +14 -0
  336. package/lib-es/currencies/parseCurrencyUnit.js.map +1 -0
  337. package/lib-es/currencies/sanitizeValueString.d.ts +6 -0
  338. package/lib-es/currencies/sanitizeValueString.d.ts.map +1 -0
  339. package/lib-es/currencies/sanitizeValueString.js +52 -0
  340. package/lib-es/currencies/sanitizeValueString.js.map +1 -0
  341. package/lib-es/currencies/support.d.ts +8 -0
  342. package/lib-es/currencies/support.d.ts.map +1 -0
  343. package/lib-es/currencies/support.js +92 -0
  344. package/lib-es/currencies/support.js.map +1 -0
  345. package/lib-es/currencies/valueFromUnit.d.ts +9 -0
  346. package/lib-es/currencies/valueFromUnit.d.ts.map +1 -0
  347. package/lib-es/currencies/valueFromUnit.js +10 -0
  348. package/lib-es/currencies/valueFromUnit.js.map +1 -0
  349. package/lib-es/derivation.d.ts +232 -0
  350. package/lib-es/derivation.d.ts.map +1 -0
  351. package/lib-es/derivation.js +473 -0
  352. package/lib-es/derivation.js.map +1 -0
  353. package/lib-es/env.d.ts +30 -0
  354. package/lib-es/env.d.ts.map +1 -0
  355. package/lib-es/env.js +758 -0
  356. package/lib-es/env.js.map +1 -0
  357. package/lib-es/errors.d.ts +7 -0
  358. package/lib-es/errors.d.ts.map +1 -0
  359. package/lib-es/errors.js +4 -0
  360. package/lib-es/errors.js.map +1 -0
  361. package/lib-es/errors.test.d.ts +2 -0
  362. package/lib-es/errors.test.d.ts.map +1 -0
  363. package/lib-es/errors.test.js +18 -0
  364. package/lib-es/errors.test.js.map +1 -0
  365. package/lib-es/mocks/account.d.ts +25 -0
  366. package/lib-es/mocks/account.d.ts.map +1 -0
  367. package/lib-es/mocks/account.js +358 -0
  368. package/lib-es/mocks/account.js.map +1 -0
  369. package/lib-es/mocks/fixtures/nfts.d.ts +27 -0
  370. package/lib-es/mocks/fixtures/nfts.d.ts.map +1 -0
  371. package/lib-es/mocks/fixtures/nfts.js +390 -0
  372. package/lib-es/mocks/fixtures/nfts.js.map +1 -0
  373. package/lib-es/mocks/fixtures/nfts.test.d.ts +2 -0
  374. package/lib-es/mocks/fixtures/nfts.test.d.ts.map +1 -0
  375. package/lib-es/mocks/fixtures/nfts.test.js +18 -0
  376. package/lib-es/mocks/fixtures/nfts.test.js.map +1 -0
  377. package/lib-es/mocks/helpers.d.ts +15 -0
  378. package/lib-es/mocks/helpers.d.ts.map +1 -0
  379. package/lib-es/mocks/helpers.js +26 -0
  380. package/lib-es/mocks/helpers.js.map +1 -0
  381. package/lib-es/network.d.ts +5 -0
  382. package/lib-es/network.d.ts.map +1 -0
  383. package/lib-es/network.js +118 -0
  384. package/lib-es/network.js.map +1 -0
  385. package/lib-es/nft/nftId.d.ts +8 -0
  386. package/lib-es/nft/nftId.d.ts.map +1 -0
  387. package/lib-es/nft/nftId.js +29 -0
  388. package/lib-es/nft/nftId.js.map +1 -0
  389. package/lib-es/operation.d.ts +24 -0
  390. package/lib-es/operation.d.ts.map +1 -0
  391. package/lib-es/operation.js +168 -0
  392. package/lib-es/operation.js.map +1 -0
  393. package/lib-es/promise.d.ts +21 -0
  394. package/lib-es/promise.d.ts.map +1 -0
  395. package/lib-es/promise.js +179 -0
  396. package/lib-es/promise.js.map +1 -0
  397. package/lib-es/promise.test.d.ts +2 -0
  398. package/lib-es/promise.test.d.ts.map +1 -0
  399. package/lib-es/promise.test.js +70 -0
  400. package/lib-es/promise.test.js.map +1 -0
  401. package/lib-es/rangeDates.d.ts +29 -0
  402. package/lib-es/rangeDates.d.ts.map +1 -0
  403. package/lib-es/rangeDates.js +84 -0
  404. package/lib-es/rangeDates.js.map +1 -0
  405. package/lib-es/rangeDates.test.d.ts +2 -0
  406. package/lib-es/rangeDates.test.d.ts.map +1 -0
  407. package/lib-es/rangeDates.test.js +49 -0
  408. package/lib-es/rangeDates.test.js.map +1 -0
  409. package/lib-es/test-helpers/staticTime.d.ts +2 -0
  410. package/lib-es/test-helpers/staticTime.d.ts.map +1 -0
  411. package/lib-es/test-helpers/staticTime.js +5 -0
  412. package/lib-es/test-helpers/staticTime.js.map +1 -0
  413. package/lib-es/transaction/common.d.ts +26 -0
  414. package/lib-es/transaction/common.d.ts.map +1 -0
  415. package/lib-es/transaction/common.js +115 -0
  416. package/lib-es/transaction/common.js.map +1 -0
  417. package/package.json +113 -0
  418. package/src/__snapshots__/account.test.ts.snap +2065 -0
  419. package/src/__snapshots__/cross.test.ts.snap +57 -0
  420. package/src/account/accountId.ts +93 -0
  421. package/src/account/accountName.ts +25 -0
  422. package/src/account/addAccounts.ts +236 -0
  423. package/src/account/balanceHistoryCache.ts +146 -0
  424. package/src/account/groupOperations.ts +164 -0
  425. package/src/account/helpers.test.ts +441 -0
  426. package/src/account/helpers.ts +380 -0
  427. package/src/account/index.ts +10 -0
  428. package/src/account/ordering.ts +109 -0
  429. package/src/account/pending.ts +66 -0
  430. package/src/account/serialization.ts +189 -0
  431. package/src/account/support.ts +96 -0
  432. package/src/account.test.ts +237 -0
  433. package/src/bot/bot-test-context.test.ts +37 -0
  434. package/src/bot/bot-test-context.ts +24 -0
  435. package/src/bot/formatters.ts +22 -0
  436. package/src/bot/specs.ts +275 -0
  437. package/src/bot/types.ts +224 -0
  438. package/src/bridge/getAddressWrapper.ts +40 -0
  439. package/src/bridge/jsHelpers.ts +645 -0
  440. package/src/cache.ts +65 -0
  441. package/src/cross.test.ts +112 -0
  442. package/src/cross.ts +366 -0
  443. package/src/currencies/BigNumberToLocaleString.test.ts +155 -0
  444. package/src/currencies/BigNumberToLocaleString.ts +80 -0
  445. package/src/currencies/CurrencyURIScheme.ts +114 -0
  446. package/src/currencies/chopCurrencyUnitDecimals.ts +34 -0
  447. package/src/currencies/formatCurrencyUnit.ts +167 -0
  448. package/src/currencies/formatShort.ts +24 -0
  449. package/src/currencies/index.ts +78 -0
  450. package/src/currencies/localeUtility.ts +50 -0
  451. package/src/currencies/parseCurrencyUnit.ts +16 -0
  452. package/src/currencies/sanitizeValueString.ts +58 -0
  453. package/src/currencies/support.ts +107 -0
  454. package/src/currencies/valueFromUnit.ts +10 -0
  455. package/src/derivation.ts +595 -0
  456. package/src/env.ts +780 -0
  457. package/src/errors.test.ts +21 -0
  458. package/src/errors.ts +9 -0
  459. package/src/mocks/account.ts +476 -0
  460. package/src/mocks/fixtures/nfts.test.ts +25 -0
  461. package/src/mocks/fixtures/nfts.ts +432 -0
  462. package/src/mocks/helpers.ts +38 -0
  463. package/src/network.ts +135 -0
  464. package/src/nft/nftId.ts +26 -0
  465. package/src/operation.ts +212 -0
  466. package/src/promise.test.ts +20 -0
  467. package/src/promise.ts +101 -0
  468. package/src/rangeDates.test.ts +66 -0
  469. package/src/rangeDates.ts +96 -0
  470. package/src/test-helpers/staticTime.ts +4 -0
  471. package/src/transaction/common.ts +157 -0
@@ -0,0 +1,164 @@
1
+ import { flattenAccounts } from "./helpers";
2
+ import { flattenOperationWithInternalsAndNfts } from "../operation";
3
+ import type {
4
+ AccountLike,
5
+ AccountLikeArray,
6
+ DailyOperations,
7
+ Operation,
8
+ } from "@ledgerhq/types-live";
9
+
10
+ function startOfDay(t: Date) {
11
+ return new Date(t.getFullYear(), t.getMonth(), t.getDate());
12
+ }
13
+
14
+ const emptyDailyOperations = {
15
+ sections: [],
16
+ completed: true,
17
+ };
18
+ type GroupOpsByDayOpts = {
19
+ count: number;
20
+ withSubAccounts?: boolean;
21
+ filterOperation?: (arg0: Operation, arg1: AccountLike) => boolean;
22
+ };
23
+
24
+ const hasStableOperation = (account: AccountLike, hash: string) =>
25
+ account.operations.some((op) => op.hash === hash);
26
+
27
+ /**
28
+ * @memberof account
29
+ */
30
+ export function groupAccountsOperationsByDay(
31
+ inputAccounts: AccountLikeArray,
32
+ { count, withSubAccounts, filterOperation }: GroupOpsByDayOpts
33
+ ): DailyOperations {
34
+ const accounts = withSubAccounts
35
+ ? flattenAccounts(inputAccounts)
36
+ : inputAccounts;
37
+ // Track indexes of account.operations[] for each account
38
+ const indexes: number[] = Array(accounts.length).fill(0);
39
+ // Track indexes of account.pendingOperations[] for each account
40
+ const indexesPending: number[] = Array(accounts.length).fill(0);
41
+
42
+ // Returns the next most recent operation from the account with current indexes
43
+ function getNext():
44
+ | {
45
+ ops: Operation[];
46
+ date: Date;
47
+ }
48
+ | null
49
+ | undefined {
50
+ let bestOp: Operation | null | undefined;
51
+ let bestOpInfo = {
52
+ accountI: 0,
53
+ fromPending: false,
54
+ };
55
+
56
+ for (let i = 0; i < accounts.length; i++) {
57
+ const account = accounts[i];
58
+ // look in operations
59
+ let op = account.operations[indexes[i]];
60
+
61
+ if (filterOperation) {
62
+ // skip operation we want to filter out
63
+ while (op && !filterOperation(op, account)) {
64
+ op = account.operations[++indexes[i]];
65
+ }
66
+ }
67
+
68
+ if (op && (!bestOp || op.date > bestOp.date)) {
69
+ bestOp = op;
70
+ bestOpInfo = {
71
+ accountI: i,
72
+ fromPending: false,
73
+ };
74
+ }
75
+
76
+ // look in pending operations
77
+ let opP = account.pendingOperations[indexesPending[i]];
78
+
79
+ while (
80
+ opP && // skip all pending operations that are already in operations
81
+ (hasStableOperation(account, opP.hash) || // but also if we want to filter it
82
+ (filterOperation && !filterOperation(opP, account)))
83
+ ) {
84
+ opP = account.pendingOperations[++indexesPending[i]];
85
+ }
86
+
87
+ if (opP && (!bestOp || opP.date > bestOp.date)) {
88
+ bestOp = opP;
89
+ bestOpInfo = {
90
+ accountI: i,
91
+ fromPending: true,
92
+ };
93
+ }
94
+ }
95
+
96
+ if (bestOp) {
97
+ if (bestOpInfo.fromPending) {
98
+ indexesPending[bestOpInfo.accountI]++;
99
+ } else {
100
+ indexes[bestOpInfo.accountI]++;
101
+ }
102
+
103
+ const ops = flattenOperationWithInternalsAndNfts(bestOp);
104
+ return {
105
+ ops,
106
+ date: bestOp.date,
107
+ };
108
+ }
109
+ }
110
+
111
+ let next = getNext();
112
+ if (!next) return emptyDailyOperations;
113
+ const sections: Array<{
114
+ day: Date;
115
+ data: Operation[];
116
+ }> = [];
117
+ let totalOperations = 0;
118
+ let day = startOfDay(next.date);
119
+ let data: Operation[] = [];
120
+
121
+ while (totalOperations < count && next) {
122
+ if (next.date < day) {
123
+ if (data.length > 0) {
124
+ const slicedData = data.slice(0, count - totalOperations);
125
+ sections.push({
126
+ day,
127
+ data: slicedData,
128
+ });
129
+ totalOperations += slicedData.length;
130
+ }
131
+
132
+ day = startOfDay(next.date);
133
+ data = next.ops;
134
+ } else {
135
+ data = data.concat(next.ops);
136
+ }
137
+
138
+ next = getNext();
139
+ }
140
+
141
+ if (data.length > 0 && totalOperations < count) {
142
+ sections.push({
143
+ day,
144
+ data,
145
+ });
146
+ }
147
+
148
+ return {
149
+ sections,
150
+ completed: !next,
151
+ };
152
+ }
153
+
154
+ /**
155
+ * Return a list of `{count}` operations grouped by day.
156
+ * @memberof account
157
+ */
158
+ export function groupAccountOperationsByDay(
159
+ account: AccountLike,
160
+ arg: GroupOpsByDayOpts
161
+ ): DailyOperations {
162
+ const accounts: AccountLike[] = [account];
163
+ return groupAccountsOperationsByDay(accounts, arg);
164
+ }
@@ -0,0 +1,441 @@
1
+ import {
2
+ CryptoCurrency,
3
+ TokenCurrency,
4
+ Unit,
5
+ } from "@ledgerhq/types-cryptoassets";
6
+ import {
7
+ Account,
8
+ ChildAccount,
9
+ Operation,
10
+ SubAccount,
11
+ TokenAccount,
12
+ } from "@ledgerhq/types-live";
13
+ import BigNumber from "bignumber.js";
14
+ import {
15
+ areAllOperationsLoaded,
16
+ emptyHistoryCache,
17
+ getAccountCurrency,
18
+ getAccountName,
19
+ getAccountSpendableBalance,
20
+ getAccountUnit,
21
+ } from ".";
22
+ import {
23
+ isAccountEmpty,
24
+ isAccountBalanceSignificant,
25
+ clearAccount,
26
+ } from "./helpers";
27
+
28
+ const mockAccount = {} as Account;
29
+ const childAccount = {
30
+ ...mockAccount,
31
+ type: "ChildAccount",
32
+ parentId: "sampleId",
33
+ address: "sampleAddress",
34
+ } as ChildAccount;
35
+ const tokenAccount = {
36
+ ...mockAccount,
37
+ type: "TokenAccount",
38
+ token: {} as TokenCurrency,
39
+ parentId: "sampleId",
40
+ } as TokenAccount;
41
+
42
+ describe(getAccountCurrency.name, () => {
43
+ describe("given an Account", () => {
44
+ beforeEach(() => {
45
+ mockAccount.type = "Account";
46
+ });
47
+ it("should return the currency", () => {
48
+ const sampleCurrency = { family: "bitcoin" } as CryptoCurrency;
49
+ mockAccount.currency = sampleCurrency;
50
+ expect(getAccountCurrency(mockAccount)).toEqual(sampleCurrency);
51
+ });
52
+ });
53
+
54
+ describe("given a ChildAccount", () => {
55
+ it("should return the currency", () => {
56
+ const sampleCurrency = { family: "bitcoin" } as CryptoCurrency;
57
+ childAccount.currency = sampleCurrency;
58
+ expect(getAccountCurrency(childAccount)).toEqual(sampleCurrency);
59
+ });
60
+ });
61
+
62
+ describe("given a TokenAccount", () => {
63
+ it("should return the token currency", () => {
64
+ const sampleToken = { id: "tokenId" } as TokenCurrency;
65
+ tokenAccount.token = sampleToken;
66
+ expect(getAccountCurrency(tokenAccount)).toEqual(sampleToken);
67
+ });
68
+ });
69
+
70
+ describe("given an unknown type Account", () => {
71
+ beforeEach(() => {
72
+ (mockAccount as any).type = "DefinitelyNotAStandardAccount";
73
+ });
74
+
75
+ it("should throw an error", () => {
76
+ expect(() => getAccountCurrency(mockAccount)).toThrow(Error);
77
+ });
78
+
79
+ it("should display the account type in the error message", () => {
80
+ expect.assertions(1);
81
+ try {
82
+ getAccountCurrency(mockAccount);
83
+ } catch (e: unknown) {
84
+ expect((e as Error).message.includes(mockAccount.type)).toEqual(true);
85
+ }
86
+ });
87
+ });
88
+ });
89
+
90
+ describe(getAccountUnit.name, () => {
91
+ describe("given an Account", () => {
92
+ beforeEach(() => {
93
+ mockAccount.type = "Account";
94
+ });
95
+ it("should return the unit", () => {
96
+ const sampleUnit = { name: "unit" } as Unit;
97
+ mockAccount.unit = sampleUnit;
98
+ expect(getAccountUnit(mockAccount)).toEqual(sampleUnit);
99
+ });
100
+ });
101
+
102
+ describe("given a ChildAccount", () => {
103
+ it("should return the currency unit", () => {
104
+ const sampleUnit = { name: "unit" } as Unit;
105
+ childAccount.currency = { units: [sampleUnit] } as CryptoCurrency;
106
+ expect(getAccountUnit(childAccount)).toEqual(sampleUnit);
107
+ });
108
+ });
109
+
110
+ describe("given a TokenAccount", () => {
111
+ it("should return the token unit", () => {
112
+ const sampleUnit = { name: "unit" } as Unit;
113
+ tokenAccount.token = { units: [sampleUnit] } as TokenCurrency;
114
+ expect(getAccountUnit(tokenAccount)).toEqual(sampleUnit);
115
+ });
116
+ });
117
+
118
+ describe("given an unknown type Account", () => {
119
+ beforeEach(() => {
120
+ (mockAccount as any).type = "DefinitelyNotAStandardAccount";
121
+ });
122
+
123
+ it("should throw an error", () => {
124
+ expect(() => getAccountUnit(mockAccount)).toThrow(Error);
125
+ });
126
+
127
+ it("should display the account type in the error message", () => {
128
+ expect.assertions(1);
129
+ try {
130
+ getAccountUnit(mockAccount);
131
+ } catch (e: unknown) {
132
+ expect((e as Error).message.includes(mockAccount.type)).toEqual(true);
133
+ }
134
+ });
135
+ });
136
+ });
137
+
138
+ describe(getAccountName.name, () => {
139
+ describe("given an Account", () => {
140
+ beforeEach(() => {
141
+ mockAccount.type = "Account";
142
+ });
143
+ it("should return the account name", () => {
144
+ const sampleAccountName = "SampleAccountName";
145
+ mockAccount.name = sampleAccountName;
146
+ expect(getAccountName(mockAccount)).toEqual(sampleAccountName);
147
+ });
148
+ });
149
+
150
+ describe("given a ChildAccount", () => {
151
+ it("should return the account name", () => {
152
+ const sampleAccountName = "SampleAccountName";
153
+ childAccount.name = sampleAccountName;
154
+ expect(getAccountName(childAccount)).toEqual(sampleAccountName);
155
+ });
156
+ });
157
+
158
+ describe("given a TokenAccount", () => {
159
+ it("should return the token account name", () => {
160
+ const sampleAccountName = "SampleAccountName";
161
+ tokenAccount.token = { name: sampleAccountName } as TokenCurrency;
162
+ expect(getAccountName(tokenAccount)).toEqual(sampleAccountName);
163
+ });
164
+ });
165
+
166
+ describe("given an unknown type Account", () => {
167
+ beforeEach(() => {
168
+ (mockAccount as any).type = "DefinitelyNotAStandardAccount";
169
+ });
170
+
171
+ it("should throw an error", () => {
172
+ expect(() => getAccountName(mockAccount)).toThrow(Error);
173
+ });
174
+
175
+ it("should display the account type in the error message", () => {
176
+ expect.assertions(1);
177
+ try {
178
+ getAccountName(mockAccount);
179
+ } catch (e: unknown) {
180
+ expect((e as Error).message.includes(mockAccount.type)).toEqual(true);
181
+ }
182
+ });
183
+ });
184
+ });
185
+
186
+ describe(getAccountSpendableBalance.name, () => {
187
+ describe("given an Account", () => {
188
+ beforeEach(() => {
189
+ mockAccount.type = "Account";
190
+ });
191
+ it("should return the account spendable balance", () => {
192
+ const sampleAccountBalance = new BigNumber(10);
193
+ mockAccount.spendableBalance = sampleAccountBalance;
194
+ expect(getAccountSpendableBalance(mockAccount)).toEqual(
195
+ sampleAccountBalance
196
+ );
197
+ });
198
+ });
199
+
200
+ describe("given a ChildAccount", () => {
201
+ it("should return the account balance", () => {
202
+ const sampleAccountBalance = new BigNumber(10);
203
+ childAccount.balance = sampleAccountBalance;
204
+ expect(getAccountSpendableBalance(childAccount)).toEqual(
205
+ sampleAccountBalance
206
+ );
207
+ });
208
+ });
209
+
210
+ describe("given a TokenAccount", () => {
211
+ it("should return the token account spendable balance", () => {
212
+ const sampleAccountBalance = new BigNumber(10);
213
+ tokenAccount.spendableBalance = sampleAccountBalance;
214
+ expect(getAccountSpendableBalance(tokenAccount)).toEqual(
215
+ sampleAccountBalance
216
+ );
217
+ });
218
+ });
219
+
220
+ describe("given an unknown type Account", () => {
221
+ beforeEach(() => {
222
+ (mockAccount as any).type = "DefinitelyNotAStandardAccount";
223
+ });
224
+
225
+ it("should throw an error", () => {
226
+ expect(() => getAccountSpendableBalance(mockAccount)).toThrow(Error);
227
+ });
228
+
229
+ it("should display the account type in the error message", () => {
230
+ expect.assertions(1);
231
+ try {
232
+ getAccountSpendableBalance(mockAccount);
233
+ } catch (e: unknown) {
234
+ expect((e as Error).message.includes(mockAccount.type)).toEqual(true);
235
+ }
236
+ });
237
+ });
238
+ });
239
+
240
+ describe(isAccountEmpty.name, () => {
241
+ describe("given an account", () => {
242
+ beforeEach(() => {
243
+ mockAccount.type = "Account";
244
+ mockAccount.currency = { family: "ethereum" } as CryptoCurrency;
245
+ });
246
+ describe("when account has no subaccounts", () => {
247
+ beforeEach(() => {
248
+ mockAccount.subAccounts = [];
249
+ });
250
+
251
+ describe("and balance is zero", () => {
252
+ beforeEach(() => {
253
+ mockAccount.balance = new BigNumber(0);
254
+ });
255
+ it("should return true if operationsCount is 0", () => {
256
+ mockAccount.operationsCount = 0;
257
+ expect(isAccountEmpty(mockAccount)).toEqual(true);
258
+ });
259
+ it("should return false if operationsCount is higher than 0", () => {
260
+ mockAccount.operationsCount = 1;
261
+ expect(isAccountEmpty(mockAccount)).toEqual(false);
262
+ });
263
+ });
264
+
265
+ describe("and balance is higher than 0", () => {
266
+ beforeEach(() => {
267
+ mockAccount.balance = new BigNumber(42);
268
+ });
269
+ it("should return false if operationsCount is 0", () => {
270
+ mockAccount.operationsCount = 0;
271
+ expect(isAccountEmpty(mockAccount)).toEqual(false);
272
+ });
273
+ it("should return false if operationsCount is higher than 0", () => {
274
+ mockAccount.operationsCount = 1;
275
+ expect(isAccountEmpty(mockAccount)).toEqual(false);
276
+ });
277
+ });
278
+ });
279
+ describe("when account has subaccounts", () => {
280
+ beforeEach(() => {
281
+ mockAccount.subAccounts = [{} as SubAccount];
282
+ });
283
+
284
+ it("should return false", () => {
285
+ expect(isAccountEmpty(mockAccount)).toEqual(false);
286
+ });
287
+ });
288
+ });
289
+ });
290
+
291
+ describe(areAllOperationsLoaded.name, () => {
292
+ describe("given an account with subAccounts", () => {
293
+ beforeEach(() => {
294
+ mockAccount.type = "Account";
295
+ mockAccount.operations = [];
296
+ mockAccount.operationsCount = 0;
297
+ mockAccount.subAccounts = [
298
+ {
299
+ operations: [],
300
+ operationsCount: 0,
301
+ },
302
+ {
303
+ operations: [{} as Operation],
304
+ operationsCount: 1,
305
+ },
306
+ ] as SubAccount[];
307
+ });
308
+ describe("when sub account operation aren't loaded", () => {
309
+ beforeEach(() => {
310
+ (mockAccount.subAccounts as SubAccount[])[1].operations = [];
311
+ });
312
+ it("should return false", () => {
313
+ expect(areAllOperationsLoaded(mockAccount)).toEqual(false);
314
+ });
315
+ });
316
+
317
+ describe("when sub account operation are loaded", () => {
318
+ it("should return true", () => {
319
+ expect(areAllOperationsLoaded(mockAccount)).toEqual(true);
320
+ });
321
+ });
322
+ });
323
+ describe("given an account without subAccounts", () => {
324
+ describe("when operations count is different from operations length", () => {
325
+ beforeEach(() => {
326
+ childAccount.operationsCount = 2;
327
+ childAccount.operations = [{} as Operation];
328
+ });
329
+ it("should return false", () => {
330
+ expect(areAllOperationsLoaded(childAccount)).toEqual(false);
331
+ });
332
+ });
333
+
334
+ describe("when operations count is same as operations length", () => {
335
+ beforeEach(() => {
336
+ childAccount.operationsCount = 1;
337
+ childAccount.operations = [{} as Operation];
338
+ });
339
+ it("should return true", () => {
340
+ expect(areAllOperationsLoaded(childAccount)).toEqual(true);
341
+ });
342
+ });
343
+ });
344
+ });
345
+
346
+ describe(isAccountBalanceSignificant.name, () => {
347
+ describe("when balance is low", () => {
348
+ beforeEach(() => {
349
+ mockAccount.balance = new BigNumber(10);
350
+ });
351
+ it("should return false", () => {
352
+ expect(isAccountBalanceSignificant(mockAccount)).toEqual(false);
353
+ });
354
+ });
355
+ describe("when balance is high", () => {
356
+ beforeEach(() => {
357
+ mockAccount.balance = new BigNumber(101);
358
+ });
359
+ it("should return true", () => {
360
+ expect(isAccountBalanceSignificant(mockAccount)).toEqual(true);
361
+ });
362
+ });
363
+ });
364
+
365
+ describe(clearAccount.name, () => {
366
+ describe("given a TokenAccount", () => {
367
+ const tokenAccount = {
368
+ ...mockAccount,
369
+ token: {} as TokenCurrency,
370
+ parentId: "sampleId",
371
+ type: "TokenAccount",
372
+ } as TokenAccount;
373
+
374
+ it("should clear operations", () => {
375
+ const clearedAccount = clearAccount(tokenAccount);
376
+ expect(clearedAccount.operations.length).toEqual(0);
377
+ expect(clearedAccount.pendingOperations.length).toEqual(0);
378
+ });
379
+
380
+ it("should clear balanceHistory", () => {
381
+ const clearedAccount = clearAccount(tokenAccount);
382
+ expect(clearedAccount.balanceHistoryCache).toEqual(emptyHistoryCache);
383
+ });
384
+ });
385
+
386
+ describe("given a ChildAccount", () => {
387
+ const childAccount = {
388
+ ...mockAccount,
389
+ type: "ChildAccount",
390
+ parentId: "sampleId",
391
+ address: "sampleAddress",
392
+ } as ChildAccount;
393
+
394
+ it("should clear operations", () => {
395
+ const clearedAccount = clearAccount(childAccount);
396
+ expect(clearedAccount.operations.length).toEqual(0);
397
+ expect(clearedAccount.pendingOperations.length).toEqual(0);
398
+ });
399
+
400
+ it("should clear balanceHistory", () => {
401
+ const clearedAccount = clearAccount(childAccount);
402
+ expect(clearedAccount.balanceHistoryCache).toEqual(emptyHistoryCache);
403
+ });
404
+ });
405
+
406
+ describe("given an Account", () => {
407
+ const ethereumCurrency = {
408
+ family: "ethereum",
409
+ } as CryptoCurrency;
410
+ const withSubAccounts = {
411
+ ...mockAccount,
412
+ subAccounts: [
413
+ {
414
+ currency: ethereumCurrency,
415
+ } as SubAccount,
416
+ ],
417
+ currency: ethereumCurrency,
418
+ };
419
+ it("should clear operations", () => {
420
+ const clearedAccount = clearAccount(withSubAccounts);
421
+ expect(clearedAccount.operations.length).toEqual(0);
422
+ expect(clearedAccount.pendingOperations.length).toEqual(0);
423
+ });
424
+
425
+ it("should clear balanceHistory", () => {
426
+ const clearedAccount = clearAccount(withSubAccounts);
427
+ expect(clearedAccount.balanceHistoryCache).toEqual(emptyHistoryCache);
428
+ });
429
+
430
+ it("should reset lastSyncDate", () => {
431
+ const clearedAccount = clearAccount(withSubAccounts);
432
+ expect(clearedAccount.lastSyncDate).toEqual(new Date(0));
433
+ });
434
+
435
+ it("should delete nfts attribute", () => {
436
+ withSubAccounts.nfts = [];
437
+ const clearedAccount = clearAccount(withSubAccounts);
438
+ expect(Object.keys(clearedAccount).indexOf("nfts")).toEqual(-1);
439
+ });
440
+ });
441
+ });