@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
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
}
|
|
43
|
+
export interface SendNotificationRequest {
|
|
44
|
+
userId: string;
|
|
45
|
+
appId: string;
|
|
46
|
+
notificationType: string;
|
|
47
|
+
message: string;
|
|
48
|
+
title?: string;
|
|
49
|
+
data?: Record<string, any>;
|
|
50
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import Cookies from "js-cookie";
|
|
2
|
+
const B3_AUTH_COOKIE_NAME = "b3-auth";
|
|
3
|
+
/**
|
|
4
|
+
* Get the authentication token from the B3 auth cookie
|
|
5
|
+
* This token is managed by the B3 Global Account authentication system
|
|
6
|
+
*
|
|
7
|
+
* @returns The JWT token string or null if not found
|
|
8
|
+
*/
|
|
9
|
+
export function getAuthToken() {
|
|
10
|
+
return Cookies.get(B3_AUTH_COOKIE_NAME) || null;
|
|
11
|
+
}
|
|
@@ -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;
|
|
@@ -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
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./useNotifications";
|
|
@@ -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 '@b3dotfun/sdk/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
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./hooks";
|
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
*/
|
|
48
|
+
savePreferences(appId: string, settings: NotificationPreferences): Promise<any>;
|
|
49
|
+
/**
|
|
50
|
+
* Get notification settings for an app
|
|
51
|
+
*/
|
|
52
|
+
getAppSettings(appId: string): Promise<any>;
|
|
53
|
+
/**
|
|
54
|
+
* Get current user's in-app notifications
|
|
55
|
+
*/
|
|
56
|
+
getInAppNotifications(): Promise<any>;
|
|
57
|
+
/**
|
|
58
|
+
* Mark a notification as read
|
|
59
|
+
*/
|
|
60
|
+
markNotificationAsRead(notificationId: string): Promise<any>;
|
|
61
|
+
/**
|
|
62
|
+
* Send a notification (requires auth)
|
|
63
|
+
*/
|
|
64
|
+
sendNotification(data: SendNotificationRequest): Promise<any>;
|
|
65
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./api";
|
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
}
|
|
43
|
+
export interface SendNotificationRequest {
|
|
44
|
+
userId: string;
|
|
45
|
+
appId: string;
|
|
46
|
+
notificationType: string;
|
|
47
|
+
message: string;
|
|
48
|
+
title?: string;
|
|
49
|
+
data?: Record<string, any>;
|
|
50
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@b3dotfun/sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.45",
|
|
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",
|
|
@@ -391,13 +391,7 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
391
391
|
: order.payload.expectedDstAmount.toString();
|
|
392
392
|
const formattedExpectedDstAmount = formatTokenAmount(BigInt(expectedDstAmount), dstToken.decimals);
|
|
393
393
|
|
|
394
|
-
const actualDstAmount =
|
|
395
|
-
order.type === "mint_nft" ||
|
|
396
|
-
order.type === "join_tournament" ||
|
|
397
|
-
order.type === "fund_tournament" ||
|
|
398
|
-
order.type === "custom"
|
|
399
|
-
? undefined
|
|
400
|
-
: order.payload.actualDstAmount;
|
|
394
|
+
const actualDstAmount = order.settlement?.actualDstAmount;
|
|
401
395
|
const formattedActualDstAmount = actualDstAmount
|
|
402
396
|
? formatTokenAmount(BigInt(actualDstAmount), dstToken.decimals)
|
|
403
397
|
: undefined;
|
|
@@ -18,13 +18,7 @@ export function OrderHistoryItem({ order, onSelectOrder, mode }: OrderHistoryIte
|
|
|
18
18
|
const tournament =
|
|
19
19
|
order.type === "join_tournament" || order.type === "fund_tournament" ? order.metadata.tournament : undefined;
|
|
20
20
|
const dstToken = order.metadata.dstToken;
|
|
21
|
-
const actualDstAmount =
|
|
22
|
-
order.type === "mint_nft" ||
|
|
23
|
-
order.type === "join_tournament" ||
|
|
24
|
-
order.type === "fund_tournament" ||
|
|
25
|
-
order.type === "custom"
|
|
26
|
-
? undefined
|
|
27
|
-
: order.payload.actualDstAmount;
|
|
21
|
+
const actualDstAmount = order.settlement?.actualDstAmount;
|
|
28
22
|
const expectedDstAmount =
|
|
29
23
|
order.type === "mint_nft" ||
|
|
30
24
|
order.type === "join_tournament" ||
|
|
@@ -247,8 +247,8 @@ export function useAnyspendFlow({
|
|
|
247
247
|
// Handle order completion
|
|
248
248
|
useEffect(() => {
|
|
249
249
|
if (oat?.data?.order.status === "executed") {
|
|
250
|
-
// get the actualDstAmount if available from
|
|
251
|
-
const amount =
|
|
250
|
+
// get the actualDstAmount if available from settlement
|
|
251
|
+
const amount = oat.data.order.settlement?.actualDstAmount;
|
|
252
252
|
const formattedActualDstAmount = amount
|
|
253
253
|
? formatTokenAmount(BigInt(amount), oat.data.order.metadata.dstToken.decimals)
|
|
254
254
|
: undefined;
|
|
@@ -256,7 +256,7 @@ export function useAnyspendFlow({
|
|
|
256
256
|
}
|
|
257
257
|
}, [
|
|
258
258
|
oat?.data?.order.status,
|
|
259
|
-
oat?.data?.order.
|
|
259
|
+
oat?.data?.order.settlement?.actualDstAmount,
|
|
260
260
|
onTransactionSuccess,
|
|
261
261
|
oat?.data?.order.metadata.dstToken.decimals,
|
|
262
262
|
]);
|
|
@@ -435,6 +435,11 @@ export interface paths {
|
|
|
435
435
|
executeTx: components["schemas"]["ExecuteTx"] | null;
|
|
436
436
|
/** @description Refund transactions if order failed */
|
|
437
437
|
refundTxs: components["schemas"]["RefundTx"][];
|
|
438
|
+
/**
|
|
439
|
+
* @description Points awarded for this order (only present when order status is executed)
|
|
440
|
+
* @example 100
|
|
441
|
+
*/
|
|
442
|
+
points: number | null;
|
|
438
443
|
};
|
|
439
444
|
/** @example 200 */
|
|
440
445
|
statusCode: number;
|
|
@@ -1119,11 +1124,6 @@ export interface components {
|
|
|
1119
1124
|
* @example 990000
|
|
1120
1125
|
*/
|
|
1121
1126
|
expectedDstAmount: string;
|
|
1122
|
-
/**
|
|
1123
|
-
* @description Actual received amount (null for new orders)
|
|
1124
|
-
* @example 990000
|
|
1125
|
-
*/
|
|
1126
|
-
actualDstAmount: string | null;
|
|
1127
1127
|
};
|
|
1128
1128
|
/** @description HypeDuel-specific payload */
|
|
1129
1129
|
HypeDuelPayload: {
|
|
@@ -1132,11 +1132,6 @@ export interface components {
|
|
|
1132
1132
|
* @example 990000
|
|
1133
1133
|
*/
|
|
1134
1134
|
expectedDstAmount: string;
|
|
1135
|
-
/**
|
|
1136
|
-
* @description Actual received amount (null for new orders)
|
|
1137
|
-
* @example 990000
|
|
1138
|
-
*/
|
|
1139
|
-
actualDstAmount: string | null;
|
|
1140
1135
|
};
|
|
1141
1136
|
/** @description Custom execution payload */
|
|
1142
1137
|
CustomPayload: {
|
|
@@ -1332,6 +1327,14 @@ export interface components {
|
|
|
1332
1327
|
* @example pi_3Rko0sJnoDg53PsP0PDLsHkR
|
|
1333
1328
|
*/
|
|
1334
1329
|
stripePaymentIntentId: string | null;
|
|
1330
|
+
/** @description Settlement information for executed orders */
|
|
1331
|
+
settlement: {
|
|
1332
|
+
/**
|
|
1333
|
+
* @description Actual received amount after execution
|
|
1334
|
+
* @example 990000
|
|
1335
|
+
*/
|
|
1336
|
+
actualDstAmount: string | null;
|
|
1337
|
+
} | null;
|
|
1335
1338
|
};
|
|
1336
1339
|
SwapOrder: components["schemas"]["BaseOrder"] & {
|
|
1337
1340
|
/**
|
|
@@ -17,8 +17,6 @@ export const buildPayload = (orderType: components["schemas"]["Order"]["type"],
|
|
|
17
17
|
case "swap":
|
|
18
18
|
return {
|
|
19
19
|
expectedDstAmount,
|
|
20
|
-
actualDstAmount: null,
|
|
21
|
-
amountInAfterFee: null,
|
|
22
20
|
};
|
|
23
21
|
case "mint_nft":
|
|
24
22
|
if (nft?.type === "erc1155") {
|
|
@@ -53,8 +51,6 @@ export const buildPayload = (orderType: components["schemas"]["Order"]["type"],
|
|
|
53
51
|
case "hype_duel":
|
|
54
52
|
return {
|
|
55
53
|
expectedDstAmount,
|
|
56
|
-
actualDstAmount: null,
|
|
57
|
-
amountInAfterFee: null,
|
|
58
54
|
};
|
|
59
55
|
default:
|
|
60
56
|
throw new Error(`Invalid order type: ${orderType}`);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const VERSION = "1.0.0";
|
|
2
|
+
|
|
3
|
+
// Export types
|
|
4
|
+
export * from "./types";
|
|
5
|
+
|
|
6
|
+
// Export services
|
|
7
|
+
export * from "./services";
|
|
8
|
+
|
|
9
|
+
// Re-export auth token getter from shared for convenience
|
|
10
|
+
// Note: Auth token is managed by B3 Global Account authentication
|
|
11
|
+
export { getAuthToken } from "../shared/utils/auth-token";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./useNotifications";
|