@b3dotfun/sdk 0.0.61 → 0.0.62-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.
Files changed (44) hide show
  1. package/dist/cjs/anyspend/react/components/AnySpendStakeB3.js +13 -2
  2. package/dist/cjs/anyspend/react/components/AnyspendDepositHype.d.ts +1 -0
  3. package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +17 -1
  4. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +4 -1
  5. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +3 -3
  6. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.js +2 -2
  7. package/dist/cjs/global-account/react/hooks/index.d.ts +1 -0
  8. package/dist/cjs/global-account/react/hooks/index.js +3 -1
  9. package/dist/cjs/global-account/react/hooks/useAuthentication.js +2 -2
  10. package/dist/cjs/global-account/react/stores/useModalStore.d.ts +2 -0
  11. package/dist/cjs/global-account/react/utils/createWagmiConfig.d.ts +27 -0
  12. package/dist/cjs/global-account/react/utils/createWagmiConfig.js +32 -0
  13. package/dist/esm/anyspend/react/components/AnySpendStakeB3.js +13 -2
  14. package/dist/esm/anyspend/react/components/AnyspendDepositHype.d.ts +1 -0
  15. package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +19 -3
  16. package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +4 -1
  17. package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +3 -3
  18. package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.js +2 -2
  19. package/dist/esm/global-account/react/hooks/index.d.ts +1 -0
  20. package/dist/esm/global-account/react/hooks/index.js +1 -0
  21. package/dist/esm/global-account/react/hooks/useAuthentication.js +2 -2
  22. package/dist/esm/global-account/react/stores/useModalStore.d.ts +2 -0
  23. package/dist/esm/global-account/react/utils/createWagmiConfig.d.ts +27 -0
  24. package/dist/esm/global-account/react/utils/createWagmiConfig.js +29 -0
  25. package/dist/types/anyspend/react/components/AnyspendDepositHype.d.ts +1 -0
  26. package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +4 -1
  27. package/dist/types/global-account/react/hooks/index.d.ts +1 -0
  28. package/dist/types/global-account/react/stores/useModalStore.d.ts +2 -0
  29. package/dist/types/global-account/react/utils/createWagmiConfig.d.ts +27 -0
  30. package/package.json +3 -3
  31. package/src/anyspend/react/components/AnySpendStakeB3.tsx +15 -2
  32. package/src/anyspend/react/components/AnyspendDepositHype.tsx +22 -2
  33. package/src/global-account/react/components/B3Provider/B3Provider.native.tsx +2 -2
  34. package/src/global-account/react/components/B3Provider/B3Provider.tsx +7 -3
  35. package/src/global-account/react/hooks/index.ts +1 -0
  36. package/src/global-account/react/hooks/useAuthentication.ts +2 -2
  37. package/src/global-account/react/stores/useModalStore.ts +2 -0
  38. package/src/global-account/react/utils/createWagmiConfig.tsx +40 -0
  39. package/dist/cjs/global-account/react/hooks/useWagmiConfig.d.ts +0 -453
  40. package/dist/cjs/global-account/react/hooks/useWagmiConfig.js +0 -44
  41. package/dist/esm/global-account/react/hooks/useWagmiConfig.d.ts +0 -453
  42. package/dist/esm/global-account/react/hooks/useWagmiConfig.js +0 -41
  43. package/dist/types/global-account/react/hooks/useWagmiConfig.d.ts +0 -453
  44. 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...");
@@ -20,5 +20,6 @@ export interface AnySpendDepositHypeProps {
20
20
  preventDefault: () => void;
21
21
  }) => void;
22
22
  customUsdInputValues?: string[];
23
+ preferEoa?: boolean;
23
24
  }
24
25
  export declare function AnySpendDepositHype(props: AnySpendDepositHypeProps): import("react/jsx-runtime").JSX.Element;
@@ -24,8 +24,10 @@ const FiatPaymentMethod_1 = require("./common/FiatPaymentMethod");
24
24
  const OrderDetails_1 = require("./common/OrderDetails");
25
25
  const PointsDetailPanel_1 = require("./common/PointsDetailPanel");
26
26
  const RecipientSelection_1 = require("./common/RecipientSelection");
27
+ const react_4 = require("thirdweb/react");
27
28
  const lucide_react_1 = require("lucide-react");
28
29
  const PanelOnramp_1 = require("./common/PanelOnramp");
30
+ const utils_1 = require("../../utils");
29
31
  const SLIPPAGE_PERCENT = 3;
30
32
  exports.HYPE_TOKEN_DETAILS = {
31
33
  SYMBOL: "HYPE",
@@ -35,7 +37,7 @@ function AnySpendDepositHype(props) {
35
37
  const fingerprintConfig = (0, AnySpendFingerprintWrapper_1.getFingerprintConfig)();
36
38
  return ((0, jsx_runtime_1.jsx)(AnySpendFingerprintWrapper_1.AnySpendFingerprintWrapper, { fingerprint: fingerprintConfig, children: (0, jsx_runtime_1.jsx)(AnySpendDepositHypeInner, { ...props }) }));
37
39
  }
38
- function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress, paymentType = "crypto", sourceTokenAddress, sourceTokenChainId, onSuccess, mainFooter, onTokenSelect, customUsdInputValues, }) {
40
+ function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress, paymentType = "crypto", sourceTokenAddress, sourceTokenChainId, onSuccess, mainFooter, onTokenSelect, customUsdInputValues, preferEoa, }) {
39
41
  // Use shared flow hook
40
42
  const { activePanel, setActivePanel, orderId, setOrderId, oat, selectedSrcChainId, setSelectedSrcChainId, selectedSrcToken, setSelectedSrcToken, srcAmount, setSrcAmount, dstAmount, isSrcInputDirty, setIsSrcInputDirty, selectedCryptoPaymentMethod, setSelectedCryptoPaymentMethod, selectedFiatPaymentMethod, setSelectedFiatPaymentMethod, selectedRecipientAddress, setSelectedRecipientAddress, recipientName, globalAddress, anyspendQuote, isLoadingAnyspendQuote, activeInputAmountInWei, geoData, coinbaseAvailablePaymentMethods, stripeWeb2Support, createOrder, isCreatingOrder, createOnrampOrder, isCreatingOnrampOrder, } = (0, useAnyspendFlow_1.useAnyspendFlow)({
41
43
  paymentType,
@@ -48,6 +50,20 @@ function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress,
48
50
  slippage: SLIPPAGE_PERCENT,
49
51
  disableUrlParamManagement: true,
50
52
  });
53
+ const { connectedEOAWallet: connectedEOAWallet } = (0, react_1.useAccountWallet)();
54
+ const setActiveWallet = (0, react_4.useSetActiveWallet)();
55
+ const activeWallet = (0, react_4.useActiveWallet)();
56
+ const setGlobalAccountWallet = (0, utils_1.useGlobalWalletState)(state => state.setGlobalAccountWallet);
57
+ const appliedPreferEoa = (0, react_3.useRef)(false);
58
+ (0, react_3.useEffect)(() => {
59
+ if (preferEoa && !appliedPreferEoa.current) {
60
+ if (connectedEOAWallet) {
61
+ appliedPreferEoa.current = true;
62
+ setGlobalAccountWallet(activeWallet);
63
+ setActiveWallet(connectedEOAWallet);
64
+ }
65
+ }
66
+ }, [preferEoa, connectedEOAWallet, setActiveWallet, activeWallet, setGlobalAccountWallet]);
51
67
  // Button state logic
52
68
  const btnInfo = (0, react_3.useMemo)(() => {
53
69
  if (activeInputAmountInWei === "0")
@@ -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, overrideDefaultConnectors, }: {
10
11
  theme: "light" | "dark";
11
12
  children: React.ReactNode;
12
13
  accountOverride?: Account;
@@ -21,6 +22,8 @@ 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[];
26
+ overrideDefaultConnectors?: boolean;
24
27
  }): import("react/jsx-runtime").JSX.Element;
25
28
  /**
26
29
  * 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, overrideDefaultConnectors = false, }) {
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, overrideDefaultConnectors });
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)();
@@ -312,6 +312,8 @@ export interface AnySpendDepositHypeProps extends BaseModalProps {
312
312
  onSuccess?: (amount?: string) => void;
313
313
  /** Custom USD input values for quick amount buttons in fiat onramp */
314
314
  customUsdInputValues?: string[];
315
+ /** prefer eoa wallet */
316
+ preferEoa?: boolean;
315
317
  }
316
318
  export interface AvatarEditorModalProps extends BaseModalProps {
317
319
  /** Modal type identifier */
@@ -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...");
@@ -20,5 +20,6 @@ export interface AnySpendDepositHypeProps {
20
20
  preventDefault: () => void;
21
21
  }) => void;
22
22
  customUsdInputValues?: string[];
23
+ preferEoa?: boolean;
23
24
  }
24
25
  export declare function AnySpendDepositHype(props: AnySpendDepositHypeProps): import("react/jsx-runtime").JSX.Element;
@@ -1,10 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { B3_TOKEN } from "../../../anyspend/index.js";
3
- import { Button, ShinyButton, StyleRoot, TransitionPanel } from "../../../global-account/react/index.js";
3
+ import { Button, ShinyButton, StyleRoot, TransitionPanel, useAccountWallet } from "../../../global-account/react/index.js";
4
4
  import { cn } from "../../../shared/utils/cn.js";
5
5
  import invariant from "invariant";
6
6
  import { motion } from "motion/react";
7
- import { useMemo } from "react";
7
+ import { useEffect, useMemo, useRef } from "react";
8
8
  import { toast } from "sonner";
9
9
  import { base } from "viem/chains";
10
10
  import { PanelView, useAnyspendFlow } from "../hooks/useAnyspendFlow.js";
@@ -17,8 +17,10 @@ import { FiatPaymentMethod, FiatPaymentMethodComponent } from "./common/FiatPaym
17
17
  import { OrderDetails } from "./common/OrderDetails.js";
18
18
  import { PointsDetailPanel } from "./common/PointsDetailPanel.js";
19
19
  import { RecipientSelection } from "./common/RecipientSelection.js";
20
+ import { useActiveWallet, useSetActiveWallet } from "thirdweb/react";
20
21
  import { ArrowDown, Loader2 } from "lucide-react";
21
22
  import { PanelOnramp } from "./common/PanelOnramp.js";
23
+ import { useGlobalWalletState } from "../../utils/index.js";
22
24
  const SLIPPAGE_PERCENT = 3;
23
25
  export const HYPE_TOKEN_DETAILS = {
24
26
  SYMBOL: "HYPE",
@@ -28,7 +30,7 @@ export function AnySpendDepositHype(props) {
28
30
  const fingerprintConfig = getFingerprintConfig();
29
31
  return (_jsx(AnySpendFingerprintWrapper, { fingerprint: fingerprintConfig, children: _jsx(AnySpendDepositHypeInner, { ...props }) }));
30
32
  }
31
- function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress, paymentType = "crypto", sourceTokenAddress, sourceTokenChainId, onSuccess, mainFooter, onTokenSelect, customUsdInputValues, }) {
33
+ function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress, paymentType = "crypto", sourceTokenAddress, sourceTokenChainId, onSuccess, mainFooter, onTokenSelect, customUsdInputValues, preferEoa, }) {
32
34
  // Use shared flow hook
33
35
  const { activePanel, setActivePanel, orderId, setOrderId, oat, selectedSrcChainId, setSelectedSrcChainId, selectedSrcToken, setSelectedSrcToken, srcAmount, setSrcAmount, dstAmount, isSrcInputDirty, setIsSrcInputDirty, selectedCryptoPaymentMethod, setSelectedCryptoPaymentMethod, selectedFiatPaymentMethod, setSelectedFiatPaymentMethod, selectedRecipientAddress, setSelectedRecipientAddress, recipientName, globalAddress, anyspendQuote, isLoadingAnyspendQuote, activeInputAmountInWei, geoData, coinbaseAvailablePaymentMethods, stripeWeb2Support, createOrder, isCreatingOrder, createOnrampOrder, isCreatingOnrampOrder, } = useAnyspendFlow({
34
36
  paymentType,
@@ -41,6 +43,20 @@ function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress,
41
43
  slippage: SLIPPAGE_PERCENT,
42
44
  disableUrlParamManagement: true,
43
45
  });
46
+ const { connectedEOAWallet: connectedEOAWallet } = useAccountWallet();
47
+ const setActiveWallet = useSetActiveWallet();
48
+ const activeWallet = useActiveWallet();
49
+ const setGlobalAccountWallet = useGlobalWalletState(state => state.setGlobalAccountWallet);
50
+ const appliedPreferEoa = useRef(false);
51
+ useEffect(() => {
52
+ if (preferEoa && !appliedPreferEoa.current) {
53
+ if (connectedEOAWallet) {
54
+ appliedPreferEoa.current = true;
55
+ setGlobalAccountWallet(activeWallet);
56
+ setActiveWallet(connectedEOAWallet);
57
+ }
58
+ }
59
+ }, [preferEoa, connectedEOAWallet, setActiveWallet, activeWallet, setGlobalAccountWallet]);
44
60
  // Button state logic
45
61
  const btnInfo = useMemo(() => {
46
62
  if (activeInputAmountInWei === "0")
@@ -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, overrideDefaultConnectors, }: {
10
11
  theme: "light" | "dark";
11
12
  children: React.ReactNode;
12
13
  accountOverride?: Account;
@@ -21,6 +22,8 @@ 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[];
26
+ overrideDefaultConnectors?: boolean;
24
27
  }): import("react/jsx-runtime").JSX.Element;
25
28
  /**
26
29
  * 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, overrideDefaultConnectors = false, }) {
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, overrideDefaultConnectors });
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();
@@ -312,6 +312,8 @@ export interface AnySpendDepositHypeProps extends BaseModalProps {
312
312
  onSuccess?: (amount?: string) => void;
313
313
  /** Custom USD input values for quick amount buttons in fiat onramp */
314
314
  customUsdInputValues?: string[];
315
+ /** prefer eoa wallet */
316
+ preferEoa?: boolean;
315
317
  }
316
318
  export interface AvatarEditorModalProps extends BaseModalProps {
317
319
  /** Modal type identifier */
@@ -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
+ }
@@ -20,5 +20,6 @@ export interface AnySpendDepositHypeProps {
20
20
  preventDefault: () => void;
21
21
  }) => void;
22
22
  customUsdInputValues?: string[];
23
+ preferEoa?: boolean;
23
24
  }
24
25
  export declare function AnySpendDepositHype(props: AnySpendDepositHypeProps): import("react/jsx-runtime").JSX.Element;
@@ -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, overrideDefaultConnectors, }: {
10
11
  theme: "light" | "dark";
11
12
  children: React.ReactNode;
12
13
  accountOverride?: Account;
@@ -21,6 +22,8 @@ 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[];
26
+ overrideDefaultConnectors?: boolean;
24
27
  }): import("react/jsx-runtime").JSX.Element;
25
28
  /**
26
29
  * 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";
@@ -312,6 +312,8 @@ export interface AnySpendDepositHypeProps extends BaseModalProps {
312
312
  onSuccess?: (amount?: string) => void;
313
313
  /** Custom USD input values for quick amount buttons in fiat onramp */
314
314
  customUsdInputValues?: string[];
315
+ /** prefer eoa wallet */
316
+ preferEoa?: boolean;
315
317
  }
316
318
  export interface AvatarEditorModalProps extends BaseModalProps {
317
319
  /** Modal type identifier */
@@ -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
+ }>)[]>;