@b3dotfun/sdk 0.1.69-alpha.0 → 0.1.69-alpha.10
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/dist/cjs/anyspend/react/components/AnySpendStakeB3.js +1 -1
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3ExactIn.js +1 -1
- package/dist/cjs/anyspend/react/components/checkout/CheckoutPaymentPanel.js +2 -4
- package/dist/cjs/anyspend/react/components/checkout/CheckoutSuccess.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/checkout/CheckoutSuccess.js +5 -3
- package/dist/cjs/anyspend/react/components/checkout/FiatCheckoutPanel.js +1 -2
- package/dist/cjs/anyspend/react/components/checkout/KycGate.js +1 -2
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +5 -0
- package/dist/cjs/anyspend/react/components/common/OrderStatus.js +37 -6
- package/dist/cjs/anyspend/react/components/common/StepProgress.d.ts +2 -0
- package/dist/cjs/anyspend/react/components/common/StepProgress.js +7 -2
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +4 -6
- package/dist/cjs/anyspend/react/hooks/useKycStatus.d.ts +3 -1
- package/dist/cjs/anyspend/react/hooks/useKycStatus.js +11 -7
- package/dist/cjs/app.shared.js +9 -7
- package/dist/cjs/global-account/react/components/B3DynamicModal.js +5 -2
- package/dist/cjs/global-account/react/components/B3Provider/AuthenticationProvider.d.ts +3 -1
- package/dist/cjs/global-account/react/components/B3Provider/AuthenticationProvider.js +2 -1
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +5 -2
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +3 -3
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.js +2 -1
- package/dist/cjs/global-account/react/components/B3Provider/LocalSDKProvider.d.ts +3 -1
- package/dist/cjs/global-account/react/components/B3Provider/LocalSDKProvider.js +3 -1
- package/dist/cjs/global-account/react/components/ManageAccount/SessionDurationContent.d.ts +5 -0
- package/dist/cjs/global-account/react/components/ManageAccount/SessionDurationContent.js +57 -0
- package/dist/cjs/global-account/react/components/ManageAccount/SettingsContent.js +12 -29
- package/dist/cjs/global-account/react/components/SignInWithB3/components/AuthButton.js +10 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +96 -15
- package/dist/cjs/global-account/react/components/SignInWithB3/utils/signInUtils.d.ts +5 -3
- package/dist/cjs/global-account/react/components/SignInWithB3/utils/signInUtils.js +15 -2
- package/dist/cjs/global-account/react/components/Toast/ToastContext.d.ts +3 -0
- package/dist/cjs/global-account/react/components/Toast/ToastContext.js +30 -7
- package/dist/cjs/global-account/react/hooks/useAuth.js +26 -15
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +23 -12
- package/dist/cjs/global-account/react/hooks/useAutoSelectWallet.d.ts +6 -3
- package/dist/cjs/global-account/react/hooks/useAutoSelectWallet.js +31 -3
- package/dist/cjs/global-account/react/hooks/useConnect.d.ts +2 -2
- package/dist/cjs/global-account/react/hooks/useFirstEOA.d.ts +8 -8
- package/dist/cjs/global-account/react/hooks/useTWAuth.js +0 -1
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +10 -1
- package/dist/cjs/global-account/react/utils/createWagmiConfig.d.ts +0 -18
- package/dist/cjs/global-account/react/utils/createWagmiConfig.js +0 -17
- package/dist/cjs/shared/utils/session-duration.d.ts +15 -0
- package/dist/cjs/shared/utils/session-duration.js +69 -0
- package/dist/esm/anyspend/react/components/AnySpendStakeB3.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendStakeB3ExactIn.js +2 -2
- package/dist/esm/anyspend/react/components/checkout/CheckoutPaymentPanel.js +2 -4
- package/dist/esm/anyspend/react/components/checkout/CheckoutSuccess.d.ts +2 -1
- package/dist/esm/anyspend/react/components/checkout/CheckoutSuccess.js +5 -3
- package/dist/esm/anyspend/react/components/checkout/FiatCheckoutPanel.js +2 -3
- package/dist/esm/anyspend/react/components/checkout/KycGate.js +2 -3
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +6 -1
- package/dist/esm/anyspend/react/components/common/OrderStatus.js +34 -3
- package/dist/esm/anyspend/react/components/common/StepProgress.d.ts +2 -0
- package/dist/esm/anyspend/react/components/common/StepProgress.js +4 -2
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +5 -7
- package/dist/esm/anyspend/react/hooks/useKycStatus.d.ts +3 -1
- package/dist/esm/anyspend/react/hooks/useKycStatus.js +9 -5
- package/dist/esm/app.shared.js +9 -7
- package/dist/esm/global-account/react/components/B3DynamicModal.js +5 -2
- package/dist/esm/global-account/react/components/B3Provider/AuthenticationProvider.d.ts +3 -1
- package/dist/esm/global-account/react/components/B3Provider/AuthenticationProvider.js +2 -1
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +5 -2
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +3 -3
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.js +2 -1
- package/dist/esm/global-account/react/components/B3Provider/LocalSDKProvider.d.ts +3 -1
- package/dist/esm/global-account/react/components/B3Provider/LocalSDKProvider.js +3 -1
- package/dist/esm/global-account/react/components/ManageAccount/SessionDurationContent.d.ts +5 -0
- package/dist/esm/global-account/react/components/ManageAccount/SessionDurationContent.js +52 -0
- package/dist/esm/global-account/react/components/ManageAccount/SettingsContent.js +12 -29
- package/dist/esm/global-account/react/components/SignInWithB3/components/AuthButton.js +11 -2
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +100 -19
- package/dist/esm/global-account/react/components/SignInWithB3/utils/signInUtils.d.ts +5 -3
- package/dist/esm/global-account/react/components/SignInWithB3/utils/signInUtils.js +14 -1
- package/dist/esm/global-account/react/components/Toast/ToastContext.d.ts +3 -0
- package/dist/esm/global-account/react/components/Toast/ToastContext.js +30 -7
- package/dist/esm/global-account/react/hooks/useAuth.js +28 -17
- package/dist/esm/global-account/react/hooks/useAuthentication.js +24 -13
- package/dist/esm/global-account/react/hooks/useAutoSelectWallet.d.ts +6 -3
- package/dist/esm/global-account/react/hooks/useAutoSelectWallet.js +33 -5
- package/dist/esm/global-account/react/hooks/useConnect.d.ts +2 -2
- package/dist/esm/global-account/react/hooks/useFirstEOA.d.ts +8 -8
- package/dist/esm/global-account/react/hooks/useTWAuth.js +0 -1
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +10 -1
- package/dist/esm/global-account/react/utils/createWagmiConfig.d.ts +0 -18
- package/dist/esm/global-account/react/utils/createWagmiConfig.js +0 -16
- package/dist/esm/shared/utils/session-duration.d.ts +15 -0
- package/dist/esm/shared/utils/session-duration.js +64 -0
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/react/components/checkout/CheckoutSuccess.d.ts +2 -1
- package/dist/types/anyspend/react/components/common/StepProgress.d.ts +2 -0
- package/dist/types/anyspend/react/hooks/useKycStatus.d.ts +3 -1
- package/dist/types/global-account/react/components/B3Provider/AuthenticationProvider.d.ts +3 -1
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +5 -2
- package/dist/types/global-account/react/components/B3Provider/LocalSDKProvider.d.ts +3 -1
- package/dist/types/global-account/react/components/ManageAccount/SessionDurationContent.d.ts +5 -0
- package/dist/types/global-account/react/components/SignInWithB3/utils/signInUtils.d.ts +5 -3
- package/dist/types/global-account/react/components/Toast/ToastContext.d.ts +3 -0
- package/dist/types/global-account/react/hooks/useAutoSelectWallet.d.ts +6 -3
- package/dist/types/global-account/react/hooks/useConnect.d.ts +2 -2
- package/dist/types/global-account/react/hooks/useFirstEOA.d.ts +8 -8
- package/dist/types/global-account/react/stores/useModalStore.d.ts +10 -1
- package/dist/types/global-account/react/utils/createWagmiConfig.d.ts +0 -18
- package/dist/types/shared/utils/session-duration.d.ts +15 -0
- package/package.json +2 -1
- package/src/anyspend/react/components/AnySpendStakeB3.tsx +2 -2
- package/src/anyspend/react/components/AnySpendStakeB3ExactIn.tsx +2 -2
- package/src/anyspend/react/components/checkout/CheckoutPaymentPanel.tsx +2 -4
- package/src/anyspend/react/components/checkout/CheckoutSuccess.tsx +13 -3
- package/src/anyspend/react/components/checkout/FiatCheckoutPanel.tsx +9 -3
- package/src/anyspend/react/components/checkout/KycGate.tsx +8 -3
- package/src/anyspend/react/components/common/OrderDetails.tsx +8 -0
- package/src/anyspend/react/components/common/OrderStatus.tsx +38 -3
- package/src/anyspend/react/components/common/StepProgress.tsx +15 -5
- package/src/anyspend/react/hooks/useAnyspendCreateOnrampOrder.ts +5 -7
- package/src/anyspend/react/hooks/useKycStatus.ts +8 -5
- package/src/app.shared.ts +9 -8
- package/src/global-account/react/components/B3DynamicModal.tsx +5 -2
- package/src/global-account/react/components/B3Provider/AuthenticationProvider.tsx +4 -0
- package/src/global-account/react/components/B3Provider/B3Provider.native.tsx +2 -1
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +16 -3
- package/src/global-account/react/components/B3Provider/LocalSDKProvider.tsx +5 -0
- package/src/global-account/react/components/ManageAccount/SessionDurationContent.tsx +107 -0
- package/src/global-account/react/components/ManageAccount/SettingsContent.tsx +28 -30
- package/src/global-account/react/components/SignInWithB3/components/AuthButton.tsx +21 -2
- package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +207 -54
- package/src/global-account/react/components/SignInWithB3/utils/signInUtils.ts +19 -3
- package/src/global-account/react/components/Toast/ToastContext.tsx +39 -7
- package/src/global-account/react/hooks/useAuth.ts +28 -17
- package/src/global-account/react/hooks/useAuthentication.ts +24 -13
- package/src/global-account/react/hooks/useAutoSelectWallet.ts +40 -6
- package/src/global-account/react/hooks/useConnect.tsx +2 -2
- package/src/global-account/react/hooks/useTWAuth.tsx +0 -1
- package/src/global-account/react/stores/useModalStore.ts +11 -0
- package/src/global-account/react/utils/createWagmiConfig.tsx +0 -18
- package/src/shared/utils/session-duration.ts +64 -0
- package/src/types/torph.d.ts +4 -0
|
@@ -1,38 +1,52 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { AuthButton, Button, getConnectOptionsFromStrategy, isWalletType, LoginStepContainer, useAuthentication, useAuthStore, useB3Config, useConnect, WalletRow, } from "../../../../../global-account/react/index.js";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { AuthButton, Button, getConnectOptionsFromStrategy, Input, isWalletType, LoginStepContainer, useAuthentication, useAuthStore, useB3Config, useConnect, WalletRow, } from "../../../../../global-account/react/index.js";
|
|
3
|
+
import { ecosystemWalletId } from "../../../../../shared/constants/index.js";
|
|
3
4
|
import { debugB3React } from "../../../../../shared/utils/debug.js";
|
|
4
5
|
import { client } from "../../../../../shared/utils/thirdweb.js";
|
|
5
6
|
import { useState } from "react";
|
|
6
|
-
import { useConnect as useConnectTW } from "thirdweb/react";
|
|
7
|
-
import { createWallet } from "thirdweb/wallets";
|
|
7
|
+
import { useConnectedWallets, useConnect as useConnectTW } from "thirdweb/react";
|
|
8
|
+
import { createWallet, preAuthenticate, } from "thirdweb/wallets";
|
|
8
9
|
const debug = debugB3React("LoginStepCustom");
|
|
10
|
+
const EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
9
11
|
export function LoginStepCustom({ onSuccess, onError, chain, strategies, maxInitialWallets = 2, automaticallySetFirstEoa, }) {
|
|
10
12
|
const { partnerId } = useB3Config();
|
|
11
13
|
const [isLoading, setIsLoading] = useState(false);
|
|
12
14
|
const [showAllWallets, setShowAllWallets] = useState(false);
|
|
15
|
+
const [showEmailFlow, setShowEmailFlow] = useState(false);
|
|
16
|
+
const [email, setEmail] = useState("");
|
|
17
|
+
const [verificationCode, setVerificationCode] = useState("");
|
|
18
|
+
const [emailCodeSent, setEmailCodeSent] = useState(false);
|
|
19
|
+
const [emailError, setEmailError] = useState(null);
|
|
13
20
|
const { connect } = useConnect(partnerId, chain);
|
|
14
21
|
const setIsAuthenticating = useAuthStore(state => state.setIsAuthenticating);
|
|
15
|
-
const
|
|
16
|
-
const { logout } = useAuthentication(partnerId, { skipAutoConnect: true });
|
|
22
|
+
const { connect: onAuthConnect, logout } = useAuthentication(partnerId, { skipAutoConnect: true });
|
|
17
23
|
const { connect: connectTW } = useConnectTW();
|
|
24
|
+
const connectedWallets = useConnectedWallets();
|
|
18
25
|
// Split strategies into auth and wallet types
|
|
19
26
|
const authStrategies = strategies.filter(s => !isWalletType(s));
|
|
20
27
|
const walletStrategies = strategies.filter(isWalletType);
|
|
21
28
|
const initialWallets = walletStrategies.slice(0, maxInitialWallets);
|
|
22
29
|
const additionalWallets = walletStrategies.slice(maxInitialWallets);
|
|
23
|
-
const
|
|
30
|
+
const authGridColumns = Math.max(1, Math.min(authStrategies.length, 4));
|
|
31
|
+
const resetEmailFlow = () => {
|
|
32
|
+
setShowEmailFlow(false);
|
|
33
|
+
setEmailCodeSent(false);
|
|
34
|
+
setVerificationCode("");
|
|
35
|
+
setEmailError(null);
|
|
36
|
+
};
|
|
37
|
+
const connectWithOptions = async (strategy, options) => {
|
|
24
38
|
try {
|
|
25
39
|
setIsLoading(true);
|
|
26
40
|
debug("setIsAuthenticating:true:3");
|
|
27
41
|
setIsAuthenticating(true);
|
|
28
|
-
const options = getConnectOptionsFromStrategy(strategy);
|
|
29
42
|
let connectResult;
|
|
30
|
-
if (automaticallySetFirstEoa) {
|
|
31
|
-
|
|
43
|
+
if (automaticallySetFirstEoa && isWalletType(strategy) && options.strategy === "wallet") {
|
|
44
|
+
const walletId = options.wallet?.id;
|
|
45
|
+
if (!walletId) {
|
|
32
46
|
throw new Error("Wallet ID is required");
|
|
33
47
|
}
|
|
34
48
|
connectResult = await connectTW(async () => {
|
|
35
|
-
const wallet = createWallet(
|
|
49
|
+
const wallet = createWallet(walletId);
|
|
36
50
|
await wallet.connect({
|
|
37
51
|
client,
|
|
38
52
|
});
|
|
@@ -40,20 +54,27 @@ export function LoginStepCustom({ onSuccess, onError, chain, strategies, maxInit
|
|
|
40
54
|
});
|
|
41
55
|
}
|
|
42
56
|
else {
|
|
43
|
-
// @ts-expect-error we have custom strategies too and we also get things like "apple" isn't assignable to "wallet"
|
|
44
57
|
connectResult = await connect(options);
|
|
45
58
|
}
|
|
46
59
|
const account = connectResult?.getAccount();
|
|
47
60
|
debug("@@connectResult", { connectResult, account, options });
|
|
48
|
-
if (!account)
|
|
61
|
+
if (!account || !connectResult)
|
|
49
62
|
throw new Error("Failed to connect");
|
|
63
|
+
const allConnectedWallets = connectedWallets.length > 0 && connectedWallets.some(wallet => wallet.id === connectResult.id)
|
|
64
|
+
? connectedWallets
|
|
65
|
+
: [connectResult, ...connectedWallets.filter(wallet => wallet.id !== connectResult.id)];
|
|
66
|
+
await onAuthConnect(connectResult, allConnectedWallets);
|
|
50
67
|
await onSuccess(account);
|
|
51
|
-
|
|
68
|
+
if (strategy === "email") {
|
|
69
|
+
resetEmailFlow();
|
|
70
|
+
}
|
|
52
71
|
}
|
|
53
72
|
catch (error) {
|
|
73
|
+
if (strategy === "email") {
|
|
74
|
+
setEmailError(error instanceof Error ? error.message : "Failed to sign in with email");
|
|
75
|
+
}
|
|
54
76
|
await onError?.(error);
|
|
55
77
|
await logout();
|
|
56
|
-
setIsAuthenticated(false);
|
|
57
78
|
}
|
|
58
79
|
finally {
|
|
59
80
|
setIsLoading(false);
|
|
@@ -61,8 +82,68 @@ export function LoginStepCustom({ onSuccess, onError, chain, strategies, maxInit
|
|
|
61
82
|
setIsAuthenticating(false);
|
|
62
83
|
}
|
|
63
84
|
};
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
85
|
+
const handleConnect = async (strategy) => {
|
|
86
|
+
if (strategy === "email") {
|
|
87
|
+
setShowEmailFlow(true);
|
|
88
|
+
setEmailCodeSent(false);
|
|
89
|
+
setVerificationCode("");
|
|
90
|
+
setEmailError(null);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const options = getConnectOptionsFromStrategy(strategy);
|
|
94
|
+
await connectWithOptions(strategy, options);
|
|
95
|
+
};
|
|
96
|
+
const handleSendEmailCode = async () => {
|
|
97
|
+
const normalizedEmail = email.trim().toLowerCase();
|
|
98
|
+
if (!normalizedEmail) {
|
|
99
|
+
setEmailError("Please enter your email address");
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
if (!EMAIL_REGEX.test(normalizedEmail)) {
|
|
103
|
+
setEmailError("Please enter a valid email address");
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
try {
|
|
107
|
+
setIsLoading(true);
|
|
108
|
+
setEmailError(null);
|
|
109
|
+
await preAuthenticate({
|
|
110
|
+
client,
|
|
111
|
+
strategy: "email",
|
|
112
|
+
email: normalizedEmail,
|
|
113
|
+
ecosystem: {
|
|
114
|
+
id: ecosystemWalletId,
|
|
115
|
+
partnerId,
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
setEmail(normalizedEmail);
|
|
119
|
+
setEmailCodeSent(true);
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
setEmailError(error instanceof Error ? error.message : "Failed to send verification code");
|
|
123
|
+
await onError?.(error);
|
|
124
|
+
}
|
|
125
|
+
finally {
|
|
126
|
+
setIsLoading(false);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
const handleEmailLogin = async () => {
|
|
130
|
+
const normalizedEmail = email.trim().toLowerCase();
|
|
131
|
+
const normalizedCode = verificationCode.trim();
|
|
132
|
+
if (!EMAIL_REGEX.test(normalizedEmail)) {
|
|
133
|
+
setEmailError("Please enter a valid email address");
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (!normalizedCode) {
|
|
137
|
+
setEmailError("Please enter your verification code");
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
await connectWithOptions("email", {
|
|
141
|
+
strategy: "email",
|
|
142
|
+
email: normalizedEmail,
|
|
143
|
+
verificationCode: normalizedCode,
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
return (_jsx(LoginStepContainer, { partnerId: partnerId, children: showEmailFlow ? (_jsxs("div", { className: "mb-6 w-full space-y-3 px-3", children: [_jsx("p", { className: "text-center text-sm font-medium text-gray-900 dark:text-gray-100", children: "Sign in with email" }), _jsx(Input, { type: "email", placeholder: "you@example.com", value: email, onChange: event => setEmail(event.target.value), disabled: isLoading || emailCodeSent }), emailCodeSent && (_jsx(Input, { type: "text", placeholder: "Enter verification code", value: verificationCode, onChange: event => setVerificationCode(event.target.value), disabled: isLoading })), emailError && _jsx("p", { className: "text-sm text-red-500", children: emailError }), _jsx(Button, { onClick: emailCodeSent ? handleEmailLogin : handleSendEmailCode, disabled: isLoading, className: "w-full", children: isLoading ? "Loading..." : emailCodeSent ? "Verify code" : "Send code" }), emailCodeSent && (_jsx(Button, { variant: "outline", onClick: handleSendEmailCode, disabled: isLoading, className: "w-full", children: "Resend code" })), _jsx(Button, { variant: "outline", onClick: resetEmailFlow, disabled: isLoading, className: "w-full", children: "Back" })] })) : (_jsxs(_Fragment, { children: [authStrategies.length > 0 && (_jsx("div", { className: `mb-6 grid w-full gap-4 px-3 ${authStrategies.length > 4 ? "grid-cols-4" : ""}`, style: authStrategies.length <= 4
|
|
147
|
+
? { gridTemplateColumns: `repeat(${authGridColumns}, minmax(0, 1fr))` }
|
|
148
|
+
: undefined, children: authStrategies.map(strategy => (_jsx(AuthButton, { strategy: strategy, onClick: () => handleConnect(strategy), isLoading: isLoading }, strategy))) })), _jsx("div", { className: "mb-4 w-full space-y-2", children: initialWallets.map(walletId => (_jsx(WalletRow, { walletId: walletId, onClick: () => handleConnect(walletId), isLoading: isLoading }, walletId))) }), additionalWallets.length > 0 && (_jsxs("div", { className: "w-full", children: [_jsx(Button, { onClick: () => setShowAllWallets(!showAllWallets), className: "mb-2 w-full bg-transparent text-gray-600 hover:bg-gray-100", children: showAllWallets ? "Show less" : "More options" }), showAllWallets && (_jsx("div", { className: "max-h-60 space-y-2 overflow-y-auto", children: additionalWallets.map(walletId => (_jsx(WalletRow, { walletId: walletId, onClick: () => handleConnect(walletId), isLoading: isLoading }, walletId))) }))] }))] })) }));
|
|
68
149
|
}
|
|
@@ -3,15 +3,17 @@ import { SingleStepAuthArgsType, Wallet } from "thirdweb/wallets";
|
|
|
3
3
|
type WalletType = Wallet["id"];
|
|
4
4
|
type StrategyType = SingleStepAuthArgsType["strategy"];
|
|
5
5
|
type CustomStrategyType = "basement" | "privy";
|
|
6
|
-
type AllowedStrategies = StrategyType | WalletType | CustomStrategyType;
|
|
7
|
-
|
|
6
|
+
type AllowedStrategies = StrategyType | WalletType | CustomStrategyType | "email";
|
|
7
|
+
type NonWalletStrategyType = Exclude<AllowedStrategies, WalletType>;
|
|
8
|
+
export declare const allowedStrategies: readonly ["apple", "google", "github", "x", "discord", "email", "guest", "walletConnect", "io.metamask", "com.coinbase.wallet", "basement", "privy"];
|
|
8
9
|
export type AllowedStrategy = (typeof allowedStrategies)[number];
|
|
9
10
|
export declare function isWalletType(strategy: AllowedStrategies): strategy is WalletType;
|
|
10
|
-
export declare function isStrategyType(strategy: AllowedStrategies): strategy is
|
|
11
|
+
export declare function isStrategyType(strategy: AllowedStrategies): strategy is NonWalletStrategyType;
|
|
11
12
|
export declare function getConnectOptionsFromStrategy(strategy: AllowedStrategy): {
|
|
12
13
|
strategy: StrategyType;
|
|
13
14
|
wallet?: Wallet;
|
|
14
15
|
chain?: Chain;
|
|
15
16
|
};
|
|
16
17
|
export declare const strategyIcons: Record<string, string>;
|
|
18
|
+
export declare const strategyLabels: Record<string, string>;
|
|
17
19
|
export {};
|
|
@@ -5,9 +5,10 @@ export const allowedStrategies = [
|
|
|
5
5
|
// Auth strategies
|
|
6
6
|
"apple",
|
|
7
7
|
"google",
|
|
8
|
+
"github",
|
|
8
9
|
"x",
|
|
9
10
|
"discord",
|
|
10
|
-
|
|
11
|
+
"email",
|
|
11
12
|
"guest",
|
|
12
13
|
// Wallet IDs
|
|
13
14
|
"walletConnect",
|
|
@@ -29,6 +30,9 @@ export function getConnectOptionsFromStrategy(strategy) {
|
|
|
29
30
|
if (!allowedStrategies.includes(strategy)) {
|
|
30
31
|
throw new Error(`Invalid strategy: ${strategy}`);
|
|
31
32
|
}
|
|
33
|
+
if (strategy === "email") {
|
|
34
|
+
throw new Error("Email strategy requires OTP flow and cannot be connected in a single step");
|
|
35
|
+
}
|
|
32
36
|
if (isWalletType(strategy)) {
|
|
33
37
|
return { strategy: "wallet", wallet: createWallet(strategy) };
|
|
34
38
|
}
|
|
@@ -45,6 +49,15 @@ export const strategyIcons = {
|
|
|
45
49
|
guest: "https://cdn.b3.fun/incognito.svg",
|
|
46
50
|
// Add more strategies as needed
|
|
47
51
|
};
|
|
52
|
+
export const strategyLabels = {
|
|
53
|
+
google: "Google",
|
|
54
|
+
x: "X",
|
|
55
|
+
discord: "Discord",
|
|
56
|
+
apple: "Apple",
|
|
57
|
+
guest: "Guest",
|
|
58
|
+
github: "GitHub",
|
|
59
|
+
email: "Email",
|
|
60
|
+
};
|
|
48
61
|
// Test it
|
|
49
62
|
// console.log(getConnectOptionsFromStrategy("io.metamask"));
|
|
50
63
|
// console.log(getConnectOptionsFromStrategy("google"));
|
|
@@ -11,6 +11,9 @@ interface ToastContextType {
|
|
|
11
11
|
addToast: (type: ToastType, message: string, duration?: number) => string;
|
|
12
12
|
removeToast: (id: string) => void;
|
|
13
13
|
clearAll: () => void;
|
|
14
|
+
headerMode: boolean;
|
|
15
|
+
setHeaderMode: (enabled: boolean) => void;
|
|
16
|
+
latestToast: ToastItem | null;
|
|
14
17
|
}
|
|
15
18
|
export declare function ToastProvider({ children }: {
|
|
16
19
|
children: React.ReactNode;
|
|
@@ -4,6 +4,9 @@ const ToastContext = createContext(undefined);
|
|
|
4
4
|
let globalToastCounter = 0;
|
|
5
5
|
export function ToastProvider({ children }) {
|
|
6
6
|
const [toasts, setToasts] = useState([]);
|
|
7
|
+
const [headerMode, setHeaderMode] = useState(false);
|
|
8
|
+
const headerModeRef = useRef(false);
|
|
9
|
+
const [latestToast, setLatestToast] = useState(null);
|
|
7
10
|
const timeoutsRef = useRef(new Map());
|
|
8
11
|
const removeToast = useCallback((id) => {
|
|
9
12
|
setToasts(prev => prev.filter(toast => toast.id !== id));
|
|
@@ -22,12 +25,23 @@ export function ToastProvider({ children }) {
|
|
|
22
25
|
duration,
|
|
23
26
|
createdAt: Date.now(),
|
|
24
27
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
if (headerModeRef.current) {
|
|
29
|
+
setLatestToast(newToast);
|
|
30
|
+
if (duration > 0) {
|
|
31
|
+
const timeout = setTimeout(() => {
|
|
32
|
+
setLatestToast(null);
|
|
33
|
+
}, duration);
|
|
34
|
+
timeoutsRef.current.set(id, timeout);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
setToasts(prev => [...prev, newToast]);
|
|
39
|
+
if (duration > 0) {
|
|
40
|
+
const timeout = setTimeout(() => {
|
|
41
|
+
removeToast(id);
|
|
42
|
+
}, duration);
|
|
43
|
+
timeoutsRef.current.set(id, timeout);
|
|
44
|
+
}
|
|
31
45
|
}
|
|
32
46
|
return id;
|
|
33
47
|
}, [removeToast]);
|
|
@@ -36,6 +50,15 @@ export function ToastProvider({ children }) {
|
|
|
36
50
|
timeoutsRef.current.clear();
|
|
37
51
|
setToasts([]);
|
|
38
52
|
}, []);
|
|
53
|
+
const setHeaderModeCallback = useCallback((enabled) => {
|
|
54
|
+
setHeaderMode(enabled);
|
|
55
|
+
headerModeRef.current = enabled;
|
|
56
|
+
if (!enabled) {
|
|
57
|
+
setLatestToast(null);
|
|
58
|
+
timeoutsRef.current.forEach(timeout => clearTimeout(timeout));
|
|
59
|
+
timeoutsRef.current.clear();
|
|
60
|
+
}
|
|
61
|
+
}, []);
|
|
39
62
|
// Cleanup on unmount
|
|
40
63
|
useEffect(() => {
|
|
41
64
|
const timeouts = timeoutsRef.current;
|
|
@@ -44,7 +67,7 @@ export function ToastProvider({ children }) {
|
|
|
44
67
|
timeouts.clear();
|
|
45
68
|
};
|
|
46
69
|
}, []);
|
|
47
|
-
return _jsx(ToastContext.Provider, { value: { toasts, addToast, removeToast, clearAll }, children: children });
|
|
70
|
+
return (_jsx(ToastContext.Provider, { value: { toasts, addToast, removeToast, clearAll, headerMode, setHeaderMode: setHeaderModeCallback, latestToast }, children: children }));
|
|
48
71
|
}
|
|
49
72
|
export function useToastContext() {
|
|
50
73
|
const context = useContext(ToastContext);
|
|
@@ -5,13 +5,13 @@ import { ecosystemWalletId } from "../../../shared/constants/index.js";
|
|
|
5
5
|
import { debugB3React } from "../../../shared/utils/debug.js";
|
|
6
6
|
import { client } from "../../../shared/utils/thirdweb.js";
|
|
7
7
|
import { getConnectors } from "@wagmi/core";
|
|
8
|
-
import { useCallback, useContext, useEffect, useRef } from "react";
|
|
8
|
+
import { useCallback, useContext, useEffect, useMemo, useRef } from "react";
|
|
9
9
|
import { useActiveWallet, useAutoConnect, useConnectedWallets, useDisconnect, useSetActiveWallet, } from "thirdweb/react";
|
|
10
10
|
import { ecosystemWallet } from "thirdweb/wallets";
|
|
11
11
|
import { preAuthenticate } from "thirdweb/wallets/in-app";
|
|
12
12
|
import { useAccount, useConnect, useSwitchAccount } from "wagmi";
|
|
13
13
|
import { LocalSDKContext } from "../components/B3Provider/LocalSDKProvider.js";
|
|
14
|
-
import {
|
|
14
|
+
import { createWagmiConfig } from "../utils/createWagmiConfig.js";
|
|
15
15
|
import { useSearchParam } from "./useSearchParamsSSR.js";
|
|
16
16
|
import { useUserQuery } from "./useUserQuery.js";
|
|
17
17
|
const debug = debugB3React("useAuth");
|
|
@@ -21,7 +21,7 @@ const debug = debugB3React("useAuth");
|
|
|
21
21
|
* This hook provides 1:1 feature parity with useAuthentication.ts
|
|
22
22
|
*/
|
|
23
23
|
export function useAuth() {
|
|
24
|
-
const { onConnectCallback } = useContext(LocalSDKContext);
|
|
24
|
+
const { onConnectCallback, disableBSMNTAuthentication } = useContext(LocalSDKContext);
|
|
25
25
|
const { disconnect } = useDisconnect();
|
|
26
26
|
const wallets = useConnectedWallets();
|
|
27
27
|
const activeWallet = useActiveWallet();
|
|
@@ -38,7 +38,7 @@ export function useAuth() {
|
|
|
38
38
|
const useAutoConnectLoadingPrevious = useRef(false);
|
|
39
39
|
const referralCode = useSearchParam("referralCode");
|
|
40
40
|
const { partnerId } = useB3Config();
|
|
41
|
-
const wagmiConfig =
|
|
41
|
+
const wagmiConfig = useMemo(() => createWagmiConfig({ partnerId }), [partnerId]);
|
|
42
42
|
const { connect } = useConnect();
|
|
43
43
|
const activeWagmiAccount = useAccount();
|
|
44
44
|
const { switchAccount } = useSwitchAccount();
|
|
@@ -63,8 +63,10 @@ export function useAuth() {
|
|
|
63
63
|
}
|
|
64
64
|
// Authenticate with BSMNT
|
|
65
65
|
try {
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
if (!disableBSMNTAuthentication) {
|
|
67
|
+
const b3Jwt = await authenticateWithB3JWT(response.accessToken);
|
|
68
|
+
debug("BSMNT re-authentication successful", b3Jwt);
|
|
69
|
+
}
|
|
68
70
|
}
|
|
69
71
|
catch (bsmntError) {
|
|
70
72
|
// BSMNT authentication failure shouldn't block the main auth flow
|
|
@@ -76,7 +78,7 @@ export function useAuth() {
|
|
|
76
78
|
debug("Re-authentication failed", err);
|
|
77
79
|
throw err;
|
|
78
80
|
}
|
|
79
|
-
}, [setUser]);
|
|
81
|
+
}, [setUser, disableBSMNTAuthentication]);
|
|
80
82
|
const syncWagmi = useCallback(async () => {
|
|
81
83
|
function syncWagmiFunc() {
|
|
82
84
|
const connectors = getConnectors(wagmiConfig);
|
|
@@ -120,9 +122,7 @@ export function useAuth() {
|
|
|
120
122
|
});
|
|
121
123
|
}
|
|
122
124
|
syncWagmiFunc();
|
|
123
|
-
|
|
124
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
125
|
-
}, [partnerId, wallets]);
|
|
125
|
+
}, [wagmiConfig, wallets, connect, switchAccount]);
|
|
126
126
|
useEffect(() => {
|
|
127
127
|
syncWagmi();
|
|
128
128
|
}, [wallets, syncWagmi]);
|
|
@@ -139,9 +139,11 @@ export function useAuth() {
|
|
|
139
139
|
setIsAuthenticated(true);
|
|
140
140
|
setIsAuthenticating(false);
|
|
141
141
|
debug("Re-authenticated successfully", { userAuth });
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
142
|
+
if (!disableBSMNTAuthentication) {
|
|
143
|
+
// Authenticate on BSMNT with B3 JWT
|
|
144
|
+
const b3Jwt = await authenticateWithB3JWT(userAuth.accessToken);
|
|
145
|
+
debug("@@b3Jwt", b3Jwt);
|
|
146
|
+
}
|
|
145
147
|
return userAuth;
|
|
146
148
|
}
|
|
147
149
|
catch (error) {
|
|
@@ -151,7 +153,14 @@ export function useAuth() {
|
|
|
151
153
|
setIsAuthenticating(false);
|
|
152
154
|
throw new Error("Authentication required. Please authenticate.");
|
|
153
155
|
}
|
|
154
|
-
}, [
|
|
156
|
+
}, [
|
|
157
|
+
reAuthenticate,
|
|
158
|
+
setIsAuthenticated,
|
|
159
|
+
setIsAuthenticating,
|
|
160
|
+
setUser,
|
|
161
|
+
setHasStartedConnecting,
|
|
162
|
+
disableBSMNTAuthentication,
|
|
163
|
+
]);
|
|
155
164
|
/**
|
|
156
165
|
* Authenticate with B3
|
|
157
166
|
*
|
|
@@ -181,8 +190,10 @@ export function useAuth() {
|
|
|
181
190
|
}
|
|
182
191
|
// Step 3: Authenticate with BSMNT for basement integration
|
|
183
192
|
try {
|
|
184
|
-
|
|
185
|
-
|
|
193
|
+
if (!disableBSMNTAuthentication) {
|
|
194
|
+
const b3Jwt = await authenticateWithB3JWT(response.accessToken);
|
|
195
|
+
debug("BSMNT authentication successful", b3Jwt);
|
|
196
|
+
}
|
|
186
197
|
}
|
|
187
198
|
catch (bsmntError) {
|
|
188
199
|
// BSMNT authentication failure shouldn't block the main auth flow
|
|
@@ -194,7 +205,7 @@ export function useAuth() {
|
|
|
194
205
|
debug("Authentication failed", err);
|
|
195
206
|
throw err;
|
|
196
207
|
}
|
|
197
|
-
}, [referralCode, setUser]);
|
|
208
|
+
}, [referralCode, setUser, disableBSMNTAuthentication]);
|
|
198
209
|
/**
|
|
199
210
|
* Handle wallet connection
|
|
200
211
|
*/
|
|
@@ -5,7 +5,7 @@ import { ecosystemWalletId } from "../../../shared/constants/index.js";
|
|
|
5
5
|
import { debugB3React } from "../../../shared/utils/debug.js";
|
|
6
6
|
import { client } from "../../../shared/utils/thirdweb.js";
|
|
7
7
|
import { getConnectors } from "@wagmi/core";
|
|
8
|
-
import { useCallback, useContext, useEffect, useRef } from "react";
|
|
8
|
+
import { useCallback, useContext, useEffect, useMemo, useRef } from "react";
|
|
9
9
|
import { useActiveWallet, useAutoConnect, useConnectedWallets, useDisconnect, useSetActiveWallet, } from "thirdweb/react";
|
|
10
10
|
import { ecosystemWallet } from "thirdweb/wallets";
|
|
11
11
|
import { preAuthenticate } from "thirdweb/wallets/in-app";
|
|
@@ -16,7 +16,7 @@ import { useTWAuth } from "./useTWAuth.js";
|
|
|
16
16
|
import { useUserQuery } from "./useUserQuery.js";
|
|
17
17
|
const debug = debugB3React("useAuthentication");
|
|
18
18
|
export function useAuthentication(partnerId, { skipAutoConnect = false } = {}) {
|
|
19
|
-
const { onConnectCallback, onLogoutCallback } = useContext(LocalSDKContext);
|
|
19
|
+
const { onConnectCallback, onLogoutCallback, disableBSMNTAuthentication } = useContext(LocalSDKContext);
|
|
20
20
|
const { disconnect } = useDisconnect();
|
|
21
21
|
const wallets = useConnectedWallets();
|
|
22
22
|
// Keep refs so logout() always disconnects current wallets, not stale closure values.
|
|
@@ -48,7 +48,7 @@ export function useAuthentication(partnerId, { skipAutoConnect = false } = {}) {
|
|
|
48
48
|
const { authenticate } = useTWAuth();
|
|
49
49
|
const { user, setUser } = useUserQuery();
|
|
50
50
|
const useAutoConnectLoadingPrevious = useRef(false);
|
|
51
|
-
const wagmiConfig = createWagmiConfig({ partnerId });
|
|
51
|
+
const wagmiConfig = useMemo(() => createWagmiConfig({ partnerId }), [partnerId]);
|
|
52
52
|
const { connect } = useConnect();
|
|
53
53
|
const activeWagmiAccount = useAccount();
|
|
54
54
|
const { switchAccount } = useSwitchAccount();
|
|
@@ -99,9 +99,7 @@ export function useAuthentication(partnerId, { skipAutoConnect = false } = {}) {
|
|
|
99
99
|
});
|
|
100
100
|
}
|
|
101
101
|
syncWagmiFunc();
|
|
102
|
-
|
|
103
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
104
|
-
}, [partnerId, wallets]);
|
|
102
|
+
}, [wagmiConfig, wallets, connect, switchAccount]);
|
|
105
103
|
useEffect(() => {
|
|
106
104
|
syncWagmi();
|
|
107
105
|
}, [wallets, syncWagmi]);
|
|
@@ -121,9 +119,11 @@ export function useAuthentication(partnerId, { skipAutoConnect = false } = {}) {
|
|
|
121
119
|
setIsAuthenticated(true);
|
|
122
120
|
setIsAuthenticating(false);
|
|
123
121
|
debug("Re-authenticated successfully", { userAuth });
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
122
|
+
if (!disableBSMNTAuthentication) {
|
|
123
|
+
// Authenticate on BSMNT with B3 JWT
|
|
124
|
+
const b3Jwt = await authenticateWithB3JWT(userAuth.accessToken);
|
|
125
|
+
debug("@@b3Jwt", b3Jwt);
|
|
126
|
+
}
|
|
127
127
|
return userAuth;
|
|
128
128
|
}
|
|
129
129
|
catch (error) {
|
|
@@ -134,12 +134,23 @@ export function useAuthentication(partnerId, { skipAutoConnect = false } = {}) {
|
|
|
134
134
|
setIsAuthenticated(true);
|
|
135
135
|
setIsAuthenticating(false);
|
|
136
136
|
debug("Fresh authentication successful", { userAuth });
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
if (!disableBSMNTAuthentication) {
|
|
138
|
+
// Authenticate on BSMNT with B3 JWT
|
|
139
|
+
const b3Jwt = await authenticateWithB3JWT(userAuth.accessToken);
|
|
140
|
+
debug("@@b3Jwt", b3Jwt);
|
|
141
|
+
}
|
|
140
142
|
return userAuth;
|
|
141
143
|
}
|
|
142
|
-
}, [
|
|
144
|
+
}, [
|
|
145
|
+
activeWallet,
|
|
146
|
+
partnerId,
|
|
147
|
+
authenticate,
|
|
148
|
+
setIsAuthenticated,
|
|
149
|
+
setIsAuthenticating,
|
|
150
|
+
setUser,
|
|
151
|
+
setHasStartedConnecting,
|
|
152
|
+
disableBSMNTAuthentication,
|
|
153
|
+
]);
|
|
143
154
|
const logout = useCallback(async (callback) => {
|
|
144
155
|
// Disconnect ecosystem/smart wallets from the connected wallets list.
|
|
145
156
|
// EOA wallets (MetaMask, Coinbase Wallet) are left in the list so they can
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { EIP1193 } from "thirdweb/wallets";
|
|
1
2
|
/**
|
|
2
|
-
* Hook to automatically
|
|
3
|
-
*
|
|
3
|
+
* Hook to automatically connect a default EOA provider (if given) and
|
|
4
|
+
* select the first EOA wallet when user is authenticated.
|
|
5
|
+
* Only auto-selects if the last auth was via wallet or no previous auth provider.
|
|
4
6
|
*/
|
|
5
|
-
export declare function useAutoSelectWallet({ enabled }: {
|
|
7
|
+
export declare function useAutoSelectWallet({ enabled, defaultEoaProvider, }: {
|
|
6
8
|
enabled: boolean;
|
|
9
|
+
defaultEoaProvider?: EIP1193.EIP1193Provider;
|
|
7
10
|
}): void;
|
|
@@ -1,16 +1,44 @@
|
|
|
1
|
+
import { client } from "../../../shared/utils/thirdweb.js";
|
|
1
2
|
import { debugB3React } from "../../../shared/utils/debug.js";
|
|
2
|
-
import { useCallback, useEffect } from "react";
|
|
3
|
-
import { getLastAuthProvider, useConnectedWallets, useSetActiveWallet } from "thirdweb/react";
|
|
3
|
+
import { useCallback, useEffect, useRef } from "react";
|
|
4
|
+
import { getLastAuthProvider, useAddConnectedWallet, useConnectedWallets, useSetActiveWallet } from "thirdweb/react";
|
|
5
|
+
import { EIP1193 } from "thirdweb/wallets";
|
|
4
6
|
import { useAuthStore } from "../stores/index.js";
|
|
5
7
|
const debug = debugB3React("useAutoSelectWallet");
|
|
6
8
|
/**
|
|
7
|
-
* Hook to automatically
|
|
8
|
-
*
|
|
9
|
+
* Hook to automatically connect a default EOA provider (if given) and
|
|
10
|
+
* select the first EOA wallet when user is authenticated.
|
|
11
|
+
* Only auto-selects if the last auth was via wallet or no previous auth provider.
|
|
9
12
|
*/
|
|
10
|
-
export function useAutoSelectWallet({ enabled }) {
|
|
13
|
+
export function useAutoSelectWallet({ enabled, defaultEoaProvider, }) {
|
|
11
14
|
const isAuthenticated = useAuthStore(state => state.isAuthenticated);
|
|
12
15
|
const wallets = useConnectedWallets();
|
|
13
16
|
const setActiveWallet = useSetActiveWallet();
|
|
17
|
+
const addConnectedWallet = useAddConnectedWallet();
|
|
18
|
+
const hasConnectedProvider = useRef(false);
|
|
19
|
+
// Auto-connect the default EOA provider (e.g. Farcaster frame wallet) on mount.
|
|
20
|
+
// Uses useAddConnectedWallet instead of useConnect so the wallet is added to
|
|
21
|
+
// connectedWallets WITHOUT becoming the active wallet. This prevents
|
|
22
|
+
// useAuthentication's logout/onTimeout from disconnecting it (logout only
|
|
23
|
+
// disconnects ecosystem wallets and the active wallet).
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (!defaultEoaProvider || hasConnectedProvider.current)
|
|
26
|
+
return;
|
|
27
|
+
hasConnectedProvider.current = true;
|
|
28
|
+
const connectDefaultProvider = async () => {
|
|
29
|
+
try {
|
|
30
|
+
const wallet = EIP1193.fromProvider({ provider: defaultEoaProvider });
|
|
31
|
+
await wallet.connect({ client });
|
|
32
|
+
addConnectedWallet(wallet);
|
|
33
|
+
debug("Auto-connected default EOA provider", wallet.id);
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
debug("Failed to auto-connect default EOA provider", error);
|
|
37
|
+
hasConnectedProvider.current = false;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
connectDefaultProvider();
|
|
41
|
+
}, [defaultEoaProvider, addConnectedWallet]);
|
|
14
42
|
const setWallet = useCallback((wallet) => {
|
|
15
43
|
debug("@@setWallet", wallet.id, wallet.getAccount()?.address);
|
|
16
44
|
setActiveWallet(wallet);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Chain } from "thirdweb";
|
|
2
|
-
import { SingleStepAuthArgsType } from "thirdweb/wallets";
|
|
2
|
+
import { MultiStepAuthArgsType, SingleStepAuthArgsType } from "thirdweb/wallets";
|
|
3
3
|
/**
|
|
4
4
|
* This hook is used to connect to a wallet using the thirdweb client.
|
|
5
5
|
*/
|
|
6
6
|
export declare function useConnect(partnerId: string, chain?: Chain): {
|
|
7
|
-
connect: (strategyOptions?: SingleStepAuthArgsType) => Promise<import("thirdweb/wallets").Wallet | null>;
|
|
7
|
+
connect: (strategyOptions?: MultiStepAuthArgsType | SingleStepAuthArgsType) => Promise<import("thirdweb/wallets").Wallet | null>;
|
|
8
8
|
isLoading: boolean;
|
|
9
9
|
};
|
|
@@ -7451,8 +7451,10 @@ export declare function useFirstEOA(chain?: {
|
|
|
7451
7451
|
[x: `bool[${string}]`]: undefined;
|
|
7452
7452
|
[x: `bytes[${string}]`]: undefined;
|
|
7453
7453
|
[x: `bytes1[${string}]`]: undefined;
|
|
7454
|
-
[x: `
|
|
7454
|
+
[x: `bytes7[${string}]`]: undefined;
|
|
7455
|
+
[x: `bytes14[${string}]`]: undefined;
|
|
7455
7456
|
[x: `bytes30[${string}]`]: undefined;
|
|
7457
|
+
[x: `bytes5[${string}]`]: undefined;
|
|
7456
7458
|
[x: `bytes18[${string}]`]: undefined;
|
|
7457
7459
|
[x: `bytes6[${string}]`]: undefined;
|
|
7458
7460
|
[x: `bytes9[${string}]`]: undefined;
|
|
@@ -7460,12 +7462,10 @@ export declare function useFirstEOA(chain?: {
|
|
|
7460
7462
|
[x: `bytes10[${string}]`]: undefined;
|
|
7461
7463
|
[x: `bytes2[${string}]`]: undefined;
|
|
7462
7464
|
[x: `bytes3[${string}]`]: undefined;
|
|
7463
|
-
[x: `
|
|
7464
|
-
[x: `bytes7[${string}]`]: undefined;
|
|
7465
|
+
[x: `bytes4[${string}]`]: undefined;
|
|
7465
7466
|
[x: `bytes11[${string}]`]: undefined;
|
|
7466
7467
|
[x: `bytes12[${string}]`]: undefined;
|
|
7467
7468
|
[x: `bytes13[${string}]`]: undefined;
|
|
7468
|
-
[x: `bytes14[${string}]`]: undefined;
|
|
7469
7469
|
[x: `bytes15[${string}]`]: undefined;
|
|
7470
7470
|
[x: `bytes16[${string}]`]: undefined;
|
|
7471
7471
|
[x: `bytes17[${string}]`]: undefined;
|
|
@@ -7553,8 +7553,10 @@ export declare function useFirstEOA(chain?: {
|
|
|
7553
7553
|
bool?: undefined;
|
|
7554
7554
|
bytes?: undefined;
|
|
7555
7555
|
bytes1?: undefined;
|
|
7556
|
-
|
|
7556
|
+
bytes7?: undefined;
|
|
7557
|
+
bytes14?: undefined;
|
|
7557
7558
|
bytes30?: undefined;
|
|
7559
|
+
bytes5?: undefined;
|
|
7558
7560
|
bytes18?: undefined;
|
|
7559
7561
|
bytes6?: undefined;
|
|
7560
7562
|
bytes9?: undefined;
|
|
@@ -7562,12 +7564,10 @@ export declare function useFirstEOA(chain?: {
|
|
|
7562
7564
|
bytes10?: undefined;
|
|
7563
7565
|
bytes2?: undefined;
|
|
7564
7566
|
bytes3?: undefined;
|
|
7565
|
-
|
|
7566
|
-
bytes7?: undefined;
|
|
7567
|
+
bytes4?: undefined;
|
|
7567
7568
|
bytes11?: undefined;
|
|
7568
7569
|
bytes12?: undefined;
|
|
7569
7570
|
bytes13?: undefined;
|
|
7570
|
-
bytes14?: undefined;
|
|
7571
7571
|
bytes15?: undefined;
|
|
7572
7572
|
bytes16?: undefined;
|
|
7573
7573
|
bytes17?: undefined;
|
|
@@ -10,7 +10,6 @@ import { useSearchParam } from "./useSearchParamsSSR.js";
|
|
|
10
10
|
* @deprecated Use useAuth() instead
|
|
11
11
|
*/
|
|
12
12
|
export function useTWAuth() {
|
|
13
|
-
console.warn("useTWAuth is deprecated. Please migrate to useAuth() for authentication.");
|
|
14
13
|
const referralCode = useSearchParam("referralCode");
|
|
15
14
|
const authenticate = useCallback(async (wallet, partnerId) => {
|
|
16
15
|
if (!wallet || !wallet?.getAuthToken?.())
|