@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
package/README.md
CHANGED
|
@@ -8,6 +8,7 @@ The SDK is organized into focused modules:
|
|
|
8
8
|
|
|
9
9
|
- **`anyspend/`** - Cross-chain execution engine functionality
|
|
10
10
|
- **`global-account/`** - B3 Global Accounts authentication and user management
|
|
11
|
+
- **`notifications/`** - Multi-channel notification management
|
|
11
12
|
- **`shared/`** - Common utilities, types, and components
|
|
12
13
|
- **`others/`** - Additional features and utilities
|
|
13
14
|
|
|
@@ -25,6 +26,7 @@ Each module contains:
|
|
|
25
26
|
| ----------------- | --------- | ------------ |
|
|
26
27
|
| AnySpend | ✅ | ❌ |
|
|
27
28
|
| Global Accounts | ✅ | ✅ |
|
|
29
|
+
| Notifications | ✅ | ✅ |
|
|
28
30
|
| Headless Services | ✅ | ✅ |
|
|
29
31
|
|
|
30
32
|
## Installation
|
|
@@ -155,9 +157,7 @@ const order = await anyspendService.createOrder({
|
|
|
155
157
|
import { anyspendService } from "@b3dotfun/sdk/anyspend/services/anyspend";
|
|
156
158
|
|
|
157
159
|
// Get order details and transactions
|
|
158
|
-
const orderDetails = await anyspendService.getOrderAndTransactions(
|
|
159
|
-
"order-id",
|
|
160
|
-
);
|
|
160
|
+
const orderDetails = await anyspendService.getOrderAndTransactions("order-id");
|
|
161
161
|
|
|
162
162
|
// Get order history for an address
|
|
163
163
|
const history = await anyspendService.getOrderHistory(
|
|
@@ -196,7 +196,7 @@ import { B3Provider, SignInWithB3 } from "@b3dotfun/sdk/global-account/react";
|
|
|
196
196
|
|
|
197
197
|
function App() {
|
|
198
198
|
return (
|
|
199
|
-
<B3Provider environment="production">
|
|
199
|
+
<B3Provider environment="production" partnerId="your-awesome-partner-id">
|
|
200
200
|
<SignInWithB3
|
|
201
201
|
provider={{ strategy: "google" }}
|
|
202
202
|
partnerId="your-partner-id"
|
|
@@ -223,7 +223,7 @@ const b3Chain = {
|
|
|
223
223
|
|
|
224
224
|
function SessionKeyAuth() {
|
|
225
225
|
return (
|
|
226
|
-
<B3Provider environment="production">
|
|
226
|
+
<B3Provider environment="production" partnerId="your-awesome-partner-id">
|
|
227
227
|
<SignInWithB3
|
|
228
228
|
provider={{ strategy: "google" }}
|
|
229
229
|
chain={b3Chain}
|
|
@@ -323,6 +323,206 @@ import { serverFunction } from "@b3dotfun/sdk/global-account/server";
|
|
|
323
323
|
// (Implementation depends on your specific needs)
|
|
324
324
|
```
|
|
325
325
|
|
|
326
|
+
# Notifications
|
|
327
|
+
|
|
328
|
+
B3 Notifications provides multi-channel notification management for your users with support for email, Telegram, Discord, SMS, WhatsApp, and in-app notifications.
|
|
329
|
+
|
|
330
|
+
## Features
|
|
331
|
+
|
|
332
|
+
- ✅ **Zero Config** - Automatically uses authenticated user's ID from JWT
|
|
333
|
+
- 🎯 **Type Safe** - Full TypeScript support
|
|
334
|
+
- ⚡ **React Hooks** - Easy integration with `useNotifications()` hook
|
|
335
|
+
- 🔐 **Secure** - JWT-based authentication
|
|
336
|
+
- 📱 **Multi-Channel** - Email, Telegram, Discord, SMS, WhatsApp, In-app
|
|
337
|
+
- 🚀 **Lightweight** - Minimal dependencies
|
|
338
|
+
|
|
339
|
+
## React Hook
|
|
340
|
+
|
|
341
|
+
### Basic Usage
|
|
342
|
+
|
|
343
|
+
```tsx
|
|
344
|
+
import { useNotifications } from "@b3dotfun/sdk/notifications/react";
|
|
345
|
+
|
|
346
|
+
function NotificationSettings() {
|
|
347
|
+
const { user, loading, connectEmail, connectTelegram, isEmailConnected } = useNotifications();
|
|
348
|
+
|
|
349
|
+
if (loading) return <div>Loading...</div>;
|
|
350
|
+
|
|
351
|
+
return (
|
|
352
|
+
<div>
|
|
353
|
+
{!isEmailConnected && <button onClick={() => connectEmail("user@example.com")}>Connect Email</button>}
|
|
354
|
+
|
|
355
|
+
<button onClick={connectTelegram}>Connect Telegram</button>
|
|
356
|
+
</div>
|
|
357
|
+
);
|
|
358
|
+
}
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
### Full Hook API
|
|
362
|
+
|
|
363
|
+
```tsx
|
|
364
|
+
const {
|
|
365
|
+
user, // User data with channels and settings
|
|
366
|
+
loading, // Loading state
|
|
367
|
+
error, // Error if any
|
|
368
|
+
refresh, // Manually refresh user data
|
|
369
|
+
connectEmail, // Connect email channel
|
|
370
|
+
connectTelegram, // Connect Telegram channel
|
|
371
|
+
updateChannel, // Update a channel
|
|
372
|
+
deleteChannel, // Delete a channel
|
|
373
|
+
// Convenience helpers
|
|
374
|
+
isEmailConnected,
|
|
375
|
+
isTelegramConnected,
|
|
376
|
+
isDiscordConnected,
|
|
377
|
+
} = useNotifications();
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
## Headless API Client
|
|
381
|
+
|
|
382
|
+
### Authentication
|
|
383
|
+
|
|
384
|
+
The notifications API automatically uses the B3 auth token from cookies. The token is managed by the B3 Global Account authentication system - you don't need to set it manually.
|
|
385
|
+
|
|
386
|
+
```typescript
|
|
387
|
+
import { getAuthToken, notificationsAPI } from "@b3dotfun/sdk/notifications";
|
|
388
|
+
// Or import from shared utils
|
|
389
|
+
// import { getAuthToken } from "@b3dotfun/sdk/shared/utils";
|
|
390
|
+
|
|
391
|
+
// Get the current auth token (from b3-auth cookie)
|
|
392
|
+
const token = getAuthToken();
|
|
393
|
+
|
|
394
|
+
// API calls automatically use the auth token
|
|
395
|
+
const userData = await notificationsAPI.getUser();
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
### User Management
|
|
399
|
+
|
|
400
|
+
```typescript
|
|
401
|
+
import { notificationsAPI } from "@b3dotfun/sdk/notifications";
|
|
402
|
+
|
|
403
|
+
// Register current user
|
|
404
|
+
await notificationsAPI.registerUser();
|
|
405
|
+
|
|
406
|
+
// Get current user's profile
|
|
407
|
+
const userData = await notificationsAPI.getUser();
|
|
408
|
+
|
|
409
|
+
// Get notification history
|
|
410
|
+
const history = await notificationsAPI.getHistory("my-app-id", 50);
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
### Channel Management
|
|
414
|
+
|
|
415
|
+
```typescript
|
|
416
|
+
// Add any channel
|
|
417
|
+
await notificationsAPI.addChannel("email", "user@example.com");
|
|
418
|
+
|
|
419
|
+
// Connect email (shorthand)
|
|
420
|
+
await notificationsAPI.connectEmail("user@example.com");
|
|
421
|
+
|
|
422
|
+
// Update channel
|
|
423
|
+
await notificationsAPI.updateChannel("channel-id", {
|
|
424
|
+
enabled: true,
|
|
425
|
+
});
|
|
426
|
+
|
|
427
|
+
// Delete channel
|
|
428
|
+
await notificationsAPI.deleteChannel("channel-id");
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
### Telegram Integration
|
|
432
|
+
|
|
433
|
+
```typescript
|
|
434
|
+
// Get Telegram deep link
|
|
435
|
+
const { deepLink, verificationCode, botUsername } = await notificationsAPI.getTelegramLink();
|
|
436
|
+
window.open(deepLink, "_blank");
|
|
437
|
+
|
|
438
|
+
// Check connection status
|
|
439
|
+
const { connected, chatId } = await notificationsAPI.checkTelegramStatus();
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
### App Preferences
|
|
443
|
+
|
|
444
|
+
```typescript
|
|
445
|
+
// Save notification preferences for an app (enabled by default)
|
|
446
|
+
await notificationsAPI.savePreferences("my-app", {
|
|
447
|
+
notificationType: "transaction",
|
|
448
|
+
channels: ["email", "telegram", "in_app"],
|
|
449
|
+
});
|
|
450
|
+
|
|
451
|
+
// Save disabled preferences
|
|
452
|
+
await notificationsAPI.savePreferences("my-app", {
|
|
453
|
+
notificationType: "transaction",
|
|
454
|
+
channels: ["email", "telegram"],
|
|
455
|
+
enabled: false,
|
|
456
|
+
});
|
|
457
|
+
|
|
458
|
+
// Get app settings
|
|
459
|
+
const settings = await notificationsAPI.getAppSettings("my-app");
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
### In-App Notifications
|
|
463
|
+
|
|
464
|
+
```typescript
|
|
465
|
+
// Get in-app notifications
|
|
466
|
+
const { notifications } = await notificationsAPI.getInAppNotifications();
|
|
467
|
+
|
|
468
|
+
// Mark notification as read
|
|
469
|
+
await notificationsAPI.markNotificationAsRead("notification-id");
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
### Send Notifications
|
|
473
|
+
|
|
474
|
+
```typescript
|
|
475
|
+
// Send a notification
|
|
476
|
+
await notificationsAPI.sendNotification({
|
|
477
|
+
userId: "user-123",
|
|
478
|
+
appId: "my-app",
|
|
479
|
+
notificationType: "transaction",
|
|
480
|
+
message: "Your transaction was successful!",
|
|
481
|
+
title: "Transaction Complete",
|
|
482
|
+
data: { transactionId: "tx-123" },
|
|
483
|
+
});
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
## Next.js Example
|
|
487
|
+
|
|
488
|
+
```tsx
|
|
489
|
+
"use client";
|
|
490
|
+
|
|
491
|
+
import { useNotifications } from "@b3dotfun/sdk/notifications/react";
|
|
492
|
+
|
|
493
|
+
export default function NotificationsPage() {
|
|
494
|
+
const { user, loading, connectEmail, connectTelegram, isEmailConnected, isTelegramConnected } = useNotifications();
|
|
495
|
+
|
|
496
|
+
if (loading) {
|
|
497
|
+
return <div>Loading notification settings...</div>;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
return (
|
|
501
|
+
<div className="space-y-4">
|
|
502
|
+
<h1>Notification Settings</h1>
|
|
503
|
+
|
|
504
|
+
<div className="rounded-lg border p-4">
|
|
505
|
+
<h2>Email</h2>
|
|
506
|
+
{isEmailConnected ? (
|
|
507
|
+
<p className="text-green-600">✓ Connected</p>
|
|
508
|
+
) : (
|
|
509
|
+
<button onClick={() => connectEmail("user@example.com")}>Connect Email</button>
|
|
510
|
+
)}
|
|
511
|
+
</div>
|
|
512
|
+
|
|
513
|
+
<div className="rounded-lg border p-4">
|
|
514
|
+
<h2>Telegram</h2>
|
|
515
|
+
{isTelegramConnected ? (
|
|
516
|
+
<p className="text-green-600">✓ Connected</p>
|
|
517
|
+
) : (
|
|
518
|
+
<button onClick={connectTelegram}>Connect Telegram</button>
|
|
519
|
+
)}
|
|
520
|
+
</div>
|
|
521
|
+
</div>
|
|
522
|
+
);
|
|
523
|
+
}
|
|
524
|
+
```
|
|
525
|
+
|
|
326
526
|
# Shared Utilities
|
|
327
527
|
|
|
328
528
|
## Chain Management
|
|
@@ -338,6 +538,25 @@ console.log(supportedChains);
|
|
|
338
538
|
console.log(b3Chain);
|
|
339
539
|
```
|
|
340
540
|
|
|
541
|
+
## Authentication Token Management
|
|
542
|
+
|
|
543
|
+
Read-only access to the B3 authentication token. The token is managed by the B3 Global Account authentication system.
|
|
544
|
+
|
|
545
|
+
```typescript
|
|
546
|
+
import { getAuthToken } from "@b3dotfun/sdk/shared/utils";
|
|
547
|
+
|
|
548
|
+
// Get the current auth token from the b3-auth cookie
|
|
549
|
+
const token = getAuthToken();
|
|
550
|
+
|
|
551
|
+
if (token) {
|
|
552
|
+
console.log("User is authenticated");
|
|
553
|
+
} else {
|
|
554
|
+
console.log("User is not authenticated");
|
|
555
|
+
}
|
|
556
|
+
```
|
|
557
|
+
|
|
558
|
+
The auth token is automatically set by the B3 Global Account authentication system (see the Global Accounts section above). All SDK modules that require authentication will automatically use this token.
|
|
559
|
+
|
|
341
560
|
## Utility Functions
|
|
342
561
|
|
|
343
562
|
```typescript
|
|
@@ -368,7 +587,7 @@ import B3DynamicModal from "@b3dotfun/sdk/global-account/react/components/B3Dyna
|
|
|
368
587
|
|
|
369
588
|
function App() {
|
|
370
589
|
return (
|
|
371
|
-
<B3Provider environment="production">
|
|
590
|
+
<B3Provider environment="production" partnerId="your-awesome-partner-id">
|
|
372
591
|
<YourApp />
|
|
373
592
|
<B3DynamicModal />
|
|
374
593
|
</B3Provider>
|
|
@@ -273,11 +273,13 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
273
273
|
(0, react_4.useEffect)(() => {
|
|
274
274
|
if (oat?.data?.order.status === "executed" && !onSuccessCalled.current) {
|
|
275
275
|
console.log("Calling onSuccess");
|
|
276
|
-
const
|
|
276
|
+
const relayTxs = oat?.data?.relayTxs;
|
|
277
|
+
const lastRelayTxHash = relayTxs?.[relayTxs.length - 1]?.txHash;
|
|
278
|
+
const txHash = oat?.data?.executeTx?.txHash || lastRelayTxHash;
|
|
277
279
|
onSuccess?.(txHash);
|
|
278
280
|
onSuccessCalled.current = true;
|
|
279
281
|
}
|
|
280
|
-
}, [oat?.data?.order.status, oat?.data?.executeTx?.txHash, onSuccess]);
|
|
282
|
+
}, [oat?.data?.order.status, oat?.data?.executeTx?.txHash, oat?.data?.relayTxs, onSuccess]);
|
|
281
283
|
// Reset flag when orderId changes
|
|
282
284
|
(0, react_4.useEffect)(() => {
|
|
283
285
|
onSuccessCalled.current = false;
|
|
@@ -467,7 +469,7 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
467
469
|
const historyView = ((0, jsx_runtime_1.jsx)("div", { className: (0, utils_1.cn)("mx-auto flex w-full max-w-2xl flex-col items-center p-5", mode === "modal" && "bg-b3-react-background"), children: (0, jsx_runtime_1.jsx)(OrderHistory_1.OrderHistory, { mode: mode, onBack: () => {
|
|
468
470
|
setActivePanel(PanelView.HISTORY);
|
|
469
471
|
}, onSelectOrder: onSelectOrder }) }));
|
|
470
|
-
const orderDetailsView = ((0, jsx_runtime_1.jsxs)("div", { className: (0, utils_1.cn)("mx-auto flex w-full flex-col items-center gap-4", mode === "modal" && "bg-b3-react-background rounded-xl"), children: [oat && ((0, jsx_runtime_1.jsx)(OrderDetails_1.OrderDetails, { mode: mode, order: oat.data.order, depositTxs: oat.data.depositTxs, relayTxs: oat.data.relayTxs, executeTx: oat.data.executeTx, refundTxs: oat.data.refundTxs, cryptoPaymentMethod: activeTab === "fiat" ? CryptoPaymentMethod_1.CryptoPaymentMethodType.NONE : selectedCryptoPaymentMethod, selectedCryptoPaymentMethod: selectedCryptoPaymentMethod, onPaymentMethodChange: setSelectedCryptoPaymentMethod, onBack: () => {
|
|
472
|
+
const orderDetailsView = ((0, jsx_runtime_1.jsxs)("div", { className: (0, utils_1.cn)("mx-auto flex w-full flex-col items-center gap-4 p-5", mode === "modal" && "bg-b3-react-background rounded-xl"), children: [oat && ((0, jsx_runtime_1.jsx)(OrderDetails_1.OrderDetails, { mode: mode, order: oat.data.order, depositTxs: oat.data.depositTxs, relayTxs: oat.data.relayTxs, executeTx: oat.data.executeTx, refundTxs: oat.data.refundTxs, cryptoPaymentMethod: activeTab === "fiat" ? CryptoPaymentMethod_1.CryptoPaymentMethodType.NONE : selectedCryptoPaymentMethod, selectedCryptoPaymentMethod: selectedCryptoPaymentMethod, onPaymentMethodChange: setSelectedCryptoPaymentMethod, onBack: () => {
|
|
471
473
|
setOrderId(undefined);
|
|
472
474
|
setActivePanel(PanelView.CONFIRM_ORDER);
|
|
473
475
|
// Remove orderId from URL when canceling
|
|
@@ -19,12 +19,12 @@ export declare function B3Provider({ theme, children, accountOverride, environme
|
|
|
19
19
|
};
|
|
20
20
|
clientType?: ClientType;
|
|
21
21
|
rpcUrls?: Record<number, string>;
|
|
22
|
-
partnerId
|
|
22
|
+
partnerId: string;
|
|
23
23
|
}): import("react/jsx-runtime").JSX.Element;
|
|
24
24
|
/**
|
|
25
25
|
* Inner provider component that provides the actual B3Context
|
|
26
26
|
*/
|
|
27
|
-
export declare function InnerProvider({ children, accountOverride, environment, defaultPermissions, automaticallySetFirstEoa, theme, clientType, }: {
|
|
27
|
+
export declare function InnerProvider({ children, accountOverride, environment, defaultPermissions, automaticallySetFirstEoa, theme, clientType, partnerId, }: {
|
|
28
28
|
children: React.ReactNode;
|
|
29
29
|
accountOverride?: Account;
|
|
30
30
|
environment: B3ContextType["environment"];
|
|
@@ -32,4 +32,5 @@ export declare function InnerProvider({ children, accountOverride, environment,
|
|
|
32
32
|
automaticallySetFirstEoa: boolean;
|
|
33
33
|
theme: "light" | "dark";
|
|
34
34
|
clientType?: ClientType;
|
|
35
|
+
partnerId: string;
|
|
35
36
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -4,14 +4,11 @@ exports.B3Provider = B3Provider;
|
|
|
4
4
|
exports.InnerProvider = InnerProvider;
|
|
5
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
6
|
const react_1 = require("../../../../global-account/react");
|
|
7
|
+
const useWagmiConfig_1 = require("../../../../global-account/react/hooks/useWagmiConfig");
|
|
7
8
|
const analytics_1 = require("../../../../global-account/utils/analytics");
|
|
8
|
-
const constants_1 = require("../../../../shared/constants");
|
|
9
|
-
const supported_1 = require("../../../../shared/constants/chains/supported");
|
|
10
9
|
const debug_1 = require("../../../../shared/utils/debug");
|
|
11
|
-
const thirdweb_1 = require("../../../../shared/utils/thirdweb");
|
|
12
10
|
require("@reservoir0x/relay-kit-ui/styles.css");
|
|
13
11
|
const react_query_1 = require("@tanstack/react-query");
|
|
14
|
-
const wagmi_adapter_1 = require("@thirdweb-dev/wagmi-adapter");
|
|
15
12
|
const react_2 = require("react");
|
|
16
13
|
const sonner_1 = require("sonner");
|
|
17
14
|
const react_3 = require("thirdweb/react");
|
|
@@ -43,76 +40,25 @@ function B3Provider({ theme = "light", children, accountOverride, environment, a
|
|
|
43
40
|
(0, react_2.useEffect)(() => {
|
|
44
41
|
(0, client_manager_1.setClientType)(clientType);
|
|
45
42
|
}, [clientType]);
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
return undefined;
|
|
49
|
-
return {
|
|
50
|
-
ecosystemId: constants_1.ecosystemWalletId,
|
|
51
|
-
partnerId: partnerId,
|
|
52
|
-
client: thirdweb_1.client,
|
|
53
|
-
};
|
|
54
|
-
}, [partnerId]);
|
|
55
|
-
// Stringify rpcUrls for stable comparison to prevent wagmiConfig recreation
|
|
56
|
-
// when parent component passes new object references with same content
|
|
57
|
-
const rpcUrlsString = (0, react_2.useMemo)(() => (rpcUrls ? JSON.stringify(rpcUrls) : undefined), [rpcUrls]);
|
|
58
|
-
/**
|
|
59
|
-
* Creates wagmi config with optional custom RPC URLs
|
|
60
|
-
* @param rpcUrls - Optional mapping of chain IDs to RPC URLs
|
|
61
|
-
*/
|
|
62
|
-
const wagmiConfig = (0, react_2.useMemo)(() => {
|
|
63
|
-
const parsedRpcUrls = rpcUrlsString ? JSON.parse(rpcUrlsString) : undefined;
|
|
64
|
-
return (0, wagmi_1.createConfig)({
|
|
65
|
-
chains: [supported_1.supportedChains[0], ...supported_1.supportedChains.slice(1)],
|
|
66
|
-
transports: Object.fromEntries(supported_1.supportedChains.map(chain => [chain.id, (0, wagmi_1.http)(parsedRpcUrls?.[chain.id])])),
|
|
67
|
-
connectors: [
|
|
68
|
-
(0, wagmi_adapter_1.inAppWalletConnector)({
|
|
69
|
-
...(ecocystemConfig || {}),
|
|
70
|
-
client: thirdweb_1.client,
|
|
71
|
-
}),
|
|
72
|
-
// injected(),
|
|
73
|
-
// coinbaseWallet({ appName: "HypeDuel" }),
|
|
74
|
-
],
|
|
75
|
-
});
|
|
76
|
-
}, [ecocystemConfig, rpcUrlsString]);
|
|
77
|
-
return ((0, jsx_runtime_1.jsx)(react_3.ThirdwebProvider, { children: (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)(react_1.TooltipProvider, { children: (0, jsx_runtime_1.jsx)(InnerProvider, { accountOverride: accountOverride, environment: environment, theme: theme, automaticallySetFirstEoa: !!automaticallySetFirstEoa, clientType: clientType, children: (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)(sonner_1.Toaster, { theme: theme, position: toaster?.position, style: toaster?.style })] }) }) }) }) }) }));
|
|
43
|
+
const wagmiConfig = (0, useWagmiConfig_1.useWagmiConfig)(partnerId, rpcUrls);
|
|
44
|
+
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)(InnerProvider, { accountOverride: accountOverride, environment: environment, theme: theme, automaticallySetFirstEoa: !!automaticallySetFirstEoa, clientType: clientType, partnerId: partnerId, children: (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)(sonner_1.Toaster, { theme: theme, position: toaster?.position, style: toaster?.style })] }) }) }) }) }) }));
|
|
78
45
|
}
|
|
79
46
|
/**
|
|
80
47
|
* Inner provider component that provides the actual B3Context
|
|
81
48
|
*/
|
|
82
|
-
function InnerProvider({ children, accountOverride, environment, defaultPermissions = DEFAULT_PERMISSIONS, automaticallySetFirstEoa, theme = "light", clientType = "socket", }) {
|
|
49
|
+
function InnerProvider({ children, accountOverride, environment, defaultPermissions = DEFAULT_PERMISSIONS, automaticallySetFirstEoa, theme = "light", clientType = "socket", partnerId, }) {
|
|
83
50
|
const activeAccount = (0, react_3.useActiveAccount)();
|
|
84
51
|
const [manuallySelectedWallet, setManuallySelectedWallet] = (0, react_2.useState)(undefined);
|
|
85
52
|
const wallets = (0, react_3.useConnectedWallets)();
|
|
86
|
-
const setActiveWallet = (0, react_3.useSetActiveWallet)();
|
|
87
53
|
const isAuthenticated = (0, react_1.useAuthStore)(state => state.isAuthenticated);
|
|
54
|
+
const isConnected = (0, react_1.useAuthStore)(state => state.isConnected);
|
|
55
|
+
const setActiveWallet = (0, react_3.useSetActiveWallet)();
|
|
56
|
+
const { user, setUser, refetchUser } = (0, react_1.useAuthentication)(partnerId);
|
|
57
|
+
debug("@@B3Provider:isConnected", isConnected);
|
|
88
58
|
debug("@@wallets", wallets);
|
|
89
|
-
|
|
90
|
-
// Try to restore user from localStorage on initialization
|
|
91
|
-
if (typeof window !== "undefined") {
|
|
92
|
-
try {
|
|
93
|
-
const storedUser = localStorage.getItem("b3-user");
|
|
94
|
-
return storedUser ? JSON.parse(storedUser) : undefined;
|
|
95
|
-
}
|
|
96
|
-
catch (error) {
|
|
97
|
-
console.warn("Failed to restore user from localStorage:", error);
|
|
98
|
-
return undefined;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return undefined;
|
|
102
|
-
});
|
|
59
|
+
debug("@@B3Provider:user", user);
|
|
103
60
|
// Use given accountOverride or activeAccount from thirdweb
|
|
104
61
|
const effectiveAccount = isAuthenticated ? accountOverride || activeAccount : undefined;
|
|
105
|
-
// Persist user to localStorage when it changes
|
|
106
|
-
(0, react_2.useEffect)(() => {
|
|
107
|
-
if (typeof window !== "undefined") {
|
|
108
|
-
if (user) {
|
|
109
|
-
localStorage.setItem("b3-user", JSON.stringify(user));
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
localStorage.removeItem("b3-user");
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}, [user]);
|
|
116
62
|
const setWallet = (0, react_2.useCallback)((wallet) => {
|
|
117
63
|
setManuallySelectedWallet(wallet);
|
|
118
64
|
const account = wallet.getAccount();
|
|
@@ -145,6 +91,7 @@ function InnerProvider({ children, accountOverride, environment, defaultPermissi
|
|
|
145
91
|
wallet: manuallySelectedWallet,
|
|
146
92
|
user,
|
|
147
93
|
setUser,
|
|
94
|
+
refetchUser,
|
|
148
95
|
initialized: true,
|
|
149
96
|
ready: !!effectiveAccount,
|
|
150
97
|
automaticallySetFirstEoa,
|
|
@@ -152,5 +99,9 @@ function InnerProvider({ children, accountOverride, environment, defaultPermissi
|
|
|
152
99
|
defaultPermissions,
|
|
153
100
|
theme,
|
|
154
101
|
clientType,
|
|
155
|
-
|
|
102
|
+
partnerId: partnerId,
|
|
103
|
+
}, children: (0, jsx_runtime_1.jsx)(InnerProvider2, { children: children }) }));
|
|
156
104
|
}
|
|
105
|
+
const InnerProvider2 = ({ children }) => {
|
|
106
|
+
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children });
|
|
107
|
+
};
|
|
@@ -5,21 +5,25 @@ import { B3ContextType } from "./types";
|
|
|
5
5
|
/**
|
|
6
6
|
* Main B3Provider component
|
|
7
7
|
*/
|
|
8
|
-
export declare function B3Provider({ theme, children, accountOverride, environment, clientType, }: {
|
|
8
|
+
export declare function B3Provider({ theme, children, accountOverride, environment, clientType, partnerId, rpcUrls, }: {
|
|
9
9
|
theme: "light" | "dark";
|
|
10
10
|
children: React.ReactNode;
|
|
11
11
|
accountOverride?: Account;
|
|
12
12
|
environment: B3ContextType["environment"];
|
|
13
13
|
clientType?: ClientType;
|
|
14
|
+
partnerId: string;
|
|
15
|
+
rpcUrls?: Record<number, string>;
|
|
14
16
|
}): import("react/jsx-runtime").JSX.Element;
|
|
15
17
|
/**
|
|
16
18
|
* Inner provider component that provides the actual B3Context
|
|
17
19
|
*/
|
|
18
|
-
export declare function InnerProvider({ children, accountOverride, environment, defaultPermissions, theme, clientType, }: {
|
|
20
|
+
export declare function InnerProvider({ children, accountOverride, environment, defaultPermissions, theme, clientType, partnerId, rpcUrls, }: {
|
|
19
21
|
children: React.ReactNode;
|
|
20
22
|
accountOverride?: Account;
|
|
21
23
|
environment: B3ContextType["environment"];
|
|
22
24
|
defaultPermissions?: PermissionsConfig;
|
|
23
25
|
theme: "light" | "dark";
|
|
24
26
|
clientType?: ClientType;
|
|
27
|
+
partnerId: string;
|
|
28
|
+
rpcUrls?: Record<number, string>;
|
|
25
29
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -4,8 +4,10 @@ exports.B3Provider = B3Provider;
|
|
|
4
4
|
exports.InnerProvider = InnerProvider;
|
|
5
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
6
|
const react_query_1 = require("@tanstack/react-query");
|
|
7
|
-
const react_1 = require("react");
|
|
8
|
-
const
|
|
7
|
+
const react_1 = require("thirdweb/react");
|
|
8
|
+
const wagmi_1 = require("wagmi");
|
|
9
|
+
const useAuthentication_1 = require("../../hooks/useAuthentication");
|
|
10
|
+
const useWagmiConfig_1 = require("../../hooks/useWagmiConfig");
|
|
9
11
|
const types_1 = require("./types");
|
|
10
12
|
/**
|
|
11
13
|
* Default permissions configuration for B3 provider
|
|
@@ -21,29 +23,32 @@ const queryClient = new react_query_1.QueryClient();
|
|
|
21
23
|
/**
|
|
22
24
|
* Main B3Provider component
|
|
23
25
|
*/
|
|
24
|
-
function B3Provider({ theme = "light", children, accountOverride, environment, clientType = "socket", }) {
|
|
25
|
-
return ((0, jsx_runtime_1.jsx)(
|
|
26
|
+
function B3Provider({ theme = "light", children, accountOverride, environment, clientType = "socket", partnerId, rpcUrls, }) {
|
|
27
|
+
return ((0, jsx_runtime_1.jsx)(react_1.ThirdwebProvider, { children: (0, jsx_runtime_1.jsx)(InnerProvider, { accountOverride: accountOverride, environment: environment, theme: theme, clientType: clientType, partnerId: partnerId, rpcUrls: rpcUrls, children: children }) }));
|
|
26
28
|
}
|
|
27
29
|
/**
|
|
28
30
|
* Inner provider component that provides the actual B3Context
|
|
29
31
|
*/
|
|
30
|
-
function InnerProvider({ children, accountOverride, environment, defaultPermissions = DEFAULT_PERMISSIONS, theme = "light", clientType = "socket", }) {
|
|
31
|
-
const activeAccount = (0,
|
|
32
|
-
const
|
|
32
|
+
function InnerProvider({ children, accountOverride, environment, defaultPermissions = DEFAULT_PERMISSIONS, theme = "light", clientType = "socket", partnerId, rpcUrls, }) {
|
|
33
|
+
const activeAccount = (0, react_1.useActiveAccount)();
|
|
34
|
+
const { user, setUser, refetchUser } = (0, useAuthentication_1.useAuthentication)(partnerId);
|
|
35
|
+
const wagmiConfig = (0, useWagmiConfig_1.useWagmiConfig)(partnerId, rpcUrls);
|
|
33
36
|
// Use given accountOverride or activeAccount from thirdweb
|
|
34
37
|
const effectiveAccount = accountOverride || activeAccount;
|
|
35
|
-
return ((0, jsx_runtime_1.jsx)(types_1.B3Context.Provider, { value: {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
38
|
+
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)(types_1.B3Context.Provider, { value: {
|
|
39
|
+
account: effectiveAccount,
|
|
40
|
+
automaticallySetFirstEoa: false,
|
|
41
|
+
setWallet: () => { },
|
|
42
|
+
wallet: undefined,
|
|
43
|
+
user,
|
|
44
|
+
setUser,
|
|
45
|
+
initialized: true,
|
|
46
|
+
ready: !!effectiveAccount,
|
|
47
|
+
environment,
|
|
48
|
+
defaultPermissions,
|
|
49
|
+
theme,
|
|
50
|
+
clientType,
|
|
51
|
+
partnerId,
|
|
52
|
+
refetchUser,
|
|
53
|
+
}, children: children }) }) }));
|
|
49
54
|
}
|
|
@@ -12,12 +12,14 @@ export interface B3ContextType {
|
|
|
12
12
|
setWallet: (wallet: Wallet) => void;
|
|
13
13
|
wallet?: Wallet;
|
|
14
14
|
setUser: (user?: Users) => void;
|
|
15
|
+
refetchUser: () => Promise<any>;
|
|
15
16
|
initialized: boolean;
|
|
16
17
|
ready: boolean;
|
|
17
18
|
environment?: "development" | "production";
|
|
18
19
|
defaultPermissions?: PermissionsConfig;
|
|
19
20
|
theme: "light" | "dark";
|
|
20
21
|
clientType: ClientType;
|
|
22
|
+
partnerId: string;
|
|
21
23
|
}
|
|
22
24
|
/**
|
|
23
25
|
* Context for B3 provider
|
|
@@ -12,9 +12,11 @@ exports.B3Context = (0, react_1.createContext)({
|
|
|
12
12
|
setWallet: () => { },
|
|
13
13
|
wallet: undefined,
|
|
14
14
|
setUser: () => { },
|
|
15
|
+
refetchUser: async () => { },
|
|
15
16
|
initialized: false,
|
|
16
17
|
ready: false,
|
|
17
18
|
environment: "development",
|
|
18
19
|
theme: "light",
|
|
19
20
|
clientType: "rest",
|
|
21
|
+
partnerId: "",
|
|
20
22
|
});
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
interface BalanceContentProps {
|
|
2
2
|
onLogout?: () => void;
|
|
3
|
-
partnerId: string;
|
|
4
3
|
showDeposit?: boolean;
|
|
5
4
|
showSwap?: boolean;
|
|
6
5
|
}
|
|
7
|
-
export declare function BalanceContent({ onLogout,
|
|
6
|
+
export declare function BalanceContent({ onLogout, showDeposit, showSwap }: BalanceContentProps): import("react/jsx-runtime").JSX.Element;
|
|
8
7
|
export {};
|
|
@@ -20,14 +20,14 @@ function centerTruncate(str, length = 4) {
|
|
|
20
20
|
return str;
|
|
21
21
|
return `${str.slice(0, length)}...${str.slice(-length)}`;
|
|
22
22
|
}
|
|
23
|
-
function BalanceContent({ onLogout,
|
|
23
|
+
function BalanceContent({ onLogout, showDeposit = true, showSwap = true }) {
|
|
24
24
|
const account = (0, react_3.useActiveAccount)();
|
|
25
25
|
const { address: eoaAddress, info: eoaInfo } = (0, useFirstEOA_1.useFirstEOA)();
|
|
26
26
|
const { data: profile } = (0, react_1.useProfile)({
|
|
27
27
|
address: eoaAddress || account?.address,
|
|
28
28
|
fresh: true,
|
|
29
29
|
});
|
|
30
|
-
const { user } = (0, react_1.useB3)();
|
|
30
|
+
const { user, partnerId } = (0, react_1.useB3)();
|
|
31
31
|
const { setB3ModalOpen, setB3ModalContentType, navigateBack } = (0, react_1.useModalStore)();
|
|
32
32
|
const { logout } = (0, react_1.useAuthentication)(partnerId);
|
|
33
33
|
const [logoutLoading, setLogoutLoading] = (0, react_2.useState)(false);
|
|
@@ -202,5 +202,5 @@ function ManageAccount({ onLogout, onSwap: _onSwap, onDeposit: _onDeposit, chain
|
|
|
202
202
|
if (["overview", "tokens", "nfts", "apps", "settings"].includes(tab)) {
|
|
203
203
|
setActiveTab?.(tab);
|
|
204
204
|
}
|
|
205
|
-
}, children: [(0, jsx_runtime_1.jsx)("div", { className: "px-4", children: (0, jsx_runtime_1.jsxs)(react_1.TabsListPrimitive, { className: "grid h-auto grid-cols-2 grid-rows-2 gap-3 rounded-none border-none bg-transparent", children: [(0, jsx_runtime_1.jsxs)(react_1.TabTriggerPrimitive, { value: "overview", className: "data-[state=active]:bg-b3-primary-blue data-[state=active]:hover:bg-b3-primary-blue data-[state=active]:border-b3-primary-blue group flex h-12 w-full items-center justify-center gap-2 rounded-xl border border-gray-200 bg-white p-2 text-center shadow-sm transition-all duration-200 hover:bg-gray-50 hover:shadow-md data-[state=active]:shadow-lg", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.BarChart3, { size: 20, className: "text-b3-primary-blue shrink-0 group-data-[state=active]:text-white" }), (0, jsx_runtime_1.jsx)("span", { className: "text-b3-grey font-neue-montreal-semibold text-sm group-data-[state=active]:text-white", children: "Overview" })] }), (0, jsx_runtime_1.jsxs)(react_1.TabTriggerPrimitive, { value: "tokens", className: "data-[state=active]:bg-b3-primary-blue data-[state=active]:hover:bg-b3-primary-blue data-[state=active]:border-b3-primary-blue group flex h-12 w-full items-center justify-center gap-2 rounded-xl border border-gray-200 bg-white p-2 text-center shadow-sm transition-all duration-200 hover:bg-gray-50 hover:shadow-md data-[state=active]:shadow-lg", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.Coins, { size: 20, className: "text-b3-primary-blue shrink-0 group-data-[state=active]:text-white" }), (0, jsx_runtime_1.jsx)("span", { className: "text-b3-grey font-neue-montreal-semibold text-sm group-data-[state=active]:text-white", children: "Tokens" })] }), (0, jsx_runtime_1.jsxs)(react_1.TabTriggerPrimitive, { value: "nfts", className: "data-[state=active]:bg-b3-primary-blue data-[state=active]:hover:bg-b3-primary-blue data-[state=active]:border-b3-primary-blue group flex h-12 w-full items-center justify-center gap-2 rounded-xl border border-gray-200 bg-white p-2 text-center shadow-sm transition-all duration-200 hover:bg-gray-50 hover:shadow-md data-[state=active]:shadow-lg", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.Image, { size: 20, className: "text-b3-primary-blue shrink-0 group-data-[state=active]:text-white" }), (0, jsx_runtime_1.jsx)("span", { className: "text-b3-grey font-neue-montreal-semibold text-sm group-data-[state=active]:text-white", children: "NFTs" })] }), (0, jsx_runtime_1.jsxs)(react_1.TabTriggerPrimitive, { value: "settings", className: "data-[state=active]:bg-b3-primary-blue data-[state=active]:hover:bg-b3-primary-blue data-[state=active]:border-b3-primary-blue group flex h-12 w-full items-center justify-center gap-2 rounded-xl border border-gray-200 bg-white p-2 text-center shadow-sm transition-all duration-200 hover:bg-gray-50 hover:shadow-md data-[state=active]:shadow-lg", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.Settings, { size: 20, className: "text-b3-primary-blue shrink-0 group-data-[state=active]:text-white" }), (0, jsx_runtime_1.jsx)("span", { className: "text-b3-grey font-neue-montreal-semibold text-sm group-data-[state=active]:text-white", children: "Settings" })] })] }) }), (0, jsx_runtime_1.jsx)(react_1.TabsContentPrimitive, { value: "overview", className: "px-4 pb-4 pt-2", children: (0, jsx_runtime_1.jsx)(BalanceContent_1.BalanceContent, { onLogout: onLogout,
|
|
205
|
+
}, children: [(0, jsx_runtime_1.jsx)("div", { className: "px-4", children: (0, jsx_runtime_1.jsxs)(react_1.TabsListPrimitive, { className: "grid h-auto grid-cols-2 grid-rows-2 gap-3 rounded-none border-none bg-transparent", children: [(0, jsx_runtime_1.jsxs)(react_1.TabTriggerPrimitive, { value: "overview", className: "data-[state=active]:bg-b3-primary-blue data-[state=active]:hover:bg-b3-primary-blue data-[state=active]:border-b3-primary-blue group flex h-12 w-full items-center justify-center gap-2 rounded-xl border border-gray-200 bg-white p-2 text-center shadow-sm transition-all duration-200 hover:bg-gray-50 hover:shadow-md data-[state=active]:shadow-lg", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.BarChart3, { size: 20, className: "text-b3-primary-blue shrink-0 group-data-[state=active]:text-white" }), (0, jsx_runtime_1.jsx)("span", { className: "text-b3-grey font-neue-montreal-semibold text-sm group-data-[state=active]:text-white", children: "Overview" })] }), (0, jsx_runtime_1.jsxs)(react_1.TabTriggerPrimitive, { value: "tokens", className: "data-[state=active]:bg-b3-primary-blue data-[state=active]:hover:bg-b3-primary-blue data-[state=active]:border-b3-primary-blue group flex h-12 w-full items-center justify-center gap-2 rounded-xl border border-gray-200 bg-white p-2 text-center shadow-sm transition-all duration-200 hover:bg-gray-50 hover:shadow-md data-[state=active]:shadow-lg", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.Coins, { size: 20, className: "text-b3-primary-blue shrink-0 group-data-[state=active]:text-white" }), (0, jsx_runtime_1.jsx)("span", { className: "text-b3-grey font-neue-montreal-semibold text-sm group-data-[state=active]:text-white", children: "Tokens" })] }), (0, jsx_runtime_1.jsxs)(react_1.TabTriggerPrimitive, { value: "nfts", className: "data-[state=active]:bg-b3-primary-blue data-[state=active]:hover:bg-b3-primary-blue data-[state=active]:border-b3-primary-blue group flex h-12 w-full items-center justify-center gap-2 rounded-xl border border-gray-200 bg-white p-2 text-center shadow-sm transition-all duration-200 hover:bg-gray-50 hover:shadow-md data-[state=active]:shadow-lg", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.Image, { size: 20, className: "text-b3-primary-blue shrink-0 group-data-[state=active]:text-white" }), (0, jsx_runtime_1.jsx)("span", { className: "text-b3-grey font-neue-montreal-semibold text-sm group-data-[state=active]:text-white", children: "NFTs" })] }), (0, jsx_runtime_1.jsxs)(react_1.TabTriggerPrimitive, { value: "settings", className: "data-[state=active]:bg-b3-primary-blue data-[state=active]:hover:bg-b3-primary-blue data-[state=active]:border-b3-primary-blue group flex h-12 w-full items-center justify-center gap-2 rounded-xl border border-gray-200 bg-white p-2 text-center shadow-sm transition-all duration-200 hover:bg-gray-50 hover:shadow-md data-[state=active]:shadow-lg", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.Settings, { size: 20, className: "text-b3-primary-blue shrink-0 group-data-[state=active]:text-white" }), (0, jsx_runtime_1.jsx)("span", { className: "text-b3-grey font-neue-montreal-semibold text-sm group-data-[state=active]:text-white", children: "Settings" })] })] }) }), (0, jsx_runtime_1.jsx)(react_1.TabsContentPrimitive, { value: "overview", className: "px-4 pb-4 pt-2", children: (0, jsx_runtime_1.jsx)(BalanceContent_1.BalanceContent, { onLogout: onLogout, showDeposit: showDeposit, showSwap: showSwap }) }), (0, jsx_runtime_1.jsx)(react_1.TabsContentPrimitive, { value: "tokens", className: "px-4 pb-4 pt-2", children: (0, jsx_runtime_1.jsx)(ContentTokens_1.ContentTokens, { activeTab: activeTab }) }), (0, jsx_runtime_1.jsx)(react_1.TabsContentPrimitive, { value: "nfts", className: "px-4 pb-4 pt-2", children: (0, jsx_runtime_1.jsx)("div", { className: "grid grid-cols-3 gap-4", children: nfts?.nftResponse ? ((0, jsx_runtime_1.jsx)(AccountAssets_1.AccountAssets, { nfts: nfts.nftResponse, isLoading: isLoading })) : ((0, jsx_runtime_1.jsx)("div", { className: "col-span-3 py-12 text-center text-gray-500", children: "No NFTs found" })) }) }), (0, jsx_runtime_1.jsx)(react_1.TabsContentPrimitive, { value: "apps", className: "px-4 pb-4 pt-2", children: (0, jsx_runtime_1.jsx)(AppsContent, {}) }), (0, jsx_runtime_1.jsx)(react_1.TabsContentPrimitive, { value: "settings", className: "px-4 pb-4 pt-2", children: (0, jsx_runtime_1.jsx)(SettingsContent, {}) })] }) }) }));
|
|
206
206
|
}
|
|
@@ -15,10 +15,10 @@ const react_4 = require("thirdweb/react");
|
|
|
15
15
|
const ManageAccountButton_1 = require("../custom/ManageAccountButton");
|
|
16
16
|
function SignIn(props) {
|
|
17
17
|
const { className } = props;
|
|
18
|
-
const { automaticallySetFirstEoa } = (0, react_1.useB3)();
|
|
18
|
+
const { automaticallySetFirstEoa, partnerId } = (0, react_1.useB3)();
|
|
19
19
|
const { wallet, address: globalAddress, ensName, connectedSmartWallet, connectedEOAWallet, isActiveSmartWallet, isActiveEOAWallet, smartWalletIcon, eoaWalletIcon, } = (0, react_1.useAccountWallet)();
|
|
20
20
|
const isMobile = (0, react_1.useIsMobile)();
|
|
21
|
-
const { logout } = (0, react_1.useAuthentication)(
|
|
21
|
+
const { logout } = (0, react_1.useAuthentication)(partnerId);
|
|
22
22
|
const onDisconnect = async () => {
|
|
23
23
|
await logout();
|
|
24
24
|
};
|
|
@@ -9,7 +9,7 @@ const Loading_1 = require("../ui/Loading");
|
|
|
9
9
|
function SignInWithB3(props) {
|
|
10
10
|
const { setB3ModalOpen, setB3ModalContentType, setEcoSystemAccountAddress } = (0, react_1.useModalStore)();
|
|
11
11
|
const { account } = (0, react_1.useB3)();
|
|
12
|
-
const { isAuthenticating, isAuthenticated } = (0, react_1.
|
|
12
|
+
const { isAuthenticating, isAuthenticated } = (0, react_1.useAuthStore)();
|
|
13
13
|
const isMobile = (0, react_1.useIsMobile)();
|
|
14
14
|
(0, react_2.useEffect)(() => {
|
|
15
15
|
if (account) {
|