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