@openfort/react 1.0.9 → 1.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/Pages/Connected/EthereumConnected.js +10 -3
- package/build/components/Pages/Connected/EthereumConnected.js.map +1 -1
- package/build/components/Pages/Loading/index.js +8 -3
- package/build/components/Pages/Loading/index.js.map +1 -1
- package/build/components/Pages/Receive/index.js +12 -3
- package/build/components/Pages/Receive/index.js.map +1 -1
- package/build/openfort/CoreOpenfortProvider.js +2 -1
- package/build/openfort/CoreOpenfortProvider.js.map +1 -1
- package/build/openfort/store.d.ts +1 -1
- package/build/openfort/store.js +11 -5
- package/build/openfort/store.js.map +1 -1
- package/build/version.d.ts +1 -1
- package/build/version.js +1 -1
- package/build/wagmi/useEmbeddedWalletWagmiSync.js +12 -1
- package/build/wagmi/useEmbeddedWalletWagmiSync.js.map +1 -1
- package/package.json +1 -1
|
@@ -40,9 +40,16 @@ const EthereumConnected = () => {
|
|
|
40
40
|
const wallet = useEthereumEmbeddedWallet();
|
|
41
41
|
const { embeddedAccounts } = useOpenfortCore();
|
|
42
42
|
const hasEthereumWallets = ((_a = embeddedAccounts === null || embeddedAccounts === void 0 ? void 0 : embeddedAccounts.filter((a) => a.chainType === ChainTypeEnum.EVM)) !== null && _a !== void 0 ? _a : []).length > 0;
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
const
|
|
43
|
+
// Use embedded wallet if available, otherwise fall back to bridge (external wallet)
|
|
44
|
+
const embeddedConnected = wallet.status === 'connected';
|
|
45
|
+
const bridgeConnected = !!((bridge === null || bridge === void 0 ? void 0 : bridge.account.isConnected) && (bridge === null || bridge === void 0 ? void 0 : bridge.account.address));
|
|
46
|
+
const isConnected = embeddedConnected || bridgeConnected;
|
|
47
|
+
const address = embeddedConnected
|
|
48
|
+
? wallet.address
|
|
49
|
+
: bridgeConnected
|
|
50
|
+
? bridge.account.address
|
|
51
|
+
: undefined;
|
|
52
|
+
const chainId = embeddedConnected ? wallet.chainId : bridgeConnected ? bridge.chainId : undefined;
|
|
46
53
|
const { chainType } = useOpenfortCore();
|
|
47
54
|
useEffect(() => {
|
|
48
55
|
if (process.env.NODE_ENV === 'development' && chainType !== ChainTypeEnum.EVM) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthereumConnected.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EthereumConnected.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -2,6 +2,7 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
2
2
|
import { ChainTypeEnum, EmbeddedState } from '@openfort/openfort-js';
|
|
3
3
|
import React, { useEffect } from 'react';
|
|
4
4
|
import { useEthereumEmbeddedWallet } from '../../../ethereum/hooks/useEthereumEmbeddedWallet.js';
|
|
5
|
+
import { useEthereumBridge } from '../../../ethereum/OpenfortEthereumBridgeContext.js';
|
|
5
6
|
import { useOpenfortCore } from '../../../openfort/useOpenfort.js';
|
|
6
7
|
import { useSolanaEmbeddedWallet } from '../../../solana/hooks/useSolanaEmbeddedWallet.js';
|
|
7
8
|
import Loader from '../../Common/Loading/index.js';
|
|
@@ -13,12 +14,15 @@ const Loading = () => {
|
|
|
13
14
|
const { setRoute, walletConfig } = useOpenfort();
|
|
14
15
|
const { user, isLoadingAccounts, isLoading, needsRecovery, embeddedState } = useOpenfortCore();
|
|
15
16
|
const { chainType } = useOpenfortCore();
|
|
17
|
+
const bridge = useEthereumBridge();
|
|
16
18
|
// Use chain-specific hooks
|
|
17
19
|
const ethereumWallet = useEthereumEmbeddedWallet();
|
|
18
20
|
const solanaWallet = useSolanaEmbeddedWallet();
|
|
19
21
|
const wallet = chainType === ChainTypeEnum.EVM ? ethereumWallet : solanaWallet;
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
+
// Check embedded wallet or bridge (external wallet) connection
|
|
23
|
+
const embeddedConnected = wallet.status === 'connected';
|
|
24
|
+
const bridgeConnected = chainType === ChainTypeEnum.EVM && !!((bridge === null || bridge === void 0 ? void 0 : bridge.account.isConnected) && (bridge === null || bridge === void 0 ? void 0 : bridge.account.address));
|
|
25
|
+
const address = embeddedConnected ? wallet.address : bridgeConnected ? bridge === null || bridge === void 0 ? void 0 : bridge.account.address : undefined;
|
|
22
26
|
const [isFirstFrame, setIsFirstFrame] = React.useState(true);
|
|
23
27
|
const [retryCount, setRetryCount] = React.useState(0);
|
|
24
28
|
useEffect(() => {
|
|
@@ -27,7 +31,8 @@ const Loading = () => {
|
|
|
27
31
|
// Wait for the SDK to settle. After storeCredentials the embedded state
|
|
28
32
|
// briefly stays UNAUTHENTICATED/NONE while the SDK processes the token.
|
|
29
33
|
// Routing to PROVIDERS here would abort the auth flow.
|
|
30
|
-
if (
|
|
34
|
+
// However, if bridge (external wallet) is already connected, don't block routing.
|
|
35
|
+
if ((embeddedState === EmbeddedState.NONE || embeddedState === EmbeddedState.UNAUTHENTICATED) && !bridgeConnected)
|
|
31
36
|
return;
|
|
32
37
|
// Also wait while accounts or user are still loading.
|
|
33
38
|
if (isLoadingAccounts || isLoading)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -3,6 +3,7 @@ import { ChainTypeEnum } from '@openfort/openfort-js';
|
|
|
3
3
|
import { useEffect } from 'react';
|
|
4
4
|
import Logos from '../../../assets/logos.js';
|
|
5
5
|
import { useEthereumEmbeddedWallet } from '../../../ethereum/hooks/useEthereumEmbeddedWallet.js';
|
|
6
|
+
import { useEthereumBridge } from '../../../ethereum/OpenfortEthereumBridgeContext.js';
|
|
6
7
|
import { useOpenfortCore } from '../../../openfort/useOpenfort.js';
|
|
7
8
|
import { useSolanaEmbeddedWallet } from '../../../solana/hooks/useSolanaEmbeddedWallet.js';
|
|
8
9
|
import { CopyIconButton } from '../../Common/CopyToClipboard/CopyIconButton.js';
|
|
@@ -27,10 +28,18 @@ const Receive = () => {
|
|
|
27
28
|
const { chainType } = useOpenfortCore();
|
|
28
29
|
const ethereumWallet = useEthereumEmbeddedWallet();
|
|
29
30
|
const solanaWallet = useSolanaEmbeddedWallet();
|
|
31
|
+
const bridge = useEthereumBridge();
|
|
30
32
|
const wallet = chainType === ChainTypeEnum.EVM ? ethereumWallet : solanaWallet;
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
const
|
|
33
|
+
// Use embedded wallet if available, otherwise fall back to bridge (external wallet)
|
|
34
|
+
const embeddedConnected = wallet.status === 'connected';
|
|
35
|
+
const bridgeConnected = chainType === ChainTypeEnum.EVM && !!((bridge === null || bridge === void 0 ? void 0 : bridge.account.isConnected) && (bridge === null || bridge === void 0 ? void 0 : bridge.account.address));
|
|
36
|
+
const isConnected = embeddedConnected || bridgeConnected;
|
|
37
|
+
const address = embeddedConnected ? wallet.address : bridgeConnected ? bridge === null || bridge === void 0 ? void 0 : bridge.account.address : undefined;
|
|
38
|
+
const chainId = embeddedConnected && chainType === ChainTypeEnum.EVM
|
|
39
|
+
? wallet.chainId
|
|
40
|
+
: bridgeConnected
|
|
41
|
+
? bridge === null || bridge === void 0 ? void 0 : bridge.chainId
|
|
42
|
+
: undefined;
|
|
34
43
|
const chain = chains.find((c) => c.id === chainId);
|
|
35
44
|
const qrValue = address || '';
|
|
36
45
|
const networkLabel = isConnected && chainType === ChainTypeEnum.SVM && solanaWallet.cluster
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -91,13 +91,14 @@ const CoreOpenfortProvider = ({ children, onConnect, onDisconnect, openfortConfi
|
|
|
91
91
|
return newClient;
|
|
92
92
|
}, []);
|
|
93
93
|
const store = useMemo(() => {
|
|
94
|
+
var _a;
|
|
94
95
|
return createOpenfortStore(chainType, openfort, () => {
|
|
95
96
|
var _a;
|
|
96
97
|
return ({
|
|
97
98
|
hasBridge: !!bridgeRef.current,
|
|
98
99
|
address: (_a = bridgeRef.current) === null || _a === void 0 ? void 0 : _a.account.address,
|
|
99
100
|
});
|
|
100
|
-
});
|
|
101
|
+
}, (_a = walletConfig === null || walletConfig === void 0 ? void 0 : walletConfig.connectOnLogin) !== null && _a !== void 0 ? _a : true);
|
|
101
102
|
}, []);
|
|
102
103
|
// Sync chainType from UI context into the store — useLayoutEffect so the store
|
|
103
104
|
// is updated before the next paint, preventing a one-render-cycle race where
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoreOpenfortProvider.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CoreOpenfortProvider.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -43,4 +43,4 @@ export type OpenfortStore = OpenfortStoreState & OpenfortStoreActions;
|
|
|
43
43
|
export declare function createOpenfortStore(initialChainType: ChainTypeEnum, client: Openfort, getBridgeInfo?: () => {
|
|
44
44
|
hasBridge: boolean;
|
|
45
45
|
address: string | undefined;
|
|
46
|
-
}): StoreApi<OpenfortStore>;
|
|
46
|
+
}, connectOnLogin?: boolean): StoreApi<OpenfortStore>;
|
package/build/openfort/store.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EmbeddedState } from '@openfort/openfort-js';
|
|
2
2
|
import { createStore } from 'zustand/vanilla';
|
|
3
3
|
|
|
4
|
-
function computeIsLoading(embeddedState, user, hasBridge, bridgeAddress) {
|
|
4
|
+
function computeIsLoading(embeddedState, user, hasBridge, bridgeAddress, embeddedAccounts, activeEmbeddedAddress, connectOnLogin) {
|
|
5
5
|
switch (embeddedState) {
|
|
6
6
|
case EmbeddedState.NONE:
|
|
7
7
|
case EmbeddedState.CREATING_ACCOUNT:
|
|
@@ -15,6 +15,11 @@ function computeIsLoading(embeddedState, user, hasBridge, bridgeAddress) {
|
|
|
15
15
|
return true;
|
|
16
16
|
if (hasBridge && !bridgeAddress)
|
|
17
17
|
return true;
|
|
18
|
+
// Embedded accounts exist but active address not yet synced.
|
|
19
|
+
// Only when connectOnLogin is true — when false, address is intentionally
|
|
20
|
+
// not auto-set and the user must pick a wallet via the UI.
|
|
21
|
+
if (connectOnLogin && (embeddedAccounts === null || embeddedAccounts === void 0 ? void 0 : embeddedAccounts.length) && !activeEmbeddedAddress)
|
|
22
|
+
return true;
|
|
18
23
|
return false;
|
|
19
24
|
default:
|
|
20
25
|
return true;
|
|
@@ -24,7 +29,7 @@ function computeNeedsRecovery(embeddedState, embeddedAccounts) {
|
|
|
24
29
|
var _a;
|
|
25
30
|
return embeddedState === EmbeddedState.EMBEDDED_SIGNER_NOT_CONFIGURED && ((_a = embeddedAccounts === null || embeddedAccounts === void 0 ? void 0 : embeddedAccounts.length) !== null && _a !== void 0 ? _a : 0) > 0;
|
|
26
31
|
}
|
|
27
|
-
function createOpenfortStore(initialChainType, client, getBridgeInfo) {
|
|
32
|
+
function createOpenfortStore(initialChainType, client, getBridgeInfo, connectOnLogin = true) {
|
|
28
33
|
const store = createStore((set) => ({
|
|
29
34
|
user: null,
|
|
30
35
|
linkedAccounts: [],
|
|
@@ -68,7 +73,7 @@ function createOpenfortStore(initialChainType, client, getBridgeInfo) {
|
|
|
68
73
|
var _a;
|
|
69
74
|
const state = store.getState();
|
|
70
75
|
const info = (_a = getBridgeInfo === null || getBridgeInfo === void 0 ? void 0 : getBridgeInfo()) !== null && _a !== void 0 ? _a : { hasBridge: false, address: undefined };
|
|
71
|
-
const loading = computeIsLoading(state.embeddedState, state.user, info.hasBridge, info.address);
|
|
76
|
+
const loading = computeIsLoading(state.embeddedState, state.user, info.hasBridge, info.address, state.embeddedAccounts, state.activeEmbeddedAddress, connectOnLogin);
|
|
72
77
|
if (loading !== state.isLoading) {
|
|
73
78
|
set({ isLoading: loading });
|
|
74
79
|
}
|
|
@@ -86,9 +91,10 @@ function createOpenfortStore(initialChainType, client, getBridgeInfo) {
|
|
|
86
91
|
const embeddedStateChanged = state.embeddedState !== prev.embeddedState;
|
|
87
92
|
const userChanged = state.user !== prev.user;
|
|
88
93
|
const embeddedAccountsChanged = state.embeddedAccounts !== prev.embeddedAccounts;
|
|
89
|
-
|
|
94
|
+
const activeAddressChanged = state.activeEmbeddedAddress !== prev.activeEmbeddedAddress;
|
|
95
|
+
if (embeddedStateChanged || userChanged || embeddedAccountsChanged || activeAddressChanged) {
|
|
90
96
|
const info = (_a = getBridgeInfo === null || getBridgeInfo === void 0 ? void 0 : getBridgeInfo()) !== null && _a !== void 0 ? _a : { hasBridge: false, address: undefined };
|
|
91
|
-
const isLoading = computeIsLoading(state.embeddedState, state.user, info.hasBridge, info.address);
|
|
97
|
+
const isLoading = computeIsLoading(state.embeddedState, state.user, info.hasBridge, info.address, state.embeddedAccounts, state.activeEmbeddedAddress, connectOnLogin);
|
|
92
98
|
if (isLoading !== state.isLoading) {
|
|
93
99
|
store.setState({ isLoading });
|
|
94
100
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"store.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/build/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const OPENFORT_VERSION = "1.0.
|
|
1
|
+
export declare const OPENFORT_VERSION = "1.0.11";
|
package/build/version.js
CHANGED
|
@@ -19,6 +19,7 @@ function useEmbeddedWalletWagmiSync() {
|
|
|
19
19
|
const provider = status === 'connected' ? wallet.provider : null;
|
|
20
20
|
// Track whether an external wallet was explicitly connected — don't override it
|
|
21
21
|
const externalConnectorActiveRef = useRef(false);
|
|
22
|
+
const connectFailedRef = useRef(false);
|
|
22
23
|
useEffect(() => {
|
|
23
24
|
if (activeConnector && activeConnector.id !== embeddedWalletId) {
|
|
24
25
|
externalConnectorActiveRef.current = true;
|
|
@@ -27,6 +28,10 @@ function useEmbeddedWalletWagmiSync() {
|
|
|
27
28
|
externalConnectorActiveRef.current = false;
|
|
28
29
|
}
|
|
29
30
|
}, [activeConnector]);
|
|
31
|
+
// Reset failure flag when provider changes (new session = fresh attempt)
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
connectFailedRef.current = false;
|
|
34
|
+
}, [provider]);
|
|
30
35
|
// Keep the module-level provider slot in sync — clear on disconnect
|
|
31
36
|
useEffect(() => {
|
|
32
37
|
if (status === 'connected' && provider) {
|
|
@@ -45,6 +50,9 @@ function useEmbeddedWalletWagmiSync() {
|
|
|
45
50
|
return;
|
|
46
51
|
if ((activeConnector === null || activeConnector === void 0 ? void 0 : activeConnector.id) === embeddedWalletId)
|
|
47
52
|
return;
|
|
53
|
+
// Already failed for this provider — don't retry
|
|
54
|
+
if (connectFailedRef.current)
|
|
55
|
+
return;
|
|
48
56
|
// An external wallet is actively connected — don't override it
|
|
49
57
|
if (externalConnectorActiveRef.current) {
|
|
50
58
|
logger.log('[EmbeddedWalletWagmiSync] Skipping auto-connect — external wallet is active', {
|
|
@@ -56,7 +64,10 @@ function useEmbeddedWalletWagmiSync() {
|
|
|
56
64
|
if (!embeddedConnector)
|
|
57
65
|
return;
|
|
58
66
|
logger.log('[EmbeddedWalletWagmiSync] Auto-connecting embedded wallet to wagmi');
|
|
59
|
-
connectAsync({ connector: embeddedConnector }).catch(() => {
|
|
67
|
+
connectAsync({ connector: embeddedConnector }).catch((error) => {
|
|
68
|
+
connectFailedRef.current = true;
|
|
69
|
+
logger.error('[EmbeddedWalletWagmiSync] Failed to connect embedded wallet to wagmi', error);
|
|
70
|
+
});
|
|
60
71
|
}, [status, provider, wagmiStatus, activeConnector, connectors, connectAsync]);
|
|
61
72
|
// Disconnect embedded connector from wagmi when the embedded wallet logs out
|
|
62
73
|
useEffect(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEmbeddedWalletWagmiSync.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useEmbeddedWalletWagmiSync.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|