@openfort/react 0.0.31 → 0.0.33
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/index.es.js
CHANGED
|
@@ -3,14 +3,14 @@ export { AccountTypeEnum, OAuthProvider, OpenfortEvents, RecoveryMethod, ThirdPa
|
|
|
3
3
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
4
|
import React, { useState, useEffect, createContext, useRef, useId, useMemo, useCallback, createElement, useLayoutEffect, useContext } from 'react';
|
|
5
5
|
import { normalize } from 'viem/ens';
|
|
6
|
-
import {
|
|
7
|
-
import { mainnet, polygon, optimism, arbitrum, sepolia } from 'wagmi/chains';
|
|
6
|
+
import { useEnsAddress, useEnsName, useEnsAvatar, useConfig, useAccount, useBlockNumber, useBalance, useConnectors as useConnectors$1, useConnect as useConnect$1, useDisconnect, useChainId, http, useSwitchChain, usePublicClient, WagmiContext } from 'wagmi';
|
|
8
7
|
import { motion, AnimatePresence, MotionConfig } from 'framer-motion';
|
|
9
8
|
import styled$1, { css, keyframes } from 'styled-components';
|
|
10
9
|
import { detect } from 'detect-browser';
|
|
11
10
|
import { useQueryClient, useQuery } from '@tanstack/react-query';
|
|
12
11
|
import useMeasure from 'react-use-measure';
|
|
13
12
|
import { Buffer } from 'buffer';
|
|
13
|
+
import { mainnet, polygon, optimism, arbitrum, sepolia } from 'wagmi/chains';
|
|
14
14
|
import { safe, injected, coinbaseWallet, walletConnect } from '@wagmi/connectors';
|
|
15
15
|
import { useTransition } from 'react-transition-state';
|
|
16
16
|
import ResizeObserver from 'resize-observer-polyfill';
|
|
@@ -24,44 +24,17 @@ import { createSiweMessage } from 'viem/siwe';
|
|
|
24
24
|
import { parseSignature } from 'viem';
|
|
25
25
|
import { hashAuthorization } from 'viem/utils';
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* ```tsx
|
|
39
|
-
* const ChainStatus: React.FC<{ chainId?: number }> = ({ chainId }) => {
|
|
40
|
-
* const isSupported = useChainIsSupported(chainId);
|
|
41
|
-
*
|
|
42
|
-
* return (
|
|
43
|
-
* <span>
|
|
44
|
-
* {chainId ?? 'Unknown chain'}: {isSupported ? 'Supported' : 'Unsupported'}
|
|
45
|
-
* </span>
|
|
46
|
-
* );
|
|
47
|
-
* };
|
|
48
|
-
* ```
|
|
49
|
-
*/
|
|
50
|
-
function useChainIsSupported(chainId) {
|
|
51
|
-
const { chains } = useConfig();
|
|
52
|
-
if (chainId === undefined || chainId === null)
|
|
53
|
-
return false;
|
|
54
|
-
return chains.some((x) => x.id === chainId);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const ensFallbackConfig = createConfig({
|
|
58
|
-
chains: [mainnet],
|
|
59
|
-
transports: {
|
|
60
|
-
[mainnet.id]: http(),
|
|
61
|
-
},
|
|
62
|
-
});
|
|
27
|
+
// import { createConfig, http } from 'wagmi'
|
|
28
|
+
// import { mainnet } from 'wagmi/chains'
|
|
29
|
+
// import { useChainIsSupported } from './useChainIsSupported'
|
|
30
|
+
// const ensFallbackConfig = createConfig({
|
|
31
|
+
// chains: [mainnet],
|
|
32
|
+
// transports: {
|
|
33
|
+
// [mainnet.id]: http(),
|
|
34
|
+
// },
|
|
35
|
+
// })
|
|
63
36
|
function useEnsFallbackConfig() {
|
|
64
|
-
return !useChainIsSupported(1) ? ensFallbackConfig : undefined;
|
|
37
|
+
return /* !useChainIsSupported(1) ? ensFallbackConfig : */ undefined;
|
|
65
38
|
}
|
|
66
39
|
|
|
67
40
|
function useIsMounted() {
|
|
@@ -1284,7 +1257,7 @@ const ImageContainer$1 = styled(motion.img) `
|
|
|
1284
1257
|
`;
|
|
1285
1258
|
|
|
1286
1259
|
const Avatar = ({ address, name, size = 96, radius = 96 }) => {
|
|
1287
|
-
var _a
|
|
1260
|
+
var _a;
|
|
1288
1261
|
const isMounted = useIsMounted();
|
|
1289
1262
|
const context = useOpenfort();
|
|
1290
1263
|
const imageRef = useRef(null);
|
|
@@ -1318,13 +1291,13 @@ const Avatar = ({ address, name, size = 96, radius = 96 }) => {
|
|
|
1318
1291
|
}, [ensAvatar]);
|
|
1319
1292
|
if (!isMounted)
|
|
1320
1293
|
return jsx("div", { style: { width: size, height: size, borderRadius: radius } });
|
|
1321
|
-
if (
|
|
1294
|
+
if (context.uiConfig.customAvatar)
|
|
1322
1295
|
return (jsx("div", { style: {
|
|
1323
1296
|
width: size,
|
|
1324
1297
|
height: size,
|
|
1325
1298
|
borderRadius: radius,
|
|
1326
1299
|
overflow: 'hidden',
|
|
1327
|
-
}, children:
|
|
1300
|
+
}, children: context.uiConfig.customAvatar({
|
|
1328
1301
|
address: address !== null && address !== void 0 ? address : ens === null || ens === void 0 ? void 0 : ens.address,
|
|
1329
1302
|
ensName: name !== null && name !== void 0 ? name : ens === null || ens === void 0 ? void 0 : ens.name,
|
|
1330
1303
|
ensImage: ens === null || ens === void 0 ? void 0 : ens.avatar,
|
|
@@ -1788,6 +1761,36 @@ const chainConfigs = [
|
|
|
1788
1761
|
},
|
|
1789
1762
|
];
|
|
1790
1763
|
|
|
1764
|
+
/**
|
|
1765
|
+
* Hook for checking if a blockchain chain is supported.
|
|
1766
|
+
*
|
|
1767
|
+
* This hook verifies whether a specific blockchain chain ID is part of the
|
|
1768
|
+
* configured Wagmi chains. Use it to validate chain compatibility before
|
|
1769
|
+
* attempting operations or rendering chain-specific UI.
|
|
1770
|
+
*
|
|
1771
|
+
* @param chainId - The blockchain chain ID to check for support.
|
|
1772
|
+
* @returns `true` when the chain is configured, `false` otherwise.
|
|
1773
|
+
*
|
|
1774
|
+
* @example
|
|
1775
|
+
* ```tsx
|
|
1776
|
+
* const ChainStatus: React.FC<{ chainId?: number }> = ({ chainId }) => {
|
|
1777
|
+
* const isSupported = useChainIsSupported(chainId);
|
|
1778
|
+
*
|
|
1779
|
+
* return (
|
|
1780
|
+
* <span>
|
|
1781
|
+
* {chainId ?? 'Unknown chain'}: {isSupported ? 'Supported' : 'Unsupported'}
|
|
1782
|
+
* </span>
|
|
1783
|
+
* );
|
|
1784
|
+
* };
|
|
1785
|
+
* ```
|
|
1786
|
+
*/
|
|
1787
|
+
function useChainIsSupported(chainId) {
|
|
1788
|
+
const { chains } = useConfig();
|
|
1789
|
+
if (chainId === undefined || chainId === null)
|
|
1790
|
+
return false;
|
|
1791
|
+
return chains.some((x) => x.id === chainId);
|
|
1792
|
+
}
|
|
1793
|
+
|
|
1791
1794
|
const ChainContainer = styled.div `
|
|
1792
1795
|
--bg: transparent;
|
|
1793
1796
|
--color: #333;
|
|
@@ -1951,6 +1954,17 @@ const useWalletStatus = () => {
|
|
|
1951
1954
|
return [context.walletStatus, context.setWalletStatus];
|
|
1952
1955
|
};
|
|
1953
1956
|
|
|
1957
|
+
const PREFIX = '[Openfort-React]';
|
|
1958
|
+
const logger = {
|
|
1959
|
+
enabled: true,
|
|
1960
|
+
// biome-ignore lint/suspicious/noConsole: allowed for debugging
|
|
1961
|
+
log: (...args) => (logger.enabled ? console.log(PREFIX, ...args) : null),
|
|
1962
|
+
// biome-ignore lint/suspicious/noConsole: allowed for debugging
|
|
1963
|
+
error: (...args) => (logger.enabled ? console.error(PREFIX, ...args) : null),
|
|
1964
|
+
// biome-ignore lint/suspicious/noConsole: allowed for debugging
|
|
1965
|
+
warn: (...args) => (logger.enabled ? console.warn(PREFIX, ...args) : null),
|
|
1966
|
+
};
|
|
1967
|
+
|
|
1954
1968
|
const safeRoutes = {
|
|
1955
1969
|
disconnected: [
|
|
1956
1970
|
routes.PROVIDERS,
|
|
@@ -2026,7 +2040,7 @@ const allRoutes = [...safeRoutes.connected, ...safeRoutes.disconnected];
|
|
|
2026
2040
|
* ```
|
|
2027
2041
|
*/
|
|
2028
2042
|
function useUI() {
|
|
2029
|
-
const { open, setOpen, setRoute
|
|
2043
|
+
const { open, setOpen, setRoute } = useOpenfort();
|
|
2030
2044
|
const { isLoading, user, needsRecovery } = useOpenfortCore();
|
|
2031
2045
|
const { isConnected } = useAccount();
|
|
2032
2046
|
function defaultOpen() {
|
|
@@ -2046,19 +2060,19 @@ function useUI() {
|
|
|
2046
2060
|
let validRoute = route;
|
|
2047
2061
|
if (!allRoutes.includes(route)) {
|
|
2048
2062
|
validRoute = isConnected ? routes.PROFILE : routes.PROVIDERS;
|
|
2049
|
-
log(`Route ${route} is not a valid route, navigating to ${validRoute} instead.`);
|
|
2063
|
+
logger.log(`Route ${route} is not a valid route, navigating to ${validRoute} instead.`);
|
|
2050
2064
|
}
|
|
2051
2065
|
else {
|
|
2052
2066
|
if (isConnected) {
|
|
2053
2067
|
if (!safeRoutes.connected.includes(route)) {
|
|
2054
2068
|
validRoute = routes.PROFILE;
|
|
2055
|
-
log(`Route ${route} is not a valid route when connected, navigating to ${validRoute} instead.`);
|
|
2069
|
+
logger.log(`Route ${route} is not a valid route when connected, navigating to ${validRoute} instead.`);
|
|
2056
2070
|
}
|
|
2057
2071
|
}
|
|
2058
2072
|
else {
|
|
2059
2073
|
if (!safeRoutes.disconnected.includes(route)) {
|
|
2060
2074
|
validRoute = routes.PROVIDERS;
|
|
2061
|
-
log(`Route ${route} is not a valid route when disconnected, navigating to ${validRoute} instead.`);
|
|
2075
|
+
logger.log(`Route ${route} is not a valid route when disconnected, navigating to ${validRoute} instead.`);
|
|
2062
2076
|
}
|
|
2063
2077
|
}
|
|
2064
2078
|
}
|
|
@@ -3524,21 +3538,10 @@ export const keys = {
|
|
|
3524
3538
|
};
|
|
3525
3539
|
*/
|
|
3526
3540
|
|
|
3527
|
-
const PREFIX = '[Openfort-React]';
|
|
3528
|
-
const logger = {
|
|
3529
|
-
enabled: true,
|
|
3530
|
-
// biome-ignore lint/suspicious/noConsole: allowed for debugging
|
|
3531
|
-
log: (...args) => (logger.enabled ? console.log(PREFIX, ...args) : null),
|
|
3532
|
-
// biome-ignore lint/suspicious/noConsole: allowed for debugging
|
|
3533
|
-
error: (...args) => (logger.enabled ? console.error(PREFIX, ...args) : null),
|
|
3534
|
-
// biome-ignore lint/suspicious/noConsole: allowed for debugging
|
|
3535
|
-
warn: (...args) => (logger.enabled ? console.warn(PREFIX, ...args) : null),
|
|
3536
|
-
};
|
|
3537
|
-
|
|
3538
3541
|
function useLocales(replacements) {
|
|
3539
|
-
var _a
|
|
3542
|
+
var _a;
|
|
3540
3543
|
const context = useOpenfort();
|
|
3541
|
-
const language = (
|
|
3544
|
+
const language = (_a = context.uiConfig.language) !== null && _a !== void 0 ? _a : 'en-US';
|
|
3542
3545
|
const translations = useMemo(() => {
|
|
3543
3546
|
return getLocale(language);
|
|
3544
3547
|
}, [language]);
|
|
@@ -4133,20 +4136,18 @@ label, showBalance = false, showAvatar = true,
|
|
|
4133
4136
|
theme, mode, customTheme,
|
|
4134
4137
|
// Events
|
|
4135
4138
|
onClick, }) {
|
|
4136
|
-
var _a
|
|
4139
|
+
var _a;
|
|
4137
4140
|
const isMounted = useIsMounted();
|
|
4138
4141
|
const context = useOpenfort();
|
|
4139
4142
|
const { address, chain } = useAccount();
|
|
4140
4143
|
const chainIsSupported = useChainIsSupported(chain === null || chain === void 0 ? void 0 : chain.id);
|
|
4141
4144
|
const { open } = useUI();
|
|
4142
|
-
const separator = ['web95', 'rounded', 'minimal'].includes((
|
|
4143
|
-
? '....'
|
|
4144
|
-
: undefined;
|
|
4145
|
+
const separator = ['web95', 'rounded', 'minimal'].includes((_a = theme !== null && theme !== void 0 ? theme : context.uiConfig.theme) !== null && _a !== void 0 ? _a : '') ? '....' : undefined;
|
|
4145
4146
|
if (!isMounted)
|
|
4146
4147
|
return null;
|
|
4147
4148
|
const shouldShowBalance = showBalance && chainIsSupported;
|
|
4148
4149
|
const willShowBalance = address && shouldShowBalance;
|
|
4149
|
-
return (jsx(ResetContainer, { "$useTheme": theme !== null && theme !== void 0 ? theme :
|
|
4150
|
+
return (jsx(ResetContainer, { "$useTheme": theme !== null && theme !== void 0 ? theme : context.uiConfig.theme, "$useMode": mode !== null && mode !== void 0 ? mode : context.mode, "$customTheme": customTheme !== null && customTheme !== void 0 ? customTheme : context.uiConfig.customTheme, children: jsxs(ThemeContainer, { onClick: () => {
|
|
4150
4151
|
if (onClick) {
|
|
4151
4152
|
onClick(() => open());
|
|
4152
4153
|
}
|
|
@@ -4176,7 +4177,7 @@ onClick, }) {
|
|
|
4176
4177
|
duration: 0.4,
|
|
4177
4178
|
ease: [0.25, 1, 0.5, 1],
|
|
4178
4179
|
},
|
|
4179
|
-
}, children: jsx(ThemedButton, { variant: 'secondary', theme: theme !== null && theme !== void 0 ? theme :
|
|
4180
|
+
}, children: jsx(ThemedButton, { variant: 'secondary', theme: theme !== null && theme !== void 0 ? theme : context.uiConfig.theme, mode: mode !== null && mode !== void 0 ? mode : context.mode, customTheme: customTheme !== null && customTheme !== void 0 ? customTheme : context.uiConfig.customTheme, style: { overflow: 'hidden' }, children: jsx(motion.div, { style: { paddingRight: 24 }, children: jsx(Balance$1, { hideSymbol: true }) }) }) }, 'balance')) })), jsx(ThemedButton, { theme: theme !== null && theme !== void 0 ? theme : context.uiConfig.theme, mode: mode !== null && mode !== void 0 ? mode : context.mode, customTheme: customTheme !== null && customTheme !== void 0 ? customTheme : context.uiConfig.customTheme, style: shouldShowBalance && showBalance && address && (theme === 'retro' || context.uiConfig.theme === 'retro')
|
|
4180
4181
|
? {
|
|
4181
4182
|
/* Special fix for the retro theme... not happy about this one */
|
|
4182
4183
|
boxShadow: 'var(--ck-connectbutton-balance-connectbutton-box-shadow)',
|
|
@@ -4272,36 +4273,35 @@ function useThemeFont(theme) {
|
|
|
4272
4273
|
* ```
|
|
4273
4274
|
*/
|
|
4274
4275
|
function useConnect({ ...props } = {}) {
|
|
4275
|
-
const context = useOpenfort();
|
|
4276
4276
|
const { connect, connectAsync, connectors, ...rest } = useConnect$1({
|
|
4277
4277
|
...props,
|
|
4278
4278
|
mutation: {
|
|
4279
4279
|
...props.mutation,
|
|
4280
|
-
onError(err) {
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
4280
|
+
onError(...err) {
|
|
4281
|
+
var _a, _b;
|
|
4282
|
+
(_b = (_a = props.mutation) === null || _a === void 0 ? void 0 : _a.onError) === null || _b === void 0 ? void 0 : _b.call(_a, ...err);
|
|
4283
|
+
if (err[0].message) {
|
|
4284
|
+
if (err[0].message !== 'User rejected request') {
|
|
4285
|
+
logger.log(err[0].message, err);
|
|
4284
4286
|
}
|
|
4285
4287
|
}
|
|
4286
4288
|
else {
|
|
4287
|
-
|
|
4289
|
+
logger.log(`Could not connect.`, err);
|
|
4288
4290
|
}
|
|
4289
4291
|
},
|
|
4290
4292
|
},
|
|
4291
4293
|
});
|
|
4292
4294
|
return {
|
|
4293
4295
|
connect: ({ connector, chainId, mutation, }) => {
|
|
4294
|
-
var _a;
|
|
4295
4296
|
return connect({
|
|
4296
4297
|
connector,
|
|
4297
|
-
chainId
|
|
4298
|
+
chainId,
|
|
4298
4299
|
}, mutation);
|
|
4299
4300
|
},
|
|
4300
4301
|
connectAsync: async ({ connector, chainId, mutation, }) => {
|
|
4301
|
-
var _a;
|
|
4302
4302
|
return connectAsync({
|
|
4303
4303
|
connector,
|
|
4304
|
-
chainId
|
|
4304
|
+
chainId,
|
|
4305
4305
|
}, mutation);
|
|
4306
4306
|
},
|
|
4307
4307
|
connectors,
|
|
@@ -4717,7 +4717,7 @@ const defaultConfig = ({ appName = 'Openfort', appIcon, appDescription, appUrl,
|
|
|
4717
4717
|
walletConnectProjectId,
|
|
4718
4718
|
coinbaseWalletPreference,
|
|
4719
4719
|
});
|
|
4720
|
-
|
|
4720
|
+
logger.log('OPENFORT CHAINS', { chains, transports, propsTransports: props === null || props === void 0 ? void 0 : props.transports });
|
|
4721
4721
|
const config = {
|
|
4722
4722
|
...props,
|
|
4723
4723
|
chains,
|
|
@@ -4816,7 +4816,6 @@ function useLockBodyScroll(initialLocked) {
|
|
|
4816
4816
|
const [locked, setLocked] = useState(initialLocked);
|
|
4817
4817
|
const context = useOpenfort();
|
|
4818
4818
|
useIsomorphicLayoutEffect(() => {
|
|
4819
|
-
var _a;
|
|
4820
4819
|
if (!locked)
|
|
4821
4820
|
return;
|
|
4822
4821
|
const original = {
|
|
@@ -4839,17 +4838,16 @@ function useLockBodyScroll(initialLocked) {
|
|
|
4839
4838
|
document.body.style.position = 'relative';
|
|
4840
4839
|
document.body.style.touchAction = 'none';
|
|
4841
4840
|
//document.documentElement.style.overflow = 'hidden'; // overflow:hidden; on <html> breaks position:sticky;
|
|
4842
|
-
if (
|
|
4841
|
+
if (context.uiConfig.avoidLayoutShift) {
|
|
4843
4842
|
document.body.style.paddingRight = `${scrollBarWidth}px`;
|
|
4844
4843
|
}
|
|
4845
4844
|
return () => {
|
|
4846
|
-
var _a;
|
|
4847
4845
|
document.documentElement.style.removeProperty('--ck-scrollbar-width');
|
|
4848
4846
|
document.body.style.overflow = original.overflow;
|
|
4849
4847
|
document.body.style.position = original.position;
|
|
4850
4848
|
document.body.style.touchAction = original.touchAction;
|
|
4851
4849
|
//document.documentElement.style.overflow = original.htmlOverflow;
|
|
4852
|
-
if (
|
|
4850
|
+
if (context.uiConfig.avoidLayoutShift) {
|
|
4853
4851
|
document.body.style.paddingRight = original.paddingRight;
|
|
4854
4852
|
}
|
|
4855
4853
|
};
|
|
@@ -5254,12 +5252,11 @@ const useWallets$1 = () => {
|
|
|
5254
5252
|
.filter((wallet, index, self) => self.findIndex((w) => w.id === wallet.id) === index)
|
|
5255
5253
|
// Replace walletConnect's name with the one from options
|
|
5256
5254
|
.map((wallet) => {
|
|
5257
|
-
var _a, _b;
|
|
5258
5255
|
if (wallet.id === 'walletConnect') {
|
|
5259
5256
|
return {
|
|
5260
5257
|
...wallet,
|
|
5261
|
-
name:
|
|
5262
|
-
shortName:
|
|
5258
|
+
name: context.uiConfig.walletConnectName || wallet.name,
|
|
5259
|
+
shortName: context.uiConfig.walletConnectName || wallet.shortName,
|
|
5263
5260
|
};
|
|
5264
5261
|
}
|
|
5265
5262
|
return wallet;
|
|
@@ -5447,7 +5444,7 @@ const FitText = ({ children, maxFontSize = 100, minFontSize = 70, }) => {
|
|
|
5447
5444
|
};
|
|
5448
5445
|
FitText.displayName = 'FitText';
|
|
5449
5446
|
|
|
5450
|
-
const OPENFORT_VERSION = '0.0.
|
|
5447
|
+
const OPENFORT_VERSION = '0.0.33';
|
|
5451
5448
|
|
|
5452
5449
|
const Portal = (props) => {
|
|
5453
5450
|
props = {
|
|
@@ -6165,7 +6162,7 @@ const contentVariants$1 = {
|
|
|
6165
6162
|
},
|
|
6166
6163
|
};
|
|
6167
6164
|
const Modal = ({ open, pages, pageId, positionInside, inline, demo, onClose, onBack, onInfo, }) => {
|
|
6168
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
6165
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
6169
6166
|
const context = useOpenfort();
|
|
6170
6167
|
const themeContext = useThemeContext();
|
|
6171
6168
|
const mobile = isMobile();
|
|
@@ -6305,7 +6302,7 @@ const Modal = ({ open, pages, pageId, positionInside, inline, demo, onClose, onB
|
|
|
6305
6302
|
const Content = (jsx(ResetContainer, { "$useTheme": (_e = demo === null || demo === void 0 ? void 0 : demo.theme) !== null && _e !== void 0 ? _e : themeContext.theme, "$useMode": (_f = demo === null || demo === void 0 ? void 0 : demo.mode) !== null && _f !== void 0 ? _f : themeContext.mode, "$customTheme": (_g = demo === null || demo === void 0 ? void 0 : demo.customTheme) !== null && _g !== void 0 ? _g : themeContext.customTheme, children: jsxs(ModalContainer, { role: "dialog", style: {
|
|
6306
6303
|
pointerEvents: rendered ? 'auto' : 'none',
|
|
6307
6304
|
position: positionInside ? 'absolute' : undefined,
|
|
6308
|
-
}, children: [!inline && jsx(BackgroundOverlay, { "$active": rendered, onClick: onClose, "$blur":
|
|
6305
|
+
}, children: [!inline && jsx(BackgroundOverlay, { "$active": rendered, onClick: onClose, "$blur": context.uiConfig.overlayBlur }), jsxs(Container$6, { style: dimensionsCSS, initial: false, children: [jsx("div", { style: {
|
|
6309
6306
|
pointerEvents: inTransition ? 'all' : 'none', // Block interaction while transitioning
|
|
6310
6307
|
position: 'absolute',
|
|
6311
6308
|
top: 0,
|
|
@@ -6315,7 +6312,7 @@ const Modal = ({ open, pages, pageId, positionInside, inline, demo, onClose, onB
|
|
|
6315
6312
|
width: 'var(--width)',
|
|
6316
6313
|
zIndex: 9,
|
|
6317
6314
|
transition: 'width 200ms ease',
|
|
6318
|
-
} }), jsxs(BoxContainer, { className: `${rendered && 'active'}`, children: [jsx(AnimatePresence, { initial: false, children: context.errorMessage && (jsxs(ErrorMessage, { initial: { y: '10%', x: '-50%' }, animate: { y: '-100%' }, exit: { y: '100%' }, transition: { duration: 0.2, ease: 'easeInOut' }, children: [jsx("span", { children: context.errorMessage }), jsx("button", { type: "button", "aria-label": flattenChildren(locales.close).toString(),
|
|
6315
|
+
} }), jsxs(BoxContainer, { className: `${rendered && 'active'}`, children: [jsx(AnimatePresence, { initial: false, children: context.errorMessage && (jsxs(ErrorMessage, { initial: { y: '10%', x: '-50%' }, animate: { y: '-100%' }, exit: { y: '100%' }, transition: { duration: 0.2, ease: 'easeInOut' }, children: [jsx("span", { children: context.errorMessage }), jsx("button", { type: "button", "aria-label": flattenChildren(locales.close).toString(), style: {
|
|
6319
6316
|
position: 'absolute',
|
|
6320
6317
|
right: 24,
|
|
6321
6318
|
top: 24,
|
|
@@ -6334,7 +6331,7 @@ const Modal = ({ open, pages, pageId, positionInside, inline, demo, onClose, onB
|
|
|
6334
6331
|
duration: mobile ? 0 : 0.1,
|
|
6335
6332
|
delay: mobile ? 0.01 : 0,
|
|
6336
6333
|
}, children: jsx(BackIcon, {}) }, "backButton")) : (onInfo &&
|
|
6337
|
-
!
|
|
6334
|
+
!context.uiConfig.hideQuestionMarkCTA && (jsx(InfoButton, { disabled: inTransition, "aria-label": flattenChildren(locales.moreInformation).toString(), onClick: onInfo, initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, transition: {
|
|
6338
6335
|
duration: mobile ? 0 : 0.1,
|
|
6339
6336
|
delay: mobile ? 0.01 : 0,
|
|
6340
6337
|
}, children: jsx(InfoIcon, {}) }, "infoButton"))) }) })] }), jsx(ModalHeading, { children: jsx(AnimatePresence, { children: jsx(motion.div, { style: {
|
|
@@ -7066,12 +7063,12 @@ const Dot = styled.button `
|
|
|
7066
7063
|
`;
|
|
7067
7064
|
|
|
7068
7065
|
const About = () => {
|
|
7069
|
-
var _a
|
|
7066
|
+
var _a;
|
|
7070
7067
|
const locales = useLocales({
|
|
7071
7068
|
//CONNECTORNAME: connector.name,
|
|
7072
7069
|
});
|
|
7073
7070
|
const context = useOpenfort();
|
|
7074
|
-
const ctaUrl = (
|
|
7071
|
+
const ctaUrl = (_a = context.uiConfig.ethereumOnboardingUrl) !== null && _a !== void 0 ? _a : locales.aboutScreen_ctaUrl;
|
|
7075
7072
|
const [_ready, setReady] = useState(true);
|
|
7076
7073
|
const [slider, setSlider] = useState(0);
|
|
7077
7074
|
const interacted = useRef(false);
|
|
@@ -7159,8 +7156,7 @@ const About = () => {
|
|
|
7159
7156
|
];
|
|
7160
7157
|
// Adjust height of ModalBody to fit content based on language
|
|
7161
7158
|
const slideHeight = (() => {
|
|
7162
|
-
|
|
7163
|
-
switch ((_a = context.uiConfig) === null || _a === void 0 ? void 0 : _a.language) {
|
|
7159
|
+
switch (context.uiConfig.language) {
|
|
7164
7160
|
case 'en-US':
|
|
7165
7161
|
case 'zh-CN':
|
|
7166
7162
|
return 64;
|
|
@@ -7206,7 +7202,6 @@ function useIsMobile() {
|
|
|
7206
7202
|
}
|
|
7207
7203
|
|
|
7208
7204
|
function useWalletConnectModal() {
|
|
7209
|
-
const { log } = useOpenfort();
|
|
7210
7205
|
const { connectAsync, connectors } = useConnect();
|
|
7211
7206
|
const [isOpen, setIsOpen] = useState(false);
|
|
7212
7207
|
return {
|
|
@@ -7230,7 +7225,7 @@ function useWalletConnectModal() {
|
|
|
7230
7225
|
await connectAsync({ connector: connector });
|
|
7231
7226
|
}
|
|
7232
7227
|
catch (err) {
|
|
7233
|
-
log('WalletConnect', err);
|
|
7228
|
+
logger.log('WalletConnect', err);
|
|
7234
7229
|
return {
|
|
7235
7230
|
error: 'Connection failed',
|
|
7236
7231
|
};
|
|
@@ -7241,14 +7236,14 @@ function useWalletConnectModal() {
|
|
|
7241
7236
|
return {};
|
|
7242
7237
|
}
|
|
7243
7238
|
catch (err) {
|
|
7244
|
-
log('Could not get WalletConnect provider', err);
|
|
7239
|
+
logger.log('Could not get WalletConnect provider', err);
|
|
7245
7240
|
return {
|
|
7246
7241
|
error: 'Could not get WalletConnect provider',
|
|
7247
7242
|
};
|
|
7248
7243
|
}
|
|
7249
7244
|
}
|
|
7250
7245
|
else {
|
|
7251
|
-
log('Configuration error: Please provide a WalletConnect Project ID in your wagmi config.');
|
|
7246
|
+
logger.log('Configuration error: Please provide a WalletConnect Project ID in your wagmi config.');
|
|
7252
7247
|
return {
|
|
7253
7248
|
error: 'Configuration error: Please provide a WalletConnect Project ID in your wagmi config.',
|
|
7254
7249
|
};
|
|
@@ -7281,7 +7276,6 @@ const useLastConnector = () => {
|
|
|
7281
7276
|
function useWalletConnectUri({ enabled } = {
|
|
7282
7277
|
enabled: true,
|
|
7283
7278
|
}) {
|
|
7284
|
-
const { log } = useOpenfort();
|
|
7285
7279
|
const [uri, setUri] = useState(undefined);
|
|
7286
7280
|
const connector = useWalletConnectConnector();
|
|
7287
7281
|
const { isConnected } = useAccount();
|
|
@@ -7292,7 +7286,7 @@ function useWalletConnectUri({ enabled } = {
|
|
|
7292
7286
|
return;
|
|
7293
7287
|
async function handleMessage(message) {
|
|
7294
7288
|
const { type, data } = message;
|
|
7295
|
-
log('WC Message', type, data);
|
|
7289
|
+
logger.log('WC Message', type, data);
|
|
7296
7290
|
if (type === 'display_uri') {
|
|
7297
7291
|
setUri(data);
|
|
7298
7292
|
}
|
|
@@ -7306,7 +7300,7 @@ function useWalletConnectUri({ enabled } = {
|
|
|
7306
7300
|
*/
|
|
7307
7301
|
}
|
|
7308
7302
|
async function handleDisconnect() {
|
|
7309
|
-
log('WC Disconnect');
|
|
7303
|
+
logger.log('WC Disconnect');
|
|
7310
7304
|
if (connector)
|
|
7311
7305
|
connectWallet(connector);
|
|
7312
7306
|
}
|
|
@@ -7323,22 +7317,22 @@ function useWalletConnectUri({ enabled } = {
|
|
|
7323
7317
|
await connectWallet(connector);
|
|
7324
7318
|
}
|
|
7325
7319
|
catch (error) {
|
|
7326
|
-
log('catch error');
|
|
7327
|
-
log(error);
|
|
7320
|
+
logger.log('catch error');
|
|
7321
|
+
logger.log(error);
|
|
7328
7322
|
if (error.code) {
|
|
7329
7323
|
switch (error.code) {
|
|
7330
7324
|
case 4001:
|
|
7331
|
-
log('error.code - User rejected');
|
|
7325
|
+
logger.log('error.code - User rejected');
|
|
7332
7326
|
connectWalletConnect(connector); // Regenerate QR code
|
|
7333
7327
|
break;
|
|
7334
7328
|
default:
|
|
7335
|
-
log('error.code - Unknown Error');
|
|
7329
|
+
logger.log('error.code - Unknown Error');
|
|
7336
7330
|
break;
|
|
7337
7331
|
}
|
|
7338
7332
|
}
|
|
7339
7333
|
else {
|
|
7340
7334
|
// Sometimes the error doesn't respond with a code
|
|
7341
|
-
log('WalletConnect cannot connect.', error);
|
|
7335
|
+
logger.log('WalletConnect cannot connect.', error);
|
|
7342
7336
|
}
|
|
7343
7337
|
}
|
|
7344
7338
|
}
|
|
@@ -7350,11 +7344,11 @@ function useWalletConnectUri({ enabled } = {
|
|
|
7350
7344
|
return;
|
|
7351
7345
|
if (connector && !isConnected) {
|
|
7352
7346
|
connectWalletConnect(connector);
|
|
7353
|
-
log('add wc listeners');
|
|
7347
|
+
logger.log('add wc listeners');
|
|
7354
7348
|
connector.emitter.on('message', handleMessage);
|
|
7355
7349
|
connector.emitter.on('disconnect', handleDisconnect);
|
|
7356
7350
|
return () => {
|
|
7357
|
-
log('remove wc listeners');
|
|
7351
|
+
logger.log('remove wc listeners');
|
|
7358
7352
|
connector.emitter.off('message', handleMessage);
|
|
7359
7353
|
connector.emitter.off('disconnect', handleDisconnect);
|
|
7360
7354
|
};
|
|
@@ -7999,7 +7993,6 @@ const ConnectorsContainer = styled.div `
|
|
|
7999
7993
|
`;
|
|
8000
7994
|
|
|
8001
7995
|
const ConnectorList = () => {
|
|
8002
|
-
var _a;
|
|
8003
7996
|
const context = useOpenfort();
|
|
8004
7997
|
const isMobile = useIsMobile();
|
|
8005
7998
|
const wallets = useWallets$1();
|
|
@@ -8010,7 +8003,7 @@ const ConnectorList = () => {
|
|
|
8010
8003
|
if (familyConnector && isFamily()) {
|
|
8011
8004
|
filteredWallets = filteredWallets.filter((wallet) => wallet.id !== (familyConnector === null || familyConnector === void 0 ? void 0 : familyConnector.id));
|
|
8012
8005
|
}
|
|
8013
|
-
const walletsToDisplay =
|
|
8006
|
+
const walletsToDisplay = context.uiConfig.hideRecentBadge || lastConnectorId === 'walletConnect' // do not hoist walletconnect to top of list
|
|
8014
8007
|
? wallets
|
|
8015
8008
|
: [
|
|
8016
8009
|
// move last used wallet to top of list
|
|
@@ -8046,8 +8039,8 @@ const ConnectorItem = ({ wallet, isRecent }) => {
|
|
|
8046
8039
|
if (redirectToMoreWallets || shouldConnectImmediately)
|
|
8047
8040
|
deeplink = undefined; // mobile redirects to more wallets page
|
|
8048
8041
|
const content = () => {
|
|
8049
|
-
var _a, _b
|
|
8050
|
-
return (jsxs(Fragment, { children: [jsx(ConnectorIcon, { "data-small": wallet.iconShouldShrink, "data-shape": wallet.iconShape, "data-background": redirectToMoreWallets, children: (_a = wallet.iconConnector) !== null && _a !== void 0 ? _a : wallet.icon }), jsxs(ConnectorLabel, { children: [isMobile ? ((_b = wallet.shortName) !== null && _b !== void 0 ? _b : wallet.name) : wallet.name, !
|
|
8042
|
+
var _a, _b;
|
|
8043
|
+
return (jsxs(Fragment, { children: [jsx(ConnectorIcon, { "data-small": wallet.iconShouldShrink, "data-shape": wallet.iconShape, "data-background": redirectToMoreWallets, children: (_a = wallet.iconConnector) !== null && _a !== void 0 ? _a : wallet.icon }), jsxs(ConnectorLabel, { children: [isMobile ? ((_b = wallet.shortName) !== null && _b !== void 0 ? _b : wallet.name) : wallet.name, !context.uiConfig.hideRecentBadge && isRecent && (jsx(RecentlyUsedTag, { children: jsx("span", { children: "Recent" }) }))] })] }));
|
|
8051
8044
|
};
|
|
8052
8045
|
return (jsx(ConnectorButton, { type: "button", disabled: context.route !== routes.CONNECTORS, onClick: () => {
|
|
8053
8046
|
if (isMobile && deeplink) {
|
|
@@ -8341,7 +8334,6 @@ const TooltipTail = styled(motion.div) `
|
|
|
8341
8334
|
`;
|
|
8342
8335
|
|
|
8343
8336
|
const Tooltip = ({ children, message, open, xOffset = 0, yOffset = 0, delay }) => {
|
|
8344
|
-
var _a;
|
|
8345
8337
|
const context = useOpenfort();
|
|
8346
8338
|
const themeContext = useThemeContext();
|
|
8347
8339
|
const [isOpen, setIsOpen] = useState(false);
|
|
@@ -8386,7 +8378,7 @@ const Tooltip = ({ children, message, open, xOffset = 0, yOffset = 0, delay }) =
|
|
|
8386
8378
|
useEffect(() => {
|
|
8387
8379
|
setIsOpen(!!open);
|
|
8388
8380
|
}, [open]);
|
|
8389
|
-
if (
|
|
8381
|
+
if (context.uiConfig.hideTooltips)
|
|
8390
8382
|
return jsx(Fragment, { children: children });
|
|
8391
8383
|
return (jsxs(Fragment, { children: [jsx(motion.div, { ref: ref, style: open === undefined
|
|
8392
8384
|
? {
|
|
@@ -8503,7 +8495,7 @@ const Loader = ({ header, description, icon, isError = false, isSuccess = false,
|
|
|
8503
8495
|
const ConnectWithMobile$1 = () => {
|
|
8504
8496
|
const { open: openWalletConnectModal } = useWalletConnectModal();
|
|
8505
8497
|
const [error, setError] = useState(undefined);
|
|
8506
|
-
const { connect, connectors } = useConnect
|
|
8498
|
+
const { connect, connectors } = useConnect();
|
|
8507
8499
|
const { connector, address } = useAccount();
|
|
8508
8500
|
const { setRoute, setConnector } = useOpenfort();
|
|
8509
8501
|
const openWCModal = async () => {
|
|
@@ -9028,14 +9020,14 @@ const mapWalletStatus = (status) => {
|
|
|
9028
9020
|
function useWallets(hookOptions = {}) {
|
|
9029
9021
|
const { client, embeddedAccounts, isLoadingAccounts: isLoadingWallets } = useOpenfortCore();
|
|
9030
9022
|
const { user } = useUser();
|
|
9031
|
-
const { walletConfig,
|
|
9023
|
+
const { walletConfig, setOpen, setRoute, setConnector, uiConfig } = useOpenfort();
|
|
9032
9024
|
const { connector, isConnected, address } = useAccount();
|
|
9033
9025
|
const chainId = useChainId();
|
|
9034
9026
|
const availableWallets = useWallets$1(); // TODO: Map wallets object to be the same as wallets
|
|
9035
9027
|
const { disconnect, disconnectAsync } = useDisconnect();
|
|
9036
9028
|
const [status, setStatus] = useWalletStatus();
|
|
9037
9029
|
const [connectToConnector, setConnectToConnector] = useState(undefined);
|
|
9038
|
-
const { connect } = useConnect
|
|
9030
|
+
const { connect } = useConnect({
|
|
9039
9031
|
mutation: {
|
|
9040
9032
|
onError: (e) => {
|
|
9041
9033
|
logger.error('Error connecting ---', e);
|
|
@@ -9051,7 +9043,7 @@ function useWallets(hookOptions = {}) {
|
|
|
9051
9043
|
},
|
|
9052
9044
|
onSuccess: (data) => {
|
|
9053
9045
|
setConnectToConnector(undefined);
|
|
9054
|
-
log('Connected with wallet', data, connectToConnector);
|
|
9046
|
+
logger.log('Connected with wallet', data, connectToConnector);
|
|
9055
9047
|
if ((connectToConnector === null || connectToConnector === void 0 ? void 0 : connectToConnector.address) &&
|
|
9056
9048
|
!data.accounts.some((a) => { var _a; return a.toLowerCase() === ((_a = connectToConnector.address) === null || _a === void 0 ? void 0 : _a.toLowerCase()); })) {
|
|
9057
9049
|
setStatus({
|
|
@@ -9171,7 +9163,7 @@ function useWallets(hookOptions = {}) {
|
|
|
9171
9163
|
return userWallets;
|
|
9172
9164
|
}, [user === null || user === void 0 ? void 0 : user.linkedAccounts, embeddedAccounts]);
|
|
9173
9165
|
const wallets = useMemo(() => {
|
|
9174
|
-
// log("Mapping wallets", { rawWallets, status, address, isConnected, connector: connector?.id });
|
|
9166
|
+
// logger.log("Mapping wallets", { rawWallets, status, address, isConnected, connector: connector?.id });
|
|
9175
9167
|
return rawWallets.map((w) => {
|
|
9176
9168
|
var _a;
|
|
9177
9169
|
return ({
|
|
@@ -9194,35 +9186,35 @@ function useWallets(hookOptions = {}) {
|
|
|
9194
9186
|
if (typeof optionsObject.walletId === 'string') {
|
|
9195
9187
|
const wallet = availableWallets.find((c) => c.id === optionsObject.walletId);
|
|
9196
9188
|
if (!wallet) {
|
|
9197
|
-
log('Connector not found', connector);
|
|
9189
|
+
logger.log('Connector not found', connector);
|
|
9198
9190
|
return { error: new OpenfortError('Connector not found', OpenfortErrorType.WALLET_ERROR) };
|
|
9199
9191
|
}
|
|
9200
|
-
log('Connecting to', wallet.connector);
|
|
9192
|
+
logger.log('Connecting to', wallet.connector);
|
|
9201
9193
|
connector = wallet.connector;
|
|
9202
9194
|
}
|
|
9203
9195
|
else {
|
|
9204
9196
|
connector = optionsObject.walletId;
|
|
9205
9197
|
}
|
|
9206
9198
|
if (!connector) {
|
|
9207
|
-
log('Connector not found', availableWallets, optionsObject.walletId);
|
|
9199
|
+
logger.log('Connector not found', availableWallets, optionsObject.walletId);
|
|
9208
9200
|
return { error: new OpenfortError('Connector not found', OpenfortErrorType.WALLET_ERROR) };
|
|
9209
9201
|
}
|
|
9210
9202
|
if ((activeWallet === null || activeWallet === void 0 ? void 0 : activeWallet.id) === connector.id && (address === null || address === void 0 ? void 0 : address.toLowerCase()) === ((_a = optionsObject.address) === null || _a === void 0 ? void 0 : _a.toLowerCase())) {
|
|
9211
|
-
log(`Already connected to ${connector.id} with address ${address}, skipping connection`);
|
|
9203
|
+
logger.log(`Already connected to ${connector.id} with address ${address}, skipping connection`);
|
|
9212
9204
|
return { wallet: activeWallet };
|
|
9213
9205
|
}
|
|
9214
9206
|
await disconnectAsync();
|
|
9215
9207
|
if (showUI) {
|
|
9216
9208
|
const walletToConnect = wallets.find((w) => w.id === connector.id);
|
|
9217
9209
|
if (!walletToConnect) {
|
|
9218
|
-
log('Wallet not found', connector);
|
|
9210
|
+
logger.log('Wallet not found', connector);
|
|
9219
9211
|
return onError({
|
|
9220
9212
|
error: new OpenfortError('Wallet not found', OpenfortErrorType.AUTHENTICATION_ERROR),
|
|
9221
9213
|
options: optionsObject,
|
|
9222
9214
|
hookOptions,
|
|
9223
9215
|
});
|
|
9224
9216
|
}
|
|
9225
|
-
log('Connecting to wallet', walletToConnect);
|
|
9217
|
+
logger.log('Connecting to wallet', walletToConnect);
|
|
9226
9218
|
if (connector.id === embeddedWalletId) {
|
|
9227
9219
|
setTimeout(() => {
|
|
9228
9220
|
setRoute(routes.RECOVER);
|
|
@@ -9239,7 +9231,7 @@ function useWallets(hookOptions = {}) {
|
|
|
9239
9231
|
function isOpenfortWallet(opts) {
|
|
9240
9232
|
return opts.walletId === embeddedWalletId;
|
|
9241
9233
|
}
|
|
9242
|
-
log('Setting active wallet', { options: optionsObject, chainId });
|
|
9234
|
+
logger.log('Setting active wallet', { options: optionsObject, chainId });
|
|
9243
9235
|
if (isOpenfortWallet(optionsObject)) {
|
|
9244
9236
|
setStatus({
|
|
9245
9237
|
status: 'connecting',
|
|
@@ -9263,7 +9255,7 @@ function useWallets(hookOptions = {}) {
|
|
|
9263
9255
|
});
|
|
9264
9256
|
let walletAddress = optionsObject.address;
|
|
9265
9257
|
// Ensure that the embedded wallet is listed
|
|
9266
|
-
log('Embedded wallets', embeddedAccounts, chainId);
|
|
9258
|
+
logger.log('Embedded wallets', embeddedAccounts, chainId);
|
|
9267
9259
|
let embeddedAccount;
|
|
9268
9260
|
if (walletAddress) {
|
|
9269
9261
|
const addressToMatch = walletAddress.toLowerCase();
|
|
@@ -9283,11 +9275,11 @@ function useWallets(hookOptions = {}) {
|
|
|
9283
9275
|
hookOptions,
|
|
9284
9276
|
});
|
|
9285
9277
|
}
|
|
9286
|
-
log('Found embedded wallet to recover', accountToRecover);
|
|
9278
|
+
logger.log('Found embedded wallet to recover', accountToRecover);
|
|
9287
9279
|
if (((_b = optionsObject.recovery) === null || _b === void 0 ? void 0 : _b.recoveryMethod) &&
|
|
9288
9280
|
accountToRecover.recoveryMethod &&
|
|
9289
9281
|
optionsObject.recovery.recoveryMethod !== accountToRecover.recoveryMethod) {
|
|
9290
|
-
log('Recovery method does not match', optionsObject.recovery.recoveryMethod, accountToRecover.recoveryMethod);
|
|
9282
|
+
logger.log('Recovery method does not match', optionsObject.recovery.recoveryMethod, accountToRecover.recoveryMethod);
|
|
9291
9283
|
return onError({
|
|
9292
9284
|
error: new OpenfortError("The recovery method you entered is incorrect and does not match the wallet's recovery method", OpenfortErrorType.WALLET_ERROR),
|
|
9293
9285
|
options: optionsObject,
|
|
@@ -9329,7 +9321,7 @@ function useWallets(hookOptions = {}) {
|
|
|
9329
9321
|
});
|
|
9330
9322
|
}
|
|
9331
9323
|
}
|
|
9332
|
-
log('Found embedded wallet to recover (without walletAddress)', accountToRecover);
|
|
9324
|
+
logger.log('Found embedded wallet to recover (without walletAddress)', accountToRecover);
|
|
9333
9325
|
const recovery = {
|
|
9334
9326
|
recoveryMethod: (_e = accountToRecover.recoveryMethod) !== null && _e !== void 0 ? _e : RecoveryMethod.AUTOMATIC,
|
|
9335
9327
|
password: (_f = optionsObject.recovery) === null || _f === void 0 ? void 0 : _f.password,
|
|
@@ -9386,7 +9378,7 @@ function useWallets(hookOptions = {}) {
|
|
|
9386
9378
|
error.message = 'Wrong password, Please try again.';
|
|
9387
9379
|
}
|
|
9388
9380
|
}
|
|
9389
|
-
log('Error handling recovery with Openfort:', error, err);
|
|
9381
|
+
logger.log('Error handling recovery with Openfort:', error, err);
|
|
9390
9382
|
setStatus({
|
|
9391
9383
|
status: 'error',
|
|
9392
9384
|
error,
|
|
@@ -9409,26 +9401,13 @@ function useWallets(hookOptions = {}) {
|
|
|
9409
9401
|
});
|
|
9410
9402
|
}
|
|
9411
9403
|
return {};
|
|
9412
|
-
}, [
|
|
9413
|
-
wallets,
|
|
9414
|
-
setOpen,
|
|
9415
|
-
setRoute,
|
|
9416
|
-
setConnector,
|
|
9417
|
-
disconnectAsync,
|
|
9418
|
-
log,
|
|
9419
|
-
address,
|
|
9420
|
-
client,
|
|
9421
|
-
walletConfig,
|
|
9422
|
-
chainId,
|
|
9423
|
-
hookOptions,
|
|
9424
|
-
]);
|
|
9404
|
+
}, [wallets, setOpen, setRoute, setConnector, disconnectAsync, address, client, walletConfig, chainId, hookOptions]);
|
|
9425
9405
|
const queryClient = useQueryClient();
|
|
9426
9406
|
const createWallet = useCallback(async ({ recovery, ...options } = {}) => {
|
|
9427
|
-
var _a;
|
|
9428
9407
|
setStatus({
|
|
9429
9408
|
status: 'creating',
|
|
9430
9409
|
});
|
|
9431
|
-
log('Creating wallet', { recovery: (recovery === null || recovery === void 0 ? void 0 : recovery.recoveryMethod) || RecoveryMethod.AUTOMATIC, options });
|
|
9410
|
+
logger.log('Creating wallet', { recovery: (recovery === null || recovery === void 0 ? void 0 : recovery.recoveryMethod) || RecoveryMethod.AUTOMATIC, options });
|
|
9432
9411
|
try {
|
|
9433
9412
|
const accessToken = await client.getAccessToken();
|
|
9434
9413
|
if (!accessToken) {
|
|
@@ -9447,7 +9426,7 @@ function useWallets(hookOptions = {}) {
|
|
|
9447
9426
|
}
|
|
9448
9427
|
const recoveryParams = await parseWalletRecovery(recovery);
|
|
9449
9428
|
const embeddedAccount = await client.embeddedWallet.create({
|
|
9450
|
-
chainId
|
|
9429
|
+
chainId,
|
|
9451
9430
|
accountType: (options === null || options === void 0 ? void 0 : options.accountType) || (walletConfig === null || walletConfig === void 0 ? void 0 : walletConfig.accountType) || AccountTypeEnum.SMART_ACCOUNT,
|
|
9452
9431
|
chainType: ChainTypeEnum.EVM,
|
|
9453
9432
|
recoveryParams,
|
|
@@ -9463,12 +9442,10 @@ function useWallets(hookOptions = {}) {
|
|
|
9463
9442
|
wallet: parseEmbeddedAccount({
|
|
9464
9443
|
embeddedAccount,
|
|
9465
9444
|
connector: openfortConnector,
|
|
9466
|
-
simpleAccounts:
|
|
9467
|
-
|
|
9468
|
-
|
|
9469
|
-
|
|
9470
|
-
// embeddedAccounts,
|
|
9471
|
-
// }),
|
|
9445
|
+
simpleAccounts: getSimpleAccounts({
|
|
9446
|
+
embeddedAccounts: [embeddedAccount],
|
|
9447
|
+
address: embeddedAccount.address,
|
|
9448
|
+
}),
|
|
9472
9449
|
chainId,
|
|
9473
9450
|
}),
|
|
9474
9451
|
},
|
|
@@ -9505,12 +9482,10 @@ function useWallets(hookOptions = {}) {
|
|
|
9505
9482
|
wallet: parseEmbeddedAccount({
|
|
9506
9483
|
embeddedAccount,
|
|
9507
9484
|
connector: openfortConnector,
|
|
9508
|
-
simpleAccounts:
|
|
9509
|
-
|
|
9510
|
-
|
|
9511
|
-
|
|
9512
|
-
// embeddedAccounts,
|
|
9513
|
-
// }),
|
|
9485
|
+
simpleAccounts: getSimpleAccounts({
|
|
9486
|
+
address: embeddedAccount.address,
|
|
9487
|
+
embeddedAccounts: [embeddedAccount],
|
|
9488
|
+
}),
|
|
9514
9489
|
chainId,
|
|
9515
9490
|
}),
|
|
9516
9491
|
},
|
|
@@ -9778,7 +9753,6 @@ const isValidEmail = (email) => {
|
|
|
9778
9753
|
* ```
|
|
9779
9754
|
*/
|
|
9780
9755
|
const useEmailAuth = (hookOptions = {}) => {
|
|
9781
|
-
const { log } = useOpenfort();
|
|
9782
9756
|
const { client, updateUser } = useOpenfortCore();
|
|
9783
9757
|
const { isOpen } = useUI();
|
|
9784
9758
|
const [requiresEmailVerification, setRequiresEmailVerification] = useState(false);
|
|
@@ -10082,7 +10056,7 @@ const useEmailAuth = (hookOptions = {}) => {
|
|
|
10082
10056
|
await client.validateAndRefreshToken();
|
|
10083
10057
|
const authToken = await client.getAccessToken();
|
|
10084
10058
|
if (!authToken) {
|
|
10085
|
-
log('No token found');
|
|
10059
|
+
logger.log('No token found');
|
|
10086
10060
|
const error = new OpenfortError('No token found', OpenfortErrorType.AUTHENTICATION_ERROR);
|
|
10087
10061
|
setStatus({
|
|
10088
10062
|
status: 'error',
|
|
@@ -10099,7 +10073,7 @@ const useEmailAuth = (hookOptions = {}) => {
|
|
|
10099
10073
|
password: options.password,
|
|
10100
10074
|
authToken,
|
|
10101
10075
|
});
|
|
10102
|
-
log('Email linked successfully');
|
|
10076
|
+
logger.log('Email linked successfully');
|
|
10103
10077
|
if ('action' in result) {
|
|
10104
10078
|
setStatus({
|
|
10105
10079
|
status: 'awaiting-input',
|
|
@@ -10141,7 +10115,7 @@ const useEmailAuth = (hookOptions = {}) => {
|
|
|
10141
10115
|
error: error,
|
|
10142
10116
|
});
|
|
10143
10117
|
}
|
|
10144
|
-
}, [client, setStatus, updateUser,
|
|
10118
|
+
}, [client, setStatus, updateUser, hookOptions, isOpen]);
|
|
10145
10119
|
const verifyEmail = useCallback(async (options) => {
|
|
10146
10120
|
setStatus({
|
|
10147
10121
|
status: 'loading',
|
|
@@ -10180,14 +10154,14 @@ const useEmailAuth = (hookOptions = {}) => {
|
|
|
10180
10154
|
status: 'error',
|
|
10181
10155
|
error,
|
|
10182
10156
|
});
|
|
10183
|
-
log('Error verifying email', e);
|
|
10157
|
+
logger.log('Error verifying email', e);
|
|
10184
10158
|
return onError({
|
|
10185
10159
|
hookOptions,
|
|
10186
10160
|
options,
|
|
10187
10161
|
error,
|
|
10188
10162
|
});
|
|
10189
10163
|
}
|
|
10190
|
-
}, [client,
|
|
10164
|
+
}, [client, hookOptions]);
|
|
10191
10165
|
return {
|
|
10192
10166
|
signInEmail,
|
|
10193
10167
|
signUpEmail,
|
|
@@ -10303,7 +10277,7 @@ const textVariants$1 = {
|
|
|
10303
10277
|
};
|
|
10304
10278
|
const EmailLogin = () => {
|
|
10305
10279
|
const [password, setPassword] = React.useState('');
|
|
10306
|
-
const { setRoute, triggerResize,
|
|
10280
|
+
const { setRoute, triggerResize, setEmailInput: setEmail, emailInput: email } = useOpenfort();
|
|
10307
10281
|
const [isRegister, setIsRegister] = React.useState(false);
|
|
10308
10282
|
const { signUpEmail, signInEmail, error: loginError, isLoading: loginLoading, } = useEmailAuth({
|
|
10309
10283
|
recoverWalletAutomatically: false,
|
|
@@ -10320,7 +10294,7 @@ const EmailLogin = () => {
|
|
|
10320
10294
|
email,
|
|
10321
10295
|
password,
|
|
10322
10296
|
});
|
|
10323
|
-
log('SIGN IN RESPONSE', { error, requiresEmailVerification });
|
|
10297
|
+
logger.log('SIGN IN RESPONSE', { error, requiresEmailVerification });
|
|
10324
10298
|
if (!error) {
|
|
10325
10299
|
if (requiresEmailVerification) {
|
|
10326
10300
|
setRoute(routes.EMAIL_VERIFICATION);
|
|
@@ -10344,7 +10318,7 @@ const EmailLogin = () => {
|
|
|
10344
10318
|
email,
|
|
10345
10319
|
password,
|
|
10346
10320
|
});
|
|
10347
|
-
log('SIGN UP RESPONSE', { error, requiresEmailVerification });
|
|
10321
|
+
logger.log('SIGN UP RESPONSE', { error, requiresEmailVerification });
|
|
10348
10322
|
if (!error) {
|
|
10349
10323
|
if (requiresEmailVerification) {
|
|
10350
10324
|
setRoute(routes.EMAIL_VERIFICATION);
|
|
@@ -10551,7 +10525,7 @@ const FloatingGraphic = ({ height = '130px', logoCenter, logoTopRight, logoTopLe
|
|
|
10551
10525
|
|
|
10552
10526
|
const EmailVerification = () => {
|
|
10553
10527
|
const { client } = useOpenfortCore();
|
|
10554
|
-
const { setRoute,
|
|
10528
|
+
const { setRoute, emailInput: emailInStorage } = useOpenfort();
|
|
10555
10529
|
const [loading, setLoading] = useState(true);
|
|
10556
10530
|
const [verificationResponse, setVerificationResponse] = useState(null);
|
|
10557
10531
|
useEffect(() => {
|
|
@@ -10575,7 +10549,7 @@ const EmailVerification = () => {
|
|
|
10575
10549
|
return;
|
|
10576
10550
|
}
|
|
10577
10551
|
const removeParams = () => {
|
|
10578
|
-
['state', 'openfortEmailVerificationUI', 'email'].forEach((key) => {
|
|
10552
|
+
['state', 'openfortEmailVerificationUI', 'email', 'openfortAuthProvider'].forEach((key) => {
|
|
10579
10553
|
url.searchParams.delete(key);
|
|
10580
10554
|
});
|
|
10581
10555
|
window.history.replaceState({}, document.title, url.toString());
|
|
@@ -10584,7 +10558,7 @@ const EmailVerification = () => {
|
|
|
10584
10558
|
setRoute(routes.EMAIL_LOGIN);
|
|
10585
10559
|
return;
|
|
10586
10560
|
}
|
|
10587
|
-
log('EmailVerification', state, email);
|
|
10561
|
+
logger.log('EmailVerification', state, email);
|
|
10588
10562
|
(async () => {
|
|
10589
10563
|
try {
|
|
10590
10564
|
await client.auth.verifyEmail({
|
|
@@ -10600,7 +10574,7 @@ const EmailVerification = () => {
|
|
|
10600
10574
|
success: false,
|
|
10601
10575
|
error: 'There was an error verifying your email. Please try again.',
|
|
10602
10576
|
});
|
|
10603
|
-
log('Error verifying email', e);
|
|
10577
|
+
logger.log('Error verifying email', e);
|
|
10604
10578
|
}
|
|
10605
10579
|
finally {
|
|
10606
10580
|
removeParams();
|
|
@@ -10630,7 +10604,7 @@ const EmailVerification = () => {
|
|
|
10630
10604
|
|
|
10631
10605
|
// TODO: Localize
|
|
10632
10606
|
const RequestEmail = () => {
|
|
10633
|
-
const {
|
|
10607
|
+
const { triggerResize, emailInput: email, setEmailInput: setEmail, setRoute } = useOpenfort();
|
|
10634
10608
|
const { client } = useOpenfortCore();
|
|
10635
10609
|
const [loading, setLoading] = React.useState(false);
|
|
10636
10610
|
const [message, setMessage] = React.useState('');
|
|
@@ -10671,7 +10645,7 @@ const RequestEmail = () => {
|
|
|
10671
10645
|
})
|
|
10672
10646
|
.catch((e) => {
|
|
10673
10647
|
var _a;
|
|
10674
|
-
log(e);
|
|
10648
|
+
logger.log(e);
|
|
10675
10649
|
const code = (_a = e === null || e === void 0 ? void 0 : e.response) === null || _a === void 0 ? void 0 : _a.status;
|
|
10676
10650
|
switch (code) {
|
|
10677
10651
|
case 400:
|
|
@@ -10693,7 +10667,7 @@ const ResetPassword = () => {
|
|
|
10693
10667
|
const fixedUrl = window.location.href.replace('?state=', '&state='); // redirectUrl is not working with query params
|
|
10694
10668
|
const url = new URL(fixedUrl);
|
|
10695
10669
|
const [password, setPassword] = React.useState('');
|
|
10696
|
-
const { setRoute, triggerResize
|
|
10670
|
+
const { setRoute, triggerResize } = useOpenfort();
|
|
10697
10671
|
const { client, updateUser } = useOpenfortCore();
|
|
10698
10672
|
const [loading, setLoading] = React.useState(false);
|
|
10699
10673
|
const email = url.searchParams.get('email');
|
|
@@ -10701,7 +10675,7 @@ const ResetPassword = () => {
|
|
|
10701
10675
|
setLoading(true);
|
|
10702
10676
|
const state = url.searchParams.get('state');
|
|
10703
10677
|
if (!email || !state) {
|
|
10704
|
-
log('No email or state found');
|
|
10678
|
+
logger.log('No email or state found');
|
|
10705
10679
|
setLoading(false);
|
|
10706
10680
|
return;
|
|
10707
10681
|
}
|
|
@@ -10725,7 +10699,7 @@ const ResetPassword = () => {
|
|
|
10725
10699
|
setRoute(routes.RECOVER);
|
|
10726
10700
|
}
|
|
10727
10701
|
catch (e) {
|
|
10728
|
-
log('Reset password error', e);
|
|
10702
|
+
logger.log('Reset password error', e);
|
|
10729
10703
|
setLoading(false);
|
|
10730
10704
|
triggerResize();
|
|
10731
10705
|
}
|
|
@@ -10767,7 +10741,7 @@ const textVariants = {
|
|
|
10767
10741
|
};
|
|
10768
10742
|
const LinkEmail = () => {
|
|
10769
10743
|
const [password, setPassword] = React.useState('');
|
|
10770
|
-
const { setRoute, triggerResize,
|
|
10744
|
+
const { setRoute, triggerResize, emailInput: email, setEmailInput: setEmail } = useOpenfort();
|
|
10771
10745
|
const { client, updateUser } = useOpenfortCore();
|
|
10772
10746
|
const [loginLoading, setLoginLoading] = React.useState(false);
|
|
10773
10747
|
const [loginError, setLoginError] = React.useState(false);
|
|
@@ -10776,7 +10750,7 @@ const LinkEmail = () => {
|
|
|
10776
10750
|
await client.validateAndRefreshToken();
|
|
10777
10751
|
const authToken = await client.getAccessToken();
|
|
10778
10752
|
if (!authToken) {
|
|
10779
|
-
log('No token found');
|
|
10753
|
+
logger.log('No token found');
|
|
10780
10754
|
setLoginLoading(false);
|
|
10781
10755
|
setLoginError('No token found.');
|
|
10782
10756
|
triggerResize();
|
|
@@ -10789,7 +10763,7 @@ const LinkEmail = () => {
|
|
|
10789
10763
|
authToken,
|
|
10790
10764
|
})
|
|
10791
10765
|
.catch((e) => {
|
|
10792
|
-
log('Link error:', e);
|
|
10766
|
+
logger.log('Link error:', e);
|
|
10793
10767
|
setLoginLoading(false);
|
|
10794
10768
|
setLoginError('Could not link email.');
|
|
10795
10769
|
triggerResize();
|
|
@@ -11027,7 +11001,7 @@ const Container$3 = styled.div ``;
|
|
|
11027
11001
|
|
|
11028
11002
|
const MoreIcon = (jsxs("svg", { width: "60", height: "60", viewBox: "0 0 60 60", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsx("title", { children: "More wallets icon" }), jsx("path", { d: "M30 42V19M19 30.5H42", stroke: "var(--ck-body-color-muted)", strokeWidth: "3", strokeLinecap: "round" })] }));
|
|
11029
11003
|
const MobileConnectors = () => {
|
|
11030
|
-
var _a
|
|
11004
|
+
var _a;
|
|
11031
11005
|
const context = useOpenfort();
|
|
11032
11006
|
const locales = useLocales();
|
|
11033
11007
|
const { connect: { getUri }, } = useWeb3();
|
|
@@ -11073,7 +11047,7 @@ const MobileConnectors = () => {
|
|
|
11073
11047
|
justifyContent: 'center',
|
|
11074
11048
|
}, children: jsx("div", { style: {
|
|
11075
11049
|
width: '50%',
|
|
11076
|
-
}, children: jsx(Spinner$3, {}) }) })) : (MoreIcon) }), jsx(WalletLabel, { children: locales.more })] })] }) }) }),
|
|
11050
|
+
}, children: jsx(Spinner$3, {}) }) })) : (MoreIcon) }), jsx(WalletLabel, { children: locales.more })] })] }) }) }), context.uiConfig.walletConnectCTA !== 'modal' && (jsx("div", { style: {
|
|
11077
11051
|
display: 'flex',
|
|
11078
11052
|
alignItems: 'center',
|
|
11079
11053
|
justifyContent: 'center',
|
|
@@ -11083,10 +11057,10 @@ const MobileConnectors = () => {
|
|
|
11083
11057
|
};
|
|
11084
11058
|
|
|
11085
11059
|
const Introduction = () => {
|
|
11086
|
-
var _a
|
|
11060
|
+
var _a;
|
|
11087
11061
|
const context = useOpenfort();
|
|
11088
11062
|
const locales = useLocales({});
|
|
11089
|
-
const ctaUrl = (
|
|
11063
|
+
const ctaUrl = (_a = context.uiConfig.walletOnboardingUrl) !== null && _a !== void 0 ? _a : locales.onboardingScreen_ctaUrl;
|
|
11090
11064
|
return (jsxs(PageContent, { children: [jsxs(Graphic, { children: [jsxs(LogoGroup, { children: [jsx(Logo$1, { children: jsx(LogoPosition, { children: jsx(LogoInner, { children: jsx(FloatWrapper, { children: jsx(RotateWrapper, { children: jsx(LogoGraphic$1, { children: jsx(Logos.Coinbase, { background: true }) }) }) }) }) }) }), jsx(Logo$1, { children: jsx(LogoPosition, { children: jsx(LogoInner, { children: jsx(FloatWrapper, { children: jsx(RotateWrapper, { children: jsx(LogoGraphic$1, { children: jsx(Logos.MetaMask, { background: true }) }) }) }) }) }) }), jsx(Logo$1, { children: jsx(LogoPosition, { children: jsx(LogoInner, { children: jsx(FloatWrapper, { children: jsx(RotateWrapper, { children: jsx(LogoGraphic$1, { children: jsx(Logos.Trust, {}) }) }) }) }) }) }), jsx(Logo$1, { children: jsx(LogoPosition, { children: jsx(LogoInner, { children: jsx(FloatWrapper, { children: jsx(RotateWrapper, { children: jsx(LogoGraphic$1, { children: jsx(Logos.Argent, {}) }) }) }) }) }) }), jsx(Logo$1, { children: jsx(LogoPosition, { children: jsx(LogoInner, { children: jsx(FloatWrapper, { children: jsx(RotateWrapper, { children: jsx(LogoGraphic$1, { children: jsx(Logos.ImToken, {}) }) }) }) }) }) })] }), jsx(GraphicBackground, { children: wave })] }), jsxs(ModalContent, { style: { paddingBottom: 18 }, children: [jsx(ModalH1, { "$small": true, children: locales.onboardingScreen_h1 }), jsx(ModalBody, { children: locales.onboardingScreen_p })] }), jsx(Button, { href: ctaUrl, arrow: true, children: locales.onboardingScreen_ctaText })] }));
|
|
11091
11065
|
};
|
|
11092
11066
|
|
|
@@ -11444,7 +11418,7 @@ const DropdownHeading = styled(motion.div) `
|
|
|
11444
11418
|
`;
|
|
11445
11419
|
|
|
11446
11420
|
const ChainSelectDropdown = ({ children, open, onClose, offsetX = 0, offsetY = 8 }) => {
|
|
11447
|
-
var _a, _b, _c
|
|
11421
|
+
var _a, _b, _c;
|
|
11448
11422
|
const context = useOpenfort();
|
|
11449
11423
|
const themeContext = useThemeContext();
|
|
11450
11424
|
const locales = useLocales();
|
|
@@ -11558,7 +11532,7 @@ const ChainSelectDropdown = ({ children, open, onClose, offsetX = 0, offsetY = 8
|
|
|
11558
11532
|
window.removeEventListener('resize', onResize);
|
|
11559
11533
|
};
|
|
11560
11534
|
}, []);
|
|
11561
|
-
return (jsxs(Fragment, { children: [jsx("div", { ref: ref, children: children }), jsx(AnimatePresence, { children: open && (jsx(Portal, { children: jsx(ResetContainer, { "$useTheme": (_a = themeContext.theme) !== null && _a !== void 0 ? _a :
|
|
11535
|
+
return (jsxs(Fragment, { children: [jsx("div", { ref: ref, children: children }), jsx(AnimatePresence, { children: open && (jsx(Portal, { children: jsx(ResetContainer, { "$useTheme": (_a = themeContext.theme) !== null && _a !== void 0 ? _a : context.uiConfig.theme, "$useMode": (_b = themeContext.mode) !== null && _b !== void 0 ? _b : context.mode, "$customTheme": (_c = themeContext.customTheme) !== null && _c !== void 0 ? _c : themeContext.customTheme, children: jsx(FocusTrap, { children: jsxs(DropdownWindow, { ref: contentRef, children: [jsx(DropdownOverlay, { onClick: onClose }), jsxs(DropdownContainer, { ref: innerRef, style: {
|
|
11562
11536
|
left: offset.x,
|
|
11563
11537
|
top: offset.y,
|
|
11564
11538
|
}, initial: 'collapsed', animate: 'open', exit: 'collapsed', variants: {
|
|
@@ -12104,7 +12078,7 @@ const LinkedProviders = () => {
|
|
|
12104
12078
|
};
|
|
12105
12079
|
|
|
12106
12080
|
const Profile = ({ closeModal }) => {
|
|
12107
|
-
var _a, _b
|
|
12081
|
+
var _a, _b;
|
|
12108
12082
|
const context = useOpenfort();
|
|
12109
12083
|
const themeContext = useThemeContext();
|
|
12110
12084
|
const locales = useLocales();
|
|
@@ -12135,10 +12109,10 @@ const Profile = ({ closeModal }) => {
|
|
|
12135
12109
|
logout();
|
|
12136
12110
|
};
|
|
12137
12111
|
}, [shouldDisconnect, logout]);
|
|
12138
|
-
const separator = ['web95', 'rounded', 'minimal'].includes((
|
|
12112
|
+
const separator = ['web95', 'rounded', 'minimal'].includes((_b = (_a = themeContext.theme) !== null && _a !== void 0 ? _a : context.uiConfig.theme) !== null && _b !== void 0 ? _b : '')
|
|
12139
12113
|
? '....'
|
|
12140
12114
|
: undefined;
|
|
12141
|
-
return (jsxs(PageContent, { children: [jsxs(ModalContent, { style: { paddingBottom: 22, gap: 6 }, children: [address ? (jsxs(Fragment, { children: [jsx(AvatarContainer, { children: jsxs(AvatarInner, { children: [jsx(ChainSelectorContainer, { children: jsx(ChainSelector, {}) }), jsx(Avatar, { address: address })] }) }), jsx(ModalH1, { children: jsx(CopyToClipboard, { string: address, children: ensName !== null && ensName !== void 0 ? ensName : truncateEthAddress(address, separator) }) }), (
|
|
12115
|
+
return (jsxs(PageContent, { children: [jsxs(ModalContent, { style: { paddingBottom: 22, gap: 6 }, children: [address ? (jsxs(Fragment, { children: [jsx(AvatarContainer, { children: jsxs(AvatarInner, { children: [jsx(ChainSelectorContainer, { children: jsx(ChainSelector, {}) }), jsx(Avatar, { address: address })] }) }), jsx(ModalH1, { children: jsx(CopyToClipboard, { string: address, children: ensName !== null && ensName !== void 0 ? ensName : truncateEthAddress(address, separator) }) }), (context === null || context === void 0 ? void 0 : context.uiConfig.hideBalance) ? null : (jsx(ModalBody, { children: jsx(BalanceContainer, { children: jsxs(AnimatePresence, { exitBeforeEnter: true, initial: false, children: [balance && (jsxs(Balance, { initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, transition: { duration: 0.2 }, children: [nFormatter(Number(balance === null || balance === void 0 ? void 0 : balance.formatted)), ` `, balance === null || balance === void 0 ? void 0 : balance.symbol] }, `chain-${chain === null || chain === void 0 ? void 0 : chain.id}`)), !balance && (jsx(LoadingBalance, { initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, transition: { duration: 0.2 }, children: "\u00A0" }))] }) }) }))] })) : (jsx(Button, { onClick: () => context.setRoute(routes.CONNECTORS), icon: jsx(Unsupported, { initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, children: jsxs("svg", { width: "130", height: "120", viewBox: "0 0 13 12", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsx("title", { children: "Unsupported wallet icon" }), jsx("path", { d: "M2.61317 11.2501H9.46246C10.6009 11.2501 11.3256 10.3506 11.3256 9.3549C11.3256 9.05145 11.255 8.73244 11.0881 8.43303L7.65903 2.14708C7.659 2.14702 7.65897 2.14696 7.65893 2.1469C7.65889 2.14682 7.65884 2.14673 7.65879 2.14664C7.31045 1.50746 6.6741 1.17871 6.04 1.17871C5.41478 1.17871 4.763 1.50043 4.41518 2.14968L0.993416 8.43476C0.828865 8.72426 0.75 9.04297 0.75 9.3549C0.75 10.3506 1.47471 11.2501 2.61317 11.2501Z", fill: "currentColor", stroke: "var(--ck-body-background, #fff)", strokeWidth: "1.5" }), jsx("path", { d: "M6.03258 7.43916C5.77502 7.43916 5.63096 7.29153 5.62223 7.02311L5.55675 4.96973C5.54802 4.69684 5.74446 4.5 6.02821 4.5C6.3076 4.5 6.51277 4.70131 6.50404 4.9742L6.43856 7.01864C6.42546 7.29153 6.2814 7.43916 6.03258 7.43916ZM6.03258 9.11676C5.7401 9.11676 5.5 8.9065 5.5 8.60677C5.5 8.30704 5.7401 8.09678 6.03258 8.09678C6.32506 8.09678 6.56515 8.30256 6.56515 8.60677C6.56515 8.91097 6.32069 9.11676 6.03258 9.11676Z", fill: "white" })] }) }), children: "Connect wallet" })), jsx(LinkedProviders, {})] }), !isSafeConnector(connector === null || connector === void 0 ? void 0 : connector.id) && (jsx(Button, { onClick: () => setShouldDisconnect(true), icon: jsx(DisconnectIcon, {}), children: locales.disconnect })), jsx(PoweredByFooter, {})] }));
|
|
12142
12116
|
};
|
|
12143
12117
|
|
|
12144
12118
|
const ProviderButton = ({ children, icon, onClick }) => {
|
|
@@ -12453,7 +12427,7 @@ const OtherMethodButton = styled.button `
|
|
|
12453
12427
|
const RecoverPasswordWallet = ({ wallet }) => {
|
|
12454
12428
|
const [recoveryPhrase, setRecoveryPhrase] = useState('');
|
|
12455
12429
|
const [recoveryError, setRecoveryError] = useState(false);
|
|
12456
|
-
const { triggerResize
|
|
12430
|
+
const { triggerResize } = useOpenfort();
|
|
12457
12431
|
const [loading, setLoading] = useState(false);
|
|
12458
12432
|
const { setActiveWallet } = useWallets();
|
|
12459
12433
|
const handleSubmit = async () => {
|
|
@@ -12471,7 +12445,7 @@ const RecoverPasswordWallet = ({ wallet }) => {
|
|
|
12471
12445
|
setRecoveryError(error.message || 'There was an error recovering your account');
|
|
12472
12446
|
}
|
|
12473
12447
|
else {
|
|
12474
|
-
log('Recovery success');
|
|
12448
|
+
logger.log('Recovery success');
|
|
12475
12449
|
}
|
|
12476
12450
|
};
|
|
12477
12451
|
useEffect(() => {
|
|
@@ -12536,18 +12510,17 @@ const RecoverPasskeyWallet = ({ wallet }) => {
|
|
|
12536
12510
|
const RecoverAutomaticWallet = ({ walletAddress }) => {
|
|
12537
12511
|
const { embeddedState } = useOpenfortCore();
|
|
12538
12512
|
const { setActiveWallet } = useWallets();
|
|
12539
|
-
const { log } = useOpenfort();
|
|
12540
12513
|
const [error, setError] = useState(false);
|
|
12541
12514
|
useEffect(() => {
|
|
12542
12515
|
(async () => {
|
|
12543
12516
|
if (embeddedState === EmbeddedState.EMBEDDED_SIGNER_NOT_CONFIGURED) {
|
|
12544
|
-
log('Automatically recovering wallet', walletAddress);
|
|
12517
|
+
logger.log('Automatically recovering wallet', walletAddress);
|
|
12545
12518
|
const response = await setActiveWallet({
|
|
12546
12519
|
walletId: embeddedWalletId,
|
|
12547
12520
|
});
|
|
12548
12521
|
if (response.error) {
|
|
12549
12522
|
setError(response.error.message || 'There was an error recovering your account');
|
|
12550
|
-
log('Error recovering wallet', response.error);
|
|
12523
|
+
logger.log('Error recovering wallet', response.error);
|
|
12551
12524
|
}
|
|
12552
12525
|
}
|
|
12553
12526
|
})();
|
|
@@ -12561,15 +12534,14 @@ const CreateWalletAutomaticRecovery = () => {
|
|
|
12561
12534
|
const { embeddedState } = useOpenfortCore();
|
|
12562
12535
|
const { createWallet } = useWallets();
|
|
12563
12536
|
const [shouldCreateWallet, setShouldCreateWallet] = useState(false);
|
|
12564
|
-
const { log } = useOpenfort();
|
|
12565
12537
|
useEffect(() => {
|
|
12566
12538
|
// To ensure the wallet is created only once
|
|
12567
12539
|
if (shouldCreateWallet) {
|
|
12568
12540
|
(async () => {
|
|
12569
|
-
log('Creating wallet Automatic recover');
|
|
12541
|
+
logger.log('Creating wallet Automatic recover');
|
|
12570
12542
|
const response = await createWallet();
|
|
12571
12543
|
if (response.error) {
|
|
12572
|
-
log('Error creating wallet', response.error);
|
|
12544
|
+
logger.log('Error creating wallet', response.error);
|
|
12573
12545
|
}
|
|
12574
12546
|
})();
|
|
12575
12547
|
}
|
|
@@ -12616,20 +12588,19 @@ const CreateWalletPasskeyRecovery = ({ onChangeMethod, }) => {
|
|
|
12616
12588
|
const { triggerResize } = useOpenfort();
|
|
12617
12589
|
const { createWallet, error: recoveryError } = useWallets();
|
|
12618
12590
|
const [shouldCreateWallet, setShouldCreateWallet] = useState(false);
|
|
12619
|
-
const { log } = useOpenfort();
|
|
12620
12591
|
const { embeddedState } = useOpenfortCore();
|
|
12621
12592
|
useEffect(() => {
|
|
12622
12593
|
// To ensure the wallet is created only once
|
|
12623
12594
|
if (shouldCreateWallet) {
|
|
12624
12595
|
(async () => {
|
|
12625
|
-
log('Creating wallet passkey recovery');
|
|
12596
|
+
logger.log('Creating wallet passkey recovery');
|
|
12626
12597
|
const response = await createWallet({
|
|
12627
12598
|
recovery: {
|
|
12628
12599
|
recoveryMethod: RecoveryMethod.PASSKEY,
|
|
12629
12600
|
},
|
|
12630
12601
|
});
|
|
12631
12602
|
if (response.error) {
|
|
12632
|
-
log('Error creating wallet', response.error);
|
|
12603
|
+
logger.log('Error creating wallet', response.error);
|
|
12633
12604
|
setShouldCreateWallet(false);
|
|
12634
12605
|
}
|
|
12635
12606
|
})();
|
|
@@ -12649,7 +12620,7 @@ const CreateWalletPasskeyRecovery = ({ onChangeMethod, }) => {
|
|
|
12649
12620
|
const CreateWalletPasswordRecovery = ({ onChangeMethod, }) => {
|
|
12650
12621
|
const [recoveryPhrase, setRecoveryPhrase] = useState('');
|
|
12651
12622
|
const [recoveryError, setRecoveryError] = useState(false);
|
|
12652
|
-
const { triggerResize
|
|
12623
|
+
const { triggerResize } = useOpenfort();
|
|
12653
12624
|
const [showPasswordIsTooWeakError, setShowPasswordIsTooWeakError] = useState(false);
|
|
12654
12625
|
const [loading, setLoading] = useState(false);
|
|
12655
12626
|
const { createWallet } = useWallets();
|
|
@@ -12670,7 +12641,7 @@ const CreateWalletPasswordRecovery = ({ onChangeMethod, }) => {
|
|
|
12670
12641
|
setRecoveryError(error.message || 'There was an error recovering your account');
|
|
12671
12642
|
}
|
|
12672
12643
|
else {
|
|
12673
|
-
log('Recovery success');
|
|
12644
|
+
logger.log('Recovery success');
|
|
12674
12645
|
}
|
|
12675
12646
|
};
|
|
12676
12647
|
useEffect(() => {
|
|
@@ -12740,6 +12711,10 @@ const SelectWalletButton = ({ wallet, onSelect }) => {
|
|
|
12740
12711
|
};
|
|
12741
12712
|
const SelectWalletToRecover = ({ wallets }) => {
|
|
12742
12713
|
const [selectedWallet, setSelectedWallet] = useState(null);
|
|
12714
|
+
const { triggerResize } = useOpenfort();
|
|
12715
|
+
useEffect(() => {
|
|
12716
|
+
triggerResize();
|
|
12717
|
+
}, [selectedWallet]);
|
|
12743
12718
|
if (selectedWallet) {
|
|
12744
12719
|
return jsx(RecoverWallet, { wallet: selectedWallet });
|
|
12745
12720
|
}
|
|
@@ -12778,7 +12753,7 @@ const Connected = () => {
|
|
|
12778
12753
|
};
|
|
12779
12754
|
const RecoverPage = () => {
|
|
12780
12755
|
const { user } = useOpenfortCore();
|
|
12781
|
-
const { triggerResize } = useOpenfort();
|
|
12756
|
+
const { triggerResize, uiConfig, walletConfig, setRoute } = useOpenfort();
|
|
12782
12757
|
const { wallets, isLoadingWallets } = useWallets();
|
|
12783
12758
|
// const [loading, setLoading] = useState(true);
|
|
12784
12759
|
const [embeddedSignerLoading, setEmbeddedSignerLoading] = useState(true);
|
|
@@ -12798,21 +12773,21 @@ const RecoverPage = () => {
|
|
|
12798
12773
|
const openfortWallets = useMemo(() => {
|
|
12799
12774
|
return wallets.filter((wallet) => wallet.id === embeddedWalletId);
|
|
12800
12775
|
}, [wallets]);
|
|
12801
|
-
|
|
12802
|
-
|
|
12803
|
-
|
|
12804
|
-
|
|
12805
|
-
|
|
12806
|
-
|
|
12807
|
-
|
|
12808
|
-
|
|
12809
|
-
|
|
12810
|
-
|
|
12811
|
-
|
|
12812
|
-
|
|
12813
|
-
|
|
12814
|
-
|
|
12815
|
-
|
|
12776
|
+
useEffect(() => {
|
|
12777
|
+
if (!user)
|
|
12778
|
+
return;
|
|
12779
|
+
if (uiConfig.linkWalletOnSignUp || !walletConfig) {
|
|
12780
|
+
if (!user.linkedAccounts.find((account) => account.provider === 'wallet')) {
|
|
12781
|
+
setRoute(routes.CONNECTORS);
|
|
12782
|
+
return;
|
|
12783
|
+
}
|
|
12784
|
+
if (!walletConfig) {
|
|
12785
|
+
// Logged in without a wallet
|
|
12786
|
+
setRoute(routes.PROFILE);
|
|
12787
|
+
return;
|
|
12788
|
+
}
|
|
12789
|
+
}
|
|
12790
|
+
}, [user]);
|
|
12816
12791
|
if (embeddedSignerLoading) {
|
|
12817
12792
|
return (jsx(PageContent, { children: jsx(Loader, { header: "Setting up wallet" }) }));
|
|
12818
12793
|
}
|
|
@@ -12878,7 +12853,6 @@ const createSIWEMessage = (address, nonce, chainId) => createSiweMessage({
|
|
|
12878
12853
|
// If there is a user already, it will link the wallet to the user
|
|
12879
12854
|
function useConnectWithSiwe() {
|
|
12880
12855
|
const { client, user, updateUser } = useOpenfortCore();
|
|
12881
|
-
const { log } = useOpenfort();
|
|
12882
12856
|
const { address, connector, chainId: accountChainId } = useAccount();
|
|
12883
12857
|
const chainId = useChainId();
|
|
12884
12858
|
const config = useConfig();
|
|
@@ -12888,7 +12862,7 @@ function useConnectWithSiwe() {
|
|
|
12888
12862
|
const connectorType = propsConnectorType !== null && propsConnectorType !== void 0 ? propsConnectorType : connector === null || connector === void 0 ? void 0 : connector.type;
|
|
12889
12863
|
const walletClientType = propsWalletClientType !== null && propsWalletClientType !== void 0 ? propsWalletClientType : connector === null || connector === void 0 ? void 0 : connector.id;
|
|
12890
12864
|
if (!address || !connectorType || !walletClientType) {
|
|
12891
|
-
log('No address found', { address, connectorType, walletClientType });
|
|
12865
|
+
logger.log('No address found', { address, connectorType, walletClientType });
|
|
12892
12866
|
onError === null || onError === void 0 ? void 0 : onError('No address found');
|
|
12893
12867
|
return;
|
|
12894
12868
|
}
|
|
@@ -12906,7 +12880,7 @@ function useConnectWithSiwe() {
|
|
|
12906
12880
|
const authToken = await client.getAccessToken();
|
|
12907
12881
|
if (!authToken)
|
|
12908
12882
|
throw new Error('No access token found');
|
|
12909
|
-
log('Linking wallet', { signature, message: SIWEMessage, connectorType, walletClientType, authToken });
|
|
12883
|
+
logger.log('Linking wallet', { signature, message: SIWEMessage, connectorType, walletClientType, authToken });
|
|
12910
12884
|
await client.auth.linkWallet({
|
|
12911
12885
|
signature,
|
|
12912
12886
|
message: SIWEMessage,
|
|
@@ -12925,7 +12899,7 @@ function useConnectWithSiwe() {
|
|
|
12925
12899
|
onConnect === null || onConnect === void 0 ? void 0 : onConnect();
|
|
12926
12900
|
}
|
|
12927
12901
|
catch (err) {
|
|
12928
|
-
log('Failed to connect with SIWE', err);
|
|
12902
|
+
logger.log('Failed to connect with SIWE', err);
|
|
12929
12903
|
if (!onError)
|
|
12930
12904
|
return;
|
|
12931
12905
|
let message = err instanceof Error ? err.message : err instanceof AxiosError ? err.message : String(err);
|
|
@@ -12943,7 +12917,7 @@ function useConnectWithSiwe() {
|
|
|
12943
12917
|
}
|
|
12944
12918
|
onError(message, err instanceof AxiosError ? err.request.status : undefined);
|
|
12945
12919
|
}
|
|
12946
|
-
}, [client, user, updateUser,
|
|
12920
|
+
}, [client, user, updateUser, address, chainId, config, connector, accountChainId, publicClient]);
|
|
12947
12921
|
return connectWithSiwe;
|
|
12948
12922
|
}
|
|
12949
12923
|
|
|
@@ -13154,7 +13128,7 @@ const contentVariants = {
|
|
|
13154
13128
|
const ConnectWithInjector = ({ switchConnectMethod, forceState }) => {
|
|
13155
13129
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
13156
13130
|
const openfort = useOpenfortCore();
|
|
13157
|
-
const {
|
|
13131
|
+
const { setOpen } = useOpenfort();
|
|
13158
13132
|
const { isConnected } = useAccount();
|
|
13159
13133
|
const { disconnect } = useDisconnect();
|
|
13160
13134
|
const connectWithSiwe = useConnectWithSiwe();
|
|
@@ -13173,7 +13147,7 @@ const ConnectWithInjector = ({ switchConnectMethod, forceState }) => {
|
|
|
13173
13147
|
},
|
|
13174
13148
|
onSettled(data, error) {
|
|
13175
13149
|
var _a;
|
|
13176
|
-
log(`onSettled - data: ${data}, error: ${error}`, data);
|
|
13150
|
+
logger.log(`onSettled - data: ${data}, error: ${error}`, data);
|
|
13177
13151
|
if (error) {
|
|
13178
13152
|
setShowTryAgainTooltip(true);
|
|
13179
13153
|
setTimeout(() => setShowTryAgainTooltip(false), 3500);
|
|
@@ -13343,7 +13317,7 @@ const states$2 = {
|
|
|
13343
13317
|
ERROR: 'error',
|
|
13344
13318
|
};
|
|
13345
13319
|
const ConnectWithOAuth = () => {
|
|
13346
|
-
const { connector, setRoute
|
|
13320
|
+
const { connector, setRoute } = useOpenfort();
|
|
13347
13321
|
const { client, user } = useOpenfortCore();
|
|
13348
13322
|
const [status, setStatus] = useState(states$2.INIT);
|
|
13349
13323
|
const [description, setDescription] = useState(undefined);
|
|
@@ -13403,7 +13377,7 @@ const ConnectWithOAuth = () => {
|
|
|
13403
13377
|
queryParams,
|
|
13404
13378
|
},
|
|
13405
13379
|
});
|
|
13406
|
-
log(linkResponse);
|
|
13380
|
+
logger.log(linkResponse);
|
|
13407
13381
|
window.location.href = linkResponse.url;
|
|
13408
13382
|
}
|
|
13409
13383
|
else {
|
|
@@ -13414,7 +13388,7 @@ const ConnectWithOAuth = () => {
|
|
|
13414
13388
|
queryParams,
|
|
13415
13389
|
},
|
|
13416
13390
|
});
|
|
13417
|
-
log(r);
|
|
13391
|
+
logger.log(r);
|
|
13418
13392
|
window.location.href = r.url;
|
|
13419
13393
|
}
|
|
13420
13394
|
}
|
|
@@ -13470,7 +13444,7 @@ const ScanIconWithLogos = ({ logo }) => {
|
|
|
13470
13444
|
};
|
|
13471
13445
|
|
|
13472
13446
|
const ConnectWithQRCode = ({ switchConnectMethod }) => {
|
|
13473
|
-
var _a, _b, _c, _d
|
|
13447
|
+
var _a, _b, _c, _d;
|
|
13474
13448
|
const context = useOpenfort();
|
|
13475
13449
|
const id = context.connector.id;
|
|
13476
13450
|
const wallet = useWallet(context.connector.id);
|
|
@@ -13483,7 +13457,7 @@ const ConnectWithQRCode = ({ switchConnectMethod }) => {
|
|
|
13483
13457
|
});
|
|
13484
13458
|
const connectWithSiwe = useConnectWithSiwe();
|
|
13485
13459
|
const { isConnected } = useAccount();
|
|
13486
|
-
const {
|
|
13460
|
+
const { setOpen } = useOpenfort();
|
|
13487
13461
|
const { disconnect } = useDisconnect();
|
|
13488
13462
|
const [isFirstFrame, setIsFirstFrame] = React.useState(true);
|
|
13489
13463
|
useEffect(() => {
|
|
@@ -13501,7 +13475,7 @@ const ConnectWithQRCode = ({ switchConnectMethod }) => {
|
|
|
13501
13475
|
// connectorType: 'walletConnect',
|
|
13502
13476
|
// walletClientType: 'walletConnect',
|
|
13503
13477
|
onError: (error) => {
|
|
13504
|
-
log(error);
|
|
13478
|
+
logger.log(error);
|
|
13505
13479
|
disconnect();
|
|
13506
13480
|
},
|
|
13507
13481
|
onConnect: () => {
|
|
@@ -13537,7 +13511,7 @@ const ConnectWithQRCode = ({ switchConnectMethod }) => {
|
|
|
13537
13511
|
alignItems: 'center',
|
|
13538
13512
|
justifyContent: 'center',
|
|
13539
13513
|
gap: 14,
|
|
13540
|
-
}, children: [
|
|
13514
|
+
}, children: [context.uiConfig.walletConnectCTA !== 'modal' && (jsx(CopyToClipboard, { variant: "button", string: uri, children: context.uiConfig.walletConnectCTA === 'link' ? locales.copyToClipboard : locales.copyCode })), context.uiConfig.walletConnectCTA !== 'link' && (jsx(Button, { icon: jsx(ExternalLinkIcon, {}), onClick: openW3M, disabled: isOpenW3M, waiting: isOpenW3M, children: context.uiConfig.walletConnectCTA === 'modal' ? locales.useWalletConnectModal : locales.useModal }))] })), isFamilyAccountsConnector(wallet.id) && (jsxs(Fragment, { children: [jsx(OrDivider, {}), jsx(Button, { onClick: () => switchConnectMethod(id), children: locales.loginWithEmailOrPhone })] })), hasApps && (jsx(Button, { onClick: () => {
|
|
13541
13515
|
context.setRoute(routes.DOWNLOAD);
|
|
13542
13516
|
},
|
|
13543
13517
|
/*
|
|
@@ -13565,7 +13539,7 @@ const ConnectUsing = () => {
|
|
|
13565
13539
|
const [status, setStatus] = useState(isQrCode ? states$1.QRCODE : states$1.INJECTOR);
|
|
13566
13540
|
useEffect(() => {
|
|
13567
13541
|
const connector = context.connector;
|
|
13568
|
-
|
|
13542
|
+
logger.log('ConnectUsing', { status, isQrCode, isOauth, connector });
|
|
13569
13543
|
if (isOauth)
|
|
13570
13544
|
return;
|
|
13571
13545
|
// if no provider, change to qrcode
|
|
@@ -13625,9 +13599,9 @@ const DownloadFooter = styled.div `
|
|
|
13625
13599
|
`;
|
|
13626
13600
|
const ConnectWithMobile = () => {
|
|
13627
13601
|
var _a, _b, _c;
|
|
13628
|
-
const { connector, setRoute
|
|
13602
|
+
const { connector, setRoute } = useOpenfort();
|
|
13629
13603
|
const walletId = Object.keys(walletConfigs).find(
|
|
13630
|
-
// where id is comma
|
|
13604
|
+
// where id is comma separated list
|
|
13631
13605
|
(id) => id
|
|
13632
13606
|
.split(',')
|
|
13633
13607
|
.map((i) => i.trim())
|
|
@@ -13643,7 +13617,7 @@ const ConnectWithMobile = () => {
|
|
|
13643
13617
|
const openApp = (url) => {
|
|
13644
13618
|
var _a;
|
|
13645
13619
|
const uri = (_a = wallet === null || wallet === void 0 ? void 0 : wallet.getWalletConnectDeeplink) === null || _a === void 0 ? void 0 : _a.call(wallet, url !== null && url !== void 0 ? url : '');
|
|
13646
|
-
log('Opening wallet app with uri', { uri, url, wallet, walletId, walletConfigs, connectorId: connector.id });
|
|
13620
|
+
logger.log('Opening wallet app with uri', { uri, url, wallet, walletId, walletConfigs, connectorId: connector.id });
|
|
13647
13621
|
if (uri) {
|
|
13648
13622
|
if (url) {
|
|
13649
13623
|
window.location.href = uri;
|
|
@@ -13706,13 +13680,12 @@ const ConnectWithMobile = () => {
|
|
|
13706
13680
|
|
|
13707
13681
|
const customThemeDefault = {};
|
|
13708
13682
|
const ConnectModal = ({ mode = 'auto', theme = 'auto', customTheme = customThemeDefault, lang = 'en-US' }) => {
|
|
13709
|
-
var _a;
|
|
13710
13683
|
const context = useOpenfort();
|
|
13711
13684
|
const { logout, user } = useOpenfortCore();
|
|
13712
13685
|
const { isConnected, chain } = useAccount();
|
|
13713
13686
|
const chainIsSupported = useChainIsSupported(chain === null || chain === void 0 ? void 0 : chain.id);
|
|
13714
13687
|
//if chain is unsupported we enforce a "switch chain" prompt
|
|
13715
|
-
const closeable = !(
|
|
13688
|
+
const closeable = !(context.uiConfig.enforceSupportedChains && isConnected && !chainIsSupported);
|
|
13716
13689
|
const mainRoutes = [
|
|
13717
13690
|
routes.PROFILE,
|
|
13718
13691
|
routes.LOADING,
|
|
@@ -13772,7 +13745,7 @@ const ConnectModal = ({ mode = 'auto', theme = 'auto', customTheme = customTheme
|
|
|
13772
13745
|
const provider = url.searchParams.get('openfortAuthProviderUI');
|
|
13773
13746
|
const emailVerification = url.searchParams.get('openfortEmailVerificationUI');
|
|
13774
13747
|
const forgotPassword = url.searchParams.get('openfortForgotPasswordUI');
|
|
13775
|
-
|
|
13748
|
+
logger.log('Checking for search parameters', url);
|
|
13776
13749
|
if (emailVerification) {
|
|
13777
13750
|
context.setOpen(true);
|
|
13778
13751
|
context.setRoute(routes.EMAIL_VERIFICATION);
|
|
@@ -13789,7 +13762,7 @@ const ConnectModal = ({ mode = 'auto', theme = 'auto', customTheme = customTheme
|
|
|
13789
13762
|
return Object.values(OAuthProvider).includes(value);
|
|
13790
13763
|
}
|
|
13791
13764
|
if (isProvider(provider)) {
|
|
13792
|
-
|
|
13765
|
+
logger.log('Found auth provider', provider);
|
|
13793
13766
|
context.setOpen(true);
|
|
13794
13767
|
context.setConnector({ id: provider, type: 'oauth' });
|
|
13795
13768
|
context.setRoute(routes.CONNECT);
|
|
@@ -13859,7 +13832,7 @@ const ConnectModal = ({ mode = 'auto', theme = 'auto', customTheme = customTheme
|
|
|
13859
13832
|
* ```
|
|
13860
13833
|
*/
|
|
13861
13834
|
const OpenfortProvider = ({ children, uiConfig, onConnect, onDisconnect, debugMode = false, publishableKey, walletConfig, overrides, thirdPartyAuth, }) => {
|
|
13862
|
-
var _a, _b, _c, _d, _e
|
|
13835
|
+
var _a, _b, _c, _d, _e;
|
|
13863
13836
|
// OpenfortProvider must be within a WagmiProvider
|
|
13864
13837
|
if (!React.useContext(WagmiContext)) {
|
|
13865
13838
|
throw Error('OpenfortProvider must be within a WagmiProvider');
|
|
@@ -13872,7 +13845,6 @@ const OpenfortProvider = ({ children, uiConfig, onConnect, onDisconnect, debugMo
|
|
|
13872
13845
|
useMemo(() => {
|
|
13873
13846
|
logger.enabled = !!debugMode;
|
|
13874
13847
|
}, []);
|
|
13875
|
-
const chains = useChains();
|
|
13876
13848
|
const injectedConnector = useConnector('injected');
|
|
13877
13849
|
const allowAutomaticRecovery = !!((walletConfig === null || walletConfig === void 0 ? void 0 : walletConfig.createEncryptedSessionEndpoint) || (walletConfig === null || walletConfig === void 0 ? void 0 : walletConfig.getEncryptionSession));
|
|
13878
13850
|
// Default config options
|
|
@@ -13894,7 +13866,6 @@ const OpenfortProvider = ({ children, uiConfig, onConnect, onDisconnect, debugMo
|
|
|
13894
13866
|
disclaimer: null,
|
|
13895
13867
|
bufferPolyfill: true,
|
|
13896
13868
|
customAvatar: undefined,
|
|
13897
|
-
initialChainId: (_a = chains === null || chains === void 0 ? void 0 : chains[0]) === null || _a === void 0 ? void 0 : _a.id,
|
|
13898
13869
|
enforceSupportedChains: false,
|
|
13899
13870
|
ethereumOnboardingUrl: undefined,
|
|
13900
13871
|
walletOnboardingUrl: undefined,
|
|
@@ -13919,7 +13890,7 @@ const OpenfortProvider = ({ children, uiConfig, onConnect, onDisconnect, debugMo
|
|
|
13919
13890
|
if (typeof window !== 'undefined') {
|
|
13920
13891
|
// Buffer Polyfill, needed for bundlers that don't provide Node polyfills (e.g CRA, Vite, etc.)
|
|
13921
13892
|
if (safeUiConfig.bufferPolyfill)
|
|
13922
|
-
window.Buffer = (
|
|
13893
|
+
window.Buffer = (_a = window.Buffer) !== null && _a !== void 0 ? _a : Buffer;
|
|
13923
13894
|
// Some bundlers may need `global` and `process.env` polyfills as well
|
|
13924
13895
|
// Not implemented here to avoid unexpected behaviors, but leaving example here for future reference
|
|
13925
13896
|
/*
|
|
@@ -13927,9 +13898,9 @@ const OpenfortProvider = ({ children, uiConfig, onConnect, onDisconnect, debugMo
|
|
|
13927
13898
|
* window.process = window.process ?? { env: {} };
|
|
13928
13899
|
*/
|
|
13929
13900
|
}
|
|
13930
|
-
const [ckTheme, setTheme] = useState((
|
|
13931
|
-
const [ckMode, setMode] = useState((
|
|
13932
|
-
const [ckCustomTheme, setCustomTheme] = useState((
|
|
13901
|
+
const [ckTheme, setTheme] = useState((_b = safeUiConfig.theme) !== null && _b !== void 0 ? _b : 'auto');
|
|
13902
|
+
const [ckMode, setMode] = useState((_c = safeUiConfig.mode) !== null && _c !== void 0 ? _c : 'auto');
|
|
13903
|
+
const [ckCustomTheme, setCustomTheme] = useState((_d = safeUiConfig.customTheme) !== null && _d !== void 0 ? _d : {});
|
|
13933
13904
|
const [ckLang, setLang] = useState('en-US');
|
|
13934
13905
|
const [open, setOpen] = useState(false);
|
|
13935
13906
|
const [connector, setConnector] = useState({
|
|
@@ -13942,9 +13913,9 @@ const OpenfortProvider = ({ children, uiConfig, onConnect, onDisconnect, debugMo
|
|
|
13942
13913
|
// Include Google Font that is needed for a themes
|
|
13943
13914
|
useThemeFont(safeUiConfig.embedGoogleFonts ? ckTheme : '');
|
|
13944
13915
|
// Other Configuration
|
|
13945
|
-
useEffect(() => { var _a; return setTheme((_a =
|
|
13946
|
-
useEffect(() => { var _a; return setMode((_a =
|
|
13947
|
-
useEffect(() => { var _a; return setCustomTheme((_a =
|
|
13916
|
+
useEffect(() => { var _a; return setTheme((_a = safeUiConfig.theme) !== null && _a !== void 0 ? _a : 'auto'); }, [safeUiConfig.theme]);
|
|
13917
|
+
useEffect(() => { var _a; return setMode((_a = safeUiConfig.mode) !== null && _a !== void 0 ? _a : 'auto'); }, [safeUiConfig.mode]);
|
|
13918
|
+
useEffect(() => { var _a; return setCustomTheme((_a = safeUiConfig.customTheme) !== null && _a !== void 0 ? _a : {}); }, [safeUiConfig.customTheme]);
|
|
13948
13919
|
useEffect(() => setLang(safeUiConfig.language || 'en-US'), [safeUiConfig.language]);
|
|
13949
13920
|
useEffect(() => setErrorMessage(null), [route, open]);
|
|
13950
13921
|
// Check if chain is supported, elsewise redirect to switches page
|
|
@@ -13984,16 +13955,8 @@ const OpenfortProvider = ({ children, uiConfig, onConnect, onDisconnect, debugMo
|
|
|
13984
13955
|
uiConfig: safeUiConfig,
|
|
13985
13956
|
errorMessage,
|
|
13986
13957
|
debugMode,
|
|
13987
|
-
log: logger.log,
|
|
13988
13958
|
emailInput,
|
|
13989
13959
|
setEmailInput,
|
|
13990
|
-
displayError: (message, code) => {
|
|
13991
|
-
setErrorMessage(message);
|
|
13992
|
-
logger.log('---------OPENFORT DEBUG---------');
|
|
13993
|
-
logger.log(message);
|
|
13994
|
-
if (code)
|
|
13995
|
-
logger.log('---------/OPENFORT DEBUG---------');
|
|
13996
|
-
},
|
|
13997
13960
|
resize,
|
|
13998
13961
|
triggerResize: () => onResize((prev) => prev + 1),
|
|
13999
13962
|
walletConfig,
|
|
@@ -14007,7 +13970,7 @@ const OpenfortProvider = ({ children, uiConfig, onConnect, onDisconnect, debugMo
|
|
|
14007
13970
|
shieldPublishableKey: walletConfig.shieldPublishableKey,
|
|
14008
13971
|
debug: debugMode,
|
|
14009
13972
|
}
|
|
14010
|
-
: undefined, overrides: overrides, thirdPartyAuth: thirdPartyAuth, onConnect: onConnect, onDisconnect: onDisconnect, children: [children, jsx(ConnectModal, { lang: ckLang, theme: ckTheme, mode: (
|
|
13973
|
+
: undefined, overrides: overrides, thirdPartyAuth: thirdPartyAuth, onConnect: onConnect, onDisconnect: onDisconnect, children: [children, jsx(ConnectModal, { lang: ckLang, theme: ckTheme, mode: (_e = safeUiConfig.mode) !== null && _e !== void 0 ? _e : ckMode, customTheme: ckCustomTheme })] }) }));
|
|
14011
13974
|
};
|
|
14012
13975
|
|
|
14013
13976
|
/**
|
|
@@ -14283,7 +14246,6 @@ const useOAuth = (hookOptions = {}) => {
|
|
|
14283
14246
|
*/
|
|
14284
14247
|
const useAuthCallback = ({ enabled = true, // Automatically handle OAuth and email callback
|
|
14285
14248
|
...hookOptions } = {}) => {
|
|
14286
|
-
const { log } = useOpenfort();
|
|
14287
14249
|
const [provider, setProvider] = useState(null);
|
|
14288
14250
|
const [email, setEmail] = useState(null);
|
|
14289
14251
|
const { verifyEmail, isSuccess: isEmailSuccess, isLoading: isEmailLoading, isError: isEmailError, error: emailError, } = useEmailAuth();
|
|
@@ -14320,7 +14282,7 @@ const useAuthCallback = ({ enabled = true, // Automatically handle OAuth and ema
|
|
|
14320
14282
|
});
|
|
14321
14283
|
window.history.replaceState({}, document.title, url.toString());
|
|
14322
14284
|
};
|
|
14323
|
-
log('EmailVerification', state, email);
|
|
14285
|
+
logger.log('EmailVerification', state, email);
|
|
14324
14286
|
const options = {
|
|
14325
14287
|
onSuccess: (data) => {
|
|
14326
14288
|
var _a;
|
|
@@ -14367,7 +14329,7 @@ const useAuthCallback = ({ enabled = true, // Automatically handle OAuth and ema
|
|
|
14367
14329
|
});
|
|
14368
14330
|
window.history.replaceState({}, document.title, url.toString());
|
|
14369
14331
|
};
|
|
14370
|
-
log('callback', { player, accessToken, refreshToken });
|
|
14332
|
+
logger.log('callback', { player, accessToken, refreshToken });
|
|
14371
14333
|
const options = {
|
|
14372
14334
|
onSuccess: (data) => {
|
|
14373
14335
|
var _a;
|
|
@@ -14513,7 +14475,6 @@ const useGuestAuth = (hookOptions = {}) => {
|
|
|
14513
14475
|
|
|
14514
14476
|
const useWalletAuth = (hookOptions = {}) => {
|
|
14515
14477
|
const { updateUser } = useOpenfortCore();
|
|
14516
|
-
const { log } = useOpenfort();
|
|
14517
14478
|
const siwe = useConnectWithSiwe();
|
|
14518
14479
|
const availableWallets = useWallets$1(); // TODO: Use this to get the wallet client type
|
|
14519
14480
|
const { disconnect } = useDisconnect();
|
|
@@ -14553,7 +14514,7 @@ const useWalletAuth = (hookOptions = {}) => {
|
|
|
14553
14514
|
setShouldConnectWithSiwe(false);
|
|
14554
14515
|
siwe({
|
|
14555
14516
|
onError: (e) => {
|
|
14556
|
-
log('Error connecting with SIWE', e);
|
|
14517
|
+
logger.log('Error connecting with SIWE', e);
|
|
14557
14518
|
disconnect();
|
|
14558
14519
|
const error = new OpenfortError('Failed to connect with siwe', OpenfortErrorType.AUTHENTICATION_ERROR, {
|
|
14559
14520
|
error: e,
|
|
@@ -14561,7 +14522,7 @@ const useWalletAuth = (hookOptions = {}) => {
|
|
|
14561
14522
|
handleError(error);
|
|
14562
14523
|
},
|
|
14563
14524
|
onConnect: () => {
|
|
14564
|
-
log('Successfully connected with SIWE');
|
|
14525
|
+
logger.log('Successfully connected with SIWE');
|
|
14565
14526
|
setStatus({
|
|
14566
14527
|
status: 'success',
|
|
14567
14528
|
});
|
|
@@ -14572,7 +14533,7 @@ const useWalletAuth = (hookOptions = {}) => {
|
|
|
14572
14533
|
});
|
|
14573
14534
|
},
|
|
14574
14535
|
});
|
|
14575
|
-
}, [shouldConnectWithSiwe, siwe, updateUser
|
|
14536
|
+
}, [shouldConnectWithSiwe, siwe, updateUser]);
|
|
14576
14537
|
// const generateSiweMessage = useCallback(
|
|
14577
14538
|
// async (args) => {
|
|
14578
14539
|
// try {
|
|
@@ -14657,7 +14618,7 @@ const useWalletAuth = (hookOptions = {}) => {
|
|
|
14657
14618
|
connector = options.connector;
|
|
14658
14619
|
}
|
|
14659
14620
|
if (!connector) {
|
|
14660
|
-
log('Connector not found', connector);
|
|
14621
|
+
logger.log('Connector not found', connector);
|
|
14661
14622
|
return handleError(new OpenfortError('Connector not found', OpenfortErrorType.AUTHENTICATION_ERROR));
|
|
14662
14623
|
}
|
|
14663
14624
|
setWalletConnectingTo(connector.id);
|
|
@@ -14681,13 +14642,13 @@ const useWalletAuth = (hookOptions = {}) => {
|
|
|
14681
14642
|
await connectAsync({
|
|
14682
14643
|
connector,
|
|
14683
14644
|
});
|
|
14684
|
-
log('Connected to wallet!!!', connector.id);
|
|
14645
|
+
logger.log('Connected to wallet!!!', connector.id);
|
|
14685
14646
|
}
|
|
14686
14647
|
catch (error) {
|
|
14687
14648
|
logger.error('Error connecting', error);
|
|
14688
14649
|
handleError(new OpenfortError('Failed to connect', OpenfortErrorType.AUTHENTICATION_ERROR, { error }));
|
|
14689
14650
|
}
|
|
14690
|
-
}, [siwe, disconnect, updateUser, availableWallets,
|
|
14651
|
+
}, [siwe, disconnect, updateUser, availableWallets, setStatus, hookOptions]);
|
|
14691
14652
|
return {
|
|
14692
14653
|
walletConnectingTo,
|
|
14693
14654
|
connectWallet,
|