@b3dotfun/sdk 0.0.47 → 0.0.48
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/README.md +225 -6
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +5 -3
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +3 -2
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +15 -64
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.d.ts +6 -2
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.js +26 -21
- package/dist/cjs/global-account/react/components/B3Provider/types.d.ts +2 -0
- package/dist/cjs/global-account/react/components/B3Provider/types.js +2 -0
- package/dist/cjs/global-account/react/components/ManageAccount/BalanceContent.d.ts +1 -2
- package/dist/cjs/global-account/react/components/ManageAccount/BalanceContent.js +2 -2
- package/dist/cjs/global-account/react/components/ManageAccount/ManageAccount.js +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignIn.js +2 -2
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3.js +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.d.ts +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +6 -22
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Privy.d.ts +1 -2
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +3 -2
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.d.ts +1 -2
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.js +10 -45
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.d.ts +1 -2
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +2 -1
- package/dist/cjs/global-account/react/components/custom/ManageAccountButton.js +2 -1
- package/dist/cjs/global-account/react/hooks/useAuthentication.d.ts +51 -2
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +141 -81
- package/dist/cjs/global-account/react/hooks/useHandleConnectWithPrivy.d.ts +1 -1
- package/dist/cjs/global-account/react/hooks/useHandleConnectWithPrivy.js +2 -1
- package/dist/cjs/global-account/react/hooks/useUserQuery.d.ts +58 -0
- package/dist/cjs/global-account/react/hooks/useUserQuery.js +86 -0
- package/dist/cjs/global-account/react/hooks/useWagmiConfig.d.ts +13 -0
- package/dist/cjs/global-account/react/hooks/useWagmiConfig.js +42 -0
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +0 -2
- package/dist/cjs/notifications/index.d.ts +3 -0
- package/dist/cjs/notifications/index.js +25 -0
- package/dist/cjs/notifications/react/hooks/index.d.ts +1 -0
- package/dist/cjs/notifications/react/hooks/index.js +17 -0
- package/dist/cjs/notifications/react/hooks/useNotifications.d.ts +42 -0
- package/dist/cjs/notifications/react/hooks/useNotifications.js +148 -0
- package/dist/cjs/notifications/react/index.d.ts +1 -0
- package/dist/cjs/notifications/react/index.js +17 -0
- package/dist/cjs/notifications/services/api.d.ts +67 -0
- package/dist/cjs/notifications/services/api.js +184 -0
- package/dist/cjs/notifications/services/index.d.ts +1 -0
- package/dist/cjs/notifications/services/index.js +17 -0
- package/dist/cjs/notifications/types/index.d.ts +51 -0
- package/dist/cjs/notifications/types/index.js +2 -0
- package/dist/cjs/shared/utils/auth-token.d.ts +7 -0
- package/dist/cjs/shared/utils/auth-token.js +17 -0
- package/dist/cjs/shared/utils/index.d.ts +1 -0
- package/dist/cjs/shared/utils/index.js +1 -0
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +5 -3
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +3 -2
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +19 -68
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.d.ts +6 -2
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.js +24 -19
- package/dist/esm/global-account/react/components/B3Provider/types.d.ts +2 -0
- package/dist/esm/global-account/react/components/B3Provider/types.js +2 -0
- package/dist/esm/global-account/react/components/ManageAccount/BalanceContent.d.ts +1 -2
- package/dist/esm/global-account/react/components/ManageAccount/BalanceContent.js +2 -2
- package/dist/esm/global-account/react/components/ManageAccount/ManageAccount.js +1 -1
- package/dist/esm/global-account/react/components/SignInWithB3/SignIn.js +2 -2
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3.js +2 -2
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.d.ts +1 -1
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +7 -23
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Privy.d.ts +1 -2
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +4 -3
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.d.ts +1 -2
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.js +11 -46
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.d.ts +1 -2
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +3 -2
- package/dist/esm/global-account/react/components/custom/ManageAccountButton.js +3 -2
- package/dist/esm/global-account/react/hooks/useAuthentication.d.ts +51 -2
- package/dist/esm/global-account/react/hooks/useAuthentication.js +144 -84
- package/dist/esm/global-account/react/hooks/useHandleConnectWithPrivy.d.ts +1 -1
- package/dist/esm/global-account/react/hooks/useHandleConnectWithPrivy.js +3 -2
- package/dist/esm/global-account/react/hooks/useUserQuery.d.ts +58 -0
- package/dist/esm/global-account/react/hooks/useUserQuery.js +83 -0
- package/dist/esm/global-account/react/hooks/useWagmiConfig.d.ts +13 -0
- package/dist/esm/global-account/react/hooks/useWagmiConfig.js +39 -0
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +0 -2
- package/dist/esm/notifications/index.d.ts +3 -0
- package/dist/esm/notifications/index.js +7 -0
- package/dist/esm/notifications/react/hooks/index.d.ts +1 -0
- package/dist/esm/notifications/react/hooks/index.js +1 -0
- package/dist/esm/notifications/react/hooks/useNotifications.d.ts +42 -0
- package/dist/esm/notifications/react/hooks/useNotifications.js +145 -0
- package/dist/esm/notifications/react/index.d.ts +1 -0
- package/dist/esm/notifications/react/index.js +1 -0
- package/dist/esm/notifications/services/api.d.ts +67 -0
- package/dist/esm/notifications/services/api.js +179 -0
- package/dist/esm/notifications/services/index.d.ts +1 -0
- package/dist/esm/notifications/services/index.js +1 -0
- package/dist/esm/notifications/types/index.d.ts +51 -0
- package/dist/esm/shared/utils/auth-token.d.ts +7 -0
- package/dist/esm/shared/utils/auth-token.js +11 -0
- package/dist/esm/shared/utils/index.d.ts +1 -0
- package/dist/esm/shared/utils/index.js +1 -0
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +3 -2
- package/dist/types/global-account/react/components/B3Provider/B3Provider.native.d.ts +6 -2
- package/dist/types/global-account/react/components/B3Provider/types.d.ts +2 -0
- package/dist/types/global-account/react/components/ManageAccount/BalanceContent.d.ts +1 -2
- package/dist/types/global-account/react/components/SignInWithB3/SignInWithB3Flow.d.ts +1 -1
- package/dist/types/global-account/react/components/SignInWithB3/SignInWithB3Privy.d.ts +1 -2
- package/dist/types/global-account/react/components/SignInWithB3/steps/LoginStep.d.ts +1 -2
- package/dist/types/global-account/react/components/SignInWithB3/steps/LoginStepCustom.d.ts +1 -2
- package/dist/types/global-account/react/hooks/useAuthentication.d.ts +51 -2
- package/dist/types/global-account/react/hooks/useHandleConnectWithPrivy.d.ts +1 -1
- package/dist/types/global-account/react/hooks/useUserQuery.d.ts +58 -0
- package/dist/types/global-account/react/hooks/useWagmiConfig.d.ts +13 -0
- package/dist/types/global-account/react/stores/useModalStore.d.ts +0 -2
- package/dist/types/notifications/index.d.ts +3 -0
- package/dist/types/notifications/react/hooks/index.d.ts +1 -0
- package/dist/types/notifications/react/hooks/useNotifications.d.ts +42 -0
- package/dist/types/notifications/react/index.d.ts +1 -0
- package/dist/types/notifications/services/api.d.ts +67 -0
- package/dist/types/notifications/services/index.d.ts +1 -0
- package/dist/types/notifications/types/index.d.ts +51 -0
- package/dist/types/shared/utils/auth-token.d.ts +7 -0
- package/dist/types/shared/utils/index.d.ts +1 -0
- package/package.json +23 -3
- package/src/anyspend/react/components/AnySpendCustom.tsx +5 -3
- package/src/global-account/react/components/B3Provider/B3Provider.native.tsx +51 -35
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +28 -72
- package/src/global-account/react/components/B3Provider/types.ts +4 -0
- package/src/global-account/react/components/ManageAccount/BalanceContent.tsx +2 -3
- package/src/global-account/react/components/ManageAccount/ManageAccount.tsx +1 -1
- package/src/global-account/react/components/SignInWithB3/SignIn.tsx +2 -2
- package/src/global-account/react/components/SignInWithB3/SignInWithB3.tsx +2 -2
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +4 -23
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Privy.tsx +4 -3
- package/src/global-account/react/components/SignInWithB3/steps/LoginStep.tsx +8 -46
- package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +2 -2
- package/src/global-account/react/components/custom/ManageAccountButton.tsx +3 -2
- package/src/global-account/react/hooks/useAuthentication.ts +170 -89
- package/src/global-account/react/hooks/useHandleConnectWithPrivy.tsx +3 -2
- package/src/global-account/react/hooks/useUserQuery.ts +95 -0
- package/src/global-account/react/hooks/useWagmiConfig.tsx +44 -0
- package/src/global-account/react/stores/useModalStore.ts +0 -2
- package/src/notifications/index.ts +9 -0
- package/src/notifications/react/hooks/index.ts +1 -0
- package/src/notifications/react/hooks/useNotifications.ts +153 -0
- package/src/notifications/react/index.ts +1 -0
- package/src/notifications/services/api.ts +217 -0
- package/src/notifications/services/index.ts +1 -0
- package/src/notifications/types/index.ts +58 -0
- package/src/shared/utils/auth-token.ts +13 -0
- package/src/shared/utils/index.ts +1 -0
- package/dist/cjs/shared/react/hooks/__tests__/useCurrencyConversion.test.js +0 -245
- package/dist/esm/shared/react/hooks/__tests__/useCurrencyConversion.test.d.ts +0 -1
- package/dist/esm/shared/react/hooks/__tests__/useCurrencyConversion.test.js +0 -243
- package/dist/types/shared/react/hooks/__tests__/useCurrencyConversion.test.d.ts +0 -1
- /package/dist/{cjs/shared/react/hooks/__tests__/useCurrencyConversion.test.d.ts → esm/notifications/types/index.js} +0 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { NotificationHistory, NotificationPreferences, SendNotificationRequest, TelegramLinkResponse, TelegramStatusResponse, UserData } from "../types";
|
|
2
|
+
export declare function setApiUrl(url: string): void;
|
|
3
|
+
export declare function getApiUrl(): string;
|
|
4
|
+
export declare const notificationsAPI: {
|
|
5
|
+
/**
|
|
6
|
+
* Register the current user (userId extracted from JWT)
|
|
7
|
+
*/
|
|
8
|
+
registerUser(): Promise<any>;
|
|
9
|
+
/**
|
|
10
|
+
* Get current user's profile and preferences
|
|
11
|
+
*/
|
|
12
|
+
getUser(): Promise<UserData>;
|
|
13
|
+
/**
|
|
14
|
+
* Get current user's notification history
|
|
15
|
+
*/
|
|
16
|
+
getHistory(appId?: string, limit?: number): Promise<NotificationHistory[]>;
|
|
17
|
+
/**
|
|
18
|
+
* Add a notification channel for current user
|
|
19
|
+
*/
|
|
20
|
+
addChannel(channelType: string, channelIdentifier: string, metadata?: Record<string, any>): Promise<any>;
|
|
21
|
+
/**
|
|
22
|
+
* Connect email for current user
|
|
23
|
+
*/
|
|
24
|
+
connectEmail(email: string): Promise<any>;
|
|
25
|
+
/**
|
|
26
|
+
* Update a notification channel
|
|
27
|
+
*/
|
|
28
|
+
updateChannel(channelId: string, updates: {
|
|
29
|
+
enabled?: boolean;
|
|
30
|
+
channelIdentifier?: string;
|
|
31
|
+
metadata?: Record<string, any>;
|
|
32
|
+
}): Promise<any>;
|
|
33
|
+
/**
|
|
34
|
+
* Delete a notification channel
|
|
35
|
+
*/
|
|
36
|
+
deleteChannel(channelId: string): Promise<any>;
|
|
37
|
+
/**
|
|
38
|
+
* Get Telegram deep link for current user
|
|
39
|
+
*/
|
|
40
|
+
getTelegramLink(): Promise<TelegramLinkResponse>;
|
|
41
|
+
/**
|
|
42
|
+
* Check current user's Telegram connection status
|
|
43
|
+
*/
|
|
44
|
+
checkTelegramStatus(): Promise<TelegramStatusResponse>;
|
|
45
|
+
/**
|
|
46
|
+
* Save notification preferences for an app
|
|
47
|
+
* @param appId - The application ID
|
|
48
|
+
* @param settings - Notification preferences including channels, type, and enabled status (defaults to true)
|
|
49
|
+
*/
|
|
50
|
+
savePreferences(appId: string, settings: NotificationPreferences): Promise<any>;
|
|
51
|
+
/**
|
|
52
|
+
* Get notification settings for an app
|
|
53
|
+
*/
|
|
54
|
+
getAppSettings(appId: string): Promise<any>;
|
|
55
|
+
/**
|
|
56
|
+
* Get current user's in-app notifications
|
|
57
|
+
*/
|
|
58
|
+
getInAppNotifications(): Promise<any>;
|
|
59
|
+
/**
|
|
60
|
+
* Mark a notification as read
|
|
61
|
+
*/
|
|
62
|
+
markNotificationAsRead(notificationId: string): Promise<any>;
|
|
63
|
+
/**
|
|
64
|
+
* Send a notification (requires auth)
|
|
65
|
+
*/
|
|
66
|
+
sendNotification(data: SendNotificationRequest): Promise<any>;
|
|
67
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./api";
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export type ChannelType = "email" | "telegram" | "discord" | "sms" | "whatsapp" | "in_app";
|
|
2
|
+
export interface NotificationChannel {
|
|
3
|
+
id: number;
|
|
4
|
+
channel_type: ChannelType;
|
|
5
|
+
enabled: number;
|
|
6
|
+
channel_identifier: string;
|
|
7
|
+
}
|
|
8
|
+
export interface UserData {
|
|
9
|
+
user: {
|
|
10
|
+
id: number;
|
|
11
|
+
user_id: string;
|
|
12
|
+
};
|
|
13
|
+
channels: NotificationChannel[];
|
|
14
|
+
appSettings: Array<{
|
|
15
|
+
app_id: string;
|
|
16
|
+
notification_type: string;
|
|
17
|
+
enabled: number;
|
|
18
|
+
channels: string;
|
|
19
|
+
}>;
|
|
20
|
+
}
|
|
21
|
+
export interface NotificationHistory {
|
|
22
|
+
id: string;
|
|
23
|
+
app_id: string;
|
|
24
|
+
notification_type: string;
|
|
25
|
+
title: string;
|
|
26
|
+
message: string;
|
|
27
|
+
created_at: string;
|
|
28
|
+
read: boolean;
|
|
29
|
+
}
|
|
30
|
+
export interface TelegramLinkResponse {
|
|
31
|
+
deepLink: string;
|
|
32
|
+
verificationCode: string;
|
|
33
|
+
botUsername: string;
|
|
34
|
+
}
|
|
35
|
+
export interface TelegramStatusResponse {
|
|
36
|
+
connected: boolean;
|
|
37
|
+
chatId?: string;
|
|
38
|
+
}
|
|
39
|
+
export interface NotificationPreferences {
|
|
40
|
+
notificationType: string;
|
|
41
|
+
channels: string[];
|
|
42
|
+
enabled?: boolean;
|
|
43
|
+
}
|
|
44
|
+
export interface SendNotificationRequest {
|
|
45
|
+
userId: string;
|
|
46
|
+
appId: string;
|
|
47
|
+
notificationType: string;
|
|
48
|
+
message: string;
|
|
49
|
+
title?: string;
|
|
50
|
+
data?: Record<string, any>;
|
|
51
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@b3dotfun/sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.48",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"react-native": "./dist/cjs/index.native.js",
|
|
@@ -170,6 +170,26 @@
|
|
|
170
170
|
"import": "./dist/esm/global-account/server.js",
|
|
171
171
|
"require": "./dist/cjs/global-account/server.js"
|
|
172
172
|
},
|
|
173
|
+
"./notifications": {
|
|
174
|
+
"types": "./dist/types/notifications/index.d.ts",
|
|
175
|
+
"import": "./dist/esm/notifications/index.js",
|
|
176
|
+
"require": "./dist/cjs/notifications/index.js"
|
|
177
|
+
},
|
|
178
|
+
"./notifications/react": {
|
|
179
|
+
"types": "./dist/types/notifications/react/index.d.ts",
|
|
180
|
+
"import": "./dist/esm/notifications/react/index.js",
|
|
181
|
+
"require": "./dist/cjs/notifications/react/index.js"
|
|
182
|
+
},
|
|
183
|
+
"./notifications/services": {
|
|
184
|
+
"types": "./dist/types/notifications/services/index.d.ts",
|
|
185
|
+
"import": "./dist/esm/notifications/services/index.js",
|
|
186
|
+
"require": "./dist/cjs/notifications/services/index.js"
|
|
187
|
+
},
|
|
188
|
+
"./notifications/types": {
|
|
189
|
+
"types": "./dist/types/notifications/types/index.d.ts",
|
|
190
|
+
"import": "./dist/esm/notifications/types/index.js",
|
|
191
|
+
"require": "./dist/cjs/notifications/types/index.js"
|
|
192
|
+
},
|
|
173
193
|
"./shared/utils": {
|
|
174
194
|
"types": "./dist/types/shared/utils/index.d.ts",
|
|
175
195
|
"import": "./dist/esm/shared/utils/index.js",
|
|
@@ -281,7 +301,7 @@
|
|
|
281
301
|
"@solana/web3.js": "^1.98.2",
|
|
282
302
|
"@stripe/react-stripe-js": "^3.7.0",
|
|
283
303
|
"@stripe/stripe-js": "^7.3.1",
|
|
284
|
-
"@thirdweb-dev/wagmi-adapter": "
|
|
304
|
+
"@thirdweb-dev/wagmi-adapter": "0.2.159",
|
|
285
305
|
"@web3icons/react": "3.16.0",
|
|
286
306
|
"big.js": "^7.0.1",
|
|
287
307
|
"class-variance-authority": "0.7.0",
|
|
@@ -354,7 +374,7 @@
|
|
|
354
374
|
"react": "^18.0.0 || ^19.0.0",
|
|
355
375
|
"react-dom": "^18.0.0 || ^19.0.0",
|
|
356
376
|
"react-native-mmkv": "^3.2.0",
|
|
357
|
-
"thirdweb": "5.
|
|
377
|
+
"thirdweb": "5.108.9",
|
|
358
378
|
"three": "^0.175.0",
|
|
359
379
|
"viem": "^2.28.1",
|
|
360
380
|
"wagmi": "^2.14.15"
|
|
@@ -395,11 +395,13 @@ function AnySpendCustomInner({
|
|
|
395
395
|
useEffect(() => {
|
|
396
396
|
if (oat?.data?.order.status === "executed" && !onSuccessCalled.current) {
|
|
397
397
|
console.log("Calling onSuccess");
|
|
398
|
-
const
|
|
398
|
+
const relayTxs = oat?.data?.relayTxs;
|
|
399
|
+
const lastRelayTxHash = relayTxs?.[relayTxs.length - 1]?.txHash;
|
|
400
|
+
const txHash = oat?.data?.executeTx?.txHash || lastRelayTxHash;
|
|
399
401
|
onSuccess?.(txHash);
|
|
400
402
|
onSuccessCalled.current = true;
|
|
401
403
|
}
|
|
402
|
-
}, [oat?.data?.order.status, oat?.data?.executeTx?.txHash, onSuccess]);
|
|
404
|
+
}, [oat?.data?.order.status, oat?.data?.executeTx?.txHash, oat?.data?.relayTxs, onSuccess]);
|
|
403
405
|
|
|
404
406
|
// Reset flag when orderId changes
|
|
405
407
|
useEffect(() => {
|
|
@@ -665,7 +667,7 @@ function AnySpendCustomInner({
|
|
|
665
667
|
const orderDetailsView = (
|
|
666
668
|
<div
|
|
667
669
|
className={cn(
|
|
668
|
-
"mx-auto flex w-full flex-col items-center gap-4",
|
|
670
|
+
"mx-auto flex w-full flex-col items-center gap-4 p-5",
|
|
669
671
|
mode === "modal" && "bg-b3-react-background rounded-xl",
|
|
670
672
|
)}
|
|
671
673
|
>
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { PermissionsConfig } from "@b3dotfun/sdk/global-account/types/permissions";
|
|
2
2
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
3
|
-
import { useState } from "react";
|
|
4
3
|
import { ThirdwebProvider, useActiveAccount } from "thirdweb/react";
|
|
5
4
|
import { Account } from "thirdweb/wallets";
|
|
6
5
|
|
|
7
|
-
import { Users } from "@b3dotfun/b3-api";
|
|
8
6
|
import { ClientType } from "../../../client-manager";
|
|
9
7
|
|
|
8
|
+
import { WagmiProvider } from "wagmi";
|
|
9
|
+
import { useAuthentication } from "../../hooks/useAuthentication";
|
|
10
|
+
import { useWagmiConfig } from "../../hooks/useWagmiConfig";
|
|
10
11
|
import { B3Context, B3ContextType } from "./types";
|
|
11
12
|
|
|
12
13
|
/**
|
|
@@ -31,28 +32,32 @@ export function B3Provider({
|
|
|
31
32
|
accountOverride,
|
|
32
33
|
environment,
|
|
33
34
|
clientType = "socket",
|
|
35
|
+
partnerId,
|
|
36
|
+
rpcUrls,
|
|
34
37
|
}: {
|
|
35
38
|
theme: "light" | "dark";
|
|
36
39
|
children: React.ReactNode;
|
|
37
40
|
accountOverride?: Account;
|
|
38
41
|
environment: B3ContextType["environment"];
|
|
39
42
|
clientType?: ClientType;
|
|
43
|
+
partnerId: string;
|
|
44
|
+
rpcUrls?: Record<number, string>;
|
|
40
45
|
}) {
|
|
41
46
|
return (
|
|
42
|
-
<
|
|
43
|
-
<
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
</
|
|
54
|
-
</
|
|
55
|
-
</
|
|
47
|
+
<ThirdwebProvider>
|
|
48
|
+
<InnerProvider
|
|
49
|
+
accountOverride={accountOverride}
|
|
50
|
+
environment={environment}
|
|
51
|
+
theme={theme}
|
|
52
|
+
clientType={clientType}
|
|
53
|
+
partnerId={partnerId}
|
|
54
|
+
rpcUrls={rpcUrls}
|
|
55
|
+
>
|
|
56
|
+
{/* <RelayKitProviderWrapper> */}
|
|
57
|
+
{children}
|
|
58
|
+
{/* </RelayKitProviderWrapper> */}
|
|
59
|
+
</InnerProvider>
|
|
60
|
+
</ThirdwebProvider>
|
|
56
61
|
);
|
|
57
62
|
}
|
|
58
63
|
|
|
@@ -66,6 +71,8 @@ export function InnerProvider({
|
|
|
66
71
|
defaultPermissions = DEFAULT_PERMISSIONS,
|
|
67
72
|
theme = "light",
|
|
68
73
|
clientType = "socket",
|
|
74
|
+
partnerId,
|
|
75
|
+
rpcUrls,
|
|
69
76
|
}: {
|
|
70
77
|
children: React.ReactNode;
|
|
71
78
|
accountOverride?: Account;
|
|
@@ -73,31 +80,40 @@ export function InnerProvider({
|
|
|
73
80
|
defaultPermissions?: PermissionsConfig;
|
|
74
81
|
theme: "light" | "dark";
|
|
75
82
|
clientType?: ClientType;
|
|
83
|
+
partnerId: string;
|
|
84
|
+
rpcUrls?: Record<number, string>;
|
|
76
85
|
}) {
|
|
77
86
|
const activeAccount = useActiveAccount();
|
|
78
|
-
const
|
|
87
|
+
const { user, setUser, refetchUser } = useAuthentication(partnerId);
|
|
88
|
+
const wagmiConfig = useWagmiConfig(partnerId, rpcUrls);
|
|
79
89
|
|
|
80
90
|
// Use given accountOverride or activeAccount from thirdweb
|
|
81
91
|
const effectiveAccount = accountOverride || activeAccount;
|
|
82
92
|
|
|
83
93
|
return (
|
|
84
|
-
<
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
94
|
+
<WagmiProvider config={wagmiConfig}>
|
|
95
|
+
<QueryClientProvider client={queryClient}>
|
|
96
|
+
<B3Context.Provider
|
|
97
|
+
value={{
|
|
98
|
+
account: effectiveAccount,
|
|
99
|
+
automaticallySetFirstEoa: false,
|
|
100
|
+
setWallet: () => {},
|
|
101
|
+
wallet: undefined,
|
|
102
|
+
user,
|
|
103
|
+
setUser,
|
|
104
|
+
initialized: true,
|
|
105
|
+
ready: !!effectiveAccount,
|
|
106
|
+
environment,
|
|
107
|
+
defaultPermissions,
|
|
108
|
+
theme,
|
|
109
|
+
clientType,
|
|
110
|
+
partnerId,
|
|
111
|
+
refetchUser,
|
|
112
|
+
}}
|
|
113
|
+
>
|
|
114
|
+
{children}
|
|
115
|
+
</B3Context.Provider>
|
|
116
|
+
</QueryClientProvider>
|
|
117
|
+
</WagmiProvider>
|
|
102
118
|
);
|
|
103
119
|
}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
RelayKitProviderWrapper,
|
|
3
|
+
TooltipProvider,
|
|
4
|
+
useAuthentication,
|
|
5
|
+
useAuthStore,
|
|
6
|
+
} from "@b3dotfun/sdk/global-account/react";
|
|
7
|
+
import { useWagmiConfig } from "@b3dotfun/sdk/global-account/react/hooks/useWagmiConfig";
|
|
3
8
|
import { PermissionsConfig } from "@b3dotfun/sdk/global-account/types/permissions";
|
|
4
9
|
import { loadGA4Script } from "@b3dotfun/sdk/global-account/utils/analytics";
|
|
5
|
-
import { ecosystemWalletId } from "@b3dotfun/sdk/shared/constants";
|
|
6
|
-
import { supportedChains } from "@b3dotfun/sdk/shared/constants/chains/supported";
|
|
7
10
|
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
8
|
-
import { client } from "@b3dotfun/sdk/shared/utils/thirdweb";
|
|
9
11
|
import "@reservoir0x/relay-kit-ui/styles.css";
|
|
10
12
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
11
|
-
import {
|
|
12
|
-
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
13
|
+
import { useCallback, useEffect, useState } from "react";
|
|
13
14
|
import { Toaster } from "sonner";
|
|
14
15
|
import {
|
|
15
16
|
getLastAuthProvider,
|
|
@@ -19,7 +20,7 @@ import {
|
|
|
19
20
|
useSetActiveWallet,
|
|
20
21
|
} from "thirdweb/react";
|
|
21
22
|
import { Account, Wallet } from "thirdweb/wallets";
|
|
22
|
-
import {
|
|
23
|
+
import { WagmiProvider } from "wagmi";
|
|
23
24
|
import { ClientType, setClientType } from "../../../client-manager";
|
|
24
25
|
import { StyleRoot } from "../StyleRoot";
|
|
25
26
|
import { B3Context, B3ContextType } from "./types";
|
|
@@ -66,7 +67,7 @@ export function B3Provider({
|
|
|
66
67
|
};
|
|
67
68
|
clientType?: ClientType;
|
|
68
69
|
rpcUrls?: Record<number, string>;
|
|
69
|
-
partnerId
|
|
70
|
+
partnerId: string;
|
|
70
71
|
}) {
|
|
71
72
|
// Initialize Google Analytics on mount
|
|
72
73
|
useEffect(() => {
|
|
@@ -77,45 +78,11 @@ export function B3Provider({
|
|
|
77
78
|
useEffect(() => {
|
|
78
79
|
setClientType(clientType);
|
|
79
80
|
}, [clientType]);
|
|
80
|
-
|
|
81
|
-
const ecocystemConfig = useMemo(() => {
|
|
82
|
-
if (!partnerId) return undefined;
|
|
83
|
-
|
|
84
|
-
return {
|
|
85
|
-
ecosystemId: ecosystemWalletId,
|
|
86
|
-
partnerId: partnerId,
|
|
87
|
-
client,
|
|
88
|
-
};
|
|
89
|
-
}, [partnerId]);
|
|
90
|
-
|
|
91
|
-
// Stringify rpcUrls for stable comparison to prevent wagmiConfig recreation
|
|
92
|
-
// when parent component passes new object references with same content
|
|
93
|
-
const rpcUrlsString = useMemo(() => (rpcUrls ? JSON.stringify(rpcUrls) : undefined), [rpcUrls]);
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Creates wagmi config with optional custom RPC URLs
|
|
97
|
-
* @param rpcUrls - Optional mapping of chain IDs to RPC URLs
|
|
98
|
-
*/
|
|
99
|
-
const wagmiConfig = useMemo(() => {
|
|
100
|
-
const parsedRpcUrls = rpcUrlsString ? JSON.parse(rpcUrlsString) : undefined;
|
|
101
|
-
|
|
102
|
-
return createConfig({
|
|
103
|
-
chains: [supportedChains[0], ...supportedChains.slice(1)],
|
|
104
|
-
transports: Object.fromEntries(supportedChains.map(chain => [chain.id, http(parsedRpcUrls?.[chain.id])])),
|
|
105
|
-
connectors: [
|
|
106
|
-
inAppWalletConnector({
|
|
107
|
-
...(ecocystemConfig || {}),
|
|
108
|
-
client,
|
|
109
|
-
}),
|
|
110
|
-
// injected(),
|
|
111
|
-
// coinbaseWallet({ appName: "HypeDuel" }),
|
|
112
|
-
],
|
|
113
|
-
});
|
|
114
|
-
}, [ecocystemConfig, rpcUrlsString]);
|
|
81
|
+
const wagmiConfig = useWagmiConfig(partnerId, rpcUrls);
|
|
115
82
|
|
|
116
83
|
return (
|
|
117
84
|
<ThirdwebProvider>
|
|
118
|
-
<WagmiProvider config={wagmiConfig}>
|
|
85
|
+
<WagmiProvider config={wagmiConfig} reconnectOnMount={false}>
|
|
119
86
|
<QueryClientProvider client={queryClient}>
|
|
120
87
|
<TooltipProvider>
|
|
121
88
|
<InnerProvider
|
|
@@ -124,6 +91,7 @@ export function B3Provider({
|
|
|
124
91
|
theme={theme}
|
|
125
92
|
automaticallySetFirstEoa={!!automaticallySetFirstEoa}
|
|
126
93
|
clientType={clientType}
|
|
94
|
+
partnerId={partnerId}
|
|
127
95
|
>
|
|
128
96
|
<RelayKitProviderWrapper simDuneApiKey={simDuneApiKey}>
|
|
129
97
|
{children}
|
|
@@ -150,6 +118,7 @@ export function InnerProvider({
|
|
|
150
118
|
automaticallySetFirstEoa,
|
|
151
119
|
theme = "light",
|
|
152
120
|
clientType = "socket",
|
|
121
|
+
partnerId,
|
|
153
122
|
}: {
|
|
154
123
|
children: React.ReactNode;
|
|
155
124
|
accountOverride?: Account;
|
|
@@ -158,42 +127,23 @@ export function InnerProvider({
|
|
|
158
127
|
automaticallySetFirstEoa: boolean;
|
|
159
128
|
theme: "light" | "dark";
|
|
160
129
|
clientType?: ClientType;
|
|
130
|
+
partnerId: string;
|
|
161
131
|
}) {
|
|
162
132
|
const activeAccount = useActiveAccount();
|
|
163
133
|
const [manuallySelectedWallet, setManuallySelectedWallet] = useState<Wallet | undefined>(undefined);
|
|
164
134
|
const wallets = useConnectedWallets();
|
|
165
|
-
const setActiveWallet = useSetActiveWallet();
|
|
166
135
|
const isAuthenticated = useAuthStore(state => state.isAuthenticated);
|
|
167
|
-
|
|
136
|
+
const isConnected = useAuthStore(state => state.isConnected);
|
|
137
|
+
const setActiveWallet = useSetActiveWallet();
|
|
138
|
+
const { user, setUser, refetchUser } = useAuthentication(partnerId);
|
|
168
139
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
try {
|
|
173
|
-
const storedUser = localStorage.getItem("b3-user");
|
|
174
|
-
return storedUser ? JSON.parse(storedUser) : undefined;
|
|
175
|
-
} catch (error) {
|
|
176
|
-
console.warn("Failed to restore user from localStorage:", error);
|
|
177
|
-
return undefined;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
return undefined;
|
|
181
|
-
});
|
|
140
|
+
debug("@@B3Provider:isConnected", isConnected);
|
|
141
|
+
debug("@@wallets", wallets);
|
|
142
|
+
debug("@@B3Provider:user", user);
|
|
182
143
|
|
|
183
144
|
// Use given accountOverride or activeAccount from thirdweb
|
|
184
145
|
const effectiveAccount = isAuthenticated ? accountOverride || activeAccount : undefined;
|
|
185
146
|
|
|
186
|
-
// Persist user to localStorage when it changes
|
|
187
|
-
useEffect(() => {
|
|
188
|
-
if (typeof window !== "undefined") {
|
|
189
|
-
if (user) {
|
|
190
|
-
localStorage.setItem("b3-user", JSON.stringify(user));
|
|
191
|
-
} else {
|
|
192
|
-
localStorage.removeItem("b3-user");
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}, [user]);
|
|
196
|
-
|
|
197
147
|
const setWallet = useCallback(
|
|
198
148
|
(wallet: Wallet) => {
|
|
199
149
|
setManuallySelectedWallet(wallet);
|
|
@@ -237,6 +187,7 @@ export function InnerProvider({
|
|
|
237
187
|
wallet: manuallySelectedWallet,
|
|
238
188
|
user,
|
|
239
189
|
setUser,
|
|
190
|
+
refetchUser,
|
|
240
191
|
initialized: true,
|
|
241
192
|
ready: !!effectiveAccount,
|
|
242
193
|
automaticallySetFirstEoa,
|
|
@@ -244,9 +195,14 @@ export function InnerProvider({
|
|
|
244
195
|
defaultPermissions,
|
|
245
196
|
theme,
|
|
246
197
|
clientType,
|
|
198
|
+
partnerId: partnerId,
|
|
247
199
|
}}
|
|
248
200
|
>
|
|
249
|
-
{children}
|
|
201
|
+
<InnerProvider2>{children}</InnerProvider2>
|
|
250
202
|
</B3Context.Provider>
|
|
251
203
|
);
|
|
252
204
|
}
|
|
205
|
+
|
|
206
|
+
const InnerProvider2 = ({ children }: { children: React.ReactNode }) => {
|
|
207
|
+
return <>{children}</>;
|
|
208
|
+
};
|
|
@@ -14,12 +14,14 @@ export interface B3ContextType {
|
|
|
14
14
|
setWallet: (wallet: Wallet) => void;
|
|
15
15
|
wallet?: Wallet;
|
|
16
16
|
setUser: (user?: Users) => void;
|
|
17
|
+
refetchUser: () => Promise<any>;
|
|
17
18
|
initialized: boolean;
|
|
18
19
|
ready: boolean;
|
|
19
20
|
environment?: "development" | "production";
|
|
20
21
|
defaultPermissions?: PermissionsConfig;
|
|
21
22
|
theme: "light" | "dark";
|
|
22
23
|
clientType: ClientType;
|
|
24
|
+
partnerId: string;
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
/**
|
|
@@ -32,9 +34,11 @@ export const B3Context = createContext<B3ContextType>({
|
|
|
32
34
|
setWallet: () => {},
|
|
33
35
|
wallet: undefined,
|
|
34
36
|
setUser: () => {},
|
|
37
|
+
refetchUser: async () => {},
|
|
35
38
|
initialized: false,
|
|
36
39
|
ready: false,
|
|
37
40
|
environment: "development",
|
|
38
41
|
theme: "light",
|
|
39
42
|
clientType: "rest",
|
|
43
|
+
partnerId: "",
|
|
40
44
|
});
|
|
@@ -23,7 +23,6 @@ import { TokenBalanceRow } from "./TokenBalanceRow";
|
|
|
23
23
|
|
|
24
24
|
interface BalanceContentProps {
|
|
25
25
|
onLogout?: () => void;
|
|
26
|
-
partnerId: string;
|
|
27
26
|
showDeposit?: boolean;
|
|
28
27
|
showSwap?: boolean;
|
|
29
28
|
}
|
|
@@ -33,14 +32,14 @@ function centerTruncate(str: string, length = 4) {
|
|
|
33
32
|
return `${str.slice(0, length)}...${str.slice(-length)}`;
|
|
34
33
|
}
|
|
35
34
|
|
|
36
|
-
export function BalanceContent({ onLogout,
|
|
35
|
+
export function BalanceContent({ onLogout, showDeposit = true, showSwap = true }: BalanceContentProps) {
|
|
37
36
|
const account = useActiveAccount();
|
|
38
37
|
const { address: eoaAddress, info: eoaInfo } = useFirstEOA();
|
|
39
38
|
const { data: profile } = useProfile({
|
|
40
39
|
address: eoaAddress || account?.address,
|
|
41
40
|
fresh: true,
|
|
42
41
|
});
|
|
43
|
-
const { user } = useB3();
|
|
42
|
+
const { user, partnerId } = useB3();
|
|
44
43
|
const { setB3ModalOpen, setB3ModalContentType, navigateBack } = useModalStore();
|
|
45
44
|
const { logout } = useAuthentication(partnerId);
|
|
46
45
|
const [logoutLoading, setLogoutLoading] = useState(false);
|
|
@@ -604,7 +604,7 @@ export function ManageAccount({
|
|
|
604
604
|
</div>
|
|
605
605
|
|
|
606
606
|
<TabsContentPrimitive value="overview" className="px-4 pb-4 pt-2">
|
|
607
|
-
<BalanceContent onLogout={onLogout}
|
|
607
|
+
<BalanceContent onLogout={onLogout} showDeposit={showDeposit} showSwap={showSwap} />
|
|
608
608
|
</TabsContentPrimitive>
|
|
609
609
|
|
|
610
610
|
<TabsContentPrimitive value="tokens" className="px-4 pb-4 pt-2">
|
|
@@ -29,7 +29,7 @@ type SignInWithB3Props = Omit<SignInWithB3ModalProps, "type" | "showBackButton">
|
|
|
29
29
|
|
|
30
30
|
export function SignIn(props: SignInWithB3Props) {
|
|
31
31
|
const { className } = props;
|
|
32
|
-
const { automaticallySetFirstEoa } = useB3();
|
|
32
|
+
const { automaticallySetFirstEoa, partnerId } = useB3();
|
|
33
33
|
const {
|
|
34
34
|
wallet,
|
|
35
35
|
address: globalAddress,
|
|
@@ -43,7 +43,7 @@ export function SignIn(props: SignInWithB3Props) {
|
|
|
43
43
|
} = useAccountWallet();
|
|
44
44
|
|
|
45
45
|
const isMobile = useIsMobile();
|
|
46
|
-
const { logout } = useAuthentication(
|
|
46
|
+
const { logout } = useAuthentication(partnerId);
|
|
47
47
|
const onDisconnect = async () => {
|
|
48
48
|
await logout();
|
|
49
49
|
};
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
Button,
|
|
3
3
|
SignInWithB3ModalProps,
|
|
4
4
|
StyleRoot,
|
|
5
|
-
|
|
5
|
+
useAuthStore,
|
|
6
6
|
useB3,
|
|
7
7
|
useIsMobile,
|
|
8
8
|
useModalStore,
|
|
@@ -21,7 +21,7 @@ export type SignInWithB3Props = Omit<SignInWithB3ModalProps, "type" | "showBackB
|
|
|
21
21
|
export function SignInWithB3(props: SignInWithB3Props) {
|
|
22
22
|
const { setB3ModalOpen, setB3ModalContentType, setEcoSystemAccountAddress } = useModalStore();
|
|
23
23
|
const { account } = useB3();
|
|
24
|
-
const { isAuthenticating, isAuthenticated } =
|
|
24
|
+
const { isAuthenticating, isAuthenticated } = useAuthStore();
|
|
25
25
|
const isMobile = useIsMobile();
|
|
26
26
|
|
|
27
27
|
useEffect(() => {
|