@b3dotfun/sdk 0.0.47-test.4 → 0.0.47

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