@zubari/sdk 0.2.5 → 0.2.7

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.
@@ -16,14 +16,13 @@ var __export = (target, all) => {
16
16
  var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
17
17
  var ZUBARI_CONTRACTS = {
18
18
  testnet: {
19
- // Ethereum Sepolia (11155111) - Deployed 2024-12-09
20
- registry: "0xEdDf443D48832f23D4A0bED4C4c5eF200B38A7d3",
21
- nft: "0xdc37e25650D685e4c38124aC314477Ea5f508a9e",
22
- marketplace: "0x48D0F3b6552A8CcDA7528db5aE8be004fCC3D3D9",
23
- // ZubariMarket deployed 2024-12-22
24
- tips: "0xFDc353edC63Cd3D4bba35bB43861369516a9Dc85",
25
- subscriptions: "0x8C05F8aD2F295fB7f3596043a7c37C98A5F7fAB8",
26
- payouts: "0x804Fe503936E8b8d3D5Dbb62AF4fB6Fe7265Fb2c",
19
+ // Ethereum Sepolia (11155111) - Deployed 2024-12-30
20
+ registry: "0xe5CE1Eb986f58BE42EEDFe5C18ee5956803b2BDC",
21
+ nft: "0xCb1AB134a75c4D504792233efC5dE949aDE3f29f",
22
+ marketplace: "0xfcEfDa6C73aC357b8695E5F8F8d17820750BF207",
23
+ tips: "0x86a9A306C7fCC9e0B8cd6859f6f15498d0046BB7",
24
+ subscriptions: "0xaB7F17A85F61d9ab9f96bCB4e73e910D019978F7",
25
+ payouts: "0x8aaB23Fb2a83A259E965Aae8Ee0938b1400B7E6b",
27
26
  entryPoint: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
28
27
  paymaster: ZERO_ADDRESS,
29
28
  // Deploy with: npx hardhat run deploy/deploy.ts --network ethereum-sepolia
@@ -563,6 +562,403 @@ var ZubariApiClient = class {
563
562
  };
564
563
  }
565
564
  }
565
+ // ============ Tips Methods ============
566
+ /**
567
+ * Send a tip to a creator
568
+ */
569
+ async sendTip(params) {
570
+ try {
571
+ return await this.request("POST", "/api/tips", params);
572
+ } catch (error) {
573
+ return {
574
+ success: false,
575
+ error: error instanceof Error ? error.message : "Failed to send tip"
576
+ };
577
+ }
578
+ }
579
+ /**
580
+ * Get tip statistics for current user
581
+ */
582
+ async getTipStats() {
583
+ try {
584
+ const data = await this.request("GET", "/api/tips/my/stats");
585
+ return { success: true, ...data };
586
+ } catch (error) {
587
+ return {
588
+ success: false,
589
+ error: error instanceof Error ? error.message : "Failed to get tip stats"
590
+ };
591
+ }
592
+ }
593
+ /**
594
+ * Get tips sent by current user
595
+ */
596
+ async getSentTips(filters) {
597
+ try {
598
+ const params = new URLSearchParams();
599
+ if (filters) {
600
+ Object.entries(filters).forEach(([key, value]) => {
601
+ if (value !== void 0) {
602
+ params.append(key, String(value));
603
+ }
604
+ });
605
+ }
606
+ const queryString = params.toString();
607
+ const path = `/api/tips/sent${queryString ? `?${queryString}` : ""}`;
608
+ const data = await this.request("GET", path);
609
+ return { success: true, ...data };
610
+ } catch (error) {
611
+ return {
612
+ success: false,
613
+ error: error instanceof Error ? error.message : "Failed to get sent tips"
614
+ };
615
+ }
616
+ }
617
+ /**
618
+ * Get tips received by current user
619
+ */
620
+ async getReceivedTips(filters) {
621
+ try {
622
+ const params = new URLSearchParams();
623
+ if (filters) {
624
+ Object.entries(filters).forEach(([key, value]) => {
625
+ if (value !== void 0) {
626
+ params.append(key, String(value));
627
+ }
628
+ });
629
+ }
630
+ const queryString = params.toString();
631
+ const path = `/api/tips/received${queryString ? `?${queryString}` : ""}`;
632
+ const data = await this.request("GET", path);
633
+ return { success: true, ...data };
634
+ } catch (error) {
635
+ return {
636
+ success: false,
637
+ error: error instanceof Error ? error.message : "Failed to get received tips"
638
+ };
639
+ }
640
+ }
641
+ /**
642
+ * Get a single tip by ID
643
+ */
644
+ async getTip(tipId) {
645
+ try {
646
+ const data = await this.request("GET", `/api/tips/${tipId}`);
647
+ return { success: true, tip: data.tip };
648
+ } catch (error) {
649
+ return {
650
+ success: false,
651
+ error: error instanceof Error ? error.message : "Failed to get tip"
652
+ };
653
+ }
654
+ }
655
+ /**
656
+ * Update tip status (for transaction confirmation)
657
+ */
658
+ async updateTipStatus(tipId, params) {
659
+ try {
660
+ const data = await this.request(
661
+ "PATCH",
662
+ `/api/tips/${tipId}/status`,
663
+ params
664
+ );
665
+ return { success: true, ...data };
666
+ } catch (error) {
667
+ return {
668
+ success: false,
669
+ error: error instanceof Error ? error.message : "Failed to update tip status"
670
+ };
671
+ }
672
+ }
673
+ // ============ Subscription Methods ============
674
+ /**
675
+ * Create a new subscription plan (creator only)
676
+ */
677
+ async createSubscriptionPlan(params) {
678
+ try {
679
+ return await this.request("POST", "/api/subscriptions/plans", params);
680
+ } catch (error) {
681
+ return {
682
+ success: false,
683
+ error: error instanceof Error ? error.message : "Failed to create subscription plan"
684
+ };
685
+ }
686
+ }
687
+ /**
688
+ * Get current user's subscription plans
689
+ */
690
+ async getMySubscriptionPlans() {
691
+ try {
692
+ const data = await this.request("GET", "/api/subscriptions/plans");
693
+ return { success: true, plans: data.plans };
694
+ } catch (error) {
695
+ return {
696
+ success: false,
697
+ error: error instanceof Error ? error.message : "Failed to get subscription plans"
698
+ };
699
+ }
700
+ }
701
+ /**
702
+ * Get subscription plan by ID
703
+ */
704
+ async getSubscriptionPlan(planId) {
705
+ try {
706
+ const plan = await this.request(
707
+ "GET",
708
+ `/api/subscriptions/plans/${planId}`
709
+ );
710
+ return { success: true, plan };
711
+ } catch (error) {
712
+ return {
713
+ success: false,
714
+ error: error instanceof Error ? error.message : "Failed to get subscription plan"
715
+ };
716
+ }
717
+ }
718
+ /**
719
+ * Delete/deactivate subscription plan
720
+ */
721
+ async deleteSubscriptionPlan(planId) {
722
+ try {
723
+ const data = await this.request(
724
+ "DELETE",
725
+ `/api/subscriptions/plans/${planId}`
726
+ );
727
+ return { success: true, ...data };
728
+ } catch (error) {
729
+ return {
730
+ success: false,
731
+ error: error instanceof Error ? error.message : "Failed to delete subscription plan"
732
+ };
733
+ }
734
+ }
735
+ /**
736
+ * Subscribe to a plan
737
+ */
738
+ async subscribe(params) {
739
+ try {
740
+ return await this.request("POST", "/api/subscriptions/subscribe", params);
741
+ } catch (error) {
742
+ return {
743
+ success: false,
744
+ error: error instanceof Error ? error.message : "Failed to subscribe"
745
+ };
746
+ }
747
+ }
748
+ /**
749
+ * Get current user's subscriptions (as subscriber)
750
+ */
751
+ async getMySubscriptions(filters) {
752
+ try {
753
+ const params = new URLSearchParams();
754
+ if (filters) {
755
+ Object.entries(filters).forEach(([key, value]) => {
756
+ if (value !== void 0) {
757
+ params.append(key, String(value));
758
+ }
759
+ });
760
+ }
761
+ const queryString = params.toString();
762
+ const path = `/api/subscriptions${queryString ? `?${queryString}` : ""}`;
763
+ const data = await this.request("GET", path);
764
+ return { success: true, ...data };
765
+ } catch (error) {
766
+ return {
767
+ success: false,
768
+ error: error instanceof Error ? error.message : "Failed to get subscriptions"
769
+ };
770
+ }
771
+ }
772
+ /**
773
+ * Get subscribers to current user's plans (as creator)
774
+ */
775
+ async getMySubscribers(filters) {
776
+ try {
777
+ const params = new URLSearchParams();
778
+ if (filters) {
779
+ Object.entries(filters).forEach(([key, value]) => {
780
+ if (value !== void 0) {
781
+ params.append(key, String(value));
782
+ }
783
+ });
784
+ }
785
+ const queryString = params.toString();
786
+ const path = `/api/subscriptions/subscribers${queryString ? `?${queryString}` : ""}`;
787
+ const data = await this.request("GET", path);
788
+ return { success: true, ...data };
789
+ } catch (error) {
790
+ return {
791
+ success: false,
792
+ error: error instanceof Error ? error.message : "Failed to get subscribers"
793
+ };
794
+ }
795
+ }
796
+ /**
797
+ * Cancel subscription
798
+ */
799
+ async cancelSubscription(subscriptionId) {
800
+ try {
801
+ const data = await this.request("DELETE", `/api/subscriptions/${subscriptionId}`);
802
+ return { success: true, ...data };
803
+ } catch (error) {
804
+ return {
805
+ success: false,
806
+ error: error instanceof Error ? error.message : "Failed to cancel subscription"
807
+ };
808
+ }
809
+ }
810
+ /**
811
+ * Create a subscription plan on-chain
812
+ */
813
+ async createSubscriptionPlanOnChain(params) {
814
+ try {
815
+ return await this.request("POST", "/api/subscriptions/contract/plans", params);
816
+ } catch (error) {
817
+ return {
818
+ success: false,
819
+ error: error instanceof Error ? error.message : "Failed to create plan on-chain"
820
+ };
821
+ }
822
+ }
823
+ /**
824
+ * Subscribe to a plan on-chain
825
+ */
826
+ async subscribeOnChain(params) {
827
+ try {
828
+ return await this.request("POST", "/api/subscriptions/contract/subscribe", params);
829
+ } catch (error) {
830
+ return {
831
+ success: false,
832
+ error: error instanceof Error ? error.message : "Failed to subscribe on-chain"
833
+ };
834
+ }
835
+ }
836
+ /**
837
+ * Cancel subscription on-chain
838
+ */
839
+ async cancelSubscriptionOnChain(subscriptionId, seed) {
840
+ try {
841
+ return await this.request(
842
+ "POST",
843
+ "/api/subscriptions/contract/cancel",
844
+ { subscriptionId, seed }
845
+ );
846
+ } catch (error) {
847
+ return {
848
+ success: false,
849
+ error: error instanceof Error ? error.message : "Failed to cancel subscription on-chain"
850
+ };
851
+ }
852
+ }
853
+ /**
854
+ * Check if user is subscribed to a creator on-chain
855
+ */
856
+ async isSubscribed(subscriber, creator) {
857
+ try {
858
+ return await this.request(
859
+ "GET",
860
+ `/api/subscriptions/contract/is-subscribed?subscriber=${subscriber}&creator=${creator}`
861
+ );
862
+ } catch (error) {
863
+ return {
864
+ subscriber,
865
+ creator,
866
+ isSubscribed: false
867
+ };
868
+ }
869
+ }
870
+ /**
871
+ * Get subscription platform fee
872
+ */
873
+ async getSubscriptionPlatformFee() {
874
+ try {
875
+ return await this.request("GET", "/api/subscriptions/platform-fee");
876
+ } catch (error) {
877
+ return {
878
+ feeBps: 0,
879
+ feePercent: "0"
880
+ };
881
+ }
882
+ }
883
+ // ============ Payouts Methods ============
884
+ /**
885
+ * Get pending and claimed earnings for the authenticated user
886
+ */
887
+ async getEarnings() {
888
+ try {
889
+ const data = await this.request("GET", "/api/payouts/earnings");
890
+ return { success: true, ...data };
891
+ } catch (error) {
892
+ return {
893
+ success: false,
894
+ error: error instanceof Error ? error.message : "Failed to get earnings"
895
+ };
896
+ }
897
+ }
898
+ /**
899
+ * Claim pending earnings
900
+ */
901
+ async claimEarnings(params) {
902
+ try {
903
+ return await this.request("POST", "/api/payouts/claim", params);
904
+ } catch (error) {
905
+ return {
906
+ success: false,
907
+ error: error instanceof Error ? error.message : "Failed to claim earnings"
908
+ };
909
+ }
910
+ }
911
+ /**
912
+ * Get payout history for the authenticated user
913
+ */
914
+ async getPayoutHistory(filters) {
915
+ try {
916
+ const params = new URLSearchParams();
917
+ if (filters) {
918
+ Object.entries(filters).forEach(([key, value]) => {
919
+ if (value !== void 0) {
920
+ params.append(key, String(value));
921
+ }
922
+ });
923
+ }
924
+ const queryString = params.toString();
925
+ const path = `/api/payouts/history${queryString ? `?${queryString}` : ""}`;
926
+ const data = await this.request("GET", path);
927
+ return { success: true, ...data };
928
+ } catch (error) {
929
+ return {
930
+ success: false,
931
+ error: error instanceof Error ? error.message : "Failed to get payout history"
932
+ };
933
+ }
934
+ }
935
+ /**
936
+ * Get earnings breakdown by source
937
+ */
938
+ async getEarningsBreakdown() {
939
+ try {
940
+ const data = await this.request("GET", "/api/payouts/breakdown");
941
+ return { success: true, ...data };
942
+ } catch (error) {
943
+ return {
944
+ success: false,
945
+ error: error instanceof Error ? error.message : "Failed to get earnings breakdown"
946
+ };
947
+ }
948
+ }
949
+ /**
950
+ * Get current platform fee for payouts
951
+ */
952
+ async getPayoutsPlatformFee() {
953
+ try {
954
+ return await this.request("GET", "/api/payouts/platform-fee");
955
+ } catch (error) {
956
+ return {
957
+ feeBps: 0,
958
+ feePercent: "0"
959
+ };
960
+ }
961
+ }
566
962
  };
567
963
  var DEFAULT_API_URL2 = process.env.NEXT_PUBLIC_API_URL || "https://ckgwifsxka.us-east-2.awsapprunner.com";
568
964
  var zubariApiClient = null;