@stokr/components-library 3.0.53 → 3.0.54
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/dist/index.js +3 -1
- package/dist/utils/formatCurrencyValue.js +35 -25
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -130,7 +130,7 @@ import { generateCoreChecklistTasks, getVerifyIdentityChecklist } from "./utils/
|
|
|
130
130
|
import { CopyToClipBoardTooltip, copyTextToClipboard, useCopyToClipboard, withCopyToClipboard } from "./utils/copyToClipboard.js";
|
|
131
131
|
import { cooldownHOC, useComponentVisible, useContainerSize, useCooldown, useMobileView, usePrevious } from "./utils/customHooks.js";
|
|
132
132
|
import { fixDecimals } from "./utils/fix-decimals.js";
|
|
133
|
-
import { formatCurrencyValue, getCurrencyIcon, getCurrencySymbol, getLiquidAssetIcon, getProjectCurrencySign } from "./utils/formatCurrencyValue.js";
|
|
133
|
+
import { CURRENCY_CONFIG, formatCurrencyValue, getCurrencyConfig, getCurrencyIcon, getCurrencySymbol, getLiquidAssetIcon, getProjectCurrencySign } from "./utils/formatCurrencyValue.js";
|
|
134
134
|
import { isUSInvestor, usCountries } from "./utils/isUSInvestor.js";
|
|
135
135
|
import { km_ify } from "./utils/km_ify.js";
|
|
136
136
|
import { momentUtils } from "./utils/moment.js";
|
|
@@ -276,6 +276,7 @@ export {
|
|
|
276
276
|
ButtonGridContainer,
|
|
277
277
|
CAPITAL_ANIMATION_LENGTH,
|
|
278
278
|
COLUMN,
|
|
279
|
+
CURRENCY_CONFIG,
|
|
279
280
|
default10 as CameraSvg,
|
|
280
281
|
default11 as CapsLockSvg,
|
|
281
282
|
CaptialRaisedSummary,
|
|
@@ -613,6 +614,7 @@ export {
|
|
|
613
614
|
getAnalyticsIngestUrl,
|
|
614
615
|
getBackofficeAppUrl,
|
|
615
616
|
getConfig,
|
|
617
|
+
getCurrencyConfig,
|
|
616
618
|
getCurrencyIcon,
|
|
617
619
|
getCurrencySymbol,
|
|
618
620
|
getFooterGroups,
|
|
@@ -4,32 +4,40 @@ import BitcoinLogo from "../static/images/currency/bitcoin-logo.png.js";
|
|
|
4
4
|
import BMN2Logo from "../static/images/currency/bmn2-logo.png.js";
|
|
5
5
|
import ETHLogo from "../static/images/currency/eth_logo.svg.js";
|
|
6
6
|
import USDTLogo from "../static/images/currency/usdt-logo.png.js";
|
|
7
|
+
const CURRENCY_CONFIG = {
|
|
8
|
+
tether: ["USDT", 2],
|
|
9
|
+
gemini: ["GUSD", 2],
|
|
10
|
+
ether: ["ETH", 4],
|
|
11
|
+
artid: ["ARTID", 2],
|
|
12
|
+
bitcoin: ["BTC", 8],
|
|
13
|
+
lbtc: ["LBTC", 8],
|
|
14
|
+
"lusdt-bfx": ["USDT", 2],
|
|
15
|
+
"lbtc-bfx": ["LBTC", 8],
|
|
16
|
+
"btc-bfx": ["BTC", 8],
|
|
17
|
+
euro: ["EUR", 2],
|
|
18
|
+
usd: ["USD", 2],
|
|
19
|
+
chf: ["CHF", 2],
|
|
20
|
+
lusdt: ["USDT", 2],
|
|
21
|
+
"bitcoin-private": ["EUR", 2],
|
|
22
|
+
"lbtc-private": ["BTC", 8],
|
|
23
|
+
bmn1: ["BMN1", 2],
|
|
24
|
+
bmn2: ["BMN2", 4],
|
|
25
|
+
"btc-fb": ["BTC", 8],
|
|
26
|
+
"usdc-fb": ["USDC", 2],
|
|
27
|
+
"usdq-fb": ["USDQ", 2],
|
|
28
|
+
xaut: ["XAUt", 6],
|
|
29
|
+
"usd-in-kind": ["USD", 2]
|
|
30
|
+
};
|
|
31
|
+
const getCurrencyConfig = (currency, tokenDecimals = 2) => {
|
|
32
|
+
const [symbol, decimals] = CURRENCY_CONFIG[currency] || [currency, tokenDecimals];
|
|
33
|
+
return { symbol, decimals };
|
|
34
|
+
};
|
|
7
35
|
const formatCurrencyValue = (currency, value, tokenDecimals = 2, options = {}) => {
|
|
8
|
-
const { valueFirst = false } = options;
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
artid: ["ARTID", 2],
|
|
14
|
-
bitcoin: ["BTC", 8],
|
|
15
|
-
lbtc: ["LBTC", 8],
|
|
16
|
-
"lusdt-bfx": ["USDT", 2],
|
|
17
|
-
"lbtc-bfx": ["LBTC", 8],
|
|
18
|
-
"btc-bfx": ["BTC", 8],
|
|
19
|
-
euro: ["EUR", 2],
|
|
20
|
-
usd: ["USD", 2],
|
|
21
|
-
chf: ["CHF", 2],
|
|
22
|
-
lusdt: ["USDT", 2],
|
|
23
|
-
"bitcoin-private": ["EUR", 2],
|
|
24
|
-
"lbtc-private": ["BTC", 8],
|
|
25
|
-
bmn1: ["BMN1", 2],
|
|
26
|
-
bmn2: ["BMN2", 4],
|
|
27
|
-
"btc-fb": ["BTC", 8],
|
|
28
|
-
"usdc-fb": ["USDC", 2],
|
|
29
|
-
"usdq-fb": ["USDQ", 2],
|
|
30
|
-
xaut: ["XAUt", 6],
|
|
31
|
-
"usd-in-kind": ["USD", 2]
|
|
32
|
-
}[currency] || [currency, tokenDecimals];
|
|
36
|
+
const { valueFirst = false, formatter } = options;
|
|
37
|
+
const { symbol, decimals } = getCurrencyConfig(currency, tokenDecimals);
|
|
38
|
+
if (typeof formatter === "function") {
|
|
39
|
+
return formatter({ symbol, decimals, value, valueFirst, currency });
|
|
40
|
+
}
|
|
33
41
|
const formattedValue = parseFloat(Math.abs(value)).toFixed(decimals);
|
|
34
42
|
return valueFirst ? `${formattedValue} ${symbol}` : `${symbol} ${formattedValue}`;
|
|
35
43
|
};
|
|
@@ -93,7 +101,9 @@ const getLiquidAssetIcon = async (assetId) => {
|
|
|
93
101
|
});
|
|
94
102
|
};
|
|
95
103
|
export {
|
|
104
|
+
CURRENCY_CONFIG,
|
|
96
105
|
formatCurrencyValue,
|
|
106
|
+
getCurrencyConfig,
|
|
97
107
|
getCurrencyIcon,
|
|
98
108
|
getCurrencySymbol,
|
|
99
109
|
getLiquidAssetIcon,
|