@b3dotfun/sdk 0.0.20-alpha.10 → 0.0.20-alpha.12
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/B3Provider.d.ts +5 -1
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +2 -2
- package/dist/cjs/global-account/react/hooks/useProfile.d.ts +2 -1
- package/dist/cjs/global-account/react/hooks/useProfile.js +9 -7
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +5 -1
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +2 -2
- package/dist/esm/global-account/react/hooks/useProfile.d.ts +2 -1
- package/dist/esm/global-account/react/hooks/useProfile.js +9 -7
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +5 -1
- package/dist/types/global-account/react/hooks/useProfile.d.ts +2 -1
- package/package.json +2 -2
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +6 -1
- package/src/global-account/react/hooks/useProfile.ts +10 -5
|
@@ -6,7 +6,7 @@ export declare const wagmiConfig: import("wagmi").Config<readonly [import("viem"
|
|
|
6
6
|
/**
|
|
7
7
|
* Main B3Provider component
|
|
8
8
|
*/
|
|
9
|
-
export declare function B3Provider({ isMainnetAnySpend, theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, }: {
|
|
9
|
+
export declare function B3Provider({ isMainnetAnySpend, theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, }: {
|
|
10
10
|
isMainnetAnySpend?: boolean;
|
|
11
11
|
theme: "light" | "dark";
|
|
12
12
|
children: React.ReactNode;
|
|
@@ -14,6 +14,10 @@ export declare function B3Provider({ isMainnetAnySpend, theme, children, account
|
|
|
14
14
|
environment: B3ContextType["environment"];
|
|
15
15
|
automaticallySetFirstEoa?: boolean;
|
|
16
16
|
simDuneApiKey?: string;
|
|
17
|
+
toaster?: {
|
|
18
|
+
position?: "top-center" | "top-right" | "bottom-center" | "bottom-right";
|
|
19
|
+
style?: React.CSSProperties;
|
|
20
|
+
};
|
|
17
21
|
}): import("react/jsx-runtime").JSX.Element;
|
|
18
22
|
/**
|
|
19
23
|
* Inner provider component that provides the actual B3Context
|
|
@@ -32,8 +32,8 @@ const queryClient = new react_query_1.QueryClient();
|
|
|
32
32
|
/**
|
|
33
33
|
* Main B3Provider component
|
|
34
34
|
*/
|
|
35
|
-
function B3Provider({ isMainnetAnySpend = true, theme = "light", children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, }) {
|
|
36
|
-
return ((0, jsx_runtime_1.jsx)(wagmi_1.WagmiProvider, { config: exports.wagmiConfig, children: (0, jsx_runtime_1.jsx)(react_query_1.QueryClientProvider, { client: queryClient, children: (0, jsx_runtime_1.jsx)(react_3.ThirdwebProvider, { children: (0, jsx_runtime_1.jsx)(react_1.TooltipProvider, { children: (0, jsx_runtime_1.jsx)(InnerProvider, { accountOverride: accountOverride, environment: environment, theme: theme, automaticallySetFirstEoa: !!automaticallySetFirstEoa, children: (0, jsx_runtime_1.jsxs)(react_1.RelayKitProviderWrapper, { isMainnet: isMainnetAnySpend, simDuneApiKey: simDuneApiKey, children: [children, (0, jsx_runtime_1.jsx)(StyleRoot_1.StyleRoot, { id: "b3-root" }), (0, jsx_runtime_1.jsx)(sonner_1.Toaster, { theme: theme })] }) }) }) }) }) }));
|
|
35
|
+
function B3Provider({ isMainnetAnySpend = true, theme = "light", children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, }) {
|
|
36
|
+
return ((0, jsx_runtime_1.jsx)(wagmi_1.WagmiProvider, { config: exports.wagmiConfig, children: (0, jsx_runtime_1.jsx)(react_query_1.QueryClientProvider, { client: queryClient, children: (0, jsx_runtime_1.jsx)(react_3.ThirdwebProvider, { children: (0, jsx_runtime_1.jsx)(react_1.TooltipProvider, { children: (0, jsx_runtime_1.jsx)(InnerProvider, { accountOverride: accountOverride, environment: environment, theme: theme, automaticallySetFirstEoa: !!automaticallySetFirstEoa, children: (0, jsx_runtime_1.jsxs)(react_1.RelayKitProviderWrapper, { isMainnet: isMainnetAnySpend, simDuneApiKey: simDuneApiKey, children: [children, (0, jsx_runtime_1.jsx)(StyleRoot_1.StyleRoot, { id: "b3-root" }), (0, jsx_runtime_1.jsx)(sonner_1.Toaster, { theme: theme, position: toaster?.position, style: toaster?.style })] }) }) }) }) }) }));
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
39
|
* Inner provider component that provides the actual B3Context
|
|
@@ -28,9 +28,10 @@ export interface DisplayNameRequestBody {
|
|
|
28
28
|
signer: string;
|
|
29
29
|
timestamp: number;
|
|
30
30
|
}
|
|
31
|
-
export declare function useProfile({ address, name, fresh, }: {
|
|
31
|
+
export declare function useProfile({ address, name, b3GlobalId, fresh, }: {
|
|
32
32
|
address?: string;
|
|
33
33
|
name?: string;
|
|
34
|
+
b3GlobalId?: string;
|
|
34
35
|
fresh?: boolean;
|
|
35
36
|
}, options?: {
|
|
36
37
|
enabled?: boolean;
|
|
@@ -6,15 +6,17 @@ exports.useDisplayName = useDisplayName;
|
|
|
6
6
|
exports.useProfileSettings = useProfileSettings;
|
|
7
7
|
const react_query_1 = require("@tanstack/react-query");
|
|
8
8
|
const PROFILES_API_URL = "https://profiles.b3.fun";
|
|
9
|
-
async function fetchProfile({ address, name, fresh = false, }) {
|
|
10
|
-
if (!address && !name) {
|
|
11
|
-
throw new Error("Either address or name must be provided");
|
|
9
|
+
async function fetchProfile({ address, name, b3GlobalId, fresh = false, }) {
|
|
10
|
+
if (!address && !name && !b3GlobalId) {
|
|
11
|
+
throw new Error("Either address or name or b3GlobalId must be provided");
|
|
12
12
|
}
|
|
13
13
|
const params = new URLSearchParams();
|
|
14
14
|
if (address)
|
|
15
15
|
params.append("address", address);
|
|
16
16
|
if (name)
|
|
17
17
|
params.append("name", name);
|
|
18
|
+
if (b3GlobalId)
|
|
19
|
+
params.append("b3GlobalId", b3GlobalId);
|
|
18
20
|
if (fresh)
|
|
19
21
|
params.append("fresh", "true");
|
|
20
22
|
const response = await fetch(`${PROFILES_API_URL}?${params.toString()}`);
|
|
@@ -61,11 +63,11 @@ async function setDisplayName({ key, displayName, signature, signer, timestamp,
|
|
|
61
63
|
}
|
|
62
64
|
return response.json();
|
|
63
65
|
}
|
|
64
|
-
function useProfile({ address, name, fresh = false, }, options) {
|
|
66
|
+
function useProfile({ address, name, b3GlobalId, fresh = false, }, options) {
|
|
65
67
|
return (0, react_query_1.useQuery)({
|
|
66
|
-
queryKey: ["profile", address || name, fresh],
|
|
67
|
-
queryFn: () => fetchProfile({ address, name, fresh }),
|
|
68
|
-
enabled: (options?.enabled ?? true) && (!!address || !!name),
|
|
68
|
+
queryKey: ["profile", address || name || b3GlobalId, fresh],
|
|
69
|
+
queryFn: () => fetchProfile({ address, name, b3GlobalId, fresh }),
|
|
70
|
+
enabled: (options?.enabled ?? true) && (!!address || !!name || !!b3GlobalId),
|
|
69
71
|
refetchInterval: options?.refetchInterval,
|
|
70
72
|
staleTime: options?.staleTime ?? 5 * 60 * 1000, // 5 minutes default
|
|
71
73
|
});
|
|
@@ -6,7 +6,7 @@ export declare const wagmiConfig: import("wagmi").Config<readonly [import("viem"
|
|
|
6
6
|
/**
|
|
7
7
|
* Main B3Provider component
|
|
8
8
|
*/
|
|
9
|
-
export declare function B3Provider({ isMainnetAnySpend, theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, }: {
|
|
9
|
+
export declare function B3Provider({ isMainnetAnySpend, theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, }: {
|
|
10
10
|
isMainnetAnySpend?: boolean;
|
|
11
11
|
theme: "light" | "dark";
|
|
12
12
|
children: React.ReactNode;
|
|
@@ -14,6 +14,10 @@ export declare function B3Provider({ isMainnetAnySpend, theme, children, account
|
|
|
14
14
|
environment: B3ContextType["environment"];
|
|
15
15
|
automaticallySetFirstEoa?: boolean;
|
|
16
16
|
simDuneApiKey?: string;
|
|
17
|
+
toaster?: {
|
|
18
|
+
position?: "top-center" | "top-right" | "bottom-center" | "bottom-right";
|
|
19
|
+
style?: React.CSSProperties;
|
|
20
|
+
};
|
|
17
21
|
}): import("react/jsx-runtime").JSX.Element;
|
|
18
22
|
/**
|
|
19
23
|
* Inner provider component that provides the actual B3Context
|
|
@@ -27,8 +27,8 @@ const queryClient = new QueryClient();
|
|
|
27
27
|
/**
|
|
28
28
|
* Main B3Provider component
|
|
29
29
|
*/
|
|
30
|
-
export function B3Provider({ isMainnetAnySpend = true, theme = "light", children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, }) {
|
|
31
|
-
return (_jsx(WagmiProvider, { config: wagmiConfig, children: _jsx(QueryClientProvider, { client: queryClient, children: _jsx(ThirdwebProvider, { children: _jsx(TooltipProvider, { children: _jsx(InnerProvider, { accountOverride: accountOverride, environment: environment, theme: theme, automaticallySetFirstEoa: !!automaticallySetFirstEoa, children: _jsxs(RelayKitProviderWrapper, { isMainnet: isMainnetAnySpend, simDuneApiKey: simDuneApiKey, children: [children, _jsx(StyleRoot, { id: "b3-root" }), _jsx(Toaster, { theme: theme })] }) }) }) }) }) }));
|
|
30
|
+
export function B3Provider({ isMainnetAnySpend = true, theme = "light", children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, }) {
|
|
31
|
+
return (_jsx(WagmiProvider, { config: wagmiConfig, children: _jsx(QueryClientProvider, { client: queryClient, children: _jsx(ThirdwebProvider, { children: _jsx(TooltipProvider, { children: _jsx(InnerProvider, { accountOverride: accountOverride, environment: environment, theme: theme, automaticallySetFirstEoa: !!automaticallySetFirstEoa, children: _jsxs(RelayKitProviderWrapper, { isMainnet: isMainnetAnySpend, simDuneApiKey: simDuneApiKey, children: [children, _jsx(StyleRoot, { id: "b3-root" }), _jsx(Toaster, { theme: theme, position: toaster?.position, style: toaster?.style })] }) }) }) }) }) }));
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
34
|
* Inner provider component that provides the actual B3Context
|
|
@@ -28,9 +28,10 @@ export interface DisplayNameRequestBody {
|
|
|
28
28
|
signer: string;
|
|
29
29
|
timestamp: number;
|
|
30
30
|
}
|
|
31
|
-
export declare function useProfile({ address, name, fresh, }: {
|
|
31
|
+
export declare function useProfile({ address, name, b3GlobalId, fresh, }: {
|
|
32
32
|
address?: string;
|
|
33
33
|
name?: string;
|
|
34
|
+
b3GlobalId?: string;
|
|
34
35
|
fresh?: boolean;
|
|
35
36
|
}, options?: {
|
|
36
37
|
enabled?: boolean;
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { useQuery } from "@tanstack/react-query";
|
|
2
2
|
const PROFILES_API_URL = "https://profiles.b3.fun";
|
|
3
|
-
async function fetchProfile({ address, name, fresh = false, }) {
|
|
4
|
-
if (!address && !name) {
|
|
5
|
-
throw new Error("Either address or name must be provided");
|
|
3
|
+
async function fetchProfile({ address, name, b3GlobalId, fresh = false, }) {
|
|
4
|
+
if (!address && !name && !b3GlobalId) {
|
|
5
|
+
throw new Error("Either address or name or b3GlobalId must be provided");
|
|
6
6
|
}
|
|
7
7
|
const params = new URLSearchParams();
|
|
8
8
|
if (address)
|
|
9
9
|
params.append("address", address);
|
|
10
10
|
if (name)
|
|
11
11
|
params.append("name", name);
|
|
12
|
+
if (b3GlobalId)
|
|
13
|
+
params.append("b3GlobalId", b3GlobalId);
|
|
12
14
|
if (fresh)
|
|
13
15
|
params.append("fresh", "true");
|
|
14
16
|
const response = await fetch(`${PROFILES_API_URL}?${params.toString()}`);
|
|
@@ -55,11 +57,11 @@ async function setDisplayName({ key, displayName, signature, signer, timestamp,
|
|
|
55
57
|
}
|
|
56
58
|
return response.json();
|
|
57
59
|
}
|
|
58
|
-
export function useProfile({ address, name, fresh = false, }, options) {
|
|
60
|
+
export function useProfile({ address, name, b3GlobalId, fresh = false, }, options) {
|
|
59
61
|
return useQuery({
|
|
60
|
-
queryKey: ["profile", address || name, fresh],
|
|
61
|
-
queryFn: () => fetchProfile({ address, name, fresh }),
|
|
62
|
-
enabled: (options?.enabled ?? true) && (!!address || !!name),
|
|
62
|
+
queryKey: ["profile", address || name || b3GlobalId, fresh],
|
|
63
|
+
queryFn: () => fetchProfile({ address, name, b3GlobalId, fresh }),
|
|
64
|
+
enabled: (options?.enabled ?? true) && (!!address || !!name || !!b3GlobalId),
|
|
63
65
|
refetchInterval: options?.refetchInterval,
|
|
64
66
|
staleTime: options?.staleTime ?? 5 * 60 * 1000, // 5 minutes default
|
|
65
67
|
});
|
|
@@ -6,7 +6,7 @@ export declare const wagmiConfig: import("wagmi").Config<readonly [import("viem"
|
|
|
6
6
|
/**
|
|
7
7
|
* Main B3Provider component
|
|
8
8
|
*/
|
|
9
|
-
export declare function B3Provider({ isMainnetAnySpend, theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, }: {
|
|
9
|
+
export declare function B3Provider({ isMainnetAnySpend, theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, }: {
|
|
10
10
|
isMainnetAnySpend?: boolean;
|
|
11
11
|
theme: "light" | "dark";
|
|
12
12
|
children: React.ReactNode;
|
|
@@ -14,6 +14,10 @@ export declare function B3Provider({ isMainnetAnySpend, theme, children, account
|
|
|
14
14
|
environment: B3ContextType["environment"];
|
|
15
15
|
automaticallySetFirstEoa?: boolean;
|
|
16
16
|
simDuneApiKey?: string;
|
|
17
|
+
toaster?: {
|
|
18
|
+
position?: "top-center" | "top-right" | "bottom-center" | "bottom-right";
|
|
19
|
+
style?: React.CSSProperties;
|
|
20
|
+
};
|
|
17
21
|
}): import("react/jsx-runtime").JSX.Element;
|
|
18
22
|
/**
|
|
19
23
|
* Inner provider component that provides the actual B3Context
|
|
@@ -28,9 +28,10 @@ export interface DisplayNameRequestBody {
|
|
|
28
28
|
signer: string;
|
|
29
29
|
timestamp: number;
|
|
30
30
|
}
|
|
31
|
-
export declare function useProfile({ address, name, fresh, }: {
|
|
31
|
+
export declare function useProfile({ address, name, b3GlobalId, fresh, }: {
|
|
32
32
|
address?: string;
|
|
33
33
|
name?: string;
|
|
34
|
+
b3GlobalId?: string;
|
|
34
35
|
fresh?: boolean;
|
|
35
36
|
}, options?: {
|
|
36
37
|
enabled?: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@b3dotfun/sdk",
|
|
3
|
-
"version": "0.0.20-alpha.
|
|
3
|
+
"version": "0.0.20-alpha.12",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"react-native": "./dist/cjs/index.native.js",
|
|
@@ -191,7 +191,7 @@
|
|
|
191
191
|
],
|
|
192
192
|
"dependencies": {
|
|
193
193
|
"@amplitude/analytics-browser": "2.14.0",
|
|
194
|
-
"@b3dotfun/b3-api": "0.0.
|
|
194
|
+
"@b3dotfun/b3-api": "0.0.38",
|
|
195
195
|
"@b3dotfun/basement-api": "0.0.11",
|
|
196
196
|
"@b3dotfun/bondkit": "^0.1.17",
|
|
197
197
|
"@chakra-ui/react": "2.10.7",
|
|
@@ -48,6 +48,7 @@ export function B3Provider({
|
|
|
48
48
|
environment,
|
|
49
49
|
automaticallySetFirstEoa,
|
|
50
50
|
simDuneApiKey,
|
|
51
|
+
toaster,
|
|
51
52
|
}: {
|
|
52
53
|
isMainnetAnySpend?: boolean;
|
|
53
54
|
theme: "light" | "dark";
|
|
@@ -56,6 +57,10 @@ export function B3Provider({
|
|
|
56
57
|
environment: B3ContextType["environment"];
|
|
57
58
|
automaticallySetFirstEoa?: boolean;
|
|
58
59
|
simDuneApiKey?: string;
|
|
60
|
+
toaster?: {
|
|
61
|
+
position?: "top-center" | "top-right" | "bottom-center" | "bottom-right";
|
|
62
|
+
style?: React.CSSProperties;
|
|
63
|
+
};
|
|
59
64
|
}) {
|
|
60
65
|
return (
|
|
61
66
|
<WagmiProvider config={wagmiConfig}>
|
|
@@ -72,7 +77,7 @@ export function B3Provider({
|
|
|
72
77
|
{children}
|
|
73
78
|
{/* For the modal https://github.com/b3-fun/b3/blob/main/packages/sdk/src/global-account/react/components/ui/dialog.tsx#L46 */}
|
|
74
79
|
<StyleRoot id="b3-root" />
|
|
75
|
-
<Toaster theme={theme} />
|
|
80
|
+
<Toaster theme={theme} position={toaster?.position} style={toaster?.style} />
|
|
76
81
|
</RelayKitProviderWrapper>
|
|
77
82
|
</InnerProvider>
|
|
78
83
|
</TooltipProvider>
|
|
@@ -42,19 +42,22 @@ const PROFILES_API_URL = "https://profiles.b3.fun";
|
|
|
42
42
|
async function fetchProfile({
|
|
43
43
|
address,
|
|
44
44
|
name,
|
|
45
|
+
b3GlobalId,
|
|
45
46
|
fresh = false,
|
|
46
47
|
}: {
|
|
47
48
|
address?: string;
|
|
48
49
|
name?: string;
|
|
50
|
+
b3GlobalId?: string;
|
|
49
51
|
fresh?: boolean;
|
|
50
52
|
}): Promise<CombinedProfile> {
|
|
51
|
-
if (!address && !name) {
|
|
52
|
-
throw new Error("Either address or name must be provided");
|
|
53
|
+
if (!address && !name && !b3GlobalId) {
|
|
54
|
+
throw new Error("Either address or name or b3GlobalId must be provided");
|
|
53
55
|
}
|
|
54
56
|
|
|
55
57
|
const params = new URLSearchParams();
|
|
56
58
|
if (address) params.append("address", address);
|
|
57
59
|
if (name) params.append("name", name);
|
|
60
|
+
if (b3GlobalId) params.append("b3GlobalId", b3GlobalId);
|
|
58
61
|
if (fresh) params.append("fresh", "true");
|
|
59
62
|
|
|
60
63
|
const response = await fetch(`${PROFILES_API_URL}?${params.toString()}`);
|
|
@@ -126,10 +129,12 @@ export function useProfile(
|
|
|
126
129
|
{
|
|
127
130
|
address,
|
|
128
131
|
name,
|
|
132
|
+
b3GlobalId,
|
|
129
133
|
fresh = false,
|
|
130
134
|
}: {
|
|
131
135
|
address?: string;
|
|
132
136
|
name?: string;
|
|
137
|
+
b3GlobalId?: string;
|
|
133
138
|
fresh?: boolean;
|
|
134
139
|
},
|
|
135
140
|
options?: {
|
|
@@ -139,9 +144,9 @@ export function useProfile(
|
|
|
139
144
|
},
|
|
140
145
|
) {
|
|
141
146
|
return useQuery({
|
|
142
|
-
queryKey: ["profile", address || name, fresh],
|
|
143
|
-
queryFn: () => fetchProfile({ address, name, fresh }),
|
|
144
|
-
enabled: (options?.enabled ?? true) && (!!address || !!name),
|
|
147
|
+
queryKey: ["profile", address || name || b3GlobalId, fresh],
|
|
148
|
+
queryFn: () => fetchProfile({ address, name, b3GlobalId, fresh }),
|
|
149
|
+
enabled: (options?.enabled ?? true) && (!!address || !!name || !!b3GlobalId),
|
|
145
150
|
refetchInterval: options?.refetchInterval,
|
|
146
151
|
staleTime: options?.staleTime ?? 5 * 60 * 1000, // 5 minutes default
|
|
147
152
|
});
|