@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.
Files changed (85) hide show
  1. package/README.md +215 -3
  2. package/dist/cjs/anyspend/react/components/common/OrderDetails.js +1 -6
  3. package/dist/cjs/anyspend/react/components/common/OrderHistoryItem.js +1 -6
  4. package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.d.ts +1 -0
  5. package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.js +3 -3
  6. package/dist/cjs/anyspend/react/hooks/useAnyspendOrderAndTransactions.d.ts +2 -0
  7. package/dist/cjs/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +36 -0
  8. package/dist/cjs/anyspend/types/api.d.ts +13 -10
  9. package/dist/cjs/anyspend/utils/orderPayload.js +0 -4
  10. package/dist/cjs/notifications/index.d.ts +4 -0
  11. package/dist/cjs/notifications/index.js +26 -0
  12. package/dist/cjs/notifications/react/hooks/index.d.ts +1 -0
  13. package/dist/cjs/notifications/react/hooks/index.js +17 -0
  14. package/dist/cjs/notifications/react/hooks/useNotifications.d.ts +42 -0
  15. package/dist/cjs/notifications/react/hooks/useNotifications.js +148 -0
  16. package/dist/cjs/notifications/react/index.d.ts +1 -0
  17. package/dist/cjs/notifications/react/index.js +17 -0
  18. package/dist/cjs/notifications/services/api.d.ts +65 -0
  19. package/dist/cjs/notifications/services/api.js +178 -0
  20. package/dist/cjs/notifications/services/index.d.ts +1 -0
  21. package/dist/cjs/notifications/services/index.js +17 -0
  22. package/dist/cjs/notifications/types/index.d.ts +50 -0
  23. package/dist/cjs/notifications/types/index.js +2 -0
  24. package/dist/cjs/shared/utils/auth-token.d.ts +7 -0
  25. package/dist/cjs/shared/utils/auth-token.js +17 -0
  26. package/dist/cjs/shared/utils/index.d.ts +1 -0
  27. package/dist/cjs/shared/utils/index.js +1 -0
  28. package/dist/esm/anyspend/react/components/common/OrderDetails.js +1 -6
  29. package/dist/esm/anyspend/react/components/common/OrderHistoryItem.js +1 -6
  30. package/dist/esm/anyspend/react/hooks/useAnyspendFlow.d.ts +1 -0
  31. package/dist/esm/anyspend/react/hooks/useAnyspendFlow.js +3 -3
  32. package/dist/esm/anyspend/react/hooks/useAnyspendOrderAndTransactions.d.ts +2 -0
  33. package/dist/esm/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +36 -0
  34. package/dist/esm/anyspend/types/api.d.ts +13 -10
  35. package/dist/esm/anyspend/utils/orderPayload.js +0 -4
  36. package/dist/esm/notifications/index.d.ts +4 -0
  37. package/dist/esm/notifications/index.js +8 -0
  38. package/dist/esm/notifications/react/hooks/index.d.ts +1 -0
  39. package/dist/esm/notifications/react/hooks/index.js +1 -0
  40. package/dist/esm/notifications/react/hooks/useNotifications.d.ts +42 -0
  41. package/dist/esm/notifications/react/hooks/useNotifications.js +145 -0
  42. package/dist/esm/notifications/react/index.d.ts +1 -0
  43. package/dist/esm/notifications/react/index.js +1 -0
  44. package/dist/esm/notifications/services/api.d.ts +65 -0
  45. package/dist/esm/notifications/services/api.js +173 -0
  46. package/dist/esm/notifications/services/index.d.ts +1 -0
  47. package/dist/esm/notifications/services/index.js +1 -0
  48. package/dist/esm/notifications/types/index.d.ts +50 -0
  49. package/dist/esm/shared/utils/auth-token.d.ts +7 -0
  50. package/dist/esm/shared/utils/auth-token.js +11 -0
  51. package/dist/esm/shared/utils/index.d.ts +1 -0
  52. package/dist/esm/shared/utils/index.js +1 -0
  53. package/dist/types/anyspend/react/hooks/useAnyspendFlow.d.ts +1 -0
  54. package/dist/types/anyspend/react/hooks/useAnyspendOrderAndTransactions.d.ts +2 -0
  55. package/dist/types/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +36 -0
  56. package/dist/types/anyspend/types/api.d.ts +13 -10
  57. package/dist/types/notifications/index.d.ts +4 -0
  58. package/dist/types/notifications/react/hooks/index.d.ts +1 -0
  59. package/dist/types/notifications/react/hooks/useNotifications.d.ts +42 -0
  60. package/dist/types/notifications/react/index.d.ts +1 -0
  61. package/dist/types/notifications/services/api.d.ts +65 -0
  62. package/dist/types/notifications/services/index.d.ts +1 -0
  63. package/dist/types/notifications/types/index.d.ts +50 -0
  64. package/dist/types/shared/utils/auth-token.d.ts +7 -0
  65. package/dist/types/shared/utils/index.d.ts +1 -0
  66. package/package.json +21 -1
  67. package/src/anyspend/react/components/common/OrderDetails.tsx +1 -7
  68. package/src/anyspend/react/components/common/OrderHistoryItem.tsx +1 -7
  69. package/src/anyspend/react/hooks/useAnyspendFlow.ts +3 -3
  70. package/src/anyspend/types/api.ts +13 -10
  71. package/src/anyspend/utils/orderPayload.ts +0 -4
  72. package/src/notifications/index.ts +11 -0
  73. package/src/notifications/react/hooks/index.ts +1 -0
  74. package/src/notifications/react/hooks/useNotifications.ts +153 -0
  75. package/src/notifications/react/index.ts +1 -0
  76. package/src/notifications/services/api.ts +211 -0
  77. package/src/notifications/services/index.ts +1 -0
  78. package/src/notifications/types/index.ts +57 -0
  79. package/src/shared/utils/auth-token.ts +13 -0
  80. package/src/shared/utils/index.ts +1 -0
  81. package/dist/cjs/shared/react/hooks/__tests__/useCurrencyConversion.test.js +0 -245
  82. package/dist/esm/shared/react/hooks/__tests__/useCurrencyConversion.test.d.ts +0 -1
  83. package/dist/esm/shared/react/hooks/__tests__/useCurrencyConversion.test.js +0 -243
  84. package/dist/types/shared/react/hooks/__tests__/useCurrencyConversion.test.d.ts +0 -1
  85. /package/dist/{cjs/shared/react/hooks/__tests__/useCurrencyConversion.test.d.ts → esm/notifications/types/index.js} +0 -0
@@ -0,0 +1,148 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useNotifications = useNotifications;
4
+ const react_1 = require("react");
5
+ const api_1 = require("../../services/api");
6
+ /**
7
+ * React hook for managing B3 notifications
8
+ * Automatically uses the authenticated user's ID from JWT
9
+ *
10
+ * @example
11
+ * ```tsx
12
+ * import { useNotifications } from '../../../notifications/react';
13
+ *
14
+ * function NotificationSettings() {
15
+ * const { user, loading, connectEmail, connectTelegram, isEmailConnected } = useNotifications();
16
+ *
17
+ * if (loading) return <div>Loading...</div>;
18
+ *
19
+ * return (
20
+ * <div>
21
+ * {!isEmailConnected && (
22
+ * <button onClick={() => connectEmail('user@example.com')}>
23
+ * Connect Email
24
+ * </button>
25
+ * )}
26
+ * <button onClick={connectTelegram}>Connect Telegram</button>
27
+ * </div>
28
+ * );
29
+ * }
30
+ * ```
31
+ */
32
+ function useNotifications() {
33
+ const [user, setUser] = (0, react_1.useState)(null);
34
+ const [loading, setLoading] = (0, react_1.useState)(true);
35
+ const [error, setError] = (0, react_1.useState)(null);
36
+ // Refs to track polling timers for cleanup
37
+ const telegramPollIntervalRef = (0, react_1.useRef)(null);
38
+ const telegramPollTimeoutRef = (0, react_1.useRef)(null);
39
+ // Cleanup function for Telegram polling
40
+ const cleanupTelegramPolling = () => {
41
+ if (telegramPollIntervalRef.current) {
42
+ clearInterval(telegramPollIntervalRef.current);
43
+ telegramPollIntervalRef.current = null;
44
+ }
45
+ if (telegramPollTimeoutRef.current) {
46
+ clearTimeout(telegramPollTimeoutRef.current);
47
+ telegramPollTimeoutRef.current = null;
48
+ }
49
+ };
50
+ // Load user data on mount
51
+ (0, react_1.useEffect)(() => {
52
+ loadUser();
53
+ }, []);
54
+ // Cleanup polling on unmount
55
+ (0, react_1.useEffect)(() => {
56
+ return () => {
57
+ cleanupTelegramPolling();
58
+ };
59
+ }, []);
60
+ const loadUser = async () => {
61
+ try {
62
+ setLoading(true);
63
+ setError(null);
64
+ const userData = await api_1.notificationsAPI.getUser();
65
+ setUser(userData);
66
+ }
67
+ catch (err) {
68
+ setError(err instanceof Error ? err : new Error("Failed to load user"));
69
+ console.error("Failed to load user:", err);
70
+ }
71
+ finally {
72
+ setLoading(false);
73
+ }
74
+ };
75
+ const connectEmail = async (email) => {
76
+ try {
77
+ await api_1.notificationsAPI.connectEmail(email);
78
+ await loadUser(); // Refresh user data
79
+ }
80
+ catch (err) {
81
+ console.error("Failed to connect email:", err);
82
+ throw err;
83
+ }
84
+ };
85
+ const connectTelegram = async () => {
86
+ try {
87
+ // Clear any existing polling before starting new one
88
+ cleanupTelegramPolling();
89
+ const { deepLink } = await api_1.notificationsAPI.getTelegramLink();
90
+ window.open(deepLink, "_blank");
91
+ // Poll for connection status
92
+ telegramPollIntervalRef.current = setInterval(async () => {
93
+ try {
94
+ const { connected } = await api_1.notificationsAPI.checkTelegramStatus();
95
+ if (connected) {
96
+ cleanupTelegramPolling();
97
+ await loadUser(); // Refresh user data
98
+ }
99
+ }
100
+ catch (err) {
101
+ console.error("Failed to check Telegram status:", err);
102
+ }
103
+ }, 2000);
104
+ // Stop polling after 2 minutes
105
+ telegramPollTimeoutRef.current = setTimeout(() => {
106
+ cleanupTelegramPolling();
107
+ }, 120000);
108
+ }
109
+ catch (err) {
110
+ console.error("Failed to connect Telegram:", err);
111
+ throw err;
112
+ }
113
+ };
114
+ const updateChannel = async (channelId, updates) => {
115
+ try {
116
+ await api_1.notificationsAPI.updateChannel(channelId, updates);
117
+ await loadUser(); // Refresh user data
118
+ }
119
+ catch (err) {
120
+ console.error("Failed to update channel:", err);
121
+ throw err;
122
+ }
123
+ };
124
+ const deleteChannel = async (channelId) => {
125
+ try {
126
+ await api_1.notificationsAPI.deleteChannel(channelId);
127
+ await loadUser(); // Refresh user data
128
+ }
129
+ catch (err) {
130
+ console.error("Failed to delete channel:", err);
131
+ throw err;
132
+ }
133
+ };
134
+ return {
135
+ user,
136
+ loading,
137
+ error,
138
+ refresh: loadUser,
139
+ connectEmail,
140
+ connectTelegram,
141
+ updateChannel,
142
+ deleteChannel,
143
+ // Convenience helpers
144
+ isEmailConnected: user?.channels?.find(c => c.channel_type === "email")?.enabled === 1,
145
+ isTelegramConnected: user?.channels?.find(c => c.channel_type === "telegram")?.enabled === 1,
146
+ isDiscordConnected: user?.channels?.find(c => c.channel_type === "discord")?.enabled === 1,
147
+ };
148
+ }
@@ -0,0 +1 @@
1
+ export * from "./hooks";
@@ -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("./hooks"), exports);
@@ -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,178 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.notificationsAPI = void 0;
4
+ exports.setApiUrl = setApiUrl;
5
+ exports.getApiUrl = getApiUrl;
6
+ const auth_token_1 = require("../../shared/utils/auth-token");
7
+ const DEFAULT_API_URL = "https://notifications.b3.fun";
8
+ let apiUrl = DEFAULT_API_URL;
9
+ function setApiUrl(url) {
10
+ apiUrl = url;
11
+ }
12
+ function getApiUrl() {
13
+ return apiUrl;
14
+ }
15
+ function getHeaders(includeAuth = false) {
16
+ const headers = {
17
+ "Content-Type": "application/json",
18
+ };
19
+ if (includeAuth) {
20
+ const token = (0, auth_token_1.getAuthToken)();
21
+ if (token) {
22
+ headers["Authorization"] = `Bearer ${token}`;
23
+ }
24
+ }
25
+ return headers;
26
+ }
27
+ exports.notificationsAPI = {
28
+ // ===== USER MANAGEMENT =====
29
+ /**
30
+ * Register the current user (userId extracted from JWT)
31
+ */
32
+ async registerUser() {
33
+ const res = await fetch(`${apiUrl}/users`, {
34
+ method: "POST",
35
+ headers: getHeaders(true),
36
+ });
37
+ return res.json();
38
+ },
39
+ /**
40
+ * Get current user's profile and preferences
41
+ */
42
+ async getUser() {
43
+ const res = await fetch(`${apiUrl}/users/me`, {
44
+ headers: getHeaders(true),
45
+ });
46
+ return res.json();
47
+ },
48
+ /**
49
+ * Get current user's notification history
50
+ */
51
+ async getHistory(appId, limit = 100) {
52
+ const params = new URLSearchParams();
53
+ if (appId)
54
+ params.append("appId", appId);
55
+ params.append("limit", limit.toString());
56
+ const res = await fetch(`${apiUrl}/users/me/history?${params}`, {
57
+ headers: getHeaders(true),
58
+ });
59
+ return res.json();
60
+ },
61
+ // ===== CHANNELS =====
62
+ /**
63
+ * Add a notification channel for current user
64
+ */
65
+ async addChannel(channelType, channelIdentifier, metadata) {
66
+ const res = await fetch(`${apiUrl}/users/me/channels`, {
67
+ method: "POST",
68
+ headers: getHeaders(true),
69
+ body: JSON.stringify({
70
+ channelType,
71
+ channelIdentifier,
72
+ enabled: true,
73
+ metadata,
74
+ }),
75
+ });
76
+ return res.json();
77
+ },
78
+ /**
79
+ * Connect email for current user
80
+ */
81
+ async connectEmail(email) {
82
+ return this.addChannel("email", email);
83
+ },
84
+ /**
85
+ * Update a notification channel
86
+ */
87
+ async updateChannel(channelId, updates) {
88
+ const res = await fetch(`${apiUrl}/users/me/channels/${channelId}`, {
89
+ method: "PUT",
90
+ headers: getHeaders(true),
91
+ body: JSON.stringify(updates),
92
+ });
93
+ return res.json();
94
+ },
95
+ /**
96
+ * Delete a notification channel
97
+ */
98
+ async deleteChannel(channelId) {
99
+ const res = await fetch(`${apiUrl}/users/me/channels/${channelId}`, {
100
+ method: "DELETE",
101
+ headers: getHeaders(true),
102
+ });
103
+ return res.json();
104
+ },
105
+ // ===== TELEGRAM =====
106
+ /**
107
+ * Get Telegram deep link for current user
108
+ */
109
+ async getTelegramLink() {
110
+ const res = await fetch(`${apiUrl}/telegram/request-link`, {
111
+ method: "POST",
112
+ headers: getHeaders(true),
113
+ });
114
+ return res.json();
115
+ },
116
+ /**
117
+ * Check current user's Telegram connection status
118
+ */
119
+ async checkTelegramStatus() {
120
+ const res = await fetch(`${apiUrl}/telegram/status/me`, {
121
+ headers: getHeaders(true),
122
+ });
123
+ return res.json();
124
+ },
125
+ // ===== APP PREFERENCES =====
126
+ /**
127
+ * Save notification preferences for an app
128
+ */
129
+ async savePreferences(appId, settings) {
130
+ const res = await fetch(`${apiUrl}/users/me/apps/${appId}/settings`, {
131
+ method: "POST",
132
+ headers: getHeaders(true),
133
+ body: JSON.stringify({ ...settings, enabled: true }),
134
+ });
135
+ return res.json();
136
+ },
137
+ /**
138
+ * Get notification settings for an app
139
+ */
140
+ async getAppSettings(appId) {
141
+ const res = await fetch(`${apiUrl}/users/me/apps/${appId}/settings`, {
142
+ headers: getHeaders(true),
143
+ });
144
+ return res.json();
145
+ },
146
+ // ===== IN-APP NOTIFICATIONS =====
147
+ /**
148
+ * Get current user's in-app notifications
149
+ */
150
+ async getInAppNotifications() {
151
+ const res = await fetch(`${apiUrl}/users/me/notifications`, {
152
+ headers: getHeaders(true),
153
+ });
154
+ return res.json();
155
+ },
156
+ /**
157
+ * Mark a notification as read
158
+ */
159
+ async markNotificationAsRead(notificationId) {
160
+ const res = await fetch(`${apiUrl}/users/me/notifications/${notificationId}/read`, {
161
+ method: "PUT",
162
+ headers: getHeaders(true),
163
+ });
164
+ return res.json();
165
+ },
166
+ // ===== SENDING NOTIFICATIONS =====
167
+ /**
168
+ * Send a notification (requires auth)
169
+ */
170
+ async sendNotification(data) {
171
+ const res = await fetch(`${apiUrl}/send`, {
172
+ method: "POST",
173
+ headers: getHeaders(true),
174
+ body: JSON.stringify(data),
175
+ });
176
+ return res.json();
177
+ },
178
+ };
@@ -0,0 +1 @@
1
+ export * from "./api";
@@ -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("./api"), exports);
@@ -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,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Get the authentication token from the B3 auth cookie
3
+ * This token is managed by the B3 Global Account authentication system
4
+ *
5
+ * @returns The JWT token string or null if not found
6
+ */
7
+ export declare function getAuthToken(): string | null;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getAuthToken = getAuthToken;
7
+ const js_cookie_1 = __importDefault(require("js-cookie"));
8
+ const B3_AUTH_COOKIE_NAME = "b3-auth";
9
+ /**
10
+ * Get the authentication token from the B3 auth cookie
11
+ * This token is managed by the B3 Global Account authentication system
12
+ *
13
+ * @returns The JWT token string or null if not found
14
+ */
15
+ function getAuthToken() {
16
+ return js_cookie_1.default.get(B3_AUTH_COOKIE_NAME) || null;
17
+ }
@@ -1,3 +1,4 @@
1
+ export * from "./auth-token";
1
2
  export * from "./cn";
2
3
  export * from "./formatNumber";
3
4
  export * from "./formatUsername";
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  // Export utility functions
18
+ __exportStar(require("./auth-token"), exports);
18
19
  __exportStar(require("./cn"), exports);
19
20
  __exportStar(require("./formatNumber"), exports);
20
21
  __exportStar(require("./formatUsername"), exports);
@@ -274,12 +274,7 @@ export const OrderDetails = memo(function OrderDetails({ mode = "modal", order,
274
274
  ? "0"
275
275
  : order.payload.expectedDstAmount.toString();
276
276
  const formattedExpectedDstAmount = formatTokenAmount(BigInt(expectedDstAmount), dstToken.decimals);
277
- const actualDstAmount = order.type === "mint_nft" ||
278
- order.type === "join_tournament" ||
279
- order.type === "fund_tournament" ||
280
- order.type === "custom"
281
- ? undefined
282
- : order.payload.actualDstAmount;
277
+ const actualDstAmount = order.settlement?.actualDstAmount;
283
278
  const formattedActualDstAmount = actualDstAmount
284
279
  ? formatTokenAmount(BigInt(actualDstAmount), dstToken.decimals)
285
280
  : undefined;
@@ -10,12 +10,7 @@ export function OrderHistoryItem({ order, onSelectOrder, mode }) {
10
10
  const nft = order.type === "mint_nft" ? order.metadata.nft : undefined;
11
11
  const tournament = order.type === "join_tournament" || order.type === "fund_tournament" ? order.metadata.tournament : undefined;
12
12
  const dstToken = order.metadata.dstToken;
13
- const actualDstAmount = order.type === "mint_nft" ||
14
- order.type === "join_tournament" ||
15
- order.type === "fund_tournament" ||
16
- order.type === "custom"
17
- ? undefined
18
- : order.payload.actualDstAmount;
13
+ const actualDstAmount = order.settlement?.actualDstAmount;
19
14
  const expectedDstAmount = order.type === "mint_nft" ||
20
15
  order.type === "join_tournament" ||
21
16
  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;
@@ -188,8 +188,8 @@ export function useAnyspendFlow({ paymentType = "crypto", recipientAddress, load
188
188
  // Handle order completion
189
189
  useEffect(() => {
190
190
  if (oat?.data?.order.status === "executed") {
191
- // get the actualDstAmount if available from custompayload
192
- const amount = oat.data.order.payload?.actualDstAmount;
191
+ // get the actualDstAmount if available from settlement
192
+ const amount = oat.data.order.settlement?.actualDstAmount;
193
193
  const formattedActualDstAmount = amount
194
194
  ? formatTokenAmount(BigInt(amount), oat.data.order.metadata.dstToken.decimals)
195
195
  : undefined;
@@ -197,7 +197,7 @@ export function useAnyspendFlow({ paymentType = "crypto", recipientAddress, load
197
197
  }
198
198
  }, [
199
199
  oat?.data?.order.status,
200
- oat?.data?.order.payload,
200
+ oat?.data?.order.settlement?.actualDstAmount,
201
201
  onTransactionSuccess,
202
202
  oat?.data?.order.metadata.dstToken.decimals,
203
203
  ]);
@@ -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>>;