@b3dotfun/sdk 0.1.0-alpha.1 → 0.1.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 (34) hide show
  1. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +30 -2
  2. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.js +31 -4
  3. package/dist/cjs/global-account/react/components/B3Provider/useB3.d.ts +12 -1
  4. package/dist/cjs/global-account/react/components/B3Provider/useB3Config.d.ts +17 -1
  5. package/dist/cjs/global-account/react/components/B3Provider/useB3Config.js +21 -2
  6. package/dist/cjs/global-account/react/stores/configStore.d.ts +24 -0
  7. package/dist/cjs/global-account/react/stores/configStore.js +30 -0
  8. package/dist/cjs/global-account/react/stores/index.d.ts +1 -0
  9. package/dist/cjs/global-account/react/stores/index.js +3 -1
  10. package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +30 -2
  11. package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.js +30 -3
  12. package/dist/esm/global-account/react/components/B3Provider/useB3.d.ts +12 -1
  13. package/dist/esm/global-account/react/components/B3Provider/useB3Config.d.ts +17 -1
  14. package/dist/esm/global-account/react/components/B3Provider/useB3Config.js +20 -1
  15. package/dist/esm/global-account/react/stores/configStore.d.ts +24 -0
  16. package/dist/esm/global-account/react/stores/configStore.js +27 -0
  17. package/dist/esm/global-account/react/stores/index.d.ts +1 -0
  18. package/dist/esm/global-account/react/stores/index.js +1 -0
  19. package/dist/types/global-account/react/components/B3Provider/useB3.d.ts +12 -1
  20. package/dist/types/global-account/react/components/B3Provider/useB3Config.d.ts +17 -1
  21. package/dist/types/global-account/react/stores/configStore.d.ts +24 -0
  22. package/dist/types/global-account/react/stores/index.d.ts +1 -0
  23. package/package.json +1 -1
  24. package/src/global-account/react/components/B3Provider/B3Provider.native.tsx +36 -28
  25. package/src/global-account/react/components/B3Provider/B3Provider.tsx +38 -21
  26. package/src/global-account/react/components/B3Provider/useB3Config.ts +21 -1
  27. package/src/global-account/react/stores/configStore.ts +51 -0
  28. package/src/global-account/react/stores/index.ts +1 -0
  29. package/dist/cjs/global-account/react/components/B3Provider/B3ConfigProvider.d.ts +0 -31
  30. package/dist/cjs/global-account/react/components/B3Provider/B3ConfigProvider.js +0 -37
  31. package/dist/esm/global-account/react/components/B3Provider/B3ConfigProvider.d.ts +0 -31
  32. package/dist/esm/global-account/react/components/B3Provider/B3ConfigProvider.js +0 -33
  33. package/dist/types/global-account/react/components/B3Provider/B3ConfigProvider.d.ts +0 -31
  34. package/src/global-account/react/components/B3Provider/B3ConfigProvider.tsx +0 -84
@@ -14,10 +14,10 @@ const react_2 = require("react");
14
14
  const react_3 = require("thirdweb/react");
15
15
  const wagmi_1 = require("wagmi");
16
16
  const client_manager_1 = require("../../../client-manager");
17
+ const configStore_1 = require("../../stores/configStore");
17
18
  const StyleRoot_1 = require("../StyleRoot");
18
19
  const index_1 = require("../Toast/index");
19
20
  const AuthenticationProvider_1 = __importDefault(require("./AuthenticationProvider"));
20
- const B3ConfigProvider_1 = require("./B3ConfigProvider");
21
21
  const LocalSDKProvider_1 = require("./LocalSDKProvider");
22
22
  // Create queryClient instance
23
23
  const queryClient = new react_query_1.QueryClient();
@@ -27,6 +27,34 @@ const queryClient = new react_query_1.QueryClient();
27
27
  function B3Provider({ theme = "light", children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey,
28
28
  // deprecated since v0.0.87
29
29
  toaster: _toaster, clientType = "rest", rpcUrls, partnerId, stripePublishableKey, onConnect, connectors, overrideDefaultConnectors = false, createClientReferenceId, enableTurnkey = false, defaultPermissions, }) {
30
+ const setConfig = (0, configStore_1.useB3ConfigStore)(state => state.setConfig);
31
+ // Initialize config store on mount
32
+ (0, react_2.useEffect)(() => {
33
+ setConfig({
34
+ accountOverride,
35
+ environment: environment ?? "development",
36
+ automaticallySetFirstEoa: !!automaticallySetFirstEoa,
37
+ theme,
38
+ clientType,
39
+ partnerId,
40
+ stripePublishableKey,
41
+ createClientReferenceId,
42
+ enableTurnkey,
43
+ defaultPermissions,
44
+ });
45
+ }, [
46
+ accountOverride,
47
+ environment,
48
+ automaticallySetFirstEoa,
49
+ theme,
50
+ clientType,
51
+ partnerId,
52
+ stripePublishableKey,
53
+ createClientReferenceId,
54
+ enableTurnkey,
55
+ defaultPermissions,
56
+ setConfig,
57
+ ]); // eslint-disable-line react-hooks/exhaustive-deps
30
58
  // Initialize Google Analytics on mount
31
59
  (0, react_2.useEffect)(() => {
32
60
  (0, analytics_1.loadGA4Script)();
@@ -36,7 +64,7 @@ toaster: _toaster, clientType = "rest", rpcUrls, partnerId, stripePublishableKey
36
64
  (0, client_manager_1.setClientType)(clientType);
37
65
  }, [clientType]);
38
66
  const wagmiConfig = (0, react_2.useMemo)(() => (0, createWagmiConfig_1.createWagmiConfig)({ partnerId, rpcUrls, connectors, overrideDefaultConnectors }), [partnerId, rpcUrls, connectors, overrideDefaultConnectors]);
39
- 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)(index_1.ToastProvider, { children: (0, jsx_runtime_1.jsx)(LocalSDKProvider_1.LocalSDKProvider, { onConnectCallback: onConnect, children: (0, jsx_runtime_1.jsxs)(B3ConfigProvider_1.B3ConfigProvider, { accountOverride: accountOverride, environment: environment, automaticallySetFirstEoa: !!automaticallySetFirstEoa, theme: theme, clientType: clientType, partnerId: partnerId, stripePublishableKey: stripePublishableKey, createClientReferenceId: createClientReferenceId, enableTurnkey: enableTurnkey, defaultPermissions: defaultPermissions, children: [(0, jsx_runtime_1.jsx)(ToastContextConnector, {}), (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)(AuthenticationProvider_1.default, { partnerId: partnerId, automaticallySetFirstEoa: !!automaticallySetFirstEoa })] }) }) }) }) }) }) }));
67
+ 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)(index_1.ToastProvider, { children: (0, jsx_runtime_1.jsxs)(LocalSDKProvider_1.LocalSDKProvider, { onConnectCallback: onConnect, children: [(0, jsx_runtime_1.jsx)(ToastContextConnector, {}), (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)(AuthenticationProvider_1.default, { partnerId: partnerId, automaticallySetFirstEoa: !!automaticallySetFirstEoa })] }) }) }) }) }) }));
40
68
  }
41
69
  /**
42
70
  * Component to connect the toast context to the global toast API
@@ -7,11 +7,12 @@ exports.B3Provider = B3Provider;
7
7
  exports.InnerProvider = InnerProvider;
8
8
  const jsx_runtime_1 = require("react/jsx-runtime");
9
9
  const react_query_1 = require("@tanstack/react-query");
10
- const react_1 = require("thirdweb/react");
10
+ const react_1 = require("react");
11
+ const react_2 = require("thirdweb/react");
11
12
  const wagmi_1 = require("wagmi");
13
+ const configStore_1 = require("../../stores/configStore");
12
14
  const createWagmiConfig_1 = require("../../utils/createWagmiConfig");
13
15
  const AuthenticationProvider_1 = __importDefault(require("./AuthenticationProvider"));
14
- const B3ConfigProvider_1 = require("./B3ConfigProvider");
15
16
  const LocalSDKProvider_1 = require("./LocalSDKProvider");
16
17
  // Create queryClient instance
17
18
  const queryClient = new react_query_1.QueryClient();
@@ -19,12 +20,38 @@ const queryClient = new react_query_1.QueryClient();
19
20
  * Main B3Provider component
20
21
  */
21
22
  function B3Provider({ theme = "light", children, accountOverride, environment, clientType = "socket", partnerId, rpcUrls, onConnect, defaultPermissions, }) {
22
- return ((0, jsx_runtime_1.jsx)(react_1.ThirdwebProvider, { children: (0, jsx_runtime_1.jsx)(LocalSDKProvider_1.LocalSDKProvider, { onConnectCallback: onConnect, children: (0, jsx_runtime_1.jsxs)(B3ConfigProvider_1.B3ConfigProvider, { accountOverride: accountOverride, environment: environment, automaticallySetFirstEoa: false, theme: theme, clientType: clientType, partnerId: partnerId, defaultPermissions: defaultPermissions, children: [children, (0, jsx_runtime_1.jsx)(AuthenticationProvider_1.default, { partnerId: partnerId, automaticallySetFirstEoa: false })] }) }) }));
23
+ const setConfig = (0, configStore_1.useB3ConfigStore)(state => state.setConfig);
24
+ // Initialize config store on mount - props are static and never change
25
+ (0, react_1.useEffect)(() => {
26
+ setConfig({
27
+ accountOverride,
28
+ environment: environment ?? "development",
29
+ automaticallySetFirstEoa: false,
30
+ theme,
31
+ clientType,
32
+ partnerId,
33
+ defaultPermissions,
34
+ });
35
+ }, []); // eslint-disable-line react-hooks/exhaustive-deps
36
+ return ((0, jsx_runtime_1.jsx)(react_2.ThirdwebProvider, { children: (0, jsx_runtime_1.jsxs)(LocalSDKProvider_1.LocalSDKProvider, { onConnectCallback: onConnect, children: [children, (0, jsx_runtime_1.jsx)(AuthenticationProvider_1.default, { partnerId: partnerId, automaticallySetFirstEoa: false })] }) }));
23
37
  }
24
38
  /**
25
39
  * Inner provider component for native
26
40
  */
27
41
  function InnerProvider({ children, accountOverride, environment, defaultPermissions, theme = "light", clientType = "socket", partnerId, rpcUrls, }) {
42
+ const setConfig = (0, configStore_1.useB3ConfigStore)(state => state.setConfig);
28
43
  const wagmiConfig = (0, createWagmiConfig_1.createWagmiConfig)({ partnerId, rpcUrls });
29
- 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)(B3ConfigProvider_1.B3ConfigProvider, { accountOverride: accountOverride, environment: environment, automaticallySetFirstEoa: false, theme: theme, clientType: clientType, partnerId: partnerId, defaultPermissions: defaultPermissions, children: children }) }) }));
44
+ // Initialize config store on mount - props are static and never change
45
+ (0, react_1.useEffect)(() => {
46
+ setConfig({
47
+ accountOverride,
48
+ environment: environment ?? "development",
49
+ automaticallySetFirstEoa: false,
50
+ theme,
51
+ clientType,
52
+ partnerId,
53
+ defaultPermissions,
54
+ });
55
+ }, []); // eslint-disable-line react-hooks/exhaustive-deps
56
+ return ((0, jsx_runtime_1.jsx)(wagmi_1.WagmiProvider, { config: wagmiConfig, children: (0, jsx_runtime_1.jsx)(react_query_1.QueryClientProvider, { client: queryClient, children: children }) }));
30
57
  }
@@ -2,4 +2,15 @@
2
2
  * Hook to access the B3 configuration
3
3
  * @deprecated This is just an alias for useB3Config. Use useB3Config directly instead.
4
4
  */
5
- export declare function useB3(): import("./B3ConfigProvider").B3ConfigContextType;
5
+ export declare function useB3(): {
6
+ automaticallySetFirstEoa: boolean;
7
+ environment: "development" | "production";
8
+ theme: "light" | "dark";
9
+ clientType: import("../../../client-manager").ClientType;
10
+ partnerId: string;
11
+ createClientReferenceId: ((params: import("../../../../anyspend/react").CreateOrderParams | import("../../../../anyspend/react").CreateOnrampOrderParams) => Promise<string>) | undefined;
12
+ enableTurnkey: boolean;
13
+ stripePublishableKey: string | undefined;
14
+ defaultPermissions: import("../../../types/permissions").PermissionsConfig;
15
+ accountOverride: import("thirdweb/wallets").Account | undefined;
16
+ };
@@ -1 +1,17 @@
1
- export { useB3Config } from "./B3ConfigProvider";
1
+ /**
2
+ * Hook to access B3 configuration
3
+ * Returns all config values from the Zustand store
4
+ * Since config is static (set once at initialization), destructuring is fine here
5
+ */
6
+ export declare const useB3Config: () => {
7
+ automaticallySetFirstEoa: boolean;
8
+ environment: "development" | "production";
9
+ theme: "light" | "dark";
10
+ clientType: import("../../../client-manager").ClientType;
11
+ partnerId: string;
12
+ createClientReferenceId: ((params: import("../../../../anyspend/react").CreateOrderParams | import("../../../../anyspend/react").CreateOnrampOrderParams) => Promise<string>) | undefined;
13
+ enableTurnkey: boolean;
14
+ stripePublishableKey: string | undefined;
15
+ defaultPermissions: import("../../../types/permissions").PermissionsConfig;
16
+ accountOverride: import("thirdweb/wallets").Account | undefined;
17
+ };
@@ -1,5 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useB3Config = void 0;
4
- var B3ConfigProvider_1 = require("./B3ConfigProvider");
5
- Object.defineProperty(exports, "useB3Config", { enumerable: true, get: function () { return B3ConfigProvider_1.useB3Config; } });
4
+ const configStore_1 = require("../../stores/configStore");
5
+ /**
6
+ * Hook to access B3 configuration
7
+ * Returns all config values from the Zustand store
8
+ * Since config is static (set once at initialization), destructuring is fine here
9
+ */
10
+ const useB3Config = () => {
11
+ return (0, configStore_1.useB3ConfigStore)(state => ({
12
+ automaticallySetFirstEoa: state.automaticallySetFirstEoa,
13
+ environment: state.environment,
14
+ theme: state.theme,
15
+ clientType: state.clientType,
16
+ partnerId: state.partnerId,
17
+ createClientReferenceId: state.createClientReferenceId,
18
+ enableTurnkey: state.enableTurnkey,
19
+ stripePublishableKey: state.stripePublishableKey,
20
+ defaultPermissions: state.defaultPermissions,
21
+ accountOverride: state.accountOverride,
22
+ }));
23
+ };
24
+ exports.useB3Config = useB3Config;
@@ -0,0 +1,24 @@
1
+ import { CreateOnrampOrderParams } from "../../../anyspend/react/hooks/useAnyspendCreateOnrampOrder";
2
+ import { CreateOrderParams } from "../../../anyspend/react/hooks/useAnyspendCreateOrder";
3
+ import { PermissionsConfig } from "../../../global-account/types/permissions";
4
+ import { Account } from "thirdweb/wallets";
5
+ import { ClientType } from "../../client-manager";
6
+ interface ConfigStore {
7
+ accountOverride?: Account;
8
+ automaticallySetFirstEoa: boolean;
9
+ environment: "development" | "production";
10
+ defaultPermissions: PermissionsConfig;
11
+ theme: "light" | "dark";
12
+ clientType: ClientType;
13
+ partnerId: string;
14
+ stripePublishableKey?: string;
15
+ createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
16
+ enableTurnkey: boolean;
17
+ setConfig: (config: Partial<Omit<ConfigStore, "setConfig">>) => void;
18
+ }
19
+ /**
20
+ * Zustand store for B3 configuration
21
+ * NOT persisted - these are developer-set configuration values
22
+ */
23
+ export declare const useB3ConfigStore: import("zustand").UseBoundStore<import("zustand").StoreApi<ConfigStore>>;
24
+ export {};
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useB3ConfigStore = void 0;
4
+ const zustand_1 = require("zustand");
5
+ /**
6
+ * Default permissions configuration for B3 provider
7
+ */
8
+ const DEFAULT_PERMISSIONS = {
9
+ approvedTargets: ["0xa8e42121e318e3D3BeD7f5969AF6D360045317DD"],
10
+ nativeTokenLimitPerTransaction: 0.1,
11
+ startDate: new Date(),
12
+ endDate: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365), // 1 year from now
13
+ };
14
+ /**
15
+ * Zustand store for B3 configuration
16
+ * NOT persisted - these are developer-set configuration values
17
+ */
18
+ exports.useB3ConfigStore = (0, zustand_1.create)(set => ({
19
+ accountOverride: undefined,
20
+ automaticallySetFirstEoa: false,
21
+ environment: "development",
22
+ defaultPermissions: DEFAULT_PERMISSIONS,
23
+ theme: "light",
24
+ clientType: "rest",
25
+ partnerId: "",
26
+ stripePublishableKey: undefined,
27
+ createClientReferenceId: undefined,
28
+ enableTurnkey: false,
29
+ setConfig: config => set(state => ({ ...state, ...config })),
30
+ }));
@@ -1,4 +1,5 @@
1
1
  export { useAuthStore } from "./useAuthStore";
2
+ export { useB3ConfigStore } from "./configStore";
2
3
  export { useModalStore } from "./useModalStore";
3
4
  export { useRecentAddressesStore } from "./useRecentAddressesStore";
4
5
  export type { AnySpendBuySpinProps, AnySpendFundTournamentProps, AnySpendJoinTournamentProps, AnySpendModalProps, AnySpendNftProps, AnySpendOrderHistoryProps, AnySpendStakeB3Props, AnyspendOrderDetailsProps, ManageAccountModalProps, ModalContentType, RequestPermissionsModalProps, SignInWithB3ModalProps, } from "./useModalStore";
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useRecentAddressesStore = exports.useModalStore = exports.useAuthStore = void 0;
3
+ exports.useRecentAddressesStore = exports.useModalStore = exports.useB3ConfigStore = exports.useAuthStore = void 0;
4
4
  var useAuthStore_1 = require("./useAuthStore");
5
5
  Object.defineProperty(exports, "useAuthStore", { enumerable: true, get: function () { return useAuthStore_1.useAuthStore; } });
6
+ var configStore_1 = require("./configStore");
7
+ Object.defineProperty(exports, "useB3ConfigStore", { enumerable: true, get: function () { return configStore_1.useB3ConfigStore; } });
6
8
  var useModalStore_1 = require("./useModalStore");
7
9
  Object.defineProperty(exports, "useModalStore", { enumerable: true, get: function () { return useModalStore_1.useModalStore; } });
8
10
  var useRecentAddressesStore_1 = require("./useRecentAddressesStore");
@@ -8,10 +8,10 @@ import { useEffect, useMemo } from "react";
8
8
  import { ThirdwebProvider } from "thirdweb/react";
9
9
  import { WagmiProvider } from "wagmi";
10
10
  import { setClientType } from "../../../client-manager.js";
11
+ import { useB3ConfigStore } from "../../stores/configStore.js";
11
12
  import { StyleRoot } from "../StyleRoot.js";
12
13
  import { setToastContext, ToastProvider, useToastContext } from "../Toast/index.js";
13
14
  import AuthenticationProvider from "./AuthenticationProvider.js";
14
- import { B3ConfigProvider } from "./B3ConfigProvider.js";
15
15
  import { LocalSDKProvider } from "./LocalSDKProvider.js";
16
16
  // Create queryClient instance
17
17
  const queryClient = new QueryClient();
@@ -21,6 +21,34 @@ const queryClient = new QueryClient();
21
21
  export function B3Provider({ theme = "light", children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey,
22
22
  // deprecated since v0.0.87
23
23
  toaster: _toaster, clientType = "rest", rpcUrls, partnerId, stripePublishableKey, onConnect, connectors, overrideDefaultConnectors = false, createClientReferenceId, enableTurnkey = false, defaultPermissions, }) {
24
+ const setConfig = useB3ConfigStore(state => state.setConfig);
25
+ // Initialize config store on mount
26
+ useEffect(() => {
27
+ setConfig({
28
+ accountOverride,
29
+ environment: environment ?? "development",
30
+ automaticallySetFirstEoa: !!automaticallySetFirstEoa,
31
+ theme,
32
+ clientType,
33
+ partnerId,
34
+ stripePublishableKey,
35
+ createClientReferenceId,
36
+ enableTurnkey,
37
+ defaultPermissions,
38
+ });
39
+ }, [
40
+ accountOverride,
41
+ environment,
42
+ automaticallySetFirstEoa,
43
+ theme,
44
+ clientType,
45
+ partnerId,
46
+ stripePublishableKey,
47
+ createClientReferenceId,
48
+ enableTurnkey,
49
+ defaultPermissions,
50
+ setConfig,
51
+ ]); // eslint-disable-line react-hooks/exhaustive-deps
24
52
  // Initialize Google Analytics on mount
25
53
  useEffect(() => {
26
54
  loadGA4Script();
@@ -30,7 +58,7 @@ toaster: _toaster, clientType = "rest", rpcUrls, partnerId, stripePublishableKey
30
58
  setClientType(clientType);
31
59
  }, [clientType]);
32
60
  const wagmiConfig = useMemo(() => createWagmiConfig({ partnerId, rpcUrls, connectors, overrideDefaultConnectors }), [partnerId, rpcUrls, connectors, overrideDefaultConnectors]);
33
- return (_jsx(ThirdwebProvider, { children: _jsx(WagmiProvider, { config: wagmiConfig, reconnectOnMount: false, children: _jsx(QueryClientProvider, { client: queryClient, children: _jsx(TooltipProvider, { children: _jsx(ToastProvider, { children: _jsx(LocalSDKProvider, { onConnectCallback: onConnect, children: _jsxs(B3ConfigProvider, { accountOverride: accountOverride, environment: environment, automaticallySetFirstEoa: !!automaticallySetFirstEoa, theme: theme, clientType: clientType, partnerId: partnerId, stripePublishableKey: stripePublishableKey, createClientReferenceId: createClientReferenceId, enableTurnkey: enableTurnkey, defaultPermissions: defaultPermissions, children: [_jsx(ToastContextConnector, {}), _jsxs(RelayKitProviderWrapper, { simDuneApiKey: simDuneApiKey, children: [children, _jsx(StyleRoot, { id: "b3-root" })] }), _jsx(AuthenticationProvider, { partnerId: partnerId, automaticallySetFirstEoa: !!automaticallySetFirstEoa })] }) }) }) }) }) }) }));
61
+ return (_jsx(ThirdwebProvider, { children: _jsx(WagmiProvider, { config: wagmiConfig, reconnectOnMount: false, children: _jsx(QueryClientProvider, { client: queryClient, children: _jsx(TooltipProvider, { children: _jsx(ToastProvider, { children: _jsxs(LocalSDKProvider, { onConnectCallback: onConnect, children: [_jsx(ToastContextConnector, {}), _jsxs(RelayKitProviderWrapper, { simDuneApiKey: simDuneApiKey, children: [children, _jsx(StyleRoot, { id: "b3-root" })] }), _jsx(AuthenticationProvider, { partnerId: partnerId, automaticallySetFirstEoa: !!automaticallySetFirstEoa })] }) }) }) }) }) }));
34
62
  }
35
63
  /**
36
64
  * Component to connect the toast context to the global toast API
@@ -1,10 +1,11 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
3
+ import { useEffect } from "react";
3
4
  import { ThirdwebProvider } from "thirdweb/react";
4
5
  import { WagmiProvider } from "wagmi";
6
+ import { useB3ConfigStore } from "../../stores/configStore.js";
5
7
  import { createWagmiConfig } from "../../utils/createWagmiConfig.js";
6
8
  import AuthenticationProvider from "./AuthenticationProvider.js";
7
- import { B3ConfigProvider } from "./B3ConfigProvider.js";
8
9
  import { LocalSDKProvider } from "./LocalSDKProvider.js";
9
10
  // Create queryClient instance
10
11
  const queryClient = new QueryClient();
@@ -12,12 +13,38 @@ const queryClient = new QueryClient();
12
13
  * Main B3Provider component
13
14
  */
14
15
  export function B3Provider({ theme = "light", children, accountOverride, environment, clientType = "socket", partnerId, rpcUrls, onConnect, defaultPermissions, }) {
15
- return (_jsx(ThirdwebProvider, { children: _jsx(LocalSDKProvider, { onConnectCallback: onConnect, children: _jsxs(B3ConfigProvider, { accountOverride: accountOverride, environment: environment, automaticallySetFirstEoa: false, theme: theme, clientType: clientType, partnerId: partnerId, defaultPermissions: defaultPermissions, children: [children, _jsx(AuthenticationProvider, { partnerId: partnerId, automaticallySetFirstEoa: false })] }) }) }));
16
+ const setConfig = useB3ConfigStore(state => state.setConfig);
17
+ // Initialize config store on mount - props are static and never change
18
+ useEffect(() => {
19
+ setConfig({
20
+ accountOverride,
21
+ environment: environment ?? "development",
22
+ automaticallySetFirstEoa: false,
23
+ theme,
24
+ clientType,
25
+ partnerId,
26
+ defaultPermissions,
27
+ });
28
+ }, []); // eslint-disable-line react-hooks/exhaustive-deps
29
+ return (_jsx(ThirdwebProvider, { children: _jsxs(LocalSDKProvider, { onConnectCallback: onConnect, children: [children, _jsx(AuthenticationProvider, { partnerId: partnerId, automaticallySetFirstEoa: false })] }) }));
16
30
  }
17
31
  /**
18
32
  * Inner provider component for native
19
33
  */
20
34
  export function InnerProvider({ children, accountOverride, environment, defaultPermissions, theme = "light", clientType = "socket", partnerId, rpcUrls, }) {
35
+ const setConfig = useB3ConfigStore(state => state.setConfig);
21
36
  const wagmiConfig = createWagmiConfig({ partnerId, rpcUrls });
22
- return (_jsx(WagmiProvider, { config: wagmiConfig, children: _jsx(QueryClientProvider, { client: queryClient, children: _jsx(B3ConfigProvider, { accountOverride: accountOverride, environment: environment, automaticallySetFirstEoa: false, theme: theme, clientType: clientType, partnerId: partnerId, defaultPermissions: defaultPermissions, children: children }) }) }));
37
+ // Initialize config store on mount - props are static and never change
38
+ useEffect(() => {
39
+ setConfig({
40
+ accountOverride,
41
+ environment: environment ?? "development",
42
+ automaticallySetFirstEoa: false,
43
+ theme,
44
+ clientType,
45
+ partnerId,
46
+ defaultPermissions,
47
+ });
48
+ }, []); // eslint-disable-line react-hooks/exhaustive-deps
49
+ return (_jsx(WagmiProvider, { config: wagmiConfig, children: _jsx(QueryClientProvider, { client: queryClient, children: children }) }));
23
50
  }
@@ -2,4 +2,15 @@
2
2
  * Hook to access the B3 configuration
3
3
  * @deprecated This is just an alias for useB3Config. Use useB3Config directly instead.
4
4
  */
5
- export declare function useB3(): import("./B3ConfigProvider").B3ConfigContextType;
5
+ export declare function useB3(): {
6
+ automaticallySetFirstEoa: boolean;
7
+ environment: "development" | "production";
8
+ theme: "light" | "dark";
9
+ clientType: import("../../../client-manager").ClientType;
10
+ partnerId: string;
11
+ createClientReferenceId: ((params: import("../../../../anyspend/react").CreateOrderParams | import("../../../../anyspend/react").CreateOnrampOrderParams) => Promise<string>) | undefined;
12
+ enableTurnkey: boolean;
13
+ stripePublishableKey: string | undefined;
14
+ defaultPermissions: import("../../../types/permissions").PermissionsConfig;
15
+ accountOverride: import("thirdweb/wallets").Account | undefined;
16
+ };
@@ -1 +1,17 @@
1
- export { useB3Config } from "./B3ConfigProvider";
1
+ /**
2
+ * Hook to access B3 configuration
3
+ * Returns all config values from the Zustand store
4
+ * Since config is static (set once at initialization), destructuring is fine here
5
+ */
6
+ export declare const useB3Config: () => {
7
+ automaticallySetFirstEoa: boolean;
8
+ environment: "development" | "production";
9
+ theme: "light" | "dark";
10
+ clientType: import("../../../client-manager").ClientType;
11
+ partnerId: string;
12
+ createClientReferenceId: ((params: import("../../../../anyspend/react").CreateOrderParams | import("../../../../anyspend/react").CreateOnrampOrderParams) => Promise<string>) | undefined;
13
+ enableTurnkey: boolean;
14
+ stripePublishableKey: string | undefined;
15
+ defaultPermissions: import("../../../types/permissions").PermissionsConfig;
16
+ accountOverride: import("thirdweb/wallets").Account | undefined;
17
+ };
@@ -1 +1,20 @@
1
- export { useB3Config } from "./B3ConfigProvider.js";
1
+ import { useB3ConfigStore } from "../../stores/configStore.js";
2
+ /**
3
+ * Hook to access B3 configuration
4
+ * Returns all config values from the Zustand store
5
+ * Since config is static (set once at initialization), destructuring is fine here
6
+ */
7
+ export const useB3Config = () => {
8
+ return useB3ConfigStore(state => ({
9
+ automaticallySetFirstEoa: state.automaticallySetFirstEoa,
10
+ environment: state.environment,
11
+ theme: state.theme,
12
+ clientType: state.clientType,
13
+ partnerId: state.partnerId,
14
+ createClientReferenceId: state.createClientReferenceId,
15
+ enableTurnkey: state.enableTurnkey,
16
+ stripePublishableKey: state.stripePublishableKey,
17
+ defaultPermissions: state.defaultPermissions,
18
+ accountOverride: state.accountOverride,
19
+ }));
20
+ };
@@ -0,0 +1,24 @@
1
+ import { CreateOnrampOrderParams } from "../../../anyspend/react/hooks/useAnyspendCreateOnrampOrder";
2
+ import { CreateOrderParams } from "../../../anyspend/react/hooks/useAnyspendCreateOrder";
3
+ import { PermissionsConfig } from "../../../global-account/types/permissions";
4
+ import { Account } from "thirdweb/wallets";
5
+ import { ClientType } from "../../client-manager";
6
+ interface ConfigStore {
7
+ accountOverride?: Account;
8
+ automaticallySetFirstEoa: boolean;
9
+ environment: "development" | "production";
10
+ defaultPermissions: PermissionsConfig;
11
+ theme: "light" | "dark";
12
+ clientType: ClientType;
13
+ partnerId: string;
14
+ stripePublishableKey?: string;
15
+ createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
16
+ enableTurnkey: boolean;
17
+ setConfig: (config: Partial<Omit<ConfigStore, "setConfig">>) => void;
18
+ }
19
+ /**
20
+ * Zustand store for B3 configuration
21
+ * NOT persisted - these are developer-set configuration values
22
+ */
23
+ export declare const useB3ConfigStore: import("zustand").UseBoundStore<import("zustand").StoreApi<ConfigStore>>;
24
+ export {};
@@ -0,0 +1,27 @@
1
+ import { create } from "zustand";
2
+ /**
3
+ * Default permissions configuration for B3 provider
4
+ */
5
+ const DEFAULT_PERMISSIONS = {
6
+ approvedTargets: ["0xa8e42121e318e3D3BeD7f5969AF6D360045317DD"],
7
+ nativeTokenLimitPerTransaction: 0.1,
8
+ startDate: new Date(),
9
+ endDate: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365), // 1 year from now
10
+ };
11
+ /**
12
+ * Zustand store for B3 configuration
13
+ * NOT persisted - these are developer-set configuration values
14
+ */
15
+ export const useB3ConfigStore = create(set => ({
16
+ accountOverride: undefined,
17
+ automaticallySetFirstEoa: false,
18
+ environment: "development",
19
+ defaultPermissions: DEFAULT_PERMISSIONS,
20
+ theme: "light",
21
+ clientType: "rest",
22
+ partnerId: "",
23
+ stripePublishableKey: undefined,
24
+ createClientReferenceId: undefined,
25
+ enableTurnkey: false,
26
+ setConfig: config => set(state => ({ ...state, ...config })),
27
+ }));
@@ -1,4 +1,5 @@
1
1
  export { useAuthStore } from "./useAuthStore";
2
+ export { useB3ConfigStore } from "./configStore";
2
3
  export { useModalStore } from "./useModalStore";
3
4
  export { useRecentAddressesStore } from "./useRecentAddressesStore";
4
5
  export type { AnySpendBuySpinProps, AnySpendFundTournamentProps, AnySpendJoinTournamentProps, AnySpendModalProps, AnySpendNftProps, AnySpendOrderHistoryProps, AnySpendStakeB3Props, AnyspendOrderDetailsProps, ManageAccountModalProps, ModalContentType, RequestPermissionsModalProps, SignInWithB3ModalProps, } from "./useModalStore";
@@ -1,3 +1,4 @@
1
1
  export { useAuthStore } from "./useAuthStore.js";
2
+ export { useB3ConfigStore } from "./configStore.js";
2
3
  export { useModalStore } from "./useModalStore.js";
3
4
  export { useRecentAddressesStore } from "./useRecentAddressesStore.js";
@@ -2,4 +2,15 @@
2
2
  * Hook to access the B3 configuration
3
3
  * @deprecated This is just an alias for useB3Config. Use useB3Config directly instead.
4
4
  */
5
- export declare function useB3(): import("./B3ConfigProvider").B3ConfigContextType;
5
+ export declare function useB3(): {
6
+ automaticallySetFirstEoa: boolean;
7
+ environment: "development" | "production";
8
+ theme: "light" | "dark";
9
+ clientType: import("../../../client-manager").ClientType;
10
+ partnerId: string;
11
+ createClientReferenceId: ((params: import("../../../../anyspend/react").CreateOrderParams | import("../../../../anyspend/react").CreateOnrampOrderParams) => Promise<string>) | undefined;
12
+ enableTurnkey: boolean;
13
+ stripePublishableKey: string | undefined;
14
+ defaultPermissions: import("../../../types/permissions").PermissionsConfig;
15
+ accountOverride: import("thirdweb/wallets").Account | undefined;
16
+ };
@@ -1 +1,17 @@
1
- export { useB3Config } from "./B3ConfigProvider";
1
+ /**
2
+ * Hook to access B3 configuration
3
+ * Returns all config values from the Zustand store
4
+ * Since config is static (set once at initialization), destructuring is fine here
5
+ */
6
+ export declare const useB3Config: () => {
7
+ automaticallySetFirstEoa: boolean;
8
+ environment: "development" | "production";
9
+ theme: "light" | "dark";
10
+ clientType: import("../../../client-manager").ClientType;
11
+ partnerId: string;
12
+ createClientReferenceId: ((params: import("../../../../anyspend/react").CreateOrderParams | import("../../../../anyspend/react").CreateOnrampOrderParams) => Promise<string>) | undefined;
13
+ enableTurnkey: boolean;
14
+ stripePublishableKey: string | undefined;
15
+ defaultPermissions: import("../../../types/permissions").PermissionsConfig;
16
+ accountOverride: import("thirdweb/wallets").Account | undefined;
17
+ };
@@ -0,0 +1,24 @@
1
+ import { CreateOnrampOrderParams } from "@b3dotfun/sdk/anyspend/react/hooks/useAnyspendCreateOnrampOrder";
2
+ import { CreateOrderParams } from "@b3dotfun/sdk/anyspend/react/hooks/useAnyspendCreateOrder";
3
+ import { PermissionsConfig } from "@b3dotfun/sdk/global-account/types/permissions";
4
+ import { Account } from "thirdweb/wallets";
5
+ import { ClientType } from "../../client-manager";
6
+ interface ConfigStore {
7
+ accountOverride?: Account;
8
+ automaticallySetFirstEoa: boolean;
9
+ environment: "development" | "production";
10
+ defaultPermissions: PermissionsConfig;
11
+ theme: "light" | "dark";
12
+ clientType: ClientType;
13
+ partnerId: string;
14
+ stripePublishableKey?: string;
15
+ createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
16
+ enableTurnkey: boolean;
17
+ setConfig: (config: Partial<Omit<ConfigStore, "setConfig">>) => void;
18
+ }
19
+ /**
20
+ * Zustand store for B3 configuration
21
+ * NOT persisted - these are developer-set configuration values
22
+ */
23
+ export declare const useB3ConfigStore: import("zustand").UseBoundStore<import("zustand").StoreApi<ConfigStore>>;
24
+ export {};
@@ -1,4 +1,5 @@
1
1
  export { useAuthStore } from "./useAuthStore";
2
+ export { useB3ConfigStore } from "./configStore";
2
3
  export { useModalStore } from "./useModalStore";
3
4
  export { useRecentAddressesStore } from "./useRecentAddressesStore";
4
5
  export type { AnySpendBuySpinProps, AnySpendFundTournamentProps, AnySpendJoinTournamentProps, AnySpendModalProps, AnySpendNftProps, AnySpendOrderHistoryProps, AnySpendStakeB3Props, AnyspendOrderDetailsProps, ManageAccountModalProps, ModalContentType, RequestPermissionsModalProps, SignInWithB3ModalProps, } from "./useModalStore";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@b3dotfun/sdk",
3
- "version": "0.1.0-alpha.1",
3
+ "version": "0.1.0",
4
4
  "source": "src/index.ts",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "react-native": "./dist/cjs/index.native.js",
@@ -1,14 +1,15 @@
1
1
  import { PermissionsConfig } from "@b3dotfun/sdk/global-account/types/permissions";
2
2
  import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
3
+ import { useEffect } from "react";
3
4
  import { ThirdwebProvider } from "thirdweb/react";
4
5
  import { Account, Wallet } from "thirdweb/wallets";
5
6
 
6
7
  import { ClientType } from "../../../client-manager";
7
8
 
8
9
  import { WagmiProvider } from "wagmi";
10
+ import { useB3ConfigStore } from "../../stores/configStore";
9
11
  import { createWagmiConfig } from "../../utils/createWagmiConfig";
10
12
  import AuthenticationProvider from "./AuthenticationProvider";
11
- import { B3ConfigProvider } from "./B3ConfigProvider";
12
13
  import { LocalSDKProvider } from "./LocalSDKProvider";
13
14
 
14
15
  // Create queryClient instance
@@ -38,23 +39,28 @@ export function B3Provider({
38
39
  onConnect?: (wallet: Wallet, b3Jwt: string) => void | Promise<void>;
39
40
  defaultPermissions?: PermissionsConfig;
40
41
  }) {
42
+ const setConfig = useB3ConfigStore(state => state.setConfig);
43
+
44
+ // Initialize config store on mount - props are static and never change
45
+ useEffect(() => {
46
+ setConfig({
47
+ accountOverride,
48
+ environment: environment ?? "development",
49
+ automaticallySetFirstEoa: false,
50
+ theme,
51
+ clientType,
52
+ partnerId,
53
+ defaultPermissions,
54
+ });
55
+ }, []); // eslint-disable-line react-hooks/exhaustive-deps
56
+
41
57
  return (
42
58
  <ThirdwebProvider>
43
59
  <LocalSDKProvider onConnectCallback={onConnect}>
44
- <B3ConfigProvider
45
- accountOverride={accountOverride}
46
- environment={environment}
47
- automaticallySetFirstEoa={false}
48
- theme={theme}
49
- clientType={clientType}
50
- partnerId={partnerId}
51
- defaultPermissions={defaultPermissions}
52
- >
53
- {/* <RelayKitProviderWrapper> */}
54
- {children}
55
- <AuthenticationProvider partnerId={partnerId} automaticallySetFirstEoa={false} />
56
- {/* </RelayKitProviderWrapper> */}
57
- </B3ConfigProvider>
60
+ {/* <RelayKitProviderWrapper> */}
61
+ {children}
62
+ <AuthenticationProvider partnerId={partnerId} automaticallySetFirstEoa={false} />
63
+ {/* </RelayKitProviderWrapper> */}
58
64
  </LocalSDKProvider>
59
65
  </ThirdwebProvider>
60
66
  );
@@ -82,23 +88,25 @@ export function InnerProvider({
82
88
  partnerId: string;
83
89
  rpcUrls?: Record<number, string>;
84
90
  }) {
91
+ const setConfig = useB3ConfigStore(state => state.setConfig);
85
92
  const wagmiConfig = createWagmiConfig({ partnerId, rpcUrls });
86
93
 
94
+ // Initialize config store on mount - props are static and never change
95
+ useEffect(() => {
96
+ setConfig({
97
+ accountOverride,
98
+ environment: environment ?? "development",
99
+ automaticallySetFirstEoa: false,
100
+ theme,
101
+ clientType,
102
+ partnerId,
103
+ defaultPermissions,
104
+ });
105
+ }, []); // eslint-disable-line react-hooks/exhaustive-deps
106
+
87
107
  return (
88
108
  <WagmiProvider config={wagmiConfig}>
89
- <QueryClientProvider client={queryClient}>
90
- <B3ConfigProvider
91
- accountOverride={accountOverride}
92
- environment={environment}
93
- automaticallySetFirstEoa={false}
94
- theme={theme}
95
- clientType={clientType}
96
- partnerId={partnerId}
97
- defaultPermissions={defaultPermissions}
98
- >
99
- {children}
100
- </B3ConfigProvider>
101
- </QueryClientProvider>
109
+ <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
102
110
  </WagmiProvider>
103
111
  );
104
112
  }
@@ -11,10 +11,10 @@ import { ThirdwebProvider } from "thirdweb/react";
11
11
  import { Account, Wallet } from "thirdweb/wallets";
12
12
  import { CreateConnectorFn, WagmiProvider } from "wagmi";
13
13
  import { ClientType, setClientType } from "../../../client-manager";
14
+ import { useB3ConfigStore } from "../../stores/configStore";
14
15
  import { StyleRoot } from "../StyleRoot";
15
16
  import { setToastContext, ToastProvider, useToastContext } from "../Toast/index";
16
17
  import AuthenticationProvider from "./AuthenticationProvider";
17
- import { B3ConfigProvider } from "./B3ConfigProvider";
18
18
  import { LocalSDKProvider } from "./LocalSDKProvider";
19
19
 
20
20
  // Create queryClient instance
@@ -65,6 +65,36 @@ export function B3Provider({
65
65
  enableTurnkey?: boolean;
66
66
  defaultPermissions?: PermissionsConfig;
67
67
  }) {
68
+ const setConfig = useB3ConfigStore(state => state.setConfig);
69
+
70
+ // Initialize config store on mount
71
+ useEffect(() => {
72
+ setConfig({
73
+ accountOverride,
74
+ environment: environment ?? "development",
75
+ automaticallySetFirstEoa: !!automaticallySetFirstEoa,
76
+ theme,
77
+ clientType,
78
+ partnerId,
79
+ stripePublishableKey,
80
+ createClientReferenceId,
81
+ enableTurnkey,
82
+ defaultPermissions,
83
+ });
84
+ }, [
85
+ accountOverride,
86
+ environment,
87
+ automaticallySetFirstEoa,
88
+ theme,
89
+ clientType,
90
+ partnerId,
91
+ stripePublishableKey,
92
+ createClientReferenceId,
93
+ enableTurnkey,
94
+ defaultPermissions,
95
+ setConfig,
96
+ ]); // eslint-disable-line react-hooks/exhaustive-deps
97
+
68
98
  // Initialize Google Analytics on mount
69
99
  useEffect(() => {
70
100
  loadGA4Script();
@@ -87,26 +117,13 @@ export function B3Provider({
87
117
  <TooltipProvider>
88
118
  <ToastProvider>
89
119
  <LocalSDKProvider onConnectCallback={onConnect}>
90
- <B3ConfigProvider
91
- accountOverride={accountOverride}
92
- environment={environment}
93
- automaticallySetFirstEoa={!!automaticallySetFirstEoa}
94
- theme={theme}
95
- clientType={clientType}
96
- partnerId={partnerId}
97
- stripePublishableKey={stripePublishableKey}
98
- createClientReferenceId={createClientReferenceId}
99
- enableTurnkey={enableTurnkey}
100
- defaultPermissions={defaultPermissions}
101
- >
102
- <ToastContextConnector />
103
- <RelayKitProviderWrapper simDuneApiKey={simDuneApiKey}>
104
- {children}
105
- {/* For the modal https://github.com/b3-fun/b3/blob/main/packages/sdk/src/global-account/react/components/ui/dialog.tsx#L46 */}
106
- <StyleRoot id="b3-root" />
107
- </RelayKitProviderWrapper>
108
- <AuthenticationProvider partnerId={partnerId} automaticallySetFirstEoa={!!automaticallySetFirstEoa} />
109
- </B3ConfigProvider>
120
+ <ToastContextConnector />
121
+ <RelayKitProviderWrapper simDuneApiKey={simDuneApiKey}>
122
+ {children}
123
+ {/* For the modal https://github.com/b3-fun/b3/blob/main/packages/sdk/src/global-account/react/components/ui/dialog.tsx#L46 */}
124
+ <StyleRoot id="b3-root" />
125
+ </RelayKitProviderWrapper>
126
+ <AuthenticationProvider partnerId={partnerId} automaticallySetFirstEoa={!!automaticallySetFirstEoa} />
110
127
  </LocalSDKProvider>
111
128
  </ToastProvider>
112
129
  </TooltipProvider>
@@ -1 +1,21 @@
1
- export { useB3Config } from "./B3ConfigProvider";
1
+ import { useB3ConfigStore } from "../../stores/configStore";
2
+
3
+ /**
4
+ * Hook to access B3 configuration
5
+ * Returns all config values from the Zustand store
6
+ * Since config is static (set once at initialization), destructuring is fine here
7
+ */
8
+ export const useB3Config = () => {
9
+ return useB3ConfigStore(state => ({
10
+ automaticallySetFirstEoa: state.automaticallySetFirstEoa,
11
+ environment: state.environment,
12
+ theme: state.theme,
13
+ clientType: state.clientType,
14
+ partnerId: state.partnerId,
15
+ createClientReferenceId: state.createClientReferenceId,
16
+ enableTurnkey: state.enableTurnkey,
17
+ stripePublishableKey: state.stripePublishableKey,
18
+ defaultPermissions: state.defaultPermissions,
19
+ accountOverride: state.accountOverride,
20
+ }));
21
+ };
@@ -0,0 +1,51 @@
1
+ import { CreateOnrampOrderParams } from "@b3dotfun/sdk/anyspend/react/hooks/useAnyspendCreateOnrampOrder";
2
+ import { CreateOrderParams } from "@b3dotfun/sdk/anyspend/react/hooks/useAnyspendCreateOrder";
3
+ import { PermissionsConfig } from "@b3dotfun/sdk/global-account/types/permissions";
4
+ import { Account } from "thirdweb/wallets";
5
+ import { create } from "zustand";
6
+ import { ClientType } from "../../client-manager";
7
+
8
+ /**
9
+ * Default permissions configuration for B3 provider
10
+ */
11
+ const DEFAULT_PERMISSIONS: PermissionsConfig = {
12
+ approvedTargets: ["0xa8e42121e318e3D3BeD7f5969AF6D360045317DD"],
13
+ nativeTokenLimitPerTransaction: 0.1,
14
+ startDate: new Date(),
15
+ endDate: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365), // 1 year from now
16
+ };
17
+
18
+ interface ConfigStore {
19
+ accountOverride?: Account;
20
+ automaticallySetFirstEoa: boolean;
21
+ environment: "development" | "production";
22
+ defaultPermissions: PermissionsConfig;
23
+ theme: "light" | "dark";
24
+ clientType: ClientType;
25
+ partnerId: string;
26
+ stripePublishableKey?: string;
27
+ createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
28
+ enableTurnkey: boolean;
29
+
30
+ // Actions
31
+ setConfig: (config: Partial<Omit<ConfigStore, "setConfig">>) => void;
32
+ }
33
+
34
+ /**
35
+ * Zustand store for B3 configuration
36
+ * NOT persisted - these are developer-set configuration values
37
+ */
38
+ export const useB3ConfigStore = create<ConfigStore>(set => ({
39
+ accountOverride: undefined,
40
+ automaticallySetFirstEoa: false,
41
+ environment: "development",
42
+ defaultPermissions: DEFAULT_PERMISSIONS,
43
+ theme: "light",
44
+ clientType: "rest",
45
+ partnerId: "",
46
+ stripePublishableKey: undefined,
47
+ createClientReferenceId: undefined,
48
+ enableTurnkey: false,
49
+
50
+ setConfig: config => set(state => ({ ...state, ...config })),
51
+ }));
@@ -1,4 +1,5 @@
1
1
  export { useAuthStore } from "./useAuthStore";
2
+ export { useB3ConfigStore } from "./configStore";
2
3
  export { useModalStore } from "./useModalStore";
3
4
  export { useRecentAddressesStore } from "./useRecentAddressesStore";
4
5
 
@@ -1,31 +0,0 @@
1
- import { CreateOnrampOrderParams } from "../../../../anyspend/react/hooks/useAnyspendCreateOnrampOrder";
2
- import { CreateOrderParams } from "../../../../anyspend/react/hooks/useAnyspendCreateOrder";
3
- import { PermissionsConfig } from "../../../../global-account/types/permissions";
4
- import { Account } from "thirdweb/wallets";
5
- import { ClientType } from "../../../client-manager";
6
- export interface B3ConfigContextType {
7
- accountOverride?: Account;
8
- automaticallySetFirstEoa: boolean;
9
- environment: "development" | "production";
10
- defaultPermissions: PermissionsConfig;
11
- theme: "light" | "dark";
12
- clientType: ClientType;
13
- partnerId: string;
14
- stripePublishableKey?: string;
15
- createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
16
- enableTurnkey: boolean;
17
- }
18
- export declare function B3ConfigProvider({ children, accountOverride, environment, defaultPermissions, automaticallySetFirstEoa, theme, clientType, partnerId, stripePublishableKey, createClientReferenceId, enableTurnkey, }: {
19
- children: React.ReactNode;
20
- accountOverride?: Account;
21
- environment?: "development" | "production";
22
- defaultPermissions?: PermissionsConfig;
23
- automaticallySetFirstEoa?: boolean;
24
- theme?: "light" | "dark";
25
- clientType?: ClientType;
26
- partnerId: string;
27
- stripePublishableKey?: string;
28
- createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
29
- enableTurnkey?: boolean;
30
- }): import("react/jsx-runtime").JSX.Element;
31
- export declare function useB3Config(): B3ConfigContextType;
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.B3ConfigProvider = B3ConfigProvider;
4
- exports.useB3Config = useB3Config;
5
- const jsx_runtime_1 = require("react/jsx-runtime");
6
- const react_1 = require("react");
7
- /**
8
- * Default permissions configuration for B3 provider
9
- */
10
- const DEFAULT_PERMISSIONS = {
11
- approvedTargets: ["0xa8e42121e318e3D3BeD7f5969AF6D360045317DD"],
12
- nativeTokenLimitPerTransaction: 0.1,
13
- startDate: new Date(),
14
- endDate: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365), // 1 year from now
15
- };
16
- const B3ConfigContext = (0, react_1.createContext)(null);
17
- function B3ConfigProvider({ children, accountOverride, environment = "development", defaultPermissions = DEFAULT_PERMISSIONS, automaticallySetFirstEoa = false, theme = "light", clientType = "rest", partnerId, stripePublishableKey, createClientReferenceId, enableTurnkey = false, }) {
18
- return ((0, jsx_runtime_1.jsx)(B3ConfigContext.Provider, { value: {
19
- accountOverride,
20
- environment,
21
- defaultPermissions,
22
- automaticallySetFirstEoa,
23
- theme,
24
- clientType,
25
- partnerId,
26
- stripePublishableKey,
27
- createClientReferenceId,
28
- enableTurnkey,
29
- }, children: children }));
30
- }
31
- function useB3Config() {
32
- const context = (0, react_1.useContext)(B3ConfigContext);
33
- if (!context) {
34
- throw new Error("useB3Config must be used within a B3ConfigProvider");
35
- }
36
- return context;
37
- }
@@ -1,31 +0,0 @@
1
- import { CreateOnrampOrderParams } from "../../../../anyspend/react/hooks/useAnyspendCreateOnrampOrder";
2
- import { CreateOrderParams } from "../../../../anyspend/react/hooks/useAnyspendCreateOrder";
3
- import { PermissionsConfig } from "../../../../global-account/types/permissions";
4
- import { Account } from "thirdweb/wallets";
5
- import { ClientType } from "../../../client-manager";
6
- export interface B3ConfigContextType {
7
- accountOverride?: Account;
8
- automaticallySetFirstEoa: boolean;
9
- environment: "development" | "production";
10
- defaultPermissions: PermissionsConfig;
11
- theme: "light" | "dark";
12
- clientType: ClientType;
13
- partnerId: string;
14
- stripePublishableKey?: string;
15
- createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
16
- enableTurnkey: boolean;
17
- }
18
- export declare function B3ConfigProvider({ children, accountOverride, environment, defaultPermissions, automaticallySetFirstEoa, theme, clientType, partnerId, stripePublishableKey, createClientReferenceId, enableTurnkey, }: {
19
- children: React.ReactNode;
20
- accountOverride?: Account;
21
- environment?: "development" | "production";
22
- defaultPermissions?: PermissionsConfig;
23
- automaticallySetFirstEoa?: boolean;
24
- theme?: "light" | "dark";
25
- clientType?: ClientType;
26
- partnerId: string;
27
- stripePublishableKey?: string;
28
- createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
29
- enableTurnkey?: boolean;
30
- }): import("react/jsx-runtime").JSX.Element;
31
- export declare function useB3Config(): B3ConfigContextType;
@@ -1,33 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { createContext, useContext } from "react";
3
- /**
4
- * Default permissions configuration for B3 provider
5
- */
6
- const DEFAULT_PERMISSIONS = {
7
- approvedTargets: ["0xa8e42121e318e3D3BeD7f5969AF6D360045317DD"],
8
- nativeTokenLimitPerTransaction: 0.1,
9
- startDate: new Date(),
10
- endDate: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365), // 1 year from now
11
- };
12
- const B3ConfigContext = createContext(null);
13
- export function B3ConfigProvider({ children, accountOverride, environment = "development", defaultPermissions = DEFAULT_PERMISSIONS, automaticallySetFirstEoa = false, theme = "light", clientType = "rest", partnerId, stripePublishableKey, createClientReferenceId, enableTurnkey = false, }) {
14
- return (_jsx(B3ConfigContext.Provider, { value: {
15
- accountOverride,
16
- environment,
17
- defaultPermissions,
18
- automaticallySetFirstEoa,
19
- theme,
20
- clientType,
21
- partnerId,
22
- stripePublishableKey,
23
- createClientReferenceId,
24
- enableTurnkey,
25
- }, children: children }));
26
- }
27
- export function useB3Config() {
28
- const context = useContext(B3ConfigContext);
29
- if (!context) {
30
- throw new Error("useB3Config must be used within a B3ConfigProvider");
31
- }
32
- return context;
33
- }
@@ -1,31 +0,0 @@
1
- import { CreateOnrampOrderParams } from "@b3dotfun/sdk/anyspend/react/hooks/useAnyspendCreateOnrampOrder";
2
- import { CreateOrderParams } from "@b3dotfun/sdk/anyspend/react/hooks/useAnyspendCreateOrder";
3
- import { PermissionsConfig } from "@b3dotfun/sdk/global-account/types/permissions";
4
- import { Account } from "thirdweb/wallets";
5
- import { ClientType } from "../../../client-manager";
6
- export interface B3ConfigContextType {
7
- accountOverride?: Account;
8
- automaticallySetFirstEoa: boolean;
9
- environment: "development" | "production";
10
- defaultPermissions: PermissionsConfig;
11
- theme: "light" | "dark";
12
- clientType: ClientType;
13
- partnerId: string;
14
- stripePublishableKey?: string;
15
- createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
16
- enableTurnkey: boolean;
17
- }
18
- export declare function B3ConfigProvider({ children, accountOverride, environment, defaultPermissions, automaticallySetFirstEoa, theme, clientType, partnerId, stripePublishableKey, createClientReferenceId, enableTurnkey, }: {
19
- children: React.ReactNode;
20
- accountOverride?: Account;
21
- environment?: "development" | "production";
22
- defaultPermissions?: PermissionsConfig;
23
- automaticallySetFirstEoa?: boolean;
24
- theme?: "light" | "dark";
25
- clientType?: ClientType;
26
- partnerId: string;
27
- stripePublishableKey?: string;
28
- createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
29
- enableTurnkey?: boolean;
30
- }): import("react/jsx-runtime").JSX.Element;
31
- export declare function useB3Config(): B3ConfigContextType;
@@ -1,84 +0,0 @@
1
- import { CreateOnrampOrderParams } from "@b3dotfun/sdk/anyspend/react/hooks/useAnyspendCreateOnrampOrder";
2
- import { CreateOrderParams } from "@b3dotfun/sdk/anyspend/react/hooks/useAnyspendCreateOrder";
3
- import { PermissionsConfig } from "@b3dotfun/sdk/global-account/types/permissions";
4
- import { createContext, useContext } from "react";
5
- import { Account } from "thirdweb/wallets";
6
- import { ClientType } from "../../../client-manager";
7
-
8
- /**
9
- * Default permissions configuration for B3 provider
10
- */
11
- const DEFAULT_PERMISSIONS: PermissionsConfig = {
12
- approvedTargets: ["0xa8e42121e318e3D3BeD7f5969AF6D360045317DD"],
13
- nativeTokenLimitPerTransaction: 0.1,
14
- startDate: new Date(),
15
- endDate: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365), // 1 year from now
16
- };
17
-
18
- export interface B3ConfigContextType {
19
- accountOverride?: Account;
20
- automaticallySetFirstEoa: boolean;
21
- environment: "development" | "production";
22
- defaultPermissions: PermissionsConfig;
23
- theme: "light" | "dark";
24
- clientType: ClientType;
25
- partnerId: string;
26
- stripePublishableKey?: string;
27
- createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
28
- enableTurnkey: boolean;
29
- }
30
-
31
- const B3ConfigContext = createContext<B3ConfigContextType | null>(null);
32
-
33
- export function B3ConfigProvider({
34
- children,
35
- accountOverride,
36
- environment = "development",
37
- defaultPermissions = DEFAULT_PERMISSIONS,
38
- automaticallySetFirstEoa = false,
39
- theme = "light",
40
- clientType = "rest",
41
- partnerId,
42
- stripePublishableKey,
43
- createClientReferenceId,
44
- enableTurnkey = false,
45
- }: {
46
- children: React.ReactNode;
47
- accountOverride?: Account;
48
- environment?: "development" | "production";
49
- defaultPermissions?: PermissionsConfig;
50
- automaticallySetFirstEoa?: boolean;
51
- theme?: "light" | "dark";
52
- clientType?: ClientType;
53
- partnerId: string;
54
- stripePublishableKey?: string;
55
- createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
56
- enableTurnkey?: boolean;
57
- }) {
58
- return (
59
- <B3ConfigContext.Provider
60
- value={{
61
- accountOverride,
62
- environment,
63
- defaultPermissions,
64
- automaticallySetFirstEoa,
65
- theme,
66
- clientType,
67
- partnerId,
68
- stripePublishableKey,
69
- createClientReferenceId,
70
- enableTurnkey,
71
- }}
72
- >
73
- {children}
74
- </B3ConfigContext.Provider>
75
- );
76
- }
77
-
78
- export function useB3Config(): B3ConfigContextType {
79
- const context = useContext(B3ConfigContext);
80
- if (!context) {
81
- throw new Error("useB3Config must be used within a B3ConfigProvider");
82
- }
83
- return context;
84
- }