@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,165 @@
1
+ import { rangeDataTable } from "../../market/utils/rangeDataTable";
2
+ import { TFunction } from "i18next";
3
+
4
+ export const RANGES = Object.keys(rangeDataTable).filter(key => key !== "1h");
5
+
6
+ const indexes: [string, number][] = [
7
+ ["d", 1],
8
+ ["K", 1000],
9
+ ["M", 1000000],
10
+ ["B", 1000000000],
11
+ ["T", 1000000000000],
12
+ ["Q", 1000000000000000],
13
+ ["Qn", 1000000000000000000],
14
+ ];
15
+
16
+ const formatters: Record<string, { [key: string]: Intl.NumberFormat }> = {};
17
+
18
+ const getSanitizedValue = (currency: string | undefined, locale: string): string => {
19
+ if (currency) {
20
+ return `${formatters[locale][currency]
21
+ ?.format(0)
22
+ .replace(/[0-9,.]+/, "***")
23
+ .trim()}`;
24
+ }
25
+ return "***";
26
+ };
27
+
28
+ const shouldReturnDash = (
29
+ value: number,
30
+ allowZeroValue: boolean,
31
+ discreetMode: boolean,
32
+ ): boolean => {
33
+ return !discreetMode && (isNaN(value) || (!value && !allowZeroValue));
34
+ };
35
+
36
+ const ensureFormatterExists = (
37
+ locale: string,
38
+ currency: string | undefined,
39
+ decimalPlaces: number,
40
+ ): void => {
41
+ if (!formatters[locale]) formatters[locale] = {};
42
+
43
+ if (currency && !formatters[locale]?.[currency]) {
44
+ createCurrencyFormatter(locale, currency, decimalPlaces);
45
+ } else if (!currency && !formatters[locale]?.[`decimal_${decimalPlaces}`]) {
46
+ createDecimalFormatter(locale, decimalPlaces);
47
+ }
48
+ };
49
+
50
+ const createCurrencyFormatter = (locale: string, currency: string, decimalPlaces: number): void => {
51
+ try {
52
+ formatters[locale][currency] = new Intl.NumberFormat(locale, {
53
+ style: "currency",
54
+ currency,
55
+ });
56
+ } catch {
57
+ formatters[locale][currency] = new Intl.NumberFormat(locale, {
58
+ style: "decimal",
59
+ minimumFractionDigits: decimalPlaces,
60
+ maximumFractionDigits: 8,
61
+ });
62
+ }
63
+ };
64
+
65
+ const createDecimalFormatter = (locale: string, decimalPlaces: number): void => {
66
+ formatters[locale][`decimal_${decimalPlaces}`] = new Intl.NumberFormat(locale, {
67
+ style: "decimal",
68
+ minimumFractionDigits: decimalPlaces,
69
+ maximumFractionDigits: decimalPlaces,
70
+ });
71
+ };
72
+
73
+ const getFormatter = (
74
+ currency: string | undefined,
75
+ locale: string,
76
+ shorten: boolean | undefined,
77
+ decimalPlaces: number,
78
+ ): Intl.NumberFormat | undefined => {
79
+ if (currency) {
80
+ return formatters[locale][currency];
81
+ }
82
+
83
+ if (shorten) {
84
+ return new Intl.NumberFormat(locale, {
85
+ notation: "compact",
86
+ maximumFractionDigits: 3,
87
+ minimumFractionDigits: Math.min(decimalPlaces, 3),
88
+ });
89
+ }
90
+
91
+ return formatters[locale][`decimal_${decimalPlaces}`];
92
+ };
93
+
94
+ const formatShortenedValue = (
95
+ value: number,
96
+ formatter: Intl.NumberFormat,
97
+ t: TFunction,
98
+ ): string => {
99
+ const sign = value > 0 ? "" : "-";
100
+ const v = Math.abs(value);
101
+ const index = Math.floor(Math.log10(v) / 3) || 0;
102
+ const [i, n] = indexes[index] || ["", 1];
103
+ const roundedValue = Math.round((v / n) * 1000) / 1000;
104
+ const number = formatter.format(roundedValue);
105
+ const I = t(`numberCompactNotation.${i}`);
106
+ const formattedNumber = number.replace(/([0-9,. ]+)/, `${sign}$1 ${I}`);
107
+ return formattedNumber.trim();
108
+ };
109
+
110
+ const formatRegularValue = (
111
+ value: number,
112
+ formatter: Intl.NumberFormat,
113
+ ticker: string,
114
+ currency: string | undefined,
115
+ locale: string,
116
+ discreetMode: boolean,
117
+ ): string => {
118
+ if (discreetMode) {
119
+ return getSanitizedValue(currency, locale);
120
+ }
121
+
122
+ const formattedValue = formatter.format(value);
123
+ const upperCaseTicker = ticker?.trim()?.toLocaleUpperCase();
124
+ return `${formattedValue} ${upperCaseTicker}`.trim();
125
+ };
126
+
127
+ export const counterValueFormatter = ({
128
+ currency,
129
+ value,
130
+ shorten,
131
+ locale,
132
+ t,
133
+ allowZeroValue = false,
134
+ ticker = "",
135
+ discreetMode = false,
136
+ decimalPlaces = 2,
137
+ }: {
138
+ currency?: string;
139
+ value: number;
140
+ shorten?: boolean;
141
+ locale: string;
142
+ t?: TFunction;
143
+ allowZeroValue?: boolean;
144
+ ticker?: string;
145
+ discreetMode?: boolean;
146
+ decimalPlaces?: number;
147
+ }): string => {
148
+ if (shouldReturnDash(value, allowZeroValue, discreetMode)) {
149
+ return "-";
150
+ }
151
+
152
+ ensureFormatterExists(locale, currency, decimalPlaces);
153
+
154
+ const formatter = getFormatter(currency, locale, shorten, decimalPlaces);
155
+
156
+ if (!formatter) {
157
+ return String(value);
158
+ }
159
+
160
+ if (shorten && t) {
161
+ return formatShortenedValue(value, formatter, t);
162
+ }
163
+
164
+ return formatRegularValue(value, formatter, ticker, currency, locale, discreetMode);
165
+ };
@@ -0,0 +1,76 @@
1
+ import { formatCurrencyUnit } from "@ledgerhq/coin-framework/lib-es/currencies/formatCurrencyUnit";
2
+ import type { CounterValuesState } from "@ledgerhq/live-countervalues/types";
3
+ import type { CryptoOrTokenCurrency, Currency } from "@ledgerhq/types-cryptoassets";
4
+ import { groupAccountsByAsset, type GroupedAccount } from "./groupAccountsByAsset";
5
+ import { AssetType } from "./type";
6
+ import { AccountLike } from "@ledgerhq/types-live";
7
+ import { counterValueFormatter } from "./counterValueFormatter";
8
+
9
+ interface ExtendedAssetType extends AssetType {
10
+ balance?: string;
11
+ fiatValue?: string;
12
+ }
13
+
14
+ export const getBalanceAndFiatValueByAssets = (
15
+ accounts: AccountLike[],
16
+ assets: CryptoOrTokenCurrency[],
17
+ counterValuesState: CounterValuesState,
18
+ targetCurrency: Currency,
19
+ isDiscreetMode: boolean = false,
20
+ userLocale: string,
21
+ ): ExtendedAssetType[] => {
22
+ const groupedAccountsByAsset = groupAccountsByAsset(
23
+ accounts,
24
+ counterValuesState,
25
+ targetCurrency,
26
+ isDiscreetMode,
27
+ );
28
+
29
+ return assets.map(asset => {
30
+ const assetGroup = groupedAccountsByAsset[asset.id];
31
+
32
+ if (assetGroup) {
33
+ return formatAssetDetails(assetGroup, asset, targetCurrency, isDiscreetMode, userLocale);
34
+ }
35
+
36
+ return {
37
+ id: asset.id,
38
+ name: asset.name,
39
+ ticker: asset.ticker,
40
+ };
41
+ });
42
+ };
43
+
44
+ const formatAssetDetails = (
45
+ assetGroup: GroupedAccount,
46
+ asset: CryptoOrTokenCurrency,
47
+ targetCurrency: Currency,
48
+ isDiscreetMode: boolean,
49
+ userLocale: string,
50
+ ): ExtendedAssetType => {
51
+ const assetDetails =
52
+ assetGroup.accounts[0].type === "Account"
53
+ ? assetGroup.accounts[0].currency
54
+ : assetGroup.accounts[0].token;
55
+
56
+ const formattedBalance = formatCurrencyUnit(assetDetails.units[0], assetGroup.totalBalance, {
57
+ showCode: true,
58
+ discreet: isDiscreetMode,
59
+ });
60
+
61
+ const formattedFiatValue = counterValueFormatter({
62
+ currency: targetCurrency.ticker,
63
+ value: assetGroup.totalFiatValue.toNumber(),
64
+ locale: userLocale,
65
+ allowZeroValue: true,
66
+ discreetMode: isDiscreetMode,
67
+ });
68
+
69
+ return {
70
+ id: asset.id,
71
+ name: asset.name,
72
+ ticker: asset.ticker,
73
+ balance: formattedBalance,
74
+ fiatValue: formattedFiatValue,
75
+ };
76
+ };
@@ -0,0 +1,13 @@
1
+ import { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
2
+ import { getTokenOrCryptoCurrencyById } from "../../deposit/helper";
3
+
4
+ export const getProviderCurrency = (
5
+ mainCurrency: CryptoOrTokenCurrency,
6
+ currencies: CryptoOrTokenCurrency[],
7
+ ) => {
8
+ try {
9
+ return getTokenOrCryptoCurrencyById(mainCurrency.id);
10
+ } catch {
11
+ return getTokenOrCryptoCurrencyById(currencies[0].id);
12
+ }
13
+ };
@@ -0,0 +1,51 @@
1
+ import { getBalanceAndFiatValue } from "./getBalanceAndFiatValue";
2
+ import type { CounterValuesState } from "@ledgerhq/live-countervalues/types";
3
+ import { Currency } from "@ledgerhq/types-cryptoassets";
4
+ import { AccountLike } from "@ledgerhq/types-live";
5
+ import BigNumber from "bignumber.js";
6
+ import { parseToBigNumber } from "./parseToBigNumber";
7
+
8
+ export type GroupedAccount = {
9
+ totalBalance: BigNumber;
10
+ totalFiatValue: BigNumber;
11
+ accounts: AccountLike[];
12
+ };
13
+
14
+ export const groupAccountsByAsset = (
15
+ accounts: AccountLike[],
16
+ counterValuesState: CounterValuesState,
17
+ targetCurrency: Currency,
18
+ isDiscreetMode: boolean,
19
+ ): Record<string, GroupedAccount> => {
20
+ const initialGroupedAccounts: Record<string, GroupedAccount> = {};
21
+
22
+ return accounts.reduce((groupedAccounts, account) => {
23
+ const assetId = account.type === "Account" ? account.currency.id : account.token.id;
24
+
25
+ if (!groupedAccounts[assetId]) {
26
+ groupedAccounts[assetId] = {
27
+ totalBalance: new BigNumber(0),
28
+ totalFiatValue: new BigNumber(0),
29
+ accounts: [],
30
+ };
31
+ }
32
+
33
+ const { fiatValue } = getBalanceAndFiatValue(
34
+ account,
35
+ counterValuesState,
36
+ targetCurrency,
37
+ isDiscreetMode,
38
+ false,
39
+ );
40
+ const balance = account.balance;
41
+
42
+ const parsedFiatValue = parseToBigNumber(fiatValue ?? "0");
43
+
44
+ groupedAccounts[assetId].totalBalance = groupedAccounts[assetId].totalBalance.plus(balance);
45
+ groupedAccounts[assetId].totalFiatValue =
46
+ groupedAccounts[assetId].totalFiatValue.plus(parsedFiatValue);
47
+ groupedAccounts[assetId].accounts.push(account);
48
+
49
+ return groupedAccounts;
50
+ }, initialGroupedAccounts);
51
+ };
@@ -0,0 +1,17 @@
1
+ import BigNumber from "bignumber.js";
2
+
3
+ /**
4
+ *
5
+ * @param value - The value to parse into a BigNumber. It can be a string, number, or an existing BigNumber instance.
6
+ * @template T - The type of the value, which can be string, number, or BigNumber.
7
+ * @returns A BigNumber instance representing the parsed value.
8
+ */
9
+ export const parseToBigNumber = <T extends string | number | BigNumber>(value: T): BigNumber => {
10
+ if (value instanceof BigNumber) {
11
+ return value;
12
+ }
13
+ if (typeof value === "string") {
14
+ return new BigNumber(value.replace(/,/g, ""));
15
+ }
16
+ return new BigNumber(value);
17
+ };
@@ -0,0 +1,22 @@
1
+ export type AssetType = {
2
+ name: string;
3
+ ticker: string;
4
+ id: string;
5
+ leftElement?: React.ReactNode;
6
+ rightElement?: React.ReactNode;
7
+ };
8
+
9
+ export type ProviderBalanceAsset = {
10
+ id: string;
11
+ name: string;
12
+ ticker: string;
13
+ balance: string;
14
+ fiatValue: string;
15
+ sortValue: number;
16
+ };
17
+
18
+ export type ProviderBalanceResultsMap = Map<string, ProviderBalanceAsset>;
19
+
20
+ export type AssetWithBalance = AssetType & {
21
+ sortValue?: number;
22
+ };
@@ -1,5 +1,5 @@
1
1
  import { getCryptoCurrencyById, getTokenById } from "@ledgerhq/cryptoassets";
2
- import { genAccount } from "@ledgerhq/live-common/mock/account";
2
+ import { genAccount } from "../../mock/account";
3
3
  import type { CryptoCurrency, TokenCurrency } from "@ledgerhq/types-cryptoassets";
4
4
  import type { Account, TokenAccount } from "@ledgerhq/types-live";
5
5
  import { getAccountTuplesForCurrency } from "../getAccountTuplesForCurrency";
@@ -24,6 +24,16 @@ export function createWrongSellParams(params: unknown): ExchangeErrorData {
24
24
  };
25
25
  }
26
26
 
27
+ export function createWrongFundParams(params: unknown): ExchangeErrorData {
28
+ return {
29
+ code: "WRONG_FUND_PARAMS",
30
+ message: "fund params are not correctly set",
31
+ data: {
32
+ params,
33
+ },
34
+ };
35
+ }
36
+
27
37
  export function createAccounIdNotFound(accountId: string): ExchangeErrorData {
28
38
  return {
29
39
  code: "ACCOUNT_ID_NOT_FOUND",
@@ -3,6 +3,7 @@ import {
3
3
  ExchangeStartParams,
4
4
  ExchangeStartSellParams,
5
5
  ExchangeStartSwapParams,
6
+ ExchangeStartFundParams,
6
7
  } from "@ledgerhq/wallet-api-exchange-module";
7
8
  import { WalletContext, WalletHandlers } from "@ledgerhq/wallet-api-server";
8
9
  import { of } from "rxjs";
@@ -153,8 +154,10 @@ describe("handlers", () => {
153
154
  uiHooks: mockUiHooks,
154
155
  });
155
156
 
156
- const params: ExchangeStartParams = {
157
+ const params: ExchangeStartFundParams = {
157
158
  exchangeType: "FUND",
159
+ provider: "TestFundProvider",
160
+ fromAccountId: accounts[0].id,
158
161
  };
159
162
  const { request, context, walletHandlers } = prepareSellRequest(params);
160
163
 
@@ -170,6 +173,7 @@ describe("handlers", () => {
170
173
  expect(mockUiStartExchange).toHaveBeenCalledTimes(1);
171
174
  const receivedParams = mockUiStartExchange.mock.calls[0][0].exchangeParams;
172
175
  expect(receivedParams.exchangeType).toBe("FUND");
176
+ expect(receivedParams.provider).toBe("TestFundProvider");
173
177
  expect(mockUiCompleteExchange).not.toHaveBeenCalled();
174
178
  });
175
179
  });
@@ -22,6 +22,7 @@ import {
22
22
  ExchangeStartResult,
23
23
  ExchangeStartSellParams,
24
24
  ExchangeStartSwapParams,
25
+ ExchangeStartFundParams,
25
26
  ExchangeSwapParams,
26
27
  ExchangeType,
27
28
  SwapLiveError,
@@ -44,6 +45,7 @@ import {
44
45
  createAccounIdNotFound,
45
46
  createWrongSellParams,
46
47
  createWrongSwapParams,
48
+ createWrongFundParams,
47
49
  ExchangeError,
48
50
  } from "./error";
49
51
  import { TrackingAPI } from "./tracking";
@@ -82,6 +84,8 @@ export type CompleteExchangeUiRequest = {
82
84
  };
83
85
  type FundStartParamsUiRequest = {
84
86
  exchangeType: "FUND";
87
+ provider: string;
88
+ exchange: Partial<Exchange> | undefined;
85
89
  };
86
90
 
87
91
  type SellStartParamsUiRequest = {
@@ -158,8 +162,6 @@ export const handlers = ({
158
162
  }
159
163
 
160
164
  const trackingParams = {
161
- // @ts-expect-error ExchangeStartFundParams does not yet have the provider. Will be added in another iteration after a bugfix is confirmed
162
- // TODO: expect-error to be deleted after
163
165
  provider: params.provider,
164
166
  exchangeType: params.exchangeType,
165
167
  };
@@ -174,9 +176,7 @@ export const handlers = ({
174
176
  } else if (params.exchangeType == "SELL") {
175
177
  exchangeParams = extractSellStartParam(params, accounts);
176
178
  } else {
177
- exchangeParams = {
178
- exchangeType: params.exchangeType,
179
- };
179
+ exchangeParams = extractFundStartParam(params, accounts);
180
180
  }
181
181
 
182
182
  return new Promise((resolve, reject) =>
@@ -711,6 +711,45 @@ function extractSellStartParam(
711
711
  };
712
712
  }
713
713
 
714
+ function extractFundStartParam(
715
+ params: ExchangeStartFundParams,
716
+ accounts: AccountLike[],
717
+ ): ExchangeStartParamsUiRequest {
718
+ if (!("provider" in params)) {
719
+ throw new ExchangeError(createWrongFundParams(params));
720
+ }
721
+
722
+ if (!params.fromAccountId) {
723
+ return {
724
+ exchangeType: params.exchangeType,
725
+ provider: params.provider,
726
+ } as ExchangeStartParamsUiRequest;
727
+ }
728
+
729
+ const realFromAccountId = getAccountIdFromWalletAccountId(params?.fromAccountId);
730
+
731
+ if (!realFromAccountId) {
732
+ throw new ExchangeError(createAccounIdNotFound(params.fromAccountId));
733
+ }
734
+
735
+ const fromAccount = accounts?.find(acc => acc.id === realFromAccountId);
736
+
737
+ if (!fromAccount) {
738
+ throw new ServerError(createAccountNotFound(params.fromAccountId));
739
+ }
740
+
741
+ const fromParentAccount = getParentAccount(fromAccount, accounts);
742
+
743
+ return {
744
+ exchangeType: params.exchangeType,
745
+ provider: params.provider,
746
+ exchange: {
747
+ fromAccount,
748
+ fromParentAccount,
749
+ },
750
+ };
751
+ }
752
+
714
753
  async function getToCurrency(
715
754
  binaryPayload: string,
716
755
  toAccount: AccountLike,