@b3dotfun/sdk 0.0.47-alpha.2 → 0.0.47-alpha.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.
- package/README.md +3 -3
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +3 -2
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +15 -64
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.d.ts +6 -2
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.js +26 -21
- package/dist/cjs/global-account/react/components/B3Provider/types.d.ts +2 -0
- package/dist/cjs/global-account/react/components/B3Provider/types.js +2 -0
- package/dist/cjs/global-account/react/components/ManageAccount/BalanceContent.d.ts +1 -2
- package/dist/cjs/global-account/react/components/ManageAccount/BalanceContent.js +2 -2
- package/dist/cjs/global-account/react/components/ManageAccount/ManageAccount.js +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignIn.js +2 -2
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3.js +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.d.ts +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +6 -22
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Privy.d.ts +1 -2
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +3 -2
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.d.ts +1 -2
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.js +10 -45
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.d.ts +1 -2
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +2 -1
- package/dist/cjs/global-account/react/components/custom/ManageAccountButton.js +2 -1
- package/dist/cjs/global-account/react/hooks/useAuthentication.d.ts +51 -2
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +141 -81
- package/dist/cjs/global-account/react/hooks/useHandleConnectWithPrivy.d.ts +1 -1
- package/dist/cjs/global-account/react/hooks/useHandleConnectWithPrivy.js +2 -1
- package/dist/cjs/global-account/react/hooks/useUserQuery.d.ts +58 -0
- package/dist/cjs/global-account/react/hooks/useUserQuery.js +86 -0
- package/dist/cjs/global-account/react/hooks/useWagmiConfig.d.ts +13 -0
- package/dist/cjs/global-account/react/hooks/useWagmiConfig.js +42 -0
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +0 -2
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +3 -2
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +19 -68
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.d.ts +6 -2
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.js +24 -19
- package/dist/esm/global-account/react/components/B3Provider/types.d.ts +2 -0
- package/dist/esm/global-account/react/components/B3Provider/types.js +2 -0
- package/dist/esm/global-account/react/components/ManageAccount/BalanceContent.d.ts +1 -2
- package/dist/esm/global-account/react/components/ManageAccount/BalanceContent.js +2 -2
- package/dist/esm/global-account/react/components/ManageAccount/ManageAccount.js +1 -1
- package/dist/esm/global-account/react/components/SignInWithB3/SignIn.js +2 -2
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3.js +2 -2
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.d.ts +1 -1
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +7 -23
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Privy.d.ts +1 -2
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +4 -3
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.d.ts +1 -2
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.js +11 -46
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.d.ts +1 -2
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +3 -2
- package/dist/esm/global-account/react/components/custom/ManageAccountButton.js +3 -2
- package/dist/esm/global-account/react/hooks/useAuthentication.d.ts +51 -2
- package/dist/esm/global-account/react/hooks/useAuthentication.js +144 -84
- package/dist/esm/global-account/react/hooks/useHandleConnectWithPrivy.d.ts +1 -1
- package/dist/esm/global-account/react/hooks/useHandleConnectWithPrivy.js +3 -2
- package/dist/esm/global-account/react/hooks/useUserQuery.d.ts +58 -0
- package/dist/esm/global-account/react/hooks/useUserQuery.js +83 -0
- package/dist/esm/global-account/react/hooks/useWagmiConfig.d.ts +13 -0
- package/dist/esm/global-account/react/hooks/useWagmiConfig.js +39 -0
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +0 -2
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +3 -2
- package/dist/types/global-account/react/components/B3Provider/B3Provider.native.d.ts +6 -2
- package/dist/types/global-account/react/components/B3Provider/types.d.ts +2 -0
- package/dist/types/global-account/react/components/ManageAccount/BalanceContent.d.ts +1 -2
- package/dist/types/global-account/react/components/SignInWithB3/SignInWithB3Flow.d.ts +1 -1
- package/dist/types/global-account/react/components/SignInWithB3/SignInWithB3Privy.d.ts +1 -2
- package/dist/types/global-account/react/components/SignInWithB3/steps/LoginStep.d.ts +1 -2
- package/dist/types/global-account/react/components/SignInWithB3/steps/LoginStepCustom.d.ts +1 -2
- package/dist/types/global-account/react/hooks/useAuthentication.d.ts +51 -2
- package/dist/types/global-account/react/hooks/useHandleConnectWithPrivy.d.ts +1 -1
- package/dist/types/global-account/react/hooks/useUserQuery.d.ts +58 -0
- package/dist/types/global-account/react/hooks/useWagmiConfig.d.ts +13 -0
- package/dist/types/global-account/react/stores/useModalStore.d.ts +0 -2
- package/package.json +3 -3
- package/src/global-account/react/components/B3Provider/B3Provider.native.tsx +51 -35
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +28 -72
- package/src/global-account/react/components/B3Provider/types.ts +4 -0
- package/src/global-account/react/components/ManageAccount/BalanceContent.tsx +2 -3
- package/src/global-account/react/components/ManageAccount/ManageAccount.tsx +1 -1
- package/src/global-account/react/components/SignInWithB3/SignIn.tsx +2 -2
- package/src/global-account/react/components/SignInWithB3/SignInWithB3.tsx +2 -2
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +4 -23
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Privy.tsx +4 -3
- package/src/global-account/react/components/SignInWithB3/steps/LoginStep.tsx +8 -46
- package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +2 -2
- package/src/global-account/react/components/custom/ManageAccountButton.tsx +3 -2
- package/src/global-account/react/hooks/useAuthentication.ts +170 -89
- package/src/global-account/react/hooks/useHandleConnectWithPrivy.tsx +3 -2
- package/src/global-account/react/hooks/useUserQuery.ts +95 -0
- package/src/global-account/react/hooks/useWagmiConfig.tsx +44 -0
- package/src/global-account/react/stores/useModalStore.ts +0 -2
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { RelayKitProviderWrapper, TooltipProvider, useAuthStore } from "../../../../global-account/react/index.js";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { RelayKitProviderWrapper, TooltipProvider, useAuthentication, useAuthStore, } from "../../../../global-account/react/index.js";
|
|
3
|
+
import { useWagmiConfig } from "../../../../global-account/react/hooks/useWagmiConfig.js";
|
|
3
4
|
import { loadGA4Script } from "../../../../global-account/utils/analytics.js";
|
|
4
|
-
import { ecosystemWalletId } from "../../../../shared/constants/index.js";
|
|
5
|
-
import { supportedChains } from "../../../../shared/constants/chains/supported.js";
|
|
6
5
|
import { debugB3React } from "../../../../shared/utils/debug.js";
|
|
7
|
-
import { client } from "../../../../shared/utils/thirdweb.js";
|
|
8
6
|
import "@reservoir0x/relay-kit-ui/styles.css";
|
|
9
7
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
10
|
-
import {
|
|
11
|
-
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
8
|
+
import { useCallback, useEffect, useState } from "react";
|
|
12
9
|
import { Toaster } from "sonner";
|
|
13
10
|
import { getLastAuthProvider, ThirdwebProvider, useActiveAccount, useConnectedWallets, useSetActiveWallet, } from "thirdweb/react";
|
|
14
|
-
import {
|
|
11
|
+
import { WagmiProvider } from "wagmi";
|
|
15
12
|
import { setClientType } from "../../../client-manager.js";
|
|
16
13
|
import { StyleRoot } from "../StyleRoot.js";
|
|
17
14
|
import { B3Context } from "./types.js";
|
|
@@ -39,76 +36,25 @@ export function B3Provider({ theme = "light", children, accountOverride, environ
|
|
|
39
36
|
useEffect(() => {
|
|
40
37
|
setClientType(clientType);
|
|
41
38
|
}, [clientType]);
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
return undefined;
|
|
45
|
-
return {
|
|
46
|
-
ecosystemId: ecosystemWalletId,
|
|
47
|
-
partnerId: partnerId,
|
|
48
|
-
client,
|
|
49
|
-
};
|
|
50
|
-
}, [partnerId]);
|
|
51
|
-
// Stringify rpcUrls for stable comparison to prevent wagmiConfig recreation
|
|
52
|
-
// when parent component passes new object references with same content
|
|
53
|
-
const rpcUrlsString = useMemo(() => (rpcUrls ? JSON.stringify(rpcUrls) : undefined), [rpcUrls]);
|
|
54
|
-
/**
|
|
55
|
-
* Creates wagmi config with optional custom RPC URLs
|
|
56
|
-
* @param rpcUrls - Optional mapping of chain IDs to RPC URLs
|
|
57
|
-
*/
|
|
58
|
-
const wagmiConfig = useMemo(() => {
|
|
59
|
-
const parsedRpcUrls = rpcUrlsString ? JSON.parse(rpcUrlsString) : undefined;
|
|
60
|
-
return createConfig({
|
|
61
|
-
chains: [supportedChains[0], ...supportedChains.slice(1)],
|
|
62
|
-
transports: Object.fromEntries(supportedChains.map(chain => [chain.id, http(parsedRpcUrls?.[chain.id])])),
|
|
63
|
-
connectors: [
|
|
64
|
-
inAppWalletConnector({
|
|
65
|
-
...(ecocystemConfig || {}),
|
|
66
|
-
client,
|
|
67
|
-
}),
|
|
68
|
-
// injected(),
|
|
69
|
-
// coinbaseWallet({ appName: "HypeDuel" }),
|
|
70
|
-
],
|
|
71
|
-
});
|
|
72
|
-
}, [ecocystemConfig, rpcUrlsString]);
|
|
73
|
-
return (_jsx(ThirdwebProvider, { children: _jsx(WagmiProvider, { config: wagmiConfig, children: _jsx(QueryClientProvider, { client: queryClient, children: _jsx(TooltipProvider, { children: _jsx(InnerProvider, { accountOverride: accountOverride, environment: environment, theme: theme, automaticallySetFirstEoa: !!automaticallySetFirstEoa, clientType: clientType, children: _jsxs(RelayKitProviderWrapper, { simDuneApiKey: simDuneApiKey, children: [children, _jsx(StyleRoot, { id: "b3-root" }), _jsx(Toaster, { theme: theme, position: toaster?.position, style: toaster?.style })] }) }) }) }) }) }));
|
|
39
|
+
const wagmiConfig = useWagmiConfig(partnerId, rpcUrls);
|
|
40
|
+
return (_jsx(ThirdwebProvider, { children: _jsx(WagmiProvider, { config: wagmiConfig, reconnectOnMount: false, children: _jsx(QueryClientProvider, { client: queryClient, children: _jsx(TooltipProvider, { children: _jsx(InnerProvider, { accountOverride: accountOverride, environment: environment, theme: theme, automaticallySetFirstEoa: !!automaticallySetFirstEoa, clientType: clientType, partnerId: partnerId, children: _jsxs(RelayKitProviderWrapper, { simDuneApiKey: simDuneApiKey, children: [children, _jsx(StyleRoot, { id: "b3-root" }), _jsx(Toaster, { theme: theme, position: toaster?.position, style: toaster?.style })] }) }) }) }) }) }));
|
|
74
41
|
}
|
|
75
42
|
/**
|
|
76
43
|
* Inner provider component that provides the actual B3Context
|
|
77
44
|
*/
|
|
78
|
-
export function InnerProvider({ children, accountOverride, environment, defaultPermissions = DEFAULT_PERMISSIONS, automaticallySetFirstEoa, theme = "light", clientType = "socket", }) {
|
|
45
|
+
export function InnerProvider({ children, accountOverride, environment, defaultPermissions = DEFAULT_PERMISSIONS, automaticallySetFirstEoa, theme = "light", clientType = "socket", partnerId, }) {
|
|
79
46
|
const activeAccount = useActiveAccount();
|
|
80
47
|
const [manuallySelectedWallet, setManuallySelectedWallet] = useState(undefined);
|
|
81
48
|
const wallets = useConnectedWallets();
|
|
82
|
-
const setActiveWallet = useSetActiveWallet();
|
|
83
49
|
const isAuthenticated = useAuthStore(state => state.isAuthenticated);
|
|
50
|
+
const isConnected = useAuthStore(state => state.isConnected);
|
|
51
|
+
const setActiveWallet = useSetActiveWallet();
|
|
52
|
+
const { user, setUser, refetchUser } = useAuthentication(partnerId);
|
|
53
|
+
debug("@@B3Provider:isConnected", isConnected);
|
|
84
54
|
debug("@@wallets", wallets);
|
|
85
|
-
|
|
86
|
-
// Try to restore user from localStorage on initialization
|
|
87
|
-
if (typeof window !== "undefined") {
|
|
88
|
-
try {
|
|
89
|
-
const storedUser = localStorage.getItem("b3-user");
|
|
90
|
-
return storedUser ? JSON.parse(storedUser) : undefined;
|
|
91
|
-
}
|
|
92
|
-
catch (error) {
|
|
93
|
-
console.warn("Failed to restore user from localStorage:", error);
|
|
94
|
-
return undefined;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
return undefined;
|
|
98
|
-
});
|
|
55
|
+
debug("@@B3Provider:user", user);
|
|
99
56
|
// Use given accountOverride or activeAccount from thirdweb
|
|
100
57
|
const effectiveAccount = isAuthenticated ? accountOverride || activeAccount : undefined;
|
|
101
|
-
// Persist user to localStorage when it changes
|
|
102
|
-
useEffect(() => {
|
|
103
|
-
if (typeof window !== "undefined") {
|
|
104
|
-
if (user) {
|
|
105
|
-
localStorage.setItem("b3-user", JSON.stringify(user));
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
localStorage.removeItem("b3-user");
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}, [user]);
|
|
112
58
|
const setWallet = useCallback((wallet) => {
|
|
113
59
|
setManuallySelectedWallet(wallet);
|
|
114
60
|
const account = wallet.getAccount();
|
|
@@ -141,6 +87,7 @@ export function InnerProvider({ children, accountOverride, environment, defaultP
|
|
|
141
87
|
wallet: manuallySelectedWallet,
|
|
142
88
|
user,
|
|
143
89
|
setUser,
|
|
90
|
+
refetchUser,
|
|
144
91
|
initialized: true,
|
|
145
92
|
ready: !!effectiveAccount,
|
|
146
93
|
automaticallySetFirstEoa,
|
|
@@ -148,5 +95,9 @@ export function InnerProvider({ children, accountOverride, environment, defaultP
|
|
|
148
95
|
defaultPermissions,
|
|
149
96
|
theme,
|
|
150
97
|
clientType,
|
|
151
|
-
|
|
98
|
+
partnerId: partnerId,
|
|
99
|
+
}, children: _jsx(InnerProvider2, { children: children }) }));
|
|
152
100
|
}
|
|
101
|
+
const InnerProvider2 = ({ children }) => {
|
|
102
|
+
return _jsx(_Fragment, { children: children });
|
|
103
|
+
};
|
|
@@ -5,21 +5,25 @@ import { B3ContextType } from "./types";
|
|
|
5
5
|
/**
|
|
6
6
|
* Main B3Provider component
|
|
7
7
|
*/
|
|
8
|
-
export declare function B3Provider({ theme, children, accountOverride, environment, clientType, }: {
|
|
8
|
+
export declare function B3Provider({ theme, children, accountOverride, environment, clientType, partnerId, rpcUrls, }: {
|
|
9
9
|
theme: "light" | "dark";
|
|
10
10
|
children: React.ReactNode;
|
|
11
11
|
accountOverride?: Account;
|
|
12
12
|
environment: B3ContextType["environment"];
|
|
13
13
|
clientType?: ClientType;
|
|
14
|
+
partnerId: string;
|
|
15
|
+
rpcUrls?: Record<number, string>;
|
|
14
16
|
}): import("react/jsx-runtime").JSX.Element;
|
|
15
17
|
/**
|
|
16
18
|
* Inner provider component that provides the actual B3Context
|
|
17
19
|
*/
|
|
18
|
-
export declare function InnerProvider({ children, accountOverride, environment, defaultPermissions, theme, clientType, }: {
|
|
20
|
+
export declare function InnerProvider({ children, accountOverride, environment, defaultPermissions, theme, clientType, partnerId, rpcUrls, }: {
|
|
19
21
|
children: React.ReactNode;
|
|
20
22
|
accountOverride?: Account;
|
|
21
23
|
environment: B3ContextType["environment"];
|
|
22
24
|
defaultPermissions?: PermissionsConfig;
|
|
23
25
|
theme: "light" | "dark";
|
|
24
26
|
clientType?: ClientType;
|
|
27
|
+
partnerId: string;
|
|
28
|
+
rpcUrls?: Record<number, string>;
|
|
25
29
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
3
|
-
import { useState } from "react";
|
|
4
3
|
import { ThirdwebProvider, useActiveAccount } from "thirdweb/react";
|
|
4
|
+
import { WagmiProvider } from "wagmi";
|
|
5
|
+
import { useAuthentication } from "../../hooks/useAuthentication.js";
|
|
6
|
+
import { useWagmiConfig } from "../../hooks/useWagmiConfig.js";
|
|
5
7
|
import { B3Context } from "./types.js";
|
|
6
8
|
/**
|
|
7
9
|
* Default permissions configuration for B3 provider
|
|
@@ -17,29 +19,32 @@ const queryClient = new QueryClient();
|
|
|
17
19
|
/**
|
|
18
20
|
* Main B3Provider component
|
|
19
21
|
*/
|
|
20
|
-
export function B3Provider({ theme = "light", children, accountOverride, environment, clientType = "socket", }) {
|
|
21
|
-
return (_jsx(
|
|
22
|
+
export function B3Provider({ theme = "light", children, accountOverride, environment, clientType = "socket", partnerId, rpcUrls, }) {
|
|
23
|
+
return (_jsx(ThirdwebProvider, { children: _jsx(InnerProvider, { accountOverride: accountOverride, environment: environment, theme: theme, clientType: clientType, partnerId: partnerId, rpcUrls: rpcUrls, children: children }) }));
|
|
22
24
|
}
|
|
23
25
|
/**
|
|
24
26
|
* Inner provider component that provides the actual B3Context
|
|
25
27
|
*/
|
|
26
|
-
export function InnerProvider({ children, accountOverride, environment, defaultPermissions = DEFAULT_PERMISSIONS, theme = "light", clientType = "socket", }) {
|
|
28
|
+
export function InnerProvider({ children, accountOverride, environment, defaultPermissions = DEFAULT_PERMISSIONS, theme = "light", clientType = "socket", partnerId, rpcUrls, }) {
|
|
27
29
|
const activeAccount = useActiveAccount();
|
|
28
|
-
const
|
|
30
|
+
const { user, setUser, refetchUser } = useAuthentication(partnerId);
|
|
31
|
+
const wagmiConfig = useWagmiConfig(partnerId, rpcUrls);
|
|
29
32
|
// Use given accountOverride or activeAccount from thirdweb
|
|
30
33
|
const effectiveAccount = accountOverride || activeAccount;
|
|
31
|
-
return (_jsx(B3Context.Provider, { value: {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
34
|
+
return (_jsx(WagmiProvider, { config: wagmiConfig, children: _jsx(QueryClientProvider, { client: queryClient, children: _jsx(B3Context.Provider, { value: {
|
|
35
|
+
account: effectiveAccount,
|
|
36
|
+
automaticallySetFirstEoa: false,
|
|
37
|
+
setWallet: () => { },
|
|
38
|
+
wallet: undefined,
|
|
39
|
+
user,
|
|
40
|
+
setUser,
|
|
41
|
+
initialized: true,
|
|
42
|
+
ready: !!effectiveAccount,
|
|
43
|
+
environment,
|
|
44
|
+
defaultPermissions,
|
|
45
|
+
theme,
|
|
46
|
+
clientType,
|
|
47
|
+
partnerId,
|
|
48
|
+
refetchUser,
|
|
49
|
+
}, children: children }) }) }));
|
|
45
50
|
}
|
|
@@ -12,12 +12,14 @@ export interface B3ContextType {
|
|
|
12
12
|
setWallet: (wallet: Wallet) => void;
|
|
13
13
|
wallet?: Wallet;
|
|
14
14
|
setUser: (user?: Users) => void;
|
|
15
|
+
refetchUser: () => Promise<any>;
|
|
15
16
|
initialized: boolean;
|
|
16
17
|
ready: boolean;
|
|
17
18
|
environment?: "development" | "production";
|
|
18
19
|
defaultPermissions?: PermissionsConfig;
|
|
19
20
|
theme: "light" | "dark";
|
|
20
21
|
clientType: ClientType;
|
|
22
|
+
partnerId: string;
|
|
21
23
|
}
|
|
22
24
|
/**
|
|
23
25
|
* Context for B3 provider
|
|
@@ -9,9 +9,11 @@ export const B3Context = createContext({
|
|
|
9
9
|
setWallet: () => { },
|
|
10
10
|
wallet: undefined,
|
|
11
11
|
setUser: () => { },
|
|
12
|
+
refetchUser: async () => { },
|
|
12
13
|
initialized: false,
|
|
13
14
|
ready: false,
|
|
14
15
|
environment: "development",
|
|
15
16
|
theme: "light",
|
|
16
17
|
clientType: "rest",
|
|
18
|
+
partnerId: "",
|
|
17
19
|
});
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
interface BalanceContentProps {
|
|
2
2
|
onLogout?: () => void;
|
|
3
|
-
partnerId: string;
|
|
4
3
|
showDeposit?: boolean;
|
|
5
4
|
showSwap?: boolean;
|
|
6
5
|
}
|
|
7
|
-
export declare function BalanceContent({ onLogout,
|
|
6
|
+
export declare function BalanceContent({ onLogout, showDeposit, showSwap }: BalanceContentProps): import("react/jsx-runtime").JSX.Element;
|
|
8
7
|
export {};
|
|
@@ -17,14 +17,14 @@ function centerTruncate(str, length = 4) {
|
|
|
17
17
|
return str;
|
|
18
18
|
return `${str.slice(0, length)}...${str.slice(-length)}`;
|
|
19
19
|
}
|
|
20
|
-
export function BalanceContent({ onLogout,
|
|
20
|
+
export function BalanceContent({ onLogout, showDeposit = true, showSwap = true }) {
|
|
21
21
|
const account = useActiveAccount();
|
|
22
22
|
const { address: eoaAddress, info: eoaInfo } = useFirstEOA();
|
|
23
23
|
const { data: profile } = useProfile({
|
|
24
24
|
address: eoaAddress || account?.address,
|
|
25
25
|
fresh: true,
|
|
26
26
|
});
|
|
27
|
-
const { user } = useB3();
|
|
27
|
+
const { user, partnerId } = useB3();
|
|
28
28
|
const { setB3ModalOpen, setB3ModalContentType, navigateBack } = useModalStore();
|
|
29
29
|
const { logout } = useAuthentication(partnerId);
|
|
30
30
|
const [logoutLoading, setLogoutLoading] = useState(false);
|
|
@@ -196,5 +196,5 @@ export function ManageAccount({ onLogout, onSwap: _onSwap, onDeposit: _onDeposit
|
|
|
196
196
|
if (["overview", "tokens", "nfts", "apps", "settings"].includes(tab)) {
|
|
197
197
|
setActiveTab?.(tab);
|
|
198
198
|
}
|
|
199
|
-
}, children: [_jsx("div", { className: "px-4", children: _jsxs(TabsListPrimitive, { className: "grid h-auto grid-cols-2 grid-rows-2 gap-3 rounded-none border-none bg-transparent", children: [_jsxs(TabTriggerPrimitive, { value: "overview", className: "data-[state=active]:bg-b3-primary-blue data-[state=active]:hover:bg-b3-primary-blue data-[state=active]:border-b3-primary-blue group flex h-12 w-full items-center justify-center gap-2 rounded-xl border border-gray-200 bg-white p-2 text-center shadow-sm transition-all duration-200 hover:bg-gray-50 hover:shadow-md data-[state=active]:shadow-lg", children: [_jsx(BarChart3, { size: 20, className: "text-b3-primary-blue shrink-0 group-data-[state=active]:text-white" }), _jsx("span", { className: "text-b3-grey font-neue-montreal-semibold text-sm group-data-[state=active]:text-white", children: "Overview" })] }), _jsxs(TabTriggerPrimitive, { value: "tokens", className: "data-[state=active]:bg-b3-primary-blue data-[state=active]:hover:bg-b3-primary-blue data-[state=active]:border-b3-primary-blue group flex h-12 w-full items-center justify-center gap-2 rounded-xl border border-gray-200 bg-white p-2 text-center shadow-sm transition-all duration-200 hover:bg-gray-50 hover:shadow-md data-[state=active]:shadow-lg", children: [_jsx(Coins, { size: 20, className: "text-b3-primary-blue shrink-0 group-data-[state=active]:text-white" }), _jsx("span", { className: "text-b3-grey font-neue-montreal-semibold text-sm group-data-[state=active]:text-white", children: "Tokens" })] }), _jsxs(TabTriggerPrimitive, { value: "nfts", className: "data-[state=active]:bg-b3-primary-blue data-[state=active]:hover:bg-b3-primary-blue data-[state=active]:border-b3-primary-blue group flex h-12 w-full items-center justify-center gap-2 rounded-xl border border-gray-200 bg-white p-2 text-center shadow-sm transition-all duration-200 hover:bg-gray-50 hover:shadow-md data-[state=active]:shadow-lg", children: [_jsx(Image, { size: 20, className: "text-b3-primary-blue shrink-0 group-data-[state=active]:text-white" }), _jsx("span", { className: "text-b3-grey font-neue-montreal-semibold text-sm group-data-[state=active]:text-white", children: "NFTs" })] }), _jsxs(TabTriggerPrimitive, { value: "settings", className: "data-[state=active]:bg-b3-primary-blue data-[state=active]:hover:bg-b3-primary-blue data-[state=active]:border-b3-primary-blue group flex h-12 w-full items-center justify-center gap-2 rounded-xl border border-gray-200 bg-white p-2 text-center shadow-sm transition-all duration-200 hover:bg-gray-50 hover:shadow-md data-[state=active]:shadow-lg", children: [_jsx(Settings, { size: 20, className: "text-b3-primary-blue shrink-0 group-data-[state=active]:text-white" }), _jsx("span", { className: "text-b3-grey font-neue-montreal-semibold text-sm group-data-[state=active]:text-white", children: "Settings" })] })] }) }), _jsx(TabsContentPrimitive, { value: "overview", className: "px-4 pb-4 pt-2", children: _jsx(BalanceContent, { onLogout: onLogout,
|
|
199
|
+
}, children: [_jsx("div", { className: "px-4", children: _jsxs(TabsListPrimitive, { className: "grid h-auto grid-cols-2 grid-rows-2 gap-3 rounded-none border-none bg-transparent", children: [_jsxs(TabTriggerPrimitive, { value: "overview", className: "data-[state=active]:bg-b3-primary-blue data-[state=active]:hover:bg-b3-primary-blue data-[state=active]:border-b3-primary-blue group flex h-12 w-full items-center justify-center gap-2 rounded-xl border border-gray-200 bg-white p-2 text-center shadow-sm transition-all duration-200 hover:bg-gray-50 hover:shadow-md data-[state=active]:shadow-lg", children: [_jsx(BarChart3, { size: 20, className: "text-b3-primary-blue shrink-0 group-data-[state=active]:text-white" }), _jsx("span", { className: "text-b3-grey font-neue-montreal-semibold text-sm group-data-[state=active]:text-white", children: "Overview" })] }), _jsxs(TabTriggerPrimitive, { value: "tokens", className: "data-[state=active]:bg-b3-primary-blue data-[state=active]:hover:bg-b3-primary-blue data-[state=active]:border-b3-primary-blue group flex h-12 w-full items-center justify-center gap-2 rounded-xl border border-gray-200 bg-white p-2 text-center shadow-sm transition-all duration-200 hover:bg-gray-50 hover:shadow-md data-[state=active]:shadow-lg", children: [_jsx(Coins, { size: 20, className: "text-b3-primary-blue shrink-0 group-data-[state=active]:text-white" }), _jsx("span", { className: "text-b3-grey font-neue-montreal-semibold text-sm group-data-[state=active]:text-white", children: "Tokens" })] }), _jsxs(TabTriggerPrimitive, { value: "nfts", className: "data-[state=active]:bg-b3-primary-blue data-[state=active]:hover:bg-b3-primary-blue data-[state=active]:border-b3-primary-blue group flex h-12 w-full items-center justify-center gap-2 rounded-xl border border-gray-200 bg-white p-2 text-center shadow-sm transition-all duration-200 hover:bg-gray-50 hover:shadow-md data-[state=active]:shadow-lg", children: [_jsx(Image, { size: 20, className: "text-b3-primary-blue shrink-0 group-data-[state=active]:text-white" }), _jsx("span", { className: "text-b3-grey font-neue-montreal-semibold text-sm group-data-[state=active]:text-white", children: "NFTs" })] }), _jsxs(TabTriggerPrimitive, { value: "settings", className: "data-[state=active]:bg-b3-primary-blue data-[state=active]:hover:bg-b3-primary-blue data-[state=active]:border-b3-primary-blue group flex h-12 w-full items-center justify-center gap-2 rounded-xl border border-gray-200 bg-white p-2 text-center shadow-sm transition-all duration-200 hover:bg-gray-50 hover:shadow-md data-[state=active]:shadow-lg", children: [_jsx(Settings, { size: 20, className: "text-b3-primary-blue shrink-0 group-data-[state=active]:text-white" }), _jsx("span", { className: "text-b3-grey font-neue-montreal-semibold text-sm group-data-[state=active]:text-white", children: "Settings" })] })] }) }), _jsx(TabsContentPrimitive, { value: "overview", className: "px-4 pb-4 pt-2", children: _jsx(BalanceContent, { onLogout: onLogout, showDeposit: showDeposit, showSwap: showSwap }) }), _jsx(TabsContentPrimitive, { value: "tokens", className: "px-4 pb-4 pt-2", children: _jsx(ContentTokens, { activeTab: activeTab }) }), _jsx(TabsContentPrimitive, { value: "nfts", className: "px-4 pb-4 pt-2", children: _jsx("div", { className: "grid grid-cols-3 gap-4", children: nfts?.nftResponse ? (_jsx(AccountAssets, { nfts: nfts.nftResponse, isLoading: isLoading })) : (_jsx("div", { className: "col-span-3 py-12 text-center text-gray-500", children: "No NFTs found" })) }) }), _jsx(TabsContentPrimitive, { value: "apps", className: "px-4 pb-4 pt-2", children: _jsx(AppsContent, {}) }), _jsx(TabsContentPrimitive, { value: "settings", className: "px-4 pb-4 pt-2", children: _jsx(SettingsContent, {}) })] }) }) }));
|
|
200
200
|
}
|
|
@@ -9,10 +9,10 @@ import { useConnectedWallets, useSetActiveWallet, useWalletInfo } from "thirdweb
|
|
|
9
9
|
import { ManageAccountButton } from "../custom/ManageAccountButton.js";
|
|
10
10
|
export function SignIn(props) {
|
|
11
11
|
const { className } = props;
|
|
12
|
-
const { automaticallySetFirstEoa } = useB3();
|
|
12
|
+
const { automaticallySetFirstEoa, partnerId } = useB3();
|
|
13
13
|
const { wallet, address: globalAddress, ensName, connectedSmartWallet, connectedEOAWallet, isActiveSmartWallet, isActiveEOAWallet, smartWalletIcon, eoaWalletIcon, } = useAccountWallet();
|
|
14
14
|
const isMobile = useIsMobile();
|
|
15
|
-
const { logout } = useAuthentication(
|
|
15
|
+
const { logout } = useAuthentication(partnerId);
|
|
16
16
|
const onDisconnect = async () => {
|
|
17
17
|
await logout();
|
|
18
18
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { Button, StyleRoot,
|
|
2
|
+
import { Button, StyleRoot, useAuthStore, useB3, useIsMobile, useModalStore, } from "../../../../global-account/react/index.js";
|
|
3
3
|
import { useEffect } from "react";
|
|
4
4
|
import { ManageAccountButton } from "../custom/ManageAccountButton.js";
|
|
5
5
|
import { Loading } from "../ui/Loading.js";
|
|
6
6
|
export function SignInWithB3(props) {
|
|
7
7
|
const { setB3ModalOpen, setB3ModalContentType, setEcoSystemAccountAddress } = useModalStore();
|
|
8
8
|
const { account } = useB3();
|
|
9
|
-
const { isAuthenticating, isAuthenticated } =
|
|
9
|
+
const { isAuthenticating, isAuthenticated } = useAuthStore();
|
|
10
10
|
const isMobile = useIsMobile();
|
|
11
11
|
useEffect(() => {
|
|
12
12
|
if (account) {
|
|
@@ -3,4 +3,4 @@ import { SignInWithB3ModalProps } from "../../../../global-account/react";
|
|
|
3
3
|
* Component that manages the authentication flow for Sign In With B3
|
|
4
4
|
* Handles different login providers, authentication steps, and session key management
|
|
5
5
|
*/
|
|
6
|
-
export declare function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onError, chain, sessionKeyAddress, partnerId, closeAfterLogin,
|
|
6
|
+
export declare function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onError, chain, sessionKeyAddress, partnerId, closeAfterLogin, source, signersEnabled, }: SignInWithB3ModalProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Loading, useAuthStore, useB3, useGetAllTWSigners, useModalStore,
|
|
2
|
+
import { Loading, useAuthStore, useB3, useGetAllTWSigners, useModalStore, } from "../../../../global-account/react/index.js";
|
|
3
3
|
import { debugB3React } from "../../../../shared/utils/debug.js";
|
|
4
4
|
import { useCallback, useEffect, useState } from "react";
|
|
5
5
|
import { useActiveAccount } from "thirdweb/react";
|
|
@@ -12,16 +12,14 @@ const MAX_REFETCH_ATTEMPTS = 20;
|
|
|
12
12
|
* Component that manages the authentication flow for Sign In With B3
|
|
13
13
|
* Handles different login providers, authentication steps, and session key management
|
|
14
14
|
*/
|
|
15
|
-
export function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onError, chain, sessionKeyAddress, partnerId, closeAfterLogin = false,
|
|
16
|
-
const {
|
|
15
|
+
export function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onError, chain, sessionKeyAddress, partnerId, closeAfterLogin = false, source = "signInWithB3Button", signersEnabled = false, }) {
|
|
16
|
+
const { automaticallySetFirstEoa } = useB3();
|
|
17
17
|
const [step, setStep] = useState(source === "requestPermissions" ? null : "login");
|
|
18
18
|
const [sessionKeyAdded, setSessionKeyAdded] = useState(source === "requestPermissions" ? true : false);
|
|
19
19
|
const { setB3ModalContentType, setB3ModalOpen, isOpen } = useModalStore();
|
|
20
20
|
const account = useActiveAccount();
|
|
21
|
-
const setIsAuthenticating = useAuthStore(state => state.setIsAuthenticating);
|
|
22
21
|
const isAuthenticating = useAuthStore(state => state.isAuthenticating);
|
|
23
22
|
const isConnected = useAuthStore(state => state.isConnected);
|
|
24
|
-
const setIsConnected = useAuthStore(state => state.setIsConnected);
|
|
25
23
|
const [refetchCount, setRefetchCount] = useState(0);
|
|
26
24
|
const [refetchError, setRefetchError] = useState(null);
|
|
27
25
|
const { data: signers, refetch: refetchSigners, isFetching: isFetchingSigners, } = useGetAllTWSigners({
|
|
@@ -31,7 +29,6 @@ export function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySucce
|
|
|
31
29
|
enabled: signersEnabled,
|
|
32
30
|
},
|
|
33
31
|
});
|
|
34
|
-
const { authenticate } = useSiwe();
|
|
35
32
|
const [refetchQueued, setRefetchQueued] = useState(false);
|
|
36
33
|
// Enhanced refetchSigners function that tracks number of attempts
|
|
37
34
|
const handleRefetchSigners = useCallback(() => {
|
|
@@ -142,13 +139,11 @@ export function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySucce
|
|
|
142
139
|
sessionKeyAddress,
|
|
143
140
|
partnerId,
|
|
144
141
|
closeAfterLogin,
|
|
145
|
-
loginWithSiwe,
|
|
146
142
|
source: "requestPermissions",
|
|
147
143
|
});
|
|
148
144
|
}, [
|
|
149
145
|
chain,
|
|
150
146
|
closeAfterLogin,
|
|
151
|
-
loginWithSiwe,
|
|
152
147
|
onError,
|
|
153
148
|
onLoginSuccess,
|
|
154
149
|
onSessionKeySuccess,
|
|
@@ -158,19 +153,8 @@ export function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySucce
|
|
|
158
153
|
strategies,
|
|
159
154
|
]);
|
|
160
155
|
const handleLoginSuccess = useCallback(async (account) => {
|
|
161
|
-
debug("Authenticating with B3 via SIWE");
|
|
162
|
-
setIsConnected(true);
|
|
163
|
-
if (loginWithSiwe) {
|
|
164
|
-
debug("setIsAuthenticating:true:1");
|
|
165
|
-
setIsAuthenticating(true);
|
|
166
|
-
const userAuth = await authenticate(account, partnerId);
|
|
167
|
-
setUser(userAuth.user);
|
|
168
|
-
}
|
|
169
|
-
debug("handleLoginSuccess:account", account);
|
|
170
156
|
onLoginSuccess?.(account);
|
|
171
|
-
|
|
172
|
-
setIsAuthenticating(false);
|
|
173
|
-
}, [loginWithSiwe, onLoginSuccess, authenticate, partnerId, setUser, setIsConnected, setIsAuthenticating]);
|
|
157
|
+
}, [onLoginSuccess]);
|
|
174
158
|
useEffect(() => {
|
|
175
159
|
if (step === "permissions") {
|
|
176
160
|
setB3ModalContentType({
|
|
@@ -192,14 +176,14 @@ export function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySucce
|
|
|
192
176
|
if (step === "login") {
|
|
193
177
|
// Custom strategy
|
|
194
178
|
if (strategies?.[0] === "privy") {
|
|
195
|
-
return _jsx(SignInWithB3Privy, { onSuccess: handleLoginSuccess,
|
|
179
|
+
return _jsx(SignInWithB3Privy, { onSuccess: handleLoginSuccess, chain: chain });
|
|
196
180
|
}
|
|
197
181
|
// Strategies are explicitly provided
|
|
198
182
|
if (strategies) {
|
|
199
|
-
return (_jsx(LoginStepCustom, { strategies: strategies,
|
|
183
|
+
return (_jsx(LoginStepCustom, { strategies: strategies, chain: chain, onSuccess: handleLoginSuccess, onError: onError, automaticallySetFirstEoa: !!automaticallySetFirstEoa }));
|
|
200
184
|
}
|
|
201
185
|
// Default to handle all strategies we support
|
|
202
|
-
return _jsx(LoginStep, {
|
|
186
|
+
return _jsx(LoginStep, { chain: chain, onSuccess: handleLoginSuccess, onError: onError });
|
|
203
187
|
}
|
|
204
188
|
return null;
|
|
205
189
|
}
|
|
@@ -4,8 +4,7 @@ interface SignInWithB3PrivyProps {
|
|
|
4
4
|
onError?: (error: Error) => Promise<void>;
|
|
5
5
|
onSuccess: (account: Account) => Promise<void>;
|
|
6
6
|
accessToken?: string;
|
|
7
|
-
partnerId: string;
|
|
8
7
|
chain: Chain;
|
|
9
8
|
}
|
|
10
|
-
export declare function SignInWithB3Privy({ onSuccess, onError,
|
|
9
|
+
export declare function SignInWithB3Privy({ onSuccess, onError, chain }: SignInWithB3PrivyProps): import("react/jsx-runtime").JSX.Element;
|
|
11
10
|
export {};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Loading, useAuthentication, useAuthStore, useHandleConnectWithPrivy, } from "../../../../global-account/react/index.js";
|
|
2
|
+
import { Loading, useAuthentication, useAuthStore, useB3, 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");
|
|
6
|
-
export function SignInWithB3Privy({ onSuccess, onError,
|
|
7
|
-
const {
|
|
6
|
+
export function SignInWithB3Privy({ onSuccess, onError, chain }) {
|
|
7
|
+
const { partnerId } = useB3();
|
|
8
|
+
const { isLoading, connectTw, fullToken } = useHandleConnectWithPrivy(chain, onSuccess);
|
|
8
9
|
const setIsAuthenticating = useAuthStore(state => state.setIsAuthenticating);
|
|
9
10
|
const setIsAuthenticated = useAuthStore(state => state.setIsAuthenticated);
|
|
10
11
|
const { logout } = useAuthentication(partnerId);
|
|
@@ -9,7 +9,6 @@ interface LoginStepProps {
|
|
|
9
9
|
/** Optional callback function called when an error occurs */
|
|
10
10
|
onError?: (error: Error) => Promise<void>;
|
|
11
11
|
/** Partner ID used for authentication */
|
|
12
|
-
partnerId: string;
|
|
13
12
|
/** Blockchain chain information */
|
|
14
13
|
chain: Chain;
|
|
15
14
|
/** Optional authentication strategy options */
|
|
@@ -20,5 +19,5 @@ interface LoginStepContainerProps {
|
|
|
20
19
|
partnerId?: string;
|
|
21
20
|
}
|
|
22
21
|
export declare function LoginStepContainer({ children, partnerId }: LoginStepContainerProps): import("react/jsx-runtime").JSX.Element;
|
|
23
|
-
export declare function LoginStep({ onSuccess,
|
|
22
|
+
export declare function LoginStep({ onSuccess, chain }: LoginStepProps): import("react/jsx-runtime").JSX.Element;
|
|
24
23
|
export {};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useAuthentication,
|
|
2
|
+
import { useAuthentication, 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";
|
|
5
4
|
import { client } from "../../../../../shared/utils/thirdweb.js";
|
|
6
5
|
import { ConnectEmbed, darkTheme, lightTheme } from "thirdweb/react";
|
|
7
6
|
import { ecosystemWallet } from "thirdweb/wallets";
|
|
@@ -15,14 +14,12 @@ export function LoginStepContainer({ children, partnerId }) {
|
|
|
15
14
|
const partnerLogo = partner?.data?.[0]?.loginCustomization?.logoUrl;
|
|
16
15
|
return (_jsxs("div", { className: "flex flex-col items-center justify-center pt-6", children: [partnerLogo && (_jsx("img", { src: partnerLogo, alt: "Partner Logo", className: "partner-logo mb-6 h-12 w-auto object-contain" })), children, _jsxs("h2", { className: "mt-6 flex items-center gap-2 text-lg font-bold", children: ["Powered by", _jsx("img", { alt: "B3 Logo", className: "h-5", src: "https://cdn.b3.fun/b3_logo.svg" }), "Connect"] })] }));
|
|
17
16
|
}
|
|
18
|
-
export function LoginStep({ onSuccess,
|
|
17
|
+
export function LoginStep({ onSuccess, chain }) {
|
|
18
|
+
const { partnerId, theme } = useB3();
|
|
19
19
|
const wallet = ecosystemWallet(ecosystemWalletId, {
|
|
20
20
|
partnerId: partnerId,
|
|
21
21
|
});
|
|
22
|
-
const {
|
|
23
|
-
const setIsAuthenticating = useAuthStore(state => state.setIsAuthenticating);
|
|
24
|
-
const setIsAuthenticated = useAuthStore(state => state.setIsAuthenticated);
|
|
25
|
-
const { logout } = useAuthentication(partnerId);
|
|
22
|
+
const { onConnect } = useAuthentication(partnerId);
|
|
26
23
|
return (_jsx(LoginStepContainer, { partnerId: partnerId, children: _jsx(ConnectEmbed, { showThirdwebBranding: false, client: client, chain: chain, wallets: [wallet], theme: theme === "light"
|
|
27
24
|
? lightTheme({
|
|
28
25
|
colors: {
|
|
@@ -33,50 +30,18 @@ export function LoginStep({ onSuccess, onError, partnerId, chain }) {
|
|
|
33
30
|
colors: {
|
|
34
31
|
modalBg: "hsl(var(--b3-react-background))",
|
|
35
32
|
},
|
|
36
|
-
}),
|
|
33
|
+
}), style: {
|
|
37
34
|
width: "100%",
|
|
38
35
|
height: "100%",
|
|
39
36
|
border: 0,
|
|
40
|
-
},
|
|
41
|
-
// TODO: Integrate with SIWE in useSIWE
|
|
42
|
-
// auth={{
|
|
43
|
-
// isLoggedIn: async (address) => {
|
|
44
|
-
// console.log("checking if logged in!", { address });
|
|
45
|
-
// return await isLoggedIn();
|
|
46
|
-
// },
|
|
47
|
-
// doLogin: async (params) => {
|
|
48
|
-
// console.log("logging in!");
|
|
49
|
-
// await login(params);
|
|
50
|
-
// },
|
|
51
|
-
// getLoginPayload: async ({ address }) =>
|
|
52
|
-
// generatePayload({ address }),
|
|
53
|
-
// doLogout: async () => {
|
|
54
|
-
// console.log("logging out!");
|
|
55
|
-
// await logout();
|
|
56
|
-
// },
|
|
57
|
-
// }}
|
|
58
|
-
header: {
|
|
37
|
+
}, header: {
|
|
59
38
|
title: "Sign in with B3",
|
|
60
39
|
titleIcon: "https://cdn.b3.fun/b3_logo.svg",
|
|
61
40
|
}, className: "b3-login-step", onConnect: async (wallet) => {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
throw new Error("No account found");
|
|
68
|
-
await onSuccess(account);
|
|
69
|
-
setIsAuthenticated(true);
|
|
70
|
-
console.log("connected!", wallet.id);
|
|
71
|
-
}
|
|
72
|
-
catch (error) {
|
|
73
|
-
await onError?.(error);
|
|
74
|
-
await logout();
|
|
75
|
-
setIsAuthenticated(false);
|
|
76
|
-
}
|
|
77
|
-
finally {
|
|
78
|
-
debug("setIsAuthenticating:false:6");
|
|
79
|
-
setIsAuthenticating(false);
|
|
80
|
-
}
|
|
41
|
+
await onConnect(wallet);
|
|
42
|
+
const account = wallet.getAccount();
|
|
43
|
+
if (!account)
|
|
44
|
+
throw new Error("No account found");
|
|
45
|
+
await onSuccess(account);
|
|
81
46
|
} }) }));
|
|
82
47
|
}
|
|
@@ -5,10 +5,9 @@ interface LoginStepCustomProps {
|
|
|
5
5
|
automaticallySetFirstEoa: boolean;
|
|
6
6
|
onSuccess: (account: Account) => Promise<void>;
|
|
7
7
|
onError?: (error: Error) => Promise<void>;
|
|
8
|
-
partnerId: string;
|
|
9
8
|
chain: Chain;
|
|
10
9
|
strategies: AllowedStrategy[];
|
|
11
10
|
maxInitialWallets?: number;
|
|
12
11
|
}
|
|
13
|
-
export declare function LoginStepCustom({ onSuccess, onError,
|
|
12
|
+
export declare function LoginStepCustom({ onSuccess, onError, chain, strategies, maxInitialWallets, automaticallySetFirstEoa, }: LoginStepCustomProps): import("react/jsx-runtime").JSX.Element;
|
|
14
13
|
export {};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { AuthButton, Button, getConnectOptionsFromStrategy, isWalletType, LoginStepContainer, useAuthentication, useAuthStore, useConnect, WalletRow, } from "../../../../../global-account/react/index.js";
|
|
2
|
+
import { AuthButton, Button, getConnectOptionsFromStrategy, isWalletType, LoginStepContainer, useAuthentication, useAuthStore, useB3, useConnect, WalletRow, } from "../../../../../global-account/react/index.js";
|
|
3
3
|
import { debugB3React } from "../../../../../shared/utils/debug.js";
|
|
4
4
|
import { client } from "../../../../../shared/utils/thirdweb.js";
|
|
5
5
|
import { useState } from "react";
|
|
6
6
|
import { useConnect as useConnectTW } from "thirdweb/react";
|
|
7
7
|
import { createWallet } from "thirdweb/wallets";
|
|
8
8
|
const debug = debugB3React("LoginStepCustom");
|
|
9
|
-
export function LoginStepCustom({ onSuccess, onError,
|
|
9
|
+
export function LoginStepCustom({ onSuccess, onError, chain, strategies, maxInitialWallets = 2, automaticallySetFirstEoa, }) {
|
|
10
|
+
const { partnerId } = useB3();
|
|
10
11
|
const [isLoading, setIsLoading] = useState(false);
|
|
11
12
|
const [showAllWallets, setShowAllWallets] = useState(false);
|
|
12
13
|
const { connect } = useConnect(partnerId, chain);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Button, StyleRoot, useAuthentication, useModalStore } from "../../../../global-account/react/index.js";
|
|
2
|
+
import { Button, StyleRoot, useAuthentication, useB3, useModalStore } from "../../../../global-account/react/index.js";
|
|
3
3
|
import { cn } from "../../../../shared/utils/index.js";
|
|
4
4
|
export function ManageAccountButton(props) {
|
|
5
|
+
const { partnerId } = useB3();
|
|
5
6
|
const { setB3ModalOpen, setB3ModalContentType } = useModalStore();
|
|
6
|
-
const { isConnected } = useAuthentication(
|
|
7
|
+
const { isConnected } = useAuthentication(partnerId);
|
|
7
8
|
const handleClickManageAccount = () => {
|
|
8
9
|
setB3ModalContentType({
|
|
9
10
|
...props,
|