@ledgerhq/live-common 34.46.0 → 34.47.0-nightly.1

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 (434) hide show
  1. package/lib/__tests__/test-helpers/environment.js +2 -0
  2. package/lib/__tests__/test-helpers/environment.js.map +1 -1
  3. package/lib/bridge/crypto-assets/index.d.ts +1 -1
  4. package/lib/bridge/crypto-assets/index.d.ts.map +1 -1
  5. package/lib/bridge/crypto-assets/index.js +1 -1
  6. package/lib/bridge/crypto-assets/index.js.map +1 -1
  7. package/lib/bridge/generic-alpaca/estimateMaxSpendable.d.ts.map +1 -1
  8. package/lib/bridge/generic-alpaca/estimateMaxSpendable.js +6 -4
  9. package/lib/bridge/generic-alpaca/estimateMaxSpendable.js.map +1 -1
  10. package/lib/bridge/generic-alpaca/getTransactionStatus.d.ts.map +1 -1
  11. package/lib/bridge/generic-alpaca/getTransactionStatus.js +2 -2
  12. package/lib/bridge/generic-alpaca/getTransactionStatus.js.map +1 -1
  13. package/lib/bridge/generic-alpaca/prepareTransaction.d.ts.map +1 -1
  14. package/lib/bridge/generic-alpaca/prepareTransaction.js +12 -12
  15. package/lib/bridge/generic-alpaca/prepareTransaction.js.map +1 -1
  16. package/lib/bridge/generic-alpaca/signOperation.d.ts.map +1 -1
  17. package/lib/bridge/generic-alpaca/signOperation.js +3 -4
  18. package/lib/bridge/generic-alpaca/signOperation.js.map +1 -1
  19. package/lib/bridge/generic-alpaca/tests/prepareTransaction.test.js +1 -1
  20. package/lib/bridge/generic-alpaca/tests/prepareTransaction.test.js.map +1 -1
  21. package/lib/bridge/generic-alpaca/utils.d.ts +0 -1
  22. package/lib/bridge/generic-alpaca/utils.d.ts.map +1 -1
  23. package/lib/bridge/generic-alpaca/utils.js +0 -1
  24. package/lib/bridge/generic-alpaca/utils.js.map +1 -1
  25. package/lib/bridge/impl.d.ts +1 -1
  26. package/lib/bridge/impl.d.ts.map +1 -1
  27. package/lib/currencies/index.d.ts +1 -1
  28. package/lib/currencies/index.d.ts.map +1 -1
  29. package/lib/currencies/index.js +1 -2
  30. package/lib/currencies/index.js.map +1 -1
  31. package/lib/currencies/sortByMarketcap.test.js +2 -1
  32. package/lib/currencies/sortByMarketcap.test.js.map +1 -1
  33. package/lib/domain/getTokensWithFunds.test.js +1 -1
  34. package/lib/domain/getTokensWithFunds.test.js.map +1 -1
  35. package/lib/e2e/enum/AppInfos.d.ts +1 -1
  36. package/lib/e2e/enum/AppInfos.d.ts.map +1 -1
  37. package/lib/e2e/enum/DeviceLabels.d.ts +3 -2
  38. package/lib/e2e/enum/DeviceLabels.d.ts.map +1 -1
  39. package/lib/e2e/enum/DeviceLabels.js +2 -1
  40. package/lib/e2e/enum/DeviceLabels.js.map +1 -1
  41. package/lib/e2e/enum/Provider.d.ts.map +1 -1
  42. package/lib/e2e/enum/Provider.js +2 -2
  43. package/lib/e2e/enum/Provider.js.map +1 -1
  44. package/lib/e2e/families/solana.d.ts.map +1 -1
  45. package/lib/e2e/families/solana.js +4 -4
  46. package/lib/e2e/families/solana.js.map +1 -1
  47. package/lib/e2e/index.d.ts +5 -0
  48. package/lib/e2e/index.d.ts.map +1 -1
  49. package/lib/e2e/speculos.d.ts.map +1 -1
  50. package/lib/e2e/speculos.js +4 -5
  51. package/lib/e2e/speculos.js.map +1 -1
  52. package/lib/e2e/speculosCI.d.ts +4 -0
  53. package/lib/e2e/speculosCI.d.ts.map +1 -1
  54. package/lib/e2e/speculosCI.js +16 -6
  55. package/lib/e2e/speculosCI.js.map +1 -1
  56. package/lib/env.react.d.ts +1 -1
  57. package/lib/env.react.d.ts.map +1 -1
  58. package/lib/exchange/swap/api/v5/actions.js +1 -1
  59. package/lib/exchange/swap/api/v5/actions.js.map +1 -1
  60. package/lib/exchange/swap/types.d.ts +1 -1
  61. package/lib/exchange/swap/types.d.ts.map +1 -1
  62. package/lib/families/canton/config.d.ts.map +1 -1
  63. package/lib/families/canton/config.js +35 -1
  64. package/lib/families/canton/config.js.map +1 -1
  65. package/lib/families/evm/setup.d.ts.map +1 -1
  66. package/lib/families/evm/setup.js +11 -1
  67. package/lib/families/evm/setup.js.map +1 -1
  68. package/lib/families/hedera/constants.d.ts +2 -0
  69. package/lib/families/hedera/constants.d.ts.map +1 -0
  70. package/lib/families/hedera/constants.js +19 -0
  71. package/lib/families/hedera/constants.js.map +1 -0
  72. package/lib/families/hedera/setup.d.ts +5 -5
  73. package/lib/families/hedera/setup.d.ts.map +1 -1
  74. package/lib/families/hedera/setup.js.map +1 -1
  75. package/lib/families/solana/setup.d.ts.map +1 -1
  76. package/lib/families/solana/setup.js +2 -1
  77. package/lib/families/solana/setup.js.map +1 -1
  78. package/lib/families/sui/constants.d.ts +2 -0
  79. package/lib/families/sui/constants.d.ts.map +1 -0
  80. package/lib/families/sui/constants.js +19 -0
  81. package/lib/families/sui/constants.js.map +1 -0
  82. package/lib/families/sui/logic.d.ts +2 -0
  83. package/lib/families/sui/logic.d.ts.map +1 -0
  84. package/lib/families/sui/logic.js +19 -0
  85. package/lib/families/sui/logic.js.map +1 -0
  86. package/lib/families/sui/react.d.ts +8 -0
  87. package/lib/families/sui/react.d.ts.map +1 -0
  88. package/lib/families/sui/react.js +85 -0
  89. package/lib/families/sui/react.js.map +1 -0
  90. package/lib/families/sui/types.d.ts +2 -0
  91. package/lib/families/sui/types.d.ts.map +1 -0
  92. package/lib/families/sui/types.js +19 -0
  93. package/lib/families/sui/types.js.map +1 -0
  94. package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
  95. package/lib/featureFlags/defaultFeatures.js +1 -0
  96. package/lib/featureFlags/defaultFeatures.js.map +1 -1
  97. package/lib/featureFlags/useFeature.d.ts +1 -1
  98. package/lib/featureFlags/useFeature.d.ts.map +1 -1
  99. package/lib/generated/bridge/js.d.ts +1 -1
  100. package/lib/market/utils/countervalueFormatter.d.ts.map +1 -1
  101. package/lib/market/utils/countervalueFormatter.js.map +1 -1
  102. package/lib/market/utils/types.d.ts +2 -0
  103. package/lib/market/utils/types.d.ts.map +1 -1
  104. package/lib/modularDrawer/__mocks__/currencies.mock.d.ts.map +1 -1
  105. package/lib/modularDrawer/__mocks__/currencies.mock.js +7 -7
  106. package/lib/modularDrawer/__mocks__/currencies.mock.js.map +1 -1
  107. package/lib/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.js +1 -1
  108. package/lib/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.js.map +1 -1
  109. package/lib/modularDrawer/data/entities/index.d.ts +68 -0
  110. package/lib/modularDrawer/data/entities/index.d.ts.map +1 -0
  111. package/lib/modularDrawer/data/entities/index.js +3 -0
  112. package/lib/modularDrawer/data/entities/index.js.map +1 -0
  113. package/lib/modularDrawer/data/state-manager/api.d.ts +857 -0
  114. package/lib/modularDrawer/data/state-manager/api.d.ts.map +1 -0
  115. package/lib/modularDrawer/data/state-manager/api.js +63 -0
  116. package/lib/modularDrawer/data/state-manager/api.js.map +1 -0
  117. package/lib/modularDrawer/hooks/__test__/useAssetsData.test.d.ts +5 -0
  118. package/lib/modularDrawer/hooks/__test__/useAssetsData.test.d.ts.map +1 -0
  119. package/lib/modularDrawer/hooks/__test__/useAssetsData.test.js +176 -0
  120. package/lib/modularDrawer/hooks/__test__/useAssetsData.test.js.map +1 -0
  121. package/lib/modularDrawer/hooks/modules/useAssetAccountCounts.d.ts +19 -0
  122. package/lib/modularDrawer/hooks/modules/useAssetAccountCounts.d.ts.map +1 -0
  123. package/lib/modularDrawer/hooks/modules/useAssetAccountCounts.js +16 -0
  124. package/lib/modularDrawer/hooks/modules/useAssetAccountCounts.js.map +1 -0
  125. package/lib/modularDrawer/hooks/modules/useLeftApyModule.d.ts +52 -0
  126. package/lib/modularDrawer/hooks/modules/useLeftApyModule.d.ts.map +1 -0
  127. package/lib/modularDrawer/hooks/modules/useLeftApyModule.js +18 -0
  128. package/lib/modularDrawer/hooks/modules/useLeftApyModule.js.map +1 -0
  129. package/lib/modularDrawer/hooks/useAssetsData.d.ts +12 -0
  130. package/lib/modularDrawer/hooks/useAssetsData.d.ts.map +1 -0
  131. package/lib/modularDrawer/hooks/useAssetsData.js +50 -0
  132. package/lib/modularDrawer/hooks/useAssetsData.js.map +1 -0
  133. package/lib/modularDrawer/types.d.ts +2 -0
  134. package/lib/modularDrawer/types.d.ts.map +1 -0
  135. package/lib/modularDrawer/types.js +3 -0
  136. package/lib/modularDrawer/types.js.map +1 -0
  137. package/lib/modularDrawer/utils/__tests__/counterValueFormatter.test.d.ts +2 -0
  138. package/lib/modularDrawer/utils/__tests__/counterValueFormatter.test.d.ts.map +1 -0
  139. package/lib/modularDrawer/utils/__tests__/counterValueFormatter.test.js +496 -0
  140. package/lib/modularDrawer/utils/__tests__/counterValueFormatter.test.js.map +1 -0
  141. package/lib/modularDrawer/utils/__tests__/currencyUtils.test.js +1 -1
  142. package/lib/modularDrawer/utils/__tests__/currencyUtils.test.js.map +1 -1
  143. package/lib/modularDrawer/utils/__tests__/haveOneCommonProvider.test.js +1 -1
  144. package/lib/modularDrawer/utils/__tests__/haveOneCommonProvider.test.js.map +1 -1
  145. package/lib/modularDrawer/utils/calculateProviderTotal.d.ts +9 -0
  146. package/lib/modularDrawer/utils/calculateProviderTotal.d.ts.map +1 -0
  147. package/lib/modularDrawer/utils/calculateProviderTotal.js +23 -0
  148. package/lib/modularDrawer/utils/calculateProviderTotal.js.map +1 -0
  149. package/lib/modularDrawer/utils/counterValueFormatter.d.ts +14 -0
  150. package/lib/modularDrawer/utils/counterValueFormatter.d.ts.map +1 -0
  151. package/lib/modularDrawer/utils/counterValueFormatter.js +107 -0
  152. package/lib/modularDrawer/utils/counterValueFormatter.js.map +1 -0
  153. package/lib/modularDrawer/utils/getBalanceAndFiatValueByAssets.d.ts +11 -0
  154. package/lib/modularDrawer/utils/getBalanceAndFiatValueByAssets.d.ts.map +1 -0
  155. package/lib/modularDrawer/utils/getBalanceAndFiatValueByAssets.js +45 -0
  156. package/lib/modularDrawer/utils/getBalanceAndFiatValueByAssets.js.map +1 -0
  157. package/lib/modularDrawer/utils/getProviderCurrency.d.ts +3 -0
  158. package/lib/modularDrawer/utils/getProviderCurrency.d.ts.map +1 -0
  159. package/lib/modularDrawer/utils/getProviderCurrency.js +14 -0
  160. package/lib/modularDrawer/utils/getProviderCurrency.js.map +1 -0
  161. package/lib/modularDrawer/utils/groupAccountsByAsset.d.ts +11 -0
  162. package/lib/modularDrawer/utils/groupAccountsByAsset.d.ts.map +1 -0
  163. package/lib/modularDrawer/utils/groupAccountsByAsset.js +32 -0
  164. package/lib/modularDrawer/utils/groupAccountsByAsset.js.map +1 -0
  165. package/lib/modularDrawer/utils/parseToBigNumber.d.ts +9 -0
  166. package/lib/modularDrawer/utils/parseToBigNumber.d.ts.map +1 -0
  167. package/lib/modularDrawer/utils/parseToBigNumber.js +24 -0
  168. package/lib/modularDrawer/utils/parseToBigNumber.js.map +1 -0
  169. package/lib/modularDrawer/utils/type.d.ts +21 -0
  170. package/lib/modularDrawer/utils/type.d.ts.map +1 -0
  171. package/lib/modularDrawer/utils/type.js +3 -0
  172. package/lib/modularDrawer/utils/type.js.map +1 -0
  173. package/lib/utils/__tests__/getAccountTuplesForCurrency.test.js +1 -1
  174. package/lib/utils/__tests__/getAccountTuplesForCurrency.test.js.map +1 -1
  175. package/lib/wallet-api/Exchange/error.d.ts +1 -0
  176. package/lib/wallet-api/Exchange/error.d.ts.map +1 -1
  177. package/lib/wallet-api/Exchange/error.js +11 -1
  178. package/lib/wallet-api/Exchange/error.js.map +1 -1
  179. package/lib/wallet-api/Exchange/server.d.ts +2 -0
  180. package/lib/wallet-api/Exchange/server.d.ts.map +1 -1
  181. package/lib/wallet-api/Exchange/server.js +29 -5
  182. package/lib/wallet-api/Exchange/server.js.map +1 -1
  183. package/lib/wallet-api/Exchange/server.test.js +3 -0
  184. package/lib/wallet-api/Exchange/server.test.js.map +1 -1
  185. package/lib-es/__tests__/test-helpers/environment.js +2 -0
  186. package/lib-es/__tests__/test-helpers/environment.js.map +1 -1
  187. package/lib-es/bridge/crypto-assets/index.d.ts +1 -1
  188. package/lib-es/bridge/crypto-assets/index.d.ts.map +1 -1
  189. package/lib-es/bridge/crypto-assets/index.js +1 -1
  190. package/lib-es/bridge/crypto-assets/index.js.map +1 -1
  191. package/lib-es/bridge/generic-alpaca/estimateMaxSpendable.d.ts.map +1 -1
  192. package/lib-es/bridge/generic-alpaca/estimateMaxSpendable.js +6 -4
  193. package/lib-es/bridge/generic-alpaca/estimateMaxSpendable.js.map +1 -1
  194. package/lib-es/bridge/generic-alpaca/getTransactionStatus.d.ts.map +1 -1
  195. package/lib-es/bridge/generic-alpaca/getTransactionStatus.js +2 -2
  196. package/lib-es/bridge/generic-alpaca/getTransactionStatus.js.map +1 -1
  197. package/lib-es/bridge/generic-alpaca/prepareTransaction.d.ts.map +1 -1
  198. package/lib-es/bridge/generic-alpaca/prepareTransaction.js +12 -12
  199. package/lib-es/bridge/generic-alpaca/prepareTransaction.js.map +1 -1
  200. package/lib-es/bridge/generic-alpaca/signOperation.d.ts.map +1 -1
  201. package/lib-es/bridge/generic-alpaca/signOperation.js +3 -4
  202. package/lib-es/bridge/generic-alpaca/signOperation.js.map +1 -1
  203. package/lib-es/bridge/generic-alpaca/tests/prepareTransaction.test.js +1 -1
  204. package/lib-es/bridge/generic-alpaca/tests/prepareTransaction.test.js.map +1 -1
  205. package/lib-es/bridge/generic-alpaca/utils.d.ts +0 -1
  206. package/lib-es/bridge/generic-alpaca/utils.d.ts.map +1 -1
  207. package/lib-es/bridge/generic-alpaca/utils.js +0 -1
  208. package/lib-es/bridge/generic-alpaca/utils.js.map +1 -1
  209. package/lib-es/bridge/impl.d.ts +1 -1
  210. package/lib-es/bridge/impl.d.ts.map +1 -1
  211. package/lib-es/currencies/index.d.ts +1 -1
  212. package/lib-es/currencies/index.d.ts.map +1 -1
  213. package/lib-es/currencies/index.js +1 -1
  214. package/lib-es/currencies/index.js.map +1 -1
  215. package/lib-es/currencies/sortByMarketcap.test.js +2 -1
  216. package/lib-es/currencies/sortByMarketcap.test.js.map +1 -1
  217. package/lib-es/domain/getTokensWithFunds.test.js +1 -1
  218. package/lib-es/domain/getTokensWithFunds.test.js.map +1 -1
  219. package/lib-es/e2e/enum/AppInfos.d.ts +1 -1
  220. package/lib-es/e2e/enum/AppInfos.d.ts.map +1 -1
  221. package/lib-es/e2e/enum/DeviceLabels.d.ts +3 -2
  222. package/lib-es/e2e/enum/DeviceLabels.d.ts.map +1 -1
  223. package/lib-es/e2e/enum/DeviceLabels.js +2 -1
  224. package/lib-es/e2e/enum/DeviceLabels.js.map +1 -1
  225. package/lib-es/e2e/enum/Provider.d.ts.map +1 -1
  226. package/lib-es/e2e/enum/Provider.js +2 -2
  227. package/lib-es/e2e/enum/Provider.js.map +1 -1
  228. package/lib-es/e2e/families/solana.d.ts.map +1 -1
  229. package/lib-es/e2e/families/solana.js +4 -4
  230. package/lib-es/e2e/families/solana.js.map +1 -1
  231. package/lib-es/e2e/index.d.ts +5 -0
  232. package/lib-es/e2e/index.d.ts.map +1 -1
  233. package/lib-es/e2e/speculos.d.ts.map +1 -1
  234. package/lib-es/e2e/speculos.js +4 -5
  235. package/lib-es/e2e/speculos.js.map +1 -1
  236. package/lib-es/e2e/speculosCI.d.ts +4 -0
  237. package/lib-es/e2e/speculosCI.d.ts.map +1 -1
  238. package/lib-es/e2e/speculosCI.js +14 -5
  239. package/lib-es/e2e/speculosCI.js.map +1 -1
  240. package/lib-es/env.react.d.ts +1 -1
  241. package/lib-es/env.react.d.ts.map +1 -1
  242. package/lib-es/exchange/swap/api/v5/actions.js +1 -1
  243. package/lib-es/exchange/swap/api/v5/actions.js.map +1 -1
  244. package/lib-es/exchange/swap/types.d.ts +1 -1
  245. package/lib-es/exchange/swap/types.d.ts.map +1 -1
  246. package/lib-es/families/canton/config.d.ts.map +1 -1
  247. package/lib-es/families/canton/config.js +35 -1
  248. package/lib-es/families/canton/config.js.map +1 -1
  249. package/lib-es/families/evm/setup.d.ts.map +1 -1
  250. package/lib-es/families/evm/setup.js +11 -1
  251. package/lib-es/families/evm/setup.js.map +1 -1
  252. package/lib-es/families/hedera/constants.d.ts +2 -0
  253. package/lib-es/families/hedera/constants.d.ts.map +1 -0
  254. package/lib-es/families/hedera/constants.js +3 -0
  255. package/lib-es/families/hedera/constants.js.map +1 -0
  256. package/lib-es/families/hedera/setup.d.ts +5 -5
  257. package/lib-es/families/hedera/setup.d.ts.map +1 -1
  258. package/lib-es/families/hedera/setup.js.map +1 -1
  259. package/lib-es/families/solana/setup.d.ts.map +1 -1
  260. package/lib-es/families/solana/setup.js +2 -1
  261. package/lib-es/families/solana/setup.js.map +1 -1
  262. package/lib-es/families/sui/constants.d.ts +2 -0
  263. package/lib-es/families/sui/constants.d.ts.map +1 -0
  264. package/lib-es/families/sui/constants.js +3 -0
  265. package/lib-es/families/sui/constants.js.map +1 -0
  266. package/lib-es/families/sui/logic.d.ts +2 -0
  267. package/lib-es/families/sui/logic.d.ts.map +1 -0
  268. package/lib-es/families/sui/logic.js +3 -0
  269. package/lib-es/families/sui/logic.js.map +1 -0
  270. package/lib-es/families/sui/react.d.ts +8 -0
  271. package/lib-es/families/sui/react.d.ts.map +1 -0
  272. package/lib-es/families/sui/react.js +78 -0
  273. package/lib-es/families/sui/react.js.map +1 -0
  274. package/lib-es/families/sui/types.d.ts +2 -0
  275. package/lib-es/families/sui/types.d.ts.map +1 -0
  276. package/lib-es/families/sui/types.js +3 -0
  277. package/lib-es/families/sui/types.js.map +1 -0
  278. package/lib-es/featureFlags/defaultFeatures.d.ts.map +1 -1
  279. package/lib-es/featureFlags/defaultFeatures.js +1 -0
  280. package/lib-es/featureFlags/defaultFeatures.js.map +1 -1
  281. package/lib-es/featureFlags/useFeature.d.ts +1 -1
  282. package/lib-es/featureFlags/useFeature.d.ts.map +1 -1
  283. package/lib-es/generated/bridge/js.d.ts +1 -1
  284. package/lib-es/market/utils/countervalueFormatter.d.ts.map +1 -1
  285. package/lib-es/market/utils/countervalueFormatter.js.map +1 -1
  286. package/lib-es/market/utils/types.d.ts +2 -0
  287. package/lib-es/market/utils/types.d.ts.map +1 -1
  288. package/lib-es/modularDrawer/__mocks__/currencies.mock.d.ts.map +1 -1
  289. package/lib-es/modularDrawer/__mocks__/currencies.mock.js +1 -1
  290. package/lib-es/modularDrawer/__mocks__/currencies.mock.js.map +1 -1
  291. package/lib-es/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.js +1 -1
  292. package/lib-es/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.js.map +1 -1
  293. package/lib-es/modularDrawer/data/entities/index.d.ts +68 -0
  294. package/lib-es/modularDrawer/data/entities/index.d.ts.map +1 -0
  295. package/lib-es/modularDrawer/data/entities/index.js +2 -0
  296. package/lib-es/modularDrawer/data/entities/index.js.map +1 -0
  297. package/lib-es/modularDrawer/data/state-manager/api.d.ts +857 -0
  298. package/lib-es/modularDrawer/data/state-manager/api.d.ts.map +1 -0
  299. package/lib-es/modularDrawer/data/state-manager/api.js +60 -0
  300. package/lib-es/modularDrawer/data/state-manager/api.js.map +1 -0
  301. package/lib-es/modularDrawer/hooks/__test__/useAssetsData.test.d.ts +5 -0
  302. package/lib-es/modularDrawer/hooks/__test__/useAssetsData.test.d.ts.map +1 -0
  303. package/lib-es/modularDrawer/hooks/__test__/useAssetsData.test.js +174 -0
  304. package/lib-es/modularDrawer/hooks/__test__/useAssetsData.test.js.map +1 -0
  305. package/lib-es/modularDrawer/hooks/modules/useAssetAccountCounts.d.ts +19 -0
  306. package/lib-es/modularDrawer/hooks/modules/useAssetAccountCounts.d.ts.map +1 -0
  307. package/lib-es/modularDrawer/hooks/modules/useAssetAccountCounts.js +12 -0
  308. package/lib-es/modularDrawer/hooks/modules/useAssetAccountCounts.js.map +1 -0
  309. package/lib-es/modularDrawer/hooks/modules/useLeftApyModule.d.ts +52 -0
  310. package/lib-es/modularDrawer/hooks/modules/useLeftApyModule.d.ts.map +1 -0
  311. package/lib-es/modularDrawer/hooks/modules/useLeftApyModule.js +11 -0
  312. package/lib-es/modularDrawer/hooks/modules/useLeftApyModule.js.map +1 -0
  313. package/lib-es/modularDrawer/hooks/useAssetsData.d.ts +12 -0
  314. package/lib-es/modularDrawer/hooks/useAssetsData.d.ts.map +1 -0
  315. package/lib-es/modularDrawer/hooks/useAssetsData.js +46 -0
  316. package/lib-es/modularDrawer/hooks/useAssetsData.js.map +1 -0
  317. package/lib-es/modularDrawer/types.d.ts +2 -0
  318. package/lib-es/modularDrawer/types.d.ts.map +1 -0
  319. package/lib-es/modularDrawer/types.js +2 -0
  320. package/lib-es/modularDrawer/types.js.map +1 -0
  321. package/lib-es/modularDrawer/utils/__tests__/counterValueFormatter.test.d.ts +2 -0
  322. package/lib-es/modularDrawer/utils/__tests__/counterValueFormatter.test.d.ts.map +1 -0
  323. package/lib-es/modularDrawer/utils/__tests__/counterValueFormatter.test.js +494 -0
  324. package/lib-es/modularDrawer/utils/__tests__/counterValueFormatter.test.js.map +1 -0
  325. package/lib-es/modularDrawer/utils/__tests__/currencyUtils.test.js +1 -1
  326. package/lib-es/modularDrawer/utils/__tests__/currencyUtils.test.js.map +1 -1
  327. package/lib-es/modularDrawer/utils/__tests__/haveOneCommonProvider.test.js +1 -1
  328. package/lib-es/modularDrawer/utils/__tests__/haveOneCommonProvider.test.js.map +1 -1
  329. package/lib-es/modularDrawer/utils/calculateProviderTotal.d.ts +9 -0
  330. package/lib-es/modularDrawer/utils/calculateProviderTotal.d.ts.map +1 -0
  331. package/lib-es/modularDrawer/utils/calculateProviderTotal.js +16 -0
  332. package/lib-es/modularDrawer/utils/calculateProviderTotal.js.map +1 -0
  333. package/lib-es/modularDrawer/utils/counterValueFormatter.d.ts +14 -0
  334. package/lib-es/modularDrawer/utils/counterValueFormatter.d.ts.map +1 -0
  335. package/lib-es/modularDrawer/utils/counterValueFormatter.js +103 -0
  336. package/lib-es/modularDrawer/utils/counterValueFormatter.js.map +1 -0
  337. package/lib-es/modularDrawer/utils/getBalanceAndFiatValueByAssets.d.ts +11 -0
  338. package/lib-es/modularDrawer/utils/getBalanceAndFiatValueByAssets.d.ts.map +1 -0
  339. package/lib-es/modularDrawer/utils/getBalanceAndFiatValueByAssets.js +41 -0
  340. package/lib-es/modularDrawer/utils/getBalanceAndFiatValueByAssets.js.map +1 -0
  341. package/lib-es/modularDrawer/utils/getProviderCurrency.d.ts +3 -0
  342. package/lib-es/modularDrawer/utils/getProviderCurrency.d.ts.map +1 -0
  343. package/lib-es/modularDrawer/utils/getProviderCurrency.js +10 -0
  344. package/lib-es/modularDrawer/utils/getProviderCurrency.js.map +1 -0
  345. package/lib-es/modularDrawer/utils/groupAccountsByAsset.d.ts +11 -0
  346. package/lib-es/modularDrawer/utils/groupAccountsByAsset.d.ts.map +1 -0
  347. package/lib-es/modularDrawer/utils/groupAccountsByAsset.js +25 -0
  348. package/lib-es/modularDrawer/utils/groupAccountsByAsset.js.map +1 -0
  349. package/lib-es/modularDrawer/utils/parseToBigNumber.d.ts +9 -0
  350. package/lib-es/modularDrawer/utils/parseToBigNumber.d.ts.map +1 -0
  351. package/lib-es/modularDrawer/utils/parseToBigNumber.js +17 -0
  352. package/lib-es/modularDrawer/utils/parseToBigNumber.js.map +1 -0
  353. package/lib-es/modularDrawer/utils/type.d.ts +21 -0
  354. package/lib-es/modularDrawer/utils/type.d.ts.map +1 -0
  355. package/lib-es/modularDrawer/utils/type.js +2 -0
  356. package/lib-es/modularDrawer/utils/type.js.map +1 -0
  357. package/lib-es/utils/__tests__/getAccountTuplesForCurrency.test.js +1 -1
  358. package/lib-es/utils/__tests__/getAccountTuplesForCurrency.test.js.map +1 -1
  359. package/lib-es/wallet-api/Exchange/error.d.ts +1 -0
  360. package/lib-es/wallet-api/Exchange/error.d.ts.map +1 -1
  361. package/lib-es/wallet-api/Exchange/error.js +9 -0
  362. package/lib-es/wallet-api/Exchange/error.js.map +1 -1
  363. package/lib-es/wallet-api/Exchange/server.d.ts +2 -0
  364. package/lib-es/wallet-api/Exchange/server.d.ts.map +1 -1
  365. package/lib-es/wallet-api/Exchange/server.js +30 -6
  366. package/lib-es/wallet-api/Exchange/server.js.map +1 -1
  367. package/lib-es/wallet-api/Exchange/server.test.js +3 -0
  368. package/lib-es/wallet-api/Exchange/server.test.js.map +1 -1
  369. package/package.json +68 -66
  370. package/src/DataModel.test.ts +1 -1
  371. package/src/__tests__/accounts/groupPerDay.ts +1 -1
  372. package/src/__tests__/test-helpers/environment.ts +2 -0
  373. package/src/__tests__/test-helpers/setup.ts +1 -1
  374. package/src/account/serialization.test.ts +1 -1
  375. package/src/bridge/crypto-assets/index.test.ts +1 -1
  376. package/src/bridge/crypto-assets/index.ts +3 -2
  377. package/src/bridge/generic-alpaca/estimateMaxSpendable.ts +11 -5
  378. package/src/bridge/generic-alpaca/getTransactionStatus.ts +2 -1
  379. package/src/bridge/generic-alpaca/prepareTransaction.ts +20 -16
  380. package/src/bridge/generic-alpaca/signOperation.ts +3 -2
  381. package/src/bridge/generic-alpaca/tests/prepareTransaction.test.ts +1 -1
  382. package/src/bridge/generic-alpaca/utils.ts +0 -2
  383. package/src/bridge/impl.ts +1 -1
  384. package/src/currencies/index.ts +0 -1
  385. package/src/currencies/sortByMarketcap.test.ts +3 -2
  386. package/src/domain/getTokensWithFunds.test.ts +1 -1
  387. package/src/e2e/enum/AppInfos.ts +1 -1
  388. package/src/e2e/enum/DeviceLabels.ts +2 -1
  389. package/src/e2e/enum/Provider.ts +2 -2
  390. package/src/e2e/families/solana.ts +7 -4
  391. package/src/e2e/speculos.ts +4 -5
  392. package/src/e2e/speculosCI.ts +18 -6
  393. package/src/exchange/swap/api/v5/actions.ts +1 -1
  394. package/src/exchange/swap/types.ts +1 -1
  395. package/src/families/bitcoin/__snapshots__/bridge.integration.test.ts.snap +7 -0
  396. package/src/families/bitcoin/satstack.test.ts +1 -1
  397. package/src/families/canton/config.ts +36 -1
  398. package/src/families/evm/setup.ts +12 -1
  399. package/src/families/hedera/__snapshots__/bridge.integration.test.ts.snap +464 -1135
  400. package/src/families/hedera/constants.ts +2 -0
  401. package/src/families/hedera/setup.ts +7 -3
  402. package/src/families/solana/setup.ts +2 -0
  403. package/src/families/sui/__snapshots__/bridge.integration.test.ts.snap +3 -1
  404. package/src/families/sui/constants.ts +2 -0
  405. package/src/families/sui/logic.ts +2 -0
  406. package/src/families/sui/react.ts +115 -0
  407. package/src/families/sui/types.ts +2 -0
  408. package/src/families/tron/data.mock.ts +1 -1
  409. package/src/featureFlags/defaultFeatures.ts +1 -0
  410. package/src/market/utils/countervalueFormatter.ts +0 -1
  411. package/src/market/utils/types.ts +4 -0
  412. package/src/modularDrawer/__mocks__/currencies.mock.ts +1 -1
  413. package/src/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.ts +1 -1
  414. package/src/modularDrawer/data/entities/index.ts +79 -0
  415. package/src/modularDrawer/data/state-manager/api.ts +83 -0
  416. package/src/modularDrawer/hooks/__test__/useAssetsData.test.ts +200 -0
  417. package/src/modularDrawer/hooks/modules/useAssetAccountCounts.tsx +36 -0
  418. package/src/modularDrawer/hooks/modules/useLeftApyModule.tsx +26 -0
  419. package/src/modularDrawer/hooks/useAssetsData.ts +59 -0
  420. package/src/modularDrawer/types.ts +1 -0
  421. package/src/modularDrawer/utils/__tests__/counterValueFormatter.test.ts +549 -0
  422. package/src/modularDrawer/utils/__tests__/currencyUtils.test.ts +1 -1
  423. package/src/modularDrawer/utils/__tests__/haveOneCommonProvider.test.ts +2 -2
  424. package/src/modularDrawer/utils/calculateProviderTotal.ts +23 -0
  425. package/src/modularDrawer/utils/counterValueFormatter.ts +165 -0
  426. package/src/modularDrawer/utils/getBalanceAndFiatValueByAssets.ts +76 -0
  427. package/src/modularDrawer/utils/getProviderCurrency.ts +13 -0
  428. package/src/modularDrawer/utils/groupAccountsByAsset.ts +51 -0
  429. package/src/modularDrawer/utils/parseToBigNumber.ts +17 -0
  430. package/src/modularDrawer/utils/type.ts +22 -0
  431. package/src/utils/__tests__/getAccountTuplesForCurrency.test.ts +1 -1
  432. package/src/wallet-api/Exchange/error.ts +10 -0
  433. package/src/wallet-api/Exchange/server.test.ts +5 -1
  434. 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,83 @@
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
+ search?: string;
12
+ currencyIds?: string[];
13
+ }
14
+
15
+ export interface PageParam {
16
+ cursor?: string;
17
+ }
18
+
19
+ export interface AssetsDataWithPagination extends AssetsData {
20
+ pagination: {
21
+ nextCursor?: string;
22
+ };
23
+ }
24
+
25
+ function transformAssetsResponse(
26
+ response: RawApiResponse,
27
+ meta?: FetchBaseQueryMeta,
28
+ ): AssetsDataWithPagination {
29
+ const enrichedCryptoOrTokenCurrencies = convertApiAssets(response.cryptoOrTokenCurrencies);
30
+
31
+ const nextCursor = meta?.response?.headers.get("x-ledger-next") || undefined;
32
+
33
+ return {
34
+ ...response,
35
+ cryptoOrTokenCurrencies: enrichedCryptoOrTokenCurrencies,
36
+ pagination: {
37
+ nextCursor,
38
+ },
39
+ };
40
+ }
41
+
42
+ export const assetsDataApi = createApi({
43
+ reducerPath: "assetsDataApi",
44
+ baseQuery: fetchBaseQuery({
45
+ baseUrl: __DEV__ ? getEnv("DADA_API_STAGING") : getEnv("DADA_API_PROD"),
46
+ }),
47
+ tagTypes: [AssetsDataTags.Assets],
48
+ endpoints: build => ({
49
+ getAssetsData: build.infiniteQuery<AssetsDataWithPagination, GetAssetsDataParams, PageParam>({
50
+ query: ({ pageParam, queryArg }) => {
51
+ const params = {
52
+ pageSize: 100,
53
+ ...(pageParam?.cursor && { cursor: pageParam.cursor }),
54
+ // ...(queryArg?.currencyIds && queryArg?.currencyIds.length > 0 && { currencyIds: queryArg.currencyIds }),
55
+ ...(queryArg?.search && { search: queryArg.search }),
56
+ };
57
+
58
+ return {
59
+ url: "assets",
60
+ params,
61
+ };
62
+ },
63
+ providesTags: [AssetsDataTags.Assets],
64
+ transformResponse: transformAssetsResponse,
65
+ infiniteQueryOptions: {
66
+ initialPageParam: {
67
+ cursor: "",
68
+ },
69
+ getNextPageParam: lastPage => {
70
+ if (lastPage.pagination.nextCursor) {
71
+ return {
72
+ cursor: lastPage.pagination.nextCursor,
73
+ };
74
+ } else {
75
+ return undefined;
76
+ }
77
+ },
78
+ },
79
+ }),
80
+ }),
81
+ });
82
+
83
+ export const { useGetAssetsDataInfiniteQuery } = assetsDataApi;
@@ -0,0 +1,200 @@
1
+ /**
2
+ * @jest-environment jsdom
3
+ */
4
+
5
+ import { renderHook } from "@testing-library/react";
6
+ import { useAssetsData } from "../useAssetsData";
7
+ import { useGetAssetsDataInfiniteQuery } from "../../data/state-manager/api";
8
+
9
+ jest.mock("../../data/state-manager/api", () => ({
10
+ useGetAssetsDataInfiniteQuery: jest.fn(),
11
+ }));
12
+
13
+ const mockuseGetAssetsDataInfiniteQuery = jest.mocked(useGetAssetsDataInfiniteQuery);
14
+
15
+ const defaultMockValues = {
16
+ data: undefined,
17
+ isLoading: false,
18
+ error: undefined,
19
+ fetchNextPage: jest.fn(),
20
+ isSuccess: true,
21
+ isFetching: false,
22
+ isError: false,
23
+ fetchPreviousPage: jest.fn(),
24
+ isFetchingPreviousPage: false,
25
+ refetch: jest.fn(),
26
+ status: "success",
27
+ };
28
+
29
+ describe("useAssetsData", () => {
30
+ beforeEach(() => {
31
+ jest.clearAllMocks();
32
+ });
33
+
34
+ it("should return loading state when API is loading", () => {
35
+ mockuseGetAssetsDataInfiniteQuery.mockReturnValue({
36
+ ...defaultMockValues,
37
+ isLoading: true,
38
+ status: "pending",
39
+ });
40
+
41
+ const { result } = renderHook(() => useAssetsData({}));
42
+
43
+ expect(result.current.isLoading).toBe(true);
44
+ expect(result.current.data).toBe(undefined);
45
+ });
46
+
47
+ it("should return combined data from multiple pages", () => {
48
+ const mockPages = [
49
+ {
50
+ cryptoAssets: { bitcoin: { id: "bitcoin", name: "Bitcoin" } },
51
+ networks: { bitcoin: { id: "bitcoin", name: "Bitcoin" } },
52
+ cryptoOrTokenCurrencies: { bitcoin: { id: "bitcoin" } },
53
+ interestRates: {},
54
+ markets: {},
55
+ currenciesOrder: {
56
+ currenciesIds: ["bitcoin"],
57
+ metaCurrencyIds: ["bitcoin"],
58
+ key: "marketCap",
59
+ order: "desc",
60
+ },
61
+ pagination: { nextCursor: "cursor-2" },
62
+ },
63
+ {
64
+ cryptoAssets: { ethereum: { id: "ethereum", name: "Ethereum" } },
65
+ networks: { ethereum: { id: "ethereum", name: "Ethereum" } },
66
+ cryptoOrTokenCurrencies: { ethereum: { id: "ethereum" } },
67
+ interestRates: {},
68
+ markets: {},
69
+ currenciesOrder: {
70
+ currenciesIds: ["ethereum"],
71
+ metaCurrencyIds: ["ethereum"],
72
+ key: "marketCap",
73
+ order: "desc",
74
+ },
75
+ pagination: { nextCursor: undefined },
76
+ },
77
+ ];
78
+
79
+ mockuseGetAssetsDataInfiniteQuery.mockReturnValue({
80
+ ...defaultMockValues,
81
+ data: { pages: mockPages, pageParams: [{ cursor: "" }, { cursor: "cursor-2" }] },
82
+ });
83
+
84
+ const { result } = renderHook(() => useAssetsData({}));
85
+
86
+ expect(result.current.data).toEqual({
87
+ cryptoAssets: {
88
+ bitcoin: { id: "bitcoin", name: "Bitcoin" },
89
+ ethereum: { id: "ethereum", name: "Ethereum" },
90
+ },
91
+ networks: {
92
+ bitcoin: { id: "bitcoin", name: "Bitcoin" },
93
+ ethereum: { id: "ethereum", name: "Ethereum" },
94
+ },
95
+ cryptoOrTokenCurrencies: {
96
+ bitcoin: { id: "bitcoin" },
97
+ ethereum: { id: "ethereum" },
98
+ },
99
+ interestRates: {},
100
+ markets: {},
101
+ currenciesOrder: {
102
+ currenciesIds: ["bitcoin", "ethereum"],
103
+ metaCurrencyIds: ["bitcoin", "ethereum"],
104
+ key: "marketCap",
105
+ order: "desc",
106
+ },
107
+ pagination: { nextCursor: undefined },
108
+ });
109
+ expect(result.current.isLoading).toBe(false);
110
+ });
111
+
112
+ it("should return error when API has error", () => {
113
+ const mockError = new Error("API Error");
114
+ mockuseGetAssetsDataInfiniteQuery.mockReturnValue({
115
+ ...defaultMockValues,
116
+ data: undefined,
117
+ error: mockError,
118
+ isSuccess: false,
119
+ isError: true,
120
+ status: "error",
121
+ });
122
+
123
+ const { result } = renderHook(() => useAssetsData({}));
124
+
125
+ expect(result.current.error).toBe(mockError);
126
+ expect(result.current.isLoading).toBe(false);
127
+ });
128
+
129
+ it("should provide loadNext function when there's a nextCursor", () => {
130
+ const mockFetchNextPage = jest.fn();
131
+ const mockPages = [
132
+ {
133
+ cryptoAssets: {},
134
+ networks: {},
135
+ cryptoOrTokenCurrencies: {},
136
+ interestRates: {},
137
+ markets: {},
138
+ currenciesOrder: {
139
+ currenciesIds: [],
140
+ metaCurrencyIds: [],
141
+ key: "marketCap",
142
+ order: "desc",
143
+ },
144
+ pagination: { nextCursor: "next-cursor-456" },
145
+ },
146
+ ];
147
+
148
+ mockuseGetAssetsDataInfiniteQuery.mockReturnValue({
149
+ ...defaultMockValues,
150
+ data: { pages: mockPages, pageParams: [{ cursor: "" }] },
151
+ fetchNextPage: mockFetchNextPage,
152
+ });
153
+
154
+ const { result } = renderHook(() => useAssetsData({}));
155
+
156
+ expect(result.current.loadNext).toBeDefined();
157
+ result.current.loadNext?.();
158
+
159
+ expect(mockFetchNextPage).toHaveBeenCalled();
160
+ });
161
+
162
+ it("should not provide loadNext function when there's no nextCursor", () => {
163
+ const mockPages = [
164
+ {
165
+ cryptoAssets: {},
166
+ networks: {},
167
+ cryptoOrTokenCurrencies: {},
168
+ interestRates: {},
169
+ markets: {},
170
+ currenciesOrder: {
171
+ currenciesIds: [],
172
+ metaCurrencyIds: [],
173
+ key: "marketCap",
174
+ order: "desc",
175
+ },
176
+ pagination: { nextCursor: undefined },
177
+ },
178
+ ];
179
+
180
+ mockuseGetAssetsDataInfiniteQuery.mockReturnValue({
181
+ ...defaultMockValues,
182
+ data: { pages: mockPages, pageParams: [{ cursor: "" }] },
183
+ });
184
+
185
+ const { result } = renderHook(() => useAssetsData({}));
186
+
187
+ expect(result.current.loadNext).toBeUndefined();
188
+ });
189
+
190
+ it("should return undefined data when no pages exist", () => {
191
+ mockuseGetAssetsDataInfiniteQuery.mockReturnValue({
192
+ ...defaultMockValues,
193
+ });
194
+
195
+ const { result } = renderHook(() => useAssetsData({}));
196
+
197
+ expect(result.current.data).toBeUndefined();
198
+ expect(result.current.loadNext).toBeUndefined();
199
+ });
200
+ });
@@ -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
+ };