@openfort/react 1.3.0 → 1.5.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/build/components/Common/Modal/styles.js +3 -0
- package/build/components/Common/Modal/styles.js.map +1 -1
- package/build/components/Common/ScrollArea/index.d.ts +5 -1
- package/build/components/Common/ScrollArea/index.js +2 -2
- package/build/components/Common/ScrollArea/styles.d.ts +4 -1
- package/build/components/Common/ScrollArea/styles.js +19 -4
- package/build/components/Common/ScrollArea/styles.js.map +1 -1
- package/build/components/ConnectModal/index.js +15 -5
- package/build/components/ConnectModal/index.js.map +1 -1
- package/build/components/PageContent/index.d.ts +2 -1
- package/build/components/PageContent/index.js +2 -2
- package/build/components/Pages/BuyProviderSelect/styles.d.ts +2 -1
- package/build/components/Pages/Connected/EthereumConnected.js +7 -3
- package/build/components/Pages/Connected/EthereumConnected.js.map +1 -1
- package/build/components/Pages/Deposit/AssetChainLogo.d.ts +5 -2
- package/build/components/Pages/Deposit/AssetChainLogo.js +21 -4
- package/build/components/Pages/Deposit/AssetChainLogo.js.map +1 -1
- package/build/components/Pages/Deposit/DepositAddressBlock.js +1 -1
- package/build/components/Pages/Deposit/RouteSelectors.js +11 -1
- package/build/components/Pages/Deposit/RouteSelectors.js.map +1 -1
- package/build/components/Pages/Deposit/SameChainDepositStatus.d.ts +7 -0
- package/build/components/Pages/Deposit/SameChainDepositStatus.js +34 -0
- package/build/components/Pages/Deposit/SameChainDepositStatus.js.map +1 -0
- package/build/components/Pages/Deposit/SameChainDepositSuccess.d.ts +11 -0
- package/build/components/Pages/Deposit/SameChainDepositSuccess.js +30 -0
- package/build/components/Pages/Deposit/SameChainDepositSuccess.js.map +1 -0
- package/build/components/Pages/Deposit/TestnetNotice.d.ts +10 -0
- package/build/components/Pages/Deposit/TestnetNotice.js +131 -0
- package/build/components/Pages/Deposit/TestnetNotice.js.map +1 -0
- package/build/components/Pages/Deposit/UnsupportedNetworkNotice.d.ts +12 -0
- package/build/components/Pages/Deposit/UnsupportedNetworkNotice.js +111 -0
- package/build/components/Pages/Deposit/UnsupportedNetworkNotice.js.map +1 -0
- package/build/components/Pages/Deposit/index.js +20 -4
- package/build/components/Pages/Deposit/index.js.map +1 -1
- package/build/components/Pages/Deposit/paymentOptions.d.ts +6 -0
- package/build/components/Pages/Deposit/paymentOptions.js +7 -1
- package/build/components/Pages/Deposit/paymentOptions.js.map +1 -1
- package/build/components/Pages/Deposit/useDepositRoute.d.ts +2 -0
- package/build/components/Pages/Deposit/useDepositRoute.js +26 -2
- package/build/components/Pages/Deposit/useDepositRoute.js.map +1 -1
- package/build/components/Pages/Deposit/useSameChainArrival.d.ts +19 -0
- package/build/components/Pages/Deposit/useSameChainArrival.js +86 -0
- package/build/components/Pages/Deposit/useSameChainArrival.js.map +1 -0
- package/build/components/Pages/DepositCrypto/index.js +26 -3
- package/build/components/Pages/DepositCrypto/index.js.map +1 -1
- package/build/components/Pages/DepositWallet/DepositWalletDesktop.js +9 -8
- package/build/components/Pages/DepositWallet/DepositWalletDesktop.js.map +1 -1
- package/build/components/Pages/DepositWallet/index.js +48 -10
- package/build/components/Pages/DepositWallet/index.js.map +1 -1
- package/build/components/Pages/SelectToken/styles.d.ts +2 -1
- package/build/components/Pages/SendConfirmation/index.js +1 -1
- package/build/constants/chainConfigs.js +32 -32
- package/build/constants/logos.d.ts +4 -0
- package/build/constants/logos.js +25 -1
- package/build/constants/logos.js.map +1 -1
- package/build/ethereum/hooks/useEthereumWalletAssets.js +39 -3
- package/build/ethereum/hooks/useEthereumWalletAssets.js.map +1 -1
- package/build/hooks/openfort/useFundingChains.d.ts +6 -0
- package/build/hooks/openfort/useFundingChains.js +19 -5
- package/build/hooks/openfort/useFundingChains.js.map +1 -1
- package/build/hooks/openfort/useUI.d.ts +13 -1
- package/build/hooks/openfort/useUI.js +19 -1
- package/build/hooks/openfort/useUI.js.map +1 -1
- package/build/shared/utils/explorer.js +6 -4
- package/build/shared/utils/explorer.js.map +1 -1
- package/build/utils/validation.d.ts +9 -0
- package/build/utils/validation.js +14 -1
- package/build/utils/validation.js.map +1 -1
- package/build/version.d.ts +1 -1
- package/build/version.js +1 -1
- package/build/wagmi/components/ChainSelect/index.js +3 -2
- package/build/wagmi/components/ChainSelect/index.js.map +1 -1
- package/build/wagmi/components/ChainSelectList/index.js +3 -2
- package/build/wagmi/components/ChainSelectList/index.js.map +1 -1
- package/build/wagmi/components/SwitchNetworks/index.js +3 -2
- package/build/wagmi/components/SwitchNetworks/index.js.map +1 -1
- package/build/wagmi/useSwitchChainFiltered.d.ts +199 -0
- package/build/wagmi/useSwitchChainFiltered.js +53 -0
- package/build/wagmi/useSwitchChainFiltered.js.map +1 -0
- package/package.json +1 -1
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { motion, AnimatePresence } from 'framer-motion';
|
|
3
3
|
import { useState, useEffect, useId } from 'react';
|
|
4
|
-
import { useAccount, useChainId
|
|
4
|
+
import { useAccount, useChainId } from 'wagmi';
|
|
5
5
|
import ChainIcons from '../../../assets/chains.js';
|
|
6
6
|
import Alert from '../../../components/Common/Alert/index.js';
|
|
7
7
|
import { useOpenfort } from '../../../components/Openfort/useOpenfort.js';
|
|
8
8
|
import { chainConfigs } from '../../../constants/chainConfigs.js';
|
|
9
9
|
import useLocales from '../../../hooks/useLocales.js';
|
|
10
10
|
import { isMobile, isCoinbaseWalletConnector } from '../../../utils/index.js';
|
|
11
|
+
import { useSwitchChainFiltered } from '../../useSwitchChainFiltered.js';
|
|
11
12
|
import { SwitchNetworksContainer, ChainButtonContainer, ChainButtons, ChainButton, ChainLogoContainer, ChainLogoSpinner, ChainIcon, ChainButtonStatus, ChainButtonBg } from './styles.js';
|
|
12
13
|
|
|
13
14
|
const Spinner = () => {
|
|
@@ -17,7 +18,7 @@ const Spinner = () => {
|
|
|
17
18
|
const ChainSelectList = ({ variant }) => {
|
|
18
19
|
const { connector } = useAccount();
|
|
19
20
|
const activeChainId = useChainId();
|
|
20
|
-
const { chains, isPending: bridgeIsPending, switchChain: switchChainFn, error: bridgeError } =
|
|
21
|
+
const { chains, isPending: bridgeIsPending, switchChain: switchChainFn, error: bridgeError, } = useSwitchChainFiltered();
|
|
21
22
|
const [pendingChainId, setPendingChainId] = useState(undefined);
|
|
22
23
|
const locales = useLocales({});
|
|
23
24
|
const mobile = isMobile();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import { useChainId
|
|
2
|
+
import { useChainId } from 'wagmi';
|
|
3
3
|
import { DisconnectIcon } from '../../../assets/icons.js';
|
|
4
4
|
import Button from '../../../components/Common/Button/index.js';
|
|
5
5
|
import { OrDivider } from '../../../components/Common/Modal/index.js';
|
|
@@ -7,11 +7,12 @@ import { ModalContent, ModalBody } from '../../../components/Common/Modal/styles
|
|
|
7
7
|
import { PageContent } from '../../../components/PageContent/index.js';
|
|
8
8
|
import useLocales from '../../../hooks/useLocales.js';
|
|
9
9
|
import { useOpenfortCore } from '../../../openfort/useOpenfort.js';
|
|
10
|
+
import { useSwitchChainFiltered } from '../../useSwitchChainFiltered.js';
|
|
10
11
|
import ChainSelectList from '../ChainSelectList/index.js';
|
|
11
12
|
|
|
12
13
|
const SwitchNetworks = () => {
|
|
13
14
|
const chainId = useChainId();
|
|
14
|
-
const { chains } =
|
|
15
|
+
const { chains } = useSwitchChainFiltered();
|
|
15
16
|
const { logout } = useOpenfortCore();
|
|
16
17
|
const locales = useLocales({});
|
|
17
18
|
const chainIsSupported = chainId != null && chains.some((c) => c.id === chainId);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wraps wagmi's `useSwitchChain`, restricting the switchable chains to those
|
|
3
|
+
* matching the Openfort publishable key environment.
|
|
4
|
+
*
|
|
5
|
+
* - `pk_test_…` keys expose only testnet chains (`chain.testnet === true`)
|
|
6
|
+
* - `pk_live_…` keys expose only mainnet chains (`chain.testnet !== true`)
|
|
7
|
+
*
|
|
8
|
+
* The chain the wallet is currently connected to is always kept in the list,
|
|
9
|
+
* even when it doesn't match the environment, so the selector can still display
|
|
10
|
+
* it and let the user switch away (without it, the active-chain lookups in the
|
|
11
|
+
* UI would resolve to `undefined` and the switch control would disappear).
|
|
12
|
+
*
|
|
13
|
+
* Chains rely on viem's `testnet` flag; custom chains defined without it are
|
|
14
|
+
* treated as mainnet. When the key prefix is unknown, or no configured chain
|
|
15
|
+
* matches the environment, the developer's full chain list is returned
|
|
16
|
+
* unchanged to avoid an empty selector.
|
|
17
|
+
*/
|
|
18
|
+
export declare const useSwitchChainFiltered: () => {
|
|
19
|
+
chains: readonly [import("viem").Chain, ...import("viem").Chain[]] | import("viem").Chain[];
|
|
20
|
+
data: undefined;
|
|
21
|
+
variables: undefined;
|
|
22
|
+
error: null;
|
|
23
|
+
isError: false;
|
|
24
|
+
isIdle: true;
|
|
25
|
+
isPending: false;
|
|
26
|
+
isSuccess: false;
|
|
27
|
+
status: "idle";
|
|
28
|
+
reset: () => void;
|
|
29
|
+
context: unknown;
|
|
30
|
+
failureCount: number;
|
|
31
|
+
failureReason: import("@wagmi/core").SwitchChainErrorType | null;
|
|
32
|
+
isPaused: boolean;
|
|
33
|
+
submittedAt: number;
|
|
34
|
+
mutate: import("wagmi/query").SwitchChainMutate<import("wagmi").Config, unknown>;
|
|
35
|
+
mutateAsync: import("wagmi/query").SwitchChainMutateAsync<import("wagmi").Config, unknown>;
|
|
36
|
+
switchChain: import("wagmi/query").SwitchChainMutate<import("wagmi").Config, unknown>;
|
|
37
|
+
switchChainAsync: import("wagmi/query").SwitchChainMutateAsync<import("wagmi").Config, unknown>;
|
|
38
|
+
} | {
|
|
39
|
+
chains: readonly [import("viem").Chain, ...import("viem").Chain[]] | import("viem").Chain[];
|
|
40
|
+
data: undefined;
|
|
41
|
+
variables: {
|
|
42
|
+
connector?: import("wagmi").Connector | undefined;
|
|
43
|
+
chainId: number;
|
|
44
|
+
addEthereumChainParameter?: {
|
|
45
|
+
nativeCurrency?: {
|
|
46
|
+
name: string;
|
|
47
|
+
symbol: string;
|
|
48
|
+
decimals: number;
|
|
49
|
+
} | undefined | undefined;
|
|
50
|
+
rpcUrls?: readonly string[] | undefined;
|
|
51
|
+
chainName?: string | undefined;
|
|
52
|
+
blockExplorerUrls?: string[] | undefined | undefined;
|
|
53
|
+
iconUrls?: string[] | undefined | undefined;
|
|
54
|
+
} | undefined;
|
|
55
|
+
};
|
|
56
|
+
error: null;
|
|
57
|
+
isError: false;
|
|
58
|
+
isIdle: false;
|
|
59
|
+
isPending: true;
|
|
60
|
+
isSuccess: false;
|
|
61
|
+
status: "pending";
|
|
62
|
+
reset: () => void;
|
|
63
|
+
context: unknown;
|
|
64
|
+
failureCount: number;
|
|
65
|
+
failureReason: import("@wagmi/core").SwitchChainErrorType | null;
|
|
66
|
+
isPaused: boolean;
|
|
67
|
+
submittedAt: number;
|
|
68
|
+
mutate: import("wagmi/query").SwitchChainMutate<import("wagmi").Config, unknown>;
|
|
69
|
+
mutateAsync: import("wagmi/query").SwitchChainMutateAsync<import("wagmi").Config, unknown>;
|
|
70
|
+
switchChain: import("wagmi/query").SwitchChainMutate<import("wagmi").Config, unknown>;
|
|
71
|
+
switchChainAsync: import("wagmi/query").SwitchChainMutateAsync<import("wagmi").Config, unknown>;
|
|
72
|
+
} | {
|
|
73
|
+
chains: readonly [import("viem").Chain, ...import("viem").Chain[]] | import("viem").Chain[];
|
|
74
|
+
data: undefined;
|
|
75
|
+
variables: {
|
|
76
|
+
connector?: import("wagmi").Connector | undefined;
|
|
77
|
+
chainId: number;
|
|
78
|
+
addEthereumChainParameter?: {
|
|
79
|
+
nativeCurrency?: {
|
|
80
|
+
name: string;
|
|
81
|
+
symbol: string;
|
|
82
|
+
decimals: number;
|
|
83
|
+
} | undefined | undefined;
|
|
84
|
+
rpcUrls?: readonly string[] | undefined;
|
|
85
|
+
chainName?: string | undefined;
|
|
86
|
+
blockExplorerUrls?: string[] | undefined | undefined;
|
|
87
|
+
iconUrls?: string[] | undefined | undefined;
|
|
88
|
+
} | undefined;
|
|
89
|
+
};
|
|
90
|
+
error: import("@wagmi/core").SwitchChainErrorType;
|
|
91
|
+
isError: true;
|
|
92
|
+
isIdle: false;
|
|
93
|
+
isPending: false;
|
|
94
|
+
isSuccess: false;
|
|
95
|
+
status: "error";
|
|
96
|
+
reset: () => void;
|
|
97
|
+
context: unknown;
|
|
98
|
+
failureCount: number;
|
|
99
|
+
failureReason: import("@wagmi/core").SwitchChainErrorType | null;
|
|
100
|
+
isPaused: boolean;
|
|
101
|
+
submittedAt: number;
|
|
102
|
+
mutate: import("wagmi/query").SwitchChainMutate<import("wagmi").Config, unknown>;
|
|
103
|
+
mutateAsync: import("wagmi/query").SwitchChainMutateAsync<import("wagmi").Config, unknown>;
|
|
104
|
+
switchChain: import("wagmi/query").SwitchChainMutate<import("wagmi").Config, unknown>;
|
|
105
|
+
switchChainAsync: import("wagmi/query").SwitchChainMutateAsync<import("wagmi").Config, unknown>;
|
|
106
|
+
} | {
|
|
107
|
+
chains: readonly [import("viem").Chain, ...import("viem").Chain[]] | import("viem").Chain[];
|
|
108
|
+
data: {
|
|
109
|
+
blockExplorers?: {
|
|
110
|
+
[key: string]: {
|
|
111
|
+
name: string;
|
|
112
|
+
url: string;
|
|
113
|
+
apiUrl?: string | undefined;
|
|
114
|
+
};
|
|
115
|
+
default: {
|
|
116
|
+
name: string;
|
|
117
|
+
url: string;
|
|
118
|
+
apiUrl?: string | undefined;
|
|
119
|
+
};
|
|
120
|
+
} | undefined | undefined;
|
|
121
|
+
blockTime?: number | undefined | undefined;
|
|
122
|
+
contracts?: {
|
|
123
|
+
[x: string]: import("viem").ChainContract | {
|
|
124
|
+
[sourceId: number]: import("viem").ChainContract | undefined;
|
|
125
|
+
} | undefined;
|
|
126
|
+
ensRegistry?: import("viem").ChainContract | undefined;
|
|
127
|
+
ensUniversalResolver?: import("viem").ChainContract | undefined;
|
|
128
|
+
multicall3?: import("viem").ChainContract | undefined;
|
|
129
|
+
erc6492Verifier?: import("viem").ChainContract | undefined;
|
|
130
|
+
} | undefined;
|
|
131
|
+
ensTlds?: readonly string[] | undefined;
|
|
132
|
+
id: number;
|
|
133
|
+
name: string;
|
|
134
|
+
nativeCurrency: {
|
|
135
|
+
name: string;
|
|
136
|
+
symbol: string;
|
|
137
|
+
decimals: number;
|
|
138
|
+
};
|
|
139
|
+
experimental_preconfirmationTime?: number | undefined | undefined;
|
|
140
|
+
rpcUrls: {
|
|
141
|
+
[key: string]: {
|
|
142
|
+
http: readonly string[];
|
|
143
|
+
webSocket?: readonly string[] | undefined;
|
|
144
|
+
};
|
|
145
|
+
default: {
|
|
146
|
+
http: readonly string[];
|
|
147
|
+
webSocket?: readonly string[] | undefined;
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
sourceId?: number | undefined | undefined;
|
|
151
|
+
testnet?: boolean | undefined | undefined;
|
|
152
|
+
custom?: Record<string, unknown> | undefined;
|
|
153
|
+
extendSchema?: Record<string, unknown> | undefined;
|
|
154
|
+
fees?: import("viem").ChainFees<import("viem").ChainFormatters | undefined> | undefined;
|
|
155
|
+
formatters?: import("viem").ChainFormatters | undefined;
|
|
156
|
+
prepareTransactionRequest?: ((args: import("viem").PrepareTransactionRequestParameters, options: {
|
|
157
|
+
client: import("viem").Client;
|
|
158
|
+
phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
|
|
159
|
+
}) => Promise<import("viem").PrepareTransactionRequestParameters>) | [fn: ((args: import("viem").PrepareTransactionRequestParameters, options: {
|
|
160
|
+
client: import("viem").Client;
|
|
161
|
+
phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
|
|
162
|
+
}) => Promise<import("viem").PrepareTransactionRequestParameters>) | undefined, options: {
|
|
163
|
+
runAt: readonly ("beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters")[];
|
|
164
|
+
}] | undefined;
|
|
165
|
+
serializers?: import("viem").ChainSerializers<import("viem").ChainFormatters | undefined, import("viem").TransactionSerializable> | undefined;
|
|
166
|
+
verifyHash?: ((client: import("viem").Client, parameters: import("viem").VerifyHashActionParameters) => Promise<import("viem").VerifyHashActionReturnType>) | undefined;
|
|
167
|
+
};
|
|
168
|
+
variables: {
|
|
169
|
+
connector?: import("wagmi").Connector | undefined;
|
|
170
|
+
chainId: number;
|
|
171
|
+
addEthereumChainParameter?: {
|
|
172
|
+
nativeCurrency?: {
|
|
173
|
+
name: string;
|
|
174
|
+
symbol: string;
|
|
175
|
+
decimals: number;
|
|
176
|
+
} | undefined | undefined;
|
|
177
|
+
rpcUrls?: readonly string[] | undefined;
|
|
178
|
+
chainName?: string | undefined;
|
|
179
|
+
blockExplorerUrls?: string[] | undefined | undefined;
|
|
180
|
+
iconUrls?: string[] | undefined | undefined;
|
|
181
|
+
} | undefined;
|
|
182
|
+
};
|
|
183
|
+
error: null;
|
|
184
|
+
isError: false;
|
|
185
|
+
isIdle: false;
|
|
186
|
+
isPending: false;
|
|
187
|
+
isSuccess: true;
|
|
188
|
+
status: "success";
|
|
189
|
+
reset: () => void;
|
|
190
|
+
context: unknown;
|
|
191
|
+
failureCount: number;
|
|
192
|
+
failureReason: import("@wagmi/core").SwitchChainErrorType | null;
|
|
193
|
+
isPaused: boolean;
|
|
194
|
+
submittedAt: number;
|
|
195
|
+
mutate: import("wagmi/query").SwitchChainMutate<import("wagmi").Config, unknown>;
|
|
196
|
+
mutateAsync: import("wagmi/query").SwitchChainMutateAsync<import("wagmi").Config, unknown>;
|
|
197
|
+
switchChain: import("wagmi/query").SwitchChainMutate<import("wagmi").Config, unknown>;
|
|
198
|
+
switchChainAsync: import("wagmi/query").SwitchChainMutateAsync<import("wagmi").Config, unknown>;
|
|
199
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { useEffect, useMemo } from 'react';
|
|
2
|
+
import { useSwitchChain, useChainId } from 'wagmi';
|
|
3
|
+
import { useOpenfort } from '../components/Openfort/useOpenfort.js';
|
|
4
|
+
import { logger } from '../utils/logger.js';
|
|
5
|
+
import { getPublishableKeyEnvironment } from '../utils/validation.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Wraps wagmi's `useSwitchChain`, restricting the switchable chains to those
|
|
9
|
+
* matching the Openfort publishable key environment.
|
|
10
|
+
*
|
|
11
|
+
* - `pk_test_…` keys expose only testnet chains (`chain.testnet === true`)
|
|
12
|
+
* - `pk_live_…` keys expose only mainnet chains (`chain.testnet !== true`)
|
|
13
|
+
*
|
|
14
|
+
* The chain the wallet is currently connected to is always kept in the list,
|
|
15
|
+
* even when it doesn't match the environment, so the selector can still display
|
|
16
|
+
* it and let the user switch away (without it, the active-chain lookups in the
|
|
17
|
+
* UI would resolve to `undefined` and the switch control would disappear).
|
|
18
|
+
*
|
|
19
|
+
* Chains rely on viem's `testnet` flag; custom chains defined without it are
|
|
20
|
+
* treated as mainnet. When the key prefix is unknown, or no configured chain
|
|
21
|
+
* matches the environment, the developer's full chain list is returned
|
|
22
|
+
* unchanged to avoid an empty selector.
|
|
23
|
+
*/
|
|
24
|
+
const useSwitchChainFiltered = () => {
|
|
25
|
+
const result = useSwitchChain();
|
|
26
|
+
const { publishableKey } = useOpenfort();
|
|
27
|
+
const activeChainId = useChainId();
|
|
28
|
+
const env = getPublishableKeyEnvironment(publishableKey);
|
|
29
|
+
const allChains = result.chains;
|
|
30
|
+
const noChainMatchesEnv = env != null && !allChains.some((c) => matchesEnvironment(c, env));
|
|
31
|
+
// Warn (dev only — gated behind debug mode) when the publishable key
|
|
32
|
+
// environment doesn't match any configured chain, since the env filter then
|
|
33
|
+
// falls back to the full list and silently does nothing.
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
if (noChainMatchesEnv) {
|
|
36
|
+
logger.warn(`No configured chain matches the "${env}" publishable key environment; ` +
|
|
37
|
+
'showing all chains. Check your wagmi chains and publishable key.');
|
|
38
|
+
}
|
|
39
|
+
}, [noChainMatchesEnv, env]);
|
|
40
|
+
const chains = useMemo(() => {
|
|
41
|
+
if (!env)
|
|
42
|
+
return allChains;
|
|
43
|
+
const filtered = allChains.filter((c) => c.id === activeChainId || matchesEnvironment(c, env));
|
|
44
|
+
return filtered.length > 0 ? filtered : allChains;
|
|
45
|
+
}, [allChains, env, activeChainId]);
|
|
46
|
+
return { ...result, chains };
|
|
47
|
+
};
|
|
48
|
+
function matchesEnvironment(chain, env) {
|
|
49
|
+
return env === 'live' ? chain.testnet !== true : chain.testnet === true;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { useSwitchChainFiltered };
|
|
53
|
+
//# sourceMappingURL=useSwitchChainFiltered.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSwitchChainFiltered.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|