@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.
@@ -2,7 +2,7 @@ import * as abitype from 'abitype';
2
2
  import * as viem from 'viem';
3
3
  import { HDNodeWallet } from 'ethers';
4
4
  import { S as SecureStorageAdapter } from './SecureStorage-jO783AhC.mjs';
5
- import { N as NetworkType } from './index-Be7yLGAO.mjs';
5
+ import { N as NetworkType } from './index-Bou-9cAG.mjs';
6
6
 
7
7
  interface NetworkConfig {
8
8
  name: string;
@@ -2,7 +2,7 @@ import * as abitype from 'abitype';
2
2
  import * as viem from 'viem';
3
3
  import { HDNodeWallet } from 'ethers';
4
4
  import { S as SecureStorageAdapter } from './SecureStorage-jO783AhC.js';
5
- import { N as NetworkType } from './index-Be7yLGAO.js';
5
+ import { N as NetworkType } from './index-Bou-9cAG.js';
6
6
 
7
7
  interface NetworkConfig {
8
8
  name: string;
@@ -1,5 +1,5 @@
1
- import { Z as ZubariWalletConfig, N as NetworkType, A as Account, a as NetworkBalance, S as SendParams, b as TxResult } from './index-Be7yLGAO.js';
2
- import './WalletManager-IOHFgvpT.js';
1
+ import { Z as ZubariWalletConfig, N as NetworkType, A as Account, a as NetworkBalance, S as SendParams, b as TxResult } from './index-Bou-9cAG.mjs';
2
+ import './WalletManager-CQSrvRVs.mjs';
3
3
 
4
4
  interface ContractAddresses {
5
5
  registry: string;
@@ -11,7 +11,6 @@ interface ContractAddresses {
11
11
  entryPoint: string;
12
12
  paymaster: string;
13
13
  accountFactory: string;
14
- usdc: string;
15
14
  usdt: string;
16
15
  weth: string;
17
16
  }
@@ -178,6 +178,59 @@ interface EarningsBreakdown {
178
178
  royalties: bigint;
179
179
  total: bigint;
180
180
  }
181
+ interface EarningsBreakdownFormatted {
182
+ tips: string;
183
+ subscriptions: string;
184
+ nftSales: string;
185
+ royalties: string;
186
+ total?: string;
187
+ }
188
+ interface EarningsPercentages {
189
+ tips: string;
190
+ subscriptions: string;
191
+ nftSales: string;
192
+ royalties: string;
193
+ }
194
+ interface PayoutRecord {
195
+ id: string;
196
+ amount: string;
197
+ txHash: string;
198
+ createdAt: string;
199
+ status?: string;
200
+ confirmedAt?: string;
201
+ }
202
+ interface EarningsResponse {
203
+ address: string;
204
+ pendingEarnings: string;
205
+ totalEarnings: string;
206
+ earningsBreakdown: EarningsBreakdownFormatted;
207
+ recentPayouts: PayoutRecord[];
208
+ }
209
+ interface PayoutHistoryResponse {
210
+ payouts: PayoutRecord[];
211
+ pagination: {
212
+ page: number;
213
+ limit: number;
214
+ total: number;
215
+ pages: number;
216
+ };
217
+ }
218
+ interface BreakdownResponse {
219
+ breakdown: EarningsBreakdownFormatted & {
220
+ total: string;
221
+ };
222
+ percentages: EarningsPercentages;
223
+ }
224
+ interface PlatformFeeResponse {
225
+ feeBps: number;
226
+ feePercent: string;
227
+ }
228
+ interface ClaimResult {
229
+ success: boolean;
230
+ transactionHash: string;
231
+ amount: string;
232
+ message: string;
233
+ }
181
234
  interface RevenueSplit {
182
235
  recipient: string;
183
236
  basisPoints: number;
@@ -205,4 +258,4 @@ declare class ZubariError extends Error {
205
258
  constructor(code: ZubariErrorCode, message: string, details?: unknown | undefined);
206
259
  }
207
260
 
208
- export { type Account as A, type BuyParams as B, type CreateVoucherParams as C, type EarningsBreakdown as E, type LazyMintVoucher as L, type NetworkType as N, type RevenueSplit as R, type SendParams as S, type TokenBalance as T, type WatermarkingData as W, type ZubariWalletConfig as Z, type NetworkBalance as a, type TxResult as b, type NFTCurrency as c, type NFTAttribute as d, type NFTMetadata as e, type NFT as f, type ListingParams as g, type Listing as h, type TipData as i, type TipResult as j, type TipStats as k, type Tip as l, type SubscriptionPlan as m, type Subscription as n, type SwapQuote as o, type SwapParams as p, type ZubariErrorCode as q, ZubariError as r };
261
+ export { type Account as A, type BuyParams as B, type CreateVoucherParams as C, type EarningsBreakdown as E, type LazyMintVoucher as L, type NetworkType as N, type PayoutHistoryResponse as P, type RevenueSplit as R, type SendParams as S, type TokenBalance as T, type WatermarkingData as W, type ZubariWalletConfig as Z, type NetworkBalance as a, type TxResult as b, type NFTCurrency as c, type NFTAttribute as d, type NFTMetadata as e, type NFT as f, type ListingParams as g, type Listing as h, type TipData as i, type TipResult as j, type TipStats as k, type Tip as l, type SubscriptionPlan as m, type Subscription as n, type SwapQuote as o, type SwapParams as p, type ZubariErrorCode as q, ZubariError as r, type EarningsResponse as s, type BreakdownResponse as t, type PlatformFeeResponse as u, type ClaimResult as v };
@@ -178,6 +178,59 @@ interface EarningsBreakdown {
178
178
  royalties: bigint;
179
179
  total: bigint;
180
180
  }
181
+ interface EarningsBreakdownFormatted {
182
+ tips: string;
183
+ subscriptions: string;
184
+ nftSales: string;
185
+ royalties: string;
186
+ total?: string;
187
+ }
188
+ interface EarningsPercentages {
189
+ tips: string;
190
+ subscriptions: string;
191
+ nftSales: string;
192
+ royalties: string;
193
+ }
194
+ interface PayoutRecord {
195
+ id: string;
196
+ amount: string;
197
+ txHash: string;
198
+ createdAt: string;
199
+ status?: string;
200
+ confirmedAt?: string;
201
+ }
202
+ interface EarningsResponse {
203
+ address: string;
204
+ pendingEarnings: string;
205
+ totalEarnings: string;
206
+ earningsBreakdown: EarningsBreakdownFormatted;
207
+ recentPayouts: PayoutRecord[];
208
+ }
209
+ interface PayoutHistoryResponse {
210
+ payouts: PayoutRecord[];
211
+ pagination: {
212
+ page: number;
213
+ limit: number;
214
+ total: number;
215
+ pages: number;
216
+ };
217
+ }
218
+ interface BreakdownResponse {
219
+ breakdown: EarningsBreakdownFormatted & {
220
+ total: string;
221
+ };
222
+ percentages: EarningsPercentages;
223
+ }
224
+ interface PlatformFeeResponse {
225
+ feeBps: number;
226
+ feePercent: string;
227
+ }
228
+ interface ClaimResult {
229
+ success: boolean;
230
+ transactionHash: string;
231
+ amount: string;
232
+ message: string;
233
+ }
181
234
  interface RevenueSplit {
182
235
  recipient: string;
183
236
  basisPoints: number;
@@ -205,4 +258,4 @@ declare class ZubariError extends Error {
205
258
  constructor(code: ZubariErrorCode, message: string, details?: unknown | undefined);
206
259
  }
207
260
 
208
- export { type Account as A, type BuyParams as B, type CreateVoucherParams as C, type EarningsBreakdown as E, type LazyMintVoucher as L, type NetworkType as N, type RevenueSplit as R, type SendParams as S, type TokenBalance as T, type WatermarkingData as W, type ZubariWalletConfig as Z, type NetworkBalance as a, type TxResult as b, type NFTCurrency as c, type NFTAttribute as d, type NFTMetadata as e, type NFT as f, type ListingParams as g, type Listing as h, type TipData as i, type TipResult as j, type TipStats as k, type Tip as l, type SubscriptionPlan as m, type Subscription as n, type SwapQuote as o, type SwapParams as p, type ZubariErrorCode as q, ZubariError as r };
261
+ export { type Account as A, type BuyParams as B, type CreateVoucherParams as C, type EarningsBreakdown as E, type LazyMintVoucher as L, type NetworkType as N, type PayoutHistoryResponse as P, type RevenueSplit as R, type SendParams as S, type TokenBalance as T, type WatermarkingData as W, type ZubariWalletConfig as Z, type NetworkBalance as a, type TxResult as b, type NFTCurrency as c, type NFTAttribute as d, type NFTMetadata as e, type NFT as f, type ListingParams as g, type Listing as h, type TipData as i, type TipResult as j, type TipStats as k, type Tip as l, type SubscriptionPlan as m, type Subscription as n, type SwapQuote as o, type SwapParams as p, type ZubariErrorCode as q, ZubariError as r, type EarningsResponse as s, type BreakdownResponse as t, type PlatformFeeResponse as u, type ClaimResult as v };
@@ -1,5 +1,5 @@
1
- import { Z as ZubariWalletConfig, N as NetworkType, A as Account, a as NetworkBalance, S as SendParams, b as TxResult } from './index-Be7yLGAO.mjs';
2
- import './WalletManager-DKPzfA74.mjs';
1
+ import { Z as ZubariWalletConfig, N as NetworkType, A as Account, a as NetworkBalance, S as SendParams, b as TxResult } from './index-Bou-9cAG.js';
2
+ import './WalletManager-U1YWIUWn.js';
3
3
 
4
4
  interface ContractAddresses {
5
5
  registry: string;
@@ -11,7 +11,6 @@ interface ContractAddresses {
11
11
  entryPoint: string;
12
12
  paymaster: string;
13
13
  accountFactory: string;
14
- usdc: string;
15
14
  usdt: string;
16
15
  weth: string;
17
16
  }
package/dist/index.d.mts CHANGED
@@ -1,9 +1,9 @@
1
- export { C as CURRENCY_ADDRESSES, N as NFT_VOUCHER_DOMAIN, c as NFT_VOUCHER_TYPES, P as PLATFORM_CONFIG, b as ZERO_ADDRESS, a as ZUBARI_CONTRACTS, Z as ZubariWallet, g as getContractAddresses } from './index-BrLMTY29.mjs';
2
- export { D as DERIVATION_PATHS, N as NETWORKS, T as TESTNET_NETWORKS, W as WalletManager, b as WalletManagerConfig, a as WalletState, g as getNetworkConfig } from './WalletManager-DKPzfA74.mjs';
1
+ export { C as CURRENCY_ADDRESSES, N as NFT_VOUCHER_DOMAIN, c as NFT_VOUCHER_TYPES, P as PLATFORM_CONFIG, b as ZERO_ADDRESS, a as ZUBARI_CONTRACTS, Z as ZubariWallet, g as getContractAddresses } from './index--dqjW2SS.mjs';
2
+ export { D as DERIVATION_PATHS, N as NETWORKS, T as TESTNET_NETWORKS, W as WalletManager, b as WalletManagerConfig, a as WalletState, g as getNetworkConfig } from './WalletManager-CQSrvRVs.mjs';
3
3
  export { M as MemoryStorageAdapter, S as SecureStorageAdapter, W as WebEncryptedStorageAdapter, c as createSecureStorage } from './SecureStorage-jO783AhC.mjs';
4
4
  export { ZubariMarketProtocol, ZubariNFTProtocol, ZubariPayoutsProtocol, ZubariSubscriptionProtocol, ZubariTipsProtocol } from './protocols/index.mjs';
5
5
  export { BrowserAddressDerivation, ChainAddress, ChainBalance, FeeEstimate, FeeRates, MultiChainAddresses, SupportedChain, SwapService, TransactionHistoryItem, TransactionParams, TransactionResult, TransactionService, TransactionServiceConfig, WdkApiClient, ZubariWdkService, ZubariWdkServiceConfig, createTransactionService, createZubariWdkService, getTransactionService, getWdkApiClient, getZubariWdkService, isBrowser } from './services/index.mjs';
6
- export { A as Account, B as BuyParams, C as CreateVoucherParams, E as EarningsBreakdown, L as LazyMintVoucher, h as Listing, g as ListingParams, f as NFT, d as NFTAttribute, c as NFTCurrency, e as NFTMetadata, a as NetworkBalance, N as NetworkType, R as RevenueSplit, S as SendParams, n as Subscription, m as SubscriptionPlan, p as SwapParams, o as SwapQuote, l as Tip, i as TipData, j as TipResult, k as TipStats, T as TokenBalance, b as TxResult, W as WatermarkingData, r as ZubariError, q as ZubariErrorCode, Z as ZubariWalletConfig } from './index-Be7yLGAO.mjs';
6
+ export { A as Account, B as BuyParams, C as CreateVoucherParams, E as EarningsBreakdown, L as LazyMintVoucher, h as Listing, g as ListingParams, f as NFT, d as NFTAttribute, c as NFTCurrency, e as NFTMetadata, a as NetworkBalance, N as NetworkType, R as RevenueSplit, S as SendParams, n as Subscription, m as SubscriptionPlan, p as SwapParams, o as SwapQuote, l as Tip, i as TipData, j as TipResult, k as TipStats, T as TokenBalance, b as TxResult, W as WatermarkingData, r as ZubariError, q as ZubariErrorCode, Z as ZubariWalletConfig } from './index-Bou-9cAG.mjs';
7
7
  export { FeeEstimateResult, SendTransactionResult, UseWalletManagerOptions, UseWalletManagerReturn, useWalletManager } from './react/index.mjs';
8
8
  import 'abitype';
9
9
  import 'viem';
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- export { C as CURRENCY_ADDRESSES, N as NFT_VOUCHER_DOMAIN, c as NFT_VOUCHER_TYPES, P as PLATFORM_CONFIG, b as ZERO_ADDRESS, a as ZUBARI_CONTRACTS, Z as ZubariWallet, g as getContractAddresses } from './index-BCX8EYxv.js';
2
- export { D as DERIVATION_PATHS, N as NETWORKS, T as TESTNET_NETWORKS, W as WalletManager, b as WalletManagerConfig, a as WalletState, g as getNetworkConfig } from './WalletManager-IOHFgvpT.js';
1
+ export { C as CURRENCY_ADDRESSES, N as NFT_VOUCHER_DOMAIN, c as NFT_VOUCHER_TYPES, P as PLATFORM_CONFIG, b as ZERO_ADDRESS, a as ZUBARI_CONTRACTS, Z as ZubariWallet, g as getContractAddresses } from './index-CkPxa5Bn.js';
2
+ export { D as DERIVATION_PATHS, N as NETWORKS, T as TESTNET_NETWORKS, W as WalletManager, b as WalletManagerConfig, a as WalletState, g as getNetworkConfig } from './WalletManager-U1YWIUWn.js';
3
3
  export { M as MemoryStorageAdapter, S as SecureStorageAdapter, W as WebEncryptedStorageAdapter, c as createSecureStorage } from './SecureStorage-jO783AhC.js';
4
4
  export { ZubariMarketProtocol, ZubariNFTProtocol, ZubariPayoutsProtocol, ZubariSubscriptionProtocol, ZubariTipsProtocol } from './protocols/index.js';
5
5
  export { BrowserAddressDerivation, ChainAddress, ChainBalance, FeeEstimate, FeeRates, MultiChainAddresses, SupportedChain, SwapService, TransactionHistoryItem, TransactionParams, TransactionResult, TransactionService, TransactionServiceConfig, WdkApiClient, ZubariWdkService, ZubariWdkServiceConfig, createTransactionService, createZubariWdkService, getTransactionService, getWdkApiClient, getZubariWdkService, isBrowser } from './services/index.js';
6
- export { A as Account, B as BuyParams, C as CreateVoucherParams, E as EarningsBreakdown, L as LazyMintVoucher, h as Listing, g as ListingParams, f as NFT, d as NFTAttribute, c as NFTCurrency, e as NFTMetadata, a as NetworkBalance, N as NetworkType, R as RevenueSplit, S as SendParams, n as Subscription, m as SubscriptionPlan, p as SwapParams, o as SwapQuote, l as Tip, i as TipData, j as TipResult, k as TipStats, T as TokenBalance, b as TxResult, W as WatermarkingData, r as ZubariError, q as ZubariErrorCode, Z as ZubariWalletConfig } from './index-Be7yLGAO.js';
6
+ export { A as Account, B as BuyParams, C as CreateVoucherParams, E as EarningsBreakdown, L as LazyMintVoucher, h as Listing, g as ListingParams, f as NFT, d as NFTAttribute, c as NFTCurrency, e as NFTMetadata, a as NetworkBalance, N as NetworkType, R as RevenueSplit, S as SendParams, n as Subscription, m as SubscriptionPlan, p as SwapParams, o as SwapQuote, l as Tip, i as TipData, j as TipResult, k as TipStats, T as TokenBalance, b as TxResult, W as WatermarkingData, r as ZubariError, q as ZubariErrorCode, Z as ZubariWalletConfig } from './index-Bou-9cAG.js';
7
7
  export { FeeEstimateResult, SendTransactionResult, UseWalletManagerOptions, UseWalletManagerReturn, useWalletManager } from './react/index.js';
8
8
  import 'abitype';
9
9
  import 'viem';
package/dist/index.js CHANGED
@@ -160,8 +160,6 @@ var ZUBARI_CONTRACTS = {
160
160
  // Deploy with: npx hardhat run deploy/deploy.ts --network ethereum-sepolia
161
161
  accountFactory: ZERO_ADDRESS,
162
162
  // Not yet deployed
163
- usdc: "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",
164
- // USDC on Sepolia
165
163
  usdt: "0xaA8E23Fb1079EA71e0a56F48a2aA51851D8433D0",
166
164
  // USDT on Sepolia
167
165
  weth: "0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14"
@@ -177,8 +175,6 @@ var ZUBARI_CONTRACTS = {
177
175
  entryPoint: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
178
176
  paymaster: ZERO_ADDRESS,
179
177
  accountFactory: ZERO_ADDRESS,
180
- usdc: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
181
- // USDC on Ethereum
182
178
  usdt: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
183
179
  // USDT on Ethereum
184
180
  weth: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
@@ -5424,12 +5420,14 @@ var ZubariSubscriptionProtocol = class {
5424
5420
  var ZubariPayoutsProtocol = class {
5425
5421
  contractAddress;
5426
5422
  chainId;
5427
- constructor(contractAddress, chainId) {
5423
+ apiBaseUrl;
5424
+ constructor(contractAddress, chainId, apiBaseUrl) {
5428
5425
  this.contractAddress = contractAddress;
5429
5426
  this.chainId = chainId;
5427
+ this.apiBaseUrl = apiBaseUrl || "https://ckgwifsxka.us-east-2.awsapprunner.com";
5430
5428
  }
5431
5429
  /**
5432
- * Get pending earnings breakdown for the current user
5430
+ * Get pending earnings breakdown for the current user (on-chain)
5433
5431
  */
5434
5432
  async getPendingEarnings() {
5435
5433
  return {
@@ -5440,6 +5438,75 @@ var ZubariPayoutsProtocol = class {
5440
5438
  total: BigInt(0)
5441
5439
  };
5442
5440
  }
5441
+ /**
5442
+ * Get earnings data from API (includes pending, total, breakdown, and recent payouts)
5443
+ * Requires authentication token
5444
+ */
5445
+ async getEarnings(authToken) {
5446
+ const response = await fetch(`${this.apiBaseUrl}/api/payouts/earnings`, {
5447
+ headers: {
5448
+ Authorization: `Bearer ${authToken}`,
5449
+ "Content-Type": "application/json"
5450
+ }
5451
+ });
5452
+ if (!response.ok) {
5453
+ const error = await response.json();
5454
+ throw new Error(error.error || "Failed to fetch earnings");
5455
+ }
5456
+ return response.json();
5457
+ }
5458
+ /**
5459
+ * Get payout history with pagination
5460
+ * Requires authentication token
5461
+ */
5462
+ async getPayoutHistory(authToken, page = 1, limit = 20) {
5463
+ const response = await fetch(
5464
+ `${this.apiBaseUrl}/api/payouts/history?page=${page}&limit=${limit}`,
5465
+ {
5466
+ headers: {
5467
+ Authorization: `Bearer ${authToken}`,
5468
+ "Content-Type": "application/json"
5469
+ }
5470
+ }
5471
+ );
5472
+ if (!response.ok) {
5473
+ const error = await response.json();
5474
+ throw new Error(error.error || "Failed to fetch payout history");
5475
+ }
5476
+ return response.json();
5477
+ }
5478
+ /**
5479
+ * Get earnings breakdown by source with percentages
5480
+ * Requires authentication token
5481
+ */
5482
+ async getBreakdown(authToken) {
5483
+ const response = await fetch(`${this.apiBaseUrl}/api/payouts/breakdown`, {
5484
+ headers: {
5485
+ Authorization: `Bearer ${authToken}`,
5486
+ "Content-Type": "application/json"
5487
+ }
5488
+ });
5489
+ if (!response.ok) {
5490
+ const error = await response.json();
5491
+ throw new Error(error.error || "Failed to fetch earnings breakdown");
5492
+ }
5493
+ return response.json();
5494
+ }
5495
+ /**
5496
+ * Get current platform fee
5497
+ */
5498
+ async getPlatformFee() {
5499
+ const response = await fetch(`${this.apiBaseUrl}/api/payouts/platform-fee`, {
5500
+ headers: {
5501
+ "Content-Type": "application/json"
5502
+ }
5503
+ });
5504
+ if (!response.ok) {
5505
+ const error = await response.json();
5506
+ throw new Error(error.error || "Failed to fetch platform fee");
5507
+ }
5508
+ return response.json();
5509
+ }
5443
5510
  /**
5444
5511
  * Get historical earnings for a time period
5445
5512
  */
@@ -5447,7 +5514,26 @@ var ZubariPayoutsProtocol = class {
5447
5514
  return [];
5448
5515
  }
5449
5516
  /**
5450
- * Claim all pending earnings
5517
+ * Claim all pending earnings via API
5518
+ * Requires authentication token and seed phrase
5519
+ */
5520
+ async claimEarningsViaApi(authToken, seed) {
5521
+ const response = await fetch(`${this.apiBaseUrl}/api/payouts/claim`, {
5522
+ method: "POST",
5523
+ headers: {
5524
+ Authorization: `Bearer ${authToken}`,
5525
+ "Content-Type": "application/json"
5526
+ },
5527
+ body: JSON.stringify({ seed })
5528
+ });
5529
+ if (!response.ok) {
5530
+ const error = await response.json();
5531
+ throw new Error(error.error || "Failed to claim earnings");
5532
+ }
5533
+ return response.json();
5534
+ }
5535
+ /**
5536
+ * Claim all pending earnings (direct contract call)
5451
5537
  */
5452
5538
  async claimEarnings() {
5453
5539
  return {
@@ -5521,6 +5607,18 @@ var ZubariPayoutsProtocol = class {
5521
5607
  status: "pending"
5522
5608
  };
5523
5609
  }
5610
+ /**
5611
+ * Get the contract address
5612
+ */
5613
+ getContractAddress() {
5614
+ return this.contractAddress;
5615
+ }
5616
+ /**
5617
+ * Get the chain ID
5618
+ */
5619
+ getChainId() {
5620
+ return this.chainId;
5621
+ }
5524
5622
  };
5525
5623
 
5526
5624
  // src/services/SwapService.ts