@b3dotfun/sdk 0.0.45 → 0.0.47-alpha.0
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 +3 -215
- package/dist/cjs/anyspend/react/components/AnySpend.js +13 -14
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +14 -15
- package/dist/cjs/anyspend/react/components/common/OrderHistory.js +2 -2
- package/dist/cjs/anyspend/react/components/common/OrderHistoryItem.js +6 -3
- package/dist/cjs/anyspend/types/api.d.ts +176 -0
- package/dist/cjs/anyspend/utils/chain.js +1 -1
- package/dist/cjs/shared/react/hooks/__tests__/useCurrencyConversion.test.js +245 -0
- package/dist/cjs/shared/utils/index.d.ts +0 -1
- package/dist/cjs/shared/utils/index.js +0 -1
- package/dist/esm/anyspend/react/components/AnySpend.js +14 -15
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +15 -16
- package/dist/esm/anyspend/react/components/common/OrderHistory.js +2 -2
- package/dist/esm/anyspend/react/components/common/OrderHistoryItem.js +8 -5
- package/dist/esm/anyspend/types/api.d.ts +176 -0
- package/dist/esm/anyspend/utils/chain.js +1 -1
- package/dist/esm/shared/react/hooks/__tests__/useCurrencyConversion.test.d.ts +1 -0
- package/dist/esm/shared/react/hooks/__tests__/useCurrencyConversion.test.js +243 -0
- package/dist/esm/shared/utils/index.d.ts +0 -1
- package/dist/esm/shared/utils/index.js +0 -1
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/types/api.d.ts +176 -0
- package/dist/types/shared/react/hooks/__tests__/useCurrencyConversion.test.d.ts +1 -0
- package/dist/types/shared/utils/index.d.ts +0 -1
- package/package.json +2 -21
- package/src/anyspend/react/components/AnySpend.tsx +21 -19
- package/src/anyspend/react/components/AnyspendDepositHype.tsx +21 -21
- package/src/anyspend/react/components/common/OrderHistory.tsx +11 -11
- package/src/anyspend/react/components/common/OrderHistoryItem.tsx +124 -129
- package/src/anyspend/types/api.ts +176 -0
- package/src/anyspend/utils/chain.ts +1 -4
- package/src/shared/utils/index.ts +0 -1
- package/dist/cjs/anyspend/react/components/common/ErrorSection.d.ts +0 -6
- package/dist/cjs/anyspend/react/components/common/ErrorSection.js +0 -12
- package/dist/cjs/notifications/index.d.ts +0 -4
- package/dist/cjs/notifications/index.js +0 -26
- package/dist/cjs/notifications/react/hooks/index.d.ts +0 -1
- package/dist/cjs/notifications/react/hooks/index.js +0 -17
- package/dist/cjs/notifications/react/hooks/useNotifications.d.ts +0 -42
- package/dist/cjs/notifications/react/hooks/useNotifications.js +0 -148
- package/dist/cjs/notifications/react/index.d.ts +0 -1
- package/dist/cjs/notifications/react/index.js +0 -17
- package/dist/cjs/notifications/services/api.d.ts +0 -65
- package/dist/cjs/notifications/services/api.js +0 -178
- package/dist/cjs/notifications/services/index.d.ts +0 -1
- package/dist/cjs/notifications/services/index.js +0 -17
- package/dist/cjs/notifications/types/index.d.ts +0 -50
- package/dist/cjs/notifications/types/index.js +0 -2
- package/dist/cjs/shared/utils/auth-token.d.ts +0 -7
- package/dist/cjs/shared/utils/auth-token.js +0 -17
- package/dist/esm/anyspend/react/components/common/ErrorSection.d.ts +0 -6
- package/dist/esm/anyspend/react/components/common/ErrorSection.js +0 -9
- package/dist/esm/notifications/index.d.ts +0 -4
- package/dist/esm/notifications/index.js +0 -8
- package/dist/esm/notifications/react/hooks/index.d.ts +0 -1
- package/dist/esm/notifications/react/hooks/index.js +0 -1
- package/dist/esm/notifications/react/hooks/useNotifications.d.ts +0 -42
- package/dist/esm/notifications/react/hooks/useNotifications.js +0 -145
- package/dist/esm/notifications/react/index.d.ts +0 -1
- package/dist/esm/notifications/react/index.js +0 -1
- package/dist/esm/notifications/services/api.d.ts +0 -65
- package/dist/esm/notifications/services/api.js +0 -173
- package/dist/esm/notifications/services/index.d.ts +0 -1
- package/dist/esm/notifications/services/index.js +0 -1
- package/dist/esm/notifications/types/index.d.ts +0 -50
- package/dist/esm/shared/utils/auth-token.d.ts +0 -7
- package/dist/esm/shared/utils/auth-token.js +0 -11
- package/dist/types/anyspend/react/components/common/ErrorSection.d.ts +0 -6
- package/dist/types/notifications/index.d.ts +0 -4
- package/dist/types/notifications/react/hooks/index.d.ts +0 -1
- package/dist/types/notifications/react/hooks/useNotifications.d.ts +0 -42
- package/dist/types/notifications/react/index.d.ts +0 -1
- package/dist/types/notifications/services/api.d.ts +0 -65
- package/dist/types/notifications/services/index.d.ts +0 -1
- package/dist/types/notifications/types/index.d.ts +0 -50
- package/dist/types/shared/utils/auth-token.d.ts +0 -7
- package/src/anyspend/react/components/common/ErrorSection.tsx +0 -21
- package/src/notifications/index.ts +0 -11
- package/src/notifications/react/hooks/index.ts +0 -1
- package/src/notifications/react/hooks/useNotifications.ts +0 -153
- package/src/notifications/react/index.ts +0 -1
- package/src/notifications/services/api.ts +0 -211
- package/src/notifications/services/index.ts +0 -1
- package/src/notifications/types/index.ts +0 -57
- package/src/shared/utils/auth-token.ts +0 -13
- /package/dist/{esm/notifications/types/index.js → cjs/shared/react/hooks/__tests__/useCurrencyConversion.test.d.ts} +0 -0
|
@@ -5,6 +5,12 @@
|
|
|
5
5
|
|
|
6
6
|
export interface paths {
|
|
7
7
|
"/chains/{chainId}/tokens": {
|
|
8
|
+
parameters: {
|
|
9
|
+
query?: never;
|
|
10
|
+
header?: never;
|
|
11
|
+
path?: never;
|
|
12
|
+
cookie?: never;
|
|
13
|
+
};
|
|
8
14
|
/**
|
|
9
15
|
* Get tokens for a chain
|
|
10
16
|
* @description Retrieves available tokens for a specific blockchain
|
|
@@ -20,6 +26,7 @@ export interface paths {
|
|
|
20
26
|
/** @description Maximum number of tokens to return */
|
|
21
27
|
limit?: number;
|
|
22
28
|
};
|
|
29
|
+
header?: never;
|
|
23
30
|
path: {
|
|
24
31
|
/**
|
|
25
32
|
* @description Blockchain chain ID
|
|
@@ -27,10 +34,15 @@ export interface paths {
|
|
|
27
34
|
*/
|
|
28
35
|
chainId: number;
|
|
29
36
|
};
|
|
37
|
+
cookie?: never;
|
|
30
38
|
};
|
|
39
|
+
requestBody?: never;
|
|
31
40
|
responses: {
|
|
32
41
|
/** @description Tokens retrieved successfully */
|
|
33
42
|
200: {
|
|
43
|
+
headers: {
|
|
44
|
+
[name: string]: unknown;
|
|
45
|
+
};
|
|
34
46
|
content: {
|
|
35
47
|
"application/json": {
|
|
36
48
|
/** @example true */
|
|
@@ -61,6 +73,9 @@ export interface paths {
|
|
|
61
73
|
};
|
|
62
74
|
/** @description Bad request */
|
|
63
75
|
400: {
|
|
76
|
+
headers: {
|
|
77
|
+
[name: string]: unknown;
|
|
78
|
+
};
|
|
64
79
|
content: {
|
|
65
80
|
"application/json": {
|
|
66
81
|
/** @example false */
|
|
@@ -74,8 +89,21 @@ export interface paths {
|
|
|
74
89
|
};
|
|
75
90
|
};
|
|
76
91
|
};
|
|
92
|
+
put?: never;
|
|
93
|
+
post?: never;
|
|
94
|
+
delete?: never;
|
|
95
|
+
options?: never;
|
|
96
|
+
head?: never;
|
|
97
|
+
patch?: never;
|
|
98
|
+
trace?: never;
|
|
77
99
|
};
|
|
78
100
|
"/onramp/coinbase/options": {
|
|
101
|
+
parameters: {
|
|
102
|
+
query?: never;
|
|
103
|
+
header?: never;
|
|
104
|
+
path?: never;
|
|
105
|
+
cookie?: never;
|
|
106
|
+
};
|
|
79
107
|
/**
|
|
80
108
|
* Get Coinbase onramp options
|
|
81
109
|
* @description Retrieves available Coinbase onramp configuration options.
|
|
@@ -108,10 +136,17 @@ export interface paths {
|
|
|
108
136
|
*/
|
|
109
137
|
chainIds?: string[];
|
|
110
138
|
};
|
|
139
|
+
header?: never;
|
|
140
|
+
path?: never;
|
|
141
|
+
cookie?: never;
|
|
111
142
|
};
|
|
143
|
+
requestBody?: never;
|
|
112
144
|
responses: {
|
|
113
145
|
/** @description Coinbase options retrieved successfully */
|
|
114
146
|
200: {
|
|
147
|
+
headers: {
|
|
148
|
+
[name: string]: unknown;
|
|
149
|
+
};
|
|
115
150
|
content: {
|
|
116
151
|
"application/json": {
|
|
117
152
|
/** @example true */
|
|
@@ -214,6 +249,9 @@ export interface paths {
|
|
|
214
249
|
};
|
|
215
250
|
/** @description Bad request */
|
|
216
251
|
400: {
|
|
252
|
+
headers: {
|
|
253
|
+
[name: string]: unknown;
|
|
254
|
+
};
|
|
217
255
|
content: {
|
|
218
256
|
"application/json": {
|
|
219
257
|
/** @example false */
|
|
@@ -227,8 +265,21 @@ export interface paths {
|
|
|
227
265
|
};
|
|
228
266
|
};
|
|
229
267
|
};
|
|
268
|
+
put?: never;
|
|
269
|
+
post?: never;
|
|
270
|
+
delete?: never;
|
|
271
|
+
options?: never;
|
|
272
|
+
head?: never;
|
|
273
|
+
patch?: never;
|
|
274
|
+
trace?: never;
|
|
230
275
|
};
|
|
231
276
|
"/onramp/stripe/supported": {
|
|
277
|
+
parameters: {
|
|
278
|
+
query?: never;
|
|
279
|
+
header?: never;
|
|
280
|
+
path?: never;
|
|
281
|
+
cookie?: never;
|
|
282
|
+
};
|
|
232
283
|
/**
|
|
233
284
|
* Check Stripe support
|
|
234
285
|
* @description Checks if Stripe onramp and Stripe Web2 are supported based on IP address location and optional transaction amount
|
|
@@ -242,10 +293,17 @@ export interface paths {
|
|
|
242
293
|
*/
|
|
243
294
|
usdAmount?: string;
|
|
244
295
|
};
|
|
296
|
+
header?: never;
|
|
297
|
+
path?: never;
|
|
298
|
+
cookie?: never;
|
|
245
299
|
};
|
|
300
|
+
requestBody?: never;
|
|
246
301
|
responses: {
|
|
247
302
|
/** @description Stripe support status retrieved successfully */
|
|
248
303
|
200: {
|
|
304
|
+
headers: {
|
|
305
|
+
[name: string]: unknown;
|
|
306
|
+
};
|
|
249
307
|
content: {
|
|
250
308
|
"application/json": {
|
|
251
309
|
/** @example true */
|
|
@@ -268,6 +326,9 @@ export interface paths {
|
|
|
268
326
|
};
|
|
269
327
|
/** @description Bad request */
|
|
270
328
|
400: {
|
|
329
|
+
headers: {
|
|
330
|
+
[name: string]: unknown;
|
|
331
|
+
};
|
|
271
332
|
content: {
|
|
272
333
|
"application/json": {
|
|
273
334
|
/** @example false */
|
|
@@ -281,8 +342,21 @@ export interface paths {
|
|
|
281
342
|
};
|
|
282
343
|
};
|
|
283
344
|
};
|
|
345
|
+
put?: never;
|
|
346
|
+
post?: never;
|
|
347
|
+
delete?: never;
|
|
348
|
+
options?: never;
|
|
349
|
+
head?: never;
|
|
350
|
+
patch?: never;
|
|
351
|
+
trace?: never;
|
|
284
352
|
};
|
|
285
353
|
"/orders": {
|
|
354
|
+
parameters: {
|
|
355
|
+
query?: never;
|
|
356
|
+
header?: never;
|
|
357
|
+
path?: never;
|
|
358
|
+
cookie?: never;
|
|
359
|
+
};
|
|
286
360
|
/**
|
|
287
361
|
* Get orders by creator
|
|
288
362
|
* @description Retrieves all orders created by a specific address
|
|
@@ -306,10 +380,17 @@ export interface paths {
|
|
|
306
380
|
*/
|
|
307
381
|
offset?: string;
|
|
308
382
|
};
|
|
383
|
+
header?: never;
|
|
384
|
+
path?: never;
|
|
385
|
+
cookie?: never;
|
|
309
386
|
};
|
|
387
|
+
requestBody?: never;
|
|
310
388
|
responses: {
|
|
311
389
|
/** @description Orders retrieved successfully */
|
|
312
390
|
200: {
|
|
391
|
+
headers: {
|
|
392
|
+
[name: string]: unknown;
|
|
393
|
+
};
|
|
313
394
|
content: {
|
|
314
395
|
"application/json": {
|
|
315
396
|
/** @example true */
|
|
@@ -325,6 +406,9 @@ export interface paths {
|
|
|
325
406
|
};
|
|
326
407
|
/** @description Bad request */
|
|
327
408
|
400: {
|
|
409
|
+
headers: {
|
|
410
|
+
[name: string]: unknown;
|
|
411
|
+
};
|
|
328
412
|
content: {
|
|
329
413
|
"application/json": {
|
|
330
414
|
/** @example false */
|
|
@@ -338,11 +422,18 @@ export interface paths {
|
|
|
338
422
|
};
|
|
339
423
|
};
|
|
340
424
|
};
|
|
425
|
+
put?: never;
|
|
341
426
|
/**
|
|
342
427
|
* Create a new order
|
|
343
428
|
* @description Creates a new order for token transactions across chains
|
|
344
429
|
*/
|
|
345
430
|
post: {
|
|
431
|
+
parameters: {
|
|
432
|
+
query?: never;
|
|
433
|
+
header?: never;
|
|
434
|
+
path?: never;
|
|
435
|
+
cookie?: never;
|
|
436
|
+
};
|
|
346
437
|
requestBody: {
|
|
347
438
|
content: {
|
|
348
439
|
"application/json": components["schemas"]["OrderRequest"];
|
|
@@ -351,6 +442,9 @@ export interface paths {
|
|
|
351
442
|
responses: {
|
|
352
443
|
/** @description Order created successfully */
|
|
353
444
|
200: {
|
|
445
|
+
headers: {
|
|
446
|
+
[name: string]: unknown;
|
|
447
|
+
};
|
|
354
448
|
content: {
|
|
355
449
|
"application/json": {
|
|
356
450
|
/** @example true */
|
|
@@ -365,6 +459,9 @@ export interface paths {
|
|
|
365
459
|
};
|
|
366
460
|
/** @description Bad request */
|
|
367
461
|
400: {
|
|
462
|
+
headers: {
|
|
463
|
+
[name: string]: unknown;
|
|
464
|
+
};
|
|
368
465
|
content: {
|
|
369
466
|
"application/json": {
|
|
370
467
|
/** @example false */
|
|
@@ -378,14 +475,27 @@ export interface paths {
|
|
|
378
475
|
};
|
|
379
476
|
};
|
|
380
477
|
};
|
|
478
|
+
delete?: never;
|
|
479
|
+
options?: never;
|
|
480
|
+
head?: never;
|
|
481
|
+
patch?: never;
|
|
482
|
+
trace?: never;
|
|
381
483
|
};
|
|
382
484
|
"/orders/{orderId}": {
|
|
485
|
+
parameters: {
|
|
486
|
+
query?: never;
|
|
487
|
+
header?: never;
|
|
488
|
+
path?: never;
|
|
489
|
+
cookie?: never;
|
|
490
|
+
};
|
|
383
491
|
/**
|
|
384
492
|
* Get order and transactions
|
|
385
493
|
* @description Retrieves order details along with associated transactions
|
|
386
494
|
*/
|
|
387
495
|
get: {
|
|
388
496
|
parameters: {
|
|
497
|
+
query?: never;
|
|
498
|
+
header?: never;
|
|
389
499
|
path: {
|
|
390
500
|
/**
|
|
391
501
|
* @description Unique order identifier
|
|
@@ -393,10 +503,15 @@ export interface paths {
|
|
|
393
503
|
*/
|
|
394
504
|
orderId: string;
|
|
395
505
|
};
|
|
506
|
+
cookie?: never;
|
|
396
507
|
};
|
|
508
|
+
requestBody?: never;
|
|
397
509
|
responses: {
|
|
398
510
|
/** @description Order and transactions retrieved successfully */
|
|
399
511
|
200: {
|
|
512
|
+
headers: {
|
|
513
|
+
[name: string]: unknown;
|
|
514
|
+
};
|
|
400
515
|
content: {
|
|
401
516
|
"application/json": {
|
|
402
517
|
/** @example true */
|
|
@@ -448,6 +563,9 @@ export interface paths {
|
|
|
448
563
|
};
|
|
449
564
|
/** @description Bad request */
|
|
450
565
|
400: {
|
|
566
|
+
headers: {
|
|
567
|
+
[name: string]: unknown;
|
|
568
|
+
};
|
|
451
569
|
content: {
|
|
452
570
|
"application/json": {
|
|
453
571
|
/** @example false */
|
|
@@ -461,6 +579,9 @@ export interface paths {
|
|
|
461
579
|
};
|
|
462
580
|
/** @description Order not found */
|
|
463
581
|
404: {
|
|
582
|
+
headers: {
|
|
583
|
+
[name: string]: unknown;
|
|
584
|
+
};
|
|
464
585
|
content: {
|
|
465
586
|
"application/json": {
|
|
466
587
|
/** @example false */
|
|
@@ -474,13 +595,34 @@ export interface paths {
|
|
|
474
595
|
};
|
|
475
596
|
};
|
|
476
597
|
};
|
|
598
|
+
put?: never;
|
|
599
|
+
post?: never;
|
|
600
|
+
delete?: never;
|
|
601
|
+
options?: never;
|
|
602
|
+
head?: never;
|
|
603
|
+
patch?: never;
|
|
604
|
+
trace?: never;
|
|
477
605
|
};
|
|
478
606
|
"/orders/quote": {
|
|
607
|
+
parameters: {
|
|
608
|
+
query?: never;
|
|
609
|
+
header?: never;
|
|
610
|
+
path?: never;
|
|
611
|
+
cookie?: never;
|
|
612
|
+
};
|
|
613
|
+
get?: never;
|
|
614
|
+
put?: never;
|
|
479
615
|
/**
|
|
480
616
|
* Get anyspend quote
|
|
481
617
|
* @description Retrieves a quote to swap, execute contract, or participate in HypeDuel
|
|
482
618
|
*/
|
|
483
619
|
post: {
|
|
620
|
+
parameters: {
|
|
621
|
+
query?: never;
|
|
622
|
+
header?: never;
|
|
623
|
+
path?: never;
|
|
624
|
+
cookie?: never;
|
|
625
|
+
};
|
|
484
626
|
requestBody: {
|
|
485
627
|
content: {
|
|
486
628
|
"application/json":
|
|
@@ -680,6 +822,9 @@ export interface paths {
|
|
|
680
822
|
responses: {
|
|
681
823
|
/** @description Quote retrieved successfully */
|
|
682
824
|
200: {
|
|
825
|
+
headers: {
|
|
826
|
+
[name: string]: unknown;
|
|
827
|
+
};
|
|
683
828
|
content: {
|
|
684
829
|
"application/json": {
|
|
685
830
|
/** @example true */
|
|
@@ -858,6 +1003,9 @@ export interface paths {
|
|
|
858
1003
|
};
|
|
859
1004
|
/** @description Bad request */
|
|
860
1005
|
400: {
|
|
1006
|
+
headers: {
|
|
1007
|
+
[name: string]: unknown;
|
|
1008
|
+
};
|
|
861
1009
|
content: {
|
|
862
1010
|
"application/json": {
|
|
863
1011
|
/** @example false */
|
|
@@ -871,8 +1019,19 @@ export interface paths {
|
|
|
871
1019
|
};
|
|
872
1020
|
};
|
|
873
1021
|
};
|
|
1022
|
+
delete?: never;
|
|
1023
|
+
options?: never;
|
|
1024
|
+
head?: never;
|
|
1025
|
+
patch?: never;
|
|
1026
|
+
trace?: never;
|
|
874
1027
|
};
|
|
875
1028
|
"/stripe/clientSecret": {
|
|
1029
|
+
parameters: {
|
|
1030
|
+
query?: never;
|
|
1031
|
+
header?: never;
|
|
1032
|
+
path?: never;
|
|
1033
|
+
cookie?: never;
|
|
1034
|
+
};
|
|
876
1035
|
/**
|
|
877
1036
|
* Get Stripe client secret
|
|
878
1037
|
* @description Retrieves a Stripe client secret for payment processing using a payment intent ID
|
|
@@ -886,10 +1045,17 @@ export interface paths {
|
|
|
886
1045
|
*/
|
|
887
1046
|
paymentIntentId: string;
|
|
888
1047
|
};
|
|
1048
|
+
header?: never;
|
|
1049
|
+
path?: never;
|
|
1050
|
+
cookie?: never;
|
|
889
1051
|
};
|
|
1052
|
+
requestBody?: never;
|
|
890
1053
|
responses: {
|
|
891
1054
|
/** @description Client secret retrieved successfully */
|
|
892
1055
|
200: {
|
|
1056
|
+
headers: {
|
|
1057
|
+
[name: string]: unknown;
|
|
1058
|
+
};
|
|
893
1059
|
content: {
|
|
894
1060
|
"application/json": {
|
|
895
1061
|
/** @example true */
|
|
@@ -908,6 +1074,9 @@ export interface paths {
|
|
|
908
1074
|
};
|
|
909
1075
|
/** @description Bad request - PaymentIntentId is required or invalid */
|
|
910
1076
|
400: {
|
|
1077
|
+
headers: {
|
|
1078
|
+
[name: string]: unknown;
|
|
1079
|
+
};
|
|
911
1080
|
content: {
|
|
912
1081
|
"application/json": {
|
|
913
1082
|
/** @example false */
|
|
@@ -921,6 +1090,13 @@ export interface paths {
|
|
|
921
1090
|
};
|
|
922
1091
|
};
|
|
923
1092
|
};
|
|
1093
|
+
put?: never;
|
|
1094
|
+
post?: never;
|
|
1095
|
+
delete?: never;
|
|
1096
|
+
options?: never;
|
|
1097
|
+
head?: never;
|
|
1098
|
+
patch?: never;
|
|
1099
|
+
trace?: never;
|
|
924
1100
|
};
|
|
925
1101
|
}
|
|
926
1102
|
export type webhooks = Record<string, never>;
|
|
@@ -136,10 +136,7 @@ export const EVM_MAINNET: Record<number, IEVMChain> = {
|
|
|
136
136
|
canDepositNative: true,
|
|
137
137
|
defaultToken: getAvaxToken(),
|
|
138
138
|
nativeToken: getAvaxToken(),
|
|
139
|
-
viem: getCustomEvmChain(
|
|
140
|
-
avalanche,
|
|
141
|
-
"https://burned-billowing-pond.avalanche-mainnet.quiknode.pro/24289978a524a18ef42e568e04fe8cad8c7b6720/ext/bc/C/rpc/",
|
|
142
|
-
),
|
|
139
|
+
viem: getCustomEvmChain(avalanche, "https://avalanche-c-chain-rpc.publicnode.com"),
|
|
143
140
|
pollingInterval: 1000, // 1 second for Avalanche
|
|
144
141
|
zapperEnum: "AVALANCHE_MAINNET",
|
|
145
142
|
coingeckoName: "avalanche",
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ErrorSection = ErrorSection;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const lucide_react_1 = require("lucide-react");
|
|
6
|
-
function ErrorSection({ error, message }) {
|
|
7
|
-
if (!error && !message) {
|
|
8
|
-
return null;
|
|
9
|
-
}
|
|
10
|
-
const errorMessage = message || error?.message || "An error occurred";
|
|
11
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: "error-section bg-as-on-surface-1 flex w-full max-w-[460px] items-center gap-2 rounded-2xl px-4 py-2", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.CircleAlert, { className: "bg-as-red h-4 min-h-4 w-4 min-w-4 rounded-full p-0 text-sm font-medium text-white" }), (0, jsx_runtime_1.jsx)("div", { className: "text-as-red text-sm", children: errorMessage })] }));
|
|
12
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
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; } });
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./useNotifications";
|
|
@@ -1,17 +0,0 @@
|
|
|
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);
|
|
@@ -1,42 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,148 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./hooks";
|