@ledgerhq/live-common 34.3.0-nightly.9 → 35.0.0-next.6

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 (457) hide show
  1. package/lib/__tests__/test-helpers/environment.js +4 -0
  2. package/lib/__tests__/test-helpers/environment.js.map +1 -1
  3. package/lib/apps/listApps/v2.d.ts +2 -2
  4. package/lib/apps/listApps/v2.d.ts.map +1 -1
  5. package/lib/apps/listApps/v2.test.js +122 -0
  6. package/lib/apps/listApps/v2.test.js.map +1 -1
  7. package/lib/apps/mock.d.ts +2 -1
  8. package/lib/apps/mock.d.ts.map +1 -1
  9. package/lib/apps/mock.js +6 -1
  10. package/lib/apps/mock.js.map +1 -1
  11. package/lib/apps/react.test.js +1 -0
  12. package/lib/apps/react.test.js.map +1 -1
  13. package/lib/device/use-cases/listAppsUseCase.d.ts.map +1 -1
  14. package/lib/device/use-cases/listAppsUseCase.js +1 -0
  15. package/lib/device/use-cases/listAppsUseCase.js.map +1 -1
  16. package/lib/deviceSDK/actions/getLatestAvailableFirmware.test.js +3 -3
  17. package/lib/deviceSDK/actions/getLatestAvailableFirmware.test.js.map +1 -1
  18. package/lib/deviceSDK/tasks/core.js +1 -1
  19. package/lib/deviceSDK/tasks/core.js.map +1 -1
  20. package/lib/env.react.d.ts +1 -1
  21. package/lib/env.react.d.ts.map +1 -1
  22. package/lib/exchange/providers/swap.d.ts.map +1 -1
  23. package/lib/exchange/providers/swap.js +6 -1
  24. package/lib/exchange/providers/swap.js.map +1 -1
  25. package/lib/exchange/swap/api/v5/__tests__/fetchCurrencyAll.spec.js +2 -1
  26. package/lib/exchange/swap/api/v5/__tests__/fetchCurrencyAll.spec.js.map +1 -1
  27. package/lib/exchange/swap/api/v5/__tests__/fetchCurrencyFrom.spec.js +2 -0
  28. package/lib/exchange/swap/api/v5/__tests__/fetchCurrencyFrom.spec.js.map +1 -1
  29. package/lib/exchange/swap/api/v5/__tests__/fetchCurrencyTo.spec.js +3 -0
  30. package/lib/exchange/swap/api/v5/__tests__/fetchCurrencyTo.spec.js.map +1 -1
  31. package/lib/exchange/swap/api/v5/fetchCurrencyAll.d.ts +2 -1
  32. package/lib/exchange/swap/api/v5/fetchCurrencyAll.d.ts.map +1 -1
  33. package/lib/exchange/swap/api/v5/fetchCurrencyAll.js +1 -2
  34. package/lib/exchange/swap/api/v5/fetchCurrencyAll.js.map +1 -1
  35. package/lib/exchange/swap/api/v5/fetchCurrencyFrom.d.ts +2 -1
  36. package/lib/exchange/swap/api/v5/fetchCurrencyFrom.d.ts.map +1 -1
  37. package/lib/exchange/swap/api/v5/fetchCurrencyFrom.js +1 -2
  38. package/lib/exchange/swap/api/v5/fetchCurrencyFrom.js.map +1 -1
  39. package/lib/exchange/swap/api/v5/fetchCurrencyTo.d.ts +2 -1
  40. package/lib/exchange/swap/api/v5/fetchCurrencyTo.d.ts.map +1 -1
  41. package/lib/exchange/swap/api/v5/fetchCurrencyTo.js +1 -2
  42. package/lib/exchange/swap/api/v5/fetchCurrencyTo.js.map +1 -1
  43. package/lib/exchange/swap/api/v5/fetchRates.d.ts +2 -2
  44. package/lib/exchange/swap/api/v5/fetchRates.d.ts.map +1 -1
  45. package/lib/exchange/swap/api/v5/fetchRates.js +1 -5
  46. package/lib/exchange/swap/api/v5/fetchRates.js.map +1 -1
  47. package/lib/exchange/swap/completeExchange.d.ts.map +1 -1
  48. package/lib/exchange/swap/completeExchange.js +2 -1
  49. package/lib/exchange/swap/completeExchange.js.map +1 -1
  50. package/lib/exchange/swap/hooks/useSwapTransaction.d.ts +4 -3
  51. package/lib/exchange/swap/hooks/useSwapTransaction.d.ts.map +1 -1
  52. package/lib/exchange/swap/hooks/useSwapTransaction.js +5 -4
  53. package/lib/exchange/swap/hooks/useSwapTransaction.js.map +1 -1
  54. package/lib/exchange/swap/hooks/v5/useFetchCurrencyAll.d.ts.map +1 -1
  55. package/lib/exchange/swap/hooks/v5/useFetchCurrencyAll.js +4 -0
  56. package/lib/exchange/swap/hooks/v5/useFetchCurrencyAll.js.map +1 -1
  57. package/lib/exchange/swap/hooks/v5/useFetchCurrencyFrom.d.ts.map +1 -1
  58. package/lib/exchange/swap/hooks/v5/useFetchCurrencyFrom.js +4 -1
  59. package/lib/exchange/swap/hooks/v5/useFetchCurrencyFrom.js.map +1 -1
  60. package/lib/exchange/swap/hooks/v5/useFetchCurrencyTo.d.ts.map +1 -1
  61. package/lib/exchange/swap/hooks/v5/useFetchCurrencyTo.js +4 -2
  62. package/lib/exchange/swap/hooks/v5/useFetchCurrencyTo.js.map +1 -1
  63. package/lib/exchange/swap/hooks/v5/useFetchRates.d.ts +3 -2
  64. package/lib/exchange/swap/hooks/v5/useFetchRates.d.ts.map +1 -1
  65. package/lib/exchange/swap/hooks/v5/useFetchRates.js +12 -9
  66. package/lib/exchange/swap/hooks/v5/useFetchRates.js.map +1 -1
  67. package/lib/exchange/swap/hooks/v5/useFilteredProviders.d.ts +6 -0
  68. package/lib/exchange/swap/hooks/v5/useFilteredProviders.d.ts.map +1 -0
  69. package/lib/exchange/swap/hooks/v5/useFilteredProviders.js +51 -0
  70. package/lib/exchange/swap/hooks/v5/useFilteredProviders.js.map +1 -0
  71. package/lib/exchange/swap/hooks/v5/useProviderRates.d.ts +2 -1
  72. package/lib/exchange/swap/hooks/v5/useProviderRates.d.ts.map +1 -1
  73. package/lib/exchange/swap/hooks/v5/useProviderRates.js +5 -12
  74. package/lib/exchange/swap/hooks/v5/useProviderRates.js.map +1 -1
  75. package/lib/exchange/swap/initSwap.d.ts.map +1 -1
  76. package/lib/exchange/swap/initSwap.js +2 -1
  77. package/lib/exchange/swap/initSwap.js.map +1 -1
  78. package/lib/families/cosmos/bridge/mock.js +1 -1
  79. package/lib/families/evm/config.d.ts.map +1 -1
  80. package/lib/families/evm/config.js +32 -0
  81. package/lib/families/evm/config.js.map +1 -1
  82. package/lib/families/stacks/__tests__/sync.integration.test.js +1 -1
  83. package/lib/families/stacks/__tests__/sync.integration.test.js.map +1 -1
  84. package/lib/families/stacks/bridge/utils/api.d.ts.map +1 -1
  85. package/lib/families/stacks/bridge/utils/api.js +9 -3
  86. package/lib/families/stacks/bridge/utils/api.js.map +1 -1
  87. package/lib/families/stacks/bridge/utils/api.types.d.ts +80 -10
  88. package/lib/families/stacks/bridge/utils/api.types.d.ts.map +1 -1
  89. package/lib/families/stacks/bridge/utils/misc.d.ts +1 -1
  90. package/lib/families/stacks/bridge/utils/misc.d.ts.map +1 -1
  91. package/lib/families/stacks/bridge/utils/misc.js +29 -21
  92. package/lib/families/stacks/bridge/utils/misc.js.map +1 -1
  93. package/lib/families/stacks/bridge/utils/misc.unit.test.js +83 -69
  94. package/lib/families/stacks/bridge/utils/misc.unit.test.js.map +1 -1
  95. package/lib/families/stacks/synchronization.js +1 -1
  96. package/lib/families/stacks/synchronization.js.map +1 -1
  97. package/lib/families/tron/api/index.js +2 -2
  98. package/lib/families/tron/api/index.js.map +1 -1
  99. package/lib/families/tron/signOperation.d.ts.map +1 -1
  100. package/lib/families/tron/signOperation.js +0 -11
  101. package/lib/families/tron/signOperation.js.map +1 -1
  102. package/lib/families/tron/synchronization.d.ts.map +1 -1
  103. package/lib/families/tron/synchronization.js +35 -3
  104. package/lib/families/tron/synchronization.js.map +1 -1
  105. package/lib/featureFlags/defaultFeatures.d.ts +5 -1
  106. package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
  107. package/lib/featureFlags/defaultFeatures.js +11 -5
  108. package/lib/featureFlags/defaultFeatures.js.map +1 -1
  109. package/lib/featureFlags/firebaseFeatureFlags.d.ts +9 -3
  110. package/lib/featureFlags/firebaseFeatureFlags.d.ts.map +1 -1
  111. package/lib/featureFlags/groupedFeatures.d.ts +2 -1
  112. package/lib/featureFlags/groupedFeatures.d.ts.map +1 -1
  113. package/lib/featureFlags/groupedFeatures.js +0 -3
  114. package/lib/featureFlags/groupedFeatures.js.map +1 -1
  115. package/lib/featureFlags/useFeature.d.ts +1 -1
  116. package/lib/featureFlags/useFeature.d.ts.map +1 -1
  117. package/lib/generated/deviceTransactionConfig.d.ts +1 -1
  118. package/lib/generated/transaction.d.ts +2 -2
  119. package/lib/helpers.d.ts +1 -0
  120. package/lib/helpers.d.ts.map +1 -1
  121. package/lib/helpers.js +5 -1
  122. package/lib/helpers.js.map +1 -1
  123. package/lib/hw/getOnboardingStatePolling.js +1 -1
  124. package/lib/hw/getOnboardingStatePolling.js.map +1 -1
  125. package/lib/market/api/index.d.ts +8 -0
  126. package/lib/market/api/index.d.ts.map +1 -0
  127. package/lib/market/api/index.js +112 -0
  128. package/lib/market/api/index.js.map +1 -0
  129. package/lib/market/hooks/useMarketDataProvider.d.ts +13 -0
  130. package/lib/market/hooks/useMarketDataProvider.d.ts.map +1 -0
  131. package/lib/market/{v2 → hooks}/useMarketDataProvider.js +36 -39
  132. package/lib/market/hooks/useMarketDataProvider.js.map +1 -0
  133. package/lib/market/{v2 → hooks}/useMarketPerformers.d.ts +1 -1
  134. package/lib/market/hooks/useMarketPerformers.d.ts.map +1 -0
  135. package/lib/market/{v2 → hooks}/useMarketPerformers.js +3 -3
  136. package/lib/market/hooks/useMarketPerformers.js.map +1 -0
  137. package/lib/market/utils/currencyFormatter.d.ts +3 -26
  138. package/lib/market/utils/currencyFormatter.d.ts.map +1 -1
  139. package/lib/market/utils/currencyFormatter.js +35 -31
  140. package/lib/market/utils/currencyFormatter.js.map +1 -1
  141. package/lib/market/utils/index.d.ts +5 -0
  142. package/lib/market/utils/index.d.ts.map +1 -0
  143. package/lib/market/utils/index.js +37 -0
  144. package/lib/market/utils/index.js.map +1 -0
  145. package/lib/market/utils/queryKeys.d.ts.map +1 -0
  146. package/lib/market/utils/queryKeys.js.map +1 -0
  147. package/lib/market/utils/timers.d.ts.map +1 -0
  148. package/lib/market/utils/timers.js.map +1 -0
  149. package/lib/market/{types.d.ts → utils/types.d.ts} +35 -53
  150. package/lib/market/utils/types.d.ts.map +1 -0
  151. package/lib/market/utils/types.js +19 -0
  152. package/lib/market/utils/types.js.map +1 -0
  153. package/lib/platform/converters.d.ts.map +1 -1
  154. package/lib/platform/converters.js +4 -5
  155. package/lib/platform/converters.js.map +1 -1
  156. package/lib/platform/types.d.ts +6 -1
  157. package/lib/platform/types.d.ts.map +1 -1
  158. package/lib/platform/types.js +11 -2
  159. package/lib/platform/types.js.map +1 -1
  160. package/lib/wallet-api/constants.d.ts +6 -1
  161. package/lib/wallet-api/constants.d.ts.map +1 -1
  162. package/lib/wallet-api/constants.js +8 -2
  163. package/lib/wallet-api/constants.js.map +1 -1
  164. package/lib/wallet-api/converters.d.ts +1 -1
  165. package/lib/wallet-api/converters.d.ts.map +1 -1
  166. package/lib/wallet-api/converters.js +6 -5
  167. package/lib/wallet-api/converters.js.map +1 -1
  168. package/lib-es/__tests__/test-helpers/environment.js +4 -0
  169. package/lib-es/__tests__/test-helpers/environment.js.map +1 -1
  170. package/lib-es/apps/listApps/v2.d.ts +2 -2
  171. package/lib-es/apps/listApps/v2.d.ts.map +1 -1
  172. package/lib-es/apps/listApps/v2.test.js +122 -0
  173. package/lib-es/apps/listApps/v2.test.js.map +1 -1
  174. package/lib-es/apps/mock.d.ts +2 -1
  175. package/lib-es/apps/mock.d.ts.map +1 -1
  176. package/lib-es/apps/mock.js +4 -0
  177. package/lib-es/apps/mock.js.map +1 -1
  178. package/lib-es/apps/react.test.js +1 -0
  179. package/lib-es/apps/react.test.js.map +1 -1
  180. package/lib-es/device/use-cases/listAppsUseCase.d.ts.map +1 -1
  181. package/lib-es/device/use-cases/listAppsUseCase.js +1 -0
  182. package/lib-es/device/use-cases/listAppsUseCase.js.map +1 -1
  183. package/lib-es/deviceSDK/actions/getLatestAvailableFirmware.test.js +4 -4
  184. package/lib-es/deviceSDK/actions/getLatestAvailableFirmware.test.js.map +1 -1
  185. package/lib-es/deviceSDK/tasks/core.js +2 -2
  186. package/lib-es/deviceSDK/tasks/core.js.map +1 -1
  187. package/lib-es/env.react.d.ts +1 -1
  188. package/lib-es/env.react.d.ts.map +1 -1
  189. package/lib-es/exchange/providers/swap.d.ts.map +1 -1
  190. package/lib-es/exchange/providers/swap.js +6 -1
  191. package/lib-es/exchange/providers/swap.js.map +1 -1
  192. package/lib-es/exchange/swap/api/v5/__tests__/fetchCurrencyAll.spec.js +2 -1
  193. package/lib-es/exchange/swap/api/v5/__tests__/fetchCurrencyAll.spec.js.map +1 -1
  194. package/lib-es/exchange/swap/api/v5/__tests__/fetchCurrencyFrom.spec.js +2 -0
  195. package/lib-es/exchange/swap/api/v5/__tests__/fetchCurrencyFrom.spec.js.map +1 -1
  196. package/lib-es/exchange/swap/api/v5/__tests__/fetchCurrencyTo.spec.js +3 -0
  197. package/lib-es/exchange/swap/api/v5/__tests__/fetchCurrencyTo.spec.js.map +1 -1
  198. package/lib-es/exchange/swap/api/v5/fetchCurrencyAll.d.ts +2 -1
  199. package/lib-es/exchange/swap/api/v5/fetchCurrencyAll.d.ts.map +1 -1
  200. package/lib-es/exchange/swap/api/v5/fetchCurrencyAll.js +2 -3
  201. package/lib-es/exchange/swap/api/v5/fetchCurrencyAll.js.map +1 -1
  202. package/lib-es/exchange/swap/api/v5/fetchCurrencyFrom.d.ts +2 -1
  203. package/lib-es/exchange/swap/api/v5/fetchCurrencyFrom.d.ts.map +1 -1
  204. package/lib-es/exchange/swap/api/v5/fetchCurrencyFrom.js +2 -3
  205. package/lib-es/exchange/swap/api/v5/fetchCurrencyFrom.js.map +1 -1
  206. package/lib-es/exchange/swap/api/v5/fetchCurrencyTo.d.ts +2 -1
  207. package/lib-es/exchange/swap/api/v5/fetchCurrencyTo.d.ts.map +1 -1
  208. package/lib-es/exchange/swap/api/v5/fetchCurrencyTo.js +2 -3
  209. package/lib-es/exchange/swap/api/v5/fetchCurrencyTo.js.map +1 -1
  210. package/lib-es/exchange/swap/api/v5/fetchRates.d.ts +2 -2
  211. package/lib-es/exchange/swap/api/v5/fetchRates.d.ts.map +1 -1
  212. package/lib-es/exchange/swap/api/v5/fetchRates.js +2 -6
  213. package/lib-es/exchange/swap/api/v5/fetchRates.js.map +1 -1
  214. package/lib-es/exchange/swap/completeExchange.d.ts.map +1 -1
  215. package/lib-es/exchange/swap/completeExchange.js +2 -1
  216. package/lib-es/exchange/swap/completeExchange.js.map +1 -1
  217. package/lib-es/exchange/swap/hooks/useSwapTransaction.d.ts +4 -3
  218. package/lib-es/exchange/swap/hooks/useSwapTransaction.d.ts.map +1 -1
  219. package/lib-es/exchange/swap/hooks/useSwapTransaction.js +5 -4
  220. package/lib-es/exchange/swap/hooks/useSwapTransaction.js.map +1 -1
  221. package/lib-es/exchange/swap/hooks/v5/useFetchCurrencyAll.d.ts.map +1 -1
  222. package/lib-es/exchange/swap/hooks/v5/useFetchCurrencyAll.js +4 -0
  223. package/lib-es/exchange/swap/hooks/v5/useFetchCurrencyAll.js.map +1 -1
  224. package/lib-es/exchange/swap/hooks/v5/useFetchCurrencyFrom.d.ts.map +1 -1
  225. package/lib-es/exchange/swap/hooks/v5/useFetchCurrencyFrom.js +4 -1
  226. package/lib-es/exchange/swap/hooks/v5/useFetchCurrencyFrom.js.map +1 -1
  227. package/lib-es/exchange/swap/hooks/v5/useFetchCurrencyTo.d.ts.map +1 -1
  228. package/lib-es/exchange/swap/hooks/v5/useFetchCurrencyTo.js +4 -2
  229. package/lib-es/exchange/swap/hooks/v5/useFetchCurrencyTo.js.map +1 -1
  230. package/lib-es/exchange/swap/hooks/v5/useFetchRates.d.ts +3 -2
  231. package/lib-es/exchange/swap/hooks/v5/useFetchRates.d.ts.map +1 -1
  232. package/lib-es/exchange/swap/hooks/v5/useFetchRates.js +12 -9
  233. package/lib-es/exchange/swap/hooks/v5/useFetchRates.js.map +1 -1
  234. package/lib-es/exchange/swap/hooks/v5/useFilteredProviders.d.ts +6 -0
  235. package/lib-es/exchange/swap/hooks/v5/useFilteredProviders.d.ts.map +1 -0
  236. package/lib-es/exchange/swap/hooks/v5/useFilteredProviders.js +47 -0
  237. package/lib-es/exchange/swap/hooks/v5/useFilteredProviders.js.map +1 -0
  238. package/lib-es/exchange/swap/hooks/v5/useProviderRates.d.ts +2 -1
  239. package/lib-es/exchange/swap/hooks/v5/useProviderRates.d.ts.map +1 -1
  240. package/lib-es/exchange/swap/hooks/v5/useProviderRates.js +6 -13
  241. package/lib-es/exchange/swap/hooks/v5/useProviderRates.js.map +1 -1
  242. package/lib-es/exchange/swap/initSwap.d.ts.map +1 -1
  243. package/lib-es/exchange/swap/initSwap.js +2 -1
  244. package/lib-es/exchange/swap/initSwap.js.map +1 -1
  245. package/lib-es/families/cosmos/bridge/mock.js +1 -1
  246. package/lib-es/families/evm/config.d.ts.map +1 -1
  247. package/lib-es/families/evm/config.js +32 -0
  248. package/lib-es/families/evm/config.js.map +1 -1
  249. package/lib-es/families/stacks/__tests__/sync.integration.test.js +1 -1
  250. package/lib-es/families/stacks/__tests__/sync.integration.test.js.map +1 -1
  251. package/lib-es/families/stacks/bridge/utils/api.d.ts.map +1 -1
  252. package/lib-es/families/stacks/bridge/utils/api.js +9 -3
  253. package/lib-es/families/stacks/bridge/utils/api.js.map +1 -1
  254. package/lib-es/families/stacks/bridge/utils/api.types.d.ts +80 -10
  255. package/lib-es/families/stacks/bridge/utils/api.types.d.ts.map +1 -1
  256. package/lib-es/families/stacks/bridge/utils/misc.d.ts +1 -1
  257. package/lib-es/families/stacks/bridge/utils/misc.d.ts.map +1 -1
  258. package/lib-es/families/stacks/bridge/utils/misc.js +30 -22
  259. package/lib-es/families/stacks/bridge/utils/misc.js.map +1 -1
  260. package/lib-es/families/stacks/bridge/utils/misc.unit.test.js +83 -66
  261. package/lib-es/families/stacks/bridge/utils/misc.unit.test.js.map +1 -1
  262. package/lib-es/families/stacks/synchronization.js +1 -1
  263. package/lib-es/families/stacks/synchronization.js.map +1 -1
  264. package/lib-es/families/tron/api/index.js +2 -2
  265. package/lib-es/families/tron/api/index.js.map +1 -1
  266. package/lib-es/families/tron/signOperation.d.ts.map +1 -1
  267. package/lib-es/families/tron/signOperation.js +1 -12
  268. package/lib-es/families/tron/signOperation.js.map +1 -1
  269. package/lib-es/families/tron/synchronization.d.ts.map +1 -1
  270. package/lib-es/families/tron/synchronization.js +35 -3
  271. package/lib-es/families/tron/synchronization.js.map +1 -1
  272. package/lib-es/featureFlags/defaultFeatures.d.ts +5 -1
  273. package/lib-es/featureFlags/defaultFeatures.d.ts.map +1 -1
  274. package/lib-es/featureFlags/defaultFeatures.js +11 -5
  275. package/lib-es/featureFlags/defaultFeatures.js.map +1 -1
  276. package/lib-es/featureFlags/firebaseFeatureFlags.d.ts +9 -3
  277. package/lib-es/featureFlags/firebaseFeatureFlags.d.ts.map +1 -1
  278. package/lib-es/featureFlags/groupedFeatures.d.ts +2 -1
  279. package/lib-es/featureFlags/groupedFeatures.d.ts.map +1 -1
  280. package/lib-es/featureFlags/groupedFeatures.js +0 -3
  281. package/lib-es/featureFlags/groupedFeatures.js.map +1 -1
  282. package/lib-es/featureFlags/useFeature.d.ts +1 -1
  283. package/lib-es/featureFlags/useFeature.d.ts.map +1 -1
  284. package/lib-es/generated/deviceTransactionConfig.d.ts +1 -1
  285. package/lib-es/generated/transaction.d.ts +2 -2
  286. package/lib-es/helpers.d.ts +1 -0
  287. package/lib-es/helpers.d.ts.map +1 -1
  288. package/lib-es/helpers.js +3 -0
  289. package/lib-es/helpers.js.map +1 -1
  290. package/lib-es/hw/getOnboardingStatePolling.js +2 -2
  291. package/lib-es/hw/getOnboardingStatePolling.js.map +1 -1
  292. package/lib-es/market/api/index.d.ts +8 -0
  293. package/lib-es/market/api/index.d.ts.map +1 -0
  294. package/lib-es/market/api/index.js +100 -0
  295. package/lib-es/market/api/index.js.map +1 -0
  296. package/lib-es/market/hooks/useMarketDataProvider.d.ts +13 -0
  297. package/lib-es/market/hooks/useMarketDataProvider.d.ts.map +1 -0
  298. package/lib-es/market/{v2 → hooks}/useMarketDataProvider.js +34 -37
  299. package/lib-es/market/hooks/useMarketDataProvider.js.map +1 -0
  300. package/lib-es/market/{v2 → hooks}/useMarketPerformers.d.ts +1 -1
  301. package/lib-es/market/hooks/useMarketPerformers.d.ts.map +1 -0
  302. package/lib-es/market/{v2 → hooks}/useMarketPerformers.js +3 -3
  303. package/lib-es/market/hooks/useMarketPerformers.js.map +1 -0
  304. package/lib-es/market/utils/currencyFormatter.d.ts +3 -26
  305. package/lib-es/market/utils/currencyFormatter.d.ts.map +1 -1
  306. package/lib-es/market/utils/currencyFormatter.js +35 -31
  307. package/lib-es/market/utils/currencyFormatter.js.map +1 -1
  308. package/lib-es/market/utils/index.d.ts +5 -0
  309. package/lib-es/market/utils/index.d.ts.map +1 -0
  310. package/lib-es/market/utils/index.js +32 -0
  311. package/lib-es/market/utils/index.js.map +1 -0
  312. package/lib-es/market/utils/queryKeys.d.ts.map +1 -0
  313. package/lib-es/market/utils/queryKeys.js.map +1 -0
  314. package/lib-es/market/utils/timers.d.ts.map +1 -0
  315. package/lib-es/market/utils/timers.js.map +1 -0
  316. package/lib-es/market/{types.d.ts → utils/types.d.ts} +35 -53
  317. package/lib-es/market/utils/types.d.ts.map +1 -0
  318. package/lib-es/market/utils/types.js +16 -0
  319. package/lib-es/market/utils/types.js.map +1 -0
  320. package/lib-es/platform/converters.d.ts.map +1 -1
  321. package/lib-es/platform/converters.js +5 -6
  322. package/lib-es/platform/converters.js.map +1 -1
  323. package/lib-es/platform/types.d.ts +6 -1
  324. package/lib-es/platform/types.d.ts.map +1 -1
  325. package/lib-es/platform/types.js +10 -1
  326. package/lib-es/platform/types.js.map +1 -1
  327. package/lib-es/wallet-api/constants.d.ts +6 -1
  328. package/lib-es/wallet-api/constants.d.ts.map +1 -1
  329. package/lib-es/wallet-api/constants.js +7 -1
  330. package/lib-es/wallet-api/constants.js.map +1 -1
  331. package/lib-es/wallet-api/converters.d.ts +1 -1
  332. package/lib-es/wallet-api/converters.d.ts.map +1 -1
  333. package/lib-es/wallet-api/converters.js +6 -5
  334. package/lib-es/wallet-api/converters.js.map +1 -1
  335. package/package.json +45 -45
  336. package/src/__tests__/test-helpers/environment.ts +4 -0
  337. package/src/apps/listApps/v2.test.ts +151 -0
  338. package/src/apps/listApps/v2.ts +2 -2
  339. package/src/apps/mock.ts +30 -1
  340. package/src/apps/react.test.ts +1 -0
  341. package/src/currencies/__snapshots__/sortByMarketcap.test.ts.snap +358 -1
  342. package/src/device/use-cases/listAppsUseCase.ts +1 -0
  343. package/src/deviceSDK/actions/getLatestAvailableFirmware.test.ts +4 -4
  344. package/src/deviceSDK/tasks/core.ts +2 -2
  345. package/src/exchange/providers/swap.ts +9 -1
  346. package/src/exchange/swap/api/v5/__tests__/fetchCurrencyAll.spec.ts +2 -1
  347. package/src/exchange/swap/api/v5/__tests__/fetchCurrencyFrom.spec.ts +3 -0
  348. package/src/exchange/swap/api/v5/__tests__/fetchCurrencyTo.spec.ts +3 -1
  349. package/src/exchange/swap/api/v5/fetchCurrencyAll.ts +3 -3
  350. package/src/exchange/swap/api/v5/fetchCurrencyFrom.ts +7 -3
  351. package/src/exchange/swap/api/v5/fetchCurrencyTo.ts +7 -3
  352. package/src/exchange/swap/api/v5/fetchRates.ts +3 -7
  353. package/src/exchange/swap/completeExchange.ts +5 -1
  354. package/src/exchange/swap/hooks/useSwapTransaction.ts +12 -9
  355. package/src/exchange/swap/hooks/v5/useFetchCurrencyAll.ts +4 -0
  356. package/src/exchange/swap/hooks/v5/useFetchCurrencyFrom.ts +4 -1
  357. package/src/exchange/swap/hooks/v5/useFetchCurrencyTo.ts +4 -2
  358. package/src/exchange/swap/hooks/v5/useFetchRates.ts +15 -9
  359. package/src/exchange/swap/hooks/v5/useFilteredProviders.ts +42 -0
  360. package/src/exchange/swap/hooks/v5/useProviderRates.ts +7 -14
  361. package/src/exchange/swap/initSwap.ts +5 -1
  362. package/src/families/cosmos/bridge/mock.ts +1 -1
  363. package/src/families/evm/config.ts +32 -0
  364. package/src/families/stacks/__snapshots__/bridge.integration.test.ts.snap +7 -7
  365. package/src/families/stacks/__tests__/sync.integration.test.ts +1 -1
  366. package/src/families/stacks/bridge/utils/api.ts +10 -5
  367. package/src/families/stacks/bridge/utils/api.types.ts +81 -10
  368. package/src/families/stacks/bridge/utils/misc.ts +43 -38
  369. package/src/families/stacks/bridge/utils/misc.unit.test.ts +88 -70
  370. package/src/families/stacks/synchronization.ts +1 -1
  371. package/src/families/tron/api/index.ts +2 -2
  372. package/src/families/tron/signOperation.ts +0 -15
  373. package/src/families/tron/synchronization.ts +45 -3
  374. package/src/featureFlags/defaultFeatures.ts +14 -3
  375. package/src/featureFlags/groupedFeatures.ts +3 -4
  376. package/src/helpers.ts +6 -0
  377. package/src/hw/getOnboardingStatePolling.ts +2 -2
  378. package/src/market/api/index.ts +138 -0
  379. package/src/market/{v2 → hooks}/useMarketDataProvider.ts +34 -33
  380. package/src/market/{v2 → hooks}/useMarketPerformers.ts +4 -4
  381. package/src/market/utils/currencyFormatter.ts +32 -28
  382. package/src/market/utils/index.ts +34 -0
  383. package/src/market/{types.ts → utils/types.ts} +38 -48
  384. package/src/platform/converters.ts +4 -5
  385. package/src/platform/types.ts +12 -1
  386. package/src/wallet-api/constants.ts +9 -1
  387. package/src/wallet-api/converters.ts +5 -6
  388. package/lib/market/MarketDataProvider.d.ts +0 -27
  389. package/lib/market/MarketDataProvider.d.ts.map +0 -1
  390. package/lib/market/MarketDataProvider.js +0 -261
  391. package/lib/market/MarketDataProvider.js.map +0 -1
  392. package/lib/market/api/api.d.ts +0 -18
  393. package/lib/market/api/api.d.ts.map +0 -1
  394. package/lib/market/api/api.js +0 -246
  395. package/lib/market/api/api.js.map +0 -1
  396. package/lib/market/api/api.mock.d.ts +0 -15
  397. package/lib/market/api/api.mock.d.ts.map +0 -1
  398. package/lib/market/api/api.mock.js +0 -395
  399. package/lib/market/api/api.mock.js.map +0 -1
  400. package/lib/market/types.d.ts.map +0 -1
  401. package/lib/market/types.js +0 -3
  402. package/lib/market/types.js.map +0 -1
  403. package/lib/market/utils/rangeFormatter.d.ts +0 -3
  404. package/lib/market/utils/rangeFormatter.d.ts.map +0 -1
  405. package/lib/market/utils/rangeFormatter.js +0 -18
  406. package/lib/market/utils/rangeFormatter.js.map +0 -1
  407. package/lib/market/v2/queryKeys.d.ts.map +0 -1
  408. package/lib/market/v2/queryKeys.js.map +0 -1
  409. package/lib/market/v2/timers.d.ts.map +0 -1
  410. package/lib/market/v2/timers.js.map +0 -1
  411. package/lib/market/v2/useMarketDataProvider.d.ts +0 -63
  412. package/lib/market/v2/useMarketDataProvider.d.ts.map +0 -1
  413. package/lib/market/v2/useMarketDataProvider.js.map +0 -1
  414. package/lib/market/v2/useMarketPerformers.d.ts.map +0 -1
  415. package/lib/market/v2/useMarketPerformers.js.map +0 -1
  416. package/lib-es/market/MarketDataProvider.d.ts +0 -27
  417. package/lib-es/market/MarketDataProvider.d.ts.map +0 -1
  418. package/lib-es/market/MarketDataProvider.js +0 -229
  419. package/lib-es/market/MarketDataProvider.js.map +0 -1
  420. package/lib-es/market/api/api.d.ts +0 -18
  421. package/lib-es/market/api/api.d.ts.map +0 -1
  422. package/lib-es/market/api/api.js +0 -232
  423. package/lib-es/market/api/api.js.map +0 -1
  424. package/lib-es/market/api/api.mock.d.ts +0 -15
  425. package/lib-es/market/api/api.mock.d.ts.map +0 -1
  426. package/lib-es/market/api/api.mock.js +0 -393
  427. package/lib-es/market/api/api.mock.js.map +0 -1
  428. package/lib-es/market/types.d.ts.map +0 -1
  429. package/lib-es/market/types.js +0 -2
  430. package/lib-es/market/types.js.map +0 -1
  431. package/lib-es/market/utils/rangeFormatter.d.ts +0 -3
  432. package/lib-es/market/utils/rangeFormatter.d.ts.map +0 -1
  433. package/lib-es/market/utils/rangeFormatter.js +0 -14
  434. package/lib-es/market/utils/rangeFormatter.js.map +0 -1
  435. package/lib-es/market/v2/queryKeys.d.ts.map +0 -1
  436. package/lib-es/market/v2/queryKeys.js.map +0 -1
  437. package/lib-es/market/v2/timers.d.ts.map +0 -1
  438. package/lib-es/market/v2/timers.js.map +0 -1
  439. package/lib-es/market/v2/useMarketDataProvider.d.ts +0 -63
  440. package/lib-es/market/v2/useMarketDataProvider.d.ts.map +0 -1
  441. package/lib-es/market/v2/useMarketDataProvider.js.map +0 -1
  442. package/lib-es/market/v2/useMarketPerformers.d.ts.map +0 -1
  443. package/lib-es/market/v2/useMarketPerformers.js.map +0 -1
  444. package/src/market/MarketDataProvider.tsx +0 -403
  445. package/src/market/api/api.mock.ts +0 -403
  446. package/src/market/api/api.ts +0 -310
  447. package/src/market/utils/rangeFormatter.ts +0 -15
  448. /package/lib/market/{v2 → utils}/queryKeys.d.ts +0 -0
  449. /package/lib/market/{v2 → utils}/queryKeys.js +0 -0
  450. /package/lib/market/{v2 → utils}/timers.d.ts +0 -0
  451. /package/lib/market/{v2 → utils}/timers.js +0 -0
  452. /package/lib-es/market/{v2 → utils}/queryKeys.d.ts +0 -0
  453. /package/lib-es/market/{v2 → utils}/queryKeys.js +0 -0
  454. /package/lib-es/market/{v2 → utils}/timers.d.ts +0 -0
  455. /package/lib-es/market/{v2 → utils}/timers.js +0 -0
  456. /package/src/market/{v2 → utils}/queryKeys.ts +0 -0
  457. /package/src/market/{v2 → utils}/timers.ts +0 -0
@@ -1,403 +0,0 @@
1
- import { CurrencyData, MarketCoin, MarketListRequestParams, SupportedCoins } from "../types";
2
- import { listCryptoCurrencies, listTokens } from "../../currencies";
3
-
4
- const cryptoCurrenciesList = [...listCryptoCurrencies(), ...listTokens()];
5
-
6
- async function setSupportedCoinsList(): Promise<SupportedCoins> {
7
- const response = await Promise.resolve([
8
- { id: "bitcoin", symbol: "btc", name: "Bitcoin" },
9
- { id: "ethereum", symbol: "eth", name: "Ethereum" },
10
- { id: "ethereum-apex", symbol: "eapex", name: "Ethereum Apex" },
11
- { id: "ethereum-cash", symbol: "ecash", name: "Ethereum Cash" },
12
- ]);
13
-
14
- return response;
15
- }
16
-
17
- const matchSearch =
18
- (search: string) =>
19
- (currency: MarketCoin): boolean => {
20
- if (!search) return false;
21
- const match = `${currency.symbol}|${currency.name}`;
22
- return match.toLowerCase().includes(search.toLowerCase());
23
- };
24
-
25
- const paginatedData = [
26
- {
27
- id: "bitcoin",
28
- symbol: "btc",
29
- name: "Bitcoin",
30
- image: "https://assets.coingecko.com/coins/images/1/large/bitcoin.png?1547033579",
31
- current_price: 46978,
32
- market_cap: 888084713113,
33
- market_cap_rank: 1,
34
- fully_diluted_valuation: 986540621536,
35
- total_volume: 27166733732,
36
- high_24h: 47466,
37
- low_24h: 45653,
38
- price_change_24h: -448.517772161074,
39
- price_change_percentage_24h: -0.94571,
40
- market_cap_change_24h: -6925208740.524048,
41
- market_cap_change_percentage_24h: -0.77376,
42
- circulating_supply: 18904218,
43
- total_supply: 21000000,
44
- max_supply: 21000000,
45
- ath: 69045,
46
- ath_change_percentage: -32.0311,
47
- ath_date: "2021-11-10T14:24:11.849Z",
48
- atl: 67.81,
49
- atl_change_percentage: 69107.58322,
50
- atl_date: "2013-07-06T00:00:00.000Z",
51
- roi: null,
52
- last_updated: "2021-12-18T16:31:02.628Z",
53
- price_change_percentage_24h_in_currency: -0.9457084615407927,
54
- },
55
- {
56
- id: "ethereum",
57
- symbol: "eth",
58
- name: "Ethereum",
59
- image: "https://assets.coingecko.com/coins/images/279/large/ethereum.png?1595348880",
60
- current_price: 3956.23,
61
- market_cap: 469967313961,
62
- market_cap_rank: 2,
63
- fully_diluted_valuation: null,
64
- total_volume: 22896047898,
65
- high_24h: 3998.6,
66
- low_24h: 3790.1,
67
- price_change_24h: 31.34,
68
- price_change_percentage_24h: 0.79852,
69
- market_cap_change_24h: 4376247843,
70
- market_cap_change_percentage_24h: 0.93993,
71
- circulating_supply: 118791776.124,
72
- total_supply: null,
73
- max_supply: null,
74
- ath: 4878.26,
75
- ath_change_percentage: -19.07897,
76
- ath_date: "2021-11-10T14:24:19.604Z",
77
- atl: 0.432979,
78
- atl_change_percentage: 911616.29321,
79
- atl_date: "2015-10-20T00:00:00.000Z",
80
- roi: {
81
- times: 111.85400578727416,
82
- currency: "btc",
83
- percentage: 11185.400578727416,
84
- },
85
- last_updated: "2021-12-18T16:30:24.123Z",
86
- price_change_percentage_24h_in_currency: 0.7985206175407733,
87
- },
88
- {
89
- id: "binancecoin",
90
- symbol: "bnb",
91
- name: "Binance Coin",
92
- image: "https://assets.coingecko.com/coins/images/825/large/binance-coin-logo.png?1547034615",
93
- current_price: 530.99,
94
- market_cap: 89278760378,
95
- market_cap_rank: 3,
96
- fully_diluted_valuation: 89278760378,
97
- total_volume: 601931681,
98
- high_24h: 536.2,
99
- low_24h: 519.35,
100
- price_change_24h: -1.431695982805,
101
- price_change_percentage_24h: -0.2689,
102
- market_cap_change_24h: -217891640.56773376,
103
- market_cap_change_percentage_24h: -0.24346,
104
- circulating_supply: 168137035.9,
105
- total_supply: 168137035.9,
106
- max_supply: 168137035.9,
107
- ath: 686.31,
108
- ath_change_percentage: -22.80102,
109
- ath_date: "2021-05-10T07:24:17.097Z",
110
- atl: 0.0398177,
111
- atl_change_percentage: 1330518.574,
112
- atl_date: "2017-10-19T00:00:00.000Z",
113
- roi: null,
114
- last_updated: "2021-12-18T16:30:40.065Z",
115
- price_change_percentage_24h_in_currency: -0.26890361163187976,
116
- },
117
- {
118
- id: "tether",
119
- symbol: "usdt",
120
- name: "Tether",
121
- image: "https://assets.coingecko.com/coins/images/325/large/Tether-logo.png?1598003707",
122
- current_price: 1,
123
- market_cap: 77439200796,
124
- market_cap_rank: 4,
125
- fully_diluted_valuation: null,
126
- total_volume: 62554588893,
127
- high_24h: 1.01,
128
- low_24h: 0.987325,
129
- price_change_24h: -0.011415856662,
130
- price_change_percentage_24h: -1.1271,
131
- market_cap_change_24h: -259872290.71488953,
132
- market_cap_change_percentage_24h: -0.33446,
133
- circulating_supply: 77328369536.52,
134
- total_supply: 77328369536.52,
135
- max_supply: null,
136
- ath: 1.32,
137
- ath_change_percentage: -24.41245,
138
- ath_date: "2018-07-24T00:00:00.000Z",
139
- atl: 0.572521,
140
- atl_change_percentage: 74.68274,
141
- atl_date: "2015-03-02T00:00:00.000Z",
142
- roi: null,
143
- last_updated: "2021-12-18T16:27:59.344Z",
144
- price_change_percentage_24h_in_currency: -1.1271033891153508,
145
- },
146
- {
147
- id: "solana",
148
- symbol: "sol",
149
- name: "Solana",
150
- image: "https://assets.coingecko.com/coins/images/4128/large/Solana.jpg?1635329178",
151
- current_price: 182.14,
152
- market_cap: 55791855479,
153
- market_cap_rank: 5,
154
- fully_diluted_valuation: null,
155
- total_volume: 1864966986,
156
- high_24h: 182.76,
157
- low_24h: 171.62,
158
- price_change_24h: 1.27,
159
- price_change_percentage_24h: 0.70456,
160
- market_cap_change_24h: 1062110605,
161
- market_cap_change_percentage_24h: 1.94065,
162
- circulating_supply: 307978914.997809,
163
- total_supply: 508180963.57,
164
- max_supply: null,
165
- ath: 259.96,
166
- ath_change_percentage: -30.21122,
167
- ath_date: "2021-11-06T21:54:35.825Z",
168
- atl: 0.500801,
169
- atl_change_percentage: 36126.43086,
170
- atl_date: "2020-05-11T19:35:23.449Z",
171
- roi: null,
172
- last_updated: "2021-12-18T16:31:38.005Z",
173
- price_change_percentage_24h_in_currency: 0.704558493197451,
174
- },
175
- {
176
- id: "usd-coin",
177
- symbol: "usdc",
178
- name: "USD Coin",
179
- image: "https://assets.coingecko.com/coins/images/6319/large/USD_Coin_icon.png?1547042389",
180
- current_price: 0.999438,
181
- market_cap: 41947712099,
182
- market_cap_rank: 6,
183
- fully_diluted_valuation: null,
184
- total_volume: 3610141997,
185
- high_24h: 1.01,
186
- low_24h: 0.992322,
187
- price_change_24h: -0.008300533333,
188
- price_change_percentage_24h: -0.82368,
189
- market_cap_change_24h: -15466850.668174744,
190
- market_cap_change_percentage_24h: -0.03686,
191
- circulating_supply: 41988882706.8525,
192
- total_supply: 41974529053.5122,
193
- max_supply: null,
194
- ath: 1.17,
195
- ath_change_percentage: -14.81075,
196
- ath_date: "2019-05-08T00:40:28.300Z",
197
- atl: 0.891848,
198
- atl_change_percentage: 12.0168,
199
- atl_date: "2021-05-19T13:14:05.611Z",
200
- roi: null,
201
- last_updated: "2021-12-18T16:31:29.480Z",
202
- price_change_percentage_24h_in_currency: -0.823678944021661,
203
- },
204
- {
205
- id: "cardano",
206
- symbol: "ada",
207
- name: "Cardano",
208
- image: "https://assets.coingecko.com/coins/images/975/large/cardano.png?1547034860",
209
- current_price: 1.25,
210
- market_cap: 40061737912,
211
- market_cap_rank: 7,
212
- fully_diluted_valuation: 56220178462,
213
- total_volume: 1039172214,
214
- high_24h: 1.27,
215
- low_24h: 1.2,
216
- price_change_24h: -0.00949416665,
217
- price_change_percentage_24h: -0.7542,
218
- market_cap_change_24h: -35615245.100372314,
219
- market_cap_change_percentage_24h: -0.08882,
220
- circulating_supply: 32066390668.4135,
221
- total_supply: 45000000000,
222
- max_supply: 45000000000,
223
- ath: 3.09,
224
- ath_change_percentage: -59.59586,
225
- ath_date: "2021-09-02T06:00:10.474Z",
226
- atl: 0.01925275,
227
- atl_change_percentage: 6378.24434,
228
- atl_date: "2020-03-13T02:22:55.044Z",
229
- roi: null,
230
- last_updated: "2021-12-18T16:31:09.050Z",
231
- price_change_percentage_24h_in_currency: -0.754204745255466,
232
- },
233
- ];
234
- // fetches currencies data for selected currencies ids
235
- async function listPaginated({
236
- search = "",
237
- starred = [],
238
- order = "desc",
239
- range = "24h",
240
- ids = [],
241
- }: MarketListRequestParams): Promise<CurrencyData[]> {
242
- const response = await Promise.resolve(paginatedData);
243
-
244
- let filteredResponse = response;
245
-
246
- if (order !== "desc") {
247
- filteredResponse = filteredResponse.sort((x, y) => y.market_cap_rank - x.market_cap_rank);
248
- }
249
-
250
- if (search) {
251
- filteredResponse = filteredResponse.filter(matchSearch(search));
252
- }
253
-
254
- if (starred.length > 0) {
255
- filteredResponse = filteredResponse.filter(currency => starred.includes(currency.id));
256
- }
257
-
258
- if (ids.length > 0) {
259
- filteredResponse = filteredResponse.filter(currency => ids.includes(currency.id));
260
- }
261
-
262
- // @ts-expect-error issue in typing
263
- return filteredResponse.map((currency: any) => ({
264
- id: currency.id,
265
- name: currency.name,
266
- image: currency.image,
267
- internalCurrency: cryptoCurrenciesList.find(
268
- ({ ticker }) => ticker.toLowerCase() === currency.symbol,
269
- ),
270
- marketcap: currency.market_cap,
271
- marketcapRank: currency.market_cap_rank,
272
- totalVolume: currency.total_volume,
273
- high24h: currency.high_24h,
274
- low24h: currency.low_24h,
275
- ticker: currency.symbol,
276
- price: currency.current_price,
277
- priceChangePercentage:
278
- range !== "24h"
279
- ? currency.price_change_percentage_24h_in_currency * 7
280
- : currency.price_change_percentage_24h_in_currency,
281
- marketCapChangePercentage24h: currency.market_cap_change_percentage_24h,
282
- circulatingSupply: currency.circulating_supply,
283
- totalSupply: currency.total_supply,
284
- maxSupply: currency.max_supply,
285
- ath: currency.ath,
286
- athDate: currency.ath_date,
287
- atl: currency.atl,
288
- atlDate: currency.atl_date,
289
- sparklineIn7d: null,
290
- chartData: [],
291
- }));
292
- }
293
-
294
- // Fetches list of supported counterCurrencies
295
- async function supportedCounterCurrencies(): Promise<string[]> {
296
- return await Promise.resolve([
297
- "btc",
298
- "eth",
299
- "ltc",
300
- "bch",
301
- "bnb",
302
- "eos",
303
- "xrp",
304
- "xlm",
305
- "link",
306
- "dot",
307
- "yfi",
308
- "usd",
309
- "aed",
310
- "ars",
311
- "aud",
312
- "bdt",
313
- "bhd",
314
- "bmd",
315
- "brl",
316
- "cad",
317
- "chf",
318
- "clp",
319
- "cny",
320
- "czk",
321
- "dkk",
322
- "eur",
323
- "gbp",
324
- "hkd",
325
- "huf",
326
- "idr",
327
- "ils",
328
- "inr",
329
- "jpy",
330
- "krw",
331
- "kwd",
332
- "lkr",
333
- "mmk",
334
- "mxn",
335
- "myr",
336
- "ngn",
337
- "nok",
338
- "nzd",
339
- "php",
340
- "pkr",
341
- "pln",
342
- "rub",
343
- "sar",
344
- "sek",
345
- "sgd",
346
- "thb",
347
- "try",
348
- "twd",
349
- "uah",
350
- "vef",
351
- "vnd",
352
- "zar",
353
- "xdr",
354
- "xag",
355
- "xau",
356
- "bits",
357
- "sats",
358
- ]);
359
- }
360
-
361
- // Fetches list of supported currencies
362
- async function currencyChartData(): Promise<{
363
- [range: string]: number[][];
364
- }> {
365
- const response = await Promise.resolve({
366
- prices: [
367
- [1639760425566, 47035.7730170554],
368
- [1639764200520, 46779.28084436036],
369
- [1639767793752, 46899.81670459505],
370
- [1639771405996, 46806.89615030911],
371
- [1639774854719, 46372.35410149477],
372
- [1639778429112, 47091.66371795489],
373
- [1639782342710, 46507.965042542106],
374
- [1639785697940, 46328.6963654447],
375
- [1639789279103, 46415.52050647275],
376
- [1639793084532, 45826.54707719198],
377
- [1639796561743, 45886.69785964224],
378
- [1639800325023, 46535.85544547407],
379
- [1639803752264, 46630.66364205827],
380
- [1639807349369, 46796.65748955589],
381
- [1639810831681, 46404.12378055947],
382
- [1639814720824, 46429.86171498202],
383
- [1639818226026, 46208.467967110075],
384
- [1639821761024, 46794.55365462657],
385
- [1639825359138, 47337.122321658026],
386
- [1639829106656, 47070.8445217621],
387
- [1639832543681, 47113.48747087277],
388
- [1639836121826, 46857.76684001326],
389
- [1639839860258, 47145.895183572036],
390
- [1639843597758, 46876.27784614691],
391
- [1639845270000, 47035.775042793095],
392
- ],
393
- });
394
-
395
- return { "24h": response.prices };
396
- }
397
-
398
- export default {
399
- setSupportedCoinsList,
400
- listPaginated,
401
- supportedCounterCurrencies,
402
- currencyChartData,
403
- };
@@ -1,310 +0,0 @@
1
- import network from "@ledgerhq/live-network/network";
2
- import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
3
- import { listCryptoCurrencies, listSupportedCurrencies, listTokens } from "../../currencies";
4
- import { getEnv } from "@ledgerhq/live-env";
5
- import {
6
- CurrencyData,
7
- MarketCoin,
8
- MarketCurrencyChartDataRequestParams,
9
- MarketListRequestParams,
10
- RawCurrencyData,
11
- MarketPerformersParams,
12
- MarketItemResponse,
13
- SupportedCoins,
14
- MarketCurrencyRequestParams,
15
- } from "../types";
16
- import { rangeDataTable } from "../utils/rangeDataTable";
17
- import { currencyFormatter } from "../utils/currencyFormatter";
18
- import URL from "url";
19
- import { getRange } from "../utils/rangeFormatter";
20
-
21
- const cryptoCurrenciesList = [...listCryptoCurrencies(), ...listTokens()];
22
-
23
- const supportedCurrencies = listSupportedCurrencies();
24
-
25
- const liveCompatibleIds: string[] = supportedCurrencies
26
- .map(({ id }: CryptoCurrency) => id)
27
- .filter(Boolean);
28
-
29
- let LIVE_COINS_LIST: string[] = [];
30
-
31
- const baseURL = () => getEnv("LEDGER_COUNTERVALUES_API");
32
- const ROOT_PATH = getEnv("MARKET_API_URL");
33
-
34
- let SUPPORTED_COINS_LIST: SupportedCoins = [];
35
-
36
- export async function setSupportedCoinsList(): Promise<SupportedCoins> {
37
- const url = `${ROOT_PATH}/coins/list`;
38
- const { data } = await network({ method: "GET", url });
39
-
40
- SUPPORTED_COINS_LIST = data;
41
-
42
- LIVE_COINS_LIST = SUPPORTED_COINS_LIST.filter(({ id }) => liveCompatibleIds.includes(id)).map(
43
- ({ id }) => id,
44
- );
45
-
46
- return SUPPORTED_COINS_LIST;
47
- }
48
-
49
- export async function getSupportedCoinsList(): Promise<SupportedCoins> {
50
- const url = `${ROOT_PATH}/coins/list`;
51
- const { data } = await network({ method: "GET", url });
52
- return data;
53
- }
54
-
55
- const matchSearch =
56
- (search: string) =>
57
- (currency: MarketCoin): boolean => {
58
- if (!search) return false;
59
- const match = `${currency.symbol}|${currency.name}`;
60
- return match.toLowerCase().includes(search.toLowerCase());
61
- };
62
-
63
- // fetches currencies data for selected currencies ids
64
- async function listPaginated({
65
- counterCurrency,
66
- range = "24h",
67
- limit = 50,
68
- page = 1,
69
- ids: _ids = [],
70
- starred = [],
71
- orderBy = "market_cap",
72
- order = "desc",
73
- search = "",
74
- sparkline = true,
75
- liveCompatible = false,
76
- top100 = false,
77
- }: MarketListRequestParams): Promise<CurrencyData[]> {
78
- let ids = _ids;
79
-
80
- if (top100) {
81
- limit = 100;
82
- } else {
83
- if (search) {
84
- ids = SUPPORTED_COINS_LIST.filter(matchSearch(search)).map(({ id }) => id);
85
- if (!ids.length) {
86
- return [];
87
- }
88
- }
89
-
90
- if (liveCompatible) {
91
- if (ids.length > 0) {
92
- ids = LIVE_COINS_LIST.filter(id => ids.includes(id));
93
- } else {
94
- ids = ids.concat(LIVE_COINS_LIST);
95
- }
96
- }
97
-
98
- if (starred.length > 0) {
99
- if (ids.length > 0) {
100
- ids = starred.filter(id => ids.includes(id));
101
- } else {
102
- ids = ids.concat(starred);
103
- }
104
- }
105
- }
106
-
107
- ids = ids.slice((page - 1) * limit, limit * page);
108
-
109
- const url =
110
- `${ROOT_PATH}/coins/markets?vs_currency=${counterCurrency}&order=${orderBy}_${order}&per_page=${limit}` +
111
- `&sparkline=${sparkline ? "true" : "false"}&price_change_percentage=${range}` +
112
- `${ids.length > 0 ? `&page=1&&ids=${ids.toString()}` : `&page=${page}`}`;
113
-
114
- let { data } = await network({
115
- method: "GET",
116
- url,
117
- });
118
-
119
- if (top100) {
120
- // Perform a search by the user's input and order the result by change in percentage
121
- data = data
122
- .filter(currency => {
123
- if (!search) return true;
124
- const match = `${currency.symbol}|${currency.name}`;
125
- return match.toLowerCase().includes(search.toLowerCase());
126
- })
127
- .sort(
128
- (a, b) =>
129
- b[`price_change_percentage_${range}_in_currency`] -
130
- a[`price_change_percentage_${range}_in_currency`],
131
- );
132
- }
133
-
134
- return currencyFormatter(data, range, cryptoCurrenciesList);
135
- }
136
-
137
- // fetches currencies data for selected currencies ids
138
- export async function fetchList({
139
- counterCurrency,
140
- range = "24h",
141
- limit = 50,
142
- page = 1,
143
- ids: _ids = [],
144
- starred = [],
145
- orderBy = "market_cap",
146
- order = "desc",
147
- search = "",
148
- sparkline = true,
149
- liveCompatible = false,
150
- top100 = false,
151
- supportedCoinsList = [],
152
- liveCoinsList = [],
153
- }: MarketListRequestParams): Promise<RawCurrencyData[]> {
154
- let ids = _ids;
155
-
156
- if (top100) {
157
- limit = 100;
158
- } else {
159
- if (search) {
160
- ids = supportedCoinsList.filter(matchSearch(search)).map(({ id }) => id);
161
- if (!ids.length) {
162
- return [];
163
- }
164
- }
165
-
166
- if (liveCompatible) {
167
- if (ids.length > 0) {
168
- ids = liveCoinsList.filter(id => ids.includes(id));
169
- } else {
170
- ids = ids.concat(liveCoinsList);
171
- }
172
- }
173
-
174
- if (starred.length > 0) {
175
- if (ids.length > 0) {
176
- ids = starred.filter(id => ids.includes(id));
177
- } else {
178
- ids = ids.concat(starred);
179
- }
180
- }
181
- }
182
-
183
- ids = ids.slice((page - 1) * limit, limit * page);
184
-
185
- const url =
186
- `${ROOT_PATH}/coins/markets?vs_currency=${counterCurrency}&order=${orderBy}_${order}&per_page=${limit}` +
187
- `&sparkline=${sparkline ? "true" : "false"}&price_change_percentage=${range}` +
188
- `${ids.length > 0 ? `&page=1&&ids=${ids.toString()}` : `&page=${page}`}`;
189
-
190
- if ((starred.length > 0 || search.length > 0) && ids.length === 0) return [];
191
-
192
- let { data } = await network({
193
- method: "GET",
194
- url,
195
- });
196
-
197
- if (top100) {
198
- // Perform a search by the user's input and order the result by change in percentage
199
- data = data
200
- .filter(currency => {
201
- if (!search) return true;
202
- const match = `${currency.symbol}|${currency.name}`;
203
- return match.toLowerCase().includes(search.toLowerCase());
204
- })
205
- .sort(
206
- (a, b) =>
207
- b[`price_change_percentage_${range}_in_currency`] -
208
- a[`price_change_percentage_${range}_in_currency`],
209
- );
210
- }
211
-
212
- return data;
213
- }
214
-
215
- // Fetches list of supported counterCurrencies
216
- export async function supportedCounterCurrencies(): Promise<string[]> {
217
- const url = `${ROOT_PATH}/simple/supported_vs_currencies`;
218
-
219
- const { data } = await network({
220
- method: "GET",
221
- url,
222
- });
223
-
224
- return data;
225
- }
226
-
227
- export async function fetchCurrencyChartData({
228
- id,
229
- counterCurrency,
230
- range = "24h",
231
- }: MarketCurrencyChartDataRequestParams): Promise<Record<string, [number, number][]>> {
232
- const { days, interval } = rangeDataTable[range];
233
-
234
- const url = `${ROOT_PATH}/coins/${id}/market_chart?vs_currency=${counterCurrency}&days=${days}&interval=${interval}`;
235
-
236
- const { data } = await network({
237
- method: "GET",
238
- url,
239
- });
240
-
241
- return { [range]: data.prices };
242
- }
243
-
244
- export async function fetchCurrencyData({
245
- counterCurrency,
246
- range = "24h",
247
- id,
248
- }: MarketCurrencyRequestParams): Promise<RawCurrencyData> {
249
- const url = URL.format({
250
- pathname: `${ROOT_PATH}/coins/markets`,
251
- query: {
252
- vs_currency: counterCurrency,
253
- sparkline: true,
254
- price_change_percentage: range,
255
- page: 1,
256
- ids: id,
257
- },
258
- });
259
-
260
- const { data } = await network({
261
- method: "GET",
262
- url,
263
- });
264
-
265
- return data[0];
266
- }
267
-
268
- export async function fetchCurrency({ id }: MarketCurrencyRequestParams): Promise<RawCurrencyData> {
269
- const url = `${ROOT_PATH}/coins/${id}`;
270
-
271
- const { data } = await network({
272
- method: "GET",
273
- url,
274
- });
275
-
276
- return data;
277
- }
278
-
279
- export async function fetchMarketPerformers({
280
- counterCurrency,
281
- range,
282
- limit = 5,
283
- top = 50,
284
- sort,
285
- supported,
286
- }: MarketPerformersParams): Promise<MarketItemResponse[]> {
287
- const sortParam = `${sort === "asc" ? "positive" : "negative"}-price-change-${getRange(range)}`;
288
-
289
- const url = URL.format({
290
- pathname: `${baseURL()}/v3/markets`,
291
- query: {
292
- to: counterCurrency,
293
- limit,
294
- top,
295
- sort: sortParam,
296
- supported,
297
- },
298
- });
299
-
300
- const { data } = await network({ method: "GET", url });
301
-
302
- return data;
303
- }
304
-
305
- export default {
306
- setSupportedCoinsList,
307
- listPaginated,
308
- supportedCounterCurrencies,
309
- currencyChartData: fetchCurrencyChartData,
310
- };