@ledgerhq/live-common 21.26.3 → 21.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/__tests__/currencies.js +1 -1
- package/lib/__tests__/families/bitcoin/wallet-btc/xpub.synced.unit.test.js +27 -26
- package/lib/__tests__/families/bitcoin/wallet-btc/xpub.synced.unit.test.js.map +1 -1
- package/lib/__tests__/families/bitcoin/wallet-btc/xpub.syncing.integration.test.js +9 -7
- package/lib/__tests__/families/bitcoin/wallet-btc/xpub.syncing.integration.test.js.map +1 -1
- package/lib/__tests__/test-helpers/bridge.js +1 -1
- package/lib/__tests__/test-helpers/bridge.js.map +1 -1
- package/lib/apps/hw.d.ts.map +1 -1
- package/lib/apps/hw.js +8 -3
- package/lib/apps/hw.js.map +1 -1
- package/lib/apps/support.d.ts.map +1 -1
- package/lib/apps/support.js +2 -1
- package/lib/apps/support.js.map +1 -1
- package/lib/bridge/jsHelpers.js +1 -1
- package/lib/bridge/jsHelpers.js.map +1 -1
- package/lib/data/icons/react/index.d.ts +1 -0
- package/lib/data/icons/react/index.d.ts.map +1 -1
- package/lib/data/icons/react/index.js +4 -2
- package/lib/data/icons/react/index.js.map +1 -1
- package/lib/data/icons/react/sol.js +3 -3
- package/lib/data/icons/react/sol.js.map +1 -1
- package/lib/data/icons/react/tyc.d.ts +8 -0
- package/lib/data/icons/react/tyc.d.ts.map +1 -0
- package/lib/data/icons/react/tyc.js +33 -0
- package/lib/data/icons/react/tyc.js.map +1 -0
- package/lib/data/icons/reactNative/index.d.ts +1 -0
- package/lib/data/icons/reactNative/index.d.ts.map +1 -1
- package/lib/data/icons/reactNative/index.js +4 -2
- package/lib/data/icons/reactNative/index.js.map +1 -1
- package/lib/data/icons/reactNative/sol.js +3 -3
- package/lib/data/icons/reactNative/sol.js.map +1 -1
- package/lib/data/icons/reactNative/tyc.d.ts +8 -0
- package/lib/data/icons/reactNative/tyc.d.ts.map +1 -0
- package/lib/data/icons/reactNative/tyc.js +34 -0
- package/lib/data/icons/reactNative/tyc.js.map +1 -0
- package/lib/env.d.ts +20 -6
- package/lib/env.d.ts.map +1 -1
- package/lib/env.js +16 -2
- package/lib/env.js.map +1 -1
- package/lib/env.react.d.ts +1 -1
- package/lib/env.react.d.ts.map +1 -1
- package/lib/exchange/hw-app-exchange/Exchange.d.ts +12 -15
- package/lib/exchange/hw-app-exchange/Exchange.d.ts.map +1 -1
- package/lib/exchange/hw-app-exchange/Exchange.js +4 -13
- package/lib/exchange/hw-app-exchange/Exchange.js.map +1 -1
- package/lib/exchange/index.d.ts.map +1 -1
- package/lib/exchange/index.js +9 -2
- package/lib/exchange/index.js.map +1 -1
- package/lib/exchange/platform/completeExchange.d.ts +6 -0
- package/lib/exchange/platform/completeExchange.d.ts.map +1 -0
- package/lib/exchange/platform/completeExchange.js +24 -0
- package/lib/exchange/platform/completeExchange.js.map +1 -0
- package/lib/exchange/platform/serialization.d.ts +4 -0
- package/lib/exchange/platform/serialization.d.ts.map +1 -0
- package/lib/exchange/platform/serialization.js +57 -0
- package/lib/exchange/platform/serialization.js.map +1 -0
- package/lib/exchange/{swap → platform}/startExchange.d.ts +0 -0
- package/lib/exchange/platform/startExchange.d.ts.map +1 -0
- package/lib/exchange/{swap → platform}/startExchange.js +3 -3
- package/lib/exchange/platform/startExchange.js.map +1 -0
- package/lib/exchange/platform/transfer/completeExchange.d.ts +5 -0
- package/lib/exchange/platform/transfer/completeExchange.d.ts.map +1 -0
- package/lib/exchange/platform/transfer/completeExchange.js +198 -0
- package/lib/exchange/platform/transfer/completeExchange.js.map +1 -0
- package/lib/exchange/platform/transfer/index.d.ts +5 -0
- package/lib/exchange/platform/transfer/index.d.ts.map +1 -0
- package/lib/exchange/platform/transfer/index.js +49 -0
- package/lib/exchange/platform/transfer/index.js.map +1 -0
- package/lib/exchange/platform/types.d.ts +59 -0
- package/lib/exchange/platform/types.d.ts.map +1 -0
- package/lib/exchange/platform/types.js +3 -0
- package/lib/exchange/platform/types.js.map +1 -0
- package/lib/exchange/sell/checkSignatureAndPrepare.js +1 -2
- package/lib/exchange/sell/checkSignatureAndPrepare.js.map +1 -1
- package/lib/exchange/sell/getTransactionId.js +1 -2
- package/lib/exchange/sell/getTransactionId.js.map +1 -1
- package/lib/exchange/sell/index.d.ts +6 -0
- package/lib/exchange/sell/index.d.ts.map +1 -1
- package/lib/exchange/sell/index.js +3 -3
- package/lib/exchange/sell/index.js.map +1 -1
- package/lib/exchange/swap/completeExchange.d.ts +2 -13
- package/lib/exchange/swap/completeExchange.d.ts.map +1 -1
- package/lib/exchange/swap/completeExchange.js +2 -4
- package/lib/exchange/swap/completeExchange.js.map +1 -1
- package/lib/exchange/swap/hooks/usePickDefaultAccount.d.ts.map +1 -1
- package/lib/exchange/swap/hooks/usePickDefaultAccount.js +4 -9
- package/lib/exchange/swap/hooks/usePickDefaultAccount.js.map +1 -1
- package/lib/exchange/swap/initSwap.d.ts.map +1 -1
- package/lib/exchange/swap/initSwap.js +3 -4
- package/lib/exchange/swap/initSwap.js.map +1 -1
- package/lib/exchange/swap/types.d.ts +0 -12
- package/lib/exchange/swap/types.d.ts.map +1 -1
- package/lib/exchange/swap/utils/index.d.ts +6 -1
- package/lib/exchange/swap/utils/index.d.ts.map +1 -1
- package/lib/exchange/swap/utils/index.js +8 -1
- package/lib/exchange/swap/utils/index.js.map +1 -1
- package/lib/exchange/swap/utils/index.test.js +27 -0
- package/lib/exchange/swap/utils/index.test.js.map +1 -1
- package/lib/exchange/testCurrencyConfig/data/coins.d.ts +8 -0
- package/lib/exchange/testCurrencyConfig/data/coins.d.ts.map +1 -0
- package/lib/exchange/testCurrencyConfig/data/coins.js +21 -0
- package/lib/exchange/testCurrencyConfig/data/coins.js.map +1 -0
- package/lib/exchange/testCurrencyConfig/index.d.ts +8 -0
- package/lib/exchange/testCurrencyConfig/index.d.ts.map +1 -0
- package/lib/exchange/testCurrencyConfig/index.js +68 -0
- package/lib/exchange/testCurrencyConfig/index.js.map +1 -0
- package/lib/families/algorand/api/algodv2.d.ts +2 -1
- package/lib/families/algorand/api/algodv2.d.ts.map +1 -1
- package/lib/families/algorand/api/algodv2.js +2 -2
- package/lib/families/algorand/api/algodv2.js.map +1 -1
- package/lib/families/algorand/js-broadcast.js +1 -1
- package/lib/families/algorand/js-broadcast.js.map +1 -1
- package/lib/families/algorand/js-signOperation.d.ts.map +1 -1
- package/lib/families/algorand/js-signOperation.js +1 -1
- package/lib/families/algorand/js-signOperation.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/wallet.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/wallet.js +8 -2
- package/lib/families/bitcoin/wallet-btc/wallet.js.map +1 -1
- package/lib/families/ethereum/datasets/ethereum.scanAccounts.1.js +1 -1
- package/lib/families/ethereum/datasets/ethereum.scanAccounts.1.js.map +1 -1
- package/lib/families/ethereum/nft.integration.test.js +1 -36
- package/lib/families/ethereum/nft.integration.test.js.map +1 -1
- package/lib/families/ethereum/specs.d.ts.map +1 -1
- package/lib/families/ethereum/specs.js +2 -0
- package/lib/families/ethereum/specs.js.map +1 -1
- package/lib/families/ethereum/synchronisation.d.ts.map +1 -1
- package/lib/families/ethereum/synchronisation.js +2 -7
- package/lib/families/ethereum/synchronisation.js.map +1 -1
- package/lib/families/solana/api/chain/index.d.ts +2 -2
- package/lib/families/solana/api/chain/index.d.ts.map +1 -1
- package/lib/families/solana/api/chain/index.js +4 -4
- package/lib/families/solana/api/chain/index.js.map +1 -1
- package/lib/families/solana/bridge/bridge.js +5 -5
- package/lib/families/solana/bridge/bridge.js.map +1 -1
- package/lib/families/solana/bridge/js.js +3 -3
- package/lib/families/solana/bridge/js.js.map +1 -1
- package/lib/families/solana/bridge/mock.js +1 -1
- package/lib/families/solana/bridge/mock.js.map +1 -1
- package/lib/families/solana/utils.d.ts +1 -2
- package/lib/families/solana/utils.d.ts.map +1 -1
- package/lib/families/solana/utils.js +11 -9
- package/lib/families/solana/utils.js.map +1 -1
- package/lib/families/tezos/datasets/tezos.scanAccounts.1.js +1 -1
- package/lib/families/tezos/datasets/tezos.scanAccounts.1.js.map +1 -1
- package/lib/hw/actions/app.d.ts +3 -0
- package/lib/hw/actions/app.d.ts.map +1 -1
- package/lib/hw/actions/app.js +7 -1
- package/lib/hw/actions/app.js.map +1 -1
- package/lib/hw/actions/completeExchange.d.ts +1 -0
- package/lib/hw/actions/completeExchange.d.ts.map +1 -1
- package/lib/hw/actions/completeExchange.js +4 -3
- package/lib/hw/actions/completeExchange.js.map +1 -1
- package/lib/hw/connectApp.d.ts +5 -0
- package/lib/hw/connectApp.d.ts.map +1 -1
- package/lib/hw/connectApp.js +37 -26
- package/lib/hw/connectApp.js.map +1 -1
- package/lib/market/MarketDataProvider.d.ts +26 -0
- package/lib/market/MarketDataProvider.d.ts.map +1 -0
- package/lib/market/MarketDataProvider.js +339 -0
- package/lib/market/MarketDataProvider.js.map +1 -0
- package/lib/market/api/api.d.ts +15 -0
- package/lib/market/api/api.d.ts.map +1 -0
- package/lib/market/api/api.js +261 -0
- package/lib/market/api/api.js.map +1 -0
- package/lib/market/api/api.mock.d.ts +15 -0
- package/lib/market/api/api.mock.d.ts.map +1 -0
- package/lib/market/api/api.mock.js +454 -0
- package/lib/market/api/api.mock.js.map +1 -0
- package/lib/market/types.d.ts +83 -0
- package/lib/market/types.d.ts.map +1 -0
- package/lib/market/types.js +3 -0
- package/lib/market/types.js.map +1 -0
- package/lib/market/utils/countervalueFormatter.d.ts +8 -0
- package/lib/market/utils/countervalueFormatter.d.ts.map +1 -0
- package/lib/market/utils/countervalueFormatter.js +18 -0
- package/lib/market/utils/countervalueFormatter.js.map +1 -0
- package/lib/market/utils/rangeDataTable.d.ts +10 -0
- package/lib/market/utils/rangeDataTable.d.ts.map +1 -0
- package/lib/market/utils/rangeDataTable.js +36 -0
- package/lib/market/utils/rangeDataTable.js.map +1 -0
- package/lib/nft/support.d.ts.map +1 -1
- package/lib/nft/support.js +1 -1
- package/lib/nft/support.js.map +1 -1
- package/lib/platform/PlatformAppProvider/api/api.mock.d.ts.map +1 -1
- package/lib/platform/PlatformAppProvider/api/api.mock.js +27 -0
- package/lib/platform/PlatformAppProvider/api/api.mock.js.map +1 -1
- package/lib/types/manager.d.ts +7 -0
- package/lib/types/manager.d.ts.map +1 -1
- package/lib/types/manager.js +7 -0
- package/lib/types/manager.js.map +1 -1
- package/package.json +17 -17
- package/src/.DS_Store +0 -0
- package/src/__tests__/__snapshots__/all.libcore.ts.snap +221 -212
- package/src/__tests__/currencies.ts +1 -1
- package/src/__tests__/families/bitcoin/wallet-btc/xpub.synced.unit.test.ts +26 -25
- package/src/__tests__/families/bitcoin/wallet-btc/xpub.syncing.integration.test.ts +2 -0
- package/src/__tests__/test-helpers/bridge.ts +1 -1
- package/src/apps/hw.ts +7 -0
- package/src/apps/support.ts +1 -0
- package/src/bridge/jsHelpers.ts +1 -1
- package/src/data/flags/.DS_Store +0 -0
- package/src/data/icons/react/index.tsx +1 -0
- package/src/data/icons/react/sol.tsx +1 -1
- package/src/data/icons/react/tyc.tsx +12 -0
- package/src/data/icons/reactNative/index.tsx +1 -0
- package/src/data/icons/reactNative/sol.tsx +1 -1
- package/src/data/icons/reactNative/tyc.tsx +13 -0
- package/src/data/icons/svg/SOL.svg +8 -1
- package/src/data/icons/svg/TYC.svg +6 -0
- package/src/env.ts +16 -2
- package/src/exchange/hw-app-exchange/Exchange.ts +22 -18
- package/src/exchange/index.ts +19 -1
- package/src/exchange/platform/completeExchange.ts +42 -0
- package/src/exchange/platform/serialization.ts +78 -0
- package/src/exchange/{swap → platform}/startExchange.ts +6 -2
- package/src/exchange/platform/transfer/completeExchange.ts +187 -0
- package/src/exchange/platform/transfer/index.ts +66 -0
- package/src/exchange/platform/types.ts +76 -0
- package/src/exchange/sell/checkSignatureAndPrepare.ts +2 -2
- package/src/exchange/sell/getTransactionId.ts +2 -2
- package/src/exchange/sell/index.ts +1 -1
- package/src/exchange/swap/completeExchange.ts +41 -50
- package/src/exchange/swap/hooks/usePickDefaultAccount.ts +4 -9
- package/src/exchange/swap/initSwap.ts +4 -7
- package/src/exchange/swap/types.ts +1 -14
- package/src/exchange/swap/utils/index.test.ts +44 -1
- package/src/exchange/swap/utils/index.ts +12 -1
- package/src/exchange/testCurrencyConfig/data/coins.ts +20 -0
- package/src/exchange/testCurrencyConfig/index.ts +24 -0
- package/src/families/algorand/api/algodv2.ts +2 -2
- package/src/families/algorand/js-broadcast.ts +1 -1
- package/src/families/algorand/js-signOperation.ts +8 -3
- package/src/families/bitcoin/wallet-btc/wallet.ts +6 -2
- package/src/families/ethereum/datasets/ethereum.scanAccounts.1.ts +43 -43
- package/src/families/ethereum/nft.integration.test.ts +1 -18
- package/src/families/ethereum/specs.ts +2 -0
- package/src/families/ethereum/synchronisation.ts +1 -6
- package/src/families/solana/api/chain/index.ts +8 -7
- package/src/families/solana/bridge/bridge.ts +11 -11
- package/src/families/solana/bridge/js.ts +3 -3
- package/src/families/solana/bridge/mock.ts +1 -1
- package/src/families/solana/utils.ts +9 -8
- package/src/families/tezos/datasets/tezos.scanAccounts.1.ts +39 -39
- package/src/hw/actions/app.ts +17 -1
- package/src/hw/actions/completeExchange.ts +9 -3
- package/src/hw/connectApp.ts +53 -31
- package/src/market/MarketDataProvider.tsx +440 -0
- package/src/market/api/api.mock.ts +374 -0
- package/src/market/api/api.ts +227 -0
- package/src/market/types.ts +92 -0
- package/src/market/utils/countervalueFormatter.ts +24 -0
- package/src/market/utils/rangeDataTable.ts +40 -0
- package/src/nft/support.ts +1 -3
- package/src/platform/PlatformAppProvider/api/api.mock.ts +27 -0
- package/src/types/manager.ts +7 -0
- package/lib/exchange/swap/startExchange.d.ts.map +0 -1
- package/lib/exchange/swap/startExchange.js.map +0 -1
- package/lib/families/ethereum/versions.d.ts +0 -2
- package/lib/families/ethereum/versions.d.ts.map +0 -1
- package/lib/families/ethereum/versions.js +0 -5
- package/lib/families/ethereum/versions.js.map +0 -1
- package/src/families/ethereum/versions.ts +0 -1
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
import { CurrencyData, 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
|
+
// fetches currencies data for selected currencies ids
|
|
18
|
+
async function listPaginated(): Promise<CurrencyData[]> {
|
|
19
|
+
const response = await Promise.resolve([
|
|
20
|
+
{
|
|
21
|
+
id: "bitcoin",
|
|
22
|
+
symbol: "btc",
|
|
23
|
+
name: "Bitcoin",
|
|
24
|
+
image:
|
|
25
|
+
"https://assets.coingecko.com/coins/images/1/large/bitcoin.png?1547033579",
|
|
26
|
+
current_price: 46978,
|
|
27
|
+
market_cap: 888084713113,
|
|
28
|
+
market_cap_rank: 1,
|
|
29
|
+
fully_diluted_valuation: 986540621536,
|
|
30
|
+
total_volume: 27166733732,
|
|
31
|
+
high_24h: 47466,
|
|
32
|
+
low_24h: 45653,
|
|
33
|
+
price_change_24h: -448.517772161074,
|
|
34
|
+
price_change_percentage_24h: -0.94571,
|
|
35
|
+
market_cap_change_24h: -6925208740.524048,
|
|
36
|
+
market_cap_change_percentage_24h: -0.77376,
|
|
37
|
+
circulating_supply: 18904218,
|
|
38
|
+
total_supply: 21000000,
|
|
39
|
+
max_supply: 21000000,
|
|
40
|
+
ath: 69045,
|
|
41
|
+
ath_change_percentage: -32.0311,
|
|
42
|
+
ath_date: "2021-11-10T14:24:11.849Z",
|
|
43
|
+
atl: 67.81,
|
|
44
|
+
atl_change_percentage: 69107.58322,
|
|
45
|
+
atl_date: "2013-07-06T00:00:00.000Z",
|
|
46
|
+
roi: null,
|
|
47
|
+
last_updated: "2021-12-18T16:31:02.628Z",
|
|
48
|
+
price_change_percentage_24h_in_currency: -0.9457084615407927,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: "ethereum",
|
|
52
|
+
symbol: "eth",
|
|
53
|
+
name: "Ethereum",
|
|
54
|
+
image:
|
|
55
|
+
"https://assets.coingecko.com/coins/images/279/large/ethereum.png?1595348880",
|
|
56
|
+
current_price: 3956.23,
|
|
57
|
+
market_cap: 469967313961,
|
|
58
|
+
market_cap_rank: 2,
|
|
59
|
+
fully_diluted_valuation: null,
|
|
60
|
+
total_volume: 22896047898,
|
|
61
|
+
high_24h: 3998.6,
|
|
62
|
+
low_24h: 3790.1,
|
|
63
|
+
price_change_24h: 31.34,
|
|
64
|
+
price_change_percentage_24h: 0.79852,
|
|
65
|
+
market_cap_change_24h: 4376247843,
|
|
66
|
+
market_cap_change_percentage_24h: 0.93993,
|
|
67
|
+
circulating_supply: 118791776.124,
|
|
68
|
+
total_supply: null,
|
|
69
|
+
max_supply: null,
|
|
70
|
+
ath: 4878.26,
|
|
71
|
+
ath_change_percentage: -19.07897,
|
|
72
|
+
ath_date: "2021-11-10T14:24:19.604Z",
|
|
73
|
+
atl: 0.432979,
|
|
74
|
+
atl_change_percentage: 911616.29321,
|
|
75
|
+
atl_date: "2015-10-20T00:00:00.000Z",
|
|
76
|
+
roi: {
|
|
77
|
+
times: 111.85400578727416,
|
|
78
|
+
currency: "btc",
|
|
79
|
+
percentage: 11185.400578727416,
|
|
80
|
+
},
|
|
81
|
+
last_updated: "2021-12-18T16:30:24.123Z",
|
|
82
|
+
price_change_percentage_24h_in_currency: 0.7985206175407733,
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
id: "binancecoin",
|
|
86
|
+
symbol: "bnb",
|
|
87
|
+
name: "Binance Coin",
|
|
88
|
+
image:
|
|
89
|
+
"https://assets.coingecko.com/coins/images/825/large/binance-coin-logo.png?1547034615",
|
|
90
|
+
current_price: 530.99,
|
|
91
|
+
market_cap: 89278760378,
|
|
92
|
+
market_cap_rank: 3,
|
|
93
|
+
fully_diluted_valuation: 89278760378,
|
|
94
|
+
total_volume: 601931681,
|
|
95
|
+
high_24h: 536.2,
|
|
96
|
+
low_24h: 519.35,
|
|
97
|
+
price_change_24h: -1.431695982805,
|
|
98
|
+
price_change_percentage_24h: -0.2689,
|
|
99
|
+
market_cap_change_24h: -217891640.56773376,
|
|
100
|
+
market_cap_change_percentage_24h: -0.24346,
|
|
101
|
+
circulating_supply: 168137035.9,
|
|
102
|
+
total_supply: 168137035.9,
|
|
103
|
+
max_supply: 168137035.9,
|
|
104
|
+
ath: 686.31,
|
|
105
|
+
ath_change_percentage: -22.80102,
|
|
106
|
+
ath_date: "2021-05-10T07:24:17.097Z",
|
|
107
|
+
atl: 0.0398177,
|
|
108
|
+
atl_change_percentage: 1330518.574,
|
|
109
|
+
atl_date: "2017-10-19T00:00:00.000Z",
|
|
110
|
+
roi: null,
|
|
111
|
+
last_updated: "2021-12-18T16:30:40.065Z",
|
|
112
|
+
price_change_percentage_24h_in_currency: -0.26890361163187976,
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
id: "tether",
|
|
116
|
+
symbol: "usdt",
|
|
117
|
+
name: "Tether",
|
|
118
|
+
image:
|
|
119
|
+
"https://assets.coingecko.com/coins/images/325/large/Tether-logo.png?1598003707",
|
|
120
|
+
current_price: 1,
|
|
121
|
+
market_cap: 77439200796,
|
|
122
|
+
market_cap_rank: 4,
|
|
123
|
+
fully_diluted_valuation: null,
|
|
124
|
+
total_volume: 62554588893,
|
|
125
|
+
high_24h: 1.01,
|
|
126
|
+
low_24h: 0.987325,
|
|
127
|
+
price_change_24h: -0.011415856662,
|
|
128
|
+
price_change_percentage_24h: -1.1271,
|
|
129
|
+
market_cap_change_24h: -259872290.71488953,
|
|
130
|
+
market_cap_change_percentage_24h: -0.33446,
|
|
131
|
+
circulating_supply: 77328369536.52,
|
|
132
|
+
total_supply: 77328369536.52,
|
|
133
|
+
max_supply: null,
|
|
134
|
+
ath: 1.32,
|
|
135
|
+
ath_change_percentage: -24.41245,
|
|
136
|
+
ath_date: "2018-07-24T00:00:00.000Z",
|
|
137
|
+
atl: 0.572521,
|
|
138
|
+
atl_change_percentage: 74.68274,
|
|
139
|
+
atl_date: "2015-03-02T00:00:00.000Z",
|
|
140
|
+
roi: null,
|
|
141
|
+
last_updated: "2021-12-18T16:27:59.344Z",
|
|
142
|
+
price_change_percentage_24h_in_currency: -1.1271033891153508,
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
id: "solana",
|
|
146
|
+
symbol: "sol",
|
|
147
|
+
name: "Solana",
|
|
148
|
+
image:
|
|
149
|
+
"https://assets.coingecko.com/coins/images/4128/large/Solana.jpg?1635329178",
|
|
150
|
+
current_price: 182.14,
|
|
151
|
+
market_cap: 55791855479,
|
|
152
|
+
market_cap_rank: 5,
|
|
153
|
+
fully_diluted_valuation: null,
|
|
154
|
+
total_volume: 1864966986,
|
|
155
|
+
high_24h: 182.76,
|
|
156
|
+
low_24h: 171.62,
|
|
157
|
+
price_change_24h: 1.27,
|
|
158
|
+
price_change_percentage_24h: 0.70456,
|
|
159
|
+
market_cap_change_24h: 1062110605,
|
|
160
|
+
market_cap_change_percentage_24h: 1.94065,
|
|
161
|
+
circulating_supply: 307978914.997809,
|
|
162
|
+
total_supply: 508180963.57,
|
|
163
|
+
max_supply: null,
|
|
164
|
+
ath: 259.96,
|
|
165
|
+
ath_change_percentage: -30.21122,
|
|
166
|
+
ath_date: "2021-11-06T21:54:35.825Z",
|
|
167
|
+
atl: 0.500801,
|
|
168
|
+
atl_change_percentage: 36126.43086,
|
|
169
|
+
atl_date: "2020-05-11T19:35:23.449Z",
|
|
170
|
+
roi: null,
|
|
171
|
+
last_updated: "2021-12-18T16:31:38.005Z",
|
|
172
|
+
price_change_percentage_24h_in_currency: 0.704558493197451,
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
id: "usd-coin",
|
|
176
|
+
symbol: "usdc",
|
|
177
|
+
name: "USD Coin",
|
|
178
|
+
image:
|
|
179
|
+
"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:
|
|
209
|
+
"https://assets.coingecko.com/coins/images/975/large/cardano.png?1547034860",
|
|
210
|
+
current_price: 1.25,
|
|
211
|
+
market_cap: 40061737912,
|
|
212
|
+
market_cap_rank: 7,
|
|
213
|
+
fully_diluted_valuation: 56220178462,
|
|
214
|
+
total_volume: 1039172214,
|
|
215
|
+
high_24h: 1.27,
|
|
216
|
+
low_24h: 1.2,
|
|
217
|
+
price_change_24h: -0.00949416665,
|
|
218
|
+
price_change_percentage_24h: -0.7542,
|
|
219
|
+
market_cap_change_24h: -35615245.100372314,
|
|
220
|
+
market_cap_change_percentage_24h: -0.08882,
|
|
221
|
+
circulating_supply: 32066390668.4135,
|
|
222
|
+
total_supply: 45000000000,
|
|
223
|
+
max_supply: 45000000000,
|
|
224
|
+
ath: 3.09,
|
|
225
|
+
ath_change_percentage: -59.59586,
|
|
226
|
+
ath_date: "2021-09-02T06:00:10.474Z",
|
|
227
|
+
atl: 0.01925275,
|
|
228
|
+
atl_change_percentage: 6378.24434,
|
|
229
|
+
atl_date: "2020-03-13T02:22:55.044Z",
|
|
230
|
+
roi: null,
|
|
231
|
+
last_updated: "2021-12-18T16:31:09.050Z",
|
|
232
|
+
price_change_percentage_24h_in_currency: -0.754204745255466,
|
|
233
|
+
},
|
|
234
|
+
]);
|
|
235
|
+
|
|
236
|
+
// @ts-expect-error issue in typing
|
|
237
|
+
return response.map((currency: any) => ({
|
|
238
|
+
id: currency.id,
|
|
239
|
+
name: currency.name,
|
|
240
|
+
image: currency.image,
|
|
241
|
+
internalCurrency: cryptoCurrenciesList.find(
|
|
242
|
+
({ ticker }) => ticker.toLowerCase() === currency.symbol
|
|
243
|
+
),
|
|
244
|
+
marketcap: currency.market_cap,
|
|
245
|
+
marketcapRank: currency.market_cap_rank,
|
|
246
|
+
totalVolume: currency.total_volume,
|
|
247
|
+
high24h: currency.high_24h,
|
|
248
|
+
low24h: currency.low_24h,
|
|
249
|
+
ticker: currency.symbol,
|
|
250
|
+
price: currency.current_price,
|
|
251
|
+
priceChangePercentage: currency.price_change_percentage_24h_in_currency,
|
|
252
|
+
marketCapChangePercentage24h: currency.market_cap_change_percentage_24h,
|
|
253
|
+
circulatingSupply: currency.circulating_supply,
|
|
254
|
+
totalSupply: currency.total_supply,
|
|
255
|
+
maxSupply: currency.max_supply,
|
|
256
|
+
ath: currency.ath,
|
|
257
|
+
athDate: currency.ath_date,
|
|
258
|
+
atl: currency.atl,
|
|
259
|
+
atlDate: currency.atl_date,
|
|
260
|
+
sparklineIn7d: null,
|
|
261
|
+
chartData: [],
|
|
262
|
+
}));
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// Fetches list of supported counterCurrencies
|
|
266
|
+
async function supportedCounterCurrencies(): Promise<string[]> {
|
|
267
|
+
return await Promise.resolve([
|
|
268
|
+
"btc",
|
|
269
|
+
"eth",
|
|
270
|
+
"ltc",
|
|
271
|
+
"bch",
|
|
272
|
+
"bnb",
|
|
273
|
+
"eos",
|
|
274
|
+
"xrp",
|
|
275
|
+
"xlm",
|
|
276
|
+
"link",
|
|
277
|
+
"dot",
|
|
278
|
+
"yfi",
|
|
279
|
+
"usd",
|
|
280
|
+
"aed",
|
|
281
|
+
"ars",
|
|
282
|
+
"aud",
|
|
283
|
+
"bdt",
|
|
284
|
+
"bhd",
|
|
285
|
+
"bmd",
|
|
286
|
+
"brl",
|
|
287
|
+
"cad",
|
|
288
|
+
"chf",
|
|
289
|
+
"clp",
|
|
290
|
+
"cny",
|
|
291
|
+
"czk",
|
|
292
|
+
"dkk",
|
|
293
|
+
"eur",
|
|
294
|
+
"gbp",
|
|
295
|
+
"hkd",
|
|
296
|
+
"huf",
|
|
297
|
+
"idr",
|
|
298
|
+
"ils",
|
|
299
|
+
"inr",
|
|
300
|
+
"jpy",
|
|
301
|
+
"krw",
|
|
302
|
+
"kwd",
|
|
303
|
+
"lkr",
|
|
304
|
+
"mmk",
|
|
305
|
+
"mxn",
|
|
306
|
+
"myr",
|
|
307
|
+
"ngn",
|
|
308
|
+
"nok",
|
|
309
|
+
"nzd",
|
|
310
|
+
"php",
|
|
311
|
+
"pkr",
|
|
312
|
+
"pln",
|
|
313
|
+
"rub",
|
|
314
|
+
"sar",
|
|
315
|
+
"sek",
|
|
316
|
+
"sgd",
|
|
317
|
+
"thb",
|
|
318
|
+
"try",
|
|
319
|
+
"twd",
|
|
320
|
+
"uah",
|
|
321
|
+
"vef",
|
|
322
|
+
"vnd",
|
|
323
|
+
"zar",
|
|
324
|
+
"xdr",
|
|
325
|
+
"xag",
|
|
326
|
+
"xau",
|
|
327
|
+
"bits",
|
|
328
|
+
"sats",
|
|
329
|
+
]);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// Fetches list of supported currencies
|
|
333
|
+
async function currencyChartData(): Promise<{
|
|
334
|
+
[range: string]: number[][];
|
|
335
|
+
}> {
|
|
336
|
+
const response = await Promise.resolve({
|
|
337
|
+
prices: [
|
|
338
|
+
[1639760425566, 47035.7730170554],
|
|
339
|
+
[1639764200520, 46779.28084436036],
|
|
340
|
+
[1639767793752, 46899.81670459505],
|
|
341
|
+
[1639771405996, 46806.89615030911],
|
|
342
|
+
[1639774854719, 46372.35410149477],
|
|
343
|
+
[1639778429112, 47091.66371795489],
|
|
344
|
+
[1639782342710, 46507.965042542106],
|
|
345
|
+
[1639785697940, 46328.6963654447],
|
|
346
|
+
[1639789279103, 46415.52050647275],
|
|
347
|
+
[1639793084532, 45826.54707719198],
|
|
348
|
+
[1639796561743, 45886.69785964224],
|
|
349
|
+
[1639800325023, 46535.85544547407],
|
|
350
|
+
[1639803752264, 46630.66364205827],
|
|
351
|
+
[1639807349369, 46796.65748955589],
|
|
352
|
+
[1639810831681, 46404.12378055947],
|
|
353
|
+
[1639814720824, 46429.86171498202],
|
|
354
|
+
[1639818226026, 46208.467967110075],
|
|
355
|
+
[1639821761024, 46794.55365462657],
|
|
356
|
+
[1639825359138, 47337.122321658026],
|
|
357
|
+
[1639829106656, 47070.8445217621],
|
|
358
|
+
[1639832543681, 47113.48747087277],
|
|
359
|
+
[1639836121826, 46857.76684001326],
|
|
360
|
+
[1639839860258, 47145.895183572036],
|
|
361
|
+
[1639843597758, 46876.27784614691],
|
|
362
|
+
[1639845270000, 47035.775042793095],
|
|
363
|
+
],
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
return { "24h": response.prices };
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
export default {
|
|
370
|
+
setSupportedCoinsList,
|
|
371
|
+
listPaginated,
|
|
372
|
+
supportedCounterCurrencies,
|
|
373
|
+
currencyChartData,
|
|
374
|
+
};
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MarketListRequestParams,
|
|
3
|
+
MarketCurrencyChartDataRequestParams,
|
|
4
|
+
CurrencyData,
|
|
5
|
+
SupportedCoins,
|
|
6
|
+
MarketCoin,
|
|
7
|
+
SparklineSvgData,
|
|
8
|
+
} from "../types";
|
|
9
|
+
import {
|
|
10
|
+
listCryptoCurrencies,
|
|
11
|
+
listTokens,
|
|
12
|
+
listSupportedCurrencies,
|
|
13
|
+
} from "../../currencies";
|
|
14
|
+
import { rangeDataTable } from "../utils/rangeDataTable";
|
|
15
|
+
import { CryptoCurrency } from "@ledgerhq/cryptoassets";
|
|
16
|
+
import { getEnv } from "../../env";
|
|
17
|
+
import network from "../../network";
|
|
18
|
+
|
|
19
|
+
const cryptoCurrenciesList = [...listCryptoCurrencies(), ...listTokens()];
|
|
20
|
+
|
|
21
|
+
const supportedCurrencies = listSupportedCurrencies();
|
|
22
|
+
|
|
23
|
+
const liveCompatibleIds = supportedCurrencies
|
|
24
|
+
.map(({ id }: CryptoCurrency) => id)
|
|
25
|
+
.filter(Boolean);
|
|
26
|
+
|
|
27
|
+
let LIVE_COINS_LIST: string[] = [];
|
|
28
|
+
|
|
29
|
+
const ROOT_PATH = getEnv("MARKET_API_URL");
|
|
30
|
+
|
|
31
|
+
let SUPPORTED_COINS_LIST: SupportedCoins = [];
|
|
32
|
+
|
|
33
|
+
async function setSupportedCoinsList(): Promise<SupportedCoins> {
|
|
34
|
+
const url = `${ROOT_PATH}/coins/list`;
|
|
35
|
+
const { data } = await network({ method: "GET", url });
|
|
36
|
+
|
|
37
|
+
SUPPORTED_COINS_LIST = data;
|
|
38
|
+
|
|
39
|
+
LIVE_COINS_LIST = SUPPORTED_COINS_LIST.filter(({ id }) =>
|
|
40
|
+
liveCompatibleIds.includes(id)
|
|
41
|
+
).map(({ id }) => id);
|
|
42
|
+
|
|
43
|
+
return SUPPORTED_COINS_LIST;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const matchSearch =
|
|
47
|
+
(search: string) =>
|
|
48
|
+
(currency: MarketCoin): boolean => {
|
|
49
|
+
if (!search) return false;
|
|
50
|
+
const match = `${currency.symbol}|${currency.name}`;
|
|
51
|
+
return match.toLowerCase().includes(search.toLowerCase());
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
function distributedCopy(items: number[], n: number): number[] {
|
|
55
|
+
const elements = [items[0]];
|
|
56
|
+
const totalItems = items.length - 2;
|
|
57
|
+
const interval = Math.floor(totalItems / (n - 2));
|
|
58
|
+
for (let i = 1; i < n - 1; i++) {
|
|
59
|
+
elements.push(items[i * interval]);
|
|
60
|
+
}
|
|
61
|
+
elements.push(items[items.length - 1]);
|
|
62
|
+
return elements;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const sparklineXMagnitude = 5;
|
|
66
|
+
const sparklineYHeight = 50;
|
|
67
|
+
|
|
68
|
+
function sparklineAsSvgData(points: number[]): SparklineSvgData {
|
|
69
|
+
const totalXSteps = sparklineXMagnitude * points.length;
|
|
70
|
+
const min = Math.min(...points);
|
|
71
|
+
const max = Math.max(...points);
|
|
72
|
+
|
|
73
|
+
const yOffset = max - min;
|
|
74
|
+
|
|
75
|
+
return {
|
|
76
|
+
path: points
|
|
77
|
+
.map((d, i) => {
|
|
78
|
+
const [x, y] = [
|
|
79
|
+
i * sparklineXMagnitude,
|
|
80
|
+
sparklineYHeight + 3 - ((d - min) * sparklineYHeight) / yOffset,
|
|
81
|
+
];
|
|
82
|
+
return i === 0 ? `M ${x} ${y}` : `L ${x} ${y}`;
|
|
83
|
+
})
|
|
84
|
+
.join(" "),
|
|
85
|
+
viewBox: `0 0 ${totalXSteps} ${sparklineYHeight + 3}`,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// fetches currencies data for selected currencies ids
|
|
90
|
+
async function listPaginated({
|
|
91
|
+
counterCurrency,
|
|
92
|
+
range = "24h",
|
|
93
|
+
limit = 50,
|
|
94
|
+
page = 1,
|
|
95
|
+
ids: _ids = [],
|
|
96
|
+
starred = [],
|
|
97
|
+
orderBy = "market_cap",
|
|
98
|
+
order = "desc",
|
|
99
|
+
search = "",
|
|
100
|
+
sparkline = true,
|
|
101
|
+
liveCompatible = false,
|
|
102
|
+
}: MarketListRequestParams): Promise<CurrencyData[]> {
|
|
103
|
+
let ids = _ids;
|
|
104
|
+
|
|
105
|
+
if (liveCompatible) {
|
|
106
|
+
ids = ids.concat(LIVE_COINS_LIST);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (starred.length > 0) {
|
|
110
|
+
ids = ids.concat(starred);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (search) {
|
|
114
|
+
ids = SUPPORTED_COINS_LIST.filter(matchSearch(search)).map(({ id }) => id);
|
|
115
|
+
if (!ids.length) {
|
|
116
|
+
return [];
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
ids = ids.slice((page - 1) * limit, limit * page);
|
|
121
|
+
|
|
122
|
+
const url =
|
|
123
|
+
`${ROOT_PATH}/coins/markets?vs_currency=${counterCurrency}&order=${orderBy}_${order}&per_page=${limit}` +
|
|
124
|
+
`&sparkline=${
|
|
125
|
+
sparkline ? "true" : "false"
|
|
126
|
+
}&price_change_percentage=${range}` +
|
|
127
|
+
`${ids.length > 0 ? `&page=1&&ids=${ids.toString()}` : `&page=${page}`}`;
|
|
128
|
+
|
|
129
|
+
const { data } = await network({
|
|
130
|
+
method: "GET",
|
|
131
|
+
url,
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
return data.map(
|
|
135
|
+
(currency: {
|
|
136
|
+
[x: string]: any;
|
|
137
|
+
id: string;
|
|
138
|
+
name: any;
|
|
139
|
+
image: any;
|
|
140
|
+
["market_cap"]: any;
|
|
141
|
+
["market_cap_rank"]: any;
|
|
142
|
+
["total_volume"]: any;
|
|
143
|
+
["high_24h"]: any;
|
|
144
|
+
["low_24h"]: any;
|
|
145
|
+
symbol: any;
|
|
146
|
+
["current_price"]: any;
|
|
147
|
+
["market_cap_change_percentage_24h"]: any;
|
|
148
|
+
["circulating_supply"]: any;
|
|
149
|
+
["total_supply"]: any;
|
|
150
|
+
["max_supply"]: any;
|
|
151
|
+
ath: any;
|
|
152
|
+
["ath_date"]: any;
|
|
153
|
+
atl: any;
|
|
154
|
+
["atl_date"]: any;
|
|
155
|
+
["sparkline_in_7d"]: { price: any };
|
|
156
|
+
}) => ({
|
|
157
|
+
id: currency.id,
|
|
158
|
+
name: currency.name,
|
|
159
|
+
image: currency.image,
|
|
160
|
+
isLiveSupported: LIVE_COINS_LIST.includes(currency.id),
|
|
161
|
+
internalCurrency: cryptoCurrenciesList.find(
|
|
162
|
+
({ ticker }) => ticker.toLowerCase() === currency.symbol
|
|
163
|
+
),
|
|
164
|
+
marketcap: currency.market_cap,
|
|
165
|
+
marketcapRank: currency.market_cap_rank,
|
|
166
|
+
totalVolume: currency.total_volume,
|
|
167
|
+
high24h: currency.high_24h,
|
|
168
|
+
low24h: currency.low_24h,
|
|
169
|
+
ticker: currency.symbol,
|
|
170
|
+
price: currency.current_price,
|
|
171
|
+
priceChangePercentage:
|
|
172
|
+
currency[`price_change_percentage_${range}_in_currency`],
|
|
173
|
+
marketCapChangePercentage24h: currency.market_cap_change_percentage_24h,
|
|
174
|
+
circulatingSupply: currency.circulating_supply,
|
|
175
|
+
totalSupply: currency.total_supply,
|
|
176
|
+
maxSupply: currency.max_supply,
|
|
177
|
+
ath: currency.ath,
|
|
178
|
+
athDate: currency.ath_date,
|
|
179
|
+
atl: currency.atl,
|
|
180
|
+
atlDate: currency.atl_date,
|
|
181
|
+
sparklineIn7d: currency?.sparkline_in_7d?.price
|
|
182
|
+
? sparklineAsSvgData(
|
|
183
|
+
distributedCopy(currency.sparkline_in_7d.price, 6 * 7)
|
|
184
|
+
) // keep 6 points per day
|
|
185
|
+
: null,
|
|
186
|
+
chartData: [],
|
|
187
|
+
})
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// Fetches list of supported counterCurrencies
|
|
192
|
+
async function supportedCounterCurrencies(): Promise<string[]> {
|
|
193
|
+
const url = `${ROOT_PATH}/simple/supported_vs_currencies`;
|
|
194
|
+
|
|
195
|
+
const { data } = await network({
|
|
196
|
+
method: "GET",
|
|
197
|
+
url,
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
return data;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// Fetches list of supported currencies
|
|
204
|
+
async function currencyChartData({
|
|
205
|
+
id,
|
|
206
|
+
counterCurrency,
|
|
207
|
+
range = "24h",
|
|
208
|
+
}: MarketCurrencyChartDataRequestParams): Promise<{
|
|
209
|
+
[range: string]: number[];
|
|
210
|
+
}> {
|
|
211
|
+
const { days, interval } = rangeDataTable[range];
|
|
212
|
+
const url = `${ROOT_PATH}/coins/${id}/market_chart?vs_currency=${counterCurrency}&days=${days}&interval=${interval}`;
|
|
213
|
+
|
|
214
|
+
const { data } = await network({
|
|
215
|
+
method: "GET",
|
|
216
|
+
url,
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
return { [range]: data.prices };
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export default {
|
|
223
|
+
setSupportedCoinsList,
|
|
224
|
+
listPaginated,
|
|
225
|
+
supportedCounterCurrencies,
|
|
226
|
+
currencyChartData,
|
|
227
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import { CryptoCurrency } from "../types";
|
|
3
|
+
|
|
4
|
+
export type MarketCoin = {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
symbol: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type SupportedCoins = MarketCoin[];
|
|
11
|
+
|
|
12
|
+
export type MarketListRequestParams = {
|
|
13
|
+
counterCurrency?: string;
|
|
14
|
+
ids?: string[];
|
|
15
|
+
starred?: string[];
|
|
16
|
+
page?: number;
|
|
17
|
+
limit?: number;
|
|
18
|
+
range?: string;
|
|
19
|
+
orderBy?: string;
|
|
20
|
+
order?: string;
|
|
21
|
+
search?: string;
|
|
22
|
+
lastRequestTime?: Date;
|
|
23
|
+
sparkline?: boolean;
|
|
24
|
+
liveCompatible?: boolean;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type MarketCurrencyChartDataRequestParams = {
|
|
28
|
+
id?: string;
|
|
29
|
+
counterCurrency?: string;
|
|
30
|
+
range?: string;
|
|
31
|
+
lastRequestTime?: Date;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export type SparklineSvgData = {
|
|
35
|
+
path: string;
|
|
36
|
+
viewBox: string;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export type CurrencyData = {
|
|
40
|
+
id: string;
|
|
41
|
+
name: string;
|
|
42
|
+
image?: string;
|
|
43
|
+
isLiveSupported?: boolean;
|
|
44
|
+
internalCurrency?: CryptoCurrency;
|
|
45
|
+
marketcap?: number;
|
|
46
|
+
marketcapRank: number;
|
|
47
|
+
totalVolume: number;
|
|
48
|
+
high24h: number;
|
|
49
|
+
low24h: number;
|
|
50
|
+
ticker: string;
|
|
51
|
+
price: number;
|
|
52
|
+
priceChangePercentage: number;
|
|
53
|
+
marketCapChangePercentage24h: number;
|
|
54
|
+
circulatingSupply: number;
|
|
55
|
+
totalSupply: number;
|
|
56
|
+
maxSupply: number;
|
|
57
|
+
ath: number;
|
|
58
|
+
athDate: Date;
|
|
59
|
+
atl: number;
|
|
60
|
+
atlDate: Date;
|
|
61
|
+
sparklineIn7d: SparklineSvgData;
|
|
62
|
+
chartData: Record<string, number[]>;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export type SingleCoinState = {
|
|
66
|
+
selectedCurrency?: string;
|
|
67
|
+
chartRequestParams: MarketCurrencyChartDataRequestParams;
|
|
68
|
+
loading: boolean;
|
|
69
|
+
loadingChart: boolean;
|
|
70
|
+
error?: Error;
|
|
71
|
+
supportedCounterCurrencies: string[];
|
|
72
|
+
selectedCoinData?: CurrencyData;
|
|
73
|
+
counterCurrency?: string;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export type State = SingleCoinState & {
|
|
77
|
+
ready: boolean;
|
|
78
|
+
marketData?: CurrencyData[];
|
|
79
|
+
requestParams: MarketListRequestParams;
|
|
80
|
+
page: number;
|
|
81
|
+
endOfList: boolean;
|
|
82
|
+
totalCoinsAvailable: number;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export type MarketDataApi = {
|
|
86
|
+
setSupportedCoinsList: () => Promise<SupportedCoins>;
|
|
87
|
+
listPaginated: (params: MarketListRequestParams) => Promise<CurrencyData[]>;
|
|
88
|
+
supportedCounterCurrencies: () => Promise<string[]>;
|
|
89
|
+
currencyChartData: (
|
|
90
|
+
params: MarketCurrencyChartDataRequestParams
|
|
91
|
+
) => Promise<{ [range: string]: number[] }>;
|
|
92
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const counterValueFormatter = ({
|
|
2
|
+
currency,
|
|
3
|
+
value,
|
|
4
|
+
shorten,
|
|
5
|
+
locale,
|
|
6
|
+
}: {
|
|
7
|
+
currency?: string;
|
|
8
|
+
value: number;
|
|
9
|
+
shorten?: boolean;
|
|
10
|
+
locale: string;
|
|
11
|
+
}): string => {
|
|
12
|
+
if (!value) {
|
|
13
|
+
return "-";
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return new Intl.NumberFormat(locale, {
|
|
17
|
+
style: currency ? "currency" : "decimal",
|
|
18
|
+
currency,
|
|
19
|
+
notation: shorten ? "compact" : "standard",
|
|
20
|
+
maximumFractionDigits: shorten ? 3 : 8,
|
|
21
|
+
}).format(value);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export default counterValueFormatter;
|