@b3dotfun/sdk 0.0.82 → 0.0.83-alpha.0

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 (44) hide show
  1. package/dist/cjs/anyspend/react/components/AnySpend.js +0 -3
  2. package/dist/cjs/anyspend/react/components/AnySpendCollectorClubPurchase.js +1 -1
  3. package/dist/cjs/anyspend/react/components/AnySpendCustom.js +0 -3
  4. package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +47 -177
  5. package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.js +0 -3
  6. package/dist/cjs/anyspend/utils/chain.d.ts +38 -0
  7. package/dist/cjs/anyspend/utils/chain.js +22 -1
  8. package/dist/cjs/anyspend/utils/token.d.ts +3 -0
  9. package/dist/cjs/anyspend/utils/token.js +17 -1
  10. package/dist/cjs/global-account/react/hooks/useAuthentication.d.ts +1 -1
  11. package/dist/cjs/global-account/react/hooks/useAuthentication.js +38 -36
  12. package/dist/cjs/global-account/react/hooks/useUserQuery.d.ts +1 -1
  13. package/dist/esm/anyspend/react/components/AnySpend.js +0 -3
  14. package/dist/esm/anyspend/react/components/AnySpendCollectorClubPurchase.js +1 -1
  15. package/dist/esm/anyspend/react/components/AnySpendCustom.js +0 -3
  16. package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +45 -175
  17. package/dist/esm/anyspend/react/hooks/useAnyspendFlow.js +0 -3
  18. package/dist/esm/anyspend/utils/chain.d.ts +38 -0
  19. package/dist/esm/anyspend/utils/chain.js +22 -1
  20. package/dist/esm/anyspend/utils/token.d.ts +3 -0
  21. package/dist/esm/anyspend/utils/token.js +15 -1
  22. package/dist/esm/global-account/react/hooks/useAuthentication.d.ts +1 -1
  23. package/dist/esm/global-account/react/hooks/useAuthentication.js +38 -36
  24. package/dist/esm/global-account/react/hooks/useUserQuery.d.ts +1 -1
  25. package/dist/styles/index.css +1 -1
  26. package/dist/types/anyspend/utils/chain.d.ts +38 -0
  27. package/dist/types/anyspend/utils/token.d.ts +3 -0
  28. package/dist/types/global-account/react/hooks/useAuthentication.d.ts +1 -1
  29. package/dist/types/global-account/react/hooks/useUserQuery.d.ts +1 -1
  30. package/package.json +1 -1
  31. package/src/anyspend/react/components/AnySpend.tsx +0 -4
  32. package/src/anyspend/react/components/AnySpendCollectorClubPurchase.tsx +1 -1
  33. package/src/anyspend/react/components/AnySpendCustom.tsx +0 -4
  34. package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +22 -253
  35. package/src/anyspend/react/hooks/useAnyspendFlow.ts +0 -4
  36. package/src/anyspend/utils/chain.ts +31 -1
  37. package/src/anyspend/utils/token.ts +17 -1
  38. package/src/global-account/react/hooks/useAuthentication.ts +47 -46
  39. package/dist/cjs/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.d.ts +0 -10
  40. package/dist/cjs/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.js +0 -73
  41. package/dist/esm/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.d.ts +0 -10
  42. package/dist/esm/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.js +0 -70
  43. package/dist/types/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.d.ts +0 -10
  44. package/src/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.ts +0 -80
@@ -1,73 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useAutoSetActiveWalletFromWagmi = useAutoSetActiveWalletFromWagmi;
4
- const thirdweb_1 = require("../../../shared/utils/thirdweb");
5
- const react_1 = require("react");
6
- const react_2 = require("thirdweb/react");
7
- const wallets_1 = require("thirdweb/wallets");
8
- const wagmi_1 = require("wagmi");
9
- /**
10
- * Hook that automatically sets the active thirdweb wallet when a wagmi wallet connects.
11
- *
12
- * This is useful for syncing wagmi wallet connections with thirdweb's wallet system,
13
- * ensuring that when users connect via wagmi, the active wallet is properly set.
14
- *
15
- * Place this hook in components that stay mounted throughout the user flow
16
- * (not in components that unmount during navigation).
17
- */
18
- function useAutoSetActiveWalletFromWagmi() {
19
- const { address: wagmiAddress, connector: wagmiConnector } = (0, wagmi_1.useAccount)();
20
- const setActiveWallet = (0, react_2.useSetActiveWallet)();
21
- const prevWagmiAddress = (0, react_1.useRef)(undefined);
22
- // Map wagmi connector names to thirdweb wallet IDs
23
- const getThirdwebWalletId = (0, react_1.useCallback)((connectorName) => {
24
- const walletMap = {
25
- MetaMask: "io.metamask",
26
- "Coinbase Wallet": "com.coinbase.wallet",
27
- Rainbow: "me.rainbow",
28
- WalletConnect: "walletConnect",
29
- Phantom: "app.phantom",
30
- };
31
- return walletMap[connectorName] || null;
32
- }, []);
33
- // Create thirdweb wallet from wagmi connector
34
- const createThirdwebWalletFromConnector = (0, react_1.useCallback)(async (connectorName) => {
35
- const walletId = getThirdwebWalletId(connectorName);
36
- if (!walletId) {
37
- console.warn(`No thirdweb wallet ID found for connector: ${connectorName}`);
38
- return null;
39
- }
40
- try {
41
- const thirdwebWallet = (0, wallets_1.createWallet)(walletId);
42
- await thirdwebWallet.connect({ client: thirdweb_1.client });
43
- return thirdwebWallet;
44
- }
45
- catch (error) {
46
- console.error(`Failed to create thirdweb wallet for ${connectorName}:`, error);
47
- return null;
48
- }
49
- }, [getThirdwebWalletId]);
50
- // Listen for wagmi wallet connections and automatically set active wallet
51
- (0, react_1.useEffect)(() => {
52
- const isNewConnection = wagmiAddress && wagmiAddress !== prevWagmiAddress.current;
53
- if (isNewConnection && wagmiConnector?.name) {
54
- prevWagmiAddress.current = wagmiAddress;
55
- const setupThirdwebWallet = async () => {
56
- try {
57
- const thirdwebWallet = await createThirdwebWalletFromConnector(wagmiConnector.name);
58
- if (thirdwebWallet) {
59
- setActiveWallet(thirdwebWallet);
60
- console.log(`Auto-set active wallet for ${wagmiConnector.name}`);
61
- }
62
- }
63
- catch (error) {
64
- console.error("Failed to auto-set active wallet:", error);
65
- }
66
- };
67
- setupThirdwebWallet();
68
- }
69
- if (!wagmiAddress) {
70
- prevWagmiAddress.current = undefined;
71
- }
72
- }, [wagmiAddress, wagmiConnector?.name, setActiveWallet, createThirdwebWalletFromConnector]);
73
- }
@@ -1,10 +0,0 @@
1
- /**
2
- * Hook that automatically sets the active thirdweb wallet when a wagmi wallet connects.
3
- *
4
- * This is useful for syncing wagmi wallet connections with thirdweb's wallet system,
5
- * ensuring that when users connect via wagmi, the active wallet is properly set.
6
- *
7
- * Place this hook in components that stay mounted throughout the user flow
8
- * (not in components that unmount during navigation).
9
- */
10
- export declare function useAutoSetActiveWalletFromWagmi(): void;
@@ -1,70 +0,0 @@
1
- import { client } from "../../../shared/utils/thirdweb.js";
2
- import { useCallback, useEffect, useRef } from "react";
3
- import { useSetActiveWallet } from "thirdweb/react";
4
- import { createWallet } from "thirdweb/wallets";
5
- import { useAccount } from "wagmi";
6
- /**
7
- * Hook that automatically sets the active thirdweb wallet when a wagmi wallet connects.
8
- *
9
- * This is useful for syncing wagmi wallet connections with thirdweb's wallet system,
10
- * ensuring that when users connect via wagmi, the active wallet is properly set.
11
- *
12
- * Place this hook in components that stay mounted throughout the user flow
13
- * (not in components that unmount during navigation).
14
- */
15
- export function useAutoSetActiveWalletFromWagmi() {
16
- const { address: wagmiAddress, connector: wagmiConnector } = useAccount();
17
- const setActiveWallet = useSetActiveWallet();
18
- const prevWagmiAddress = useRef(undefined);
19
- // Map wagmi connector names to thirdweb wallet IDs
20
- const getThirdwebWalletId = useCallback((connectorName) => {
21
- const walletMap = {
22
- MetaMask: "io.metamask",
23
- "Coinbase Wallet": "com.coinbase.wallet",
24
- Rainbow: "me.rainbow",
25
- WalletConnect: "walletConnect",
26
- Phantom: "app.phantom",
27
- };
28
- return walletMap[connectorName] || null;
29
- }, []);
30
- // Create thirdweb wallet from wagmi connector
31
- const createThirdwebWalletFromConnector = useCallback(async (connectorName) => {
32
- const walletId = getThirdwebWalletId(connectorName);
33
- if (!walletId) {
34
- console.warn(`No thirdweb wallet ID found for connector: ${connectorName}`);
35
- return null;
36
- }
37
- try {
38
- const thirdwebWallet = createWallet(walletId);
39
- await thirdwebWallet.connect({ client });
40
- return thirdwebWallet;
41
- }
42
- catch (error) {
43
- console.error(`Failed to create thirdweb wallet for ${connectorName}:`, error);
44
- return null;
45
- }
46
- }, [getThirdwebWalletId]);
47
- // Listen for wagmi wallet connections and automatically set active wallet
48
- useEffect(() => {
49
- const isNewConnection = wagmiAddress && wagmiAddress !== prevWagmiAddress.current;
50
- if (isNewConnection && wagmiConnector?.name) {
51
- prevWagmiAddress.current = wagmiAddress;
52
- const setupThirdwebWallet = async () => {
53
- try {
54
- const thirdwebWallet = await createThirdwebWalletFromConnector(wagmiConnector.name);
55
- if (thirdwebWallet) {
56
- setActiveWallet(thirdwebWallet);
57
- console.log(`Auto-set active wallet for ${wagmiConnector.name}`);
58
- }
59
- }
60
- catch (error) {
61
- console.error("Failed to auto-set active wallet:", error);
62
- }
63
- };
64
- setupThirdwebWallet();
65
- }
66
- if (!wagmiAddress) {
67
- prevWagmiAddress.current = undefined;
68
- }
69
- }, [wagmiAddress, wagmiConnector?.name, setActiveWallet, createThirdwebWalletFromConnector]);
70
- }
@@ -1,10 +0,0 @@
1
- /**
2
- * Hook that automatically sets the active thirdweb wallet when a wagmi wallet connects.
3
- *
4
- * This is useful for syncing wagmi wallet connections with thirdweb's wallet system,
5
- * ensuring that when users connect via wagmi, the active wallet is properly set.
6
- *
7
- * Place this hook in components that stay mounted throughout the user flow
8
- * (not in components that unmount during navigation).
9
- */
10
- export declare function useAutoSetActiveWalletFromWagmi(): void;
@@ -1,80 +0,0 @@
1
- import { client } from "@b3dotfun/sdk/shared/utils/thirdweb";
2
- import { useCallback, useEffect, useRef } from "react";
3
- import { useSetActiveWallet } from "thirdweb/react";
4
- import { WalletId, createWallet } from "thirdweb/wallets";
5
- import { useAccount } from "wagmi";
6
-
7
- /**
8
- * Hook that automatically sets the active thirdweb wallet when a wagmi wallet connects.
9
- *
10
- * This is useful for syncing wagmi wallet connections with thirdweb's wallet system,
11
- * ensuring that when users connect via wagmi, the active wallet is properly set.
12
- *
13
- * Place this hook in components that stay mounted throughout the user flow
14
- * (not in components that unmount during navigation).
15
- */
16
- export function useAutoSetActiveWalletFromWagmi() {
17
- const { address: wagmiAddress, connector: wagmiConnector } = useAccount();
18
- const setActiveWallet = useSetActiveWallet();
19
- const prevWagmiAddress = useRef<string | undefined>(undefined);
20
-
21
- // Map wagmi connector names to thirdweb wallet IDs
22
- const getThirdwebWalletId = useCallback((connectorName: string): WalletId | null => {
23
- const walletMap: Record<string, WalletId> = {
24
- MetaMask: "io.metamask",
25
- "Coinbase Wallet": "com.coinbase.wallet",
26
- Rainbow: "me.rainbow",
27
- WalletConnect: "walletConnect",
28
- Phantom: "app.phantom",
29
- };
30
- return walletMap[connectorName] || null;
31
- }, []);
32
-
33
- // Create thirdweb wallet from wagmi connector
34
- const createThirdwebWalletFromConnector = useCallback(
35
- async (connectorName: string) => {
36
- const walletId = getThirdwebWalletId(connectorName);
37
- if (!walletId) {
38
- console.warn(`No thirdweb wallet ID found for connector: ${connectorName}`);
39
- return null;
40
- }
41
-
42
- try {
43
- const thirdwebWallet = createWallet(walletId);
44
- await thirdwebWallet.connect({ client });
45
- return thirdwebWallet;
46
- } catch (error) {
47
- console.error(`Failed to create thirdweb wallet for ${connectorName}:`, error);
48
- return null;
49
- }
50
- },
51
- [getThirdwebWalletId],
52
- );
53
-
54
- // Listen for wagmi wallet connections and automatically set active wallet
55
- useEffect(() => {
56
- const isNewConnection = wagmiAddress && wagmiAddress !== prevWagmiAddress.current;
57
-
58
- if (isNewConnection && wagmiConnector?.name) {
59
- prevWagmiAddress.current = wagmiAddress;
60
-
61
- const setupThirdwebWallet = async () => {
62
- try {
63
- const thirdwebWallet = await createThirdwebWalletFromConnector(wagmiConnector.name);
64
- if (thirdwebWallet) {
65
- setActiveWallet(thirdwebWallet);
66
- console.log(`Auto-set active wallet for ${wagmiConnector.name}`);
67
- }
68
- } catch (error) {
69
- console.error("Failed to auto-set active wallet:", error);
70
- }
71
- };
72
-
73
- setupThirdwebWallet();
74
- }
75
-
76
- if (!wagmiAddress) {
77
- prevWagmiAddress.current = undefined;
78
- }
79
- }, [wagmiAddress, wagmiConnector?.name, setActiveWallet, createThirdwebWalletFromConnector]);
80
- }