@zubari/sdk 0.1.29 → 0.2.0

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.
@@ -1,4 +1,4 @@
1
- import { c as NFTMetadata, L as LazyMintVoucher, b as TxResult, e as ListingParams, d as NFT, B as BuyParams, f as Listing, g as TipData, h as TipResult, i as TipStats, j as SubscriptionPlan, k as Subscription, E as EarningsBreakdown, R as RevenueSplit } from '../index-IPLQBUaD.mjs';
1
+ import { C as CreateVoucherParams, L as LazyMintVoucher, e as NFTMetadata, b as TxResult, g as ListingParams, f as NFT, B as BuyParams, h as Listing, l as Tip, m as SubscriptionPlan, n as Subscription, E as EarningsBreakdown, R as RevenueSplit } from '../index-Be7yLGAO.mjs';
2
2
 
3
3
  /**
4
4
  * ZubariNFTProtocol - NFT creation and marketplace operations
@@ -10,12 +10,42 @@ declare class ZubariNFTProtocol {
10
10
  private readonly contractAddress;
11
11
  private readonly _marketplaceAddress;
12
12
  private readonly chainId;
13
- constructor(contractAddress: string, marketplaceAddress: string, chainId: number);
13
+ private readonly network;
14
+ private nonceCounter;
15
+ constructor(contractAddress: string, marketplaceAddress: string, chainId: number, network?: 'testnet' | 'mainnet');
16
+ /**
17
+ * Convert human-readable price to wei
18
+ * @param price - Price in human-readable format (e.g., "1.5")
19
+ * @param currency - ETH (18 decimals) or USDT (6 decimals)
20
+ */
21
+ private priceToWei;
22
+ /**
23
+ * Get currency address for the configured network
24
+ */
25
+ private getCurrencyAddress;
26
+ /**
27
+ * Generate a unique nonce
28
+ */
29
+ private generateNonce;
30
+ /**
31
+ * Pad string to bytes32 format
32
+ */
33
+ private toBytes32;
14
34
  /**
15
35
  * Create a lazy mint voucher for off-chain NFT creation
16
36
  * The voucher can be redeemed on-chain when purchased
37
+ *
38
+ * @param params - Voucher creation parameters
39
+ * @param signer - Object with signTypedData method (ethers.js wallet or viem client)
17
40
  */
18
- createLazyMintVoucher(metadata: NFTMetadata, creatorAddress: string, signer: {
41
+ createLazyMintVoucher(params: CreateVoucherParams, signer: {
42
+ signTypedData: (domain: object, types: object, value: object) => Promise<string>;
43
+ }): Promise<LazyMintVoucher>;
44
+ /**
45
+ * @deprecated Use createLazyMintVoucher(params, signer) instead
46
+ * Legacy method for backward compatibility
47
+ */
48
+ createLazyMintVoucherLegacy(metadata: NFTMetadata, creatorAddress: string, signer: {
19
49
  signTypedData: (domain: object, types: object, value: object) => Promise<string>;
20
50
  }): Promise<LazyMintVoucher>;
21
51
  /**
@@ -203,89 +233,389 @@ declare class ZubariMarketProtocol {
203
233
  * ZubariTipsProtocol - Micropayment tips for creators
204
234
  *
205
235
  * Handles ETH and ERC-20 token tips with platform fee distribution.
206
- * Supports gasless tips via ERC-4337 when enabled.
236
+ * Supports individual tips, batch tips, and tip queries.
207
237
  */
208
238
  declare class ZubariTipsProtocol {
209
239
  private readonly contractAddress;
210
240
  private readonly chainId;
211
- private readonly gaslessEnabled;
212
- constructor(contractAddress: string, chainId: number, gaslessEnabled?: boolean);
241
+ private readonly abi;
242
+ constructor(contractAddress: string, chainId: number);
213
243
  /**
214
- * Send a tip to a creator
244
+ * Get the contract ABI
215
245
  */
216
- sendTip(tip: TipData): Promise<TipResult>;
246
+ getAbi(): ({
247
+ inputs: {
248
+ internalType: string;
249
+ name: string;
250
+ type: string;
251
+ }[];
252
+ stateMutability: string;
253
+ type: string;
254
+ name?: undefined;
255
+ anonymous?: undefined;
256
+ outputs?: undefined;
257
+ } | {
258
+ inputs: {
259
+ internalType: string;
260
+ name: string;
261
+ type: string;
262
+ }[];
263
+ name: string;
264
+ type: string;
265
+ stateMutability?: undefined;
266
+ anonymous?: undefined;
267
+ outputs?: undefined;
268
+ } | {
269
+ anonymous: boolean;
270
+ inputs: {
271
+ indexed: boolean;
272
+ internalType: string;
273
+ name: string;
274
+ type: string;
275
+ }[];
276
+ name: string;
277
+ type: string;
278
+ stateMutability?: undefined;
279
+ outputs?: undefined;
280
+ } | {
281
+ inputs: {
282
+ internalType: string;
283
+ name: string;
284
+ type: string;
285
+ }[];
286
+ name: string;
287
+ outputs: {
288
+ components: {
289
+ internalType: string;
290
+ name: string;
291
+ type: string;
292
+ }[];
293
+ internalType: string;
294
+ name: string;
295
+ type: string;
296
+ }[];
297
+ stateMutability: string;
298
+ type: string;
299
+ anonymous?: undefined;
300
+ } | {
301
+ inputs: {
302
+ internalType: string;
303
+ name: string;
304
+ type: string;
305
+ }[];
306
+ name: string;
307
+ outputs: {
308
+ internalType: string;
309
+ name: string;
310
+ type: string;
311
+ }[];
312
+ stateMutability: string;
313
+ type: string;
314
+ anonymous?: undefined;
315
+ })[];
316
+ /**
317
+ * Get the contract address
318
+ */
319
+ getAddress(): string;
320
+ /**
321
+ * Send ETH tip to a creator
322
+ * @param recipient The recipient address
323
+ * @param message Optional tip message
324
+ * @param signer Wallet signer with sendTransaction method
325
+ * @param value ETH amount to tip (in wei)
326
+ */
327
+ tipETH(recipient: string, message: string, signer: {
328
+ sendTransaction: (tx: object) => Promise<{
329
+ hash: string;
330
+ }>;
331
+ }, value: bigint): Promise<TxResult>;
217
332
  /**
218
- * Send tips to multiple creators in a single transaction
333
+ * Send ERC-20 token tip to a creator
334
+ * @param recipient The recipient address
335
+ * @param token The ERC-20 token address
336
+ * @param amount The amount of tokens to tip
337
+ * @param message Optional tip message
338
+ * @param signer Wallet signer
219
339
  */
220
- sendBatchTips(tips: TipData[]): Promise<TipResult[]>;
340
+ tipToken(recipient: string, token: string, amount: bigint, message: string, signer: {
341
+ sendTransaction: (tx: object) => Promise<{
342
+ hash: string;
343
+ }>;
344
+ }): Promise<TxResult>;
221
345
  /**
222
- * Get tips received by an address
346
+ * Send batch tips to multiple creators in a single transaction
347
+ * @param recipients Array of recipient addresses
348
+ * @param amounts Array of tip amounts (in wei)
349
+ * @param messages Array of tip messages
350
+ * @param signer Wallet signer
351
+ * @param value Total ETH to send
223
352
  */
224
- getTipsReceived(address: string): Promise<TipResult[]>;
353
+ sendBatchTips(recipients: string[], amounts: bigint[], messages: string[], signer: {
354
+ sendTransaction: (tx: object) => Promise<{
355
+ hash: string;
356
+ }>;
357
+ }, value: bigint): Promise<TxResult>;
225
358
  /**
226
- * Get tips sent by an address
359
+ * Get tip details by ID
360
+ * @param tipId The tip ID
361
+ * @param provider JSON-RPC provider
227
362
  */
228
- getTipsSent(address: string): Promise<TipResult[]>;
363
+ getTip(tipId: string, provider: {
364
+ call: (tx: object) => Promise<string>;
365
+ }): Promise<Tip | null>;
229
366
  /**
230
- * Get tip statistics for a creator
367
+ * Get total tips received by an address
368
+ * @param address The address to query
369
+ * @param provider JSON-RPC provider
231
370
  */
232
- getCreatorTipStats(creator: string): Promise<TipStats>;
371
+ getTotalTipsReceived(address: string, provider: {
372
+ call: (tx: object) => Promise<string>;
373
+ }): Promise<bigint>;
233
374
  /**
234
375
  * Get platform fee in basis points
376
+ * @param provider JSON-RPC provider
235
377
  */
236
- getPlatformFeeBps(): number;
378
+ getPlatformFeeBps(provider: {
379
+ call: (tx: object) => Promise<string>;
380
+ }): Promise<number>;
381
+ /**
382
+ * Get current tip counter
383
+ * @param provider JSON-RPC provider
384
+ */
385
+ getTipCounter(provider: {
386
+ call: (tx: object) => Promise<string>;
387
+ }): Promise<bigint>;
388
+ /**
389
+ * Get treasury address
390
+ * @param provider JSON-RPC provider
391
+ */
392
+ getTreasury(provider: {
393
+ call: (tx: object) => Promise<string>;
394
+ }): Promise<string>;
395
+ /**
396
+ * Calculate platform fee for a given amount
397
+ * @param amount The tip amount
398
+ * @param feeBps Fee in basis points (default: 300 = 3%)
399
+ */
400
+ calculateFee(amount: bigint, feeBps?: number): {
401
+ fee: bigint;
402
+ creatorAmount: bigint;
403
+ };
237
404
  }
238
405
 
239
406
  /**
240
407
  * ZubariSubscriptionProtocol - Recurring subscription payments
241
408
  *
242
409
  * Handles subscription plan creation, subscription management,
243
- * and verification of active subscriptions.
410
+ * and verification of active subscriptions using the ZubariSubscription smart contract.
244
411
  */
245
412
  declare class ZubariSubscriptionProtocol {
246
413
  private readonly contractAddress;
247
414
  private readonly chainId;
415
+ private readonly abi;
248
416
  constructor(contractAddress: string, chainId: number);
417
+ /**
418
+ * Get the contract ABI
419
+ */
420
+ getAbi(): ({
421
+ inputs: {
422
+ internalType: string;
423
+ name: string;
424
+ type: string;
425
+ }[];
426
+ stateMutability: string;
427
+ type: string;
428
+ name?: undefined;
429
+ anonymous?: undefined;
430
+ outputs?: undefined;
431
+ } | {
432
+ inputs: {
433
+ internalType: string;
434
+ name: string;
435
+ type: string;
436
+ }[];
437
+ name: string;
438
+ type: string;
439
+ stateMutability?: undefined;
440
+ anonymous?: undefined;
441
+ outputs?: undefined;
442
+ } | {
443
+ anonymous: boolean;
444
+ inputs: {
445
+ indexed: boolean;
446
+ internalType: string;
447
+ name: string;
448
+ type: string;
449
+ }[];
450
+ name: string;
451
+ type: string;
452
+ stateMutability?: undefined;
453
+ outputs?: undefined;
454
+ } | {
455
+ inputs: {
456
+ internalType: string;
457
+ name: string;
458
+ type: string;
459
+ }[];
460
+ name: string;
461
+ outputs: {
462
+ internalType: string;
463
+ name: string;
464
+ type: string;
465
+ }[];
466
+ stateMutability: string;
467
+ type: string;
468
+ anonymous?: undefined;
469
+ } | {
470
+ inputs: {
471
+ internalType: string;
472
+ name: string;
473
+ type: string;
474
+ }[];
475
+ name: string;
476
+ outputs: {
477
+ components: {
478
+ internalType: string;
479
+ name: string;
480
+ type: string;
481
+ }[];
482
+ internalType: string;
483
+ name: string;
484
+ type: string;
485
+ }[];
486
+ stateMutability: string;
487
+ type: string;
488
+ anonymous?: undefined;
489
+ })[];
490
+ /**
491
+ * Get the contract address
492
+ */
493
+ getAddress(): string;
249
494
  /**
250
495
  * Create a new subscription plan
496
+ * @param plan The plan details
497
+ * @param signer Wallet signer with sendTransaction method
251
498
  */
252
- createPlan(plan: SubscriptionPlan): Promise<string>;
499
+ createPlan(plan: SubscriptionPlan, signer: {
500
+ sendTransaction: (tx: object) => Promise<{
501
+ hash: string;
502
+ }>;
503
+ }): Promise<string>;
253
504
  /**
254
- * Update an existing subscription plan
505
+ * Deactivate a subscription plan (only creator can do this)
506
+ * @param planId The plan ID to deactivate
507
+ * @param signer Wallet signer
255
508
  */
256
- updatePlan(planId: string, updates: Partial<SubscriptionPlan>): Promise<TxResult>;
509
+ deactivatePlan(planId: string, signer: {
510
+ sendTransaction: (tx: object) => Promise<{
511
+ hash: string;
512
+ }>;
513
+ }): Promise<TxResult>;
257
514
  /**
258
515
  * Subscribe to a creator's plan
516
+ * @param planId The plan ID to subscribe to
517
+ * @param months Number of months to subscribe
518
+ * @param signer Wallet signer
519
+ * @param value ETH value to send (if paying with ETH)
259
520
  */
260
- subscribe(creator: string, planId: string, months?: number): Promise<Subscription>;
521
+ subscribe(planId: string, months: number, signer: {
522
+ sendTransaction: (tx: object) => Promise<{
523
+ hash: string;
524
+ }>;
525
+ }, value?: bigint): Promise<TxResult>;
261
526
  /**
262
527
  * Cancel an active subscription
528
+ * @param subscriptionId The subscription ID to cancel
529
+ * @param signer Wallet signer
530
+ */
531
+ cancel(subscriptionId: string, signer: {
532
+ sendTransaction: (tx: object) => Promise<{
533
+ hash: string;
534
+ }>;
535
+ }): Promise<TxResult>;
536
+ /**
537
+ * Set auto-renew for a subscription
538
+ * @param subscriptionId The subscription ID
539
+ * @param autoRenew Whether to enable auto-renew
540
+ * @param signer Wallet signer
263
541
  */
264
- cancel(subscriptionId: string): Promise<TxResult>;
542
+ setAutoRenew(subscriptionId: string, autoRenew: boolean, signer: {
543
+ sendTransaction: (tx: object) => Promise<{
544
+ hash: string;
545
+ }>;
546
+ }): Promise<TxResult>;
265
547
  /**
266
548
  * Check if an address is subscribed to a creator
549
+ * @param subscriber The subscriber address
550
+ * @param creator The creator address
551
+ * @param provider JSON-RPC provider
267
552
  */
268
- isSubscribed(creator: string, subscriber?: string): Promise<boolean>;
553
+ isSubscribed(subscriber: string, creator: string, provider: {
554
+ call: (tx: object) => Promise<string>;
555
+ }): Promise<boolean>;
269
556
  /**
270
- * Get active subscriptions for a subscriber
557
+ * Get the active subscription ID between subscriber and creator
558
+ * @param subscriber The subscriber address
559
+ * @param creator The creator address
560
+ * @param provider JSON-RPC provider
271
561
  */
272
- getActiveSubscriptions(subscriber?: string): Promise<Subscription[]>;
562
+ getActiveSubscriptionId(subscriber: string, creator: string, provider: {
563
+ call: (tx: object) => Promise<string>;
564
+ }): Promise<string | null>;
273
565
  /**
274
- * Get all subscribers for a creator
566
+ * Get subscription details by ID
567
+ * @param subscriptionId The subscription ID
568
+ * @param provider JSON-RPC provider
275
569
  */
276
- getSubscribers(creator: string): Promise<Subscription[]>;
570
+ getSubscription(subscriptionId: string, provider: {
571
+ call: (tx: object) => Promise<string>;
572
+ }): Promise<Subscription | null>;
277
573
  /**
278
574
  * Get a specific plan by ID
575
+ * @param planId The plan ID
576
+ * @param provider JSON-RPC provider
279
577
  */
280
- getPlan(planId: string): Promise<SubscriptionPlan | null>;
578
+ getPlan(planId: string, provider: {
579
+ call: (tx: object) => Promise<string>;
580
+ }): Promise<SubscriptionPlan | null>;
281
581
  /**
282
- * Get all plans for a creator
582
+ * Get all plan IDs for a creator
583
+ * @param creator The creator address
584
+ * @param provider JSON-RPC provider
585
+ */
586
+ getCreatorPlanIds(creator: string, provider: {
587
+ call: (tx: object) => Promise<string>;
588
+ }): Promise<string[]>;
589
+ /**
590
+ * Get all plans for a creator with full details
591
+ * @param creator The creator address
592
+ * @param provider JSON-RPC provider
283
593
  */
284
- getCreatorPlans(creator: string): Promise<SubscriptionPlan[]>;
594
+ getCreatorPlans(creator: string, provider: {
595
+ call: (tx: object) => Promise<string>;
596
+ }): Promise<SubscriptionPlan[]>;
285
597
  /**
286
- * Generate a unique plan ID
598
+ * Get platform fee in basis points
599
+ * @param provider JSON-RPC provider
287
600
  */
288
- private generatePlanId;
601
+ getPlatformFeeBps(provider: {
602
+ call: (tx: object) => Promise<string>;
603
+ }): Promise<number>;
604
+ /**
605
+ * Calculate the total cost for a subscription
606
+ * @param planPrice The plan price per period
607
+ * @param months Number of months
608
+ */
609
+ calculateSubscriptionCost(planPrice: bigint, months: number): bigint;
610
+ /**
611
+ * Calculate platform fee for a given amount
612
+ * @param amount The amount
613
+ * @param feeBps Fee in basis points
614
+ */
615
+ calculateFee(amount: bigint, feeBps?: number): {
616
+ fee: bigint;
617
+ creatorAmount: bigint;
618
+ };
289
619
  }
290
620
 
291
621
  /**