@ledgerhq/live-common 34.53.0-nightly.20251119110540 → 34.53.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 (397) hide show
  1. package/lib/__tests__/test-helpers/bridge.d.ts.map +1 -1
  2. package/lib/__tests__/test-helpers/bridge.js +4 -0
  3. package/lib/__tests__/test-helpers/bridge.js.map +1 -1
  4. package/lib/__tests__/test-helpers/environment.js +0 -3
  5. package/lib/__tests__/test-helpers/environment.js.map +1 -1
  6. package/lib/bridge/generic-alpaca/getAccountShape.d.ts.map +1 -1
  7. package/lib/bridge/generic-alpaca/getAccountShape.js +10 -12
  8. package/lib/bridge/generic-alpaca/getAccountShape.js.map +1 -1
  9. package/lib/currencies/helpers.d.ts +3 -1
  10. package/lib/currencies/helpers.d.ts.map +1 -1
  11. package/lib/currencies/helpers.js +27 -1
  12. package/lib/currencies/helpers.js.map +1 -1
  13. package/lib/dada-client/hooks/useAssetsData.d.ts +0 -1
  14. package/lib/dada-client/hooks/useAssetsData.d.ts.map +1 -1
  15. package/lib/dada-client/hooks/useAssetsData.js +0 -1
  16. package/lib/dada-client/hooks/useAssetsData.js.map +1 -1
  17. package/lib/deposit/helper.d.ts +8 -0
  18. package/lib/deposit/helper.d.ts.map +1 -0
  19. package/lib/deposit/helper.js +125 -0
  20. package/lib/deposit/helper.js.map +1 -0
  21. package/lib/deposit/index.d.ts +3 -0
  22. package/lib/deposit/index.d.ts.map +1 -0
  23. package/lib/deposit/index.js +6 -0
  24. package/lib/deposit/index.js.map +1 -0
  25. package/lib/deposit/mock.d.ts +75 -0
  26. package/lib/deposit/mock.d.ts.map +1 -0
  27. package/lib/deposit/mock.js +15111 -0
  28. package/lib/deposit/mock.js.map +1 -0
  29. package/lib/deposit/type.d.ts +17 -0
  30. package/lib/deposit/type.d.ts.map +1 -1
  31. package/lib/deposit/type.js.map +1 -1
  32. package/lib/deposit/useGroupedCurrenciesByProvider.hook.d.ts +3 -0
  33. package/lib/deposit/useGroupedCurrenciesByProvider.hook.d.ts.map +1 -0
  34. package/lib/deposit/useGroupedCurrenciesByProvider.hook.js +40 -0
  35. package/lib/deposit/useGroupedCurrenciesByProvider.hook.js.map +1 -0
  36. package/lib/deviceSDK/hooks/useBatteryStatuses.d.ts +1 -2
  37. package/lib/deviceSDK/hooks/useBatteryStatuses.d.ts.map +1 -1
  38. package/lib/deviceSDK/hooks/useBatteryStatuses.js +2 -4
  39. package/lib/deviceSDK/hooks/useBatteryStatuses.js.map +1 -1
  40. package/lib/deviceSDK/tasks/core.d.ts +1 -1
  41. package/lib/deviceSDK/tasks/core.d.ts.map +1 -1
  42. package/lib/deviceSDK/tasks/core.js +1 -1
  43. package/lib/deviceSDK/tasks/core.js.map +1 -1
  44. package/lib/deviceSDK/tasks/getDeviceInfo.d.ts.map +1 -1
  45. package/lib/deviceSDK/tasks/getDeviceInfo.js +0 -2
  46. package/lib/deviceSDK/tasks/getDeviceInfo.js.map +1 -1
  47. package/lib/deviceSDK/tasks/getLatestFirmware.d.ts.map +1 -1
  48. package/lib/deviceSDK/tasks/getLatestFirmware.js +2 -2
  49. package/lib/deviceSDK/tasks/getLatestFirmware.js.map +1 -1
  50. package/lib/deviceSDK/tasks/updateFirmware.d.ts.map +1 -1
  51. package/lib/deviceSDK/tasks/updateFirmware.js +0 -1
  52. package/lib/deviceSDK/tasks/updateFirmware.js.map +1 -1
  53. package/lib/e2e/enum/Account.d.ts +1 -0
  54. package/lib/e2e/enum/Account.d.ts.map +1 -1
  55. package/lib/e2e/enum/Account.js +1 -0
  56. package/lib/e2e/enum/Account.js.map +1 -1
  57. package/lib/e2e/enum/Currency.d.ts +1 -0
  58. package/lib/e2e/enum/Currency.d.ts.map +1 -1
  59. package/lib/e2e/enum/Currency.js +6 -2
  60. package/lib/e2e/enum/Currency.js.map +1 -1
  61. package/lib/e2e/index.d.ts +0 -9
  62. package/lib/e2e/index.d.ts.map +1 -1
  63. package/lib/exchange/providers/swap.d.ts +0 -1
  64. package/lib/exchange/providers/swap.d.ts.map +1 -1
  65. package/lib/exchange/providers/swap.js +1 -5
  66. package/lib/exchange/providers/swap.js.map +1 -1
  67. package/lib/exchange/swap/hooks/v5/useFetchCurrencyAll.d.ts.map +1 -1
  68. package/lib/exchange/swap/hooks/v5/useFetchCurrencyAll.js +3 -2
  69. package/lib/exchange/swap/hooks/v5/useFetchCurrencyAll.js.map +1 -1
  70. package/lib/exchange/swap/hooks/v5/useFilteredProviders.d.ts.map +1 -1
  71. package/lib/exchange/swap/hooks/v5/useFilteredProviders.js +10 -15
  72. package/lib/exchange/swap/hooks/v5/useFilteredProviders.js.map +1 -1
  73. package/lib/families/evm/config.d.ts.map +1 -1
  74. package/lib/families/evm/config.js +0 -49
  75. package/lib/families/evm/config.js.map +1 -1
  76. package/lib/featureFlags/defaultFeatures.d.ts +0 -3
  77. package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
  78. package/lib/featureFlags/defaultFeatures.js +0 -4
  79. package/lib/featureFlags/defaultFeatures.js.map +1 -1
  80. package/lib/market/hooks/useMarketDataProvider.js +0 -1
  81. package/lib/market/hooks/useMarketDataProvider.js.map +1 -1
  82. package/lib/market/utils/types.d.ts +0 -1
  83. package/lib/market/utils/types.d.ts.map +1 -1
  84. package/lib/market/utils/types.js.map +1 -1
  85. package/lib/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.d.ts +22 -0
  86. package/lib/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.d.ts.map +1 -0
  87. package/lib/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.js +41 -0
  88. package/lib/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.js.map +1 -0
  89. package/lib/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.d.ts.map +1 -1
  90. package/lib/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.js +0 -11
  91. package/lib/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.js.map +1 -1
  92. package/lib/modularDrawer/hooks/useNetworkAccountCounts.d.ts +5 -1
  93. package/lib/modularDrawer/hooks/useNetworkAccountCounts.d.ts.map +1 -1
  94. package/lib/modularDrawer/hooks/useNetworkAccountCounts.js +2 -2
  95. package/lib/modularDrawer/hooks/useNetworkAccountCounts.js.map +1 -1
  96. package/lib/modularDrawer/modules/createNetworkConfiguration.d.ts +1 -1
  97. package/lib/modularDrawer/modules/createNetworkConfiguration.d.ts.map +1 -1
  98. package/lib/modularDrawer/modules/createNetworkConfiguration.js +2 -1
  99. package/lib/modularDrawer/modules/createNetworkConfiguration.js.map +1 -1
  100. package/lib/modularDrawer/utils/currencyUtils.d.ts +10 -0
  101. package/lib/modularDrawer/utils/currencyUtils.d.ts.map +1 -0
  102. package/lib/modularDrawer/utils/currencyUtils.js +74 -0
  103. package/lib/modularDrawer/utils/currencyUtils.js.map +1 -0
  104. package/lib/modularDrawer/utils/{groupCurrenciesByAsset.d.ts → groupCurrenciesByProvider.d.ts} +2 -2
  105. package/lib/modularDrawer/utils/groupCurrenciesByProvider.d.ts.map +1 -0
  106. package/lib/modularDrawer/utils/groupCurrenciesByProvider.js +21 -0
  107. package/lib/modularDrawer/utils/groupCurrenciesByProvider.js.map +1 -0
  108. package/lib/modularDrawer/utils/index.d.ts +1 -1
  109. package/lib/modularDrawer/utils/index.d.ts.map +1 -1
  110. package/lib/modularDrawer/utils/index.js +3 -3
  111. package/lib/modularDrawer/utils/index.js.map +1 -1
  112. package/lib/modularDrawer/utils/type.d.ts +5 -0
  113. package/lib/modularDrawer/utils/type.d.ts.map +1 -1
  114. package/lib/platform/filters.d.ts +2 -1
  115. package/lib/platform/filters.d.ts.map +1 -1
  116. package/lib/platform/filters.js +17 -1
  117. package/lib/platform/filters.js.map +1 -1
  118. package/lib/platform/helpers.d.ts +5 -1
  119. package/lib/platform/helpers.d.ts.map +1 -1
  120. package/lib/platform/helpers.js +33 -1
  121. package/lib/platform/helpers.js.map +1 -1
  122. package/lib/platform/react.d.ts +3 -2
  123. package/lib/platform/react.d.ts.map +1 -1
  124. package/lib/platform/react.js +16 -66
  125. package/lib/platform/react.js.map +1 -1
  126. package/lib/platform/types.d.ts +3 -3
  127. package/lib/platform/types.d.ts.map +1 -1
  128. package/lib/postOnboarding/reducer.d.ts +0 -2
  129. package/lib/postOnboarding/reducer.d.ts.map +1 -1
  130. package/lib/utils/getAccountTuplesForCurrency.d.ts +1 -1
  131. package/lib/utils/getAccountTuplesForCurrency.d.ts.map +1 -1
  132. package/lib/utils/getAccountTuplesForCurrency.js +3 -2
  133. package/lib/utils/getAccountTuplesForCurrency.js.map +1 -1
  134. package/lib/wallet-api/Exchange/server.d.ts.map +1 -1
  135. package/lib/wallet-api/Exchange/server.js +4 -5
  136. package/lib/wallet-api/Exchange/server.js.map +1 -1
  137. package/lib/wallet-api/converters.d.ts +0 -1
  138. package/lib/wallet-api/converters.d.ts.map +1 -1
  139. package/lib/wallet-api/converters.js +2 -7
  140. package/lib/wallet-api/converters.js.map +1 -1
  141. package/lib/wallet-api/react.d.ts +11 -6
  142. package/lib/wallet-api/react.d.ts.map +1 -1
  143. package/lib/wallet-api/react.js +135 -291
  144. package/lib/wallet-api/react.js.map +1 -1
  145. package/lib/wallet-api/tracking.d.ts +0 -6
  146. package/lib/wallet-api/tracking.d.ts.map +1 -1
  147. package/lib/wallet-api/tracking.js +0 -20
  148. package/lib/wallet-api/tracking.js.map +1 -1
  149. package/lib/wallet-api/types.d.ts +0 -3
  150. package/lib/wallet-api/types.d.ts.map +1 -1
  151. package/lib/wallet-api/useDappLogic.d.ts.map +1 -1
  152. package/lib/wallet-api/useDappLogic.js +80 -65
  153. package/lib/wallet-api/useDappLogic.js.map +1 -1
  154. package/lib/wallet-api/utils/deriveAccountIdForManifest.d.ts +0 -6
  155. package/lib/wallet-api/utils/deriveAccountIdForManifest.d.ts.map +1 -1
  156. package/lib/wallet-api/utils/deriveAccountIdForManifest.js +3 -13
  157. package/lib/wallet-api/utils/deriveAccountIdForManifest.js.map +1 -1
  158. package/lib-es/__tests__/test-helpers/bridge.d.ts.map +1 -1
  159. package/lib-es/__tests__/test-helpers/bridge.js +4 -0
  160. package/lib-es/__tests__/test-helpers/bridge.js.map +1 -1
  161. package/lib-es/__tests__/test-helpers/environment.js +0 -3
  162. package/lib-es/__tests__/test-helpers/environment.js.map +1 -1
  163. package/lib-es/bridge/generic-alpaca/getAccountShape.d.ts.map +1 -1
  164. package/lib-es/bridge/generic-alpaca/getAccountShape.js +11 -13
  165. package/lib-es/bridge/generic-alpaca/getAccountShape.js.map +1 -1
  166. package/lib-es/currencies/helpers.d.ts +3 -1
  167. package/lib-es/currencies/helpers.d.ts.map +1 -1
  168. package/lib-es/currencies/helpers.js +24 -0
  169. package/lib-es/currencies/helpers.js.map +1 -1
  170. package/lib-es/dada-client/hooks/useAssetsData.d.ts +0 -1
  171. package/lib-es/dada-client/hooks/useAssetsData.d.ts.map +1 -1
  172. package/lib-es/dada-client/hooks/useAssetsData.js +0 -1
  173. package/lib-es/dada-client/hooks/useAssetsData.js.map +1 -1
  174. package/lib-es/deposit/helper.d.ts +8 -0
  175. package/lib-es/deposit/helper.d.ts.map +1 -0
  176. package/lib-es/deposit/helper.js +117 -0
  177. package/lib-es/deposit/helper.js.map +1 -0
  178. package/lib-es/deposit/index.d.ts +3 -0
  179. package/lib-es/deposit/index.d.ts.map +1 -0
  180. package/lib-es/deposit/index.js +3 -0
  181. package/lib-es/deposit/index.js.map +1 -0
  182. package/lib-es/deposit/mock.d.ts +75 -0
  183. package/lib-es/deposit/mock.d.ts.map +1 -0
  184. package/lib-es/deposit/mock.js +15108 -0
  185. package/lib-es/deposit/mock.js.map +1 -0
  186. package/lib-es/deposit/type.d.ts +17 -0
  187. package/lib-es/deposit/type.d.ts.map +1 -1
  188. package/lib-es/deposit/type.js.map +1 -1
  189. package/lib-es/deposit/useGroupedCurrenciesByProvider.hook.d.ts +3 -0
  190. package/lib-es/deposit/useGroupedCurrenciesByProvider.hook.d.ts.map +1 -0
  191. package/lib-es/deposit/useGroupedCurrenciesByProvider.hook.js +36 -0
  192. package/lib-es/deposit/useGroupedCurrenciesByProvider.hook.js.map +1 -0
  193. package/lib-es/deviceSDK/hooks/useBatteryStatuses.d.ts +1 -2
  194. package/lib-es/deviceSDK/hooks/useBatteryStatuses.d.ts.map +1 -1
  195. package/lib-es/deviceSDK/hooks/useBatteryStatuses.js +2 -4
  196. package/lib-es/deviceSDK/hooks/useBatteryStatuses.js.map +1 -1
  197. package/lib-es/deviceSDK/tasks/core.d.ts +1 -1
  198. package/lib-es/deviceSDK/tasks/core.d.ts.map +1 -1
  199. package/lib-es/deviceSDK/tasks/core.js +1 -1
  200. package/lib-es/deviceSDK/tasks/core.js.map +1 -1
  201. package/lib-es/deviceSDK/tasks/getDeviceInfo.d.ts.map +1 -1
  202. package/lib-es/deviceSDK/tasks/getDeviceInfo.js +0 -2
  203. package/lib-es/deviceSDK/tasks/getDeviceInfo.js.map +1 -1
  204. package/lib-es/deviceSDK/tasks/getLatestFirmware.d.ts.map +1 -1
  205. package/lib-es/deviceSDK/tasks/getLatestFirmware.js +2 -2
  206. package/lib-es/deviceSDK/tasks/getLatestFirmware.js.map +1 -1
  207. package/lib-es/deviceSDK/tasks/updateFirmware.d.ts.map +1 -1
  208. package/lib-es/deviceSDK/tasks/updateFirmware.js +1 -2
  209. package/lib-es/deviceSDK/tasks/updateFirmware.js.map +1 -1
  210. package/lib-es/e2e/enum/Account.d.ts +1 -0
  211. package/lib-es/e2e/enum/Account.d.ts.map +1 -1
  212. package/lib-es/e2e/enum/Account.js +1 -0
  213. package/lib-es/e2e/enum/Account.js.map +1 -1
  214. package/lib-es/e2e/enum/Currency.d.ts +1 -0
  215. package/lib-es/e2e/enum/Currency.d.ts.map +1 -1
  216. package/lib-es/e2e/enum/Currency.js +6 -2
  217. package/lib-es/e2e/enum/Currency.js.map +1 -1
  218. package/lib-es/e2e/index.d.ts +0 -9
  219. package/lib-es/e2e/index.d.ts.map +1 -1
  220. package/lib-es/exchange/providers/swap.d.ts +0 -1
  221. package/lib-es/exchange/providers/swap.d.ts.map +1 -1
  222. package/lib-es/exchange/providers/swap.js +0 -3
  223. package/lib-es/exchange/providers/swap.js.map +1 -1
  224. package/lib-es/exchange/swap/hooks/v5/useFetchCurrencyAll.d.ts.map +1 -1
  225. package/lib-es/exchange/swap/hooks/v5/useFetchCurrencyAll.js +3 -2
  226. package/lib-es/exchange/swap/hooks/v5/useFetchCurrencyAll.js.map +1 -1
  227. package/lib-es/exchange/swap/hooks/v5/useFilteredProviders.d.ts.map +1 -1
  228. package/lib-es/exchange/swap/hooks/v5/useFilteredProviders.js +12 -17
  229. package/lib-es/exchange/swap/hooks/v5/useFilteredProviders.js.map +1 -1
  230. package/lib-es/families/evm/config.d.ts.map +1 -1
  231. package/lib-es/families/evm/config.js +0 -49
  232. package/lib-es/families/evm/config.js.map +1 -1
  233. package/lib-es/featureFlags/defaultFeatures.d.ts +0 -3
  234. package/lib-es/featureFlags/defaultFeatures.d.ts.map +1 -1
  235. package/lib-es/featureFlags/defaultFeatures.js +0 -4
  236. package/lib-es/featureFlags/defaultFeatures.js.map +1 -1
  237. package/lib-es/market/hooks/useMarketDataProvider.js +0 -1
  238. package/lib-es/market/hooks/useMarketDataProvider.js.map +1 -1
  239. package/lib-es/market/utils/types.d.ts +0 -1
  240. package/lib-es/market/utils/types.d.ts.map +1 -1
  241. package/lib-es/market/utils/types.js.map +1 -1
  242. package/lib-es/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.d.ts +22 -0
  243. package/lib-es/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.d.ts.map +1 -0
  244. package/lib-es/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.js +38 -0
  245. package/lib-es/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.js.map +1 -0
  246. package/lib-es/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.d.ts.map +1 -1
  247. package/lib-es/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.js +0 -11
  248. package/lib-es/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.js.map +1 -1
  249. package/lib-es/modularDrawer/hooks/useNetworkAccountCounts.d.ts +5 -1
  250. package/lib-es/modularDrawer/hooks/useNetworkAccountCounts.d.ts.map +1 -1
  251. package/lib-es/modularDrawer/hooks/useNetworkAccountCounts.js +2 -2
  252. package/lib-es/modularDrawer/hooks/useNetworkAccountCounts.js.map +1 -1
  253. package/lib-es/modularDrawer/modules/createNetworkConfiguration.d.ts +1 -1
  254. package/lib-es/modularDrawer/modules/createNetworkConfiguration.d.ts.map +1 -1
  255. package/lib-es/modularDrawer/modules/createNetworkConfiguration.js +2 -1
  256. package/lib-es/modularDrawer/modules/createNetworkConfiguration.js.map +1 -1
  257. package/lib-es/modularDrawer/utils/currencyUtils.d.ts +10 -0
  258. package/lib-es/modularDrawer/utils/currencyUtils.d.ts.map +1 -0
  259. package/lib-es/modularDrawer/utils/currencyUtils.js +65 -0
  260. package/lib-es/modularDrawer/utils/currencyUtils.js.map +1 -0
  261. package/lib-es/modularDrawer/utils/{groupCurrenciesByAsset.d.ts → groupCurrenciesByProvider.d.ts} +2 -2
  262. package/lib-es/modularDrawer/utils/groupCurrenciesByProvider.d.ts.map +1 -0
  263. package/lib-es/modularDrawer/utils/{groupCurrenciesByAsset.js → groupCurrenciesByProvider.js} +6 -6
  264. package/lib-es/modularDrawer/utils/groupCurrenciesByProvider.js.map +1 -0
  265. package/lib-es/modularDrawer/utils/index.d.ts +1 -1
  266. package/lib-es/modularDrawer/utils/index.d.ts.map +1 -1
  267. package/lib-es/modularDrawer/utils/index.js +1 -1
  268. package/lib-es/modularDrawer/utils/index.js.map +1 -1
  269. package/lib-es/modularDrawer/utils/type.d.ts +5 -0
  270. package/lib-es/modularDrawer/utils/type.d.ts.map +1 -1
  271. package/lib-es/platform/filters.d.ts +2 -1
  272. package/lib-es/platform/filters.d.ts.map +1 -1
  273. package/lib-es/platform/filters.js +15 -0
  274. package/lib-es/platform/filters.js.map +1 -1
  275. package/lib-es/platform/helpers.d.ts +5 -1
  276. package/lib-es/platform/helpers.d.ts.map +1 -1
  277. package/lib-es/platform/helpers.js +30 -1
  278. package/lib-es/platform/helpers.js.map +1 -1
  279. package/lib-es/platform/react.d.ts +3 -2
  280. package/lib-es/platform/react.d.ts.map +1 -1
  281. package/lib-es/platform/react.js +16 -67
  282. package/lib-es/platform/react.js.map +1 -1
  283. package/lib-es/platform/types.d.ts +3 -3
  284. package/lib-es/platform/types.d.ts.map +1 -1
  285. package/lib-es/postOnboarding/reducer.d.ts +0 -2
  286. package/lib-es/postOnboarding/reducer.d.ts.map +1 -1
  287. package/lib-es/utils/getAccountTuplesForCurrency.d.ts +1 -1
  288. package/lib-es/utils/getAccountTuplesForCurrency.d.ts.map +1 -1
  289. package/lib-es/utils/getAccountTuplesForCurrency.js +3 -2
  290. package/lib-es/utils/getAccountTuplesForCurrency.js.map +1 -1
  291. package/lib-es/wallet-api/Exchange/server.d.ts.map +1 -1
  292. package/lib-es/wallet-api/Exchange/server.js +4 -5
  293. package/lib-es/wallet-api/Exchange/server.js.map +1 -1
  294. package/lib-es/wallet-api/converters.d.ts +0 -1
  295. package/lib-es/wallet-api/converters.d.ts.map +1 -1
  296. package/lib-es/wallet-api/converters.js +1 -5
  297. package/lib-es/wallet-api/converters.js.map +1 -1
  298. package/lib-es/wallet-api/react.d.ts +11 -6
  299. package/lib-es/wallet-api/react.d.ts.map +1 -1
  300. package/lib-es/wallet-api/react.js +131 -289
  301. package/lib-es/wallet-api/react.js.map +1 -1
  302. package/lib-es/wallet-api/tracking.d.ts +0 -6
  303. package/lib-es/wallet-api/tracking.d.ts.map +1 -1
  304. package/lib-es/wallet-api/tracking.js +0 -20
  305. package/lib-es/wallet-api/tracking.js.map +1 -1
  306. package/lib-es/wallet-api/types.d.ts +0 -3
  307. package/lib-es/wallet-api/types.d.ts.map +1 -1
  308. package/lib-es/wallet-api/useDappLogic.d.ts.map +1 -1
  309. package/lib-es/wallet-api/useDappLogic.js +77 -62
  310. package/lib-es/wallet-api/useDappLogic.js.map +1 -1
  311. package/lib-es/wallet-api/utils/deriveAccountIdForManifest.d.ts +0 -6
  312. package/lib-es/wallet-api/utils/deriveAccountIdForManifest.d.ts.map +1 -1
  313. package/lib-es/wallet-api/utils/deriveAccountIdForManifest.js +2 -11
  314. package/lib-es/wallet-api/utils/deriveAccountIdForManifest.js.map +1 -1
  315. package/package.json +57 -57
  316. package/src/__tests__/migration/account-migration.ts +0 -3
  317. package/src/__tests__/test-helpers/bridge.ts +2 -0
  318. package/src/__tests__/test-helpers/environment.ts +0 -3
  319. package/src/bridge/generic-alpaca/getAccountShape.ts +12 -15
  320. package/src/bridge/generic-alpaca/tests/getAccountShape.test.ts +101 -142
  321. package/src/currencies/helpers.test.ts +20 -0
  322. package/src/currencies/helpers.ts +42 -1
  323. package/src/dada-client/hooks/useAssetsData.ts +0 -1
  324. package/src/deposit/deposit.integration.test.ts +88 -0
  325. package/src/deposit/deposit.test.ts +684 -0
  326. package/src/deposit/helper.ts +143 -0
  327. package/src/deposit/index.ts +3 -0
  328. package/src/deposit/mock.ts +15112 -0
  329. package/src/deposit/type.ts +21 -0
  330. package/src/deposit/useGroupedCurrenciesByProvider.hook.ts +46 -0
  331. package/src/deviceSDK/hooks/useBatteryStatuses.test.ts +1 -3
  332. package/src/deviceSDK/hooks/useBatteryStatuses.ts +1 -4
  333. package/src/deviceSDK/tasks/core.test.ts +0 -20
  334. package/src/deviceSDK/tasks/core.ts +1 -2
  335. package/src/deviceSDK/tasks/getDeviceInfo.ts +0 -2
  336. package/src/deviceSDK/tasks/getLatestFirmware.ts +4 -4
  337. package/src/deviceSDK/tasks/updateFirmware.ts +0 -2
  338. package/src/e2e/enum/Account.ts +6 -0
  339. package/src/e2e/enum/Currency.ts +6 -2
  340. package/src/exchange/providers/swap.ts +0 -4
  341. package/src/exchange/swap/hooks/v5/useFetchCurrencyAll.ts +3 -2
  342. package/src/exchange/swap/hooks/v5/useFilteredProviders.ts +12 -37
  343. package/src/families/evm/config.ts +0 -49
  344. package/src/families/stellar/__snapshots__/bridge.integration.test.ts.snap +12 -84
  345. package/src/featureFlags/defaultFeatures.ts +0 -4
  346. package/src/market/hooks/useMarketDataProvider.ts +0 -1
  347. package/src/market/utils/types.ts +0 -1
  348. package/src/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.ts +49 -0
  349. package/src/modularDrawer/hooks/__test__/useAssetAccountCounts.test.ts +5 -0
  350. package/src/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.ts +0 -11
  351. package/src/modularDrawer/hooks/useNetworkAccountCounts.tsx +6 -1
  352. package/src/modularDrawer/modules/__test__/createAssetConfiguration.test.tsx +2 -2
  353. package/src/modularDrawer/modules/__test__/createNetworkConfiguration.test.ts +342 -0
  354. package/src/modularDrawer/modules/createNetworkConfiguration.ts +2 -1
  355. package/src/modularDrawer/utils/__tests__/currencyUtils.test.ts +126 -0
  356. package/src/modularDrawer/utils/currencyUtils.ts +95 -0
  357. package/src/modularDrawer/utils/{groupCurrenciesByAsset.ts → groupCurrenciesByProvider.ts} +5 -5
  358. package/src/modularDrawer/utils/index.ts +1 -1
  359. package/src/modularDrawer/utils/type.ts +5 -0
  360. package/src/platform/filters.ts +23 -1
  361. package/src/platform/helpers.ts +49 -2
  362. package/src/platform/react.ts +22 -86
  363. package/src/platform/types.ts +1 -1
  364. package/src/utils/__tests__/getAccountTuplesForCurrency.test.ts +30 -0
  365. package/src/utils/getAccountTuplesForCurrency.ts +6 -1
  366. package/src/wallet-api/Exchange/server.test.ts +5 -0
  367. package/src/wallet-api/Exchange/server.ts +6 -7
  368. package/src/wallet-api/converters.ts +1 -6
  369. package/src/wallet-api/react.ts +137 -310
  370. package/src/wallet-api/tracking.ts +0 -22
  371. package/src/wallet-api/types.ts +0 -5
  372. package/src/wallet-api/useDappLogic.ts +106 -91
  373. package/src/wallet-api/utils/deriveAccountIdForManifest.ts +2 -14
  374. package/lib/device/use-cases/getDeviceHasBattery.d.ts +0 -2
  375. package/lib/device/use-cases/getDeviceHasBattery.d.ts.map +0 -1
  376. package/lib/device/use-cases/getDeviceHasBattery.js +0 -6
  377. package/lib/device/use-cases/getDeviceHasBattery.js.map +0 -1
  378. package/lib/e2e/enum/ReceiveFundsOptions.d.ts +0 -6
  379. package/lib/e2e/enum/ReceiveFundsOptions.d.ts.map +0 -1
  380. package/lib/e2e/enum/ReceiveFundsOptions.js +0 -8
  381. package/lib/e2e/enum/ReceiveFundsOptions.js.map +0 -1
  382. package/lib/modularDrawer/utils/groupCurrenciesByAsset.d.ts.map +0 -1
  383. package/lib/modularDrawer/utils/groupCurrenciesByAsset.js +0 -21
  384. package/lib/modularDrawer/utils/groupCurrenciesByAsset.js.map +0 -1
  385. package/lib-es/device/use-cases/getDeviceHasBattery.d.ts +0 -2
  386. package/lib-es/device/use-cases/getDeviceHasBattery.d.ts.map +0 -1
  387. package/lib-es/device/use-cases/getDeviceHasBattery.js +0 -2
  388. package/lib-es/device/use-cases/getDeviceHasBattery.js.map +0 -1
  389. package/lib-es/e2e/enum/ReceiveFundsOptions.d.ts +0 -6
  390. package/lib-es/e2e/enum/ReceiveFundsOptions.d.ts.map +0 -1
  391. package/lib-es/e2e/enum/ReceiveFundsOptions.js +0 -5
  392. package/lib-es/e2e/enum/ReceiveFundsOptions.js.map +0 -1
  393. package/lib-es/modularDrawer/utils/groupCurrenciesByAsset.d.ts.map +0 -1
  394. package/lib-es/modularDrawer/utils/groupCurrenciesByAsset.js.map +0 -1
  395. package/src/device/use-cases/getDeviceHasBattery.ts +0 -1
  396. package/src/e2e/enum/ReceiveFundsOptions.ts +0 -7
  397. package/src/modularDrawer/utils/__tests__/groupCurrenciesByAsset.test.ts +0 -88
@@ -0,0 +1,684 @@
1
+ import {
2
+ groupCurrenciesByProvider,
3
+ searchByNameOrTicker,
4
+ searchByProviderId,
5
+ loadCurrenciesByProvider,
6
+ getTokenOrCryptoCurrencyById,
7
+ } from "./helper";
8
+ import { MOCK_TOKENS_ONLY, MOCK_WITH_TOKEN_AND_CURRENCY_ASSET, MOCK_IDS, MOCK_POL } from "./mock";
9
+ import { MappedAsset } from "./type";
10
+ import {
11
+ getCryptoCurrencyById,
12
+ setSupportedCurrencies,
13
+ sortCurrenciesByIds,
14
+ } from "../currencies/index";
15
+ import { isCurrencySupported, listSupportedCurrencies, listTokens } from "../currencies";
16
+ import { CryptoOrTokenCurrency, TokenCurrency } from "@ledgerhq/types-cryptoassets";
17
+ import { getCryptoAssetsStore } from "../bridge/crypto-assets/index";
18
+ import { initializeLegacyTokens } from "@ledgerhq/cryptoassets/legacy/legacy-data";
19
+ import { addTokens } from "@ledgerhq/cryptoassets/legacy/legacy-utils";
20
+
21
+ const TOKEN_ONLY_ASSETS = MOCK_TOKENS_ONLY as MappedAsset[];
22
+
23
+ const listSupportedTokens = () => listTokens().filter(t => isCurrencySupported(t.parentCurrency));
24
+
25
+ describe("Deposit logic", () => {
26
+ beforeAll(() => {
27
+ initializeLegacyTokens(addTokens);
28
+ });
29
+
30
+ afterEach(() => {
31
+ setSupportedCurrencies([]);
32
+ });
33
+
34
+ describe("searchByProviderId", () => {
35
+ test("should find assets by provider ID", () => {
36
+ const result = searchByProviderId(TOKEN_ONLY_ASSETS, "tether");
37
+ expect(result).toEqual(TOKEN_ONLY_ASSETS);
38
+ });
39
+
40
+ test("should return empty array for non-existent provider ID", () => {
41
+ const result = searchByProviderId(TOKEN_ONLY_ASSETS, "non-existent-provider");
42
+ expect(result).toEqual([]);
43
+ });
44
+
45
+ test("should handle case insensitive search", () => {
46
+ const result = searchByProviderId(TOKEN_ONLY_ASSETS, "TETHER");
47
+ expect(result).toEqual(TOKEN_ONLY_ASSETS);
48
+ });
49
+
50
+ test("should handle empty assets list", () => {
51
+ const result = searchByProviderId([], "tether");
52
+ expect(result).toEqual([]);
53
+ });
54
+
55
+ test("should handle empty provider ID", () => {
56
+ const result = searchByProviderId(TOKEN_ONLY_ASSETS, "");
57
+ expect(result).toEqual([]);
58
+ });
59
+
60
+ test("should handle special characters in provider ID", () => {
61
+ const mockAssets = [
62
+ { ...TOKEN_ONLY_ASSETS[0], providerId: "test-provider_123" },
63
+ ] as MappedAsset[];
64
+ const result = searchByProviderId(mockAssets, "test-provider_123");
65
+ expect(result).toHaveLength(1);
66
+ });
67
+ });
68
+
69
+ describe("searchByNameOrTicker", () => {
70
+ test("should find assets by name or ticker", () => {
71
+ const result = searchByNameOrTicker(TOKEN_ONLY_ASSETS, "usdt");
72
+ expect(result.length).toBeGreaterThan(0);
73
+ });
74
+
75
+ test("should handle case insensitive search", () => {
76
+ const result = searchByNameOrTicker(TOKEN_ONLY_ASSETS, "USDT");
77
+ expect(result.length).toBeGreaterThan(0);
78
+ });
79
+
80
+ test("should find partial matches", () => {
81
+ const result = searchByNameOrTicker(TOKEN_ONLY_ASSETS, "usd");
82
+ expect(result.length).toBeGreaterThan(0);
83
+ });
84
+
85
+ test("should return empty array for non-matching search", () => {
86
+ const result = searchByNameOrTicker(TOKEN_ONLY_ASSETS, "non-existent-token");
87
+ expect(result).toEqual([]);
88
+ });
89
+
90
+ test("should handle empty search term", () => {
91
+ const result = searchByNameOrTicker(TOKEN_ONLY_ASSETS, "");
92
+ expect(result).toEqual(TOKEN_ONLY_ASSETS);
93
+ });
94
+
95
+ test("should handle empty assets list", () => {
96
+ const result = searchByNameOrTicker([], "usdt");
97
+ expect(result).toEqual([]);
98
+ });
99
+
100
+ test("should search in both name and ticker fields", () => {
101
+ const mockAssets = [
102
+ { ...TOKEN_ONLY_ASSETS[0], name: "Test Token", ticker: "TTK" },
103
+ { ...TOKEN_ONLY_ASSETS[0], name: "Another Token", ticker: "USDT" },
104
+ ] as MappedAsset[];
105
+
106
+ const nameResult = searchByNameOrTicker(mockAssets, "Test");
107
+ const tickerResult = searchByNameOrTicker(mockAssets, "USDT");
108
+
109
+ expect(nameResult).toHaveLength(1);
110
+ expect(tickerResult).toHaveLength(1);
111
+ });
112
+ });
113
+
114
+ describe("groupCurrenciesByProvider", () => {
115
+ test("should group currencies by provider", async () => {
116
+ const currencies = (
117
+ await Promise.all(
118
+ TOKEN_ONLY_ASSETS.map(asset => getCryptoAssetsStore().findTokenById(asset.ledgerId)),
119
+ )
120
+ ).filter((t): t is TokenCurrency => t !== undefined);
121
+ const { currenciesByProvider } = groupCurrenciesByProvider(TOKEN_ONLY_ASSETS, currencies);
122
+ expect(currenciesByProvider).toEqual([
123
+ {
124
+ providerId: "tether",
125
+ currenciesByNetwork: currencies,
126
+ },
127
+ ]);
128
+ });
129
+
130
+ test("should handle POL assets correctly", async () => {
131
+ const currenciesPol = (
132
+ await Promise.all(
133
+ MOCK_POL.map(asset =>
134
+ asset.$type === "Token"
135
+ ? getCryptoAssetsStore().findTokenById(asset.ledgerId)
136
+ : Promise.resolve(getCryptoCurrencyById(asset.ledgerId)),
137
+ ),
138
+ )
139
+ ).filter((c): c is CryptoOrTokenCurrency => c !== undefined);
140
+ const { currenciesByProvider: currenciesByProviderBis, sortedCryptoCurrencies } =
141
+ groupCurrenciesByProvider(MOCK_POL as MappedAsset[], currenciesPol);
142
+ expect(currenciesByProviderBis).toEqual([
143
+ {
144
+ providerId: "matic-network",
145
+ currenciesByNetwork: currenciesPol,
146
+ },
147
+ ]);
148
+
149
+ expect(sortedCryptoCurrencies).toEqual([currenciesPol[1]]);
150
+ });
151
+
152
+ test("should handle empty assets array", async () => {
153
+ const currencies = (
154
+ await Promise.all(
155
+ TOKEN_ONLY_ASSETS.map(asset => getCryptoAssetsStore().findTokenById(asset.ledgerId)),
156
+ )
157
+ ).filter((t): t is TokenCurrency => t !== undefined);
158
+ const { currenciesByProvider, sortedCryptoCurrencies } = groupCurrenciesByProvider(
159
+ [],
160
+ currencies,
161
+ );
162
+ expect(currenciesByProvider).toEqual([]);
163
+ expect(sortedCryptoCurrencies).toEqual([]);
164
+ });
165
+
166
+ test("should handle empty currencies array", () => {
167
+ const { currenciesByProvider, sortedCryptoCurrencies } = groupCurrenciesByProvider(
168
+ TOKEN_ONLY_ASSETS,
169
+ [],
170
+ );
171
+ expect(currenciesByProvider).toEqual([]);
172
+ expect(sortedCryptoCurrencies).toEqual([]);
173
+ });
174
+
175
+ test("should handle currencies without corresponding assets", () => {
176
+ setSupportedCurrencies(["bitcoin"]);
177
+ const btcCurrency = getCryptoCurrencyById("bitcoin");
178
+ const { currenciesByProvider, sortedCryptoCurrencies } = groupCurrenciesByProvider(
179
+ TOKEN_ONLY_ASSETS,
180
+ [btcCurrency],
181
+ );
182
+ expect(currenciesByProvider).toEqual([]);
183
+ expect(sortedCryptoCurrencies).toEqual([]);
184
+ });
185
+
186
+ test("should prioritize crypto currencies over tokens in sortedCryptoCurrencies", async () => {
187
+ const mockAssets = [
188
+ { ...TOKEN_ONLY_ASSETS[0], providerId: "test-provider" },
189
+ ] as MappedAsset[];
190
+
191
+ setSupportedCurrencies(["ethereum"]);
192
+ const ethCurrency = getCryptoCurrencyById("ethereum");
193
+ const tokenCurrency = await getCryptoAssetsStore().findTokenById(
194
+ TOKEN_ONLY_ASSETS[0].ledgerId,
195
+ );
196
+ if (!tokenCurrency) throw new Error("Token not found");
197
+
198
+ const { sortedCryptoCurrencies } = groupCurrenciesByProvider(mockAssets, [
199
+ tokenCurrency,
200
+ ethCurrency,
201
+ ]);
202
+
203
+ expect(sortedCryptoCurrencies.length).toBeGreaterThan(0);
204
+ });
205
+
206
+ test("should handle duplicate provider IDs correctly", async () => {
207
+ const duplicateAssets = [
208
+ TOKEN_ONLY_ASSETS[0],
209
+ { ...TOKEN_ONLY_ASSETS[0], ledgerId: "different-id" },
210
+ ] as MappedAsset[];
211
+
212
+ const token = await getCryptoAssetsStore().findTokenById(TOKEN_ONLY_ASSETS[0].ledgerId);
213
+ if (!token) throw new Error("Token not found");
214
+ const currencies = [token];
215
+ const { currenciesByProvider } = groupCurrenciesByProvider(duplicateAssets, currencies);
216
+
217
+ expect(currenciesByProvider).toHaveLength(1);
218
+ expect(currenciesByProvider[0].currenciesByNetwork).toHaveLength(1);
219
+ });
220
+ });
221
+
222
+ describe("getTokenOrCryptoCurrencyById", () => {
223
+ test("should return crypto currency by ID", async () => {
224
+ const result = await getTokenOrCryptoCurrencyById("bitcoin");
225
+ expect(result).toBeDefined();
226
+ expect(result.type).toBe("CryptoCurrency");
227
+ });
228
+
229
+ test("should return token by ID", async () => {
230
+ const result = await getTokenOrCryptoCurrencyById("ethereum/erc20/usd_tether__erc20_");
231
+ expect(result).toBeDefined();
232
+ expect(result.type).toBe("TokenCurrency");
233
+ });
234
+
235
+ test("should handle invalid crypto currency ID", async () => {
236
+ await expect(getTokenOrCryptoCurrencyById("invalid-crypto-id")).rejects.toThrow();
237
+ });
238
+
239
+ test("should handle invalid token ID", async () => {
240
+ await expect(getTokenOrCryptoCurrencyById("invalid/token/id")).rejects.toThrow();
241
+ });
242
+
243
+ test("should handle empty ID", async () => {
244
+ await expect(getTokenOrCryptoCurrencyById("")).rejects.toThrow();
245
+ });
246
+ });
247
+
248
+ describe("loadCurrenciesByProvider", () => {
249
+ test("should load currencies by provider successfully", async () => {
250
+ setSupportedCurrencies(["ethereum", "bitcoin"]);
251
+ const supportedCurrencies = listSupportedCurrencies() as CryptoOrTokenCurrency[];
252
+
253
+ const result = await loadCurrenciesByProvider(supportedCurrencies);
254
+
255
+ expect(result).toBeDefined();
256
+ expect(result.currenciesByProvider).toBeDefined();
257
+ expect(result.sortedCryptoCurrencies).toBeDefined();
258
+ expect(Array.isArray(result.currenciesByProvider)).toBe(true);
259
+ expect(Array.isArray(result.sortedCryptoCurrencies)).toBe(true);
260
+ });
261
+
262
+ test("should handle empty currencies array", async () => {
263
+ const result = await loadCurrenciesByProvider([]);
264
+
265
+ expect(result).toBeDefined();
266
+ expect(result.currenciesByProvider).toEqual([]);
267
+ expect(result.sortedCryptoCurrencies).toEqual([]);
268
+ });
269
+
270
+ test("should handle currencies with no corresponding assets", async () => {
271
+ setSupportedCurrencies(["bitcoin"]);
272
+ const supportedCurrencies = [getCryptoCurrencyById("bitcoin")];
273
+
274
+ const result = await loadCurrenciesByProvider(supportedCurrencies);
275
+
276
+ expect(result).toBeDefined();
277
+
278
+ expect(Array.isArray(result.currenciesByProvider)).toBe(true);
279
+ expect(Array.isArray(result.sortedCryptoCurrencies)).toBe(true);
280
+ });
281
+ });
282
+
283
+ describe("Currency support scenarios", () => {
284
+ it("should return Arbitrum and not Optimism in the sortedCryptoCurrencies", () => {
285
+ setSupportedCurrencies(["arbitrum", "arbitrum_sepolia"]);
286
+ const currencies = sortCurrenciesByIds(
287
+ (listSupportedCurrencies() as CryptoOrTokenCurrency[]).concat(listSupportedTokens()),
288
+ MOCK_IDS,
289
+ );
290
+
291
+ const { sortedCryptoCurrencies } = groupCurrenciesByProvider(
292
+ MOCK_WITH_TOKEN_AND_CURRENCY_ASSET as MappedAsset[],
293
+ currencies,
294
+ );
295
+ expect(sortedCryptoCurrencies).toEqual([getCryptoCurrencyById("arbitrum")]);
296
+ });
297
+
298
+ it("should return Optimism only in the sortedCryptoCurrencies", () => {
299
+ setSupportedCurrencies(["optimism", "optimism_sepolia"]);
300
+ const currencies = sortCurrenciesByIds(
301
+ (listSupportedCurrencies() as CryptoOrTokenCurrency[]).concat(listSupportedTokens()),
302
+ MOCK_IDS,
303
+ );
304
+
305
+ const { sortedCryptoCurrencies } = groupCurrenciesByProvider(
306
+ MOCK_WITH_TOKEN_AND_CURRENCY_ASSET as MappedAsset[],
307
+ currencies,
308
+ );
309
+ expect(sortedCryptoCurrencies).toEqual([getCryptoCurrencyById("optimism")]);
310
+ });
311
+
312
+ it("should return currencies based on what's actually supported and available in mock data", () => {
313
+ setSupportedCurrencies(["optimism", "optimism_sepolia", "arbitrum", "arbitrum_sepolia"]);
314
+ const currencies = sortCurrenciesByIds(
315
+ (listSupportedCurrencies() as CryptoOrTokenCurrency[]).concat(listSupportedTokens()),
316
+ MOCK_IDS,
317
+ );
318
+
319
+ const { sortedCryptoCurrencies } = groupCurrenciesByProvider(
320
+ MOCK_WITH_TOKEN_AND_CURRENCY_ASSET as MappedAsset[],
321
+ currencies,
322
+ );
323
+
324
+ expect(Array.isArray(sortedCryptoCurrencies)).toBe(true);
325
+ expect(sortedCryptoCurrencies.length).toBeGreaterThanOrEqual(0);
326
+
327
+ sortedCryptoCurrencies.forEach(currency => {
328
+ expect(["optimism", "arbitrum"].includes(currency.id)).toBe(true);
329
+ });
330
+ });
331
+ });
332
+
333
+ describe("Token-only scenarios", () => {
334
+ it("should return only Polygon token while its currency is supported in the list", async () => {
335
+ setSupportedCurrencies(["polygon"]);
336
+
337
+ const currencies = sortCurrenciesByIds(
338
+ (listSupportedCurrencies() as CryptoOrTokenCurrency[]).concat(listSupportedTokens()),
339
+ MOCK_IDS,
340
+ );
341
+ const { sortedCryptoCurrencies } = groupCurrenciesByProvider(
342
+ MOCK_TOKENS_ONLY as MappedAsset[],
343
+ currencies,
344
+ );
345
+ expect(sortedCryptoCurrencies).toEqual([
346
+ await getCryptoAssetsStore().findTokenById("polygon/erc20/(pos)_tether_usd"),
347
+ ]);
348
+ });
349
+
350
+ it("should return only BSC token while its currency is supported in the list", async () => {
351
+ setSupportedCurrencies(["bsc"]);
352
+
353
+ const currencies = sortCurrenciesByIds(
354
+ (listSupportedCurrencies() as CryptoOrTokenCurrency[]).concat(listSupportedTokens()),
355
+ MOCK_IDS,
356
+ );
357
+ const { sortedCryptoCurrencies } = groupCurrenciesByProvider(
358
+ MOCK_TOKENS_ONLY as MappedAsset[],
359
+ currencies,
360
+ );
361
+ expect(sortedCryptoCurrencies).toEqual([
362
+ await getCryptoAssetsStore().findTokenById("bsc/bep20/binance-peg_bsc-usd"),
363
+ ]);
364
+ });
365
+
366
+ it("should return tokens that are actually supported based on mock data", () => {
367
+ setSupportedCurrencies(["ethereum", "bsc", "polygon"]);
368
+
369
+ const currencies = sortCurrenciesByIds(
370
+ (listSupportedCurrencies() as CryptoOrTokenCurrency[]).concat(listSupportedTokens()),
371
+ MOCK_IDS,
372
+ );
373
+ const { sortedCryptoCurrencies } = groupCurrenciesByProvider(
374
+ MOCK_TOKENS_ONLY as MappedAsset[],
375
+ currencies,
376
+ );
377
+
378
+ expect(Array.isArray(sortedCryptoCurrencies)).toBe(true);
379
+ expect(sortedCryptoCurrencies.length).toBeGreaterThanOrEqual(0);
380
+
381
+ sortedCryptoCurrencies.forEach(currency => {
382
+ expect(currency.type).toBe("TokenCurrency");
383
+ expect(["ethereum", "polygon", "bsc"].some(network => currency.id.includes(network))).toBe(
384
+ true,
385
+ );
386
+ });
387
+ });
388
+
389
+ it("should return specific Ethereum and Polygon USDT tokens when both currencies are supported", () => {
390
+ setSupportedCurrencies(["ethereum", "polygon"]);
391
+
392
+ const currencies = sortCurrenciesByIds(
393
+ (listSupportedCurrencies() as CryptoOrTokenCurrency[]).concat(listSupportedTokens()),
394
+ MOCK_IDS,
395
+ );
396
+
397
+ const { sortedCryptoCurrencies } = groupCurrenciesByProvider(
398
+ MOCK_TOKENS_ONLY as MappedAsset[],
399
+ currencies,
400
+ );
401
+
402
+ expect(Array.isArray(sortedCryptoCurrencies)).toBe(true);
403
+ expect(sortedCryptoCurrencies.length).toBeGreaterThan(0);
404
+
405
+ const tokenIds = sortedCryptoCurrencies.map(currency => currency.id);
406
+
407
+ expect(tokenIds).toContain("ethereum/erc20/usd_tether__erc20_");
408
+
409
+ sortedCryptoCurrencies.forEach(currency => {
410
+ expect(currency.type).toBe("TokenCurrency");
411
+ expect(currency.id).toMatch(/tether|usdt/i);
412
+ });
413
+ });
414
+
415
+ it("should return all supported USDT tokens when multiple currencies are enabled", () => {
416
+ setSupportedCurrencies(["ethereum", "bsc", "polygon"]);
417
+
418
+ const currencies = sortCurrenciesByIds(
419
+ (listSupportedCurrencies() as CryptoOrTokenCurrency[]).concat(listSupportedTokens()),
420
+ MOCK_IDS,
421
+ );
422
+ const { sortedCryptoCurrencies } = groupCurrenciesByProvider(
423
+ MOCK_TOKENS_ONLY as MappedAsset[],
424
+ currencies,
425
+ );
426
+
427
+ expect(Array.isArray(sortedCryptoCurrencies)).toBe(true);
428
+ expect(sortedCryptoCurrencies.length).toBeGreaterThan(0);
429
+
430
+ const tokenIds = sortedCryptoCurrencies.map(currency => currency.id);
431
+
432
+ expect(tokenIds).toContain("ethereum/erc20/usd_tether__erc20_");
433
+
434
+ sortedCryptoCurrencies.forEach(currency => {
435
+ expect(currency.type).toBe("TokenCurrency");
436
+ });
437
+
438
+ const hasExpectedNetworks = sortedCryptoCurrencies.every(currency =>
439
+ ["ethereum", "polygon", "bsc"].some(network => currency.id.includes(network)),
440
+ );
441
+ expect(hasExpectedNetworks).toBe(true);
442
+ });
443
+
444
+ it("should return empty array when no supported currencies", () => {
445
+ setSupportedCurrencies([]);
446
+ const currencies = sortCurrenciesByIds(
447
+ (listSupportedCurrencies() as CryptoOrTokenCurrency[]).concat(listSupportedTokens()),
448
+ MOCK_IDS,
449
+ );
450
+
451
+ const { sortedCryptoCurrencies } = groupCurrenciesByProvider(
452
+ [...TOKEN_ONLY_ASSETS, ...MOCK_WITH_TOKEN_AND_CURRENCY_ASSET] as MappedAsset[],
453
+ currencies,
454
+ );
455
+ expect(sortedCryptoCurrencies).toEqual([]);
456
+ });
457
+ });
458
+
459
+ describe("Comprehensive integration tests", () => {
460
+ it("should handle all supported currencies and tokens in the system", async () => {
461
+ // Set all major supported currencies from the live-common setup
462
+ setSupportedCurrencies([
463
+ "bitcoin",
464
+ "ethereum",
465
+ "bsc",
466
+ "polygon",
467
+ "arbitrum",
468
+ "optimism",
469
+ "avalanche_c_chain",
470
+ "solana",
471
+ "cardano",
472
+ "polkadot",
473
+ "cosmos",
474
+ "tron",
475
+ "stellar",
476
+ "hedera",
477
+ "near",
478
+ "sui",
479
+ ]);
480
+
481
+ const allSupportedCurrencies = listSupportedCurrencies() as CryptoOrTokenCurrency[];
482
+ const allSupportedTokens = listSupportedTokens();
483
+
484
+ // Test the full loadCurrenciesByProvider functionality
485
+ const result = await loadCurrenciesByProvider(
486
+ allSupportedCurrencies.concat(allSupportedTokens),
487
+ );
488
+
489
+ // Comprehensive validation
490
+ expect(result).toBeDefined();
491
+ expect(result.currenciesByProvider).toBeDefined();
492
+ expect(result.sortedCryptoCurrencies).toBeDefined();
493
+ expect(Array.isArray(result.currenciesByProvider)).toBe(true);
494
+ expect(Array.isArray(result.sortedCryptoCurrencies)).toBe(true);
495
+
496
+ // Should have meaningful results with this many currencies
497
+ expect(result.currenciesByProvider.length).toBeGreaterThan(0);
498
+ expect(result.sortedCryptoCurrencies.length).toBeGreaterThan(0);
499
+
500
+ // Validate structure of each provider group
501
+ result.currenciesByProvider.forEach(providerGroup => {
502
+ expect(providerGroup.providerId).toBeDefined();
503
+ expect(typeof providerGroup.providerId).toBe("string");
504
+ expect(Array.isArray(providerGroup.currenciesByNetwork)).toBe(true);
505
+ expect(providerGroup.currenciesByNetwork.length).toBeGreaterThan(0);
506
+
507
+ // Each currency in the group should be valid
508
+ providerGroup.currenciesByNetwork.forEach(currency => {
509
+ expect(currency.id).toBeDefined();
510
+ expect(currency.type).toMatch(/^(CryptoCurrency|TokenCurrency)$/);
511
+ });
512
+ });
513
+
514
+ // Validate sortedCryptoCurrencies
515
+ result.sortedCryptoCurrencies.forEach(currency => {
516
+ expect(currency.id).toBeDefined();
517
+ expect(currency.type).toMatch(/^(CryptoCurrency|TokenCurrency)$/);
518
+ });
519
+
520
+ // Should not have duplicates in sortedCryptoCurrencies
521
+ const sortedIds = result.sortedCryptoCurrencies.map(c => c.id);
522
+ const uniqueIds = new Set(sortedIds);
523
+ expect(sortedIds.length).toBe(uniqueIds.size);
524
+ });
525
+
526
+ it("should efficiently handle the intersection of all mock assets with all supported currencies", () => {
527
+ setSupportedCurrencies([
528
+ "bitcoin",
529
+ "ethereum",
530
+ "bsc",
531
+ "polygon",
532
+ "arbitrum",
533
+ "optimism",
534
+ "avalanche_c_chain",
535
+ "solana",
536
+ "cardano",
537
+ "polkadot",
538
+ "cosmos",
539
+ "tron",
540
+ "stellar",
541
+ "hedera",
542
+ "near",
543
+ "sui",
544
+ "litecoin",
545
+ "dogecoin",
546
+ ]);
547
+
548
+ const currencies = sortCurrenciesByIds(
549
+ (listSupportedCurrencies() as CryptoOrTokenCurrency[]).concat(listSupportedTokens()),
550
+ MOCK_IDS,
551
+ );
552
+
553
+ const allMockAssets = [
554
+ ...TOKEN_ONLY_ASSETS,
555
+ ...MOCK_WITH_TOKEN_AND_CURRENCY_ASSET,
556
+ ...MOCK_POL,
557
+ ] as MappedAsset[];
558
+
559
+ const startTime = Date.now();
560
+ const { currenciesByProvider, sortedCryptoCurrencies } = groupCurrenciesByProvider(
561
+ allMockAssets,
562
+ currencies,
563
+ );
564
+ const endTime = Date.now();
565
+
566
+ expect(endTime - startTime).toBeLessThan(100);
567
+
568
+ expect(Array.isArray(currenciesByProvider)).toBe(true);
569
+ expect(Array.isArray(sortedCryptoCurrencies)).toBe(true);
570
+
571
+ if (currenciesByProvider.length > 0) {
572
+ currenciesByProvider.forEach(provider => {
573
+ expect(provider.providerId).toBeDefined();
574
+ expect(provider.currenciesByNetwork.length).toBeGreaterThan(0);
575
+ });
576
+ }
577
+
578
+ if (sortedCryptoCurrencies.length > 0) {
579
+ sortedCryptoCurrencies.forEach(currency => {
580
+ expect(currency.type).toMatch(/^(CryptoCurrency|TokenCurrency)$/);
581
+ });
582
+ }
583
+ });
584
+
585
+ it("should demonstrate provider grouping behavior with diverse mock data", () => {
586
+ setSupportedCurrencies(["ethereum", "polygon", "arbitrum", "optimism"]);
587
+
588
+ const currencies = sortCurrenciesByIds(
589
+ (listSupportedCurrencies() as CryptoOrTokenCurrency[]).concat(listSupportedTokens()),
590
+ MOCK_IDS,
591
+ );
592
+
593
+ const { currenciesByProvider, sortedCryptoCurrencies } = groupCurrenciesByProvider(
594
+ [...TOKEN_ONLY_ASSETS, ...MOCK_WITH_TOKEN_AND_CURRENCY_ASSET, ...MOCK_POL] as MappedAsset[],
595
+ currencies,
596
+ );
597
+
598
+ const providerIds = new Set(currenciesByProvider.map(p => p.providerId));
599
+
600
+ const expectedProviders = ["tether", "ethereum", "matic-network"];
601
+ expectedProviders.forEach(expectedProvider => {
602
+ if (currenciesByProvider.some(p => p.providerId === expectedProvider)) {
603
+ expect(providerIds.has(expectedProvider)).toBe(true);
604
+ }
605
+ });
606
+
607
+ currenciesByProvider.forEach(provider => {
608
+ expect(provider.currenciesByNetwork.length).toBeGreaterThan(0);
609
+ provider.currenciesByNetwork.forEach(currency => {
610
+ expect(currency.id).toBeDefined();
611
+ expect(["CryptoCurrency", "TokenCurrency"].includes(currency.type)).toBe(true);
612
+ });
613
+ });
614
+
615
+ expect(sortedCryptoCurrencies.length).toBeLessThanOrEqual(providerIds.size);
616
+ });
617
+ });
618
+
619
+ describe("Error handling", () => {
620
+ test("should handle malformed asset data by throwing error", async () => {
621
+ const malformedAssets = [
622
+ { ...TOKEN_ONLY_ASSETS[0], ledgerId: undefined as any },
623
+ { ...TOKEN_ONLY_ASSETS[0], providerId: null as any },
624
+ ] as MappedAsset[];
625
+
626
+ const token = await getCryptoAssetsStore().findTokenById(TOKEN_ONLY_ASSETS[0].ledgerId);
627
+ if (!token) throw new Error("Token not found");
628
+ const currencies = [token];
629
+
630
+ expect(() => {
631
+ groupCurrenciesByProvider(malformedAssets, currencies);
632
+ }).toThrow();
633
+ });
634
+
635
+ test("should handle assets with null/undefined fields gracefully where possible", async () => {
636
+ const partiallyMalformedAssets = [
637
+ { ...TOKEN_ONLY_ASSETS[0], providerId: "" },
638
+ ] as MappedAsset[];
639
+
640
+ const token = await getCryptoAssetsStore().findTokenById(TOKEN_ONLY_ASSETS[0].ledgerId);
641
+ if (!token) throw new Error("Token not found");
642
+ const currencies = [token];
643
+
644
+ expect(() => {
645
+ groupCurrenciesByProvider(partiallyMalformedAssets, currencies);
646
+ }).not.toThrow();
647
+ });
648
+
649
+ test("should handle very large datasets efficiently", async () => {
650
+ const largeAssetList = Array(10000)
651
+ .fill(TOKEN_ONLY_ASSETS[0])
652
+ .map((asset, index) => ({
653
+ ...asset,
654
+ ledgerId: `${asset.ledgerId}_${index}`,
655
+ providerId: `provider_${index % 10}`,
656
+ })) as MappedAsset[];
657
+
658
+ const token = await getCryptoAssetsStore().findTokenById(TOKEN_ONLY_ASSETS[0].ledgerId);
659
+ if (!token) throw new Error("Token not found");
660
+ const currencies = [token];
661
+
662
+ const startTime = Date.now();
663
+ const result = groupCurrenciesByProvider(largeAssetList, currencies);
664
+ const endTime = Date.now();
665
+
666
+ expect(endTime - startTime).toBeLessThan(1000);
667
+ expect(result.currenciesByProvider).toBeDefined();
668
+ expect(result.sortedCryptoCurrencies).toBeDefined();
669
+ });
670
+
671
+ test("should handle case sensitivity in ledger IDs correctly", async () => {
672
+ const mixedCaseAssets = [
673
+ { ...TOKEN_ONLY_ASSETS[0], ledgerId: TOKEN_ONLY_ASSETS[0].ledgerId.toUpperCase() },
674
+ ] as MappedAsset[];
675
+
676
+ const token = await getCryptoAssetsStore().findTokenById(TOKEN_ONLY_ASSETS[0].ledgerId);
677
+ if (!token) throw new Error("Token not found");
678
+ const currencies = [token];
679
+ const { currenciesByProvider } = groupCurrenciesByProvider(mixedCaseAssets, currencies);
680
+
681
+ expect(currenciesByProvider).toHaveLength(1);
682
+ });
683
+ });
684
+ });