@b3dotfun/sdk 0.1.0-alpha.2 → 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.
- package/dist/cjs/anyspend/react/components/common/GasIndicator.d.ts +1 -1
- package/dist/cjs/anyspend/react/components/common/GasIndicator.js +16 -6
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +30 -2
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.js +31 -4
- package/dist/cjs/global-account/react/components/B3Provider/useB3.d.ts +12 -1
- package/dist/cjs/global-account/react/components/B3Provider/useB3Config.d.ts +17 -1
- package/dist/cjs/global-account/react/components/B3Provider/useB3Config.js +21 -2
- package/dist/cjs/global-account/react/stores/configStore.d.ts +24 -0
- package/dist/cjs/global-account/react/stores/configStore.js +30 -0
- package/dist/cjs/global-account/react/stores/index.d.ts +1 -0
- package/dist/cjs/global-account/react/stores/index.js +3 -1
- package/dist/esm/anyspend/react/components/common/GasIndicator.d.ts +1 -1
- package/dist/esm/anyspend/react/components/common/GasIndicator.js +17 -7
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +30 -2
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.js +30 -3
- package/dist/esm/global-account/react/components/B3Provider/useB3.d.ts +12 -1
- package/dist/esm/global-account/react/components/B3Provider/useB3Config.d.ts +17 -1
- package/dist/esm/global-account/react/components/B3Provider/useB3Config.js +20 -1
- package/dist/esm/global-account/react/stores/configStore.d.ts +24 -0
- package/dist/esm/global-account/react/stores/configStore.js +27 -0
- package/dist/esm/global-account/react/stores/index.d.ts +1 -0
- package/dist/esm/global-account/react/stores/index.js +1 -0
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/react/components/common/GasIndicator.d.ts +1 -1
- package/dist/types/global-account/react/components/B3Provider/useB3.d.ts +12 -1
- package/dist/types/global-account/react/components/B3Provider/useB3Config.d.ts +17 -1
- package/dist/types/global-account/react/stores/configStore.d.ts +24 -0
- package/dist/types/global-account/react/stores/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/anyspend/react/components/common/GasIndicator.tsx +30 -11
- package/src/global-account/react/components/B3Provider/B3Provider.native.tsx +36 -28
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +38 -21
- package/src/global-account/react/components/B3Provider/useB3Config.ts +21 -1
- package/src/global-account/react/stores/configStore.ts +51 -0
- package/src/global-account/react/stores/index.ts +1 -0
- package/dist/cjs/global-account/react/components/B3Provider/B3ConfigProvider.d.ts +0 -31
- package/dist/cjs/global-account/react/components/B3Provider/B3ConfigProvider.js +0 -37
- package/dist/esm/global-account/react/components/B3Provider/B3ConfigProvider.d.ts +0 -31
- package/dist/esm/global-account/react/components/B3Provider/B3ConfigProvider.js +0 -33
- package/dist/types/global-account/react/components/B3Provider/B3ConfigProvider.d.ts +0 -31
- package/src/global-account/react/components/B3Provider/B3ConfigProvider.tsx +0 -84
|
@@ -9,7 +9,23 @@ export interface GasIndicatorProps {
|
|
|
9
9
|
className?: string;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
const LEVEL_LABELS: Record<GasPriceData["level"], string> = {
|
|
13
|
+
low: "Low",
|
|
14
|
+
normal: "Normal",
|
|
15
|
+
elevated: "Elevated",
|
|
16
|
+
high: "High",
|
|
17
|
+
spike: "Spike",
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const LEVEL_STYLES: Record<GasPriceData["level"], string> = {
|
|
21
|
+
low: "bg-green-500/20 text-green-500",
|
|
22
|
+
normal: "bg-as-surface-tertiary text-as-secondary",
|
|
23
|
+
elevated: "bg-yellow-500/20 text-yellow-600",
|
|
24
|
+
high: "bg-orange-500/20 text-orange-500",
|
|
25
|
+
spike: "bg-red-500/20 text-red-500",
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
function formatGasPrice(gweiString: string): string {
|
|
13
29
|
const gwei = parseFloat(gweiString);
|
|
14
30
|
if (gwei < 0.001) return "<0.001";
|
|
15
31
|
if (gwei < 1) return gwei.toFixed(3);
|
|
@@ -18,23 +34,26 @@ function formatGwei(gweiString: string): string {
|
|
|
18
34
|
}
|
|
19
35
|
|
|
20
36
|
export function GasIndicator({ gasPrice, className }: GasIndicatorProps) {
|
|
21
|
-
// Only show when gas is high or spike
|
|
22
|
-
if (!["high", "spike"].includes(gasPrice.level)) {
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
37
|
return (
|
|
27
38
|
<motion.div
|
|
28
39
|
initial={{ opacity: 0, y: 10 }}
|
|
29
40
|
animate={{ opacity: 1, y: 0 }}
|
|
30
41
|
transition={{ duration: 0.2 }}
|
|
31
|
-
className={cn(
|
|
42
|
+
className={cn(
|
|
43
|
+
"flex items-center justify-between rounded-lg px-3 py-2",
|
|
44
|
+
gasPrice.isSpike ? "bg-yellow-500/10" : "bg-as-surface-secondary",
|
|
45
|
+
className,
|
|
46
|
+
)}
|
|
32
47
|
>
|
|
33
|
-
<div className="flex items-center
|
|
34
|
-
<span className="text-
|
|
35
|
-
|
|
48
|
+
<div className="flex items-center gap-2">
|
|
49
|
+
<span className="text-as-secondary text-xs">Gas on {gasPrice.chainName}</span>
|
|
50
|
+
</div>
|
|
51
|
+
<div className="flex items-center gap-2">
|
|
52
|
+
<span className={cn("rounded px-1.5 py-0.5 text-xs font-medium", LEVEL_STYLES[gasPrice.level])}>
|
|
53
|
+
{LEVEL_LABELS[gasPrice.level]}
|
|
54
|
+
</span>
|
|
55
|
+
<span className="text-as-primary text-xs font-medium">{formatGasPrice(gasPrice.gasPriceGwei)} Gwei</span>
|
|
36
56
|
</div>
|
|
37
|
-
<span className="text-as-secondary text-xs">Consider swapping later for better rates</span>
|
|
38
57
|
</motion.div>
|
|
39
58
|
);
|
|
40
59
|
}
|
|
@@ -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
|
-
<
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
<
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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
|
-
|
|
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,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
|
-
}
|