@zubari/sdk 0.2.4 → 0.2.6
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/dist/TransactionService-8xSEGoWA.d.mts +579 -0
- package/dist/TransactionService-CaIcCoqY.d.ts +579 -0
- package/dist/{WalletManager-CQSrvRVs.d.mts → WalletManager-B1qvFF4K.d.mts} +1 -1
- package/dist/{WalletManager-U1YWIUWn.d.ts → WalletManager-CCs4Jsv7.d.ts} +1 -1
- package/dist/{index-CkPxa5Bn.d.ts → index-BPojlGT6.d.ts} +2 -2
- package/dist/{index-Bou-9cAG.d.ts → index-Cx389p_j.d.mts} +1 -1
- package/dist/{index-Bou-9cAG.d.mts → index-Cx389p_j.d.ts} +1 -1
- package/dist/{index--dqjW2SS.d.mts → index-xZYY0MEX.d.mts} +2 -2
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/protocols/index.d.mts +1 -1
- package/dist/protocols/index.d.ts +1 -1
- package/dist/react/index.d.mts +3 -3
- package/dist/react/index.d.ts +3 -3
- package/dist/services/index.d.mts +591 -465
- package/dist/services/index.d.ts +591 -465
- package/dist/services/index.js +690 -2
- package/dist/services/index.js.map +1 -1
- package/dist/services/index.mjs +688 -3
- package/dist/services/index.mjs.map +1 -1
- package/dist/wallet/index.d.mts +3 -3
- package/dist/wallet/index.d.ts +3 -3
- package/package.json +1 -1
package/dist/services/index.js
CHANGED
|
@@ -296,6 +296,691 @@ function getWdkApiClient(baseUrl) {
|
|
|
296
296
|
return wdkApiClient;
|
|
297
297
|
}
|
|
298
298
|
|
|
299
|
+
// src/services/ZubariApiClient.ts
|
|
300
|
+
var ZubariApiClient = class {
|
|
301
|
+
config;
|
|
302
|
+
constructor(config) {
|
|
303
|
+
this.config = {
|
|
304
|
+
baseUrl: config.baseUrl.replace(/\/$/, ""),
|
|
305
|
+
// Remove trailing slash
|
|
306
|
+
timeout: config.timeout || 3e4,
|
|
307
|
+
authToken: config.authToken
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Set the authentication token
|
|
312
|
+
*/
|
|
313
|
+
setAuthToken(token) {
|
|
314
|
+
this.config.authToken = token;
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Clear the authentication token
|
|
318
|
+
*/
|
|
319
|
+
clearAuthToken() {
|
|
320
|
+
this.config.authToken = void 0;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Make an authenticated request to the API
|
|
324
|
+
*/
|
|
325
|
+
async request(method, path, body) {
|
|
326
|
+
const headers = {
|
|
327
|
+
"Content-Type": "application/json"
|
|
328
|
+
};
|
|
329
|
+
if (this.config.authToken) {
|
|
330
|
+
headers["Authorization"] = `Bearer ${this.config.authToken}`;
|
|
331
|
+
}
|
|
332
|
+
const response = await fetch(`${this.config.baseUrl}${path}`, {
|
|
333
|
+
method,
|
|
334
|
+
headers,
|
|
335
|
+
body: body ? JSON.stringify(body) : void 0
|
|
336
|
+
});
|
|
337
|
+
if (!response.ok) {
|
|
338
|
+
const errorData = await response.json().catch(() => ({}));
|
|
339
|
+
throw new Error(errorData.error || `HTTP ${response.status}: ${response.statusText}`);
|
|
340
|
+
}
|
|
341
|
+
return response.json();
|
|
342
|
+
}
|
|
343
|
+
// ============ NFT Methods ============
|
|
344
|
+
/**
|
|
345
|
+
* Get all NFTs with optional filters
|
|
346
|
+
*/
|
|
347
|
+
async getNFTs(filters) {
|
|
348
|
+
try {
|
|
349
|
+
const params = new URLSearchParams();
|
|
350
|
+
if (filters) {
|
|
351
|
+
Object.entries(filters).forEach(([key, value]) => {
|
|
352
|
+
if (value !== void 0) {
|
|
353
|
+
params.append(key, String(value));
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
const queryString = params.toString();
|
|
358
|
+
const path = `/api/nfts${queryString ? `?${queryString}` : ""}`;
|
|
359
|
+
return await this.request("GET", path);
|
|
360
|
+
} catch (error) {
|
|
361
|
+
return {
|
|
362
|
+
success: false,
|
|
363
|
+
error: error instanceof Error ? error.message : "Failed to get NFTs"
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Get a single NFT by ID
|
|
369
|
+
*/
|
|
370
|
+
async getNFT(nftId) {
|
|
371
|
+
try {
|
|
372
|
+
const nft = await this.request("GET", `/api/nfts/${nftId}`);
|
|
373
|
+
return { success: true, nft };
|
|
374
|
+
} catch (error) {
|
|
375
|
+
return {
|
|
376
|
+
success: false,
|
|
377
|
+
error: error instanceof Error ? error.message : "Failed to get NFT"
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* Create a new NFT (lazy minted)
|
|
383
|
+
*/
|
|
384
|
+
async createNFT(data, image) {
|
|
385
|
+
try {
|
|
386
|
+
const formData = new FormData();
|
|
387
|
+
formData.append("image", image);
|
|
388
|
+
formData.append("name", data.name);
|
|
389
|
+
if (data.description) formData.append("description", data.description);
|
|
390
|
+
formData.append("price", data.price);
|
|
391
|
+
formData.append("currency", data.currency);
|
|
392
|
+
if (data.royaltyBps !== void 0) formData.append("royaltyBps", String(data.royaltyBps));
|
|
393
|
+
if (data.attributes) formData.append("attributes", JSON.stringify(data.attributes));
|
|
394
|
+
if (data.externalUrl) formData.append("externalUrl", data.externalUrl);
|
|
395
|
+
const headers = {};
|
|
396
|
+
if (this.config.authToken) {
|
|
397
|
+
headers["Authorization"] = `Bearer ${this.config.authToken}`;
|
|
398
|
+
}
|
|
399
|
+
const response = await fetch(`${this.config.baseUrl}/api/nfts`, {
|
|
400
|
+
method: "POST",
|
|
401
|
+
headers,
|
|
402
|
+
body: formData
|
|
403
|
+
});
|
|
404
|
+
if (!response.ok) {
|
|
405
|
+
const errorData = await response.json().catch(() => ({}));
|
|
406
|
+
throw new Error(errorData.error || `HTTP ${response.status}`);
|
|
407
|
+
}
|
|
408
|
+
const nft = await response.json();
|
|
409
|
+
return { success: true, nft };
|
|
410
|
+
} catch (error) {
|
|
411
|
+
return {
|
|
412
|
+
success: false,
|
|
413
|
+
error: error instanceof Error ? error.message : "Failed to create NFT"
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* Create a voucher for an NFT (EIP-712 signed)
|
|
419
|
+
*/
|
|
420
|
+
async createVoucher(nftId, params) {
|
|
421
|
+
try {
|
|
422
|
+
return await this.request("POST", `/api/nfts/${nftId}/voucher`, params);
|
|
423
|
+
} catch (error) {
|
|
424
|
+
return {
|
|
425
|
+
success: false,
|
|
426
|
+
error: error instanceof Error ? error.message : "Failed to create voucher"
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Redeem an NFT voucher (buy/mint)
|
|
432
|
+
*/
|
|
433
|
+
async redeemVoucher(nftId, params) {
|
|
434
|
+
try {
|
|
435
|
+
return await this.request("POST", `/api/nfts/${nftId}/redeem`, params);
|
|
436
|
+
} catch (error) {
|
|
437
|
+
return {
|
|
438
|
+
success: false,
|
|
439
|
+
error: error instanceof Error ? error.message : "Failed to redeem voucher"
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* Get voucher status for an NFT
|
|
445
|
+
*/
|
|
446
|
+
async getVoucherStatus(nftId) {
|
|
447
|
+
try {
|
|
448
|
+
return await this.request("GET", `/api/nfts/${nftId}/voucher/status`);
|
|
449
|
+
} catch (error) {
|
|
450
|
+
return {
|
|
451
|
+
success: false,
|
|
452
|
+
error: error instanceof Error ? error.message : "Failed to get voucher status"
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
// ============ Marketplace Methods ============
|
|
457
|
+
/**
|
|
458
|
+
* Get all active listings
|
|
459
|
+
*/
|
|
460
|
+
async getListings(filters) {
|
|
461
|
+
try {
|
|
462
|
+
const params = new URLSearchParams();
|
|
463
|
+
if (filters) {
|
|
464
|
+
Object.entries(filters).forEach(([key, value]) => {
|
|
465
|
+
if (value !== void 0) {
|
|
466
|
+
params.append(key, String(value));
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
const queryString = params.toString();
|
|
471
|
+
const path = `/api/market/listings${queryString ? `?${queryString}` : ""}`;
|
|
472
|
+
return await this.request("GET", path);
|
|
473
|
+
} catch (error) {
|
|
474
|
+
return {
|
|
475
|
+
success: false,
|
|
476
|
+
error: error instanceof Error ? error.message : "Failed to get listings"
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* List an NFT for sale
|
|
482
|
+
*/
|
|
483
|
+
async listItem(params) {
|
|
484
|
+
try {
|
|
485
|
+
return await this.request("POST", "/api/market/list", params);
|
|
486
|
+
} catch (error) {
|
|
487
|
+
return {
|
|
488
|
+
success: false,
|
|
489
|
+
error: error instanceof Error ? error.message : "Failed to list item"
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* Buy a listed NFT
|
|
495
|
+
*/
|
|
496
|
+
async buyItem(params) {
|
|
497
|
+
try {
|
|
498
|
+
return await this.request("POST", "/api/market/buy", params);
|
|
499
|
+
} catch (error) {
|
|
500
|
+
return {
|
|
501
|
+
success: false,
|
|
502
|
+
error: error instanceof Error ? error.message : "Failed to buy item"
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Cancel a listing
|
|
508
|
+
*/
|
|
509
|
+
async cancelListing(params) {
|
|
510
|
+
try {
|
|
511
|
+
return await this.request("POST", "/api/market/cancel", params);
|
|
512
|
+
} catch (error) {
|
|
513
|
+
return {
|
|
514
|
+
success: false,
|
|
515
|
+
error: error instanceof Error ? error.message : "Failed to cancel listing"
|
|
516
|
+
};
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Update listing price
|
|
521
|
+
*/
|
|
522
|
+
async updateListingPrice(params) {
|
|
523
|
+
try {
|
|
524
|
+
return await this.request("PATCH", "/api/market/price", params);
|
|
525
|
+
} catch (error) {
|
|
526
|
+
return {
|
|
527
|
+
success: false,
|
|
528
|
+
error: error instanceof Error ? error.message : "Failed to update price"
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* Get current user's listings
|
|
534
|
+
*/
|
|
535
|
+
async getMyListings(filters) {
|
|
536
|
+
try {
|
|
537
|
+
const params = new URLSearchParams();
|
|
538
|
+
if (filters) {
|
|
539
|
+
Object.entries(filters).forEach(([key, value]) => {
|
|
540
|
+
if (value !== void 0) {
|
|
541
|
+
params.append(key, String(value));
|
|
542
|
+
}
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
const queryString = params.toString();
|
|
546
|
+
const path = `/api/market/my/listings${queryString ? `?${queryString}` : ""}`;
|
|
547
|
+
return await this.request("GET", path);
|
|
548
|
+
} catch (error) {
|
|
549
|
+
return {
|
|
550
|
+
success: false,
|
|
551
|
+
error: error instanceof Error ? error.message : "Failed to get my listings"
|
|
552
|
+
};
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
/**
|
|
556
|
+
* Get marketplace statistics
|
|
557
|
+
*/
|
|
558
|
+
async getMarketStats() {
|
|
559
|
+
try {
|
|
560
|
+
return await this.request("GET", "/api/market/stats");
|
|
561
|
+
} catch (error) {
|
|
562
|
+
return {
|
|
563
|
+
success: false,
|
|
564
|
+
error: error instanceof Error ? error.message : "Failed to get market stats"
|
|
565
|
+
};
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
// ============ Tips Methods ============
|
|
569
|
+
/**
|
|
570
|
+
* Send a tip to a creator
|
|
571
|
+
*/
|
|
572
|
+
async sendTip(params) {
|
|
573
|
+
try {
|
|
574
|
+
return await this.request("POST", "/api/tips", params);
|
|
575
|
+
} catch (error) {
|
|
576
|
+
return {
|
|
577
|
+
success: false,
|
|
578
|
+
error: error instanceof Error ? error.message : "Failed to send tip"
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* Get tip statistics for current user
|
|
584
|
+
*/
|
|
585
|
+
async getTipStats() {
|
|
586
|
+
try {
|
|
587
|
+
const data = await this.request("GET", "/api/tips/my/stats");
|
|
588
|
+
return { success: true, ...data };
|
|
589
|
+
} catch (error) {
|
|
590
|
+
return {
|
|
591
|
+
success: false,
|
|
592
|
+
error: error instanceof Error ? error.message : "Failed to get tip stats"
|
|
593
|
+
};
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
/**
|
|
597
|
+
* Get tips sent by current user
|
|
598
|
+
*/
|
|
599
|
+
async getSentTips(filters) {
|
|
600
|
+
try {
|
|
601
|
+
const params = new URLSearchParams();
|
|
602
|
+
if (filters) {
|
|
603
|
+
Object.entries(filters).forEach(([key, value]) => {
|
|
604
|
+
if (value !== void 0) {
|
|
605
|
+
params.append(key, String(value));
|
|
606
|
+
}
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
const queryString = params.toString();
|
|
610
|
+
const path = `/api/tips/sent${queryString ? `?${queryString}` : ""}`;
|
|
611
|
+
const data = await this.request("GET", path);
|
|
612
|
+
return { success: true, ...data };
|
|
613
|
+
} catch (error) {
|
|
614
|
+
return {
|
|
615
|
+
success: false,
|
|
616
|
+
error: error instanceof Error ? error.message : "Failed to get sent tips"
|
|
617
|
+
};
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
/**
|
|
621
|
+
* Get tips received by current user
|
|
622
|
+
*/
|
|
623
|
+
async getReceivedTips(filters) {
|
|
624
|
+
try {
|
|
625
|
+
const params = new URLSearchParams();
|
|
626
|
+
if (filters) {
|
|
627
|
+
Object.entries(filters).forEach(([key, value]) => {
|
|
628
|
+
if (value !== void 0) {
|
|
629
|
+
params.append(key, String(value));
|
|
630
|
+
}
|
|
631
|
+
});
|
|
632
|
+
}
|
|
633
|
+
const queryString = params.toString();
|
|
634
|
+
const path = `/api/tips/received${queryString ? `?${queryString}` : ""}`;
|
|
635
|
+
const data = await this.request("GET", path);
|
|
636
|
+
return { success: true, ...data };
|
|
637
|
+
} catch (error) {
|
|
638
|
+
return {
|
|
639
|
+
success: false,
|
|
640
|
+
error: error instanceof Error ? error.message : "Failed to get received tips"
|
|
641
|
+
};
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
/**
|
|
645
|
+
* Get a single tip by ID
|
|
646
|
+
*/
|
|
647
|
+
async getTip(tipId) {
|
|
648
|
+
try {
|
|
649
|
+
const data = await this.request("GET", `/api/tips/${tipId}`);
|
|
650
|
+
return { success: true, tip: data.tip };
|
|
651
|
+
} catch (error) {
|
|
652
|
+
return {
|
|
653
|
+
success: false,
|
|
654
|
+
error: error instanceof Error ? error.message : "Failed to get tip"
|
|
655
|
+
};
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* Update tip status (for transaction confirmation)
|
|
660
|
+
*/
|
|
661
|
+
async updateTipStatus(tipId, params) {
|
|
662
|
+
try {
|
|
663
|
+
const data = await this.request(
|
|
664
|
+
"PATCH",
|
|
665
|
+
`/api/tips/${tipId}/status`,
|
|
666
|
+
params
|
|
667
|
+
);
|
|
668
|
+
return { success: true, ...data };
|
|
669
|
+
} catch (error) {
|
|
670
|
+
return {
|
|
671
|
+
success: false,
|
|
672
|
+
error: error instanceof Error ? error.message : "Failed to update tip status"
|
|
673
|
+
};
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
// ============ Subscription Methods ============
|
|
677
|
+
/**
|
|
678
|
+
* Create a new subscription plan (creator only)
|
|
679
|
+
*/
|
|
680
|
+
async createSubscriptionPlan(params) {
|
|
681
|
+
try {
|
|
682
|
+
return await this.request("POST", "/api/subscriptions/plans", params);
|
|
683
|
+
} catch (error) {
|
|
684
|
+
return {
|
|
685
|
+
success: false,
|
|
686
|
+
error: error instanceof Error ? error.message : "Failed to create subscription plan"
|
|
687
|
+
};
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
/**
|
|
691
|
+
* Get current user's subscription plans
|
|
692
|
+
*/
|
|
693
|
+
async getMySubscriptionPlans() {
|
|
694
|
+
try {
|
|
695
|
+
const data = await this.request("GET", "/api/subscriptions/plans");
|
|
696
|
+
return { success: true, plans: data.plans };
|
|
697
|
+
} catch (error) {
|
|
698
|
+
return {
|
|
699
|
+
success: false,
|
|
700
|
+
error: error instanceof Error ? error.message : "Failed to get subscription plans"
|
|
701
|
+
};
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
/**
|
|
705
|
+
* Get subscription plan by ID
|
|
706
|
+
*/
|
|
707
|
+
async getSubscriptionPlan(planId) {
|
|
708
|
+
try {
|
|
709
|
+
const plan = await this.request(
|
|
710
|
+
"GET",
|
|
711
|
+
`/api/subscriptions/plans/${planId}`
|
|
712
|
+
);
|
|
713
|
+
return { success: true, plan };
|
|
714
|
+
} catch (error) {
|
|
715
|
+
return {
|
|
716
|
+
success: false,
|
|
717
|
+
error: error instanceof Error ? error.message : "Failed to get subscription plan"
|
|
718
|
+
};
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
/**
|
|
722
|
+
* Delete/deactivate subscription plan
|
|
723
|
+
*/
|
|
724
|
+
async deleteSubscriptionPlan(planId) {
|
|
725
|
+
try {
|
|
726
|
+
const data = await this.request(
|
|
727
|
+
"DELETE",
|
|
728
|
+
`/api/subscriptions/plans/${planId}`
|
|
729
|
+
);
|
|
730
|
+
return { success: true, ...data };
|
|
731
|
+
} catch (error) {
|
|
732
|
+
return {
|
|
733
|
+
success: false,
|
|
734
|
+
error: error instanceof Error ? error.message : "Failed to delete subscription plan"
|
|
735
|
+
};
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
/**
|
|
739
|
+
* Subscribe to a plan
|
|
740
|
+
*/
|
|
741
|
+
async subscribe(params) {
|
|
742
|
+
try {
|
|
743
|
+
return await this.request("POST", "/api/subscriptions/subscribe", params);
|
|
744
|
+
} catch (error) {
|
|
745
|
+
return {
|
|
746
|
+
success: false,
|
|
747
|
+
error: error instanceof Error ? error.message : "Failed to subscribe"
|
|
748
|
+
};
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
/**
|
|
752
|
+
* Get current user's subscriptions (as subscriber)
|
|
753
|
+
*/
|
|
754
|
+
async getMySubscriptions(filters) {
|
|
755
|
+
try {
|
|
756
|
+
const params = new URLSearchParams();
|
|
757
|
+
if (filters) {
|
|
758
|
+
Object.entries(filters).forEach(([key, value]) => {
|
|
759
|
+
if (value !== void 0) {
|
|
760
|
+
params.append(key, String(value));
|
|
761
|
+
}
|
|
762
|
+
});
|
|
763
|
+
}
|
|
764
|
+
const queryString = params.toString();
|
|
765
|
+
const path = `/api/subscriptions${queryString ? `?${queryString}` : ""}`;
|
|
766
|
+
const data = await this.request("GET", path);
|
|
767
|
+
return { success: true, ...data };
|
|
768
|
+
} catch (error) {
|
|
769
|
+
return {
|
|
770
|
+
success: false,
|
|
771
|
+
error: error instanceof Error ? error.message : "Failed to get subscriptions"
|
|
772
|
+
};
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
/**
|
|
776
|
+
* Get subscribers to current user's plans (as creator)
|
|
777
|
+
*/
|
|
778
|
+
async getMySubscribers(filters) {
|
|
779
|
+
try {
|
|
780
|
+
const params = new URLSearchParams();
|
|
781
|
+
if (filters) {
|
|
782
|
+
Object.entries(filters).forEach(([key, value]) => {
|
|
783
|
+
if (value !== void 0) {
|
|
784
|
+
params.append(key, String(value));
|
|
785
|
+
}
|
|
786
|
+
});
|
|
787
|
+
}
|
|
788
|
+
const queryString = params.toString();
|
|
789
|
+
const path = `/api/subscriptions/subscribers${queryString ? `?${queryString}` : ""}`;
|
|
790
|
+
const data = await this.request("GET", path);
|
|
791
|
+
return { success: true, ...data };
|
|
792
|
+
} catch (error) {
|
|
793
|
+
return {
|
|
794
|
+
success: false,
|
|
795
|
+
error: error instanceof Error ? error.message : "Failed to get subscribers"
|
|
796
|
+
};
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
/**
|
|
800
|
+
* Cancel subscription
|
|
801
|
+
*/
|
|
802
|
+
async cancelSubscription(subscriptionId) {
|
|
803
|
+
try {
|
|
804
|
+
const data = await this.request("DELETE", `/api/subscriptions/${subscriptionId}`);
|
|
805
|
+
return { success: true, ...data };
|
|
806
|
+
} catch (error) {
|
|
807
|
+
return {
|
|
808
|
+
success: false,
|
|
809
|
+
error: error instanceof Error ? error.message : "Failed to cancel subscription"
|
|
810
|
+
};
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
/**
|
|
814
|
+
* Create a subscription plan on-chain
|
|
815
|
+
*/
|
|
816
|
+
async createSubscriptionPlanOnChain(params) {
|
|
817
|
+
try {
|
|
818
|
+
return await this.request("POST", "/api/subscriptions/contract/plans", params);
|
|
819
|
+
} catch (error) {
|
|
820
|
+
return {
|
|
821
|
+
success: false,
|
|
822
|
+
error: error instanceof Error ? error.message : "Failed to create plan on-chain"
|
|
823
|
+
};
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
/**
|
|
827
|
+
* Subscribe to a plan on-chain
|
|
828
|
+
*/
|
|
829
|
+
async subscribeOnChain(params) {
|
|
830
|
+
try {
|
|
831
|
+
return await this.request("POST", "/api/subscriptions/contract/subscribe", params);
|
|
832
|
+
} catch (error) {
|
|
833
|
+
return {
|
|
834
|
+
success: false,
|
|
835
|
+
error: error instanceof Error ? error.message : "Failed to subscribe on-chain"
|
|
836
|
+
};
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
/**
|
|
840
|
+
* Cancel subscription on-chain
|
|
841
|
+
*/
|
|
842
|
+
async cancelSubscriptionOnChain(subscriptionId, seed) {
|
|
843
|
+
try {
|
|
844
|
+
return await this.request(
|
|
845
|
+
"POST",
|
|
846
|
+
"/api/subscriptions/contract/cancel",
|
|
847
|
+
{ subscriptionId, seed }
|
|
848
|
+
);
|
|
849
|
+
} catch (error) {
|
|
850
|
+
return {
|
|
851
|
+
success: false,
|
|
852
|
+
error: error instanceof Error ? error.message : "Failed to cancel subscription on-chain"
|
|
853
|
+
};
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
/**
|
|
857
|
+
* Check if user is subscribed to a creator on-chain
|
|
858
|
+
*/
|
|
859
|
+
async isSubscribed(subscriber, creator) {
|
|
860
|
+
try {
|
|
861
|
+
return await this.request(
|
|
862
|
+
"GET",
|
|
863
|
+
`/api/subscriptions/contract/is-subscribed?subscriber=${subscriber}&creator=${creator}`
|
|
864
|
+
);
|
|
865
|
+
} catch (error) {
|
|
866
|
+
return {
|
|
867
|
+
subscriber,
|
|
868
|
+
creator,
|
|
869
|
+
isSubscribed: false
|
|
870
|
+
};
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
/**
|
|
874
|
+
* Get subscription platform fee
|
|
875
|
+
*/
|
|
876
|
+
async getSubscriptionPlatformFee() {
|
|
877
|
+
try {
|
|
878
|
+
return await this.request("GET", "/api/subscriptions/platform-fee");
|
|
879
|
+
} catch (error) {
|
|
880
|
+
return {
|
|
881
|
+
feeBps: 0,
|
|
882
|
+
feePercent: "0"
|
|
883
|
+
};
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
// ============ Payouts Methods ============
|
|
887
|
+
/**
|
|
888
|
+
* Get pending and claimed earnings for the authenticated user
|
|
889
|
+
*/
|
|
890
|
+
async getEarnings() {
|
|
891
|
+
try {
|
|
892
|
+
const data = await this.request("GET", "/api/payouts/earnings");
|
|
893
|
+
return { success: true, ...data };
|
|
894
|
+
} catch (error) {
|
|
895
|
+
return {
|
|
896
|
+
success: false,
|
|
897
|
+
error: error instanceof Error ? error.message : "Failed to get earnings"
|
|
898
|
+
};
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
/**
|
|
902
|
+
* Claim pending earnings
|
|
903
|
+
*/
|
|
904
|
+
async claimEarnings(params) {
|
|
905
|
+
try {
|
|
906
|
+
return await this.request("POST", "/api/payouts/claim", params);
|
|
907
|
+
} catch (error) {
|
|
908
|
+
return {
|
|
909
|
+
success: false,
|
|
910
|
+
error: error instanceof Error ? error.message : "Failed to claim earnings"
|
|
911
|
+
};
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
/**
|
|
915
|
+
* Get payout history for the authenticated user
|
|
916
|
+
*/
|
|
917
|
+
async getPayoutHistory(filters) {
|
|
918
|
+
try {
|
|
919
|
+
const params = new URLSearchParams();
|
|
920
|
+
if (filters) {
|
|
921
|
+
Object.entries(filters).forEach(([key, value]) => {
|
|
922
|
+
if (value !== void 0) {
|
|
923
|
+
params.append(key, String(value));
|
|
924
|
+
}
|
|
925
|
+
});
|
|
926
|
+
}
|
|
927
|
+
const queryString = params.toString();
|
|
928
|
+
const path = `/api/payouts/history${queryString ? `?${queryString}` : ""}`;
|
|
929
|
+
const data = await this.request("GET", path);
|
|
930
|
+
return { success: true, ...data };
|
|
931
|
+
} catch (error) {
|
|
932
|
+
return {
|
|
933
|
+
success: false,
|
|
934
|
+
error: error instanceof Error ? error.message : "Failed to get payout history"
|
|
935
|
+
};
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
/**
|
|
939
|
+
* Get earnings breakdown by source
|
|
940
|
+
*/
|
|
941
|
+
async getEarningsBreakdown() {
|
|
942
|
+
try {
|
|
943
|
+
const data = await this.request("GET", "/api/payouts/breakdown");
|
|
944
|
+
return { success: true, ...data };
|
|
945
|
+
} catch (error) {
|
|
946
|
+
return {
|
|
947
|
+
success: false,
|
|
948
|
+
error: error instanceof Error ? error.message : "Failed to get earnings breakdown"
|
|
949
|
+
};
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
/**
|
|
953
|
+
* Get current platform fee for payouts
|
|
954
|
+
*/
|
|
955
|
+
async getPayoutsPlatformFee() {
|
|
956
|
+
try {
|
|
957
|
+
return await this.request("GET", "/api/payouts/platform-fee");
|
|
958
|
+
} catch (error) {
|
|
959
|
+
return {
|
|
960
|
+
feeBps: 0,
|
|
961
|
+
feePercent: "0"
|
|
962
|
+
};
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
};
|
|
966
|
+
var DEFAULT_API_URL2 = process.env.NEXT_PUBLIC_API_URL || "https://ckgwifsxka.us-east-2.awsapprunner.com";
|
|
967
|
+
var zubariApiClient = null;
|
|
968
|
+
function getZubariApiClient(config) {
|
|
969
|
+
if (!zubariApiClient || config?.baseUrl && zubariApiClient["config"].baseUrl !== config.baseUrl) {
|
|
970
|
+
zubariApiClient = new ZubariApiClient({
|
|
971
|
+
baseUrl: config?.baseUrl || DEFAULT_API_URL2,
|
|
972
|
+
timeout: config?.timeout,
|
|
973
|
+
authToken: config?.authToken
|
|
974
|
+
});
|
|
975
|
+
} else if (config?.authToken) {
|
|
976
|
+
zubariApiClient.setAuthToken(config.authToken);
|
|
977
|
+
}
|
|
978
|
+
return zubariApiClient;
|
|
979
|
+
}
|
|
980
|
+
function createZubariApiClient(config) {
|
|
981
|
+
return new ZubariApiClient(config);
|
|
982
|
+
}
|
|
983
|
+
|
|
299
984
|
// src/services/BrowserAddressDerivation.ts
|
|
300
985
|
var BrowserAddressDerivation_exports = {};
|
|
301
986
|
__export(BrowserAddressDerivation_exports, {
|
|
@@ -489,7 +1174,7 @@ function generateSeedPhrase() {
|
|
|
489
1174
|
}
|
|
490
1175
|
|
|
491
1176
|
// src/services/ZubariWdkService.ts
|
|
492
|
-
var
|
|
1177
|
+
var DEFAULT_API_URL3 = "https://ckgwifsxka.us-east-2.awsapprunner.com";
|
|
493
1178
|
function isBrowser() {
|
|
494
1179
|
return typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
495
1180
|
}
|
|
@@ -514,7 +1199,7 @@ var ZubariWdkService = class {
|
|
|
514
1199
|
constructor(config = {}) {
|
|
515
1200
|
this.config = {
|
|
516
1201
|
network: config.network || "testnet",
|
|
517
|
-
apiUrl: config.apiUrl || process.env.NEXT_PUBLIC_API_URL ||
|
|
1202
|
+
apiUrl: config.apiUrl || process.env.NEXT_PUBLIC_API_URL || DEFAULT_API_URL3,
|
|
518
1203
|
forceApi: config.forceApi ?? false,
|
|
519
1204
|
timeout: config.timeout || 3e4
|
|
520
1205
|
};
|
|
@@ -1339,11 +2024,14 @@ exports.BrowserAddressDerivation = BrowserAddressDerivation_exports;
|
|
|
1339
2024
|
exports.SwapService = SwapService;
|
|
1340
2025
|
exports.TransactionService = TransactionService;
|
|
1341
2026
|
exports.WdkApiClient = WdkApiClient;
|
|
2027
|
+
exports.ZubariApiClient = ZubariApiClient;
|
|
1342
2028
|
exports.ZubariWdkService = ZubariWdkService;
|
|
1343
2029
|
exports.createTransactionService = createTransactionService;
|
|
2030
|
+
exports.createZubariApiClient = createZubariApiClient;
|
|
1344
2031
|
exports.createZubariWdkService = createZubariWdkService;
|
|
1345
2032
|
exports.getTransactionService = getTransactionService;
|
|
1346
2033
|
exports.getWdkApiClient = getWdkApiClient;
|
|
2034
|
+
exports.getZubariApiClient = getZubariApiClient;
|
|
1347
2035
|
exports.getZubariWdkService = getZubariWdkService;
|
|
1348
2036
|
exports.isBrowser = isBrowser;
|
|
1349
2037
|
//# sourceMappingURL=index.js.map
|