@ledgerhq/live-common 34.47.0-nightly.7 → 34.47.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 (370) hide show
  1. package/lib/bridge/crypto-assets/index.d.ts.map +1 -1
  2. package/lib/bridge/crypto-assets/index.js +0 -4
  3. package/lib/bridge/crypto-assets/index.js.map +1 -1
  4. package/lib/bridge/crypto-assets/index.test.js +0 -36
  5. package/lib/bridge/crypto-assets/index.test.js.map +1 -1
  6. package/lib/bridge/generic-alpaca/alpaca/index.d.ts.map +1 -1
  7. package/lib/bridge/generic-alpaca/alpaca/index.js +1 -6
  8. package/lib/bridge/generic-alpaca/alpaca/index.js.map +1 -1
  9. package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.js +1 -1
  10. package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.js.map +1 -1
  11. package/lib/bridge/generic-alpaca/buildSubAccounts.d.ts +3 -2
  12. package/lib/bridge/generic-alpaca/buildSubAccounts.d.ts.map +1 -1
  13. package/lib/bridge/generic-alpaca/buildSubAccounts.js +12 -3
  14. package/lib/bridge/generic-alpaca/buildSubAccounts.js.map +1 -1
  15. package/lib/bridge/generic-alpaca/getAccountShape.d.ts.map +1 -1
  16. package/lib/bridge/generic-alpaca/getAccountShape.js +4 -4
  17. package/lib/bridge/generic-alpaca/getAccountShape.js.map +1 -1
  18. package/lib/bridge/generic-alpaca/tests/utils.test.d.ts.map +1 -0
  19. package/lib/bridge/generic-alpaca/tests/utils.test.js +20 -0
  20. package/lib/bridge/generic-alpaca/tests/utils.test.js.map +1 -0
  21. package/lib/bridge/generic-alpaca/utils.d.ts.map +1 -1
  22. package/lib/bridge/generic-alpaca/utils.js +2 -5
  23. package/lib/bridge/generic-alpaca/utils.js.map +1 -1
  24. package/lib/e2e/enum/DeviceLabels.d.ts +1 -3
  25. package/lib/e2e/enum/DeviceLabels.d.ts.map +1 -1
  26. package/lib/e2e/enum/DeviceLabels.js +0 -2
  27. package/lib/e2e/enum/DeviceLabels.js.map +1 -1
  28. package/lib/e2e/families/tezos.d.ts.map +1 -1
  29. package/lib/e2e/families/tezos.js +0 -2
  30. package/lib/e2e/families/tezos.js.map +1 -1
  31. package/lib/e2e/index.d.ts +4 -4
  32. package/lib/e2e/speculos.d.ts +0 -1
  33. package/lib/e2e/speculos.d.ts.map +1 -1
  34. package/lib/e2e/speculos.js +2 -12
  35. package/lib/e2e/speculos.js.map +1 -1
  36. package/lib/exchange/platform/transfer/completeExchange.d.ts.map +1 -1
  37. package/lib/exchange/platform/transfer/completeExchange.js +5 -3
  38. package/lib/exchange/platform/transfer/completeExchange.js.map +1 -1
  39. package/lib/exchange/swap/completeExchange.d.ts.map +1 -1
  40. package/lib/exchange/swap/completeExchange.js +2 -5
  41. package/lib/exchange/swap/completeExchange.js.map +1 -1
  42. package/lib/exchange/swap/initSwap.d.ts.map +1 -1
  43. package/lib/exchange/swap/initSwap.js +2 -5
  44. package/lib/exchange/swap/initSwap.js.map +1 -1
  45. package/lib/families/canton/config.d.ts.map +1 -1
  46. package/lib/families/canton/config.js +0 -4
  47. package/lib/families/canton/config.js.map +1 -1
  48. package/lib/families/solana/setup.d.ts.map +1 -1
  49. package/lib/families/solana/setup.js +0 -9
  50. package/lib/families/solana/setup.js.map +1 -1
  51. package/lib/featureFlags/defaultFeatures.js +1 -1
  52. package/lib/featureFlags/defaultFeatures.js.map +1 -1
  53. package/lib/featureFlags/useFeature.d.ts +1 -1
  54. package/lib/featureFlags/useFeature.d.ts.map +1 -1
  55. package/lib/modularDrawer/data/state-manager/api.d.ts +37 -727
  56. package/lib/modularDrawer/data/state-manager/api.d.ts.map +1 -1
  57. package/lib/modularDrawer/data/state-manager/api.js +17 -38
  58. package/lib/modularDrawer/data/state-manager/api.js.map +1 -1
  59. package/lib/modularDrawer/hooks/__test__/useAssetsData.test.js +78 -134
  60. package/lib/modularDrawer/hooks/__test__/useAssetsData.test.js.map +1 -1
  61. package/{lib-es/modularDrawer/hooks → lib/modularDrawer/hooks/modules}/useAssetAccountCounts.d.ts +1 -1
  62. package/lib/modularDrawer/hooks/modules/useAssetAccountCounts.d.ts.map +1 -0
  63. package/lib/modularDrawer/hooks/{useAssetAccountCounts.js → modules/useAssetAccountCounts.js} +1 -1
  64. package/lib/modularDrawer/hooks/modules/useAssetAccountCounts.js.map +1 -0
  65. package/lib/modularDrawer/hooks/modules/useLeftApyModule.d.ts +3 -3
  66. package/lib/modularDrawer/hooks/modules/useLeftApyModule.d.ts.map +1 -1
  67. package/lib/modularDrawer/hooks/modules/useLeftApyModule.js +10 -59
  68. package/lib/modularDrawer/hooks/modules/useLeftApyModule.js.map +1 -1
  69. package/lib/modularDrawer/hooks/useAssetsData.d.ts +6 -10
  70. package/lib/modularDrawer/hooks/useAssetsData.d.ts.map +1 -1
  71. package/lib/modularDrawer/hooks/useAssetsData.js +17 -40
  72. package/lib/modularDrawer/hooks/useAssetsData.js.map +1 -1
  73. package/lib/modularDrawer/types.d.ts +2 -0
  74. package/lib/modularDrawer/types.d.ts.map +1 -0
  75. package/lib/modularDrawer/types.js +3 -0
  76. package/lib/modularDrawer/types.js.map +1 -0
  77. package/lib/modularDrawer/utils/type.d.ts +1 -89
  78. package/lib/modularDrawer/utils/type.d.ts.map +1 -1
  79. package/lib/wallet-api/Exchange/server.js +2 -2
  80. package/lib/wallet-api/Exchange/server.js.map +1 -1
  81. package/lib/wallet-api/react.d.ts +0 -2
  82. package/lib/wallet-api/react.d.ts.map +1 -1
  83. package/lib/wallet-api/react.js +1 -3
  84. package/lib/wallet-api/react.js.map +1 -1
  85. package/lib-es/bridge/crypto-assets/index.d.ts.map +1 -1
  86. package/lib-es/bridge/crypto-assets/index.js +0 -4
  87. package/lib-es/bridge/crypto-assets/index.js.map +1 -1
  88. package/lib-es/bridge/crypto-assets/index.test.js +0 -36
  89. package/lib-es/bridge/crypto-assets/index.test.js.map +1 -1
  90. package/lib-es/bridge/generic-alpaca/alpaca/index.d.ts.map +1 -1
  91. package/lib-es/bridge/generic-alpaca/alpaca/index.js +1 -6
  92. package/lib-es/bridge/generic-alpaca/alpaca/index.js.map +1 -1
  93. package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.js +1 -1
  94. package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.js.map +1 -1
  95. package/lib-es/bridge/generic-alpaca/buildSubAccounts.d.ts +3 -2
  96. package/lib-es/bridge/generic-alpaca/buildSubAccounts.d.ts.map +1 -1
  97. package/lib-es/bridge/generic-alpaca/buildSubAccounts.js +9 -2
  98. package/lib-es/bridge/generic-alpaca/buildSubAccounts.js.map +1 -1
  99. package/lib-es/bridge/generic-alpaca/getAccountShape.d.ts.map +1 -1
  100. package/lib-es/bridge/generic-alpaca/getAccountShape.js +3 -3
  101. package/lib-es/bridge/generic-alpaca/getAccountShape.js.map +1 -1
  102. package/lib-es/bridge/generic-alpaca/tests/utils.test.d.ts.map +1 -0
  103. package/lib-es/bridge/generic-alpaca/tests/utils.test.js +18 -0
  104. package/lib-es/bridge/generic-alpaca/tests/utils.test.js.map +1 -0
  105. package/lib-es/bridge/generic-alpaca/utils.d.ts.map +1 -1
  106. package/lib-es/bridge/generic-alpaca/utils.js +2 -5
  107. package/lib-es/bridge/generic-alpaca/utils.js.map +1 -1
  108. package/lib-es/e2e/enum/DeviceLabels.d.ts +1 -3
  109. package/lib-es/e2e/enum/DeviceLabels.d.ts.map +1 -1
  110. package/lib-es/e2e/enum/DeviceLabels.js +0 -2
  111. package/lib-es/e2e/enum/DeviceLabels.js.map +1 -1
  112. package/lib-es/e2e/families/tezos.d.ts.map +1 -1
  113. package/lib-es/e2e/families/tezos.js +0 -2
  114. package/lib-es/e2e/families/tezos.js.map +1 -1
  115. package/lib-es/e2e/index.d.ts +4 -4
  116. package/lib-es/e2e/speculos.d.ts +0 -1
  117. package/lib-es/e2e/speculos.d.ts.map +1 -1
  118. package/lib-es/e2e/speculos.js +1 -10
  119. package/lib-es/e2e/speculos.js.map +1 -1
  120. package/lib-es/exchange/platform/transfer/completeExchange.d.ts.map +1 -1
  121. package/lib-es/exchange/platform/transfer/completeExchange.js +2 -3
  122. package/lib-es/exchange/platform/transfer/completeExchange.js.map +1 -1
  123. package/lib-es/exchange/swap/completeExchange.d.ts.map +1 -1
  124. package/lib-es/exchange/swap/completeExchange.js +2 -5
  125. package/lib-es/exchange/swap/completeExchange.js.map +1 -1
  126. package/lib-es/exchange/swap/initSwap.d.ts.map +1 -1
  127. package/lib-es/exchange/swap/initSwap.js +2 -5
  128. package/lib-es/exchange/swap/initSwap.js.map +1 -1
  129. package/lib-es/families/canton/config.d.ts.map +1 -1
  130. package/lib-es/families/canton/config.js +0 -4
  131. package/lib-es/families/canton/config.js.map +1 -1
  132. package/lib-es/families/solana/setup.d.ts.map +1 -1
  133. package/lib-es/families/solana/setup.js +0 -9
  134. package/lib-es/families/solana/setup.js.map +1 -1
  135. package/lib-es/featureFlags/defaultFeatures.js +1 -1
  136. package/lib-es/featureFlags/defaultFeatures.js.map +1 -1
  137. package/lib-es/featureFlags/useFeature.d.ts +1 -1
  138. package/lib-es/featureFlags/useFeature.d.ts.map +1 -1
  139. package/lib-es/modularDrawer/data/state-manager/api.d.ts +37 -727
  140. package/lib-es/modularDrawer/data/state-manager/api.d.ts.map +1 -1
  141. package/lib-es/modularDrawer/data/state-manager/api.js +14 -35
  142. package/lib-es/modularDrawer/data/state-manager/api.js.map +1 -1
  143. package/lib-es/modularDrawer/hooks/__test__/useAssetsData.test.js +79 -135
  144. package/lib-es/modularDrawer/hooks/__test__/useAssetsData.test.js.map +1 -1
  145. package/{lib/modularDrawer/hooks → lib-es/modularDrawer/hooks/modules}/useAssetAccountCounts.d.ts +1 -1
  146. package/lib-es/modularDrawer/hooks/modules/useAssetAccountCounts.d.ts.map +1 -0
  147. package/lib-es/modularDrawer/hooks/{useAssetAccountCounts.js → modules/useAssetAccountCounts.js} +1 -1
  148. package/lib-es/modularDrawer/hooks/modules/useAssetAccountCounts.js.map +1 -0
  149. package/lib-es/modularDrawer/hooks/modules/useLeftApyModule.d.ts +3 -3
  150. package/lib-es/modularDrawer/hooks/modules/useLeftApyModule.d.ts.map +1 -1
  151. package/lib-es/modularDrawer/hooks/modules/useLeftApyModule.js +8 -37
  152. package/lib-es/modularDrawer/hooks/modules/useLeftApyModule.js.map +1 -1
  153. package/lib-es/modularDrawer/hooks/useAssetsData.d.ts +6 -10
  154. package/lib-es/modularDrawer/hooks/useAssetsData.d.ts.map +1 -1
  155. package/lib-es/modularDrawer/hooks/useAssetsData.js +19 -42
  156. package/lib-es/modularDrawer/hooks/useAssetsData.js.map +1 -1
  157. package/lib-es/modularDrawer/types.d.ts +2 -0
  158. package/lib-es/modularDrawer/types.d.ts.map +1 -0
  159. package/lib-es/modularDrawer/types.js +2 -0
  160. package/lib-es/modularDrawer/types.js.map +1 -0
  161. package/lib-es/modularDrawer/utils/type.d.ts +1 -89
  162. package/lib-es/modularDrawer/utils/type.d.ts.map +1 -1
  163. package/lib-es/wallet-api/Exchange/server.js +2 -2
  164. package/lib-es/wallet-api/Exchange/server.js.map +1 -1
  165. package/lib-es/wallet-api/react.d.ts +0 -2
  166. package/lib-es/wallet-api/react.d.ts.map +1 -1
  167. package/lib-es/wallet-api/react.js +1 -3
  168. package/lib-es/wallet-api/react.js.map +1 -1
  169. package/package.json +77 -77
  170. package/src/bridge/crypto-assets/index.test.ts +0 -47
  171. package/src/bridge/crypto-assets/index.ts +0 -5
  172. package/src/bridge/generic-alpaca/alpaca/index.ts +1 -14
  173. package/src/bridge/generic-alpaca/alpaca/network/network-alpaca.ts +1 -1
  174. package/src/bridge/generic-alpaca/buildSubAccounts.ts +11 -3
  175. package/src/bridge/generic-alpaca/getAccountShape.ts +4 -3
  176. package/src/bridge/generic-alpaca/tests/utils.test.ts +19 -0
  177. package/src/bridge/generic-alpaca/utils.ts +2 -6
  178. package/src/e2e/enum/DeviceLabels.ts +0 -2
  179. package/src/e2e/families/tezos.ts +0 -2
  180. package/src/e2e/speculos.ts +1 -11
  181. package/src/exchange/platform/transfer/completeExchange.ts +2 -3
  182. package/src/exchange/swap/completeExchange.ts +2 -5
  183. package/src/exchange/swap/initSwap.ts +4 -5
  184. package/src/families/canton/config.ts +0 -5
  185. package/src/families/solana/setup.ts +0 -9
  186. package/src/featureFlags/defaultFeatures.ts +1 -1
  187. package/src/modularDrawer/data/state-manager/api.ts +27 -42
  188. package/src/modularDrawer/hooks/__test__/useAssetsData.test.ts +80 -141
  189. package/src/modularDrawer/hooks/{useAssetAccountCounts.tsx → modules/useAssetAccountCounts.tsx} +2 -2
  190. package/src/modularDrawer/hooks/modules/useLeftApyModule.tsx +9 -42
  191. package/src/modularDrawer/hooks/useAssetsData.ts +22 -59
  192. package/src/modularDrawer/types.ts +1 -0
  193. package/src/modularDrawer/utils/type.ts +0 -97
  194. package/src/wallet-api/Exchange/server.ts +2 -2
  195. package/src/wallet-api/react.ts +1 -5
  196. package/lib/bridge/crypto-assets/cal-integration.d.ts +0 -4
  197. package/lib/bridge/crypto-assets/cal-integration.d.ts.map +0 -1
  198. package/lib/bridge/crypto-assets/cal-integration.js +0 -26
  199. package/lib/bridge/crypto-assets/cal-integration.js.map +0 -1
  200. package/lib/bridge/crypto-assets/cal-integration.test.d.ts +0 -2
  201. package/lib/bridge/crypto-assets/cal-integration.test.d.ts.map +0 -1
  202. package/lib/bridge/crypto-assets/cal-integration.test.js +0 -45
  203. package/lib/bridge/crypto-assets/cal-integration.test.js.map +0 -1
  204. package/lib/bridge/crypto-assets/cal-store.d.ts +0 -14
  205. package/lib/bridge/crypto-assets/cal-store.d.ts.map +0 -1
  206. package/lib/bridge/crypto-assets/cal-store.js +0 -58
  207. package/lib/bridge/crypto-assets/cal-store.js.map +0 -1
  208. package/lib/bridge/crypto-assets/cal-store.test.d.ts +0 -2
  209. package/lib/bridge/crypto-assets/cal-store.test.d.ts.map +0 -1
  210. package/lib/bridge/crypto-assets/cal-store.test.js +0 -70
  211. package/lib/bridge/crypto-assets/cal-store.test.js.map +0 -1
  212. package/lib/bridge/generic-alpaca/alpaca/index.unit.test.d.ts +0 -2
  213. package/lib/bridge/generic-alpaca/alpaca/index.unit.test.d.ts.map +0 -1
  214. package/lib/bridge/generic-alpaca/alpaca/index.unit.test.js +0 -89
  215. package/lib/bridge/generic-alpaca/alpaca/index.unit.test.js.map +0 -1
  216. package/lib/bridge/generic-alpaca/utils.test.d.ts.map +0 -1
  217. package/lib/bridge/generic-alpaca/utils.test.js +0 -123
  218. package/lib/bridge/generic-alpaca/utils.test.js.map +0 -1
  219. package/lib/modularDrawer/__mocks__/dada.mock.d.ts +0 -3336
  220. package/lib/modularDrawer/__mocks__/dada.mock.d.ts.map +0 -1
  221. package/lib/modularDrawer/__mocks__/dada.mock.js +0 -3879
  222. package/lib/modularDrawer/__mocks__/dada.mock.js.map +0 -1
  223. package/lib/modularDrawer/data/entities/interestRateSelectors.d.ts +0 -16
  224. package/lib/modularDrawer/data/entities/interestRateSelectors.d.ts.map +0 -1
  225. package/lib/modularDrawer/data/entities/interestRateSelectors.js +0 -21
  226. package/lib/modularDrawer/data/entities/interestRateSelectors.js.map +0 -1
  227. package/lib/modularDrawer/data/state-manager/types.d.ts +0 -24
  228. package/lib/modularDrawer/data/state-manager/types.d.ts.map +0 -1
  229. package/lib/modularDrawer/data/state-manager/types.js +0 -13
  230. package/lib/modularDrawer/data/state-manager/types.js.map +0 -1
  231. package/lib/modularDrawer/hooks/useAssetAccountCounts.d.ts.map +0 -1
  232. package/lib/modularDrawer/hooks/useAssetAccountCounts.js.map +0 -1
  233. package/lib/modularDrawer/hooks/useLeftAccounts.d.ts +0 -13
  234. package/lib/modularDrawer/hooks/useLeftAccounts.d.ts.map +0 -1
  235. package/lib/modularDrawer/hooks/useLeftAccounts.js +0 -15
  236. package/lib/modularDrawer/hooks/useLeftAccounts.js.map +0 -1
  237. package/lib/modularDrawer/hooks/useLeftAccountsApy.d.ts +0 -6
  238. package/lib/modularDrawer/hooks/useLeftAccountsApy.d.ts.map +0 -1
  239. package/lib/modularDrawer/hooks/useLeftAccountsApy.js +0 -19
  240. package/lib/modularDrawer/hooks/useLeftAccountsApy.js.map +0 -1
  241. package/lib/modularDrawer/hooks/useLeftApy.d.ts +0 -54
  242. package/lib/modularDrawer/hooks/useLeftApy.d.ts.map +0 -1
  243. package/lib/modularDrawer/hooks/useLeftApy.js +0 -15
  244. package/lib/modularDrawer/hooks/useLeftApy.js.map +0 -1
  245. package/lib/modularDrawer/hooks/useRightBalanceAsset.d.ts +0 -57
  246. package/lib/modularDrawer/hooks/useRightBalanceAsset.d.ts.map +0 -1
  247. package/lib/modularDrawer/hooks/useRightBalanceAsset.js +0 -87
  248. package/lib/modularDrawer/hooks/useRightBalanceAsset.js.map +0 -1
  249. package/lib/modularDrawer/hooks/useRightBalanceNetwork.d.ts +0 -63
  250. package/lib/modularDrawer/hooks/useRightBalanceNetwork.d.ts.map +0 -1
  251. package/lib/modularDrawer/hooks/useRightBalanceNetwork.js +0 -66
  252. package/lib/modularDrawer/hooks/useRightBalanceNetwork.js.map +0 -1
  253. package/lib/modularDrawer/modules/createAssetConfiguration.d.ts +0 -4
  254. package/lib/modularDrawer/modules/createAssetConfiguration.d.ts.map +0 -1
  255. package/lib/modularDrawer/modules/createAssetConfiguration.js +0 -41
  256. package/lib/modularDrawer/modules/createAssetConfiguration.js.map +0 -1
  257. package/lib/modularDrawer/modules/createNetworkConfiguration.d.ts +0 -6
  258. package/lib/modularDrawer/modules/createNetworkConfiguration.d.ts.map +0 -1
  259. package/lib/modularDrawer/modules/createNetworkConfiguration.js +0 -56
  260. package/lib/modularDrawer/modules/createNetworkConfiguration.js.map +0 -1
  261. package/lib/modularDrawer/utils/buildProviderCurrenciesMap.d.ts +0 -9
  262. package/lib/modularDrawer/utils/buildProviderCurrenciesMap.d.ts.map +0 -1
  263. package/lib/modularDrawer/utils/buildProviderCurrenciesMap.js +0 -17
  264. package/lib/modularDrawer/utils/buildProviderCurrenciesMap.js.map +0 -1
  265. package/lib/modularDrawer/utils/getLoadingStatus.d.ts +0 -9
  266. package/lib/modularDrawer/utils/getLoadingStatus.d.ts.map +0 -1
  267. package/lib/modularDrawer/utils/getLoadingStatus.js +0 -18
  268. package/lib/modularDrawer/utils/getLoadingStatus.js.map +0 -1
  269. package/lib/modularDrawer/utils/sortByBalance.d.ts +0 -6
  270. package/lib/modularDrawer/utils/sortByBalance.d.ts.map +0 -1
  271. package/lib/modularDrawer/utils/sortByBalance.js +0 -32
  272. package/lib/modularDrawer/utils/sortByBalance.js.map +0 -1
  273. package/lib-es/bridge/crypto-assets/cal-integration.d.ts +0 -4
  274. package/lib-es/bridge/crypto-assets/cal-integration.d.ts.map +0 -1
  275. package/lib-es/bridge/crypto-assets/cal-integration.js +0 -21
  276. package/lib-es/bridge/crypto-assets/cal-integration.js.map +0 -1
  277. package/lib-es/bridge/crypto-assets/cal-integration.test.d.ts +0 -2
  278. package/lib-es/bridge/crypto-assets/cal-integration.test.d.ts.map +0 -1
  279. package/lib-es/bridge/crypto-assets/cal-integration.test.js +0 -43
  280. package/lib-es/bridge/crypto-assets/cal-integration.test.js.map +0 -1
  281. package/lib-es/bridge/crypto-assets/cal-store.d.ts +0 -14
  282. package/lib-es/bridge/crypto-assets/cal-store.d.ts.map +0 -1
  283. package/lib-es/bridge/crypto-assets/cal-store.js +0 -54
  284. package/lib-es/bridge/crypto-assets/cal-store.js.map +0 -1
  285. package/lib-es/bridge/crypto-assets/cal-store.test.d.ts +0 -2
  286. package/lib-es/bridge/crypto-assets/cal-store.test.d.ts.map +0 -1
  287. package/lib-es/bridge/crypto-assets/cal-store.test.js +0 -68
  288. package/lib-es/bridge/crypto-assets/cal-store.test.js.map +0 -1
  289. package/lib-es/bridge/generic-alpaca/alpaca/index.unit.test.d.ts +0 -2
  290. package/lib-es/bridge/generic-alpaca/alpaca/index.unit.test.d.ts.map +0 -1
  291. package/lib-es/bridge/generic-alpaca/alpaca/index.unit.test.js +0 -64
  292. package/lib-es/bridge/generic-alpaca/alpaca/index.unit.test.js.map +0 -1
  293. package/lib-es/bridge/generic-alpaca/utils.test.d.ts.map +0 -1
  294. package/lib-es/bridge/generic-alpaca/utils.test.js +0 -118
  295. package/lib-es/bridge/generic-alpaca/utils.test.js.map +0 -1
  296. package/lib-es/modularDrawer/__mocks__/dada.mock.d.ts +0 -3336
  297. package/lib-es/modularDrawer/__mocks__/dada.mock.d.ts.map +0 -1
  298. package/lib-es/modularDrawer/__mocks__/dada.mock.js +0 -3876
  299. package/lib-es/modularDrawer/__mocks__/dada.mock.js.map +0 -1
  300. package/lib-es/modularDrawer/data/entities/interestRateSelectors.d.ts +0 -16
  301. package/lib-es/modularDrawer/data/entities/interestRateSelectors.d.ts.map +0 -1
  302. package/lib-es/modularDrawer/data/entities/interestRateSelectors.js +0 -18
  303. package/lib-es/modularDrawer/data/entities/interestRateSelectors.js.map +0 -1
  304. package/lib-es/modularDrawer/data/state-manager/types.d.ts +0 -24
  305. package/lib-es/modularDrawer/data/state-manager/types.d.ts.map +0 -1
  306. package/lib-es/modularDrawer/data/state-manager/types.js +0 -10
  307. package/lib-es/modularDrawer/data/state-manager/types.js.map +0 -1
  308. package/lib-es/modularDrawer/hooks/useAssetAccountCounts.d.ts.map +0 -1
  309. package/lib-es/modularDrawer/hooks/useAssetAccountCounts.js.map +0 -1
  310. package/lib-es/modularDrawer/hooks/useLeftAccounts.d.ts +0 -13
  311. package/lib-es/modularDrawer/hooks/useLeftAccounts.d.ts.map +0 -1
  312. package/lib-es/modularDrawer/hooks/useLeftAccounts.js +0 -11
  313. package/lib-es/modularDrawer/hooks/useLeftAccounts.js.map +0 -1
  314. package/lib-es/modularDrawer/hooks/useLeftAccountsApy.d.ts +0 -6
  315. package/lib-es/modularDrawer/hooks/useLeftAccountsApy.d.ts.map +0 -1
  316. package/lib-es/modularDrawer/hooks/useLeftAccountsApy.js +0 -15
  317. package/lib-es/modularDrawer/hooks/useLeftAccountsApy.js.map +0 -1
  318. package/lib-es/modularDrawer/hooks/useLeftApy.d.ts +0 -54
  319. package/lib-es/modularDrawer/hooks/useLeftApy.d.ts.map +0 -1
  320. package/lib-es/modularDrawer/hooks/useLeftApy.js +0 -11
  321. package/lib-es/modularDrawer/hooks/useLeftApy.js.map +0 -1
  322. package/lib-es/modularDrawer/hooks/useRightBalanceAsset.d.ts +0 -57
  323. package/lib-es/modularDrawer/hooks/useRightBalanceAsset.d.ts.map +0 -1
  324. package/lib-es/modularDrawer/hooks/useRightBalanceAsset.js +0 -83
  325. package/lib-es/modularDrawer/hooks/useRightBalanceAsset.js.map +0 -1
  326. package/lib-es/modularDrawer/hooks/useRightBalanceNetwork.d.ts +0 -63
  327. package/lib-es/modularDrawer/hooks/useRightBalanceNetwork.d.ts.map +0 -1
  328. package/lib-es/modularDrawer/hooks/useRightBalanceNetwork.js +0 -62
  329. package/lib-es/modularDrawer/hooks/useRightBalanceNetwork.js.map +0 -1
  330. package/lib-es/modularDrawer/modules/createAssetConfiguration.d.ts +0 -4
  331. package/lib-es/modularDrawer/modules/createAssetConfiguration.d.ts.map +0 -1
  332. package/lib-es/modularDrawer/modules/createAssetConfiguration.js +0 -39
  333. package/lib-es/modularDrawer/modules/createAssetConfiguration.js.map +0 -1
  334. package/lib-es/modularDrawer/modules/createNetworkConfiguration.d.ts +0 -6
  335. package/lib-es/modularDrawer/modules/createNetworkConfiguration.d.ts.map +0 -1
  336. package/lib-es/modularDrawer/modules/createNetworkConfiguration.js +0 -50
  337. package/lib-es/modularDrawer/modules/createNetworkConfiguration.js.map +0 -1
  338. package/lib-es/modularDrawer/utils/buildProviderCurrenciesMap.d.ts +0 -9
  339. package/lib-es/modularDrawer/utils/buildProviderCurrenciesMap.d.ts.map +0 -1
  340. package/lib-es/modularDrawer/utils/buildProviderCurrenciesMap.js +0 -13
  341. package/lib-es/modularDrawer/utils/buildProviderCurrenciesMap.js.map +0 -1
  342. package/lib-es/modularDrawer/utils/getLoadingStatus.d.ts +0 -9
  343. package/lib-es/modularDrawer/utils/getLoadingStatus.d.ts.map +0 -1
  344. package/lib-es/modularDrawer/utils/getLoadingStatus.js +0 -14
  345. package/lib-es/modularDrawer/utils/getLoadingStatus.js.map +0 -1
  346. package/lib-es/modularDrawer/utils/sortByBalance.d.ts +0 -6
  347. package/lib-es/modularDrawer/utils/sortByBalance.d.ts.map +0 -1
  348. package/lib-es/modularDrawer/utils/sortByBalance.js +0 -25
  349. package/lib-es/modularDrawer/utils/sortByBalance.js.map +0 -1
  350. package/src/bridge/crypto-assets/cal-integration.test.ts +0 -53
  351. package/src/bridge/crypto-assets/cal-integration.ts +0 -23
  352. package/src/bridge/crypto-assets/cal-store.test.ts +0 -93
  353. package/src/bridge/crypto-assets/cal-store.ts +0 -63
  354. package/src/bridge/generic-alpaca/alpaca/index.unit.test.ts +0 -78
  355. package/src/bridge/generic-alpaca/utils.test.ts +0 -133
  356. package/src/modularDrawer/__mocks__/dada.mock.ts +0 -3890
  357. package/src/modularDrawer/data/entities/interestRateSelectors.ts +0 -39
  358. package/src/modularDrawer/data/state-manager/types.ts +0 -28
  359. package/src/modularDrawer/hooks/useLeftAccounts.tsx +0 -23
  360. package/src/modularDrawer/hooks/useLeftAccountsApy.tsx +0 -28
  361. package/src/modularDrawer/hooks/useLeftApy.tsx +0 -19
  362. package/src/modularDrawer/hooks/useRightBalanceAsset.tsx +0 -140
  363. package/src/modularDrawer/hooks/useRightBalanceNetwork.tsx +0 -116
  364. package/src/modularDrawer/modules/createAssetConfiguration.ts +0 -61
  365. package/src/modularDrawer/modules/createNetworkConfiguration.ts +0 -79
  366. package/src/modularDrawer/utils/buildProviderCurrenciesMap.tsx +0 -25
  367. package/src/modularDrawer/utils/getLoadingStatus.ts +0 -24
  368. package/src/modularDrawer/utils/sortByBalance.tsx +0 -32
  369. /package/lib/bridge/generic-alpaca/{utils.test.d.ts → tests/utils.test.d.ts} +0 -0
  370. /package/lib-es/bridge/generic-alpaca/{utils.test.d.ts → tests/utils.test.d.ts} +0 -0
@@ -1,39 +0,0 @@
1
- import { createSelector } from "@reduxjs/toolkit";
2
- import { InterestRate } from "../entities";
3
-
4
- interface ApiState {
5
- assetsDataApi?: {
6
- queries?: Record<string, QueryCacheEntry>;
7
- };
8
- }
9
-
10
- interface QueryCacheEntry {
11
- data?: {
12
- pages?: Array<{
13
- interestRates?: Record<string, InterestRate>;
14
- }>;
15
- };
16
- }
17
-
18
- export const selectInterestRateByCurrency: (
19
- state: ApiState,
20
- currencyId: string,
21
- ) => InterestRate | undefined = createSelector(
22
- [
23
- (state: ApiState) => state.assetsDataApi?.queries ?? {},
24
- (_state: ApiState, currencyId: string) => currencyId,
25
- ],
26
- (queries, currencyId): InterestRate | undefined => {
27
- for (const query of Object.values(queries)) {
28
- const pages = query.data?.pages;
29
- if (!pages) continue;
30
-
31
- for (const page of pages) {
32
- const rate = page.interestRates?.[currencyId];
33
- if (rate) return rate;
34
- }
35
- }
36
-
37
- return undefined;
38
- },
39
- );
@@ -1,28 +0,0 @@
1
- import { AssetsData } from "../entities";
2
-
3
- export enum AssetsDataTags {
4
- Assets = "Assets",
5
- }
6
-
7
- export enum AssetsAdditionalData {
8
- Apy = "apy",
9
- MarketTrend = "marketTrend",
10
- }
11
-
12
- export interface GetAssetsDataParams {
13
- search?: string;
14
- currencyIds?: string[];
15
- useCase?: string;
16
- product: "llm" | "lld";
17
- version: string;
18
- }
19
-
20
- export interface PageParam {
21
- cursor?: string;
22
- }
23
-
24
- export interface AssetsDataWithPagination extends AssetsData {
25
- pagination: {
26
- nextCursor?: string;
27
- };
28
- }
@@ -1,23 +0,0 @@
1
- import { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
2
- import { ReactNode } from "react";
3
- import { AccountModuleParams, AccountDataItem } from "../utils/type";
4
-
5
- export const createUseLeftAccountsModule = ({
6
- useAccountData,
7
- accountsCount,
8
- }: {
9
- useAccountData: (params: AccountModuleParams) => AccountDataItem[];
10
- accountsCount: (args: { label: string }) => ReactNode;
11
- }) => {
12
- return function useLeftAccountsModule(
13
- params: AccountModuleParams,
14
- ): Array<CryptoOrTokenCurrency & { leftElement?: ReactNode; count: number }> {
15
- const accountData = useAccountData(params);
16
-
17
- return accountData.map(({ asset, label, count }) => ({
18
- ...asset,
19
- leftElement: count > 0 ? accountsCount({ label }) : undefined,
20
- count,
21
- }));
22
- };
23
- };
@@ -1,28 +0,0 @@
1
- import {
2
- AccountDataItem,
3
- AccountModuleParams,
4
- CreateAccountsCountAndApy,
5
- NetworkWithCount,
6
- } from "../utils/type";
7
-
8
- export const createUseLeftAccountsApyModule = ({
9
- useAccountData,
10
- accountsCountAndApy,
11
- }: {
12
- useAccountData: (params: AccountModuleParams) => AccountDataItem[];
13
- accountsCountAndApy: CreateAccountsCountAndApy;
14
- }) => {
15
- return function useLeftAccountsApyModule(params: AccountModuleParams): NetworkWithCount[] {
16
- const accountData = useAccountData(params);
17
-
18
- return accountData.map(({ asset, label, count }) => {
19
- const value = 5.11; // TODO to be retrieved from DADA
20
- const type = "APY"; // TODO to be retrieved from DADA
21
- return {
22
- ...asset,
23
- leftElement: count > 0 ? accountsCountAndApy({ label, value, type }) : undefined,
24
- count,
25
- };
26
- });
27
- };
28
- };
@@ -1,19 +0,0 @@
1
- import type { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
2
- import { ReactNode } from "react";
3
- import { ApyType } from "../utils/type";
4
-
5
- export const createUseLeftApyModule = ({
6
- ApyIndicator,
7
- }: {
8
- ApyIndicator: (args: { value: number; type: ApyType }) => ReactNode;
9
- }) => {
10
- return (assets: CryptoOrTokenCurrency[]) => {
11
- const value = 5.11; // TODO: fetch DADA
12
- const type: ApyType = "APY"; // TODO: fetch DADA
13
-
14
- return assets.map(asset => ({
15
- ...asset,
16
- leftElement: ApyIndicator({ value, type }),
17
- }));
18
- };
19
- };
@@ -1,140 +0,0 @@
1
- import { useMemo } from "react";
2
- import type { ReactNode } from "react";
3
- import type { CryptoOrTokenCurrency, Currency } from "@ledgerhq/types-cryptoassets";
4
- import { formatCurrencyUnit } from "@ledgerhq/coin-framework/currencies/formatCurrencyUnit";
5
- import BigNumber from "bignumber.js";
6
- import { counterValueFormatter } from "../utils/counterValueFormatter";
7
- import { compareByBalanceThenFiat } from "../utils/sortByBalance";
8
- import { UseBalanceDeps } from "../utils/type";
9
- import { buildProviderCurrenciesMap } from "../utils/buildProviderCurrenciesMap";
10
- import { CurrenciesByProviderId } from "../../deposit/type";
11
- import { calculateProviderTotals } from "../utils/calculateProviderTotal";
12
- import { getProviderCurrency } from "../utils/getProviderCurrency";
13
- import { getBalanceAndFiatValueByAssets } from "../utils/getBalanceAndFiatValueByAssets";
14
- import { groupAccountsByAsset } from "../utils/groupAccountsByAsset";
15
-
16
- export type AssetDeps = {
17
- useBalanceDeps: UseBalanceDeps;
18
- balanceItem: (asset: { fiatValue?: string; balance?: string }) => ReactNode;
19
- };
20
-
21
- export function createUseRightBalanceAsset({ useBalanceDeps, balanceItem }: AssetDeps) {
22
- const formatProviderResult = (
23
- providerCurrency: CryptoOrTokenCurrency,
24
- totalBalance: BigNumber,
25
- totalFiatValue: BigNumber,
26
- counterValueCurrency: Currency,
27
- locale: string,
28
- discreet: boolean,
29
- ) => {
30
- const unit = providerCurrency.units?.[0];
31
- const balance = unit
32
- ? formatCurrencyUnit(unit, totalBalance, { showCode: true, discreet })
33
- : `${totalBalance.toFixed()} ${providerCurrency.ticker ?? providerCurrency.symbol}`;
34
- const fiatValue = counterValueFormatter({
35
- currency: counterValueCurrency.ticker,
36
- value: totalFiatValue.toNumber(),
37
- locale,
38
- allowZeroValue: true,
39
- });
40
- return { balance, fiatValue };
41
- };
42
-
43
- return function useRightBalanceAsset(
44
- assets: CryptoOrTokenCurrency[],
45
- currenciesByProvider: CurrenciesByProviderId[],
46
- ) {
47
- const { flattenedAccounts, discreet, state, counterValueCurrency, locale } = useBalanceDeps();
48
-
49
- const grouped = useMemo(
50
- () => groupAccountsByAsset(flattenedAccounts, state, counterValueCurrency, discreet),
51
- [flattenedAccounts, state, counterValueCurrency, discreet],
52
- );
53
-
54
- const providerMap = useMemo(
55
- () => buildProviderCurrenciesMap(currenciesByProvider),
56
- [currenciesByProvider],
57
- );
58
-
59
- return useMemo(() => {
60
- if (!providerMap) {
61
- const allBalance = getBalanceAndFiatValueByAssets(
62
- flattenedAccounts,
63
- assets,
64
- state,
65
- counterValueCurrency,
66
- discreet,
67
- locale,
68
- );
69
- const balanceMap = new Map(allBalance.map(b => [b.id, b]));
70
- const assetsWithBalanceData = assets.map(asset => {
71
- const balanceData = balanceMap.get(asset.id) || {};
72
- return {
73
- asset,
74
- balanceData,
75
- };
76
- });
77
-
78
- assetsWithBalanceData.sort((a, b) =>
79
- compareByBalanceThenFiat(a.balanceData, b.balanceData, discreet),
80
- );
81
-
82
- return assetsWithBalanceData.map(({ asset, balanceData }) => ({
83
- ...asset,
84
- rightElement: balanceItem(balanceData),
85
- }));
86
- }
87
-
88
- const assetsSet = new Set(assets.map(a => a.id));
89
- const providerResultsMap = new Map<string, { balance?: string; fiatValue?: string }>();
90
-
91
- for (const [, { currencies, mainCurrency }] of providerMap) {
92
- if (!assetsSet.has(mainCurrency.id)) continue;
93
- const providerCurrency = getProviderCurrency(mainCurrency, currencies);
94
- if (!providerCurrency) continue;
95
-
96
- const { totalBalance, totalFiatValue, hasAccounts } = calculateProviderTotals(
97
- currencies,
98
- grouped,
99
- );
100
- if (!hasAccounts) continue;
101
-
102
- const { balance, fiatValue } = formatProviderResult(
103
- providerCurrency,
104
- totalBalance,
105
- totalFiatValue,
106
- counterValueCurrency,
107
- locale,
108
- discreet,
109
- );
110
- providerResultsMap.set(mainCurrency.id, { balance, fiatValue });
111
- }
112
-
113
- const assetsWithBalanceData = assets.map(asset => {
114
- const balanceData = providerResultsMap.get(asset.id) || {};
115
- return {
116
- asset,
117
- balanceData,
118
- };
119
- });
120
-
121
- assetsWithBalanceData.sort((a, b) =>
122
- compareByBalanceThenFiat(a.balanceData, b.balanceData, discreet),
123
- );
124
-
125
- return assetsWithBalanceData.map(({ asset, balanceData }) => ({
126
- ...asset,
127
- rightElement: balanceItem(balanceData),
128
- }));
129
- }, [
130
- assets,
131
- providerMap,
132
- flattenedAccounts,
133
- state,
134
- counterValueCurrency,
135
- discreet,
136
- locale,
137
- grouped,
138
- ]);
139
- };
140
- }
@@ -1,116 +0,0 @@
1
- import { useMemo, type ReactNode } from "react";
2
- import type { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
3
- import { compareByBalanceThenFiat } from "../utils/sortByBalance";
4
- import { BalanceUI, UseBalanceDeps } from "../utils/type";
5
- import { CurrenciesByProviderId } from "../../deposit/type";
6
- import { getBalanceAndFiatValueByAssets } from "../utils/getBalanceAndFiatValueByAssets";
7
-
8
- export type NetworkDeps = {
9
- balanceItem: (asset: { fiatValue?: string; balance?: string }) => ReactNode;
10
- useBalanceDeps: UseBalanceDeps;
11
- };
12
-
13
- type Params = {
14
- assets: CryptoOrTokenCurrency[];
15
- selectedAssetId: string;
16
- currenciesByProvider: CurrenciesByProviderId[];
17
- };
18
-
19
- export function createUseRightBalanceNetwork({ useBalanceDeps, balanceItem }: NetworkDeps) {
20
- return function useRightBalanceNetwork({
21
- assets: networks,
22
- selectedAssetId,
23
- currenciesByProvider,
24
- }: Params) {
25
- const { flattenedAccounts, discreet, state, counterValueCurrency, locale } = useBalanceDeps();
26
-
27
- return useMemo(() => {
28
- if (currenciesByProvider && currenciesByProvider.length > 0) {
29
- const providerOfSelectedAsset = currenciesByProvider.find(provider =>
30
- provider.currenciesByNetwork.some(currency => currency.id === selectedAssetId),
31
- );
32
-
33
- if (providerOfSelectedAsset) {
34
- const pairs = networks.map(network => ({
35
- network,
36
- asset: providerOfSelectedAsset.currenciesByNetwork.find(currency =>
37
- currency.type === "TokenCurrency"
38
- ? currency.parentCurrency.id === network.id
39
- : currency.id === network.id,
40
- ),
41
- }));
42
-
43
- const validAssets = pairs.filter(p => p.asset).map(p => p.asset!);
44
-
45
- const allBalanceData =
46
- validAssets.length > 0
47
- ? getBalanceAndFiatValueByAssets(
48
- flattenedAccounts,
49
- validAssets,
50
- state,
51
- counterValueCurrency,
52
- discreet,
53
- locale,
54
- )
55
- : [];
56
-
57
- const balanceMap = new Map(allBalanceData.map(b => [b.id, b]));
58
-
59
- const networkWithBalanceData = pairs.map(({ network, asset }) => {
60
- const balanceData: BalanceUI = asset ? balanceMap.get(asset.id) || {} : {};
61
- return {
62
- network,
63
- balanceData,
64
- };
65
- });
66
-
67
- networkWithBalanceData.sort((a, b) =>
68
- compareByBalanceThenFiat(a.balanceData, b.balanceData, discreet),
69
- );
70
-
71
- return networkWithBalanceData.map(({ network, balanceData }) => ({
72
- ...network,
73
- rightElement: balanceItem(balanceData),
74
- }));
75
- }
76
- }
77
-
78
- const networkBalanceData = getBalanceAndFiatValueByAssets(
79
- flattenedAccounts,
80
- networks,
81
- state,
82
- counterValueCurrency,
83
- discreet,
84
- locale,
85
- );
86
-
87
- const balanceMap = new Map(networkBalanceData.map(b => [b.id, b]));
88
-
89
- const networksWithBalance = networks.map(network => {
90
- const balanceData = balanceMap.get(network.id) || {};
91
- return {
92
- network,
93
- balanceData,
94
- };
95
- });
96
-
97
- networksWithBalance.sort((a, b) =>
98
- compareByBalanceThenFiat(a.balanceData, b.balanceData, discreet),
99
- );
100
-
101
- return networksWithBalance.map(({ network, balanceData }) => ({
102
- ...network,
103
- rightElement: balanceItem(balanceData),
104
- }));
105
- }, [
106
- networks,
107
- selectedAssetId,
108
- currenciesByProvider,
109
- flattenedAccounts,
110
- state,
111
- counterValueCurrency,
112
- discreet,
113
- locale,
114
- ]);
115
- };
116
- }
@@ -1,61 +0,0 @@
1
- import type { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
2
- import { AssetType, CreateAssetConfigurationHook, AssetConfigurationDeps } from "../utils/type";
3
- import { CurrenciesByProviderId } from "../../deposit/type";
4
- import { composeHooks } from "../../utils/composeHooks";
5
- import { createUseLeftApyModule } from "../hooks/useLeftApy";
6
- import { createUseRightBalanceAsset } from "../hooks/useRightBalanceAsset";
7
-
8
- const getRightElement =
9
- (AssetConfigurationDeps: AssetConfigurationDeps) => (rightElement: string) => {
10
- switch (rightElement) {
11
- case "balance":
12
- return createUseRightBalanceAsset({
13
- useBalanceDeps: AssetConfigurationDeps.useBalanceDeps,
14
- balanceItem: AssetConfigurationDeps.balanceItem,
15
- });
16
- case "marketTrend":
17
- case "undefined":
18
- default:
19
- return undefined;
20
- }
21
- };
22
-
23
- const getLeftElement =
24
- (AssetConfigurationDeps: AssetConfigurationDeps) => (leftElement: string) => {
25
- switch (leftElement) {
26
- case "apy":
27
- return createUseLeftApyModule({ ApyIndicator: AssetConfigurationDeps.ApyIndicator });
28
- case "priceVariation":
29
- case "undefined":
30
- default:
31
- return undefined;
32
- }
33
- };
34
-
35
- const createAssetConfigurationHook: CreateAssetConfigurationHook =
36
- deps =>
37
- ({ assetsConfiguration, currenciesByProvider }) => {
38
- const { rightElement = "undefined", leftElement = "undefined" } = assetsConfiguration ?? {};
39
-
40
- const rightHook = getRightElement(deps)(rightElement);
41
- const leftHook = getLeftElement(deps)(leftElement);
42
-
43
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
44
- const hooks = [rightHook, leftHook].filter(Boolean) as Array<
45
- (
46
- assets: CryptoOrTokenCurrency[],
47
- currenciesByProvider?: CurrenciesByProviderId[],
48
- ) => AssetType[]
49
- >;
50
-
51
- return (assets: CryptoOrTokenCurrency[]) => {
52
- const composedHook = composeHooks<CryptoOrTokenCurrency, AssetType>(
53
- ...hooks.map(
54
- hook => (assets: CryptoOrTokenCurrency[]) => hook(assets, currenciesByProvider),
55
- ),
56
- );
57
- return composedHook(assets);
58
- };
59
- };
60
-
61
- export default createAssetConfigurationHook;
@@ -1,79 +0,0 @@
1
- import type { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
2
- import { createUseLeftAccountsModule } from "../hooks/useLeftAccounts";
3
- import { createUseLeftAccountsApyModule } from "../hooks/useLeftAccountsApy";
4
- import { createUseRightBalanceNetwork } from "../hooks/useRightBalanceNetwork";
5
- import {
6
- CreateNetworkConfigurationHookProps,
7
- NetworkConfigurationDeps,
8
- LeftElementKind,
9
- Network,
10
- NetworkHook,
11
- RightElementKind,
12
- } from "../utils/type";
13
- import { composeHooks } from "../../utils/composeHooks";
14
-
15
- export const getLeftElement =
16
- (NetworkConfigurationDeps: NetworkConfigurationDeps) =>
17
- (leftElement: LeftElementKind): NetworkHook | undefined => {
18
- switch (leftElement) {
19
- case "numberOfAccounts":
20
- return createUseLeftAccountsModule({
21
- useAccountData: NetworkConfigurationDeps.useAccountData,
22
- accountsCount: NetworkConfigurationDeps.accountsCount,
23
- });
24
- case "numberOfAccountsAndApy":
25
- return createUseLeftAccountsApyModule({
26
- useAccountData: NetworkConfigurationDeps.useAccountData,
27
- accountsCountAndApy: NetworkConfigurationDeps.accountsCountAndApy,
28
- });
29
- case "undefined":
30
- default:
31
- return undefined;
32
- }
33
- };
34
-
35
- export const getRightElement =
36
- (NetworkConfigurationDeps: NetworkConfigurationDeps) =>
37
- (rightElement: RightElementKind): NetworkHook | undefined => {
38
- switch (rightElement) {
39
- case "balance":
40
- return createUseRightBalanceNetwork({
41
- useBalanceDeps: NetworkConfigurationDeps.useBalanceDeps,
42
- balanceItem: NetworkConfigurationDeps.balanceItem,
43
- });
44
- case "undefined":
45
- default:
46
- return undefined;
47
- }
48
- };
49
-
50
- export const createNetworkConfigurationHook =
51
- (NetworkConfigurationDeps: NetworkConfigurationDeps) =>
52
- ({
53
- networksConfig,
54
- selectedAssetId,
55
- currenciesByProvider,
56
- accounts$,
57
- }: CreateNetworkConfigurationHookProps) => {
58
- const { leftElement = "undefined", rightElement = "undefined" } = networksConfig ?? {};
59
- const leftHook = getLeftElement(NetworkConfigurationDeps)(leftElement);
60
- const rightHook = getRightElement(NetworkConfigurationDeps)(rightElement);
61
-
62
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
63
- const hooks = [rightHook, leftHook].filter(Boolean) as NetworkHook[];
64
-
65
- return (assets: CryptoOrTokenCurrency[]): Array<CryptoOrTokenCurrency & Network> => {
66
- const composedHook = composeHooks<CryptoOrTokenCurrency, Network>(
67
- ...hooks.map(
68
- hook => (assets: CryptoOrTokenCurrency[]) =>
69
- hook({
70
- assets,
71
- selectedAssetId,
72
- currenciesByProvider: currenciesByProvider || [],
73
- accounts$,
74
- }),
75
- ),
76
- );
77
- return composedHook(assets);
78
- };
79
- };
@@ -1,25 +0,0 @@
1
- import { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
2
-
3
- export const buildProviderCurrenciesMap = (
4
- currenciesByProvider?: Array<{
5
- providerId: string;
6
- currenciesByNetwork?: CryptoOrTokenCurrency[];
7
- }>,
8
- ) => {
9
- if (!currenciesByProvider?.length) return null;
10
-
11
- const map = new Map<
12
- string,
13
- { mainCurrency: CryptoOrTokenCurrency; currencies: CryptoOrTokenCurrency[] }
14
- >();
15
-
16
- currenciesByProvider.forEach(({ providerId, currenciesByNetwork = [] }) => {
17
- if (currenciesByNetwork.length > 0) {
18
- const mainCurrency =
19
- currenciesByNetwork.find(c => c.id === providerId) ?? currenciesByNetwork[0];
20
- map.set(providerId, { mainCurrency, currencies: currenciesByNetwork });
21
- }
22
- });
23
-
24
- return map;
25
- };
@@ -1,24 +0,0 @@
1
- import { LoadingStatus } from "../../deposit/type";
2
- import { SerializedError } from "@reduxjs/toolkit";
3
- import { FetchBaseQueryError } from "@reduxjs/toolkit/query";
4
-
5
- export const getLoadingStatus = ({
6
- isLoading,
7
- isSuccess,
8
- error,
9
- }: {
10
- isLoading: boolean;
11
- isSuccess: boolean;
12
- error?: FetchBaseQueryError | SerializedError;
13
- }): LoadingStatus => {
14
- if (isLoading) {
15
- return LoadingStatus.Pending;
16
- }
17
- if (error) {
18
- return LoadingStatus.Error;
19
- }
20
- if (isSuccess) {
21
- return LoadingStatus.Success;
22
- }
23
- return LoadingStatus.Idle;
24
- };
@@ -1,32 +0,0 @@
1
- import { BalanceUI } from "./type";
2
-
3
- export const parseFiatValue = (value?: string, discreet?: boolean) => {
4
- if (!value || discreet) return -1;
5
- return parseFloat(value.replace(/[^0-9.-]+/g, "")) || -1;
6
- };
7
-
8
- export function toFiatString(x?: BalanceUI): string | undefined {
9
- return x && "fiatValue" in x ? String(x.fiatValue) : undefined;
10
- }
11
-
12
- export function hasBalance(balanceData?: BalanceUI): boolean {
13
- return (
14
- !!balanceData &&
15
- (("fiatValue" in balanceData && !!balanceData.fiatValue) ||
16
- ("balance" in balanceData && !!balanceData.balance))
17
- );
18
- }
19
-
20
- export function compareByBalanceThenFiat(
21
- a: BalanceUI | undefined,
22
- b: BalanceUI | undefined,
23
- discreet: boolean,
24
- ): number {
25
- const ah = hasBalance(a);
26
- const bh = hasBalance(b);
27
- if (ah && !bh) return -1;
28
- if (!ah && bh) return 1;
29
- const af = parseFiatValue(toFiatString(a), discreet);
30
- const bf = parseFiatValue(toFiatString(b), discreet);
31
- return bf - af;
32
- }