@ensofinance/checkout-widget 0.0.9 → 0.0.10
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
|
@@ -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,
|
|
@@ -305,6 +305,13 @@ export const getChainName = (chainId: SupportedChainId) => {
|
|
|
305
305
|
return capitalize(geckoName).split("-")[0];
|
|
306
306
|
};
|
|
307
307
|
|
|
308
|
+
// Hook to get chain name from wagmi config
|
|
309
|
+
export const useChainName = (chainId: number) => {
|
|
310
|
+
const config = useConfig();
|
|
311
|
+
const chain = config.chains.find((c) => c.id === chainId);
|
|
312
|
+
return chain?.name || getChainName(chainId as SupportedChainId);
|
|
313
|
+
};
|
|
314
|
+
|
|
308
315
|
export const shortenAddress = (address: string) => {
|
|
309
316
|
return `${address.slice(0, 4)}...${address.slice(-4)}`;
|
|
310
317
|
};
|