@b3dotfun/sdk 0.0.21 → 0.0.22-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +2 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.js +3 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +4 -1
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +4 -1
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +2 -0
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +2 -2
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.js +4 -1
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +4 -1
- package/dist/esm/global-account/react/hooks/useAuthentication.js +4 -1
- package/package.json +1 -1
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +2 -0
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Privy.tsx +2 -2
- package/src/global-account/react/components/SignInWithB3/steps/LoginStep.tsx +4 -1
- package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +4 -1
- package/src/global-account/react/hooks/useAuthentication.ts +4 -2
package/README.md
CHANGED
|
@@ -418,3 +418,31 @@ try {
|
|
|
418
418
|
---
|
|
419
419
|
|
|
420
420
|
For more detailed examples and advanced usage patterns, refer to the individual module documentation and type definitions.
|
|
421
|
+
|
|
422
|
+
## Local dev
|
|
423
|
+
|
|
424
|
+
If you are testing with one of the demos in this repo, simply make changes and they will reflect. If you are testing outside of this repo, follow the instructions below.
|
|
425
|
+
|
|
426
|
+
Initial setup
|
|
427
|
+
|
|
428
|
+
```
|
|
429
|
+
yalc publish # run this in sdk folder
|
|
430
|
+
yalc add @b3dotfun/sdk # run this in your other project
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
After making changes
|
|
434
|
+
|
|
435
|
+
```
|
|
436
|
+
yalc publish # run this in sdk folder
|
|
437
|
+
yalc update # run this in your other project
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
## Debugging
|
|
441
|
+
|
|
442
|
+
If you want to debug with existing logs that we provide, simply run this in your browser console, on the app you are debugging
|
|
443
|
+
|
|
444
|
+
```
|
|
445
|
+
localStorage.setItem('debug', '@@b3dotfun/sdk**')
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
Now, if you filter your console logs for `@@b3dotFun`, you will see several logs we provide.
|
|
@@ -164,12 +164,14 @@ function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onE
|
|
|
164
164
|
debug("Authenticating with B3 via SIWE");
|
|
165
165
|
setIsConnected(true);
|
|
166
166
|
if (loginWithSiwe) {
|
|
167
|
+
debug("@@setIsAuthenticating:true:1");
|
|
167
168
|
setIsAuthenticating(true);
|
|
168
169
|
const userAuth = await authenticate(account, partnerId);
|
|
169
170
|
setUser(userAuth.user);
|
|
170
171
|
}
|
|
171
172
|
debug("handleLoginSuccess:account", account);
|
|
172
173
|
onLoginSuccess?.(account);
|
|
174
|
+
debug("@@setIsAuthenticating:false:1");
|
|
173
175
|
setIsAuthenticating(false);
|
|
174
176
|
}, [loginWithSiwe, onLoginSuccess, setIsAuthenticating, authenticate, partnerId, setUser, setIsConnected]);
|
|
175
177
|
(0, react_2.useEffect)(() => {
|
|
@@ -18,7 +18,6 @@ function SignInWithB3Privy({ onSuccess, onError, partnerId, chain }) {
|
|
|
18
18
|
(0, react_2.useEffect)(() => {
|
|
19
19
|
async function autoConnect() {
|
|
20
20
|
try {
|
|
21
|
-
setIsAuthenticating(true);
|
|
22
21
|
const connectResult = await connectTw();
|
|
23
22
|
const account = connectResult?.getAccount();
|
|
24
23
|
if (!account) {
|
|
@@ -35,6 +34,7 @@ function SignInWithB3Privy({ onSuccess, onError, partnerId, chain }) {
|
|
|
35
34
|
setIsAuthenticated(false);
|
|
36
35
|
}
|
|
37
36
|
finally {
|
|
37
|
+
debug("@@setIsAuthenticating:false:7");
|
|
38
38
|
setIsAuthenticating(false);
|
|
39
39
|
}
|
|
40
40
|
}
|
|
@@ -5,6 +5,7 @@ exports.LoginStep = LoginStep;
|
|
|
5
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
6
|
const react_1 = require("../../../../../global-account/react");
|
|
7
7
|
const constants_1 = require("../../../../../shared/constants");
|
|
8
|
+
const debug_1 = require("../../../../../shared/utils/debug");
|
|
8
9
|
const thirdweb_1 = require("../../../../../shared/utils/thirdweb");
|
|
9
10
|
const react_2 = require("thirdweb/react");
|
|
10
11
|
const wallets_1 = require("thirdweb/wallets");
|
|
@@ -64,6 +65,7 @@ function LoginStep({ onSuccess, onError, partnerId, chain }) {
|
|
|
64
65
|
}, onConnect: async (wallet) => {
|
|
65
66
|
try {
|
|
66
67
|
setIsAuthenticating(true);
|
|
68
|
+
(0, debug_1.debug)("@@setIsAuthenticating:true:6");
|
|
67
69
|
const account = wallet.getAccount();
|
|
68
70
|
if (!account)
|
|
69
71
|
throw new Error("No account found");
|
|
@@ -77,6 +79,7 @@ function LoginStep({ onSuccess, onError, partnerId, chain }) {
|
|
|
77
79
|
setIsAuthenticated(false);
|
|
78
80
|
}
|
|
79
81
|
finally {
|
|
82
|
+
(0, debug_1.debug)("@@setIsAuthenticating:false:6");
|
|
80
83
|
setIsAuthenticating(false);
|
|
81
84
|
}
|
|
82
85
|
} }) }));
|
|
@@ -3,10 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.LoginStepCustom = LoginStepCustom;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("../../../../../global-account/react");
|
|
6
|
+
const debug_1 = require("../../../../../shared/utils/debug");
|
|
7
|
+
const thirdweb_1 = require("../../../../../shared/utils/thirdweb");
|
|
6
8
|
const react_2 = require("react");
|
|
7
9
|
const react_3 = require("thirdweb/react");
|
|
8
10
|
const wallets_1 = require("thirdweb/wallets");
|
|
9
|
-
const thirdweb_1 = require("../../../../../shared/utils/thirdweb");
|
|
10
11
|
function LoginStepCustom({ onSuccess, onError, partnerId, chain, strategies, maxInitialWallets = 2, automaticallySetFirstEoa, }) {
|
|
11
12
|
const [isLoading, setIsLoading] = (0, react_2.useState)(false);
|
|
12
13
|
const [showAllWallets, setShowAllWallets] = (0, react_2.useState)(false);
|
|
@@ -23,6 +24,7 @@ function LoginStepCustom({ onSuccess, onError, partnerId, chain, strategies, max
|
|
|
23
24
|
const handleConnect = async (strategy) => {
|
|
24
25
|
try {
|
|
25
26
|
setIsLoading(true);
|
|
27
|
+
(0, debug_1.debug)("@@setIsAuthenticating:true:3");
|
|
26
28
|
setIsAuthenticating(true);
|
|
27
29
|
const options = (0, react_1.getConnectOptionsFromStrategy)(strategy);
|
|
28
30
|
let connectResult;
|
|
@@ -56,6 +58,7 @@ function LoginStepCustom({ onSuccess, onError, partnerId, chain, strategies, max
|
|
|
56
58
|
}
|
|
57
59
|
finally {
|
|
58
60
|
setIsLoading(false);
|
|
61
|
+
(0, debug_1.debug)("@@setIsAuthenticating:false:3");
|
|
59
62
|
setIsAuthenticating(false);
|
|
60
63
|
}
|
|
61
64
|
};
|
|
@@ -46,6 +46,7 @@ function useAuthentication(partnerId, loginWithSiwe) {
|
|
|
46
46
|
setIsAuthenticated(true);
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
|
+
debug("@@setIsAuthenticating:true:4");
|
|
49
50
|
setIsAuthenticating(true);
|
|
50
51
|
const account = await wallet.getAccount();
|
|
51
52
|
if (!account) {
|
|
@@ -70,6 +71,7 @@ function useAuthentication(partnerId, loginWithSiwe) {
|
|
|
70
71
|
catch (error) {
|
|
71
72
|
debug("Auto-connect authentication failed", { error });
|
|
72
73
|
setIsAuthenticated(false);
|
|
74
|
+
debug("@@setIsAuthenticating:false:4");
|
|
73
75
|
setUser();
|
|
74
76
|
}
|
|
75
77
|
},
|
|
@@ -77,19 +79,20 @@ function useAuthentication(partnerId, loginWithSiwe) {
|
|
|
77
79
|
// Ensure isAuthenticating stays true until we're fully ready
|
|
78
80
|
(0, react_2.useEffect)(() => {
|
|
79
81
|
if (useAutoConnectLoading) {
|
|
80
|
-
setIsAuthenticating(true);
|
|
81
82
|
setIsConnecting(true);
|
|
82
83
|
}
|
|
83
84
|
else if (!isAuthenticated) {
|
|
84
85
|
// Only set isAuthenticating to false if we're not authenticated
|
|
85
86
|
// This prevents the flicker state where both isAuthenticating and isAuthenticated are false
|
|
86
87
|
const timeout = setTimeout(() => {
|
|
88
|
+
debug("@@setIsAuthenticating:false:5a");
|
|
87
89
|
setIsAuthenticating(false);
|
|
88
90
|
setIsConnecting(false);
|
|
89
91
|
}, 100); // Add a small delay to prevent quick flickers
|
|
90
92
|
return () => clearTimeout(timeout);
|
|
91
93
|
}
|
|
92
94
|
else {
|
|
95
|
+
debug("@@setIsAuthenticating:false:5b");
|
|
93
96
|
setIsAuthenticating(false);
|
|
94
97
|
setIsConnecting(false);
|
|
95
98
|
}
|
|
@@ -161,12 +161,14 @@ export function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySucce
|
|
|
161
161
|
debug("Authenticating with B3 via SIWE");
|
|
162
162
|
setIsConnected(true);
|
|
163
163
|
if (loginWithSiwe) {
|
|
164
|
+
debug("@@setIsAuthenticating:true:1");
|
|
164
165
|
setIsAuthenticating(true);
|
|
165
166
|
const userAuth = await authenticate(account, partnerId);
|
|
166
167
|
setUser(userAuth.user);
|
|
167
168
|
}
|
|
168
169
|
debug("handleLoginSuccess:account", account);
|
|
169
170
|
onLoginSuccess?.(account);
|
|
171
|
+
debug("@@setIsAuthenticating:false:1");
|
|
170
172
|
setIsAuthenticating(false);
|
|
171
173
|
}, [loginWithSiwe, onLoginSuccess, setIsAuthenticating, authenticate, partnerId, setUser, setIsConnected]);
|
|
172
174
|
useEffect(() => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Loading, useAuthentication,
|
|
2
|
+
import { Loading, useAuthentication, useAuthStore, useHandleConnectWithPrivy, } from "../../../../global-account/react/index.js";
|
|
3
3
|
import { debugB3React } from "../../../../shared/utils/debug.js";
|
|
4
4
|
import { useEffect } from "react";
|
|
5
5
|
const debug = debugB3React("SignInWithB3Privy");
|
|
@@ -15,7 +15,6 @@ export function SignInWithB3Privy({ onSuccess, onError, partnerId, chain }) {
|
|
|
15
15
|
useEffect(() => {
|
|
16
16
|
async function autoConnect() {
|
|
17
17
|
try {
|
|
18
|
-
setIsAuthenticating(true);
|
|
19
18
|
const connectResult = await connectTw();
|
|
20
19
|
const account = connectResult?.getAccount();
|
|
21
20
|
if (!account) {
|
|
@@ -32,6 +31,7 @@ export function SignInWithB3Privy({ onSuccess, onError, partnerId, chain }) {
|
|
|
32
31
|
setIsAuthenticated(false);
|
|
33
32
|
}
|
|
34
33
|
finally {
|
|
34
|
+
debug("@@setIsAuthenticating:false:7");
|
|
35
35
|
setIsAuthenticating(false);
|
|
36
36
|
}
|
|
37
37
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useAuthentication,
|
|
2
|
+
import { useAuthentication, useAuthStore, useB3, useQueryB3 } from "../../../../../global-account/react/index.js";
|
|
3
3
|
import { ecosystemWalletId } from "../../../../../shared/constants/index.js";
|
|
4
|
+
import { debug } from "../../../../../shared/utils/debug.js";
|
|
4
5
|
import { client } from "../../../../../shared/utils/thirdweb.js";
|
|
5
6
|
import { ConnectEmbed, darkTheme, lightTheme } from "thirdweb/react";
|
|
6
7
|
import { ecosystemWallet } from "thirdweb/wallets";
|
|
@@ -60,6 +61,7 @@ export function LoginStep({ onSuccess, onError, partnerId, chain }) {
|
|
|
60
61
|
}, onConnect: async (wallet) => {
|
|
61
62
|
try {
|
|
62
63
|
setIsAuthenticating(true);
|
|
64
|
+
debug("@@setIsAuthenticating:true:6");
|
|
63
65
|
const account = wallet.getAccount();
|
|
64
66
|
if (!account)
|
|
65
67
|
throw new Error("No account found");
|
|
@@ -73,6 +75,7 @@ export function LoginStep({ onSuccess, onError, partnerId, chain }) {
|
|
|
73
75
|
setIsAuthenticated(false);
|
|
74
76
|
}
|
|
75
77
|
finally {
|
|
78
|
+
debug("@@setIsAuthenticating:false:6");
|
|
76
79
|
setIsAuthenticating(false);
|
|
77
80
|
}
|
|
78
81
|
} }) }));
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { AuthButton, Button, getConnectOptionsFromStrategy, isWalletType, LoginStepContainer, useAuthentication, useAuthStore, useConnect, WalletRow, } from "../../../../../global-account/react/index.js";
|
|
3
|
+
import { debug } from "../../../../../shared/utils/debug.js";
|
|
4
|
+
import { client } from "../../../../../shared/utils/thirdweb.js";
|
|
3
5
|
import { useState } from "react";
|
|
4
6
|
import { useConnect as useConnectTW } from "thirdweb/react";
|
|
5
7
|
import { createWallet } from "thirdweb/wallets";
|
|
6
|
-
import { client } from "../../../../../shared/utils/thirdweb.js";
|
|
7
8
|
export function LoginStepCustom({ onSuccess, onError, partnerId, chain, strategies, maxInitialWallets = 2, automaticallySetFirstEoa, }) {
|
|
8
9
|
const [isLoading, setIsLoading] = useState(false);
|
|
9
10
|
const [showAllWallets, setShowAllWallets] = useState(false);
|
|
@@ -20,6 +21,7 @@ export function LoginStepCustom({ onSuccess, onError, partnerId, chain, strategi
|
|
|
20
21
|
const handleConnect = async (strategy) => {
|
|
21
22
|
try {
|
|
22
23
|
setIsLoading(true);
|
|
24
|
+
debug("@@setIsAuthenticating:true:3");
|
|
23
25
|
setIsAuthenticating(true);
|
|
24
26
|
const options = getConnectOptionsFromStrategy(strategy);
|
|
25
27
|
let connectResult;
|
|
@@ -53,6 +55,7 @@ export function LoginStepCustom({ onSuccess, onError, partnerId, chain, strategi
|
|
|
53
55
|
}
|
|
54
56
|
finally {
|
|
55
57
|
setIsLoading(false);
|
|
58
|
+
debug("@@setIsAuthenticating:false:3");
|
|
56
59
|
setIsAuthenticating(false);
|
|
57
60
|
}
|
|
58
61
|
};
|
|
@@ -40,6 +40,7 @@ export function useAuthentication(partnerId, loginWithSiwe) {
|
|
|
40
40
|
setIsAuthenticated(true);
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
43
|
+
debug("@@setIsAuthenticating:true:4");
|
|
43
44
|
setIsAuthenticating(true);
|
|
44
45
|
const account = await wallet.getAccount();
|
|
45
46
|
if (!account) {
|
|
@@ -64,6 +65,7 @@ export function useAuthentication(partnerId, loginWithSiwe) {
|
|
|
64
65
|
catch (error) {
|
|
65
66
|
debug("Auto-connect authentication failed", { error });
|
|
66
67
|
setIsAuthenticated(false);
|
|
68
|
+
debug("@@setIsAuthenticating:false:4");
|
|
67
69
|
setUser();
|
|
68
70
|
}
|
|
69
71
|
},
|
|
@@ -71,19 +73,20 @@ export function useAuthentication(partnerId, loginWithSiwe) {
|
|
|
71
73
|
// Ensure isAuthenticating stays true until we're fully ready
|
|
72
74
|
useEffect(() => {
|
|
73
75
|
if (useAutoConnectLoading) {
|
|
74
|
-
setIsAuthenticating(true);
|
|
75
76
|
setIsConnecting(true);
|
|
76
77
|
}
|
|
77
78
|
else if (!isAuthenticated) {
|
|
78
79
|
// Only set isAuthenticating to false if we're not authenticated
|
|
79
80
|
// This prevents the flicker state where both isAuthenticating and isAuthenticated are false
|
|
80
81
|
const timeout = setTimeout(() => {
|
|
82
|
+
debug("@@setIsAuthenticating:false:5a");
|
|
81
83
|
setIsAuthenticating(false);
|
|
82
84
|
setIsConnecting(false);
|
|
83
85
|
}, 100); // Add a small delay to prevent quick flickers
|
|
84
86
|
return () => clearTimeout(timeout);
|
|
85
87
|
}
|
|
86
88
|
else {
|
|
89
|
+
debug("@@setIsAuthenticating:false:5b");
|
|
87
90
|
setIsAuthenticating(false);
|
|
88
91
|
setIsConnecting(false);
|
|
89
92
|
}
|
package/package.json
CHANGED
|
@@ -196,12 +196,14 @@ export function SignInWithB3Flow({
|
|
|
196
196
|
debug("Authenticating with B3 via SIWE");
|
|
197
197
|
setIsConnected(true);
|
|
198
198
|
if (loginWithSiwe) {
|
|
199
|
+
debug("@@setIsAuthenticating:true:1");
|
|
199
200
|
setIsAuthenticating(true);
|
|
200
201
|
const userAuth = await authenticate(account, partnerId);
|
|
201
202
|
setUser(userAuth.user);
|
|
202
203
|
}
|
|
203
204
|
debug("handleLoginSuccess:account", account);
|
|
204
205
|
onLoginSuccess?.(account);
|
|
206
|
+
debug("@@setIsAuthenticating:false:1");
|
|
205
207
|
setIsAuthenticating(false);
|
|
206
208
|
},
|
|
207
209
|
[loginWithSiwe, onLoginSuccess, setIsAuthenticating, authenticate, partnerId, setUser, setIsConnected],
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Loading,
|
|
3
3
|
useAuthentication,
|
|
4
|
-
useHandleConnectWithPrivy,
|
|
5
4
|
useAuthStore,
|
|
5
|
+
useHandleConnectWithPrivy,
|
|
6
6
|
} from "@b3dotfun/sdk/global-account/react";
|
|
7
7
|
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
8
8
|
import { useEffect } from "react";
|
|
@@ -32,7 +32,6 @@ export function SignInWithB3Privy({ onSuccess, onError, partnerId, chain }: Sign
|
|
|
32
32
|
useEffect(() => {
|
|
33
33
|
async function autoConnect() {
|
|
34
34
|
try {
|
|
35
|
-
setIsAuthenticating(true);
|
|
36
35
|
const connectResult = await connectTw();
|
|
37
36
|
const account = connectResult?.getAccount();
|
|
38
37
|
if (!account) {
|
|
@@ -47,6 +46,7 @@ export function SignInWithB3Privy({ onSuccess, onError, partnerId, chain }: Sign
|
|
|
47
46
|
await logout();
|
|
48
47
|
setIsAuthenticated(false);
|
|
49
48
|
} finally {
|
|
49
|
+
debug("@@setIsAuthenticating:false:7");
|
|
50
50
|
setIsAuthenticating(false);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { useAuthentication,
|
|
1
|
+
import { useAuthentication, useAuthStore, useB3, useQueryB3 } from "@b3dotfun/sdk/global-account/react";
|
|
2
2
|
import { ecosystemWalletId } from "@b3dotfun/sdk/shared/constants";
|
|
3
|
+
import { debug } from "@b3dotfun/sdk/shared/utils/debug";
|
|
3
4
|
import { client } from "@b3dotfun/sdk/shared/utils/thirdweb";
|
|
4
5
|
import { Chain } from "thirdweb";
|
|
5
6
|
import { ConnectEmbed, darkTheme, lightTheme } from "thirdweb/react";
|
|
@@ -113,6 +114,7 @@ export function LoginStep({ onSuccess, onError, partnerId, chain }: LoginStepPro
|
|
|
113
114
|
onConnect={async wallet => {
|
|
114
115
|
try {
|
|
115
116
|
setIsAuthenticating(true);
|
|
117
|
+
debug("@@setIsAuthenticating:true:6");
|
|
116
118
|
|
|
117
119
|
const account = wallet.getAccount();
|
|
118
120
|
if (!account) throw new Error("No account found");
|
|
@@ -126,6 +128,7 @@ export function LoginStep({ onSuccess, onError, partnerId, chain }: LoginStepPro
|
|
|
126
128
|
await logout();
|
|
127
129
|
setIsAuthenticated(false);
|
|
128
130
|
} finally {
|
|
131
|
+
debug("@@setIsAuthenticating:false:6");
|
|
129
132
|
setIsAuthenticating(false);
|
|
130
133
|
}
|
|
131
134
|
}}
|
|
@@ -10,11 +10,12 @@ import {
|
|
|
10
10
|
useConnect,
|
|
11
11
|
WalletRow,
|
|
12
12
|
} from "@b3dotfun/sdk/global-account/react";
|
|
13
|
+
import { debug } from "@b3dotfun/sdk/shared/utils/debug";
|
|
14
|
+
import { client } from "@b3dotfun/sdk/shared/utils/thirdweb";
|
|
13
15
|
import { useState } from "react";
|
|
14
16
|
import { Chain } from "thirdweb";
|
|
15
17
|
import { useConnect as useConnectTW } from "thirdweb/react";
|
|
16
18
|
import { Account, createWallet, Wallet, WalletId } from "thirdweb/wallets";
|
|
17
|
-
import { client } from "@b3dotfun/sdk/shared/utils/thirdweb";
|
|
18
19
|
|
|
19
20
|
interface LoginStepCustomProps {
|
|
20
21
|
automaticallySetFirstEoa: boolean;
|
|
@@ -52,6 +53,7 @@ export function LoginStepCustom({
|
|
|
52
53
|
const handleConnect = async (strategy: AllowedStrategy) => {
|
|
53
54
|
try {
|
|
54
55
|
setIsLoading(true);
|
|
56
|
+
debug("@@setIsAuthenticating:true:3");
|
|
55
57
|
setIsAuthenticating(true);
|
|
56
58
|
const options = getConnectOptionsFromStrategy(strategy);
|
|
57
59
|
let connectResult: Wallet | null;
|
|
@@ -84,6 +86,7 @@ export function LoginStepCustom({
|
|
|
84
86
|
setIsAuthenticated(false);
|
|
85
87
|
} finally {
|
|
86
88
|
setIsLoading(false);
|
|
89
|
+
debug("@@setIsAuthenticating:false:3");
|
|
87
90
|
setIsAuthenticating(false);
|
|
88
91
|
}
|
|
89
92
|
};
|
|
@@ -44,7 +44,7 @@ export function useAuthentication(partnerId: string, loginWithSiwe?: boolean) {
|
|
|
44
44
|
setIsAuthenticated(true);
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
|
-
|
|
47
|
+
debug("@@setIsAuthenticating:true:4");
|
|
48
48
|
setIsAuthenticating(true);
|
|
49
49
|
const account = await wallet.getAccount();
|
|
50
50
|
if (!account) {
|
|
@@ -68,6 +68,7 @@ export function useAuthentication(partnerId: string, loginWithSiwe?: boolean) {
|
|
|
68
68
|
} catch (error) {
|
|
69
69
|
debug("Auto-connect authentication failed", { error });
|
|
70
70
|
setIsAuthenticated(false);
|
|
71
|
+
debug("@@setIsAuthenticating:false:4");
|
|
71
72
|
setUser();
|
|
72
73
|
}
|
|
73
74
|
},
|
|
@@ -76,17 +77,18 @@ export function useAuthentication(partnerId: string, loginWithSiwe?: boolean) {
|
|
|
76
77
|
// Ensure isAuthenticating stays true until we're fully ready
|
|
77
78
|
useEffect(() => {
|
|
78
79
|
if (useAutoConnectLoading) {
|
|
79
|
-
setIsAuthenticating(true);
|
|
80
80
|
setIsConnecting(true);
|
|
81
81
|
} else if (!isAuthenticated) {
|
|
82
82
|
// Only set isAuthenticating to false if we're not authenticated
|
|
83
83
|
// This prevents the flicker state where both isAuthenticating and isAuthenticated are false
|
|
84
84
|
const timeout = setTimeout(() => {
|
|
85
|
+
debug("@@setIsAuthenticating:false:5a");
|
|
85
86
|
setIsAuthenticating(false);
|
|
86
87
|
setIsConnecting(false);
|
|
87
88
|
}, 100); // Add a small delay to prevent quick flickers
|
|
88
89
|
return () => clearTimeout(timeout);
|
|
89
90
|
} else {
|
|
91
|
+
debug("@@setIsAuthenticating:false:5b");
|
|
90
92
|
setIsAuthenticating(false);
|
|
91
93
|
setIsConnecting(false);
|
|
92
94
|
}
|