@b3dotfun/sdk 0.0.61-alpha.0 → 0.0.61-alpha.2

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 (34) hide show
  1. package/dist/cjs/anyspend/react/components/AnySpendStakeB3.js +13 -2
  2. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +3 -1
  3. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +3 -3
  4. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.js +2 -2
  5. package/dist/cjs/global-account/react/hooks/index.d.ts +1 -0
  6. package/dist/cjs/global-account/react/hooks/index.js +3 -1
  7. package/dist/cjs/global-account/react/hooks/useAuthentication.js +2 -2
  8. package/dist/cjs/global-account/react/utils/createWagmiConfig.d.ts +27 -0
  9. package/dist/cjs/global-account/react/utils/createWagmiConfig.js +32 -0
  10. package/dist/esm/anyspend/react/components/AnySpendStakeB3.js +13 -2
  11. package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +3 -1
  12. package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +3 -3
  13. package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.js +2 -2
  14. package/dist/esm/global-account/react/hooks/index.d.ts +1 -0
  15. package/dist/esm/global-account/react/hooks/index.js +1 -0
  16. package/dist/esm/global-account/react/hooks/useAuthentication.js +2 -2
  17. package/dist/esm/global-account/react/utils/createWagmiConfig.d.ts +27 -0
  18. package/dist/esm/global-account/react/utils/createWagmiConfig.js +29 -0
  19. package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +3 -1
  20. package/dist/types/global-account/react/hooks/index.d.ts +1 -0
  21. package/dist/types/global-account/react/utils/createWagmiConfig.d.ts +27 -0
  22. package/package.json +1 -2
  23. package/src/anyspend/react/components/AnySpendStakeB3.tsx +15 -2
  24. package/src/global-account/react/components/B3Provider/B3Provider.native.tsx +2 -2
  25. package/src/global-account/react/components/B3Provider/B3Provider.tsx +5 -3
  26. package/src/global-account/react/hooks/index.ts +1 -0
  27. package/src/global-account/react/hooks/useAuthentication.ts +2 -2
  28. package/src/global-account/react/utils/createWagmiConfig.tsx +40 -0
  29. package/dist/cjs/global-account/react/hooks/useWagmiConfig.d.ts +0 -453
  30. package/dist/cjs/global-account/react/hooks/useWagmiConfig.js +0 -44
  31. package/dist/esm/global-account/react/hooks/useWagmiConfig.d.ts +0 -453
  32. package/dist/esm/global-account/react/hooks/useWagmiConfig.js +0 -41
  33. package/dist/types/global-account/react/hooks/useWagmiConfig.d.ts +0 -453
  34. package/src/global-account/react/hooks/useWagmiConfig.tsx +0 -46
@@ -163,12 +163,23 @@ function AnySpendStakeB3({ loadOrder, mode = "modal", recipientAddress, stakeAmo
163
163
  functionName: "approve",
164
164
  args: [ERC20Staking, BigInt(userStakeAmount)],
165
165
  });
166
- await switchChainAndExecute(chains_1.base.id, {
166
+ const approvalHash = await switchChainAndExecute(chains_1.base.id, {
167
167
  to: anyspend_1.B3_TOKEN.address,
168
168
  data: approvalData,
169
169
  value: BigInt(0),
170
170
  });
171
- sonner_1.toast.info("Approval confirmed. Proceeding with stake...");
171
+ if (!approvalHash) {
172
+ sonner_1.toast.error("Approval failed. Please try again.");
173
+ return;
174
+ }
175
+ const approvalReceipt = await basePublicClient.waitForTransactionReceipt({
176
+ hash: approvalHash,
177
+ confirmations: 1,
178
+ });
179
+ if (approvalReceipt?.status !== "success") {
180
+ sonner_1.toast.error("Approval failed. Please try again.");
181
+ return;
182
+ }
172
183
  }
173
184
  // Execute the stake
174
185
  sonner_1.toast.info("Staking B3...");
@@ -1,12 +1,13 @@
1
1
  import { PermissionsConfig } from "../../../../global-account/types/permissions";
2
2
  import "@relayprotocol/relay-kit-ui/styles.css";
3
3
  import { Account, Wallet } from "thirdweb/wallets";
4
+ import { CreateConnectorFn } from "wagmi";
4
5
  import { ClientType } from "../../../client-manager";
5
6
  import { B3ContextType } from "./types";
6
7
  /**
7
8
  * Main B3Provider component
8
9
  */
9
- export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, clientType, rpcUrls, partnerId, onConnect, }: {
10
+ export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, clientType, rpcUrls, partnerId, onConnect, connectors, }: {
10
11
  theme: "light" | "dark";
11
12
  children: React.ReactNode;
12
13
  accountOverride?: Account;
@@ -21,6 +22,7 @@ export declare function B3Provider({ theme, children, accountOverride, environme
21
22
  rpcUrls?: Record<number, string>;
22
23
  partnerId: string;
23
24
  onConnect?: (wallet: Wallet, b3Jwt: string) => void | Promise<void>;
25
+ connectors?: CreateConnectorFn[];
24
26
  }): import("react/jsx-runtime").JSX.Element;
25
27
  /**
26
28
  * Inner provider component that provides the actual B3Context
@@ -4,7 +4,7 @@ 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");
7
+ const createWagmiConfig_1 = require("../../../../global-account/react/utils/createWagmiConfig");
8
8
  const analytics_1 = require("../../../../global-account/utils/analytics");
9
9
  const debug_1 = require("../../../../shared/utils/debug");
10
10
  require("@relayprotocol/relay-kit-ui/styles.css");
@@ -32,7 +32,7 @@ const queryClient = new react_query_1.QueryClient();
32
32
  /**
33
33
  * Main B3Provider component
34
34
  */
35
- function B3Provider({ theme = "light", children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, clientType = "rest", rpcUrls, partnerId, onConnect, }) {
35
+ function B3Provider({ theme = "light", children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, clientType = "rest", rpcUrls, partnerId, onConnect, connectors, }) {
36
36
  // Initialize Google Analytics on mount
37
37
  (0, react_2.useEffect)(() => {
38
38
  (0, analytics_1.loadGA4Script)();
@@ -41,7 +41,7 @@ function B3Provider({ theme = "light", children, accountOverride, environment, a
41
41
  (0, react_2.useEffect)(() => {
42
42
  (0, client_manager_1.setClientType)(clientType);
43
43
  }, [clientType]);
44
- const wagmiConfig = (0, useWagmiConfig_1.useWagmiConfig)(partnerId, rpcUrls);
44
+ const wagmiConfig = (0, createWagmiConfig_1.createWagmiConfig)({ partnerId, rpcUrls, connectors });
45
45
  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)(LocalSDKProvider_1.LocalSDKProvider, { onConnectCallback: onConnect, 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
46
  }
47
47
  /**
@@ -7,7 +7,7 @@ const react_query_1 = require("@tanstack/react-query");
7
7
  const react_1 = require("thirdweb/react");
8
8
  const wagmi_1 = require("wagmi");
9
9
  const useAuthentication_1 = require("../../hooks/useAuthentication");
10
- const useWagmiConfig_1 = require("../../hooks/useWagmiConfig");
10
+ const createWagmiConfig_1 = require("../../utils/createWagmiConfig");
11
11
  const LocalSDKProvider_1 = require("./LocalSDKProvider");
12
12
  const types_1 = require("./types");
13
13
  /**
@@ -33,7 +33,7 @@ function B3Provider({ theme = "light", children, accountOverride, environment, c
33
33
  function InnerProvider({ children, accountOverride, environment, defaultPermissions = DEFAULT_PERMISSIONS, theme = "light", clientType = "socket", partnerId, rpcUrls, }) {
34
34
  const activeAccount = (0, react_1.useActiveAccount)();
35
35
  const { user, setUser, refetchUser } = (0, useAuthentication_1.useAuthentication)(partnerId);
36
- const wagmiConfig = (0, useWagmiConfig_1.useWagmiConfig)(partnerId, rpcUrls);
36
+ const wagmiConfig = (0, createWagmiConfig_1.createWagmiConfig)({ partnerId, rpcUrls });
37
37
  // Use given accountOverride or activeAccount from thirdweb
38
38
  const effectiveAccount = accountOverride || activeAccount;
39
39
  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: {
@@ -1,3 +1,4 @@
1
+ export { createWagmiConfig, type CreateWagmiConfigOptions } from "../utils/createWagmiConfig";
1
2
  export { useAccountAssets } from "./useAccountAssets";
2
3
  export { useAccountWallet } from "./useAccountWallet";
3
4
  export { useAddTWSessionKey } from "./useAddTWSessionKey";
@@ -14,7 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.useURLParams = exports.useUnifiedChainSwitchAndExecute = exports.useTokensFromAddress = exports.useTokenPriceWithFallback = exports.useTokenPrice = exports.useTokenFromUrl = exports.useTokenData = exports.useTokenBalancesByChain = exports.useTokenBalance = exports.useSiwe = exports.useSimBalance = exports.useSearchParamsSSR = exports.useRouter = exports.useRemoveSessionKey = exports.useQueryBSMNT = exports.useQueryB3 = exports.useProfilePreference = exports.useProfile = exports.useOneBalance = exports.useNativeBalanceFromRPC = exports.useNativeBalance = exports.useMediaQuery = exports.useIsomorphicLayoutEffect = exports.useIsMobile = exports.useHasMounted = exports.useHandleConnectWithPrivy = exports.useGlobalAccount = exports.useGetGeo = exports.useGetAllTWSigners = exports.useFirstEOA = exports.useExchangeRate = exports.useConnect = exports.useClient = exports.useChainSwitchWithAction = exports.useBestTransactionPath = exports.useB3EnsName = exports.useB3BalanceFromAddresses = exports.useAuthentication = exports.useAnalytics = exports.useAddTWSessionKey = exports.useAccountWallet = exports.useAccountAssets = void 0;
17
+ exports.useURLParams = exports.useUnifiedChainSwitchAndExecute = exports.useTokensFromAddress = exports.useTokenPriceWithFallback = exports.useTokenPrice = exports.useTokenFromUrl = exports.useTokenData = exports.useTokenBalancesByChain = exports.useTokenBalance = exports.useSiwe = exports.useSimBalance = exports.useSearchParamsSSR = exports.useRouter = exports.useRemoveSessionKey = exports.useQueryBSMNT = exports.useQueryB3 = exports.useProfilePreference = exports.useProfile = exports.useOneBalance = exports.useNativeBalanceFromRPC = exports.useNativeBalance = exports.useMediaQuery = exports.useIsomorphicLayoutEffect = exports.useIsMobile = exports.useHasMounted = exports.useHandleConnectWithPrivy = exports.useGlobalAccount = exports.useGetGeo = exports.useGetAllTWSigners = exports.useFirstEOA = exports.useExchangeRate = exports.useConnect = exports.useClient = exports.useChainSwitchWithAction = exports.useBestTransactionPath = exports.useB3EnsName = exports.useB3BalanceFromAddresses = exports.useAuthentication = exports.useAnalytics = exports.useAddTWSessionKey = exports.useAccountWallet = exports.useAccountAssets = exports.createWagmiConfig = void 0;
18
+ var createWagmiConfig_1 = require("../utils/createWagmiConfig");
19
+ Object.defineProperty(exports, "createWagmiConfig", { enumerable: true, get: function () { return createWagmiConfig_1.createWagmiConfig; } });
18
20
  var useAccountAssets_1 = require("./useAccountAssets");
19
21
  Object.defineProperty(exports, "useAccountAssets", { enumerable: true, get: function () { return useAccountAssets_1.useAccountAssets; } });
20
22
  var useAccountWallet_1 = require("./useAccountWallet");
@@ -17,9 +17,9 @@ const wallets_1 = require("thirdweb/wallets");
17
17
  const in_app_1 = require("thirdweb/wallets/in-app");
18
18
  const wagmi_1 = require("wagmi");
19
19
  const LocalSDKProvider_1 = require("../components/B3Provider/LocalSDKProvider");
20
+ const createWagmiConfig_1 = require("../utils/createWagmiConfig");
20
21
  const useTWAuth_1 = require("./useTWAuth");
21
22
  const useUserQuery_1 = require("./useUserQuery");
22
- const useWagmiConfig_1 = require("./useWagmiConfig");
23
23
  const debug = (0, debug_1.debugB3React)("useAuthentication");
24
24
  function useAuthentication(partnerId) {
25
25
  const { onConnectCallback } = (0, react_2.useContext)(LocalSDKProvider_1.LocalSDKContext);
@@ -39,7 +39,7 @@ function useAuthentication(partnerId) {
39
39
  const { authenticate } = (0, useTWAuth_1.useTWAuth)();
40
40
  const { user, setUser } = (0, useUserQuery_1.useUserQuery)();
41
41
  const useAutoConnectLoadingPrevious = (0, react_2.useRef)(false);
42
- const wagmiConfig = (0, useWagmiConfig_1.useWagmiConfig)(partnerId);
42
+ const wagmiConfig = (0, createWagmiConfig_1.createWagmiConfig)({ partnerId });
43
43
  const { connect } = (0, wagmi_1.useConnect)();
44
44
  const activeWagmiAccount = (0, wagmi_1.useAccount)();
45
45
  const { switchAccount } = (0, wagmi_1.useSwitchAccount)();
@@ -0,0 +1,27 @@
1
+ import { type CreateConnectorFn } from "wagmi";
2
+ export interface CreateWagmiConfigOptions {
3
+ partnerId: string;
4
+ rpcUrls?: Record<number, string>;
5
+ connectors?: CreateConnectorFn[];
6
+ overrideDefaultConnectors?: boolean;
7
+ }
8
+ /**
9
+ * Creates a wagmi config with optional custom RPC URLs and connectors
10
+ * @param options.partnerId - Partner ID for the ecosystem wallet
11
+ * @param options.rpcUrls - Optional mapping of chain IDs to RPC URLs
12
+ * @param options.connectors - Additional connectors to include
13
+ * @param options.overrideDefaultConnectors - If true, only use provided connectors (ignores defaults)
14
+ */
15
+ export declare function createWagmiConfig(options: CreateWagmiConfigOptions): import("wagmi").Config<readonly [import("viem").Chain, ...import("viem").Chain[]], {
16
+ [k: string]: import("viem").HttpTransport<undefined, false>;
17
+ }, (CreateConnectorFn | CreateConnectorFn<import("thirdweb/dist/types/adapters/eip1193").EIP1193Provider | undefined, {
18
+ connect<withCapabilities extends boolean = false>(parameters?: import("@thirdweb-dev/wagmi-adapter").ConnectionOptions<withCapabilities> | undefined): Promise<{
19
+ accounts: withCapabilities extends true ? readonly {
20
+ address: `0x${string}`;
21
+ capabilities: Record<string, unknown>;
22
+ }[] : readonly `0x${string}`[];
23
+ chainId: number;
24
+ }>;
25
+ }, {
26
+ "thirdweb:lastChainId": number;
27
+ }>)[]>;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createWagmiConfig = createWagmiConfig;
4
+ const constants_1 = require("../../../shared/constants");
5
+ const supported_1 = require("../../../shared/constants/chains/supported");
6
+ const thirdweb_1 = require("../../../shared/utils/thirdweb");
7
+ const wagmi_adapter_1 = require("@thirdweb-dev/wagmi-adapter");
8
+ const viem_1 = require("viem");
9
+ const wagmi_1 = require("wagmi");
10
+ /**
11
+ * Creates a wagmi config with optional custom RPC URLs and connectors
12
+ * @param options.partnerId - Partner ID for the ecosystem wallet
13
+ * @param options.rpcUrls - Optional mapping of chain IDs to RPC URLs
14
+ * @param options.connectors - Additional connectors to include
15
+ * @param options.overrideDefaultConnectors - If true, only use provided connectors (ignores defaults)
16
+ */
17
+ function createWagmiConfig(options) {
18
+ const { partnerId, rpcUrls, connectors = [], overrideDefaultConnectors = false } = options;
19
+ const defaultConnectors = [
20
+ (0, wagmi_adapter_1.inAppWalletConnector)({
21
+ ecosystemId: constants_1.ecosystemWalletId,
22
+ partnerId,
23
+ client: thirdweb_1.client,
24
+ }),
25
+ ];
26
+ const finalConnectors = overrideDefaultConnectors ? connectors : [...defaultConnectors, ...connectors];
27
+ return (0, wagmi_1.createConfig)({
28
+ chains: [supported_1.supportedChains[0], ...supported_1.supportedChains.slice(1)],
29
+ transports: Object.fromEntries(supported_1.supportedChains.map(chain => [chain.id, (0, viem_1.http)(rpcUrls?.[chain.id])])),
30
+ connectors: finalConnectors,
31
+ });
32
+ }
@@ -157,12 +157,23 @@ export function AnySpendStakeB3({ loadOrder, mode = "modal", recipientAddress, s
157
157
  functionName: "approve",
158
158
  args: [ERC20Staking, BigInt(userStakeAmount)],
159
159
  });
160
- await switchChainAndExecute(base.id, {
160
+ const approvalHash = await switchChainAndExecute(base.id, {
161
161
  to: B3_TOKEN.address,
162
162
  data: approvalData,
163
163
  value: BigInt(0),
164
164
  });
165
- toast.info("Approval confirmed. Proceeding with stake...");
165
+ if (!approvalHash) {
166
+ toast.error("Approval failed. Please try again.");
167
+ return;
168
+ }
169
+ const approvalReceipt = await basePublicClient.waitForTransactionReceipt({
170
+ hash: approvalHash,
171
+ confirmations: 1,
172
+ });
173
+ if (approvalReceipt?.status !== "success") {
174
+ toast.error("Approval failed. Please try again.");
175
+ return;
176
+ }
166
177
  }
167
178
  // Execute the stake
168
179
  toast.info("Staking B3...");
@@ -1,12 +1,13 @@
1
1
  import { PermissionsConfig } from "../../../../global-account/types/permissions";
2
2
  import "@relayprotocol/relay-kit-ui/styles.css";
3
3
  import { Account, Wallet } from "thirdweb/wallets";
4
+ import { CreateConnectorFn } from "wagmi";
4
5
  import { ClientType } from "../../../client-manager";
5
6
  import { B3ContextType } from "./types";
6
7
  /**
7
8
  * Main B3Provider component
8
9
  */
9
- export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, clientType, rpcUrls, partnerId, onConnect, }: {
10
+ export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, clientType, rpcUrls, partnerId, onConnect, connectors, }: {
10
11
  theme: "light" | "dark";
11
12
  children: React.ReactNode;
12
13
  accountOverride?: Account;
@@ -21,6 +22,7 @@ export declare function B3Provider({ theme, children, accountOverride, environme
21
22
  rpcUrls?: Record<number, string>;
22
23
  partnerId: string;
23
24
  onConnect?: (wallet: Wallet, b3Jwt: string) => void | Promise<void>;
25
+ connectors?: CreateConnectorFn[];
24
26
  }): import("react/jsx-runtime").JSX.Element;
25
27
  /**
26
28
  * Inner provider component that provides the actual B3Context
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { RelayKitProviderWrapper, TooltipProvider, useAuthentication, useAuthStore, } from "../../../../global-account/react/index.js";
3
- import { useWagmiConfig } from "../../../../global-account/react/hooks/useWagmiConfig.js";
3
+ import { createWagmiConfig } from "../../../../global-account/react/utils/createWagmiConfig.js";
4
4
  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";
@@ -28,7 +28,7 @@ const queryClient = new QueryClient();
28
28
  /**
29
29
  * Main B3Provider component
30
30
  */
31
- export function B3Provider({ theme = "light", children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, clientType = "rest", rpcUrls, partnerId, onConnect, }) {
31
+ export function B3Provider({ theme = "light", children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, clientType = "rest", rpcUrls, partnerId, onConnect, connectors, }) {
32
32
  // Initialize Google Analytics on mount
33
33
  useEffect(() => {
34
34
  loadGA4Script();
@@ -37,7 +37,7 @@ export function B3Provider({ theme = "light", children, accountOverride, environ
37
37
  useEffect(() => {
38
38
  setClientType(clientType);
39
39
  }, [clientType]);
40
- const wagmiConfig = useWagmiConfig(partnerId, rpcUrls);
40
+ const wagmiConfig = createWagmiConfig({ partnerId, rpcUrls, connectors });
41
41
  return (_jsx(ThirdwebProvider, { children: _jsx(WagmiProvider, { config: wagmiConfig, reconnectOnMount: false, children: _jsx(QueryClientProvider, { client: queryClient, children: _jsx(TooltipProvider, { children: _jsx(LocalSDKProvider, { onConnectCallback: onConnect, children: _jsx(InnerProvider, { accountOverride: accountOverride, environment: environment, theme: theme, automaticallySetFirstEoa: !!automaticallySetFirstEoa, clientType: clientType, partnerId: partnerId, children: _jsxs(RelayKitProviderWrapper, { simDuneApiKey: simDuneApiKey, children: [children, _jsx(StyleRoot, { id: "b3-root" }), _jsx(Toaster, { theme: theme, position: toaster?.position, style: toaster?.style })] }) }) }) }) }) }) }));
42
42
  }
43
43
  /**
@@ -3,7 +3,7 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
3
3
  import { ThirdwebProvider, useActiveAccount } from "thirdweb/react";
4
4
  import { WagmiProvider } from "wagmi";
5
5
  import { useAuthentication } from "../../hooks/useAuthentication.js";
6
- import { useWagmiConfig } from "../../hooks/useWagmiConfig.js";
6
+ import { createWagmiConfig } from "../../utils/createWagmiConfig.js";
7
7
  import { LocalSDKProvider } from "./LocalSDKProvider.js";
8
8
  import { B3Context } from "./types.js";
9
9
  /**
@@ -29,7 +29,7 @@ export function B3Provider({ theme = "light", children, accountOverride, environ
29
29
  export function InnerProvider({ children, accountOverride, environment, defaultPermissions = DEFAULT_PERMISSIONS, theme = "light", clientType = "socket", partnerId, rpcUrls, }) {
30
30
  const activeAccount = useActiveAccount();
31
31
  const { user, setUser, refetchUser } = useAuthentication(partnerId);
32
- const wagmiConfig = useWagmiConfig(partnerId, rpcUrls);
32
+ const wagmiConfig = createWagmiConfig({ partnerId, rpcUrls });
33
33
  // Use given accountOverride or activeAccount from thirdweb
34
34
  const effectiveAccount = accountOverride || activeAccount;
35
35
  return (_jsx(WagmiProvider, { config: wagmiConfig, children: _jsx(QueryClientProvider, { client: queryClient, children: _jsx(B3Context.Provider, { value: {
@@ -1,3 +1,4 @@
1
+ export { createWagmiConfig, type CreateWagmiConfigOptions } from "../utils/createWagmiConfig";
1
2
  export { useAccountAssets } from "./useAccountAssets";
2
3
  export { useAccountWallet } from "./useAccountWallet";
3
4
  export { useAddTWSessionKey } from "./useAddTWSessionKey";
@@ -1,3 +1,4 @@
1
+ export { createWagmiConfig } from "../utils/createWagmiConfig.js";
1
2
  export { useAccountAssets } from "./useAccountAssets.js";
2
3
  export { useAccountWallet } from "./useAccountWallet.js";
3
4
  export { useAddTWSessionKey } from "./useAddTWSessionKey.js";
@@ -11,9 +11,9 @@ import { ecosystemWallet } from "thirdweb/wallets";
11
11
  import { preAuthenticate } from "thirdweb/wallets/in-app";
12
12
  import { useAccount, useConnect, useSwitchAccount } from "wagmi";
13
13
  import { LocalSDKContext } from "../components/B3Provider/LocalSDKProvider.js";
14
+ import { createWagmiConfig } from "../utils/createWagmiConfig.js";
14
15
  import { useTWAuth } from "./useTWAuth.js";
15
16
  import { useUserQuery } from "./useUserQuery.js";
16
- import { useWagmiConfig } from "./useWagmiConfig.js";
17
17
  const debug = debugB3React("useAuthentication");
18
18
  export function useAuthentication(partnerId) {
19
19
  const { onConnectCallback } = useContext(LocalSDKContext);
@@ -33,7 +33,7 @@ export function useAuthentication(partnerId) {
33
33
  const { authenticate } = useTWAuth();
34
34
  const { user, setUser } = useUserQuery();
35
35
  const useAutoConnectLoadingPrevious = useRef(false);
36
- const wagmiConfig = useWagmiConfig(partnerId);
36
+ const wagmiConfig = createWagmiConfig({ partnerId });
37
37
  const { connect } = useConnect();
38
38
  const activeWagmiAccount = useAccount();
39
39
  const { switchAccount } = useSwitchAccount();
@@ -0,0 +1,27 @@
1
+ import { type CreateConnectorFn } from "wagmi";
2
+ export interface CreateWagmiConfigOptions {
3
+ partnerId: string;
4
+ rpcUrls?: Record<number, string>;
5
+ connectors?: CreateConnectorFn[];
6
+ overrideDefaultConnectors?: boolean;
7
+ }
8
+ /**
9
+ * Creates a wagmi config with optional custom RPC URLs and connectors
10
+ * @param options.partnerId - Partner ID for the ecosystem wallet
11
+ * @param options.rpcUrls - Optional mapping of chain IDs to RPC URLs
12
+ * @param options.connectors - Additional connectors to include
13
+ * @param options.overrideDefaultConnectors - If true, only use provided connectors (ignores defaults)
14
+ */
15
+ export declare function createWagmiConfig(options: CreateWagmiConfigOptions): import("wagmi").Config<readonly [import("viem").Chain, ...import("viem").Chain[]], {
16
+ [k: string]: import("viem").HttpTransport<undefined, false>;
17
+ }, (CreateConnectorFn | CreateConnectorFn<import("thirdweb/dist/types/adapters/eip1193").EIP1193Provider | undefined, {
18
+ connect<withCapabilities extends boolean = false>(parameters?: import("@thirdweb-dev/wagmi-adapter").ConnectionOptions<withCapabilities> | undefined): Promise<{
19
+ accounts: withCapabilities extends true ? readonly {
20
+ address: `0x${string}`;
21
+ capabilities: Record<string, unknown>;
22
+ }[] : readonly `0x${string}`[];
23
+ chainId: number;
24
+ }>;
25
+ }, {
26
+ "thirdweb:lastChainId": number;
27
+ }>)[]>;
@@ -0,0 +1,29 @@
1
+ import { ecosystemWalletId } from "../../../shared/constants/index.js";
2
+ import { supportedChains } from "../../../shared/constants/chains/supported.js";
3
+ import { client } from "../../../shared/utils/thirdweb.js";
4
+ import { inAppWalletConnector } from "@thirdweb-dev/wagmi-adapter";
5
+ import { http } from "viem";
6
+ import { createConfig } from "wagmi";
7
+ /**
8
+ * Creates a wagmi config with optional custom RPC URLs and connectors
9
+ * @param options.partnerId - Partner ID for the ecosystem wallet
10
+ * @param options.rpcUrls - Optional mapping of chain IDs to RPC URLs
11
+ * @param options.connectors - Additional connectors to include
12
+ * @param options.overrideDefaultConnectors - If true, only use provided connectors (ignores defaults)
13
+ */
14
+ export function createWagmiConfig(options) {
15
+ const { partnerId, rpcUrls, connectors = [], overrideDefaultConnectors = false } = options;
16
+ const defaultConnectors = [
17
+ inAppWalletConnector({
18
+ ecosystemId: ecosystemWalletId,
19
+ partnerId,
20
+ client,
21
+ }),
22
+ ];
23
+ const finalConnectors = overrideDefaultConnectors ? connectors : [...defaultConnectors, ...connectors];
24
+ return createConfig({
25
+ chains: [supportedChains[0], ...supportedChains.slice(1)],
26
+ transports: Object.fromEntries(supportedChains.map(chain => [chain.id, http(rpcUrls?.[chain.id])])),
27
+ connectors: finalConnectors,
28
+ });
29
+ }
@@ -1,12 +1,13 @@
1
1
  import { PermissionsConfig } from "@b3dotfun/sdk/global-account/types/permissions";
2
2
  import "@relayprotocol/relay-kit-ui/styles.css";
3
3
  import { Account, Wallet } from "thirdweb/wallets";
4
+ import { CreateConnectorFn } from "wagmi";
4
5
  import { ClientType } from "../../../client-manager";
5
6
  import { B3ContextType } from "./types";
6
7
  /**
7
8
  * Main B3Provider component
8
9
  */
9
- export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, clientType, rpcUrls, partnerId, onConnect, }: {
10
+ export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, clientType, rpcUrls, partnerId, onConnect, connectors, }: {
10
11
  theme: "light" | "dark";
11
12
  children: React.ReactNode;
12
13
  accountOverride?: Account;
@@ -21,6 +22,7 @@ export declare function B3Provider({ theme, children, accountOverride, environme
21
22
  rpcUrls?: Record<number, string>;
22
23
  partnerId: string;
23
24
  onConnect?: (wallet: Wallet, b3Jwt: string) => void | Promise<void>;
25
+ connectors?: CreateConnectorFn[];
24
26
  }): import("react/jsx-runtime").JSX.Element;
25
27
  /**
26
28
  * Inner provider component that provides the actual B3Context
@@ -1,3 +1,4 @@
1
+ export { createWagmiConfig, type CreateWagmiConfigOptions } from "../utils/createWagmiConfig";
1
2
  export { useAccountAssets } from "./useAccountAssets";
2
3
  export { useAccountWallet } from "./useAccountWallet";
3
4
  export { useAddTWSessionKey } from "./useAddTWSessionKey";
@@ -0,0 +1,27 @@
1
+ import { type CreateConnectorFn } from "wagmi";
2
+ export interface CreateWagmiConfigOptions {
3
+ partnerId: string;
4
+ rpcUrls?: Record<number, string>;
5
+ connectors?: CreateConnectorFn[];
6
+ overrideDefaultConnectors?: boolean;
7
+ }
8
+ /**
9
+ * Creates a wagmi config with optional custom RPC URLs and connectors
10
+ * @param options.partnerId - Partner ID for the ecosystem wallet
11
+ * @param options.rpcUrls - Optional mapping of chain IDs to RPC URLs
12
+ * @param options.connectors - Additional connectors to include
13
+ * @param options.overrideDefaultConnectors - If true, only use provided connectors (ignores defaults)
14
+ */
15
+ export declare function createWagmiConfig(options: CreateWagmiConfigOptions): import("wagmi").Config<readonly [import("viem").Chain, ...import("viem").Chain[]], {
16
+ [k: string]: import("viem").HttpTransport<undefined, false>;
17
+ }, (CreateConnectorFn | CreateConnectorFn<import("thirdweb/dist/types/adapters/eip1193").EIP1193Provider | undefined, {
18
+ connect<withCapabilities extends boolean = false>(parameters?: import("@thirdweb-dev/wagmi-adapter").ConnectionOptions<withCapabilities> | undefined): Promise<{
19
+ accounts: withCapabilities extends true ? readonly {
20
+ address: `0x${string}`;
21
+ capabilities: Record<string, unknown>;
22
+ }[] : readonly `0x${string}`[];
23
+ chainId: number;
24
+ }>;
25
+ }, {
26
+ "thirdweb:lastChainId": number;
27
+ }>)[]>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@b3dotfun/sdk",
3
- "version": "0.0.61-alpha.0",
3
+ "version": "0.0.61-alpha.2",
4
4
  "source": "src/index.ts",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "react-native": "./dist/cjs/index.native.js",
@@ -284,7 +284,6 @@
284
284
  "dependencies": {
285
285
  "@b3dotfun/b3-api": "0.0.77",
286
286
  "@b3dotfun/basement-api": "0.0.11",
287
- "@farcaster/miniapp-wagmi-connector": "^1.1.0",
288
287
  "@feathersjs/authentication-client": "5.0.33",
289
288
  "@feathersjs/feathers": "5.0.33",
290
289
  "@feathersjs/rest-client": "5.0.33",
@@ -207,13 +207,26 @@ export function AnySpendStakeB3({
207
207
  args: [ERC20Staking as `0x${string}`, BigInt(userStakeAmount)],
208
208
  });
209
209
 
210
- await switchChainAndExecute(base.id, {
210
+ const approvalHash = await switchChainAndExecute(base.id, {
211
211
  to: B3_TOKEN.address as `0x${string}`,
212
212
  data: approvalData,
213
213
  value: BigInt(0),
214
214
  });
215
215
 
216
- toast.info("Approval confirmed. Proceeding with stake...");
216
+ if (!approvalHash) {
217
+ toast.error("Approval failed. Please try again.");
218
+ return;
219
+ }
220
+
221
+ const approvalReceipt = await basePublicClient.waitForTransactionReceipt({
222
+ hash: approvalHash as `0x${string}`,
223
+ confirmations: 1,
224
+ });
225
+
226
+ if (approvalReceipt?.status !== "success") {
227
+ toast.error("Approval failed. Please try again.");
228
+ return;
229
+ }
217
230
  }
218
231
 
219
232
  // Execute the stake
@@ -7,7 +7,7 @@ import { ClientType } from "../../../client-manager";
7
7
 
8
8
  import { WagmiProvider } from "wagmi";
9
9
  import { useAuthentication } from "../../hooks/useAuthentication";
10
- import { useWagmiConfig } from "../../hooks/useWagmiConfig";
10
+ import { createWagmiConfig } from "../../utils/createWagmiConfig";
11
11
  import { LocalSDKProvider } from "./LocalSDKProvider";
12
12
  import { B3Context, B3ContextType } from "./types";
13
13
 
@@ -90,7 +90,7 @@ export function InnerProvider({
90
90
  }) {
91
91
  const activeAccount = useActiveAccount();
92
92
  const { user, setUser, refetchUser } = useAuthentication(partnerId);
93
- const wagmiConfig = useWagmiConfig(partnerId, rpcUrls);
93
+ const wagmiConfig = createWagmiConfig({ partnerId, rpcUrls });
94
94
 
95
95
  // Use given accountOverride or activeAccount from thirdweb
96
96
  const effectiveAccount = accountOverride || activeAccount;
@@ -4,7 +4,7 @@ import {
4
4
  useAuthentication,
5
5
  useAuthStore,
6
6
  } from "@b3dotfun/sdk/global-account/react";
7
- import { useWagmiConfig } from "@b3dotfun/sdk/global-account/react/hooks/useWagmiConfig";
7
+ import { createWagmiConfig } from "@b3dotfun/sdk/global-account/react/utils/createWagmiConfig";
8
8
  import { PermissionsConfig } from "@b3dotfun/sdk/global-account/types/permissions";
9
9
  import { loadGA4Script } from "@b3dotfun/sdk/global-account/utils/analytics";
10
10
  import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
@@ -20,7 +20,7 @@ import {
20
20
  useSetActiveWallet,
21
21
  } from "thirdweb/react";
22
22
  import { Account, Wallet } from "thirdweb/wallets";
23
- import { WagmiProvider } from "wagmi";
23
+ import { CreateConnectorFn, WagmiProvider } from "wagmi";
24
24
  import { ClientType, setClientType } from "../../../client-manager";
25
25
  import { StyleRoot } from "../StyleRoot";
26
26
  import { LocalSDKProvider } from "./LocalSDKProvider";
@@ -56,6 +56,7 @@ export function B3Provider({
56
56
  rpcUrls,
57
57
  partnerId,
58
58
  onConnect,
59
+ connectors,
59
60
  }: {
60
61
  theme: "light" | "dark";
61
62
  children: React.ReactNode;
@@ -71,6 +72,7 @@ export function B3Provider({
71
72
  rpcUrls?: Record<number, string>;
72
73
  partnerId: string;
73
74
  onConnect?: (wallet: Wallet, b3Jwt: string) => void | Promise<void>;
75
+ connectors?: CreateConnectorFn[];
74
76
  }) {
75
77
  // Initialize Google Analytics on mount
76
78
  useEffect(() => {
@@ -81,7 +83,7 @@ export function B3Provider({
81
83
  useEffect(() => {
82
84
  setClientType(clientType);
83
85
  }, [clientType]);
84
- const wagmiConfig = useWagmiConfig(partnerId, rpcUrls);
86
+ const wagmiConfig = createWagmiConfig({ partnerId, rpcUrls, connectors });
85
87
 
86
88
  return (
87
89
  <ThirdwebProvider>
@@ -1,3 +1,4 @@
1
+ export { createWagmiConfig, type CreateWagmiConfigOptions } from "../utils/createWagmiConfig";
1
2
  export { useAccountAssets } from "./useAccountAssets";
2
3
  export { useAccountWallet } from "./useAccountWallet";
3
4
  export { useAddTWSessionKey } from "./useAddTWSessionKey";
@@ -18,9 +18,9 @@ import { Wallet, ecosystemWallet } from "thirdweb/wallets";
18
18
  import { preAuthenticate } from "thirdweb/wallets/in-app";
19
19
  import { useAccount, useConnect, useSwitchAccount } from "wagmi";
20
20
  import { LocalSDKContext } from "../components/B3Provider/LocalSDKProvider";
21
+ import { createWagmiConfig } from "../utils/createWagmiConfig";
21
22
  import { useTWAuth } from "./useTWAuth";
22
23
  import { useUserQuery } from "./useUserQuery";
23
- import { useWagmiConfig } from "./useWagmiConfig";
24
24
 
25
25
  const debug = debugB3React("useAuthentication");
26
26
 
@@ -42,7 +42,7 @@ export function useAuthentication(partnerId: string) {
42
42
  const { authenticate } = useTWAuth();
43
43
  const { user, setUser } = useUserQuery();
44
44
  const useAutoConnectLoadingPrevious = useRef(false);
45
- const wagmiConfig = useWagmiConfig(partnerId);
45
+ const wagmiConfig = createWagmiConfig({ partnerId });
46
46
  const { connect } = useConnect();
47
47
  const activeWagmiAccount = useAccount();
48
48
  const { switchAccount } = useSwitchAccount();
@@ -0,0 +1,40 @@
1
+ import { ecosystemWalletId } from "@b3dotfun/sdk/shared/constants";
2
+ import { supportedChains } from "@b3dotfun/sdk/shared/constants/chains/supported";
3
+ import { client } from "@b3dotfun/sdk/shared/utils/thirdweb";
4
+ import { inAppWalletConnector } from "@thirdweb-dev/wagmi-adapter";
5
+ import { http } from "viem";
6
+ import { createConfig, type CreateConnectorFn } from "wagmi";
7
+
8
+ export interface CreateWagmiConfigOptions {
9
+ partnerId: string;
10
+ rpcUrls?: Record<number, string>;
11
+ connectors?: CreateConnectorFn[];
12
+ overrideDefaultConnectors?: boolean;
13
+ }
14
+
15
+ /**
16
+ * Creates a wagmi config with optional custom RPC URLs and connectors
17
+ * @param options.partnerId - Partner ID for the ecosystem wallet
18
+ * @param options.rpcUrls - Optional mapping of chain IDs to RPC URLs
19
+ * @param options.connectors - Additional connectors to include
20
+ * @param options.overrideDefaultConnectors - If true, only use provided connectors (ignores defaults)
21
+ */
22
+ export function createWagmiConfig(options: CreateWagmiConfigOptions) {
23
+ const { partnerId, rpcUrls, connectors = [], overrideDefaultConnectors = false } = options;
24
+
25
+ const defaultConnectors = [
26
+ inAppWalletConnector({
27
+ ecosystemId: ecosystemWalletId,
28
+ partnerId,
29
+ client,
30
+ }),
31
+ ];
32
+
33
+ const finalConnectors = overrideDefaultConnectors ? connectors : [...defaultConnectors, ...connectors];
34
+
35
+ return createConfig({
36
+ chains: [supportedChains[0], ...supportedChains.slice(1)],
37
+ transports: Object.fromEntries(supportedChains.map(chain => [chain.id, http(rpcUrls?.[chain.id])])),
38
+ connectors: finalConnectors,
39
+ });
40
+ }