@b3dotfun/sdk 0.0.21-alpha.1 → 0.0.21

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