@openfort/react 1.0.1 → 1.0.3

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.
@@ -9,12 +9,14 @@ import { CoreOpenfortProvider } from '../../openfort/CoreOpenfortProvider.js';
9
9
  import { logger } from '../../utils/logger.js';
10
10
  import { buildChainFromConfig } from '../../utils/rpc.js';
11
11
  import { isFamily } from '../../utils/wallets.js';
12
- import { EmbeddedWalletWagmiSync } from '../../wagmi/useEmbeddedWalletWagmiSync.js';
13
12
  import { OpenfortContext, UIContext } from './context.js';
14
13
  import { UIAuthProvider, routes, defaultSendFormState, defaultBuyFormState, notStoredInHistoryRoutes } from './types.js';
15
14
 
16
- const SolanaContextProvider = lazy(() => import('../../solana/SolanaContext.js').then((m) => ({ default: m.SolanaContextProvider })));
17
- const LazyConnectKitModal = lazy(() => import('../ConnectModal/index.js'));
15
+ const SolanaContextProvider = lazy(() => import(/* @vite-ignore */ '../../solana/SolanaContext.js').then((m) => ({ default: m.SolanaContextProvider })));
16
+ const LazyEmbeddedWalletWagmiSync = lazy(() => import(/* @vite-ignore */ '../../wagmi/useEmbeddedWalletWagmiSync.js').then((m) => ({
17
+ default: m.EmbeddedWalletWagmiSync,
18
+ })));
19
+ const LazyConnectKitModal = lazy(() => import(/* @vite-ignore */ '../ConnectModal/index.js'));
18
20
  let openfortProviderWarnedNoWagmi = false;
19
21
  /**
20
22
  * Root provider for Openfort. Wrap your app with this to enable connect modal, auth, and wallet features.
@@ -92,8 +94,8 @@ const OpenfortProvider = ({ children, uiConfig, onConnect, onDisconnect, debugMo
92
94
  defaultMethod: allowAutomaticRecovery ? RecoveryMethod.AUTOMATIC : RecoveryMethod.PASSWORD,
93
95
  },
94
96
  authProviders: hasWagmi
95
- ? [UIAuthProvider.GUEST, UIAuthProvider.EMAIL_OTP, UIAuthProvider.WALLET]
96
- : [UIAuthProvider.GUEST, UIAuthProvider.EMAIL_OTP],
97
+ ? [UIAuthProvider.GUEST, UIAuthProvider.EMAIL_OTP, UIAuthProvider.WALLET, UIAuthProvider.GOOGLE]
98
+ : [UIAuthProvider.GUEST, UIAuthProvider.EMAIL_OTP, UIAuthProvider.GOOGLE],
97
99
  }), [allowAutomaticRecovery, hasWagmi]);
98
100
  const safeUiConfig = useMemo(() => {
99
101
  var _a, _b, _c, _d, _e;
@@ -318,7 +320,7 @@ const OpenfortProvider = ({ children, uiConfig, onConnect, onDisconnect, debugMo
318
320
  setBuyForm,
319
321
  triggerResize,
320
322
  ]);
321
- const innerChildren = (jsxs(Fragment, { children: [hasWagmi && jsx(EmbeddedWalletWagmiSync, {}), debugModeOptions.debugRoutes && (jsx("pre", { style: {
323
+ const innerChildren = (jsxs(Fragment, { children: [hasWagmi && (jsx(Suspense, { fallback: null, children: jsx(LazyEmbeddedWalletWagmiSync, {}) })), debugModeOptions.debugRoutes && (jsx("pre", { style: {
322
324
  position: 'absolute',
323
325
  top: 0,
324
326
  left: 0,
@@ -1 +1 @@
1
- {"version":3,"file":"OpenfortProvider.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"OpenfortProvider.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,10 +1,9 @@
1
1
  import { jsx, jsxs } from 'react/jsx-runtime';
2
- import { RecoveryMethod, EmbeddedState } from '@openfort/openfort-js';
2
+ import { RecoveryMethod } from '@openfort/openfort-js';
3
3
  import { motion } from 'framer-motion';
4
4
  import { useState, useEffect, useCallback, useMemo } from 'react';
5
5
  import { PhoneIcon, EmailIcon, FingerPrintIcon, KeyIcon, LockIcon } from '../../../assets/icons.js';
6
6
  import { OpenfortError } from '../../../types.js';
7
- import { useOpenfortCore } from '../../../openfort/useOpenfort.js';
8
7
  import { useRecoveryOTP } from '../../../shared/hooks/useRecoveryOTP.js';
9
8
  import { handleOtpRecoveryError } from '../../../shared/utils/otpError.js';
10
9
  import { useSolanaEmbeddedWallet } from '../../../solana/hooks/useSolanaEmbeddedWallet.js';
@@ -55,7 +54,6 @@ const OtherMethod = ({ currentMethod, onChangeMethod, }) => {
55
54
  };
56
55
  const SolanaCreateAutomatic = ({ onBack, logoutOnBack }) => {
57
56
  var _a;
58
- const { embeddedState } = useOpenfortCore();
59
57
  const { setRoute, triggerResize } = useOpenfort();
60
58
  const embeddedWallet = useSolanaEmbeddedWallet();
61
59
  const { isEnabled: isWalletRecoveryOTPEnabled, requestOTP } = useRecoveryOTP();
@@ -115,11 +113,12 @@ const SolanaCreateAutomatic = ({ onBack, logoutOnBack }) => {
115
113
  })();
116
114
  }, [shouldCreate]);
117
115
  const [canSendOtp, setCanSendOtp] = useState(true);
116
+ // Trigger creation on mount. We only land here when no Solana wallet exists.
117
+ // Don't gate on embeddedState — the user may have an EVM wallet (embeddedState=READY)
118
+ // but still need a Solana wallet.
118
119
  useEffect(() => {
119
- if (embeddedState === EmbeddedState.EMBEDDED_SIGNER_NOT_CONFIGURED) {
120
- setShouldCreate(true);
121
- }
122
- }, [embeddedState]);
120
+ setShouldCreate(true);
121
+ }, []);
123
122
  const handleResendClick = useCallback(() => {
124
123
  setOtpStatus('send-otp');
125
124
  setCanSendOtp(false);
@@ -145,7 +144,6 @@ const SolanaCreateAutomatic = ({ onBack, logoutOnBack }) => {
145
144
  const SolanaCreatePasskey = ({ onChangeMethod, onBack, logoutOnBack, }) => {
146
145
  const { triggerResize, setRoute } = useOpenfort();
147
146
  const embeddedWallet = useSolanaEmbeddedWallet();
148
- const { embeddedState } = useOpenfortCore();
149
147
  const [shouldCreate, setShouldCreate] = useState(false);
150
148
  const [recoveryError, setRecoveryError] = useState(null);
151
149
  useEffect(() => {
@@ -164,11 +162,12 @@ const SolanaCreatePasskey = ({ onChangeMethod, onBack, logoutOnBack, }) => {
164
162
  }
165
163
  })();
166
164
  }, [shouldCreate]);
165
+ // Trigger creation on mount. We only land here when no Solana wallet exists.
166
+ // Don't gate on embeddedState — the user may have an EVM wallet (embeddedState=READY)
167
+ // but still need a Solana wallet.
167
168
  useEffect(() => {
168
- if (embeddedState === EmbeddedState.EMBEDDED_SIGNER_NOT_CONFIGURED) {
169
- setShouldCreate(true);
170
- }
171
- }, [embeddedState]);
169
+ setShouldCreate(true);
170
+ }, []);
172
171
  useEffect(() => {
173
172
  if (recoveryError)
174
173
  triggerResize();
@@ -1 +1 @@
1
- {"version":3,"file":"SolanaCreateWallet.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"SolanaCreateWallet.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,7 +1,7 @@
1
1
  import { jsx, jsxs } from 'react/jsx-runtime';
2
2
  import { ChainTypeEnum, RecoveryMethod, EmbeddedState } from '@openfort/openfort-js';
3
3
  import { motion } from 'framer-motion';
4
- import { useEffect, useState, useCallback, useMemo } from 'react';
4
+ import { useEffect, useState, useRef, useCallback, useMemo } from 'react';
5
5
  import { PlusIcon, PhoneIcon, EmailIcon, FingerPrintIcon, KeyIcon, ShieldIcon, LockIcon } from '../../../assets/icons.js';
6
6
  import Logos from '../../../assets/logos.js';
7
7
  import { OpenfortError } from '../../../types.js';
@@ -64,15 +64,17 @@ const OtherMethod = ({ currentMethod, onChangeMethod, }) => {
64
64
  const CreateWalletAutomaticRecovery = ({ onBack, logoutOnBack, }) => {
65
65
  var _a;
66
66
  const { embeddedState } = useOpenfortCore();
67
- const { setRoute, triggerResize } = useOpenfort();
67
+ const { setRoute, triggerResize, walletConfig } = useOpenfort();
68
68
  const [recoveryError, setRecoveryError] = useState(null);
69
69
  const { create } = useEthereumEmbeddedWallet();
70
70
  const { isEnabled: isWalletRecoveryOTPEnabled, requestOTP } = useRecoveryOTP();
71
71
  const [shouldCreateWallet, setShouldCreateWallet] = useState(false);
72
+ const isCreatingRef = useRef(false);
72
73
  const [needsOTP, setNeedsOTP] = useState(false);
73
74
  const [otpResponse, setOtpResponse] = useState(null);
74
75
  const [otpStatus, setOtpStatus] = useState('idle');
75
76
  const [error, setError] = useState(false);
77
+ const [canSendOtp, setCanSendOtp] = useState(true);
76
78
  const handleCompleteOtp = async (otp) => {
77
79
  setOtpStatus('loading');
78
80
  try {
@@ -96,13 +98,18 @@ const CreateWalletAutomaticRecovery = ({ onBack, logoutOnBack, }) => {
96
98
  useEffect(() => {
97
99
  if (!shouldCreateWallet)
98
100
  return;
101
+ if (isCreatingRef.current)
102
+ return;
103
+ isCreatingRef.current = true;
99
104
  (async () => {
100
105
  logger.log('Creating wallet Automatic recover');
101
106
  try {
102
107
  await create({ recoveryMethod: RecoveryMethod.AUTOMATIC });
108
+ setShouldCreateWallet(false);
103
109
  setRoute(routes.CONNECTED_SUCCESS);
104
110
  }
105
111
  catch (err) {
112
+ setShouldCreateWallet(false);
106
113
  const { error, isOTPRequired } = handleOtpRecoveryError(err, isWalletRecoveryOTPEnabled);
107
114
  if (isOTPRequired && isWalletRecoveryOTPEnabled) {
108
115
  try {
@@ -120,15 +127,19 @@ const CreateWalletAutomaticRecovery = ({ onBack, logoutOnBack, }) => {
120
127
  setRecoveryError(error);
121
128
  }
122
129
  }
130
+ finally {
131
+ isCreatingRef.current = false;
132
+ }
123
133
  triggerResize();
124
134
  })();
125
135
  }, [shouldCreateWallet, create, isWalletRecoveryOTPEnabled, requestOTP, triggerResize]);
126
- const [canSendOtp, setCanSendOtp] = useState(true);
127
136
  useEffect(() => {
128
- if (embeddedState === EmbeddedState.EMBEDDED_SIGNER_NOT_CONFIGURED) {
129
- setShouldCreateWallet(true);
130
- }
131
- }, [embeddedState]);
137
+ if (embeddedState !== EmbeddedState.EMBEDDED_SIGNER_NOT_CONFIGURED)
138
+ return;
139
+ if ((walletConfig === null || walletConfig === void 0 ? void 0 : walletConfig.connectOnLogin) === false)
140
+ return;
141
+ setShouldCreateWallet(true);
142
+ }, [embeddedState, walletConfig === null || walletConfig === void 0 ? void 0 : walletConfig.connectOnLogin]);
132
143
  const handleResendClick = useCallback(() => {
133
144
  setOtpStatus('send-otp');
134
145
  setCanSendOtp(false);
@@ -152,18 +163,23 @@ const CreateWalletAutomaticRecovery = ({ onBack, logoutOnBack, }) => {
152
163
  return (jsx(PageContent, { onBack: onBack, logoutOnBack: logoutOnBack, children: jsx(Loader, { isError: !!recoveryError, header: recoveryError ? 'Error creating wallet.' : `Creating wallet...`, description: recoveryError ? recoveryError.message : undefined }) }));
153
164
  };
154
165
  const CreateWalletPasskeyRecovery = ({ onChangeMethod, onBack, logoutOnBack, }) => {
155
- const { triggerResize, setRoute } = useOpenfort();
166
+ const { triggerResize, setRoute, walletConfig } = useOpenfort();
156
167
  const { create } = useEthereumEmbeddedWallet();
157
168
  const [shouldCreateWallet, setShouldCreateWallet] = useState(false);
169
+ const isCreatingRef = useRef(false);
158
170
  const [recoveryError, setRecoveryError] = useState(null);
159
171
  const { embeddedState } = useOpenfortCore();
160
172
  useEffect(() => {
161
173
  if (!shouldCreateWallet)
162
174
  return;
175
+ if (isCreatingRef.current)
176
+ return;
177
+ isCreatingRef.current = true;
163
178
  (async () => {
164
179
  logger.log('Creating wallet passkey recovery');
165
180
  try {
166
181
  await create({ recoveryMethod: RecoveryMethod.PASSKEY });
182
+ setShouldCreateWallet(false);
167
183
  setRoute(routes.CONNECTED_SUCCESS);
168
184
  }
169
185
  catch (err) {
@@ -171,13 +187,18 @@ const CreateWalletPasskeyRecovery = ({ onChangeMethod, onBack, logoutOnBack, })
171
187
  setRecoveryError(new Error('Failed to create wallet'));
172
188
  setShouldCreateWallet(false);
173
189
  }
190
+ finally {
191
+ isCreatingRef.current = false;
192
+ }
174
193
  })();
175
194
  }, [shouldCreateWallet, create]);
176
195
  useEffect(() => {
177
- if (embeddedState === EmbeddedState.EMBEDDED_SIGNER_NOT_CONFIGURED) {
178
- setShouldCreateWallet(true);
179
- }
180
- }, [embeddedState]);
196
+ if (embeddedState !== EmbeddedState.EMBEDDED_SIGNER_NOT_CONFIGURED)
197
+ return;
198
+ if ((walletConfig === null || walletConfig === void 0 ? void 0 : walletConfig.connectOnLogin) === false)
199
+ return;
200
+ setShouldCreateWallet(true);
201
+ }, [embeddedState, walletConfig === null || walletConfig === void 0 ? void 0 : walletConfig.connectOnLogin]);
181
202
  useEffect(() => {
182
203
  if (recoveryError)
183
204
  triggerResize();
@@ -269,8 +290,7 @@ const CreateOrConnectWallet = () => {
269
290
  };
270
291
  const EthereumCreateWallet = () => {
271
292
  const { uiConfig, walletConfig, setRoute } = useOpenfort();
272
- const { user } = useOpenfortCore();
273
- const { chainType } = useOpenfortCore();
293
+ const { user, chainType } = useOpenfortCore();
274
294
  // Use chain-specific hooks
275
295
  const ethereumWallet = useEthereumEmbeddedWallet();
276
296
  const solanaWallet = useSolanaEmbeddedWallet();
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -29,9 +29,8 @@ const errorForChainRegistry = {
29
29
  }),
30
30
  };
31
31
  const LoadWallets = () => {
32
- const { chainType } = useOpenfortCore();
33
- const { user } = useOpenfortCore();
34
- const { triggerResize, setRoute, setConnector } = useOpenfort();
32
+ const { chainType, user, isLoadingAccounts } = useOpenfortCore();
33
+ const { triggerResize, setRoute, setConnector, walletConfig } = useOpenfort();
35
34
  const ethereumWallet = useEthereumEmbeddedWallet();
36
35
  const solanaWallet = useSolanaEmbeddedWallet();
37
36
  const embeddedWallet = chainType === ChainTypeEnum.EVM ? ethereumWallet : solanaWallet;
@@ -39,7 +38,10 @@ const LoadWallets = () => {
39
38
  const wallets = embeddedWallet.wallets;
40
39
  const isLoadingWallets = embeddedWallet.status === 'fetching-wallets' ||
41
40
  embeddedWallet.status === 'connecting' ||
42
- embeddedWallet.status === 'creating';
41
+ embeddedWallet.status === 'creating' ||
42
+ // For Solana, the hook never enters 'fetching-wallets' — accounts are derived from the
43
+ // core embeddedAccounts store. Wait for the core fetch to complete before routing.
44
+ isLoadingAccounts;
43
45
  const errorWallets = embeddedWallet.status === 'error' ? new Error(embeddedWallet.error) : undefined;
44
46
  useEffect(() => {
45
47
  let timeout;
@@ -62,6 +64,10 @@ const LoadWallets = () => {
62
64
  }
63
65
  logger.log('User wallets loaded:', wallets.length);
64
66
  if (wallets.length === 0) {
67
+ if ((walletConfig === null || walletConfig === void 0 ? void 0 : walletConfig.connectOnLogin) === false) {
68
+ setRoute(routes.CONNECTED);
69
+ return;
70
+ }
65
71
  setRoute(createRoute(chainType));
66
72
  return;
67
73
  }
@@ -80,7 +86,7 @@ const LoadWallets = () => {
80
86
  return;
81
87
  }
82
88
  setRoute(routes.SELECT_WALLET_TO_RECOVER);
83
- }, [loadingUX, isLoadingWallets, wallets, user, chainType, setRoute, setConnector]);
89
+ }, [loadingUX, isLoadingWallets, wallets, user, chainType, setRoute, setConnector, walletConfig]);
84
90
  const { isError: isErrorFromChain, message: errorMessageFromChain } = errorForChainRegistry[chainType](errorWallets);
85
91
  const isError = !user || isErrorFromChain;
86
92
  const errorMessage = !user ? undefined : errorMessageFromChain;
@@ -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,8 @@
1
+ import { AccountTypeEnum } from '@openfort/openfort-js';
1
2
  /**
2
3
  * Identifier for the Openfort embedded wallet connector.
3
4
  * Used when identifying the embedded wallet in connector lists.
4
5
  */
5
6
  export declare const embeddedWalletId = "xyz.openfort";
7
+ /** Default account type when none is specified in walletConfig or create options. */
8
+ export declare const DEFAULT_ACCOUNT_TYPE = AccountTypeEnum.EOA;
@@ -1,8 +1,12 @@
1
+ import { AccountTypeEnum } from '@openfort/openfort-js';
2
+
1
3
  /**
2
4
  * Identifier for the Openfort embedded wallet connector.
3
5
  * Used when identifying the embedded wallet in connector lists.
4
6
  */
5
7
  const embeddedWalletId = 'xyz.openfort';
8
+ /** Default account type when none is specified in walletConfig or create options. */
9
+ const DEFAULT_ACCOUNT_TYPE = AccountTypeEnum.EOA;
6
10
 
7
- export { embeddedWalletId };
11
+ export { DEFAULT_ACCOUNT_TYPE, embeddedWalletId };
8
12
  //# sourceMappingURL=openfort.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"openfort.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
1
+ {"version":3,"file":"openfort.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}
@@ -1,7 +1,8 @@
1
- import { ChainTypeEnum, AccountTypeEnum, EmbeddedState, RecoveryMethod } from '@openfort/openfort-js';
1
+ import { ChainTypeEnum, EmbeddedState, RecoveryMethod } from '@openfort/openfort-js';
2
2
  import { useRef, useState, useMemo, useCallback, useEffect } from 'react';
3
3
  import { baseSepolia } from 'viem/chains';
4
4
  import { useOpenfort } from '../../components/Openfort/useOpenfort.js';
5
+ import { DEFAULT_ACCOUNT_TYPE } from '../../constants/openfort.js';
5
6
  import { useConnectionStrategy } from '../../core/ConnectionStrategyContext.js';
6
7
  import { OpenfortError, OpenfortReactErrorType } from '../../types.js';
7
8
  import { useOpenfortCore } from '../../openfort/useOpenfort.js';
@@ -131,11 +132,11 @@ function useEthereumEmbeddedWallet(options) {
131
132
  },
132
133
  });
133
134
  // Determine account type (use createOptions, then walletConfig, else default to Smart Account)
134
- const accountType = (_c = (_a = createOptions === null || createOptions === void 0 ? void 0 : createOptions.accountType) !== null && _a !== void 0 ? _a : (_b = walletConfig === null || walletConfig === void 0 ? void 0 : walletConfig.ethereum) === null || _b === void 0 ? void 0 : _b.accountType) !== null && _c !== void 0 ? _c : AccountTypeEnum.SMART_ACCOUNT;
135
+ const accountType = (_c = (_a = createOptions === null || createOptions === void 0 ? void 0 : createOptions.accountType) !== null && _a !== void 0 ? _a : (_b = walletConfig === null || walletConfig === void 0 ? void 0 : walletConfig.ethereum) === null || _b === void 0 ? void 0 : _b.accountType) !== null && _c !== void 0 ? _c : DEFAULT_ACCOUNT_TYPE;
135
136
  const account = await client.embeddedWallet.create({
136
137
  chainType: ChainTypeEnum.EVM,
137
138
  accountType,
138
- ...(accountType !== AccountTypeEnum.EOA && { chainId: (_d = createOptions === null || createOptions === void 0 ? void 0 : createOptions.chainId) !== null && _d !== void 0 ? _d : creationChainId }),
139
+ ...(accountType !== DEFAULT_ACCOUNT_TYPE && { chainId: (_d = createOptions === null || createOptions === void 0 ? void 0 : createOptions.chainId) !== null && _d !== void 0 ? _d : creationChainId }),
139
140
  recoveryParams,
140
141
  });
141
142
  await updateEmbeddedAccounts({ silent: true });
@@ -1 +1 @@
1
- {"version":3,"file":"useEthereumEmbeddedWallet.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"useEthereumEmbeddedWallet.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,6 +1,7 @@
1
- import { AccountTypeEnum, ChainTypeEnum, RecoveryMethod, EmbeddedState } from '@openfort/openfort-js';
1
+ import { ChainTypeEnum, RecoveryMethod, EmbeddedState } from '@openfort/openfort-js';
2
2
  import { useCallback } from 'react';
3
3
  import { useOpenfort } from '../../../components/Openfort/useOpenfort.js';
4
+ import { DEFAULT_ACCOUNT_TYPE } from '../../../constants/openfort.js';
4
5
  import { useOpenfortCore } from '../../../openfort/useOpenfort.js';
5
6
  import { buildRecoveryParams } from '../../../shared/utils/recovery.js';
6
7
  import { logger } from '../../../utils/logger.js';
@@ -54,11 +55,11 @@ const useConnectToWalletPostAuth = () => {
54
55
  getAccessToken: () => client.getAccessToken(),
55
56
  getUserId: async () => { var _a; return (_a = (await client.user.get())) === null || _a === void 0 ? void 0 : _a.id; },
56
57
  });
57
- const accountType = (_c = (_b = walletConfig === null || walletConfig === void 0 ? void 0 : walletConfig.ethereum) === null || _b === void 0 ? void 0 : _b.accountType) !== null && _c !== void 0 ? _c : AccountTypeEnum.SMART_ACCOUNT;
58
+ const accountType = (_c = (_b = walletConfig === null || walletConfig === void 0 ? void 0 : walletConfig.ethereum) === null || _b === void 0 ? void 0 : _b.accountType) !== null && _c !== void 0 ? _c : DEFAULT_ACCOUNT_TYPE;
58
59
  const account = await client.embeddedWallet.create({
59
60
  chainType,
60
- accountType: chainType === ChainTypeEnum.EVM ? accountType : AccountTypeEnum.EOA,
61
- ...(chainType === ChainTypeEnum.EVM && accountType !== AccountTypeEnum.EOA && { chainId }),
61
+ accountType: chainType === ChainTypeEnum.EVM ? accountType : DEFAULT_ACCOUNT_TYPE,
62
+ ...(chainType === ChainTypeEnum.EVM && accountType !== DEFAULT_ACCOUNT_TYPE && { chainId }),
62
63
  recoveryParams,
63
64
  });
64
65
  await updateEmbeddedAccounts({ silent: true });
@@ -1 +1 @@
1
- {"version":3,"file":"useConnectToWalletPostAuth.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"useConnectToWalletPostAuth.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @remarks Client-only. Use in a Client Component (e.g. add `"use client"` in Next.js App Router).
8
8
  *
9
- * @returns user, linkedAccounts, isAuthenticated, isConnected, getAccessToken, validateAndRefreshToken
9
+ * @returns user, linkedAccounts, isLoading, isAuthenticated, isConnected, getAccessToken, validateAndRefreshToken
10
10
  *
11
11
  * @example
12
12
  * ```tsx
@@ -21,6 +21,7 @@
21
21
  export declare function useUser(): {
22
22
  user: import("@openfort/openfort-js").User | null;
23
23
  linkedAccounts: import("@openfort/openfort-js").UserAccount[];
24
+ isLoading: boolean;
24
25
  isAuthenticated: boolean;
25
26
  isConnected: boolean;
26
27
  getAccessToken: () => Promise<string | null>;
@@ -11,7 +11,7 @@ import { handleOAuthConfigError } from '../../utils/oauthErrorHandler.js';
11
11
  *
12
12
  * @remarks Client-only. Use in a Client Component (e.g. add `"use client"` in Next.js App Router).
13
13
  *
14
- * @returns user, linkedAccounts, isAuthenticated, isConnected, getAccessToken, validateAndRefreshToken
14
+ * @returns user, linkedAccounts, isLoading, isAuthenticated, isConnected, getAccessToken, validateAndRefreshToken
15
15
  *
16
16
  * @example
17
17
  * ```tsx
@@ -24,7 +24,7 @@ import { handleOAuthConfigError } from '../../utils/oauthErrorHandler.js';
24
24
  * ```
25
25
  */
26
26
  function useUser() {
27
- const { user, client, embeddedState, linkedAccounts, activeEmbeddedAddress } = useOpenfortCore();
27
+ const { user, client, embeddedState, linkedAccounts, activeEmbeddedAddress, isLoading } = useOpenfortCore();
28
28
  const isAuthenticated = embeddedState !== EmbeddedState.NONE && embeddedState !== EmbeddedState.UNAUTHENTICATED;
29
29
  const isConnected = embeddedState === EmbeddedState.READY && !!activeEmbeddedAddress;
30
30
  const getAccessTokenAndUpdate = useCallback(async () => {
@@ -50,6 +50,7 @@ function useUser() {
50
50
  return {
51
51
  user,
52
52
  linkedAccounts,
53
+ isLoading,
53
54
  isAuthenticated,
54
55
  isConnected,
55
56
  getAccessToken: getAccessTokenAndUpdate,
@@ -1 +1 @@
1
- {"version":3,"file":"useUser.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"useUser.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,5 +1,5 @@
1
1
  import { ChainTypeEnum, EmbeddedState } from '@openfort/openfort-js';
2
- import { useContext, useMemo, useState, useEffect, useRef, useCallback, useLayoutEffect, createElement, Fragment } from 'react';
2
+ import { useContext, useMemo, useState, useEffect, useRef, useLayoutEffect, useCallback, createElement, Fragment } from 'react';
3
3
  import { useStore } from 'zustand';
4
4
  import { routes } from '../components/Openfort/types.js';
5
5
  import { useOpenfort } from '../components/Openfort/useOpenfort.js';
@@ -99,8 +99,10 @@ const CoreOpenfortProvider = ({ children, onConnect, onDisconnect, openfortConfi
99
99
  });
100
100
  });
101
101
  }, []);
102
- // Sync chainType from UI context into the store
103
- useEffect(() => {
102
+ // Sync chainType from UI context into the store — useLayoutEffect so the store
103
+ // is updated before the next paint, preventing a one-render-cycle race where
104
+ // the strategy context (synchronous) sees SVM but the store still shows EVM.
105
+ useLayoutEffect(() => {
104
106
  store.getState().setChainType(chainType);
105
107
  }, [store, chainType]);
106
108
  // Recompute isLoading when bridge address changes (bridge connects/disconnects)
@@ -1 +1 @@
1
- {"version":3,"file":"CoreOpenfortProvider.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"CoreOpenfortProvider.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1 +1 @@
1
- export declare const OPENFORT_VERSION = "1.0.1";
1
+ export declare const OPENFORT_VERSION = "1.0.3";
package/build/version.js CHANGED
@@ -1,4 +1,4 @@
1
- const OPENFORT_VERSION = '1.0.1';
1
+ const OPENFORT_VERSION = '1.0.3';
2
2
 
3
3
  export { OPENFORT_VERSION };
4
4
  //# sourceMappingURL=version.js.map
@@ -9,7 +9,12 @@ function setEmbeddedWalletProvider(p) {
9
9
  function embeddedWalletConnector() {
10
10
  return createConnector((config) => {
11
11
  const accountsChangedHandler = (accs) => {
12
- config.emitter.emit('change', { accounts: accs });
12
+ // Filter out non-EVM addresses (e.g. Solana base58) that the SDK may emit
13
+ // when recover() is called for a Solana wallet — sdk bug, defensive guard.
14
+ const valid = accs.filter((a) => /^0x[0-9a-fA-F]{40}$/i.test(a));
15
+ if (valid.length === 0)
16
+ return;
17
+ config.emitter.emit('change', { accounts: valid });
13
18
  };
14
19
  const chainChangedHandler = (chain) => {
15
20
  config.emitter.emit('change', { chainId: Number(chain) });
@@ -1 +1 @@
1
- {"version":3,"file":"embeddedConnector.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"embeddedConnector.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfort/react",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "author": "Openfort (https://www.openfort.io)",
5
5
  "license": "BSD-2-Clause license",
6
6
  "description": "The easiest way to integrate Openfort to your project.",