@zubari/sdk 0.1.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.
Files changed (49) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +324 -0
  3. package/dist/SecureStorage-jO783AhC.d.mts +89 -0
  4. package/dist/SecureStorage-jO783AhC.d.ts +89 -0
  5. package/dist/SwapService-C0G8IXW2.d.mts +35 -0
  6. package/dist/SwapService-DZD0OJI_.d.ts +35 -0
  7. package/dist/WalletManager-DJjdq89b.d.mts +6106 -0
  8. package/dist/WalletManager-TiAdzqrn.d.ts +6106 -0
  9. package/dist/index-BLuxEdLp.d.mts +156 -0
  10. package/dist/index-BLuxEdLp.d.ts +156 -0
  11. package/dist/index-DO3T2HVe.d.ts +135 -0
  12. package/dist/index-fXVD8_D0.d.mts +135 -0
  13. package/dist/index.d.mts +67 -0
  14. package/dist/index.d.ts +67 -0
  15. package/dist/index.js +2411 -0
  16. package/dist/index.js.map +1 -0
  17. package/dist/index.mjs +2386 -0
  18. package/dist/index.mjs.map +1 -0
  19. package/dist/protocols/index.d.mts +181 -0
  20. package/dist/protocols/index.d.ts +181 -0
  21. package/dist/protocols/index.js +415 -0
  22. package/dist/protocols/index.js.map +1 -0
  23. package/dist/protocols/index.mjs +410 -0
  24. package/dist/protocols/index.mjs.map +1 -0
  25. package/dist/react/index.d.mts +49 -0
  26. package/dist/react/index.d.ts +49 -0
  27. package/dist/react/index.js +1573 -0
  28. package/dist/react/index.js.map +1 -0
  29. package/dist/react/index.mjs +1570 -0
  30. package/dist/react/index.mjs.map +1 -0
  31. package/dist/services/index.d.mts +198 -0
  32. package/dist/services/index.d.ts +198 -0
  33. package/dist/services/index.js +554 -0
  34. package/dist/services/index.js.map +1 -0
  35. package/dist/services/index.mjs +547 -0
  36. package/dist/services/index.mjs.map +1 -0
  37. package/dist/storage/index.d.mts +57 -0
  38. package/dist/storage/index.d.ts +57 -0
  39. package/dist/storage/index.js +442 -0
  40. package/dist/storage/index.js.map +1 -0
  41. package/dist/storage/index.mjs +435 -0
  42. package/dist/storage/index.mjs.map +1 -0
  43. package/dist/wallet/index.d.mts +8 -0
  44. package/dist/wallet/index.d.ts +8 -0
  45. package/dist/wallet/index.js +1678 -0
  46. package/dist/wallet/index.js.map +1 -0
  47. package/dist/wallet/index.mjs +1674 -0
  48. package/dist/wallet/index.mjs.map +1 -0
  49. package/package.json +136 -0
@@ -0,0 +1,181 @@
1
+ import { d as NFTMetadata, L as LazyMintVoucher, T as TxResult, f as ListingParams, e as NFT, g as TipData, h as TipResult, i as TipStats, j as SubscriptionPlan, k as Subscription, E as EarningsBreakdown, R as RevenueSplit } from '../index-BLuxEdLp.js';
2
+
3
+ /**
4
+ * ZubariNFTProtocol - NFT creation and marketplace operations
5
+ *
6
+ * Handles lazy minting via EIP-712 signatures, NFT listing,
7
+ * and marketplace operations on Ethereum network.
8
+ */
9
+ declare class ZubariNFTProtocol {
10
+ private readonly contractAddress;
11
+ private readonly _marketplaceAddress;
12
+ private readonly chainId;
13
+ constructor(contractAddress: string, marketplaceAddress: string, chainId: number);
14
+ /**
15
+ * Create a lazy mint voucher for off-chain NFT creation
16
+ * The voucher can be redeemed on-chain when purchased
17
+ */
18
+ createLazyMintVoucher(metadata: NFTMetadata, creatorAddress: string, signer: {
19
+ signTypedData: (domain: object, types: object, value: object) => Promise<string>;
20
+ }): Promise<LazyMintVoucher>;
21
+ /**
22
+ * Redeem a lazy mint voucher to mint the NFT on-chain
23
+ */
24
+ redeemVoucher(voucher: LazyMintVoucher, _buyerAddress: string): Promise<TxResult>;
25
+ /**
26
+ * List an NFT for sale on the marketplace
27
+ */
28
+ listForSale(_params: ListingParams): Promise<TxResult>;
29
+ /**
30
+ * Buy an NFT from the marketplace
31
+ */
32
+ buyNFT(_listingId: string, _price: bigint): Promise<TxResult>;
33
+ /**
34
+ * Transfer an NFT to another address
35
+ */
36
+ transfer(_tokenId: string, _to: string): Promise<TxResult>;
37
+ /**
38
+ * Get NFTs owned by an address
39
+ */
40
+ getOwnedNFTs(_address: string): Promise<NFT[]>;
41
+ /**
42
+ * Generate a random tokenId (32 bytes hex)
43
+ */
44
+ private generateTokenId;
45
+ }
46
+
47
+ /**
48
+ * ZubariTipsProtocol - Micropayment tips for creators
49
+ *
50
+ * Handles ETH and ERC-20 token tips with platform fee distribution.
51
+ * Supports gasless tips via ERC-4337 when enabled.
52
+ */
53
+ declare class ZubariTipsProtocol {
54
+ private readonly contractAddress;
55
+ private readonly chainId;
56
+ private readonly gaslessEnabled;
57
+ constructor(contractAddress: string, chainId: number, gaslessEnabled?: boolean);
58
+ /**
59
+ * Send a tip to a creator
60
+ */
61
+ sendTip(tip: TipData): Promise<TipResult>;
62
+ /**
63
+ * Send tips to multiple creators in a single transaction
64
+ */
65
+ sendBatchTips(tips: TipData[]): Promise<TipResult[]>;
66
+ /**
67
+ * Get tips received by an address
68
+ */
69
+ getTipsReceived(address: string): Promise<TipResult[]>;
70
+ /**
71
+ * Get tips sent by an address
72
+ */
73
+ getTipsSent(address: string): Promise<TipResult[]>;
74
+ /**
75
+ * Get tip statistics for a creator
76
+ */
77
+ getCreatorTipStats(creator: string): Promise<TipStats>;
78
+ /**
79
+ * Get platform fee in basis points
80
+ */
81
+ getPlatformFeeBps(): number;
82
+ }
83
+
84
+ /**
85
+ * ZubariSubscriptionProtocol - Recurring subscription payments
86
+ *
87
+ * Handles subscription plan creation, subscription management,
88
+ * and verification of active subscriptions.
89
+ */
90
+ declare class ZubariSubscriptionProtocol {
91
+ private readonly contractAddress;
92
+ private readonly chainId;
93
+ constructor(contractAddress: string, chainId: number);
94
+ /**
95
+ * Create a new subscription plan
96
+ */
97
+ createPlan(plan: SubscriptionPlan): Promise<string>;
98
+ /**
99
+ * Update an existing subscription plan
100
+ */
101
+ updatePlan(planId: string, updates: Partial<SubscriptionPlan>): Promise<TxResult>;
102
+ /**
103
+ * Subscribe to a creator's plan
104
+ */
105
+ subscribe(creator: string, planId: string, months?: number): Promise<Subscription>;
106
+ /**
107
+ * Cancel an active subscription
108
+ */
109
+ cancel(subscriptionId: string): Promise<TxResult>;
110
+ /**
111
+ * Check if an address is subscribed to a creator
112
+ */
113
+ isSubscribed(creator: string, subscriber?: string): Promise<boolean>;
114
+ /**
115
+ * Get active subscriptions for a subscriber
116
+ */
117
+ getActiveSubscriptions(subscriber?: string): Promise<Subscription[]>;
118
+ /**
119
+ * Get all subscribers for a creator
120
+ */
121
+ getSubscribers(creator: string): Promise<Subscription[]>;
122
+ /**
123
+ * Get a specific plan by ID
124
+ */
125
+ getPlan(planId: string): Promise<SubscriptionPlan | null>;
126
+ /**
127
+ * Get all plans for a creator
128
+ */
129
+ getCreatorPlans(creator: string): Promise<SubscriptionPlan[]>;
130
+ /**
131
+ * Generate a unique plan ID
132
+ */
133
+ private generatePlanId;
134
+ }
135
+
136
+ /**
137
+ * ZubariPayoutsProtocol - Creator earnings management
138
+ *
139
+ * Handles earnings tracking, claiming, revenue splits,
140
+ * and conversion to stablecoins.
141
+ */
142
+ declare class ZubariPayoutsProtocol {
143
+ private readonly contractAddress;
144
+ private readonly chainId;
145
+ constructor(contractAddress: string, chainId: number);
146
+ /**
147
+ * Get pending earnings breakdown for the current user
148
+ */
149
+ getPendingEarnings(): Promise<EarningsBreakdown>;
150
+ /**
151
+ * Get historical earnings for a time period
152
+ */
153
+ getEarningsHistory(period?: 'day' | 'week' | 'month' | 'all'): Promise<EarningsBreakdown[]>;
154
+ /**
155
+ * Claim all pending earnings
156
+ */
157
+ claimEarnings(): Promise<TxResult>;
158
+ /**
159
+ * Claim specific amount of earnings
160
+ */
161
+ claimPartialEarnings(amount: bigint): Promise<TxResult>;
162
+ /**
163
+ * Setup revenue split with collaborators
164
+ * Basis points must sum to 10000 (100%)
165
+ */
166
+ setupRevenueSplit(splits: RevenueSplit[]): Promise<TxResult>;
167
+ /**
168
+ * Get current revenue split configuration
169
+ */
170
+ getRevenueSplit(): Promise<RevenueSplit[]>;
171
+ /**
172
+ * Remove revenue split (creator gets 100%)
173
+ */
174
+ removeRevenueSplit(): Promise<TxResult>;
175
+ /**
176
+ * Convert earnings to stablecoin (USDT)
177
+ */
178
+ convertToStable(token: string, amount: bigint): Promise<TxResult>;
179
+ }
180
+
181
+ export { ZubariNFTProtocol, ZubariPayoutsProtocol, ZubariSubscriptionProtocol, ZubariTipsProtocol };
@@ -0,0 +1,415 @@
1
+ 'use strict';
2
+
3
+ // src/config/contracts.ts
4
+ var PLATFORM_CONFIG = {
5
+ // Platform fee in basis points (300 = 3%)
6
+ tipFeeBps: 300,
7
+ // Maximum royalty in basis points (1000 = 10%)
8
+ maxRoyaltyBps: 1e3,
9
+ // Voucher validity in seconds (30 days)
10
+ voucherValiditySecs: 30 * 24 * 60 * 60};
11
+ var NFT_VOUCHER_DOMAIN = {
12
+ name: "ZubariNFT",
13
+ version: "1"
14
+ };
15
+ var NFT_VOUCHER_TYPES = {
16
+ NFTVoucher: [
17
+ { name: "tokenId", type: "bytes32" },
18
+ { name: "uri", type: "string" },
19
+ { name: "creator", type: "address" },
20
+ { name: "royaltyBps", type: "uint256" },
21
+ { name: "deadline", type: "uint256" }
22
+ ]
23
+ };
24
+
25
+ // src/protocols/NFTProtocol.ts
26
+ var ZubariNFTProtocol = class {
27
+ contractAddress;
28
+ _marketplaceAddress;
29
+ chainId;
30
+ constructor(contractAddress, marketplaceAddress, chainId) {
31
+ this.contractAddress = contractAddress;
32
+ this._marketplaceAddress = marketplaceAddress;
33
+ this.chainId = chainId;
34
+ }
35
+ /**
36
+ * Create a lazy mint voucher for off-chain NFT creation
37
+ * The voucher can be redeemed on-chain when purchased
38
+ */
39
+ async createLazyMintVoucher(metadata, creatorAddress, signer) {
40
+ if (metadata.royaltyBps > PLATFORM_CONFIG.maxRoyaltyBps) {
41
+ throw new Error(`Royalty cannot exceed ${PLATFORM_CONFIG.maxRoyaltyBps / 100}%`);
42
+ }
43
+ const tokenId = this.generateTokenId();
44
+ const deadline = Math.floor(Date.now() / 1e3) + PLATFORM_CONFIG.voucherValiditySecs;
45
+ const voucherData = {
46
+ tokenId,
47
+ uri: metadata.image,
48
+ // Will be IPFS URI
49
+ creator: creatorAddress,
50
+ royaltyBps: metadata.royaltyBps,
51
+ deadline
52
+ };
53
+ const domain = {
54
+ ...NFT_VOUCHER_DOMAIN,
55
+ chainId: this.chainId,
56
+ verifyingContract: this.contractAddress
57
+ };
58
+ const signature = await signer.signTypedData(domain, NFT_VOUCHER_TYPES, voucherData);
59
+ return {
60
+ ...voucherData,
61
+ signature
62
+ };
63
+ }
64
+ /**
65
+ * Redeem a lazy mint voucher to mint the NFT on-chain
66
+ */
67
+ async redeemVoucher(voucher, _buyerAddress) {
68
+ if (voucher.deadline < Math.floor(Date.now() / 1e3)) {
69
+ throw new Error("Voucher has expired");
70
+ }
71
+ return {
72
+ hash: "",
73
+ network: "ethereum",
74
+ status: "pending"
75
+ };
76
+ }
77
+ /**
78
+ * List an NFT for sale on the marketplace
79
+ */
80
+ async listForSale(_params) {
81
+ return {
82
+ hash: "",
83
+ network: "ethereum",
84
+ status: "pending"
85
+ };
86
+ }
87
+ /**
88
+ * Buy an NFT from the marketplace
89
+ */
90
+ async buyNFT(_listingId, _price) {
91
+ return {
92
+ hash: "",
93
+ network: "ethereum",
94
+ status: "pending"
95
+ };
96
+ }
97
+ /**
98
+ * Transfer an NFT to another address
99
+ */
100
+ async transfer(_tokenId, _to) {
101
+ return {
102
+ hash: "",
103
+ network: "ethereum",
104
+ status: "pending"
105
+ };
106
+ }
107
+ /**
108
+ * Get NFTs owned by an address
109
+ */
110
+ async getOwnedNFTs(_address) {
111
+ return [];
112
+ }
113
+ /**
114
+ * Generate a random tokenId (32 bytes hex)
115
+ */
116
+ generateTokenId() {
117
+ const bytes = new Uint8Array(32);
118
+ crypto.getRandomValues(bytes);
119
+ return "0x" + Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
120
+ }
121
+ };
122
+
123
+ // src/protocols/TipsProtocol.ts
124
+ var ZubariTipsProtocol = class {
125
+ contractAddress;
126
+ chainId;
127
+ gaslessEnabled;
128
+ constructor(contractAddress, chainId, gaslessEnabled = false) {
129
+ this.contractAddress = contractAddress;
130
+ this.chainId = chainId;
131
+ this.gaslessEnabled = gaslessEnabled;
132
+ }
133
+ /**
134
+ * Send a tip to a creator
135
+ */
136
+ async sendTip(tip) {
137
+ const { recipient, amount, token, message } = tip;
138
+ const platformFee = amount * BigInt(PLATFORM_CONFIG.tipFeeBps) / BigInt(1e4);
139
+ const creatorAmount = amount - platformFee;
140
+ if (amount <= 0n) {
141
+ throw new Error("Tip amount must be greater than 0");
142
+ }
143
+ const txResult = {
144
+ hash: ""};
145
+ return {
146
+ txHash: txResult.hash,
147
+ tipId: "",
148
+ // Will be returned from contract event
149
+ recipient,
150
+ amount: creatorAmount,
151
+ platformFee,
152
+ timestamp: Math.floor(Date.now() / 1e3)
153
+ };
154
+ }
155
+ /**
156
+ * Send tips to multiple creators in a single transaction
157
+ */
158
+ async sendBatchTips(tips) {
159
+ if (tips.length === 0) {
160
+ throw new Error("At least one tip is required");
161
+ }
162
+ tips.reduce((sum, tip) => sum + tip.amount, BigInt(0));
163
+ return tips.map((tip) => ({
164
+ txHash: "",
165
+ tipId: "",
166
+ recipient: tip.recipient,
167
+ amount: tip.amount - tip.amount * BigInt(PLATFORM_CONFIG.tipFeeBps) / BigInt(1e4),
168
+ platformFee: tip.amount * BigInt(PLATFORM_CONFIG.tipFeeBps) / BigInt(1e4),
169
+ timestamp: Math.floor(Date.now() / 1e3)
170
+ }));
171
+ }
172
+ /**
173
+ * Get tips received by an address
174
+ */
175
+ async getTipsReceived(address) {
176
+ return [];
177
+ }
178
+ /**
179
+ * Get tips sent by an address
180
+ */
181
+ async getTipsSent(address) {
182
+ return [];
183
+ }
184
+ /**
185
+ * Get tip statistics for a creator
186
+ */
187
+ async getCreatorTipStats(creator) {
188
+ return {
189
+ totalReceived: BigInt(0),
190
+ tipCount: 0,
191
+ uniqueTippers: 0
192
+ };
193
+ }
194
+ /**
195
+ * Get platform fee in basis points
196
+ */
197
+ getPlatformFeeBps() {
198
+ return PLATFORM_CONFIG.tipFeeBps;
199
+ }
200
+ };
201
+
202
+ // src/protocols/SubscriptionProtocol.ts
203
+ var ZubariSubscriptionProtocol = class {
204
+ contractAddress;
205
+ chainId;
206
+ constructor(contractAddress, chainId) {
207
+ this.contractAddress = contractAddress;
208
+ this.chainId = chainId;
209
+ }
210
+ /**
211
+ * Create a new subscription plan
212
+ */
213
+ async createPlan(plan) {
214
+ if (!plan.name || plan.name.length === 0) {
215
+ throw new Error("Plan name is required");
216
+ }
217
+ if (plan.price <= 0n) {
218
+ throw new Error("Plan price must be greater than 0");
219
+ }
220
+ if (plan.duration <= 0) {
221
+ throw new Error("Plan duration must be greater than 0");
222
+ }
223
+ const planId = this.generatePlanId(plan.name);
224
+ return planId;
225
+ }
226
+ /**
227
+ * Update an existing subscription plan
228
+ */
229
+ async updatePlan(planId, updates) {
230
+ return {
231
+ hash: "",
232
+ network: "ethereum",
233
+ status: "pending"
234
+ };
235
+ }
236
+ /**
237
+ * Subscribe to a creator's plan
238
+ */
239
+ async subscribe(creator, planId, months = 1) {
240
+ if (months <= 0) {
241
+ throw new Error("Subscription duration must be at least 1 month");
242
+ }
243
+ const now = Math.floor(Date.now() / 1e3);
244
+ const durationSeconds = months * 30 * 24 * 60 * 60;
245
+ return {
246
+ subscriptionId: "",
247
+ planId,
248
+ creator,
249
+ subscriber: "",
250
+ // Current user address
251
+ startTime: now,
252
+ endTime: now + durationSeconds,
253
+ autoRenew: false,
254
+ status: "active"
255
+ };
256
+ }
257
+ /**
258
+ * Cancel an active subscription
259
+ */
260
+ async cancel(subscriptionId) {
261
+ return {
262
+ hash: "",
263
+ network: "ethereum",
264
+ status: "pending"
265
+ };
266
+ }
267
+ /**
268
+ * Check if an address is subscribed to a creator
269
+ */
270
+ async isSubscribed(creator, subscriber) {
271
+ return false;
272
+ }
273
+ /**
274
+ * Get active subscriptions for a subscriber
275
+ */
276
+ async getActiveSubscriptions(subscriber) {
277
+ return [];
278
+ }
279
+ /**
280
+ * Get all subscribers for a creator
281
+ */
282
+ async getSubscribers(creator) {
283
+ return [];
284
+ }
285
+ /**
286
+ * Get a specific plan by ID
287
+ */
288
+ async getPlan(planId) {
289
+ return null;
290
+ }
291
+ /**
292
+ * Get all plans for a creator
293
+ */
294
+ async getCreatorPlans(creator) {
295
+ return [];
296
+ }
297
+ /**
298
+ * Generate a unique plan ID
299
+ */
300
+ generatePlanId(name) {
301
+ const bytes = new Uint8Array(16);
302
+ crypto.getRandomValues(bytes);
303
+ return "0x" + Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
304
+ }
305
+ };
306
+
307
+ // src/protocols/PayoutsProtocol.ts
308
+ var ZubariPayoutsProtocol = class {
309
+ contractAddress;
310
+ chainId;
311
+ constructor(contractAddress, chainId) {
312
+ this.contractAddress = contractAddress;
313
+ this.chainId = chainId;
314
+ }
315
+ /**
316
+ * Get pending earnings breakdown for the current user
317
+ */
318
+ async getPendingEarnings() {
319
+ return {
320
+ tips: BigInt(0),
321
+ subscriptions: BigInt(0),
322
+ nftSales: BigInt(0),
323
+ royalties: BigInt(0),
324
+ total: BigInt(0)
325
+ };
326
+ }
327
+ /**
328
+ * Get historical earnings for a time period
329
+ */
330
+ async getEarningsHistory(period = "all") {
331
+ return [];
332
+ }
333
+ /**
334
+ * Claim all pending earnings
335
+ */
336
+ async claimEarnings() {
337
+ return {
338
+ hash: "",
339
+ network: "ethereum",
340
+ status: "pending"
341
+ };
342
+ }
343
+ /**
344
+ * Claim specific amount of earnings
345
+ */
346
+ async claimPartialEarnings(amount) {
347
+ if (amount <= 0n) {
348
+ throw new Error("Amount must be greater than 0");
349
+ }
350
+ return {
351
+ hash: "",
352
+ network: "ethereum",
353
+ status: "pending"
354
+ };
355
+ }
356
+ /**
357
+ * Setup revenue split with collaborators
358
+ * Basis points must sum to 10000 (100%)
359
+ */
360
+ async setupRevenueSplit(splits) {
361
+ const totalBps = splits.reduce((sum, split) => sum + split.basisPoints, 0);
362
+ if (totalBps !== 1e4) {
363
+ throw new Error("Revenue splits must sum to 100% (10000 basis points)");
364
+ }
365
+ for (const split of splits) {
366
+ if (split.basisPoints <= 0) {
367
+ throw new Error("Each split must have positive basis points");
368
+ }
369
+ if (!split.recipient || split.recipient.length === 0) {
370
+ throw new Error("Each split must have a valid recipient address");
371
+ }
372
+ }
373
+ return {
374
+ hash: "",
375
+ network: "ethereum",
376
+ status: "pending"
377
+ };
378
+ }
379
+ /**
380
+ * Get current revenue split configuration
381
+ */
382
+ async getRevenueSplit() {
383
+ return [];
384
+ }
385
+ /**
386
+ * Remove revenue split (creator gets 100%)
387
+ */
388
+ async removeRevenueSplit() {
389
+ return {
390
+ hash: "",
391
+ network: "ethereum",
392
+ status: "pending"
393
+ };
394
+ }
395
+ /**
396
+ * Convert earnings to stablecoin (USDT)
397
+ */
398
+ async convertToStable(token, amount) {
399
+ if (amount <= 0n) {
400
+ throw new Error("Amount must be greater than 0");
401
+ }
402
+ return {
403
+ hash: "",
404
+ network: "ethereum",
405
+ status: "pending"
406
+ };
407
+ }
408
+ };
409
+
410
+ exports.ZubariNFTProtocol = ZubariNFTProtocol;
411
+ exports.ZubariPayoutsProtocol = ZubariPayoutsProtocol;
412
+ exports.ZubariSubscriptionProtocol = ZubariSubscriptionProtocol;
413
+ exports.ZubariTipsProtocol = ZubariTipsProtocol;
414
+ //# sourceMappingURL=index.js.map
415
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/config/contracts.ts","../../src/protocols/NFTProtocol.ts","../../src/protocols/TipsProtocol.ts","../../src/protocols/SubscriptionProtocol.ts","../../src/protocols/PayoutsProtocol.ts"],"names":[],"mappings":";;;AAkDO,IAAM,eAAA,GAAkB;AAAA;AAAA,EAE7B,SAAA,EAAW,GAAA;AAAA;AAAA,EAEX,aAAA,EAAe,GAAA;AAAA,EAEK;AAAA,EAEpB,mBAAA,EAAqB,EAAA,GAAK,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AAM,EAAA;AAAA,MACN,OAAA,EAAS,UAAA;AAAA,MACT,MAAA,EAAQ;AAAA,KACV;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,eAAA,CAAgB,KAAA,EAAe,MAAA,EAAmC;AACtE,IAAA,IAAI,UAAU,EAAA,EAAI;AAChB,MAAA,MAAM,IAAI,MAAM,+BAA+B,CAAA;AAAA,IACjD;AAGA,IAAA,OAAO;AAAA,MACL,IAAA,EAAM,EAAA;AAAA,MACN,OAAA,EAAS,UAAA;AAAA,MACT,MAAA,EAAQ;AAAA,KACV;AAAA,EACF;AACF","file":"index.js","sourcesContent":["// Contract addresses for Zubari ecosystem\nexport interface ContractAddresses {\n registry: string;\n nft: string;\n marketplace: string;\n tips: string;\n subscriptions: string;\n payouts: string;\n entryPoint: string;\n paymaster: string;\n accountFactory: string;\n usdt: string;\n weth: string;\n}\n\n// Placeholder addresses - will be updated after deployment\nconst ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';\n\nexport const ZUBARI_CONTRACTS: Record<'testnet' | 'mainnet', ContractAddresses> = {\n testnet: {\n // Ethereum Sepolia (11155111) - Deployed 2024-12-09\n registry: '0xEdDf443D48832f23D4A0bED4C4c5eF200B38A7d3',\n nft: '0xdc37e25650D685e4c38124aC314477Ea5f508a9e',\n marketplace: ZERO_ADDRESS, // Not yet deployed\n tips: '0xFDc353edC63Cd3D4bba35bB43861369516a9Dc85',\n subscriptions: '0x8C05F8aD2F295fB7f3596043a7c37C98A5F7fAB8',\n payouts: '0x804Fe503936E8b8d3D5Dbb62AF4fB6Fe7265Fb2c',\n entryPoint: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789',\n paymaster: ZERO_ADDRESS, // Not yet deployed\n accountFactory: ZERO_ADDRESS, // Not yet deployed\n usdt: '0xaA8E23Fb1079EA71e0a56F48a2aA51851D8433D0', // USDT on Sepolia\n weth: '0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14',\n },\n mainnet: {\n // Ethereum Mainnet (1)\n registry: ZERO_ADDRESS,\n nft: ZERO_ADDRESS,\n marketplace: ZERO_ADDRESS,\n tips: ZERO_ADDRESS,\n subscriptions: ZERO_ADDRESS,\n payouts: ZERO_ADDRESS,\n entryPoint: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789',\n paymaster: ZERO_ADDRESS,\n accountFactory: ZERO_ADDRESS,\n usdt: '0xdAC17F958D2ee523a2206206994597C13D831ec7', // USDT on Ethereum\n weth: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',\n },\n};\n\n// Platform configuration\nexport const PLATFORM_CONFIG = {\n // Platform fee in basis points (300 = 3%)\n tipFeeBps: 300,\n // Maximum royalty in basis points (1000 = 10%)\n maxRoyaltyBps: 1000,\n // Default slippage tolerance for swaps (50 = 0.5%)\n defaultSlippageBps: 50,\n // Voucher validity in seconds (30 days)\n voucherValiditySecs: 30 * 24 * 60 * 60,\n // Swap deadline in seconds (30 minutes)\n swapDeadlineSecs: 30 * 60,\n} as const;\n\n// EIP-712 Domain for lazy minting\nexport const NFT_VOUCHER_DOMAIN = {\n name: 'ZubariNFT',\n version: '1',\n} as const;\n\nexport const NFT_VOUCHER_TYPES = {\n NFTVoucher: [\n { name: 'tokenId', type: 'bytes32' },\n { name: 'uri', type: 'string' },\n { name: 'creator', type: 'address' },\n { name: 'royaltyBps', type: 'uint256' },\n { name: 'deadline', type: 'uint256' },\n ],\n} as const;\n\nexport function getContractAddresses(network: 'testnet' | 'mainnet'): ContractAddresses {\n return ZUBARI_CONTRACTS[network];\n}\n","import type {\n NFTMetadata,\n LazyMintVoucher,\n NFT,\n ListingParams,\n TxResult,\n} from '../types';\nimport { PLATFORM_CONFIG, NFT_VOUCHER_DOMAIN, NFT_VOUCHER_TYPES } from '../config/contracts';\n\n/**\n * ZubariNFTProtocol - NFT creation and marketplace operations\n *\n * Handles lazy minting via EIP-712 signatures, NFT listing,\n * and marketplace operations on Ethereum network.\n */\nexport class ZubariNFTProtocol {\n private readonly contractAddress: string;\n private readonly _marketplaceAddress: string;\n private readonly chainId: number;\n\n constructor(\n contractAddress: string,\n marketplaceAddress: string,\n chainId: number\n ) {\n this.contractAddress = contractAddress;\n this._marketplaceAddress = marketplaceAddress;\n this.chainId = chainId;\n }\n\n /**\n * Create a lazy mint voucher for off-chain NFT creation\n * The voucher can be redeemed on-chain when purchased\n */\n async createLazyMintVoucher(\n metadata: NFTMetadata,\n creatorAddress: string,\n signer: { signTypedData: (domain: object, types: object, value: object) => Promise<string> }\n ): Promise<LazyMintVoucher> {\n // Validate royalty\n if (metadata.royaltyBps > PLATFORM_CONFIG.maxRoyaltyBps) {\n throw new Error(`Royalty cannot exceed ${PLATFORM_CONFIG.maxRoyaltyBps / 100}%`);\n }\n\n // Generate random tokenId\n const tokenId = this.generateTokenId();\n\n // Calculate deadline (30 days from now)\n const deadline = Math.floor(Date.now() / 1000) + PLATFORM_CONFIG.voucherValiditySecs;\n\n // Build voucher data\n const voucherData = {\n tokenId,\n uri: metadata.image, // Will be IPFS URI\n creator: creatorAddress,\n royaltyBps: metadata.royaltyBps,\n deadline,\n };\n\n // Create EIP-712 domain\n const domain = {\n ...NFT_VOUCHER_DOMAIN,\n chainId: this.chainId,\n verifyingContract: this.contractAddress,\n };\n\n // Sign the voucher\n const signature = await signer.signTypedData(domain, NFT_VOUCHER_TYPES, voucherData);\n\n return {\n ...voucherData,\n signature,\n };\n }\n\n /**\n * Redeem a lazy mint voucher to mint the NFT on-chain\n */\n async redeemVoucher(voucher: LazyMintVoucher, _buyerAddress: string): Promise<TxResult> {\n // Validate voucher deadline\n if (voucher.deadline < Math.floor(Date.now() / 1000)) {\n throw new Error('Voucher has expired');\n }\n\n // Placeholder - will call contract\n return {\n hash: '',\n network: 'ethereum',\n status: 'pending',\n };\n }\n\n /**\n * List an NFT for sale on the marketplace\n */\n async listForSale(_params: ListingParams): Promise<TxResult> {\n // Placeholder - will approve and list\n return {\n hash: '',\n network: 'ethereum',\n status: 'pending',\n };\n }\n\n /**\n * Buy an NFT from the marketplace\n */\n async buyNFT(_listingId: string, _price: bigint): Promise<TxResult> {\n // Placeholder - will call marketplace contract\n return {\n hash: '',\n network: 'ethereum',\n status: 'pending',\n };\n }\n\n /**\n * Transfer an NFT to another address\n */\n async transfer(_tokenId: string, _to: string): Promise<TxResult> {\n // Placeholder - will call NFT contract\n return {\n hash: '',\n network: 'ethereum',\n status: 'pending',\n };\n }\n\n /**\n * Get NFTs owned by an address\n */\n async getOwnedNFTs(_address: string): Promise<NFT[]> {\n // Placeholder - will query contract/indexer\n return [];\n }\n\n /**\n * Generate a random tokenId (32 bytes hex)\n */\n private generateTokenId(): string {\n const bytes = new Uint8Array(32);\n crypto.getRandomValues(bytes);\n return '0x' + Array.from(bytes).map(b => b.toString(16).padStart(2, '0')).join('');\n }\n}\n","import type { TipData, TipResult, TipStats, TxResult } from '../types';\nimport { PLATFORM_CONFIG } from '../config/contracts';\n\n/**\n * ZubariTipsProtocol - Micropayment tips for creators\n *\n * Handles ETH and ERC-20 token tips with platform fee distribution.\n * Supports gasless tips via ERC-4337 when enabled.\n */\nexport class ZubariTipsProtocol {\n private readonly contractAddress: string;\n private readonly chainId: number;\n private readonly gaslessEnabled: boolean;\n\n constructor(contractAddress: string, chainId: number, gaslessEnabled: boolean = false) {\n this.contractAddress = contractAddress;\n this.chainId = chainId;\n this.gaslessEnabled = gaslessEnabled;\n }\n\n /**\n * Send a tip to a creator\n */\n async sendTip(tip: TipData): Promise<TipResult> {\n const { recipient, amount, token, message } = tip;\n\n // Calculate platform fee (3%)\n const platformFee = (amount * BigInt(PLATFORM_CONFIG.tipFeeBps)) / BigInt(10000);\n const creatorAmount = amount - platformFee;\n\n // Validate amount\n if (amount <= 0n) {\n throw new Error('Tip amount must be greater than 0');\n }\n\n // Placeholder - will call contract\n const txResult: TxResult = {\n hash: '',\n network: 'ethereum',\n status: 'pending',\n };\n\n return {\n txHash: txResult.hash,\n tipId: '', // Will be returned from contract event\n recipient,\n amount: creatorAmount,\n platformFee,\n timestamp: Math.floor(Date.now() / 1000),\n };\n }\n\n /**\n * Send tips to multiple creators in a single transaction\n */\n async sendBatchTips(tips: TipData[]): Promise<TipResult[]> {\n if (tips.length === 0) {\n throw new Error('At least one tip is required');\n }\n\n // Calculate total amount needed\n const totalAmount = tips.reduce((sum, tip) => sum + tip.amount, BigInt(0));\n\n // Placeholder - will call batch function\n return tips.map(tip => ({\n txHash: '',\n tipId: '',\n recipient: tip.recipient,\n amount: tip.amount - (tip.amount * BigInt(PLATFORM_CONFIG.tipFeeBps)) / BigInt(10000),\n platformFee: (tip.amount * BigInt(PLATFORM_CONFIG.tipFeeBps)) / BigInt(10000),\n timestamp: Math.floor(Date.now() / 1000),\n }));\n }\n\n /**\n * Get tips received by an address\n */\n async getTipsReceived(address: string): Promise<TipResult[]> {\n // Placeholder - will query indexer\n return [];\n }\n\n /**\n * Get tips sent by an address\n */\n async getTipsSent(address: string): Promise<TipResult[]> {\n // Placeholder - will query indexer\n return [];\n }\n\n /**\n * Get tip statistics for a creator\n */\n async getCreatorTipStats(creator: string): Promise<TipStats> {\n // Placeholder - will query indexer/contract\n return {\n totalReceived: BigInt(0),\n tipCount: 0,\n uniqueTippers: 0,\n };\n }\n\n /**\n * Get platform fee in basis points\n */\n getPlatformFeeBps(): number {\n return PLATFORM_CONFIG.tipFeeBps;\n }\n}\n","import type { SubscriptionPlan, Subscription, TxResult } from '../types';\n\n/**\n * ZubariSubscriptionProtocol - Recurring subscription payments\n *\n * Handles subscription plan creation, subscription management,\n * and verification of active subscriptions.\n */\nexport class ZubariSubscriptionProtocol {\n private readonly contractAddress: string;\n private readonly chainId: number;\n\n constructor(contractAddress: string, chainId: number) {\n this.contractAddress = contractAddress;\n this.chainId = chainId;\n }\n\n /**\n * Create a new subscription plan\n */\n async createPlan(plan: SubscriptionPlan): Promise<string> {\n // Validate plan\n if (!plan.name || plan.name.length === 0) {\n throw new Error('Plan name is required');\n }\n if (plan.price <= 0n) {\n throw new Error('Plan price must be greater than 0');\n }\n if (plan.duration <= 0) {\n throw new Error('Plan duration must be greater than 0');\n }\n\n // Generate planId based on creator + name hash\n const planId = this.generatePlanId(plan.name);\n\n // Placeholder - will call contract\n return planId;\n }\n\n /**\n * Update an existing subscription plan\n */\n async updatePlan(planId: string, updates: Partial<SubscriptionPlan>): Promise<TxResult> {\n // Placeholder - will call contract\n return {\n hash: '',\n network: 'ethereum',\n status: 'pending',\n };\n }\n\n /**\n * Subscribe to a creator's plan\n */\n async subscribe(\n creator: string,\n planId: string,\n months: number = 1\n ): Promise<Subscription> {\n if (months <= 0) {\n throw new Error('Subscription duration must be at least 1 month');\n }\n\n const now = Math.floor(Date.now() / 1000);\n const durationSeconds = months * 30 * 24 * 60 * 60; // 30 days per month\n\n // Placeholder - will call contract\n return {\n subscriptionId: '',\n planId,\n creator,\n subscriber: '', // Current user address\n startTime: now,\n endTime: now + durationSeconds,\n autoRenew: false,\n status: 'active',\n };\n }\n\n /**\n * Cancel an active subscription\n */\n async cancel(subscriptionId: string): Promise<TxResult> {\n // Placeholder - will call contract\n return {\n hash: '',\n network: 'ethereum',\n status: 'pending',\n };\n }\n\n /**\n * Check if an address is subscribed to a creator\n */\n async isSubscribed(creator: string, subscriber?: string): Promise<boolean> {\n // Placeholder - will call contract view function\n return false;\n }\n\n /**\n * Get active subscriptions for a subscriber\n */\n async getActiveSubscriptions(subscriber?: string): Promise<Subscription[]> {\n // Placeholder - will query contract/indexer\n return [];\n }\n\n /**\n * Get all subscribers for a creator\n */\n async getSubscribers(creator: string): Promise<Subscription[]> {\n // Placeholder - will query contract/indexer\n return [];\n }\n\n /**\n * Get a specific plan by ID\n */\n async getPlan(planId: string): Promise<SubscriptionPlan | null> {\n // Placeholder - will query contract\n return null;\n }\n\n /**\n * Get all plans for a creator\n */\n async getCreatorPlans(creator: string): Promise<SubscriptionPlan[]> {\n // Placeholder - will query contract/indexer\n return [];\n }\n\n /**\n * Generate a unique plan ID\n */\n private generatePlanId(name: string): string {\n const bytes = new Uint8Array(16);\n crypto.getRandomValues(bytes);\n return '0x' + Array.from(bytes).map(b => b.toString(16).padStart(2, '0')).join('');\n }\n}\n","import type { EarningsBreakdown, RevenueSplit, TxResult } from '../types';\n\n/**\n * ZubariPayoutsProtocol - Creator earnings management\n *\n * Handles earnings tracking, claiming, revenue splits,\n * and conversion to stablecoins.\n */\nexport class ZubariPayoutsProtocol {\n private readonly contractAddress: string;\n private readonly chainId: number;\n\n constructor(contractAddress: string, chainId: number) {\n this.contractAddress = contractAddress;\n this.chainId = chainId;\n }\n\n /**\n * Get pending earnings breakdown for the current user\n */\n async getPendingEarnings(): Promise<EarningsBreakdown> {\n // Placeholder - will call contract\n return {\n tips: BigInt(0),\n subscriptions: BigInt(0),\n nftSales: BigInt(0),\n royalties: BigInt(0),\n total: BigInt(0),\n };\n }\n\n /**\n * Get historical earnings for a time period\n */\n async getEarningsHistory(\n period: 'day' | 'week' | 'month' | 'all' = 'all'\n ): Promise<EarningsBreakdown[]> {\n // Placeholder - will query indexer\n return [];\n }\n\n /**\n * Claim all pending earnings\n */\n async claimEarnings(): Promise<TxResult> {\n // Placeholder - will call contract\n return {\n hash: '',\n network: 'ethereum',\n status: 'pending',\n };\n }\n\n /**\n * Claim specific amount of earnings\n */\n async claimPartialEarnings(amount: bigint): Promise<TxResult> {\n if (amount <= 0n) {\n throw new Error('Amount must be greater than 0');\n }\n\n // Placeholder - will call contract\n return {\n hash: '',\n network: 'ethereum',\n status: 'pending',\n };\n }\n\n /**\n * Setup revenue split with collaborators\n * Basis points must sum to 10000 (100%)\n */\n async setupRevenueSplit(splits: RevenueSplit[]): Promise<TxResult> {\n // Validate that basis points sum to 100%\n const totalBps = splits.reduce((sum, split) => sum + split.basisPoints, 0);\n if (totalBps !== 10000) {\n throw new Error('Revenue splits must sum to 100% (10000 basis points)');\n }\n\n // Validate each split\n for (const split of splits) {\n if (split.basisPoints <= 0) {\n throw new Error('Each split must have positive basis points');\n }\n if (!split.recipient || split.recipient.length === 0) {\n throw new Error('Each split must have a valid recipient address');\n }\n }\n\n // Placeholder - will call contract\n return {\n hash: '',\n network: 'ethereum',\n status: 'pending',\n };\n }\n\n /**\n * Get current revenue split configuration\n */\n async getRevenueSplit(): Promise<RevenueSplit[]> {\n // Placeholder - will query contract\n return [];\n }\n\n /**\n * Remove revenue split (creator gets 100%)\n */\n async removeRevenueSplit(): Promise<TxResult> {\n // Placeholder - will call contract\n return {\n hash: '',\n network: 'ethereum',\n status: 'pending',\n };\n }\n\n /**\n * Convert earnings to stablecoin (USDT)\n */\n async convertToStable(token: string, amount: bigint): Promise<TxResult> {\n if (amount <= 0n) {\n throw new Error('Amount must be greater than 0');\n }\n\n // Placeholder - will use swap protocol\n return {\n hash: '',\n network: 'ethereum',\n status: 'pending',\n };\n }\n}\n"]}