@zubari/sdk 0.2.2 → 0.2.3

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.
@@ -3137,12 +3137,14 @@ var ZubariSubscriptionProtocol = class {
3137
3137
  var ZubariPayoutsProtocol = class {
3138
3138
  contractAddress;
3139
3139
  chainId;
3140
- constructor(contractAddress, chainId) {
3140
+ apiBaseUrl;
3141
+ constructor(contractAddress, chainId, apiBaseUrl) {
3141
3142
  this.contractAddress = contractAddress;
3142
3143
  this.chainId = chainId;
3144
+ this.apiBaseUrl = apiBaseUrl || "https://ckgwifsxka.us-east-2.awsapprunner.com";
3143
3145
  }
3144
3146
  /**
3145
- * Get pending earnings breakdown for the current user
3147
+ * Get pending earnings breakdown for the current user (on-chain)
3146
3148
  */
3147
3149
  async getPendingEarnings() {
3148
3150
  return {
@@ -3153,6 +3155,75 @@ var ZubariPayoutsProtocol = class {
3153
3155
  total: BigInt(0)
3154
3156
  };
3155
3157
  }
3158
+ /**
3159
+ * Get earnings data from API (includes pending, total, breakdown, and recent payouts)
3160
+ * Requires authentication token
3161
+ */
3162
+ async getEarnings(authToken) {
3163
+ const response = await fetch(`${this.apiBaseUrl}/api/payouts/earnings`, {
3164
+ headers: {
3165
+ Authorization: `Bearer ${authToken}`,
3166
+ "Content-Type": "application/json"
3167
+ }
3168
+ });
3169
+ if (!response.ok) {
3170
+ const error = await response.json();
3171
+ throw new Error(error.error || "Failed to fetch earnings");
3172
+ }
3173
+ return response.json();
3174
+ }
3175
+ /**
3176
+ * Get payout history with pagination
3177
+ * Requires authentication token
3178
+ */
3179
+ async getPayoutHistory(authToken, page = 1, limit = 20) {
3180
+ const response = await fetch(
3181
+ `${this.apiBaseUrl}/api/payouts/history?page=${page}&limit=${limit}`,
3182
+ {
3183
+ headers: {
3184
+ Authorization: `Bearer ${authToken}`,
3185
+ "Content-Type": "application/json"
3186
+ }
3187
+ }
3188
+ );
3189
+ if (!response.ok) {
3190
+ const error = await response.json();
3191
+ throw new Error(error.error || "Failed to fetch payout history");
3192
+ }
3193
+ return response.json();
3194
+ }
3195
+ /**
3196
+ * Get earnings breakdown by source with percentages
3197
+ * Requires authentication token
3198
+ */
3199
+ async getBreakdown(authToken) {
3200
+ const response = await fetch(`${this.apiBaseUrl}/api/payouts/breakdown`, {
3201
+ headers: {
3202
+ Authorization: `Bearer ${authToken}`,
3203
+ "Content-Type": "application/json"
3204
+ }
3205
+ });
3206
+ if (!response.ok) {
3207
+ const error = await response.json();
3208
+ throw new Error(error.error || "Failed to fetch earnings breakdown");
3209
+ }
3210
+ return response.json();
3211
+ }
3212
+ /**
3213
+ * Get current platform fee
3214
+ */
3215
+ async getPlatformFee() {
3216
+ const response = await fetch(`${this.apiBaseUrl}/api/payouts/platform-fee`, {
3217
+ headers: {
3218
+ "Content-Type": "application/json"
3219
+ }
3220
+ });
3221
+ if (!response.ok) {
3222
+ const error = await response.json();
3223
+ throw new Error(error.error || "Failed to fetch platform fee");
3224
+ }
3225
+ return response.json();
3226
+ }
3156
3227
  /**
3157
3228
  * Get historical earnings for a time period
3158
3229
  */
@@ -3160,7 +3231,26 @@ var ZubariPayoutsProtocol = class {
3160
3231
  return [];
3161
3232
  }
3162
3233
  /**
3163
- * Claim all pending earnings
3234
+ * Claim all pending earnings via API
3235
+ * Requires authentication token and seed phrase
3236
+ */
3237
+ async claimEarningsViaApi(authToken, seed) {
3238
+ const response = await fetch(`${this.apiBaseUrl}/api/payouts/claim`, {
3239
+ method: "POST",
3240
+ headers: {
3241
+ Authorization: `Bearer ${authToken}`,
3242
+ "Content-Type": "application/json"
3243
+ },
3244
+ body: JSON.stringify({ seed })
3245
+ });
3246
+ if (!response.ok) {
3247
+ const error = await response.json();
3248
+ throw new Error(error.error || "Failed to claim earnings");
3249
+ }
3250
+ return response.json();
3251
+ }
3252
+ /**
3253
+ * Claim all pending earnings (direct contract call)
3164
3254
  */
3165
3255
  async claimEarnings() {
3166
3256
  return {
@@ -3234,6 +3324,18 @@ var ZubariPayoutsProtocol = class {
3234
3324
  status: "pending"
3235
3325
  };
3236
3326
  }
3327
+ /**
3328
+ * Get the contract address
3329
+ */
3330
+ getContractAddress() {
3331
+ return this.contractAddress;
3332
+ }
3333
+ /**
3334
+ * Get the chain ID
3335
+ */
3336
+ getChainId() {
3337
+ return this.chainId;
3338
+ }
3237
3339
  };
3238
3340
 
3239
3341
  export { ZubariMarketProtocol, ZubariNFTProtocol, ZubariPayoutsProtocol, ZubariSubscriptionProtocol, ZubariTipsProtocol };