@ensofinance/checkout-widget 0.0.5 → 0.0.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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ensofinance/checkout-widget",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"homepage": "https://www.enso.build/",
|
|
6
6
|
"repository": {
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
"publish": "npm publish --access public",
|
|
23
23
|
"dev": "vite build --watch --mode=dev --minify=false --sourcemap=false --emptyOutDir=false",
|
|
24
24
|
"build": "vite build",
|
|
25
|
-
"preview": "vite preview"
|
|
25
|
+
"preview": "vite preview",
|
|
26
|
+
"build:pump:publish": "npm run build && npm run bump && npm run publish"
|
|
26
27
|
},
|
|
27
28
|
"dependencies": {
|
|
28
29
|
"@chakra-ui/react": "^3.19.1",
|
|
@@ -9,7 +9,12 @@ import { Button, IconButton, Tab, Input } from "../ui";
|
|
|
9
9
|
import CurrencySwapDisplay from "../CurrencySwapDisplay";
|
|
10
10
|
import { useEnsoPrice, useEnsoToken } from "@/enso-api/api";
|
|
11
11
|
import { useAppStore } from "@/store";
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
normalizeValue,
|
|
14
|
+
denormalizeValue,
|
|
15
|
+
formatNumber,
|
|
16
|
+
formatUSD,
|
|
17
|
+
} from "@/util";
|
|
13
18
|
import { useTokenBalance } from "@/util/wallet";
|
|
14
19
|
|
|
15
20
|
type InputMode = "usd" | "token";
|
|
@@ -81,10 +86,11 @@ const WalletAmountStep = ({ nextStep }: { nextStep?: string }) => {
|
|
|
81
86
|
if (inputMode === "usd") {
|
|
82
87
|
const cleanUsd = value.replace("$", "");
|
|
83
88
|
// Clean the input from usd sign
|
|
89
|
+
console.log(cleanUsd, priceData, tokenDetails?.decimals);
|
|
84
90
|
setUsdValue(cleanUsd);
|
|
85
91
|
setAmountIn(
|
|
86
92
|
denormalizeValue(
|
|
87
|
-
(parseFloat(cleanUsd)
|
|
93
|
+
(parseFloat(cleanUsd) / priceData).toString(),
|
|
88
94
|
tokenDetails?.decimals,
|
|
89
95
|
),
|
|
90
96
|
);
|
|
@@ -101,21 +107,24 @@ const WalletAmountStep = ({ nextStep }: { nextStep?: string }) => {
|
|
|
101
107
|
|
|
102
108
|
// Get input placeholder and display value
|
|
103
109
|
const getInputDisplay = () => {
|
|
110
|
+
const formattedValue = formatNumber(tokenValue);
|
|
111
|
+
const safeUsdValue = parseFloat(usdValue) > 0 ? usdValue : 0;
|
|
112
|
+
|
|
104
113
|
if (inputMode === "usd") {
|
|
105
114
|
return {
|
|
106
115
|
placeholder: "$10.00",
|
|
107
|
-
displayValue:
|
|
116
|
+
displayValue: safeUsdValue ? `$${safeUsdValue}` : "",
|
|
108
117
|
equivalentValue: tokenValue
|
|
109
|
-
? `${
|
|
118
|
+
? `${formattedValue} ${tokenDetails?.symbol}`
|
|
110
119
|
: "—",
|
|
111
120
|
};
|
|
112
|
-
} else {
|
|
113
|
-
return {
|
|
114
|
-
placeholder: "0.00",
|
|
115
|
-
displayValue: tokenValue,
|
|
116
|
-
equivalentValue: usdValue ? `$${usdValue}` : "—",
|
|
117
|
-
};
|
|
118
121
|
}
|
|
122
|
+
|
|
123
|
+
return {
|
|
124
|
+
placeholder: "0.00",
|
|
125
|
+
displayValue: formattedValue,
|
|
126
|
+
equivalentValue: formatUSD(safeUsdValue),
|
|
127
|
+
};
|
|
119
128
|
};
|
|
120
129
|
|
|
121
130
|
const { placeholder, displayValue, equivalentValue } = getInputDisplay();
|