@b3dotfun/sdk 0.1.0-alpha.0 → 0.1.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/global-account/react/components/B3Provider/B3ConfigProvider.d.ts +31 -0
- package/dist/cjs/global-account/react/components/B3Provider/B3ConfigProvider.js +37 -0
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +2 -30
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.js +4 -31
- package/dist/cjs/global-account/react/components/B3Provider/useB3.d.ts +1 -12
- package/dist/cjs/global-account/react/components/B3Provider/useB3Config.d.ts +1 -17
- package/dist/cjs/global-account/react/components/B3Provider/useB3Config.js +2 -21
- package/dist/cjs/global-account/react/stores/index.d.ts +0 -1
- package/dist/cjs/global-account/react/stores/index.js +1 -3
- package/dist/esm/global-account/react/components/B3Provider/B3ConfigProvider.d.ts +31 -0
- package/dist/esm/global-account/react/components/B3Provider/B3ConfigProvider.js +33 -0
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +2 -30
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.js +3 -30
- package/dist/esm/global-account/react/components/B3Provider/useB3.d.ts +1 -12
- package/dist/esm/global-account/react/components/B3Provider/useB3Config.d.ts +1 -17
- package/dist/esm/global-account/react/components/B3Provider/useB3Config.js +1 -20
- package/dist/esm/global-account/react/stores/index.d.ts +0 -1
- package/dist/esm/global-account/react/stores/index.js +0 -1
- package/dist/types/global-account/react/components/B3Provider/B3ConfigProvider.d.ts +31 -0
- package/dist/types/global-account/react/components/B3Provider/useB3.d.ts +1 -12
- package/dist/types/global-account/react/components/B3Provider/useB3Config.d.ts +1 -17
- package/dist/types/global-account/react/stores/index.d.ts +0 -1
- package/package.json +1 -1
- package/src/global-account/react/components/B3Provider/B3ConfigProvider.tsx +84 -0
- package/src/global-account/react/components/B3Provider/B3Provider.native.tsx +28 -36
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +21 -38
- package/src/global-account/react/components/B3Provider/useB3Config.ts +1 -21
- package/src/global-account/react/stores/index.ts +0 -1
- package/dist/cjs/global-account/react/stores/configStore.d.ts +0 -24
- package/dist/cjs/global-account/react/stores/configStore.js +0 -30
- package/dist/esm/global-account/react/stores/configStore.d.ts +0 -24
- package/dist/esm/global-account/react/stores/configStore.js +0 -27
- package/dist/types/global-account/react/stores/configStore.d.ts +0 -24
- package/src/global-account/react/stores/configStore.ts +0 -51
|
@@ -0,0 +1,31 @@
|
|
|
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;
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
}
|
|
@@ -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");
|
|
18
17
|
const StyleRoot_1 = require("../StyleRoot");
|
|
19
18
|
const index_1 = require("../Toast/index");
|
|
20
19
|
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,34 +27,6 @@ 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
|
|
58
30
|
// Initialize Google Analytics on mount
|
|
59
31
|
(0, react_2.useEffect)(() => {
|
|
60
32
|
(0, analytics_1.loadGA4Script)();
|
|
@@ -64,7 +36,7 @@ toaster: _toaster, clientType = "rest", rpcUrls, partnerId, stripePublishableKey
|
|
|
64
36
|
(0, client_manager_1.setClientType)(clientType);
|
|
65
37
|
}, [clientType]);
|
|
66
38
|
const wagmiConfig = (0, react_2.useMemo)(() => (0, createWagmiConfig_1.createWagmiConfig)({ partnerId, rpcUrls, connectors, overrideDefaultConnectors }), [partnerId, rpcUrls, connectors, overrideDefaultConnectors]);
|
|
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.
|
|
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 })] }) }) }) }) }) }) }));
|
|
68
40
|
}
|
|
69
41
|
/**
|
|
70
42
|
* Component to connect the toast context to the global toast API
|
|
@@ -7,12 +7,11 @@ 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("react");
|
|
11
|
-
const react_2 = require("thirdweb/react");
|
|
10
|
+
const react_1 = require("thirdweb/react");
|
|
12
11
|
const wagmi_1 = require("wagmi");
|
|
13
|
-
const configStore_1 = require("../../stores/configStore");
|
|
14
12
|
const createWagmiConfig_1 = require("../../utils/createWagmiConfig");
|
|
15
13
|
const AuthenticationProvider_1 = __importDefault(require("./AuthenticationProvider"));
|
|
14
|
+
const B3ConfigProvider_1 = require("./B3ConfigProvider");
|
|
16
15
|
const LocalSDKProvider_1 = require("./LocalSDKProvider");
|
|
17
16
|
// Create queryClient instance
|
|
18
17
|
const queryClient = new react_query_1.QueryClient();
|
|
@@ -20,38 +19,12 @@ const queryClient = new react_query_1.QueryClient();
|
|
|
20
19
|
* Main B3Provider component
|
|
21
20
|
*/
|
|
22
21
|
function B3Provider({ theme = "light", children, accountOverride, environment, clientType = "socket", partnerId, rpcUrls, onConnect, defaultPermissions, }) {
|
|
23
|
-
|
|
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 })] }) }));
|
|
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 })] }) }) }));
|
|
37
23
|
}
|
|
38
24
|
/**
|
|
39
25
|
* Inner provider component for native
|
|
40
26
|
*/
|
|
41
27
|
function InnerProvider({ children, accountOverride, environment, defaultPermissions, theme = "light", clientType = "socket", partnerId, rpcUrls, }) {
|
|
42
|
-
const setConfig = (0, configStore_1.useB3ConfigStore)(state => state.setConfig);
|
|
43
28
|
const wagmiConfig = (0, createWagmiConfig_1.createWagmiConfig)({ partnerId, rpcUrls });
|
|
44
|
-
|
|
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 }) }));
|
|
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 }) }) }));
|
|
57
30
|
}
|
|
@@ -2,15 +2,4 @@
|
|
|
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():
|
|
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
|
-
};
|
|
5
|
+
export declare function useB3(): import("./B3ConfigProvider").B3ConfigContextType;
|
|
@@ -1,17 +1 @@
|
|
|
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
|
+
export { useB3Config } from "./B3ConfigProvider";
|
|
@@ -1,24 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useB3Config = void 0;
|
|
4
|
-
|
|
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;
|
|
4
|
+
var B3ConfigProvider_1 = require("./B3ConfigProvider");
|
|
5
|
+
Object.defineProperty(exports, "useB3Config", { enumerable: true, get: function () { return B3ConfigProvider_1.useB3Config; } });
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { useAuthStore } from "./useAuthStore";
|
|
2
|
-
export { useB3ConfigStore } from "./configStore";
|
|
3
2
|
export { useModalStore } from "./useModalStore";
|
|
4
3
|
export { useRecentAddressesStore } from "./useRecentAddressesStore";
|
|
5
4
|
export type { AnySpendBuySpinProps, AnySpendFundTournamentProps, AnySpendJoinTournamentProps, AnySpendModalProps, AnySpendNftProps, AnySpendOrderHistoryProps, AnySpendStakeB3Props, AnyspendOrderDetailsProps, ManageAccountModalProps, ModalContentType, RequestPermissionsModalProps, SignInWithB3ModalProps, } from "./useModalStore";
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useRecentAddressesStore = exports.useModalStore = exports.
|
|
3
|
+
exports.useRecentAddressesStore = exports.useModalStore = 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; } });
|
|
8
6
|
var useModalStore_1 = require("./useModalStore");
|
|
9
7
|
Object.defineProperty(exports, "useModalStore", { enumerable: true, get: function () { return useModalStore_1.useModalStore; } });
|
|
10
8
|
var useRecentAddressesStore_1 = require("./useRecentAddressesStore");
|
|
@@ -0,0 +1,31 @@
|
|
|
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;
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
}
|
|
@@ -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";
|
|
12
11
|
import { StyleRoot } from "../StyleRoot.js";
|
|
13
12
|
import { setToastContext, ToastProvider, useToastContext } from "../Toast/index.js";
|
|
14
13
|
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,34 +21,6 @@ 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
|
|
52
24
|
// Initialize Google Analytics on mount
|
|
53
25
|
useEffect(() => {
|
|
54
26
|
loadGA4Script();
|
|
@@ -58,7 +30,7 @@ toaster: _toaster, clientType = "rest", rpcUrls, partnerId, stripePublishableKey
|
|
|
58
30
|
setClientType(clientType);
|
|
59
31
|
}, [clientType]);
|
|
60
32
|
const wagmiConfig = useMemo(() => createWagmiConfig({ partnerId, rpcUrls, connectors, overrideDefaultConnectors }), [partnerId, rpcUrls, connectors, overrideDefaultConnectors]);
|
|
61
|
-
return (_jsx(ThirdwebProvider, { children: _jsx(WagmiProvider, { config: wagmiConfig, reconnectOnMount: false, children: _jsx(QueryClientProvider, { client: queryClient, children: _jsx(TooltipProvider, { children: _jsx(ToastProvider, { children:
|
|
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 })] }) }) }) }) }) }) }));
|
|
62
34
|
}
|
|
63
35
|
/**
|
|
64
36
|
* Component to connect the toast context to the global toast API
|
|
@@ -1,11 +1,10 @@
|
|
|
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";
|
|
4
3
|
import { ThirdwebProvider } from "thirdweb/react";
|
|
5
4
|
import { WagmiProvider } from "wagmi";
|
|
6
|
-
import { useB3ConfigStore } from "../../stores/configStore.js";
|
|
7
5
|
import { createWagmiConfig } from "../../utils/createWagmiConfig.js";
|
|
8
6
|
import AuthenticationProvider from "./AuthenticationProvider.js";
|
|
7
|
+
import { B3ConfigProvider } from "./B3ConfigProvider.js";
|
|
9
8
|
import { LocalSDKProvider } from "./LocalSDKProvider.js";
|
|
10
9
|
// Create queryClient instance
|
|
11
10
|
const queryClient = new QueryClient();
|
|
@@ -13,38 +12,12 @@ const queryClient = new QueryClient();
|
|
|
13
12
|
* Main B3Provider component
|
|
14
13
|
*/
|
|
15
14
|
export function B3Provider({ theme = "light", children, accountOverride, environment, clientType = "socket", partnerId, rpcUrls, onConnect, defaultPermissions, }) {
|
|
16
|
-
|
|
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 })] }) }));
|
|
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 })] }) }) }));
|
|
30
16
|
}
|
|
31
17
|
/**
|
|
32
18
|
* Inner provider component for native
|
|
33
19
|
*/
|
|
34
20
|
export function InnerProvider({ children, accountOverride, environment, defaultPermissions, theme = "light", clientType = "socket", partnerId, rpcUrls, }) {
|
|
35
|
-
const setConfig = useB3ConfigStore(state => state.setConfig);
|
|
36
21
|
const wagmiConfig = createWagmiConfig({ partnerId, rpcUrls });
|
|
37
|
-
|
|
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 }) }));
|
|
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 }) }) }));
|
|
50
23
|
}
|
|
@@ -2,15 +2,4 @@
|
|
|
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():
|
|
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
|
-
};
|
|
5
|
+
export declare function useB3(): import("./B3ConfigProvider").B3ConfigContextType;
|
|
@@ -1,17 +1 @@
|
|
|
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
|
+
export { useB3Config } from "./B3ConfigProvider";
|
|
@@ -1,20 +1 @@
|
|
|
1
|
-
|
|
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
|
-
};
|
|
1
|
+
export { useB3Config } from "./B3ConfigProvider.js";
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { useAuthStore } from "./useAuthStore";
|
|
2
|
-
export { useB3ConfigStore } from "./configStore";
|
|
3
2
|
export { useModalStore } from "./useModalStore";
|
|
4
3
|
export { useRecentAddressesStore } from "./useRecentAddressesStore";
|
|
5
4
|
export type { AnySpendBuySpinProps, AnySpendFundTournamentProps, AnySpendJoinTournamentProps, AnySpendModalProps, AnySpendNftProps, AnySpendOrderHistoryProps, AnySpendStakeB3Props, AnyspendOrderDetailsProps, ManageAccountModalProps, ModalContentType, RequestPermissionsModalProps, SignInWithB3ModalProps, } from "./useModalStore";
|
|
@@ -0,0 +1,31 @@
|
|
|
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;
|
|
@@ -2,15 +2,4 @@
|
|
|
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():
|
|
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
|
-
};
|
|
5
|
+
export declare function useB3(): import("./B3ConfigProvider").B3ConfigContextType;
|
|
@@ -1,17 +1 @@
|
|
|
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
|
+
export { useB3Config } from "./B3ConfigProvider";
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { useAuthStore } from "./useAuthStore";
|
|
2
|
-
export { useB3ConfigStore } from "./configStore";
|
|
3
2
|
export { useModalStore } from "./useModalStore";
|
|
4
3
|
export { useRecentAddressesStore } from "./useRecentAddressesStore";
|
|
5
4
|
export type { AnySpendBuySpinProps, AnySpendFundTournamentProps, AnySpendJoinTournamentProps, AnySpendModalProps, AnySpendNftProps, AnySpendOrderHistoryProps, AnySpendStakeB3Props, AnyspendOrderDetailsProps, ManageAccountModalProps, ModalContentType, RequestPermissionsModalProps, SignInWithB3ModalProps, } from "./useModalStore";
|
package/package.json
CHANGED
|
@@ -0,0 +1,84 @@
|
|
|
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
|
+
}
|
|
@@ -1,15 +1,14 @@
|
|
|
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";
|
|
4
3
|
import { ThirdwebProvider } from "thirdweb/react";
|
|
5
4
|
import { Account, Wallet } from "thirdweb/wallets";
|
|
6
5
|
|
|
7
6
|
import { ClientType } from "../../../client-manager";
|
|
8
7
|
|
|
9
8
|
import { WagmiProvider } from "wagmi";
|
|
10
|
-
import { useB3ConfigStore } from "../../stores/configStore";
|
|
11
9
|
import { createWagmiConfig } from "../../utils/createWagmiConfig";
|
|
12
10
|
import AuthenticationProvider from "./AuthenticationProvider";
|
|
11
|
+
import { B3ConfigProvider } from "./B3ConfigProvider";
|
|
13
12
|
import { LocalSDKProvider } from "./LocalSDKProvider";
|
|
14
13
|
|
|
15
14
|
// Create queryClient instance
|
|
@@ -39,28 +38,23 @@ export function B3Provider({
|
|
|
39
38
|
onConnect?: (wallet: Wallet, b3Jwt: string) => void | Promise<void>;
|
|
40
39
|
defaultPermissions?: PermissionsConfig;
|
|
41
40
|
}) {
|
|
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
|
-
|
|
57
41
|
return (
|
|
58
42
|
<ThirdwebProvider>
|
|
59
43
|
<LocalSDKProvider onConnectCallback={onConnect}>
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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>
|
|
64
58
|
</LocalSDKProvider>
|
|
65
59
|
</ThirdwebProvider>
|
|
66
60
|
);
|
|
@@ -88,25 +82,23 @@ export function InnerProvider({
|
|
|
88
82
|
partnerId: string;
|
|
89
83
|
rpcUrls?: Record<number, string>;
|
|
90
84
|
}) {
|
|
91
|
-
const setConfig = useB3ConfigStore(state => state.setConfig);
|
|
92
85
|
const wagmiConfig = createWagmiConfig({ partnerId, rpcUrls });
|
|
93
86
|
|
|
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
|
-
|
|
107
87
|
return (
|
|
108
88
|
<WagmiProvider config={wagmiConfig}>
|
|
109
|
-
<QueryClientProvider client={queryClient}>
|
|
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>
|
|
110
102
|
</WagmiProvider>
|
|
111
103
|
);
|
|
112
104
|
}
|
|
@@ -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";
|
|
15
14
|
import { StyleRoot } from "../StyleRoot";
|
|
16
15
|
import { setToastContext, ToastProvider, useToastContext } from "../Toast/index";
|
|
17
16
|
import AuthenticationProvider from "./AuthenticationProvider";
|
|
17
|
+
import { B3ConfigProvider } from "./B3ConfigProvider";
|
|
18
18
|
import { LocalSDKProvider } from "./LocalSDKProvider";
|
|
19
19
|
|
|
20
20
|
// Create queryClient instance
|
|
@@ -65,36 +65,6 @@ 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
|
-
|
|
98
68
|
// Initialize Google Analytics on mount
|
|
99
69
|
useEffect(() => {
|
|
100
70
|
loadGA4Script();
|
|
@@ -117,13 +87,26 @@ export function B3Provider({
|
|
|
117
87
|
<TooltipProvider>
|
|
118
88
|
<ToastProvider>
|
|
119
89
|
<LocalSDKProvider onConnectCallback={onConnect}>
|
|
120
|
-
<
|
|
121
|
-
|
|
122
|
-
{
|
|
123
|
-
{
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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>
|
|
127
110
|
</LocalSDKProvider>
|
|
128
111
|
</ToastProvider>
|
|
129
112
|
</TooltipProvider>
|
|
@@ -1,21 +1 @@
|
|
|
1
|
-
|
|
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
|
-
};
|
|
1
|
+
export { useB3Config } from "./B3ConfigProvider";
|
|
@@ -1,24 +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
|
-
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,30 +0,0 @@
|
|
|
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,24 +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
|
-
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,27 +0,0 @@
|
|
|
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,24 +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
|
-
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,51 +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 { 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
|
-
}));
|