@b3dotfun/sdk 0.0.44 → 0.0.45
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 +215 -3
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +1 -6
- package/dist/cjs/anyspend/react/components/common/OrderHistoryItem.js +1 -6
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.d.ts +1 -0
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.js +3 -3
- package/dist/cjs/anyspend/react/hooks/useAnyspendOrderAndTransactions.d.ts +2 -0
- package/dist/cjs/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +36 -0
- package/dist/cjs/anyspend/types/api.d.ts +13 -10
- package/dist/cjs/anyspend/utils/orderPayload.js +0 -4
- package/dist/cjs/notifications/index.d.ts +4 -0
- package/dist/cjs/notifications/index.js +26 -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 +65 -0
- package/dist/cjs/notifications/services/api.js +178 -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 +50 -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/common/OrderDetails.js +1 -6
- package/dist/esm/anyspend/react/components/common/OrderHistoryItem.js +1 -6
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.d.ts +1 -0
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.js +3 -3
- package/dist/esm/anyspend/react/hooks/useAnyspendOrderAndTransactions.d.ts +2 -0
- package/dist/esm/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +36 -0
- package/dist/esm/anyspend/types/api.d.ts +13 -10
- package/dist/esm/anyspend/utils/orderPayload.js +0 -4
- package/dist/esm/notifications/index.d.ts +4 -0
- package/dist/esm/notifications/index.js +8 -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 +65 -0
- package/dist/esm/notifications/services/api.js +173 -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 +50 -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/anyspend/react/hooks/useAnyspendFlow.d.ts +1 -0
- package/dist/types/anyspend/react/hooks/useAnyspendOrderAndTransactions.d.ts +2 -0
- package/dist/types/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +36 -0
- package/dist/types/anyspend/types/api.d.ts +13 -10
- package/dist/types/notifications/index.d.ts +4 -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 +65 -0
- package/dist/types/notifications/services/index.d.ts +1 -0
- package/dist/types/notifications/types/index.d.ts +50 -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 +21 -1
- package/src/anyspend/react/components/common/OrderDetails.tsx +1 -7
- package/src/anyspend/react/components/common/OrderHistoryItem.tsx +1 -7
- package/src/anyspend/react/hooks/useAnyspendFlow.ts +3 -3
- package/src/anyspend/types/api.ts +13 -10
- package/src/anyspend/utils/orderPayload.ts +0 -4
- package/src/notifications/index.ts +11 -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 +211 -0
- package/src/notifications/services/index.ts +1 -0
- package/src/notifications/types/index.ts +57 -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(
|
|
@@ -323,6 +323,199 @@ 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
|
|
446
|
+
await notificationsAPI.savePreferences("my-app", {
|
|
447
|
+
notificationType: "transaction",
|
|
448
|
+
channels: ["email", "telegram", "in_app"],
|
|
449
|
+
});
|
|
450
|
+
|
|
451
|
+
// Get app settings
|
|
452
|
+
const settings = await notificationsAPI.getAppSettings("my-app");
|
|
453
|
+
```
|
|
454
|
+
|
|
455
|
+
### In-App Notifications
|
|
456
|
+
|
|
457
|
+
```typescript
|
|
458
|
+
// Get in-app notifications
|
|
459
|
+
const { notifications } = await notificationsAPI.getInAppNotifications();
|
|
460
|
+
|
|
461
|
+
// Mark notification as read
|
|
462
|
+
await notificationsAPI.markNotificationAsRead("notification-id");
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
### Send Notifications
|
|
466
|
+
|
|
467
|
+
```typescript
|
|
468
|
+
// Send a notification
|
|
469
|
+
await notificationsAPI.sendNotification({
|
|
470
|
+
userId: "user-123",
|
|
471
|
+
appId: "my-app",
|
|
472
|
+
notificationType: "transaction",
|
|
473
|
+
message: "Your transaction was successful!",
|
|
474
|
+
title: "Transaction Complete",
|
|
475
|
+
data: { transactionId: "tx-123" },
|
|
476
|
+
});
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
## Next.js Example
|
|
480
|
+
|
|
481
|
+
```tsx
|
|
482
|
+
"use client";
|
|
483
|
+
|
|
484
|
+
import { useNotifications } from "@b3dotfun/sdk/notifications/react";
|
|
485
|
+
|
|
486
|
+
export default function NotificationsPage() {
|
|
487
|
+
const { user, loading, connectEmail, connectTelegram, isEmailConnected, isTelegramConnected } = useNotifications();
|
|
488
|
+
|
|
489
|
+
if (loading) {
|
|
490
|
+
return <div>Loading notification settings...</div>;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
return (
|
|
494
|
+
<div className="space-y-4">
|
|
495
|
+
<h1>Notification Settings</h1>
|
|
496
|
+
|
|
497
|
+
<div className="rounded-lg border p-4">
|
|
498
|
+
<h2>Email</h2>
|
|
499
|
+
{isEmailConnected ? (
|
|
500
|
+
<p className="text-green-600">✓ Connected</p>
|
|
501
|
+
) : (
|
|
502
|
+
<button onClick={() => connectEmail("user@example.com")}>Connect Email</button>
|
|
503
|
+
)}
|
|
504
|
+
</div>
|
|
505
|
+
|
|
506
|
+
<div className="rounded-lg border p-4">
|
|
507
|
+
<h2>Telegram</h2>
|
|
508
|
+
{isTelegramConnected ? (
|
|
509
|
+
<p className="text-green-600">✓ Connected</p>
|
|
510
|
+
) : (
|
|
511
|
+
<button onClick={connectTelegram}>Connect Telegram</button>
|
|
512
|
+
)}
|
|
513
|
+
</div>
|
|
514
|
+
</div>
|
|
515
|
+
);
|
|
516
|
+
}
|
|
517
|
+
```
|
|
518
|
+
|
|
326
519
|
# Shared Utilities
|
|
327
520
|
|
|
328
521
|
## Chain Management
|
|
@@ -338,6 +531,25 @@ console.log(supportedChains);
|
|
|
338
531
|
console.log(b3Chain);
|
|
339
532
|
```
|
|
340
533
|
|
|
534
|
+
## Authentication Token Management
|
|
535
|
+
|
|
536
|
+
Read-only access to the B3 authentication token. The token is managed by the B3 Global Account authentication system.
|
|
537
|
+
|
|
538
|
+
```typescript
|
|
539
|
+
import { getAuthToken } from "@b3dotfun/sdk/shared/utils";
|
|
540
|
+
|
|
541
|
+
// Get the current auth token from the b3-auth cookie
|
|
542
|
+
const token = getAuthToken();
|
|
543
|
+
|
|
544
|
+
if (token) {
|
|
545
|
+
console.log("User is authenticated");
|
|
546
|
+
} else {
|
|
547
|
+
console.log("User is not authenticated");
|
|
548
|
+
}
|
|
549
|
+
```
|
|
550
|
+
|
|
551
|
+
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.
|
|
552
|
+
|
|
341
553
|
## Utility Functions
|
|
342
554
|
|
|
343
555
|
```typescript
|
|
@@ -280,12 +280,7 @@ exports.OrderDetails = (0, react_4.memo)(function OrderDetails({ mode = "modal",
|
|
|
280
280
|
? "0"
|
|
281
281
|
: order.payload.expectedDstAmount.toString();
|
|
282
282
|
const formattedExpectedDstAmount = (0, number_1.formatTokenAmount)(BigInt(expectedDstAmount), dstToken.decimals);
|
|
283
|
-
const actualDstAmount = order.
|
|
284
|
-
order.type === "join_tournament" ||
|
|
285
|
-
order.type === "fund_tournament" ||
|
|
286
|
-
order.type === "custom"
|
|
287
|
-
? undefined
|
|
288
|
-
: order.payload.actualDstAmount;
|
|
283
|
+
const actualDstAmount = order.settlement?.actualDstAmount;
|
|
289
284
|
const formattedActualDstAmount = actualDstAmount
|
|
290
285
|
? (0, number_1.formatTokenAmount)(BigInt(actualDstAmount), dstToken.decimals)
|
|
291
286
|
: undefined;
|
|
@@ -16,12 +16,7 @@ function OrderHistoryItem({ order, onSelectOrder, mode }) {
|
|
|
16
16
|
const nft = order.type === "mint_nft" ? order.metadata.nft : undefined;
|
|
17
17
|
const tournament = order.type === "join_tournament" || order.type === "fund_tournament" ? order.metadata.tournament : undefined;
|
|
18
18
|
const dstToken = order.metadata.dstToken;
|
|
19
|
-
const actualDstAmount = order.
|
|
20
|
-
order.type === "join_tournament" ||
|
|
21
|
-
order.type === "fund_tournament" ||
|
|
22
|
-
order.type === "custom"
|
|
23
|
-
? undefined
|
|
24
|
-
: order.payload.actualDstAmount;
|
|
19
|
+
const actualDstAmount = order.settlement?.actualDstAmount;
|
|
25
20
|
const expectedDstAmount = order.type === "mint_nft" ||
|
|
26
21
|
order.type === "join_tournament" ||
|
|
27
22
|
order.type === "fund_tournament" ||
|
|
@@ -36,6 +36,7 @@ export declare function useAnyspendFlow({ paymentType, recipientAddress, loadOrd
|
|
|
36
36
|
relayTxs: components["schemas"]["RelayTx"][];
|
|
37
37
|
executeTx: components["schemas"]["ExecuteTx"] | null;
|
|
38
38
|
refundTxs: components["schemas"]["RefundTx"][];
|
|
39
|
+
points: number | null;
|
|
39
40
|
};
|
|
40
41
|
statusCode: number;
|
|
41
42
|
} | undefined;
|
|
@@ -192,8 +192,8 @@ function useAnyspendFlow({ paymentType = "crypto", recipientAddress, loadOrder,
|
|
|
192
192
|
// Handle order completion
|
|
193
193
|
(0, react_3.useEffect)(() => {
|
|
194
194
|
if (oat?.data?.order.status === "executed") {
|
|
195
|
-
// get the actualDstAmount if available from
|
|
196
|
-
const amount = oat.data.order.
|
|
195
|
+
// get the actualDstAmount if available from settlement
|
|
196
|
+
const amount = oat.data.order.settlement?.actualDstAmount;
|
|
197
197
|
const formattedActualDstAmount = amount
|
|
198
198
|
? (0, number_1.formatTokenAmount)(BigInt(amount), oat.data.order.metadata.dstToken.decimals)
|
|
199
199
|
: undefined;
|
|
@@ -201,7 +201,7 @@ function useAnyspendFlow({ paymentType = "crypto", recipientAddress, loadOrder,
|
|
|
201
201
|
}
|
|
202
202
|
}, [
|
|
203
203
|
oat?.data?.order.status,
|
|
204
|
-
oat?.data?.order.
|
|
204
|
+
oat?.data?.order.settlement?.actualDstAmount,
|
|
205
205
|
onTransactionSuccess,
|
|
206
206
|
oat?.data?.order.metadata.dstToken.decimals,
|
|
207
207
|
]);
|
|
@@ -8,6 +8,7 @@ export declare function useAnyspendOrderAndTransactions(orderId: string | undefi
|
|
|
8
8
|
relayTxs: import("../..").components["schemas"]["RelayTx"][];
|
|
9
9
|
executeTx: import("../..").components["schemas"]["ExecuteTx"] | null;
|
|
10
10
|
refundTxs: import("../..").components["schemas"]["RefundTx"][];
|
|
11
|
+
points: number | null;
|
|
11
12
|
};
|
|
12
13
|
statusCode: number;
|
|
13
14
|
} | undefined;
|
|
@@ -22,6 +23,7 @@ export declare function useAnyspendOrderAndTransactions(orderId: string | undefi
|
|
|
22
23
|
relayTxs: import("../..").components["schemas"]["RelayTx"][];
|
|
23
24
|
executeTx: import("../..").components["schemas"]["ExecuteTx"] | null;
|
|
24
25
|
refundTxs: import("../..").components["schemas"]["RefundTx"][];
|
|
26
|
+
points: number | null;
|
|
25
27
|
};
|
|
26
28
|
statusCode: number;
|
|
27
29
|
}, Error>>;
|
|
@@ -18,6 +18,9 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
|
|
|
18
18
|
onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
|
|
19
19
|
oneClickBuyUrl: string | null;
|
|
20
20
|
stripePaymentIntentId: string | null;
|
|
21
|
+
settlement: {
|
|
22
|
+
actualDstAmount: string | null;
|
|
23
|
+
} | null;
|
|
21
24
|
} & {
|
|
22
25
|
type: "swap";
|
|
23
26
|
payload: import("../..").components["schemas"]["SwapPayload"];
|
|
@@ -41,6 +44,9 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
|
|
|
41
44
|
onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
|
|
42
45
|
oneClickBuyUrl: string | null;
|
|
43
46
|
stripePaymentIntentId: string | null;
|
|
47
|
+
settlement: {
|
|
48
|
+
actualDstAmount: string | null;
|
|
49
|
+
} | null;
|
|
44
50
|
} & {
|
|
45
51
|
type: "hype_duel";
|
|
46
52
|
payload: import("../..").components["schemas"]["HypeDuelPayload"];
|
|
@@ -64,6 +70,9 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
|
|
|
64
70
|
onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
|
|
65
71
|
oneClickBuyUrl: string | null;
|
|
66
72
|
stripePaymentIntentId: string | null;
|
|
73
|
+
settlement: {
|
|
74
|
+
actualDstAmount: string | null;
|
|
75
|
+
} | null;
|
|
67
76
|
} & {
|
|
68
77
|
type: "custom";
|
|
69
78
|
payload: import("../..").components["schemas"]["CustomPayload"];
|
|
@@ -87,6 +96,9 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
|
|
|
87
96
|
onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
|
|
88
97
|
oneClickBuyUrl: string | null;
|
|
89
98
|
stripePaymentIntentId: string | null;
|
|
99
|
+
settlement: {
|
|
100
|
+
actualDstAmount: string | null;
|
|
101
|
+
} | null;
|
|
90
102
|
} & {
|
|
91
103
|
type: "mint_nft";
|
|
92
104
|
payload: import("../..").components["schemas"]["MintNftPayload"];
|
|
@@ -110,6 +122,9 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
|
|
|
110
122
|
onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
|
|
111
123
|
oneClickBuyUrl: string | null;
|
|
112
124
|
stripePaymentIntentId: string | null;
|
|
125
|
+
settlement: {
|
|
126
|
+
actualDstAmount: string | null;
|
|
127
|
+
} | null;
|
|
113
128
|
} & {
|
|
114
129
|
type: "join_tournament";
|
|
115
130
|
payload: import("../..").components["schemas"]["JoinTournamentPayload"];
|
|
@@ -133,6 +148,9 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
|
|
|
133
148
|
onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
|
|
134
149
|
oneClickBuyUrl: string | null;
|
|
135
150
|
stripePaymentIntentId: string | null;
|
|
151
|
+
settlement: {
|
|
152
|
+
actualDstAmount: string | null;
|
|
153
|
+
} | null;
|
|
136
154
|
} & {
|
|
137
155
|
type: "fund_tournament";
|
|
138
156
|
payload: import("../..").components["schemas"]["FundTournamentPayload"];
|
|
@@ -159,6 +177,9 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
|
|
|
159
177
|
onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
|
|
160
178
|
oneClickBuyUrl: string | null;
|
|
161
179
|
stripePaymentIntentId: string | null;
|
|
180
|
+
settlement: {
|
|
181
|
+
actualDstAmount: string | null;
|
|
182
|
+
} | null;
|
|
162
183
|
} & {
|
|
163
184
|
type: "swap";
|
|
164
185
|
payload: import("../..").components["schemas"]["SwapPayload"];
|
|
@@ -182,6 +203,9 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
|
|
|
182
203
|
onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
|
|
183
204
|
oneClickBuyUrl: string | null;
|
|
184
205
|
stripePaymentIntentId: string | null;
|
|
206
|
+
settlement: {
|
|
207
|
+
actualDstAmount: string | null;
|
|
208
|
+
} | null;
|
|
185
209
|
} & {
|
|
186
210
|
type: "hype_duel";
|
|
187
211
|
payload: import("../..").components["schemas"]["HypeDuelPayload"];
|
|
@@ -205,6 +229,9 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
|
|
|
205
229
|
onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
|
|
206
230
|
oneClickBuyUrl: string | null;
|
|
207
231
|
stripePaymentIntentId: string | null;
|
|
232
|
+
settlement: {
|
|
233
|
+
actualDstAmount: string | null;
|
|
234
|
+
} | null;
|
|
208
235
|
} & {
|
|
209
236
|
type: "custom";
|
|
210
237
|
payload: import("../..").components["schemas"]["CustomPayload"];
|
|
@@ -228,6 +255,9 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
|
|
|
228
255
|
onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
|
|
229
256
|
oneClickBuyUrl: string | null;
|
|
230
257
|
stripePaymentIntentId: string | null;
|
|
258
|
+
settlement: {
|
|
259
|
+
actualDstAmount: string | null;
|
|
260
|
+
} | null;
|
|
231
261
|
} & {
|
|
232
262
|
type: "mint_nft";
|
|
233
263
|
payload: import("../..").components["schemas"]["MintNftPayload"];
|
|
@@ -251,6 +281,9 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
|
|
|
251
281
|
onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
|
|
252
282
|
oneClickBuyUrl: string | null;
|
|
253
283
|
stripePaymentIntentId: string | null;
|
|
284
|
+
settlement: {
|
|
285
|
+
actualDstAmount: string | null;
|
|
286
|
+
} | null;
|
|
254
287
|
} & {
|
|
255
288
|
type: "join_tournament";
|
|
256
289
|
payload: import("../..").components["schemas"]["JoinTournamentPayload"];
|
|
@@ -274,6 +307,9 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
|
|
|
274
307
|
onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
|
|
275
308
|
oneClickBuyUrl: string | null;
|
|
276
309
|
stripePaymentIntentId: string | null;
|
|
310
|
+
settlement: {
|
|
311
|
+
actualDstAmount: string | null;
|
|
312
|
+
} | null;
|
|
277
313
|
} & {
|
|
278
314
|
type: "fund_tournament";
|
|
279
315
|
payload: import("../..").components["schemas"]["FundTournamentPayload"];
|
|
@@ -434,6 +434,11 @@ export interface paths {
|
|
|
434
434
|
executeTx: components["schemas"]["ExecuteTx"] | null;
|
|
435
435
|
/** @description Refund transactions if order failed */
|
|
436
436
|
refundTxs: components["schemas"]["RefundTx"][];
|
|
437
|
+
/**
|
|
438
|
+
* @description Points awarded for this order (only present when order status is executed)
|
|
439
|
+
* @example 100
|
|
440
|
+
*/
|
|
441
|
+
points: number | null;
|
|
437
442
|
};
|
|
438
443
|
/** @example 200 */
|
|
439
444
|
statusCode: number;
|
|
@@ -1112,11 +1117,6 @@ export interface components {
|
|
|
1112
1117
|
* @example 990000
|
|
1113
1118
|
*/
|
|
1114
1119
|
expectedDstAmount: string;
|
|
1115
|
-
/**
|
|
1116
|
-
* @description Actual received amount (null for new orders)
|
|
1117
|
-
* @example 990000
|
|
1118
|
-
*/
|
|
1119
|
-
actualDstAmount: string | null;
|
|
1120
1120
|
};
|
|
1121
1121
|
/** @description HypeDuel-specific payload */
|
|
1122
1122
|
HypeDuelPayload: {
|
|
@@ -1125,11 +1125,6 @@ export interface components {
|
|
|
1125
1125
|
* @example 990000
|
|
1126
1126
|
*/
|
|
1127
1127
|
expectedDstAmount: string;
|
|
1128
|
-
/**
|
|
1129
|
-
* @description Actual received amount (null for new orders)
|
|
1130
|
-
* @example 990000
|
|
1131
|
-
*/
|
|
1132
|
-
actualDstAmount: string | null;
|
|
1133
1128
|
};
|
|
1134
1129
|
/** @description Custom execution payload */
|
|
1135
1130
|
CustomPayload: {
|
|
@@ -1315,6 +1310,14 @@ export interface components {
|
|
|
1315
1310
|
* @example pi_3Rko0sJnoDg53PsP0PDLsHkR
|
|
1316
1311
|
*/
|
|
1317
1312
|
stripePaymentIntentId: string | null;
|
|
1313
|
+
/** @description Settlement information for executed orders */
|
|
1314
|
+
settlement: {
|
|
1315
|
+
/**
|
|
1316
|
+
* @description Actual received amount after execution
|
|
1317
|
+
* @example 990000
|
|
1318
|
+
*/
|
|
1319
|
+
actualDstAmount: string | null;
|
|
1320
|
+
} | null;
|
|
1318
1321
|
};
|
|
1319
1322
|
SwapOrder: components["schemas"]["BaseOrder"] & {
|
|
1320
1323
|
/**
|
|
@@ -8,8 +8,6 @@ const buildPayload = (orderType, params) => {
|
|
|
8
8
|
case "swap":
|
|
9
9
|
return {
|
|
10
10
|
expectedDstAmount,
|
|
11
|
-
actualDstAmount: null,
|
|
12
|
-
amountInAfterFee: null,
|
|
13
11
|
};
|
|
14
12
|
case "mint_nft":
|
|
15
13
|
if (nft?.type === "erc1155") {
|
|
@@ -46,8 +44,6 @@ const buildPayload = (orderType, params) => {
|
|
|
46
44
|
case "hype_duel":
|
|
47
45
|
return {
|
|
48
46
|
expectedDstAmount,
|
|
49
|
-
actualDstAmount: null,
|
|
50
|
-
amountInAfterFee: null,
|
|
51
47
|
};
|
|
52
48
|
default:
|
|
53
49
|
throw new Error(`Invalid order type: ${orderType}`);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.getAuthToken = exports.VERSION = void 0;
|
|
18
|
+
exports.VERSION = "1.0.0";
|
|
19
|
+
// Export types
|
|
20
|
+
__exportStar(require("./types"), exports);
|
|
21
|
+
// Export services
|
|
22
|
+
__exportStar(require("./services"), exports);
|
|
23
|
+
// Re-export auth token getter from shared for convenience
|
|
24
|
+
// Note: Auth token is managed by B3 Global Account authentication
|
|
25
|
+
var auth_token_1 = require("../shared/utils/auth-token");
|
|
26
|
+
Object.defineProperty(exports, "getAuthToken", { enumerable: true, get: function () { return auth_token_1.getAuthToken; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./useNotifications";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./useNotifications"), exports);
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { UserData } from "../../types";
|
|
2
|
+
/**
|
|
3
|
+
* React hook for managing B3 notifications
|
|
4
|
+
* Automatically uses the authenticated user's ID from JWT
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* import { useNotifications } from '../../../notifications/react';
|
|
9
|
+
*
|
|
10
|
+
* function NotificationSettings() {
|
|
11
|
+
* const { user, loading, connectEmail, connectTelegram, isEmailConnected } = useNotifications();
|
|
12
|
+
*
|
|
13
|
+
* if (loading) return <div>Loading...</div>;
|
|
14
|
+
*
|
|
15
|
+
* return (
|
|
16
|
+
* <div>
|
|
17
|
+
* {!isEmailConnected && (
|
|
18
|
+
* <button onClick={() => connectEmail('user@example.com')}>
|
|
19
|
+
* Connect Email
|
|
20
|
+
* </button>
|
|
21
|
+
* )}
|
|
22
|
+
* <button onClick={connectTelegram}>Connect Telegram</button>
|
|
23
|
+
* </div>
|
|
24
|
+
* );
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function useNotifications(): {
|
|
29
|
+
user: UserData | null;
|
|
30
|
+
loading: boolean;
|
|
31
|
+
error: Error | null;
|
|
32
|
+
refresh: () => Promise<void>;
|
|
33
|
+
connectEmail: (email: string) => Promise<void>;
|
|
34
|
+
connectTelegram: () => Promise<void>;
|
|
35
|
+
updateChannel: (channelId: string, updates: {
|
|
36
|
+
enabled?: boolean;
|
|
37
|
+
}) => Promise<void>;
|
|
38
|
+
deleteChannel: (channelId: string) => Promise<void>;
|
|
39
|
+
isEmailConnected: boolean;
|
|
40
|
+
isTelegramConnected: boolean;
|
|
41
|
+
isDiscordConnected: boolean;
|
|
42
|
+
};
|