@openfort/react 1.0.10 → 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/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
|
@@ -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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|