@ledgerhq/live-common 34.46.0 → 34.47.0-nightly.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 (422) hide show
  1. package/lib/bridge/crypto-assets/index.d.ts +1 -1
  2. package/lib/bridge/crypto-assets/index.d.ts.map +1 -1
  3. package/lib/bridge/crypto-assets/index.js +1 -1
  4. package/lib/bridge/crypto-assets/index.js.map +1 -1
  5. package/lib/bridge/generic-alpaca/estimateMaxSpendable.d.ts.map +1 -1
  6. package/lib/bridge/generic-alpaca/estimateMaxSpendable.js +6 -4
  7. package/lib/bridge/generic-alpaca/estimateMaxSpendable.js.map +1 -1
  8. package/lib/bridge/generic-alpaca/getTransactionStatus.d.ts.map +1 -1
  9. package/lib/bridge/generic-alpaca/getTransactionStatus.js +2 -2
  10. package/lib/bridge/generic-alpaca/getTransactionStatus.js.map +1 -1
  11. package/lib/bridge/generic-alpaca/prepareTransaction.d.ts.map +1 -1
  12. package/lib/bridge/generic-alpaca/prepareTransaction.js +12 -12
  13. package/lib/bridge/generic-alpaca/prepareTransaction.js.map +1 -1
  14. package/lib/bridge/generic-alpaca/signOperation.d.ts.map +1 -1
  15. package/lib/bridge/generic-alpaca/signOperation.js +3 -4
  16. package/lib/bridge/generic-alpaca/signOperation.js.map +1 -1
  17. package/lib/bridge/generic-alpaca/tests/prepareTransaction.test.js +1 -1
  18. package/lib/bridge/generic-alpaca/tests/prepareTransaction.test.js.map +1 -1
  19. package/lib/bridge/generic-alpaca/utils.d.ts +0 -1
  20. package/lib/bridge/generic-alpaca/utils.d.ts.map +1 -1
  21. package/lib/bridge/generic-alpaca/utils.js +0 -1
  22. package/lib/bridge/generic-alpaca/utils.js.map +1 -1
  23. package/lib/bridge/impl.d.ts +1 -1
  24. package/lib/bridge/impl.d.ts.map +1 -1
  25. package/lib/currencies/index.d.ts +1 -1
  26. package/lib/currencies/index.d.ts.map +1 -1
  27. package/lib/currencies/index.js +1 -2
  28. package/lib/currencies/index.js.map +1 -1
  29. package/lib/currencies/sortByMarketcap.test.js +2 -1
  30. package/lib/currencies/sortByMarketcap.test.js.map +1 -1
  31. package/lib/domain/getTokensWithFunds.test.js +1 -1
  32. package/lib/domain/getTokensWithFunds.test.js.map +1 -1
  33. package/lib/e2e/enum/AppInfos.d.ts +1 -1
  34. package/lib/e2e/enum/AppInfos.d.ts.map +1 -1
  35. package/lib/e2e/enum/DeviceLabels.d.ts +3 -2
  36. package/lib/e2e/enum/DeviceLabels.d.ts.map +1 -1
  37. package/lib/e2e/enum/DeviceLabels.js +2 -1
  38. package/lib/e2e/enum/DeviceLabels.js.map +1 -1
  39. package/lib/e2e/enum/Provider.d.ts.map +1 -1
  40. package/lib/e2e/enum/Provider.js +2 -2
  41. package/lib/e2e/enum/Provider.js.map +1 -1
  42. package/lib/e2e/families/solana.d.ts.map +1 -1
  43. package/lib/e2e/families/solana.js +4 -4
  44. package/lib/e2e/families/solana.js.map +1 -1
  45. package/lib/e2e/index.d.ts +5 -0
  46. package/lib/e2e/index.d.ts.map +1 -1
  47. package/lib/e2e/speculos.d.ts.map +1 -1
  48. package/lib/e2e/speculos.js +4 -5
  49. package/lib/e2e/speculos.js.map +1 -1
  50. package/lib/e2e/speculosCI.d.ts +4 -0
  51. package/lib/e2e/speculosCI.d.ts.map +1 -1
  52. package/lib/e2e/speculosCI.js +16 -6
  53. package/lib/e2e/speculosCI.js.map +1 -1
  54. package/lib/env.react.d.ts +1 -1
  55. package/lib/env.react.d.ts.map +1 -1
  56. package/lib/exchange/swap/api/v5/actions.js +1 -1
  57. package/lib/exchange/swap/api/v5/actions.js.map +1 -1
  58. package/lib/exchange/swap/types.d.ts +1 -1
  59. package/lib/exchange/swap/types.d.ts.map +1 -1
  60. package/lib/families/evm/setup.d.ts.map +1 -1
  61. package/lib/families/evm/setup.js +11 -1
  62. package/lib/families/evm/setup.js.map +1 -1
  63. package/lib/families/hedera/constants.d.ts +2 -0
  64. package/lib/families/hedera/constants.d.ts.map +1 -0
  65. package/lib/families/hedera/constants.js +19 -0
  66. package/lib/families/hedera/constants.js.map +1 -0
  67. package/lib/families/hedera/setup.d.ts +5 -5
  68. package/lib/families/hedera/setup.d.ts.map +1 -1
  69. package/lib/families/hedera/setup.js.map +1 -1
  70. package/lib/families/solana/setup.d.ts.map +1 -1
  71. package/lib/families/solana/setup.js +2 -1
  72. package/lib/families/solana/setup.js.map +1 -1
  73. package/lib/families/sui/constants.d.ts +2 -0
  74. package/lib/families/sui/constants.d.ts.map +1 -0
  75. package/lib/families/sui/constants.js +19 -0
  76. package/lib/families/sui/constants.js.map +1 -0
  77. package/lib/families/sui/logic.d.ts +2 -0
  78. package/lib/families/sui/logic.d.ts.map +1 -0
  79. package/lib/families/sui/logic.js +19 -0
  80. package/lib/families/sui/logic.js.map +1 -0
  81. package/lib/families/sui/react.d.ts +8 -0
  82. package/lib/families/sui/react.d.ts.map +1 -0
  83. package/lib/families/sui/react.js +85 -0
  84. package/lib/families/sui/react.js.map +1 -0
  85. package/lib/families/sui/types.d.ts +2 -0
  86. package/lib/families/sui/types.d.ts.map +1 -0
  87. package/lib/families/sui/types.js +19 -0
  88. package/lib/families/sui/types.js.map +1 -0
  89. package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
  90. package/lib/featureFlags/defaultFeatures.js +1 -0
  91. package/lib/featureFlags/defaultFeatures.js.map +1 -1
  92. package/lib/featureFlags/useFeature.d.ts +1 -1
  93. package/lib/featureFlags/useFeature.d.ts.map +1 -1
  94. package/lib/generated/bridge/js.d.ts +1 -1
  95. package/lib/market/utils/countervalueFormatter.d.ts.map +1 -1
  96. package/lib/market/utils/countervalueFormatter.js.map +1 -1
  97. package/lib/market/utils/types.d.ts +2 -0
  98. package/lib/market/utils/types.d.ts.map +1 -1
  99. package/lib/modularDrawer/__mocks__/currencies.mock.d.ts.map +1 -1
  100. package/lib/modularDrawer/__mocks__/currencies.mock.js +7 -7
  101. package/lib/modularDrawer/__mocks__/currencies.mock.js.map +1 -1
  102. package/lib/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.js +1 -1
  103. package/lib/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.js.map +1 -1
  104. package/lib/modularDrawer/data/entities/index.d.ts +68 -0
  105. package/lib/modularDrawer/data/entities/index.d.ts.map +1 -0
  106. package/lib/modularDrawer/data/entities/index.js +3 -0
  107. package/lib/modularDrawer/data/entities/index.js.map +1 -0
  108. package/lib/modularDrawer/data/state-manager/api.d.ts +152 -0
  109. package/lib/modularDrawer/data/state-manager/api.d.ts.map +1 -0
  110. package/lib/modularDrawer/data/state-manager/api.js +45 -0
  111. package/lib/modularDrawer/data/state-manager/api.js.map +1 -0
  112. package/lib/modularDrawer/hooks/__test__/useAssetsData.test.d.ts +5 -0
  113. package/lib/modularDrawer/hooks/__test__/useAssetsData.test.d.ts.map +1 -0
  114. package/lib/modularDrawer/hooks/__test__/useAssetsData.test.js +120 -0
  115. package/lib/modularDrawer/hooks/__test__/useAssetsData.test.js.map +1 -0
  116. package/lib/modularDrawer/hooks/modules/useAssetAccountCounts.d.ts +19 -0
  117. package/lib/modularDrawer/hooks/modules/useAssetAccountCounts.d.ts.map +1 -0
  118. package/lib/modularDrawer/hooks/modules/useAssetAccountCounts.js +16 -0
  119. package/lib/modularDrawer/hooks/modules/useAssetAccountCounts.js.map +1 -0
  120. package/lib/modularDrawer/hooks/modules/useLeftApyModule.d.ts +52 -0
  121. package/lib/modularDrawer/hooks/modules/useLeftApyModule.d.ts.map +1 -0
  122. package/lib/modularDrawer/hooks/modules/useLeftApyModule.js +18 -0
  123. package/lib/modularDrawer/hooks/modules/useLeftApyModule.js.map +1 -0
  124. package/lib/modularDrawer/hooks/useAssetsData.d.ts +13 -0
  125. package/lib/modularDrawer/hooks/useAssetsData.d.ts.map +1 -0
  126. package/lib/modularDrawer/hooks/useAssetsData.js +31 -0
  127. package/lib/modularDrawer/hooks/useAssetsData.js.map +1 -0
  128. package/lib/modularDrawer/types.d.ts +2 -0
  129. package/lib/modularDrawer/types.d.ts.map +1 -0
  130. package/lib/modularDrawer/types.js +3 -0
  131. package/lib/modularDrawer/types.js.map +1 -0
  132. package/lib/modularDrawer/utils/__tests__/counterValueFormatter.test.d.ts +2 -0
  133. package/lib/modularDrawer/utils/__tests__/counterValueFormatter.test.d.ts.map +1 -0
  134. package/lib/modularDrawer/utils/__tests__/counterValueFormatter.test.js +496 -0
  135. package/lib/modularDrawer/utils/__tests__/counterValueFormatter.test.js.map +1 -0
  136. package/lib/modularDrawer/utils/__tests__/currencyUtils.test.js +1 -1
  137. package/lib/modularDrawer/utils/__tests__/currencyUtils.test.js.map +1 -1
  138. package/lib/modularDrawer/utils/__tests__/haveOneCommonProvider.test.js +1 -1
  139. package/lib/modularDrawer/utils/__tests__/haveOneCommonProvider.test.js.map +1 -1
  140. package/lib/modularDrawer/utils/calculateProviderTotal.d.ts +9 -0
  141. package/lib/modularDrawer/utils/calculateProviderTotal.d.ts.map +1 -0
  142. package/lib/modularDrawer/utils/calculateProviderTotal.js +23 -0
  143. package/lib/modularDrawer/utils/calculateProviderTotal.js.map +1 -0
  144. package/lib/modularDrawer/utils/counterValueFormatter.d.ts +14 -0
  145. package/lib/modularDrawer/utils/counterValueFormatter.d.ts.map +1 -0
  146. package/lib/modularDrawer/utils/counterValueFormatter.js +107 -0
  147. package/lib/modularDrawer/utils/counterValueFormatter.js.map +1 -0
  148. package/lib/modularDrawer/utils/getBalanceAndFiatValueByAssets.d.ts +11 -0
  149. package/lib/modularDrawer/utils/getBalanceAndFiatValueByAssets.d.ts.map +1 -0
  150. package/lib/modularDrawer/utils/getBalanceAndFiatValueByAssets.js +45 -0
  151. package/lib/modularDrawer/utils/getBalanceAndFiatValueByAssets.js.map +1 -0
  152. package/lib/modularDrawer/utils/getProviderCurrency.d.ts +3 -0
  153. package/lib/modularDrawer/utils/getProviderCurrency.d.ts.map +1 -0
  154. package/lib/modularDrawer/utils/getProviderCurrency.js +14 -0
  155. package/lib/modularDrawer/utils/getProviderCurrency.js.map +1 -0
  156. package/lib/modularDrawer/utils/groupAccountsByAsset.d.ts +11 -0
  157. package/lib/modularDrawer/utils/groupAccountsByAsset.d.ts.map +1 -0
  158. package/lib/modularDrawer/utils/groupAccountsByAsset.js +32 -0
  159. package/lib/modularDrawer/utils/groupAccountsByAsset.js.map +1 -0
  160. package/lib/modularDrawer/utils/parseToBigNumber.d.ts +9 -0
  161. package/lib/modularDrawer/utils/parseToBigNumber.d.ts.map +1 -0
  162. package/lib/modularDrawer/utils/parseToBigNumber.js +24 -0
  163. package/lib/modularDrawer/utils/parseToBigNumber.js.map +1 -0
  164. package/lib/modularDrawer/utils/type.d.ts +21 -0
  165. package/lib/modularDrawer/utils/type.d.ts.map +1 -0
  166. package/lib/modularDrawer/utils/type.js +3 -0
  167. package/lib/modularDrawer/utils/type.js.map +1 -0
  168. package/lib/utils/__tests__/getAccountTuplesForCurrency.test.js +1 -1
  169. package/lib/utils/__tests__/getAccountTuplesForCurrency.test.js.map +1 -1
  170. package/lib/wallet-api/Exchange/error.d.ts +1 -0
  171. package/lib/wallet-api/Exchange/error.d.ts.map +1 -1
  172. package/lib/wallet-api/Exchange/error.js +11 -1
  173. package/lib/wallet-api/Exchange/error.js.map +1 -1
  174. package/lib/wallet-api/Exchange/server.d.ts +2 -0
  175. package/lib/wallet-api/Exchange/server.d.ts.map +1 -1
  176. package/lib/wallet-api/Exchange/server.js +29 -5
  177. package/lib/wallet-api/Exchange/server.js.map +1 -1
  178. package/lib/wallet-api/Exchange/server.test.js +3 -0
  179. package/lib/wallet-api/Exchange/server.test.js.map +1 -1
  180. package/lib-es/bridge/crypto-assets/index.d.ts +1 -1
  181. package/lib-es/bridge/crypto-assets/index.d.ts.map +1 -1
  182. package/lib-es/bridge/crypto-assets/index.js +1 -1
  183. package/lib-es/bridge/crypto-assets/index.js.map +1 -1
  184. package/lib-es/bridge/generic-alpaca/estimateMaxSpendable.d.ts.map +1 -1
  185. package/lib-es/bridge/generic-alpaca/estimateMaxSpendable.js +6 -4
  186. package/lib-es/bridge/generic-alpaca/estimateMaxSpendable.js.map +1 -1
  187. package/lib-es/bridge/generic-alpaca/getTransactionStatus.d.ts.map +1 -1
  188. package/lib-es/bridge/generic-alpaca/getTransactionStatus.js +2 -2
  189. package/lib-es/bridge/generic-alpaca/getTransactionStatus.js.map +1 -1
  190. package/lib-es/bridge/generic-alpaca/prepareTransaction.d.ts.map +1 -1
  191. package/lib-es/bridge/generic-alpaca/prepareTransaction.js +12 -12
  192. package/lib-es/bridge/generic-alpaca/prepareTransaction.js.map +1 -1
  193. package/lib-es/bridge/generic-alpaca/signOperation.d.ts.map +1 -1
  194. package/lib-es/bridge/generic-alpaca/signOperation.js +3 -4
  195. package/lib-es/bridge/generic-alpaca/signOperation.js.map +1 -1
  196. package/lib-es/bridge/generic-alpaca/tests/prepareTransaction.test.js +1 -1
  197. package/lib-es/bridge/generic-alpaca/tests/prepareTransaction.test.js.map +1 -1
  198. package/lib-es/bridge/generic-alpaca/utils.d.ts +0 -1
  199. package/lib-es/bridge/generic-alpaca/utils.d.ts.map +1 -1
  200. package/lib-es/bridge/generic-alpaca/utils.js +0 -1
  201. package/lib-es/bridge/generic-alpaca/utils.js.map +1 -1
  202. package/lib-es/bridge/impl.d.ts +1 -1
  203. package/lib-es/bridge/impl.d.ts.map +1 -1
  204. package/lib-es/currencies/index.d.ts +1 -1
  205. package/lib-es/currencies/index.d.ts.map +1 -1
  206. package/lib-es/currencies/index.js +1 -1
  207. package/lib-es/currencies/index.js.map +1 -1
  208. package/lib-es/currencies/sortByMarketcap.test.js +2 -1
  209. package/lib-es/currencies/sortByMarketcap.test.js.map +1 -1
  210. package/lib-es/domain/getTokensWithFunds.test.js +1 -1
  211. package/lib-es/domain/getTokensWithFunds.test.js.map +1 -1
  212. package/lib-es/e2e/enum/AppInfos.d.ts +1 -1
  213. package/lib-es/e2e/enum/AppInfos.d.ts.map +1 -1
  214. package/lib-es/e2e/enum/DeviceLabels.d.ts +3 -2
  215. package/lib-es/e2e/enum/DeviceLabels.d.ts.map +1 -1
  216. package/lib-es/e2e/enum/DeviceLabels.js +2 -1
  217. package/lib-es/e2e/enum/DeviceLabels.js.map +1 -1
  218. package/lib-es/e2e/enum/Provider.d.ts.map +1 -1
  219. package/lib-es/e2e/enum/Provider.js +2 -2
  220. package/lib-es/e2e/enum/Provider.js.map +1 -1
  221. package/lib-es/e2e/families/solana.d.ts.map +1 -1
  222. package/lib-es/e2e/families/solana.js +4 -4
  223. package/lib-es/e2e/families/solana.js.map +1 -1
  224. package/lib-es/e2e/index.d.ts +5 -0
  225. package/lib-es/e2e/index.d.ts.map +1 -1
  226. package/lib-es/e2e/speculos.d.ts.map +1 -1
  227. package/lib-es/e2e/speculos.js +4 -5
  228. package/lib-es/e2e/speculos.js.map +1 -1
  229. package/lib-es/e2e/speculosCI.d.ts +4 -0
  230. package/lib-es/e2e/speculosCI.d.ts.map +1 -1
  231. package/lib-es/e2e/speculosCI.js +14 -5
  232. package/lib-es/e2e/speculosCI.js.map +1 -1
  233. package/lib-es/env.react.d.ts +1 -1
  234. package/lib-es/env.react.d.ts.map +1 -1
  235. package/lib-es/exchange/swap/api/v5/actions.js +1 -1
  236. package/lib-es/exchange/swap/api/v5/actions.js.map +1 -1
  237. package/lib-es/exchange/swap/types.d.ts +1 -1
  238. package/lib-es/exchange/swap/types.d.ts.map +1 -1
  239. package/lib-es/families/evm/setup.d.ts.map +1 -1
  240. package/lib-es/families/evm/setup.js +11 -1
  241. package/lib-es/families/evm/setup.js.map +1 -1
  242. package/lib-es/families/hedera/constants.d.ts +2 -0
  243. package/lib-es/families/hedera/constants.d.ts.map +1 -0
  244. package/lib-es/families/hedera/constants.js +3 -0
  245. package/lib-es/families/hedera/constants.js.map +1 -0
  246. package/lib-es/families/hedera/setup.d.ts +5 -5
  247. package/lib-es/families/hedera/setup.d.ts.map +1 -1
  248. package/lib-es/families/hedera/setup.js.map +1 -1
  249. package/lib-es/families/solana/setup.d.ts.map +1 -1
  250. package/lib-es/families/solana/setup.js +2 -1
  251. package/lib-es/families/solana/setup.js.map +1 -1
  252. package/lib-es/families/sui/constants.d.ts +2 -0
  253. package/lib-es/families/sui/constants.d.ts.map +1 -0
  254. package/lib-es/families/sui/constants.js +3 -0
  255. package/lib-es/families/sui/constants.js.map +1 -0
  256. package/lib-es/families/sui/logic.d.ts +2 -0
  257. package/lib-es/families/sui/logic.d.ts.map +1 -0
  258. package/lib-es/families/sui/logic.js +3 -0
  259. package/lib-es/families/sui/logic.js.map +1 -0
  260. package/lib-es/families/sui/react.d.ts +8 -0
  261. package/lib-es/families/sui/react.d.ts.map +1 -0
  262. package/lib-es/families/sui/react.js +78 -0
  263. package/lib-es/families/sui/react.js.map +1 -0
  264. package/lib-es/families/sui/types.d.ts +2 -0
  265. package/lib-es/families/sui/types.d.ts.map +1 -0
  266. package/lib-es/families/sui/types.js +3 -0
  267. package/lib-es/families/sui/types.js.map +1 -0
  268. package/lib-es/featureFlags/defaultFeatures.d.ts.map +1 -1
  269. package/lib-es/featureFlags/defaultFeatures.js +1 -0
  270. package/lib-es/featureFlags/defaultFeatures.js.map +1 -1
  271. package/lib-es/featureFlags/useFeature.d.ts +1 -1
  272. package/lib-es/featureFlags/useFeature.d.ts.map +1 -1
  273. package/lib-es/generated/bridge/js.d.ts +1 -1
  274. package/lib-es/market/utils/countervalueFormatter.d.ts.map +1 -1
  275. package/lib-es/market/utils/countervalueFormatter.js.map +1 -1
  276. package/lib-es/market/utils/types.d.ts +2 -0
  277. package/lib-es/market/utils/types.d.ts.map +1 -1
  278. package/lib-es/modularDrawer/__mocks__/currencies.mock.d.ts.map +1 -1
  279. package/lib-es/modularDrawer/__mocks__/currencies.mock.js +1 -1
  280. package/lib-es/modularDrawer/__mocks__/currencies.mock.js.map +1 -1
  281. package/lib-es/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.js +1 -1
  282. package/lib-es/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.js.map +1 -1
  283. package/lib-es/modularDrawer/data/entities/index.d.ts +68 -0
  284. package/lib-es/modularDrawer/data/entities/index.d.ts.map +1 -0
  285. package/lib-es/modularDrawer/data/entities/index.js +2 -0
  286. package/lib-es/modularDrawer/data/entities/index.js.map +1 -0
  287. package/lib-es/modularDrawer/data/state-manager/api.d.ts +152 -0
  288. package/lib-es/modularDrawer/data/state-manager/api.d.ts.map +1 -0
  289. package/lib-es/modularDrawer/data/state-manager/api.js +42 -0
  290. package/lib-es/modularDrawer/data/state-manager/api.js.map +1 -0
  291. package/lib-es/modularDrawer/hooks/__test__/useAssetsData.test.d.ts +5 -0
  292. package/lib-es/modularDrawer/hooks/__test__/useAssetsData.test.d.ts.map +1 -0
  293. package/lib-es/modularDrawer/hooks/__test__/useAssetsData.test.js +118 -0
  294. package/lib-es/modularDrawer/hooks/__test__/useAssetsData.test.js.map +1 -0
  295. package/lib-es/modularDrawer/hooks/modules/useAssetAccountCounts.d.ts +19 -0
  296. package/lib-es/modularDrawer/hooks/modules/useAssetAccountCounts.d.ts.map +1 -0
  297. package/lib-es/modularDrawer/hooks/modules/useAssetAccountCounts.js +12 -0
  298. package/lib-es/modularDrawer/hooks/modules/useAssetAccountCounts.js.map +1 -0
  299. package/lib-es/modularDrawer/hooks/modules/useLeftApyModule.d.ts +52 -0
  300. package/lib-es/modularDrawer/hooks/modules/useLeftApyModule.d.ts.map +1 -0
  301. package/lib-es/modularDrawer/hooks/modules/useLeftApyModule.js +11 -0
  302. package/lib-es/modularDrawer/hooks/modules/useLeftApyModule.js.map +1 -0
  303. package/lib-es/modularDrawer/hooks/useAssetsData.d.ts +13 -0
  304. package/lib-es/modularDrawer/hooks/useAssetsData.d.ts.map +1 -0
  305. package/lib-es/modularDrawer/hooks/useAssetsData.js +27 -0
  306. package/lib-es/modularDrawer/hooks/useAssetsData.js.map +1 -0
  307. package/lib-es/modularDrawer/types.d.ts +2 -0
  308. package/lib-es/modularDrawer/types.d.ts.map +1 -0
  309. package/lib-es/modularDrawer/types.js +2 -0
  310. package/lib-es/modularDrawer/types.js.map +1 -0
  311. package/lib-es/modularDrawer/utils/__tests__/counterValueFormatter.test.d.ts +2 -0
  312. package/lib-es/modularDrawer/utils/__tests__/counterValueFormatter.test.d.ts.map +1 -0
  313. package/lib-es/modularDrawer/utils/__tests__/counterValueFormatter.test.js +494 -0
  314. package/lib-es/modularDrawer/utils/__tests__/counterValueFormatter.test.js.map +1 -0
  315. package/lib-es/modularDrawer/utils/__tests__/currencyUtils.test.js +1 -1
  316. package/lib-es/modularDrawer/utils/__tests__/currencyUtils.test.js.map +1 -1
  317. package/lib-es/modularDrawer/utils/__tests__/haveOneCommonProvider.test.js +1 -1
  318. package/lib-es/modularDrawer/utils/__tests__/haveOneCommonProvider.test.js.map +1 -1
  319. package/lib-es/modularDrawer/utils/calculateProviderTotal.d.ts +9 -0
  320. package/lib-es/modularDrawer/utils/calculateProviderTotal.d.ts.map +1 -0
  321. package/lib-es/modularDrawer/utils/calculateProviderTotal.js +16 -0
  322. package/lib-es/modularDrawer/utils/calculateProviderTotal.js.map +1 -0
  323. package/lib-es/modularDrawer/utils/counterValueFormatter.d.ts +14 -0
  324. package/lib-es/modularDrawer/utils/counterValueFormatter.d.ts.map +1 -0
  325. package/lib-es/modularDrawer/utils/counterValueFormatter.js +103 -0
  326. package/lib-es/modularDrawer/utils/counterValueFormatter.js.map +1 -0
  327. package/lib-es/modularDrawer/utils/getBalanceAndFiatValueByAssets.d.ts +11 -0
  328. package/lib-es/modularDrawer/utils/getBalanceAndFiatValueByAssets.d.ts.map +1 -0
  329. package/lib-es/modularDrawer/utils/getBalanceAndFiatValueByAssets.js +41 -0
  330. package/lib-es/modularDrawer/utils/getBalanceAndFiatValueByAssets.js.map +1 -0
  331. package/lib-es/modularDrawer/utils/getProviderCurrency.d.ts +3 -0
  332. package/lib-es/modularDrawer/utils/getProviderCurrency.d.ts.map +1 -0
  333. package/lib-es/modularDrawer/utils/getProviderCurrency.js +10 -0
  334. package/lib-es/modularDrawer/utils/getProviderCurrency.js.map +1 -0
  335. package/lib-es/modularDrawer/utils/groupAccountsByAsset.d.ts +11 -0
  336. package/lib-es/modularDrawer/utils/groupAccountsByAsset.d.ts.map +1 -0
  337. package/lib-es/modularDrawer/utils/groupAccountsByAsset.js +25 -0
  338. package/lib-es/modularDrawer/utils/groupAccountsByAsset.js.map +1 -0
  339. package/lib-es/modularDrawer/utils/parseToBigNumber.d.ts +9 -0
  340. package/lib-es/modularDrawer/utils/parseToBigNumber.d.ts.map +1 -0
  341. package/lib-es/modularDrawer/utils/parseToBigNumber.js +17 -0
  342. package/lib-es/modularDrawer/utils/parseToBigNumber.js.map +1 -0
  343. package/lib-es/modularDrawer/utils/type.d.ts +21 -0
  344. package/lib-es/modularDrawer/utils/type.d.ts.map +1 -0
  345. package/lib-es/modularDrawer/utils/type.js +2 -0
  346. package/lib-es/modularDrawer/utils/type.js.map +1 -0
  347. package/lib-es/utils/__tests__/getAccountTuplesForCurrency.test.js +1 -1
  348. package/lib-es/utils/__tests__/getAccountTuplesForCurrency.test.js.map +1 -1
  349. package/lib-es/wallet-api/Exchange/error.d.ts +1 -0
  350. package/lib-es/wallet-api/Exchange/error.d.ts.map +1 -1
  351. package/lib-es/wallet-api/Exchange/error.js +9 -0
  352. package/lib-es/wallet-api/Exchange/error.js.map +1 -1
  353. package/lib-es/wallet-api/Exchange/server.d.ts +2 -0
  354. package/lib-es/wallet-api/Exchange/server.d.ts.map +1 -1
  355. package/lib-es/wallet-api/Exchange/server.js +30 -6
  356. package/lib-es/wallet-api/Exchange/server.js.map +1 -1
  357. package/lib-es/wallet-api/Exchange/server.test.js +3 -0
  358. package/lib-es/wallet-api/Exchange/server.test.js.map +1 -1
  359. package/package.json +36 -34
  360. package/src/DataModel.test.ts +1 -1
  361. package/src/__tests__/accounts/groupPerDay.ts +1 -1
  362. package/src/__tests__/test-helpers/setup.ts +1 -1
  363. package/src/account/serialization.test.ts +1 -1
  364. package/src/bridge/crypto-assets/index.test.ts +1 -1
  365. package/src/bridge/crypto-assets/index.ts +3 -2
  366. package/src/bridge/generic-alpaca/estimateMaxSpendable.ts +11 -5
  367. package/src/bridge/generic-alpaca/getTransactionStatus.ts +2 -1
  368. package/src/bridge/generic-alpaca/prepareTransaction.ts +20 -16
  369. package/src/bridge/generic-alpaca/signOperation.ts +3 -2
  370. package/src/bridge/generic-alpaca/tests/prepareTransaction.test.ts +1 -1
  371. package/src/bridge/generic-alpaca/utils.ts +0 -2
  372. package/src/bridge/impl.ts +1 -1
  373. package/src/currencies/index.ts +0 -1
  374. package/src/currencies/sortByMarketcap.test.ts +3 -2
  375. package/src/domain/getTokensWithFunds.test.ts +1 -1
  376. package/src/e2e/enum/AppInfos.ts +1 -1
  377. package/src/e2e/enum/DeviceLabels.ts +2 -1
  378. package/src/e2e/enum/Provider.ts +2 -2
  379. package/src/e2e/families/solana.ts +7 -4
  380. package/src/e2e/speculos.ts +4 -5
  381. package/src/e2e/speculosCI.ts +18 -6
  382. package/src/exchange/swap/api/v5/actions.ts +1 -1
  383. package/src/exchange/swap/types.ts +1 -1
  384. package/src/families/bitcoin/__snapshots__/bridge.integration.test.ts.snap +7 -0
  385. package/src/families/bitcoin/satstack.test.ts +1 -1
  386. package/src/families/evm/setup.ts +12 -1
  387. package/src/families/hedera/__snapshots__/bridge.integration.test.ts.snap +464 -1135
  388. package/src/families/hedera/constants.ts +2 -0
  389. package/src/families/hedera/setup.ts +7 -3
  390. package/src/families/solana/setup.ts +2 -0
  391. package/src/families/sui/__snapshots__/bridge.integration.test.ts.snap +3 -1
  392. package/src/families/sui/constants.ts +2 -0
  393. package/src/families/sui/logic.ts +2 -0
  394. package/src/families/sui/react.ts +115 -0
  395. package/src/families/sui/types.ts +2 -0
  396. package/src/families/tron/data.mock.ts +1 -1
  397. package/src/featureFlags/defaultFeatures.ts +1 -0
  398. package/src/market/utils/countervalueFormatter.ts +0 -1
  399. package/src/market/utils/types.ts +4 -0
  400. package/src/modularDrawer/__mocks__/currencies.mock.ts +1 -1
  401. package/src/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.ts +1 -1
  402. package/src/modularDrawer/data/entities/index.ts +79 -0
  403. package/src/modularDrawer/data/state-manager/api.ts +62 -0
  404. package/src/modularDrawer/hooks/__test__/useAssetsData.test.ts +139 -0
  405. package/src/modularDrawer/hooks/modules/useAssetAccountCounts.tsx +36 -0
  406. package/src/modularDrawer/hooks/modules/useLeftApyModule.tsx +26 -0
  407. package/src/modularDrawer/hooks/useAssetsData.ts +36 -0
  408. package/src/modularDrawer/types.ts +1 -0
  409. package/src/modularDrawer/utils/__tests__/counterValueFormatter.test.ts +549 -0
  410. package/src/modularDrawer/utils/__tests__/currencyUtils.test.ts +1 -1
  411. package/src/modularDrawer/utils/__tests__/haveOneCommonProvider.test.ts +2 -2
  412. package/src/modularDrawer/utils/calculateProviderTotal.ts +23 -0
  413. package/src/modularDrawer/utils/counterValueFormatter.ts +165 -0
  414. package/src/modularDrawer/utils/getBalanceAndFiatValueByAssets.ts +76 -0
  415. package/src/modularDrawer/utils/getProviderCurrency.ts +13 -0
  416. package/src/modularDrawer/utils/groupAccountsByAsset.ts +51 -0
  417. package/src/modularDrawer/utils/parseToBigNumber.ts +17 -0
  418. package/src/modularDrawer/utils/type.ts +22 -0
  419. package/src/utils/__tests__/getAccountTuplesForCurrency.test.ts +1 -1
  420. package/src/wallet-api/Exchange/error.ts +10 -0
  421. package/src/wallet-api/Exchange/server.test.ts +5 -1
  422. package/src/wallet-api/Exchange/server.ts +44 -5
@@ -0,0 +1,2 @@
1
+ // Encapsulate for LLD & LLM
2
+ export * from "@ledgerhq/coin-hedera/constants";
@@ -4,17 +4,21 @@ import { createBridges } from "@ledgerhq/coin-hedera/bridge/index";
4
4
  import Transport from "@ledgerhq/hw-transport";
5
5
  import Hedera from "@ledgerhq/hw-app-hedera";
6
6
  import hederaResolver from "@ledgerhq/coin-hedera/signer/index";
7
- import type { Account, Bridge } from "@ledgerhq/types-live";
7
+ import type {
8
+ TransactionStatus,
9
+ Transaction,
10
+ HederaAccount,
11
+ } from "@ledgerhq/coin-hedera/types/index";
12
+ import type { Bridge } from "@ledgerhq/types-live";
8
13
  import makeCliTools from "@ledgerhq/coin-hedera/test/cli";
9
14
  import { CreateSigner, createResolver, executeWithSigner } from "../../bridge/setup";
10
15
  import { Resolver } from "../../hw/getAddress/types";
11
- import { TransactionStatus, Transaction } from "@ledgerhq/coin-hedera/types/index";
12
16
 
13
17
  const createSigner: CreateSigner<Hedera> = (transport: Transport) => {
14
18
  return new Hedera(transport);
15
19
  };
16
20
 
17
- const bridge: Bridge<Transaction, Account, TransactionStatus> = createBridges(
21
+ const bridge: Bridge<Transaction, HederaAccount, TransactionStatus> = createBridges(
18
22
  executeWithSigner(createSigner),
19
23
  );
20
24
 
@@ -19,6 +19,7 @@ import { SolanaCoinConfig } from "@ledgerhq/coin-solana/config";
19
19
  import { getCryptoCurrencyById } from "../../currencies";
20
20
  import { signMessage } from "@ledgerhq/coin-solana/hw-signMessage";
21
21
  import { LegacySignerSolana } from "@ledgerhq/live-signer-solana";
22
+ import { getCryptoAssetsStore } from "../../bridge/crypto-assets";
22
23
 
23
24
  const createSigner: CreateSigner<SolanaSigner> = (transport: Transport) =>
24
25
  new LegacySignerSolana(transport);
@@ -30,6 +31,7 @@ const getCurrencyConfig = () => {
30
31
  const bridge: Bridge<Transaction, SolanaAccount, TransactionStatus> = createBridges(
31
32
  executeWithSigner(createSigner),
32
33
  getCurrencyConfig,
34
+ getCryptoAssetsStore,
33
35
  );
34
36
 
35
37
  const messageSigner = {
@@ -14,9 +14,10 @@ exports[`sui currency bridge scanAccounts sui seed 1 1`] = `
14
14
  "pendingOperations": [],
15
15
  "seedIdentifier": "e5fb8c817b97e9e9aec677b9e822e8a60c7471624f36b701c94560b88195a8e7",
16
16
  "spendableBalance": "102696240",
17
+ "subAccounts": [],
17
18
  "suiResources": {},
18
19
  "swapHistory": [],
19
- "syncHash": undefined,
20
+ "syncHash": "6p9XjoTwZ81o9xTkodgswDbETbrN5Lkv1b2shBN4p99s",
20
21
  "used": true,
21
22
  },
22
23
  {
@@ -31,6 +32,7 @@ exports[`sui currency bridge scanAccounts sui seed 1 1`] = `
31
32
  "pendingOperations": [],
32
33
  "seedIdentifier": "e5fb8c817b97e9e9aec677b9e822e8a60c7471624f36b701c94560b88195a8e7",
33
34
  "spendableBalance": "0",
35
+ "subAccounts": [],
34
36
  "suiResources": {},
35
37
  "swapHistory": [],
36
38
  "syncHash": undefined,
@@ -0,0 +1,2 @@
1
+ // Encapsulate for LLD et LLM
2
+ export * from "@ledgerhq/coin-sui/constants";
@@ -0,0 +1,2 @@
1
+ // Encapsulate for LLD et LLM
2
+ export * from "@ledgerhq/coin-sui/logic";
@@ -0,0 +1,115 @@
1
+ import { useEffect, useMemo, useState } from "react";
2
+ import { FIGMENT_SUI_VALIDATOR_ADDRESS } from "@ledgerhq/coin-sui/constants";
3
+ import { BigNumber } from "bignumber.js";
4
+ import { SuiAccount, SuiResources, SuiValidator, MappedStake } from "./types";
5
+ import { getAccountCurrency } from "../../account";
6
+ import { Unit } from "@ledgerhq/types-cryptoassets";
7
+ import { formatCurrencyUnit } from "@ledgerhq/coin-framework/currencies";
8
+ import { getCurrentSuiPreloadData } from "@ledgerhq/coin-sui/preload";
9
+ import { getOperationExtra } from "@ledgerhq/coin-sui/getOperationExtra";
10
+ import { OperationType } from "@ledgerhq/types-live";
11
+
12
+ export function useSuiMappedStakingPositions(account: SuiAccount) {
13
+ const { validators } = getCurrentSuiPreloadData();
14
+ const stakingPositions = account.suiResources?.stakes;
15
+
16
+ const unit = getAccountCurrency(account).units[0];
17
+
18
+ return useMemo(
19
+ () => mapStakingPositions(stakingPositions ?? [], validators, unit),
20
+ [stakingPositions, validators, unit],
21
+ );
22
+ }
23
+
24
+ export function useGetExtraDetails(account: SuiAccount, type: OperationType, digest: string) {
25
+ if (!account.suiResources) {
26
+ account.suiResources = {};
27
+ }
28
+ if (!account.suiResources.cachedOps) {
29
+ account.suiResources.cachedOps = {};
30
+ }
31
+ const cache = account.suiResources.cachedOps;
32
+ const [data, setData] = useState(cache[digest]);
33
+
34
+ useEffect(() => {
35
+ if (type !== "DELEGATE" && type !== "UNDELEGATE") return;
36
+ if (data) return;
37
+ getOperationExtra(digest).then(result => {
38
+ setData(result);
39
+ cache[digest] = result;
40
+ });
41
+ }, [data, digest, cache, type]);
42
+
43
+ return data;
44
+ }
45
+
46
+ export function useLedgerFirstShuffledValidatorsSui(search: string) {
47
+ const { validators: unorderedValidators } = getCurrentSuiPreloadData();
48
+ const validators = reorderValidators(unorderedValidators);
49
+ return useMemo(() => {
50
+ if (validators.length === 0 || !search || search === "") {
51
+ return validators;
52
+ }
53
+
54
+ const lowercaseSearch = search.toLowerCase();
55
+
56
+ const filtered = validators.filter(
57
+ validator =>
58
+ validator.suiAddress?.toLowerCase().includes(lowercaseSearch) ||
59
+ validator.name.toLowerCase().includes(lowercaseSearch),
60
+ );
61
+
62
+ return filtered;
63
+ }, [validators, search]);
64
+ }
65
+
66
+ function reorderValidators(validators: SuiValidator[]): SuiValidator[] {
67
+ const sortedValidators = [...validators].sort((a, b) =>
68
+ new BigNumber(b.stakingPoolSuiBalance).minus(new BigNumber(a.stakingPoolSuiBalance)).toNumber(),
69
+ );
70
+
71
+ // move Ledger validator to the first position
72
+ const ledgerValidator = sortedValidators.find(
73
+ v => v.suiAddress === FIGMENT_SUI_VALIDATOR_ADDRESS,
74
+ );
75
+
76
+ if (ledgerValidator) {
77
+ const sortedValidatorsLedgerFirst = sortedValidators.filter(
78
+ v => v.suiAddress !== FIGMENT_SUI_VALIDATOR_ADDRESS,
79
+ );
80
+ sortedValidatorsLedgerFirst.unshift(ledgerValidator);
81
+
82
+ return sortedValidatorsLedgerFirst;
83
+ }
84
+
85
+ return sortedValidators;
86
+ }
87
+
88
+ type Stake = Required<SuiResources>["stakes"];
89
+
90
+ export const mapStakingPositions = (
91
+ stakingPositions: Stake,
92
+ validators: SuiValidator[],
93
+ unit: Unit,
94
+ ): MappedStake[] => {
95
+ const data = stakingPositions.flatMap(sp =>
96
+ sp.stakes.map(s => ({ ...s, validatorAddress: sp.validatorAddress })),
97
+ );
98
+ return data.map<MappedStake>(sp => {
99
+ const rank = validators.findIndex(v => v.suiAddress === sp.validatorAddress);
100
+ const validator = validators[rank] ?? sp;
101
+ const formatConfig = {
102
+ disableRounding: false,
103
+ alwaysShowSign: false,
104
+ showCode: true,
105
+ };
106
+
107
+ return {
108
+ ...sp,
109
+ rank,
110
+ validator,
111
+ stakedSuiId: sp.stakedSuiId,
112
+ formattedAmount: formatCurrencyUnit(unit, BigNumber(sp.principal), formatConfig),
113
+ };
114
+ });
115
+ };
@@ -0,0 +1,2 @@
1
+ // Encapsulate for LLD et LLM
2
+ export * from "@ledgerhq/coin-sui/types";
@@ -1,7 +1,7 @@
1
1
  import { fromAccountRaw } from "../../account/serialization";
2
2
  import { TronAccount } from "@ledgerhq/coin-tron/types/index";
3
3
  import { setCryptoAssetsStore as setCryptoAssetsStoreForCoinFramework } from "@ledgerhq/coin-framework/crypto-assets/index";
4
- import { CryptoAssetsStore } from "@ledgerhq/coin-framework/crypto-assets/type";
4
+ import type { CryptoAssetsStore } from "@ledgerhq/types-live";
5
5
 
6
6
  export const __NEXT_REWARD_DATE__ = new Date(Date.now() - 6 * 60 * 60 * 1000);
7
7
 
@@ -625,6 +625,7 @@ export const DEFAULT_FEATURES: Features = {
625
625
  },
626
626
  },
627
627
  lldModularDrawerBackendData: DEFAULT_FEATURE,
628
+ llmModularDrawerBackendData: DEFAULT_FEATURE,
628
629
  llmModularDrawer: {
629
630
  ...DEFAULT_FEATURE,
630
631
  params: {
@@ -12,7 +12,6 @@ export const counterValueFormatter = ({
12
12
  if (!value) {
13
13
  return "-";
14
14
  }
15
-
16
15
  return new Intl.NumberFormat(locale, {
17
16
  style: currency ? "currency" : "decimal",
18
17
  currency,
@@ -144,6 +144,7 @@ export type MarketItemResponse = {
144
144
  circulatingSupply: number;
145
145
  fullyDilutedValuation: number;
146
146
  high24h: number;
147
+ currencyId: string;
147
148
  id: string;
148
149
  image: string;
149
150
  ledgerIds: string[];
@@ -167,6 +168,9 @@ export type MarketItemResponse = {
167
168
  totalVolume: number;
168
169
  updatedAt: string;
169
170
  };
171
+
172
+ export type PartialMarketItemResponse = Partial<MarketItemResponse>;
173
+
170
174
  export type MarketItemPerformer = {
171
175
  id: string;
172
176
  name: string;
@@ -1,5 +1,5 @@
1
- import { getCryptoCurrencyById } from "@ledgerhq/live-common/currencies/index";
2
1
  import { TokenCurrency } from "@ledgerhq/types-cryptoassets";
2
+ import { getCryptoCurrencyById } from "../../currencies";
3
3
 
4
4
  export const mockBtcCryptoCurrency = getCryptoCurrencyById("bitcoin");
5
5
  export const mockEthCryptoCurrency = getCryptoCurrencyById("ethereum");
@@ -1,4 +1,4 @@
1
- import { LoadingStatus } from "@ledgerhq/live-common/deposit/type";
1
+ import { LoadingStatus } from "../../deposit/type";
2
2
  import {
3
3
  arbitrumToken,
4
4
  mockArbitrumCryptoCurrency,
@@ -0,0 +1,79 @@
1
+ import type { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
2
+ import type { ApiAsset } from "@ledgerhq/cryptoassets";
3
+ import { PartialMarketItemResponse } from "@ledgerhq/live-common/market/utils/types";
4
+
5
+ // Types for crypto asset metadata
6
+ export interface CryptoAssetMeta {
7
+ /** Asset identifier */
8
+ id: string;
9
+ /** Asset ticker symbol */
10
+ ticker: string;
11
+ /** Asset display name */
12
+ name: string;
13
+ /** Map of network IDs to their corresponding asset IDs */
14
+ assetsIds: Record<string, string>;
15
+ }
16
+
17
+ // Types for network information
18
+ export interface NetworkInfo {
19
+ /** Network identifier */
20
+ id: string;
21
+ /** Network display name */
22
+ name: string;
23
+ }
24
+
25
+ // Types for interest rate data
26
+ export interface InterestRate {
27
+ /** Currency identifier */
28
+ currencyId: string;
29
+ /** Interest rate value */
30
+ rate: number;
31
+ /** Type of rate (NRR, APR, APY, etc.) */
32
+ type: string;
33
+ /** Timestamp when the rate was fetched */
34
+ fetchAt: string;
35
+ }
36
+
37
+ // Types for currency ordering
38
+ export interface CurrenciesOrder {
39
+ /** Sorting key (e.g., "marketCap") */
40
+ key: string;
41
+ /** Sort order (e.g., "desc") */
42
+ order: string;
43
+ /** Ordered list of currency IDs */
44
+ currenciesIds: string[];
45
+ /** Ordered list of meta-currency IDs */
46
+ metaCurrencyIds: string[];
47
+ }
48
+
49
+ // Types for raw API response (before transformation)
50
+ export interface RawApiResponse {
51
+ /** Grouped crypto assets by meta-currency */
52
+ cryptoAssets: Record<string, CryptoAssetMeta>;
53
+ /** Network information */
54
+ networks: Record<string, NetworkInfo>;
55
+ /** Raw crypto currencies and token currencies from API */
56
+ cryptoOrTokenCurrencies: Record<string, ApiAsset>;
57
+ /** Interest rates for various currencies */
58
+ interestRates: Record<string, InterestRate>;
59
+ /** Market data for currencies */
60
+ markets: Record<string, PartialMarketItemResponse>;
61
+ /** Currency ordering information */
62
+ currenciesOrder: CurrenciesOrder;
63
+ }
64
+
65
+ // Types for transformed API response (after transformation)
66
+ export interface AssetsData {
67
+ /** Grouped crypto assets by meta-currency */
68
+ cryptoAssets: Record<string, CryptoAssetMeta>;
69
+ /** Network information */
70
+ networks: Record<string, NetworkInfo>;
71
+ /** Transformed crypto currencies and token currencies compatible with Ledger Live */
72
+ cryptoOrTokenCurrencies: Record<string, CryptoOrTokenCurrency>;
73
+ /** Interest rates for various currencies */
74
+ interestRates: Record<string, InterestRate>;
75
+ /** Market data for currencies */
76
+ markets: Record<string, PartialMarketItemResponse>;
77
+ /** Currency ordering information */
78
+ currenciesOrder: CurrenciesOrder;
79
+ }
@@ -0,0 +1,62 @@
1
+ import { createApi, fetchBaseQuery, FetchBaseQueryMeta } from "@reduxjs/toolkit/query/react";
2
+ import { convertApiAssets } from "@ledgerhq/cryptoassets";
3
+ import { AssetsData, RawApiResponse } from "../entities";
4
+ import { getEnv } from "@ledgerhq/live-env";
5
+
6
+ export enum AssetsDataTags {
7
+ Assets = "Assets",
8
+ }
9
+
10
+ export interface GetAssetsDataParams {
11
+ cursor?: string;
12
+ search?: string;
13
+ currencyIds?: string[];
14
+ }
15
+
16
+ export interface AssetsDataWithPagination extends AssetsData {
17
+ pagination: {
18
+ nextCursor?: string;
19
+ };
20
+ }
21
+
22
+ function transformAssetsResponse(
23
+ response: RawApiResponse,
24
+ meta?: FetchBaseQueryMeta,
25
+ ): AssetsDataWithPagination {
26
+ const enrichedCryptoOrTokenCurrencies = convertApiAssets(response.cryptoOrTokenCurrencies);
27
+
28
+ const nextCursor = meta?.response?.headers.get("x-ledger-next") || undefined;
29
+
30
+ return {
31
+ ...response,
32
+ cryptoOrTokenCurrencies: enrichedCryptoOrTokenCurrencies,
33
+ pagination: {
34
+ nextCursor,
35
+ },
36
+ };
37
+ }
38
+
39
+ export const assetsDataApi = createApi({
40
+ reducerPath: "assetsDataApi",
41
+ baseQuery: fetchBaseQuery({
42
+ baseUrl: __DEV__ ? getEnv("DADA_API_STAGING") : getEnv("DADA_API_PROD"),
43
+ }),
44
+ tagTypes: [AssetsDataTags.Assets],
45
+ endpoints: build => ({
46
+ getAssetsData: build.query<AssetsDataWithPagination, GetAssetsDataParams>({
47
+ query: ({ cursor, search, currencyIds: _currencyIds }) => ({
48
+ url: "assets",
49
+ params: {
50
+ ...(cursor && { cursor }),
51
+ ...(search && { search }),
52
+ // ...(currencyIds && currencyIds.length > 0 && { currencyIds }),
53
+ pageSize: 100,
54
+ },
55
+ }),
56
+ providesTags: [AssetsDataTags.Assets],
57
+ transformResponse: transformAssetsResponse,
58
+ }),
59
+ }),
60
+ });
61
+
62
+ export const { useGetAssetsDataQuery } = assetsDataApi;
@@ -0,0 +1,139 @@
1
+ /**
2
+ * @jest-environment jsdom
3
+ */
4
+
5
+ import { renderHook } from "@testing-library/react";
6
+ import { useAssetsData } from "../useAssetsData";
7
+ import { useGetAssetsDataQuery } from "../../data/state-manager/api";
8
+
9
+ jest.mock("../../data/state-manager/api", () => ({
10
+ useGetAssetsDataQuery: jest.fn(),
11
+ }));
12
+
13
+ const mockSetCursor = jest.fn();
14
+ jest.mock("react", () => ({
15
+ ...jest.requireActual("react"),
16
+ useState: jest.fn(() => [undefined, mockSetCursor]),
17
+ useCallback: jest.fn(fn => fn),
18
+ useMemo: jest.fn(fn => fn()),
19
+ }));
20
+
21
+ const mockUseGetAssetsDataQuery = jest.mocked(useGetAssetsDataQuery);
22
+
23
+ describe("useAssetsData", () => {
24
+ beforeEach(() => {
25
+ jest.clearAllMocks();
26
+ });
27
+
28
+ it("should return loading state when API is loading", () => {
29
+ mockUseGetAssetsDataQuery.mockReturnValue({
30
+ data: undefined,
31
+ isLoading: true,
32
+ error: undefined,
33
+ refetch: jest.fn(),
34
+ isFetching: false,
35
+ isSuccess: false,
36
+ isError: false,
37
+ currentData: undefined,
38
+ });
39
+
40
+ const { result } = renderHook(() => useAssetsData({}));
41
+
42
+ expect(result.current.isLoading).toBe(true);
43
+ expect(result.current.data).toBe(undefined);
44
+ expect(result.current.hasMore).toBe(false);
45
+ });
46
+
47
+ it("should return data and hasMore when API returns data", () => {
48
+ const mockData = {
49
+ assetsData: [],
50
+ pagination: { nextCursor: "test-cursor" },
51
+ };
52
+ mockUseGetAssetsDataQuery.mockReturnValue({
53
+ data: mockData,
54
+ isLoading: false,
55
+ error: undefined,
56
+ refetch: jest.fn(),
57
+ isFetching: false,
58
+ isSuccess: true,
59
+ isError: false,
60
+ currentData: mockData,
61
+ });
62
+
63
+ const { result } = renderHook(() => useAssetsData({}));
64
+
65
+ expect(result.current.data).toBe(mockData);
66
+ expect(result.current.isLoading).toBe(false);
67
+ expect(result.current.hasMore).toBe(true);
68
+ });
69
+
70
+ it("should return error when API has error", () => {
71
+ const mockError = new Error("API Error");
72
+ mockUseGetAssetsDataQuery.mockReturnValue({
73
+ data: undefined,
74
+ isLoading: false,
75
+ error: mockError,
76
+ refetch: jest.fn(),
77
+ isFetching: false,
78
+ isSuccess: false,
79
+ isError: true,
80
+ currentData: undefined,
81
+ });
82
+
83
+ const { result } = renderHook(() => useAssetsData({}));
84
+
85
+ expect(result.current.error).toBe(mockError);
86
+ expect(result.current.isLoading).toBe(false);
87
+ });
88
+
89
+ it("should call setCursor when loadNext is called and there's a nextCursor", () => {
90
+ const nextCursor = "next-cursor-456";
91
+ mockUseGetAssetsDataQuery.mockReturnValue({
92
+ data: {
93
+ assetsData: [],
94
+ pagination: { nextCursor },
95
+ },
96
+ isLoading: false,
97
+ error: undefined,
98
+ refetch: jest.fn(),
99
+ isFetching: false,
100
+ isSuccess: true,
101
+ isError: false,
102
+ currentData: {
103
+ assetsData: [],
104
+ pagination: { nextCursor },
105
+ },
106
+ });
107
+
108
+ const { result } = renderHook(() => useAssetsData({}));
109
+
110
+ result.current.loadNext();
111
+
112
+ expect(mockSetCursor).toHaveBeenCalledWith(nextCursor);
113
+ });
114
+
115
+ it("should not call setCursor when there's no nextCursor", () => {
116
+ mockUseGetAssetsDataQuery.mockReturnValue({
117
+ data: {
118
+ assetsData: [],
119
+ pagination: { nextCursor: undefined },
120
+ },
121
+ isLoading: false,
122
+ error: undefined,
123
+ refetch: jest.fn(),
124
+ isFetching: false,
125
+ isSuccess: true,
126
+ isError: false,
127
+ currentData: {
128
+ assetsData: [],
129
+ pagination: { nextCursor: undefined },
130
+ },
131
+ });
132
+
133
+ const { result } = renderHook(() => useAssetsData({}));
134
+
135
+ result.current.loadNext();
136
+
137
+ expect(mockSetCursor).not.toHaveBeenCalled();
138
+ });
139
+ });
@@ -0,0 +1,36 @@
1
+ import { Observable } from "rxjs";
2
+ import { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
3
+ import { getAccountTuplesForCurrency } from "../../../utils/getAccountTuplesForCurrency";
4
+ import type { Account } from "@ledgerhq/types-live";
5
+ import { WalletAPIAccount } from "../../../wallet-api/types";
6
+
7
+ type AccountModuleParams = {
8
+ assets: CryptoOrTokenCurrency[];
9
+ nestedAccounts: Account[];
10
+ accountIds: Map<string, boolean> | undefined;
11
+ formatLabel: (count: number) => string;
12
+ accounts$?: Observable<WalletAPIAccount[]>;
13
+ };
14
+
15
+ export type AssetCountItem = {
16
+ asset: CryptoOrTokenCurrency;
17
+ label: string;
18
+ count: number;
19
+ };
20
+
21
+ export const useAssetAccountCounts = ({
22
+ assets,
23
+ nestedAccounts,
24
+ accountIds,
25
+ formatLabel,
26
+ }: AccountModuleParams): AssetCountItem[] =>
27
+ assets
28
+ .map(asset => {
29
+ const { length } = getAccountTuplesForCurrency(asset, nestedAccounts, accountIds);
30
+ return {
31
+ asset,
32
+ label: formatLabel(length),
33
+ count: length,
34
+ };
35
+ })
36
+ .sort((a, b) => b.count - a.count);
@@ -0,0 +1,26 @@
1
+ import React from "react";
2
+ import { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
3
+ import { ApyType } from "../../types";
4
+
5
+ const createApyItem = ({
6
+ value,
7
+ type,
8
+ ApyIndicator,
9
+ }: {
10
+ value: number;
11
+ type: ApyType;
12
+ ApyIndicator: React.ComponentType<{ value: number; type: ApyType }>;
13
+ }) => <ApyIndicator value={value} type={type} />;
14
+
15
+ export const useLeftApyModule = (
16
+ assets: CryptoOrTokenCurrency[],
17
+ ApyIndicator: React.ComponentType<{ value: number; type: ApyType }>,
18
+ ) => {
19
+ const value = 5.11; // TODO to be retrieved from DADA
20
+ const type = "APY"; // TODO to be retrieved from DADA
21
+
22
+ return assets.map(asset => ({
23
+ ...asset,
24
+ leftElement: createApyItem({ value, type, ApyIndicator }),
25
+ }));
26
+ };
@@ -0,0 +1,36 @@
1
+ import { useState, useCallback } from "react";
2
+ import { useGetAssetsDataQuery } from "../data/state-manager/api";
3
+
4
+ export function useAssetsData({
5
+ search,
6
+ currencyIds,
7
+ }: {
8
+ search?: string;
9
+ currencyIds?: string[];
10
+ }) {
11
+ const [cursor, setCursor] = useState<string | undefined>(undefined);
12
+ const { data, error, isLoading, isSuccess } = useGetAssetsDataQuery({
13
+ cursor,
14
+ search,
15
+ currencyIds,
16
+ });
17
+
18
+ const loadNext = useCallback(() => {
19
+ const nextCursor = data?.pagination?.nextCursor;
20
+ if (nextCursor) {
21
+ setCursor(nextCursor);
22
+ }
23
+ }, [data?.pagination?.nextCursor]);
24
+
25
+ const hasMore = Boolean(data?.pagination?.nextCursor);
26
+
27
+ return {
28
+ data,
29
+ error,
30
+ isLoading,
31
+ isSuccess,
32
+ hasMore,
33
+ cursor,
34
+ loadNext,
35
+ };
36
+ }
@@ -0,0 +1 @@
1
+ export type ApyType = "NRR" | "APY" | "APR";