@b3dotfun/sdk 0.0.82 → 0.0.83-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/anyspend/react/components/AnySpend.js +0 -3
- package/dist/cjs/anyspend/react/components/AnySpendCollectorClubPurchase.js +1 -1
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +0 -3
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +47 -177
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.js +0 -3
- package/dist/cjs/anyspend/react/providers/AnyspendProvider.js +1 -13
- package/dist/cjs/anyspend/utils/chain.d.ts +38 -0
- package/dist/cjs/anyspend/utils/chain.js +22 -1
- package/dist/cjs/anyspend/utils/token.d.ts +3 -0
- package/dist/cjs/anyspend/utils/token.js +17 -1
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +1 -1
- package/dist/cjs/global-account/react/hooks/useAuthentication.d.ts +1 -1
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +38 -36
- package/dist/cjs/global-account/react/hooks/useUserQuery.d.ts +1 -1
- package/dist/esm/anyspend/react/components/AnySpend.js +0 -3
- package/dist/esm/anyspend/react/components/AnySpendCollectorClubPurchase.js +1 -1
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +0 -3
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +45 -175
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.js +0 -3
- package/dist/esm/anyspend/react/providers/AnyspendProvider.js +1 -13
- package/dist/esm/anyspend/utils/chain.d.ts +38 -0
- package/dist/esm/anyspend/utils/chain.js +22 -1
- package/dist/esm/anyspend/utils/token.d.ts +3 -0
- package/dist/esm/anyspend/utils/token.js +15 -1
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +2 -2
- package/dist/esm/global-account/react/hooks/useAuthentication.d.ts +1 -1
- package/dist/esm/global-account/react/hooks/useAuthentication.js +38 -36
- package/dist/esm/global-account/react/hooks/useUserQuery.d.ts +1 -1
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/utils/chain.d.ts +38 -0
- package/dist/types/anyspend/utils/token.d.ts +3 -0
- package/dist/types/global-account/react/hooks/useAuthentication.d.ts +1 -1
- package/dist/types/global-account/react/hooks/useUserQuery.d.ts +1 -1
- package/package.json +1 -1
- package/src/anyspend/react/components/AnySpend.tsx +0 -4
- package/src/anyspend/react/components/AnySpendCollectorClubPurchase.tsx +1 -1
- package/src/anyspend/react/components/AnySpendCustom.tsx +0 -4
- package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +22 -253
- package/src/anyspend/react/hooks/useAnyspendFlow.ts +0 -4
- package/src/anyspend/react/providers/AnyspendProvider.tsx +7 -22
- package/src/anyspend/utils/chain.ts +31 -1
- package/src/anyspend/utils/token.ts +17 -1
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +6 -2
- package/src/global-account/react/hooks/useAuthentication.ts +47 -46
- package/dist/cjs/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.d.ts +0 -10
- package/dist/cjs/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.js +0 -73
- package/dist/esm/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.d.ts +0 -10
- package/dist/esm/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.js +0 -70
- package/dist/types/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.d.ts +0 -10
- package/src/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.ts +0 -80
|
@@ -5,7 +5,7 @@ import { loadGA4Script } from "../../../../global-account/utils/analytics.js";
|
|
|
5
5
|
import { debugB3React } from "../../../../shared/utils/debug.js";
|
|
6
6
|
import "@relayprotocol/relay-kit-ui/styles.css";
|
|
7
7
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
8
|
-
import { useCallback, useEffect, useState } from "react";
|
|
8
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
9
9
|
import { getLastAuthProvider, ThirdwebProvider, useActiveAccount, useConnectedWallets, useSetActiveWallet, } from "thirdweb/react";
|
|
10
10
|
import { WagmiProvider } from "wagmi";
|
|
11
11
|
import { setClientType } from "../../../client-manager.js";
|
|
@@ -39,7 +39,7 @@ toaster: _toaster, clientType = "rest", rpcUrls, partnerId, onConnect, connector
|
|
|
39
39
|
useEffect(() => {
|
|
40
40
|
setClientType(clientType);
|
|
41
41
|
}, [clientType]);
|
|
42
|
-
const wagmiConfig = createWagmiConfig({ partnerId, rpcUrls, connectors, overrideDefaultConnectors });
|
|
42
|
+
const wagmiConfig = useMemo(() => createWagmiConfig({ partnerId, rpcUrls, connectors, overrideDefaultConnectors }), [partnerId, rpcUrls, connectors, overrideDefaultConnectors]);
|
|
43
43
|
return (_jsx(ThirdwebProvider, { children: _jsx(WagmiProvider, { config: wagmiConfig, reconnectOnMount: false, children: _jsx(QueryClientProvider, { client: queryClient, children: _jsx(TooltipProvider, { children: _jsx(ToastProvider, { children: _jsx(LocalSDKProvider, { onConnectCallback: onConnect, children: _jsxs(InnerProvider, { accountOverride: accountOverride, environment: environment, theme: theme, automaticallySetFirstEoa: !!automaticallySetFirstEoa, clientType: clientType, partnerId: partnerId, createClientReferenceId: createClientReferenceId, enableTurnkey: enableTurnkey, children: [_jsx(ToastContextConnector, {}), _jsxs(RelayKitProviderWrapper, { simDuneApiKey: simDuneApiKey, children: [children, _jsx(StyleRoot, { id: "b3-root" })] })] }) }) }) }) }) }) }));
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
@@ -41,8 +41,8 @@ export declare function useAuthentication(partnerId: string): {
|
|
|
41
41
|
name?: string | undefined;
|
|
42
42
|
address?: string | undefined;
|
|
43
43
|
email?: string | undefined;
|
|
44
|
-
phone?: string | undefined;
|
|
45
44
|
username?: string | undefined;
|
|
45
|
+
phone?: string | undefined;
|
|
46
46
|
fid?: string | undefined;
|
|
47
47
|
};
|
|
48
48
|
}[] | undefined;
|
|
@@ -125,14 +125,40 @@ export function useAuthentication(partnerId) {
|
|
|
125
125
|
return userAuth;
|
|
126
126
|
}
|
|
127
127
|
}, [activeWallet, partnerId, authenticate, setIsAuthenticated, setIsAuthenticating, setUser, setHasStartedConnecting]);
|
|
128
|
+
const logout = useCallback(async (callback) => {
|
|
129
|
+
if (activeWallet) {
|
|
130
|
+
debug("@@logout:activeWallet", activeWallet);
|
|
131
|
+
disconnect(activeWallet);
|
|
132
|
+
debug("@@logout:activeWallet", activeWallet);
|
|
133
|
+
}
|
|
134
|
+
// Log out of each wallet
|
|
135
|
+
wallets.forEach(wallet => {
|
|
136
|
+
console.log("@@logging out", wallet);
|
|
137
|
+
disconnect(wallet);
|
|
138
|
+
});
|
|
139
|
+
// Delete localStorage thirdweb:connected-wallet-ids
|
|
140
|
+
// https://npc-labs.slack.com/archives/C070E6HNG85/p1750185115273099
|
|
141
|
+
if (typeof localStorage !== "undefined") {
|
|
142
|
+
localStorage.removeItem("thirdweb:connected-wallet-ids");
|
|
143
|
+
localStorage.removeItem("wagmi.store");
|
|
144
|
+
localStorage.removeItem("lastAuthProvider");
|
|
145
|
+
localStorage.removeItem("b3-user");
|
|
146
|
+
}
|
|
147
|
+
app.logout();
|
|
148
|
+
debug("@@logout:loggedOut");
|
|
149
|
+
setIsAuthenticated(false);
|
|
150
|
+
setIsConnected(false);
|
|
151
|
+
setUser();
|
|
152
|
+
callback?.();
|
|
153
|
+
}, [activeWallet, disconnect, wallets, setIsAuthenticated, setUser, setIsConnected]);
|
|
128
154
|
const onConnect = useCallback(async (_walleAutoConnectedWith, allConnectedWallets) => {
|
|
129
155
|
debug("@@useAuthentication:onConnect", { _walleAutoConnectedWith, allConnectedWallets });
|
|
130
|
-
const wallet = allConnectedWallets.find(wallet => wallet.id.startsWith("ecosystem."));
|
|
131
|
-
if (!wallet) {
|
|
132
|
-
throw new Error("No smart wallet found during auto-connect");
|
|
133
|
-
}
|
|
134
|
-
debug("@@useAuthentication:onConnect", { wallet });
|
|
135
156
|
try {
|
|
157
|
+
const wallet = allConnectedWallets.find(wallet => wallet.id.startsWith("ecosystem."));
|
|
158
|
+
if (!wallet) {
|
|
159
|
+
throw new Error("No smart wallet found during auto-connect");
|
|
160
|
+
}
|
|
161
|
+
debug("@@useAuthentication:onConnect", { wallet });
|
|
136
162
|
setHasStartedConnecting(true);
|
|
137
163
|
setIsConnected(true);
|
|
138
164
|
setIsAuthenticating(true);
|
|
@@ -146,6 +172,7 @@ export function useAuthentication(partnerId) {
|
|
|
146
172
|
debug("@@useAuthentication:onConnect:failed", { error });
|
|
147
173
|
setIsAuthenticated(false);
|
|
148
174
|
setUser(undefined);
|
|
175
|
+
await logout();
|
|
149
176
|
}
|
|
150
177
|
finally {
|
|
151
178
|
setIsAuthenticating(false);
|
|
@@ -156,44 +183,19 @@ export function useAuthentication(partnerId) {
|
|
|
156
183
|
isConnected,
|
|
157
184
|
});
|
|
158
185
|
}, [
|
|
159
|
-
onConnectCallback,
|
|
160
|
-
authenticateUser,
|
|
161
186
|
isAuthenticated,
|
|
162
187
|
isAuthenticating,
|
|
163
188
|
isConnected,
|
|
164
|
-
setActiveWallet,
|
|
165
189
|
setHasStartedConnecting,
|
|
166
|
-
setIsAuthenticated,
|
|
167
|
-
setIsAuthenticating,
|
|
168
190
|
setIsConnected,
|
|
191
|
+
setIsAuthenticating,
|
|
192
|
+
setActiveWallet,
|
|
193
|
+
authenticateUser,
|
|
194
|
+
onConnectCallback,
|
|
195
|
+
setIsAuthenticated,
|
|
169
196
|
setUser,
|
|
197
|
+
logout,
|
|
170
198
|
]);
|
|
171
|
-
const logout = useCallback(async (callback) => {
|
|
172
|
-
if (activeWallet) {
|
|
173
|
-
debug("@@logout:activeWallet", activeWallet);
|
|
174
|
-
disconnect(activeWallet);
|
|
175
|
-
debug("@@logout:activeWallet", activeWallet);
|
|
176
|
-
}
|
|
177
|
-
// Log out of each wallet
|
|
178
|
-
wallets.forEach(wallet => {
|
|
179
|
-
console.log("@@logging out", wallet);
|
|
180
|
-
disconnect(wallet);
|
|
181
|
-
});
|
|
182
|
-
// Delete localStorage thirdweb:connected-wallet-ids
|
|
183
|
-
// https://npc-labs.slack.com/archives/C070E6HNG85/p1750185115273099
|
|
184
|
-
if (typeof localStorage !== "undefined") {
|
|
185
|
-
localStorage.removeItem("thirdweb:connected-wallet-ids");
|
|
186
|
-
localStorage.removeItem("wagmi.store");
|
|
187
|
-
localStorage.removeItem("lastAuthProvider");
|
|
188
|
-
localStorage.removeItem("b3-user");
|
|
189
|
-
}
|
|
190
|
-
app.logout();
|
|
191
|
-
debug("@@logout:loggedOut");
|
|
192
|
-
setIsAuthenticated(false);
|
|
193
|
-
setIsConnected(false);
|
|
194
|
-
setUser();
|
|
195
|
-
callback?.();
|
|
196
|
-
}, [activeWallet, disconnect, wallets, setIsAuthenticated, setUser, setIsConnected]);
|
|
197
199
|
const { isLoading: useAutoConnectLoading } = useAutoConnect({
|
|
198
200
|
client,
|
|
199
201
|
wallets: [wallet],
|
|
@@ -36,8 +36,8 @@ export declare function useUserQuery(): {
|
|
|
36
36
|
name?: string | undefined;
|
|
37
37
|
address?: string | undefined;
|
|
38
38
|
email?: string | undefined;
|
|
39
|
-
phone?: string | undefined;
|
|
40
39
|
username?: string | undefined;
|
|
40
|
+
phone?: string | undefined;
|
|
41
41
|
fid?: string | undefined;
|
|
42
42
|
};
|
|
43
43
|
}[] | undefined;
|