@ensofinance/checkout-widget 0.0.9 → 0.0.11
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/checkout-widget.es.js +2223 -2225
- package/dist/checkout-widget.es.js.map +1 -1
- package/dist/checkout-widget.umd.js +12 -12
- package/dist/checkout-widget.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Checkout.tsx +1 -0
- package/src/components/steps/QuoteStep.tsx +3 -2
- package/src/util/common.tsx +24 -5
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@ import { Button, IconButton, Input } from "../ui";
|
|
|
8
8
|
import { HeaderWrapper, HeaderTitle, BodyWrapper } from "../ui/styled";
|
|
9
9
|
import { TransactionDetailRow } from "../TransactionDetailRow";
|
|
10
10
|
import { useAppDetails, useRouteData } from "@/util/enso-hooks";
|
|
11
|
-
import {
|
|
11
|
+
import { useChainName } from "@/util/common";
|
|
12
12
|
import QuoteParameters from "../QuoteParameters";
|
|
13
13
|
|
|
14
14
|
const QuoteStep = () => {
|
|
@@ -19,6 +19,7 @@ const QuoteStep = () => {
|
|
|
19
19
|
const { routeLoading, usdAmountIn, routeData } = useRouteData();
|
|
20
20
|
const walletChainId = useChainId();
|
|
21
21
|
const { switchChain } = useSwitchChain();
|
|
22
|
+
const chainName = useChainName(chainIdIn);
|
|
22
23
|
|
|
23
24
|
const wrongChain = walletChainId !== chainIdIn;
|
|
24
25
|
|
|
@@ -95,7 +96,7 @@ const QuoteStep = () => {
|
|
|
95
96
|
switchChain({ chainId: chainIdIn });
|
|
96
97
|
}}
|
|
97
98
|
>
|
|
98
|
-
Switch to {
|
|
99
|
+
Switch to {chainName}
|
|
99
100
|
</Button>
|
|
100
101
|
) : (
|
|
101
102
|
<Button
|
package/src/util/common.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useQuery } from "@tanstack/react-query";
|
|
2
|
-
import { useAccount } from "wagmi";
|
|
2
|
+
import { useAccount, useConfig } from "wagmi";
|
|
3
3
|
import { type Address, zeroAddress } from "viem";
|
|
4
4
|
import {
|
|
5
5
|
CHAINS_ETHERSCAN,
|
|
@@ -253,8 +253,19 @@ export const useTokenFromList = (
|
|
|
253
253
|
);
|
|
254
254
|
};
|
|
255
255
|
|
|
256
|
-
const
|
|
257
|
-
|
|
256
|
+
const getAlternativeMeshSymbol = (
|
|
257
|
+
symbol: string,
|
|
258
|
+
chainId: SupportedChainId,
|
|
259
|
+
) => {
|
|
260
|
+
if (symbol === "USDT") {
|
|
261
|
+
if (chainId === SupportedChainId.BSC) {
|
|
262
|
+
return "BSC-USD";
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
return "USDT0";
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
return symbol;
|
|
258
269
|
};
|
|
259
270
|
|
|
260
271
|
export const useTokenFromListBySymbols = (
|
|
@@ -266,9 +277,11 @@ export const useTokenFromListBySymbols = (
|
|
|
266
277
|
? tokenSymbols
|
|
267
278
|
: [tokenSymbols];
|
|
268
279
|
|
|
269
|
-
return arrayData.map((
|
|
280
|
+
return arrayData.map((meshSymbol) =>
|
|
270
281
|
data?.find(
|
|
271
|
-
(token) =>
|
|
282
|
+
(token) =>
|
|
283
|
+
token.symbol ==
|
|
284
|
+
getAlternativeMeshSymbol(meshSymbol, priorityChainId),
|
|
272
285
|
),
|
|
273
286
|
);
|
|
274
287
|
};
|
|
@@ -305,6 +318,12 @@ export const getChainName = (chainId: SupportedChainId) => {
|
|
|
305
318
|
return capitalize(geckoName).split("-")[0];
|
|
306
319
|
};
|
|
307
320
|
|
|
321
|
+
export const useChainName = (chainId: number) => {
|
|
322
|
+
const config = useConfig();
|
|
323
|
+
const chain = config.chains.find((c) => c.id === chainId);
|
|
324
|
+
return chain?.name || getChainName(chainId as SupportedChainId);
|
|
325
|
+
};
|
|
326
|
+
|
|
308
327
|
export const shortenAddress = (address: string) => {
|
|
309
328
|
return `${address.slice(0, 4)}...${address.slice(-4)}`;
|
|
310
329
|
};
|