@campnetwork/origin 1.2.6 → 1.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.
@@ -9,10 +9,12 @@ interface Environment {
9
9
  ORIGIN_DASHBOARD: string;
10
10
  DATANFT_CONTRACT_ADDRESS: string;
11
11
  MARKETPLACE_CONTRACT_ADDRESS: string;
12
+ BATCH_PURCHASE_CONTRACT_ADDRESS: string;
12
13
  CHAIN: any;
13
14
  IPNFT_ABI?: any;
14
15
  MARKETPLACE_ABI?: any;
15
16
  TBA_ABI?: any;
17
+ BATCH_PURCHASE_ABI?: any;
16
18
  }
17
19
 
18
20
  /**
@@ -215,6 +217,125 @@ declare function settlePaymentIntent(this: Origin, paymentIntentResponse: X402Re
215
217
  */
216
218
  declare function getDataWithIntent(this: Origin, tokenId: bigint, signer?: any, decide?: (terms: any) => Promise<boolean>): Promise<any>;
217
219
 
220
+ /**
221
+ * Parameters for a single purchase in a bulk buy operation.
222
+ */
223
+ interface BuyParams {
224
+ tokenId: bigint;
225
+ expectedPrice: bigint;
226
+ expectedDuration: number;
227
+ expectedPaymentToken: Address;
228
+ }
229
+ /**
230
+ * Preview of bulk purchase costs.
231
+ */
232
+ interface BulkCostPreview {
233
+ totalNativeCost: bigint;
234
+ totalERC20Cost: bigint;
235
+ validCount: bigint;
236
+ invalidTokenIds: bigint[];
237
+ }
238
+ /**
239
+ * Executes an atomic bulk purchase of multiple IP-NFT licenses.
240
+ * All purchases succeed or all fail together.
241
+ *
242
+ * @param buyer The address that will receive the licenses.
243
+ * @param purchases Array of purchase parameters for each token.
244
+ * @param value Total native token value to send (sum of all native token purchases).
245
+ * @returns A promise that resolves with the transaction result.
246
+ *
247
+ * @example
248
+ * ```typescript
249
+ * const purchases = [
250
+ * { tokenId: 1n, expectedPrice: 1000000000000000n, expectedDuration: 86400, expectedPaymentToken: zeroAddress },
251
+ * { tokenId: 2n, expectedPrice: 2000000000000000n, expectedDuration: 86400, expectedPaymentToken: zeroAddress },
252
+ * ];
253
+ * const totalValue = 3000000000000000n;
254
+ * await origin.bulkBuyAccess(buyerAddress, purchases, totalValue);
255
+ * ```
256
+ */
257
+ declare function bulkBuyAccess(this: Origin, buyer: Address, purchases: BuyParams[], value?: bigint): Promise<any>;
258
+ /**
259
+ * Executes a fault-tolerant bulk purchase of multiple IP-NFT licenses.
260
+ * Individual purchases can fail without reverting the entire transaction.
261
+ * Unused funds are automatically refunded.
262
+ *
263
+ * @param buyer The address that will receive the licenses.
264
+ * @param purchases Array of purchase parameters for each token.
265
+ * @param value Total native token value to send (can be more than needed; excess is refunded).
266
+ * @returns A promise that resolves with the tolerant result including success/failure counts.
267
+ *
268
+ * @example
269
+ * ```typescript
270
+ * const result = await origin.bulkBuyAccessTolerant(buyerAddress, purchases, totalValue);
271
+ * console.log(`Purchased ${result.successCount} of ${purchases.length} IPs`);
272
+ * console.log(`Failed tokens: ${result.failedTokenIds}`);
273
+ * ```
274
+ */
275
+ declare function bulkBuyAccessTolerant(this: Origin, buyer: Address, purchases: BuyParams[], value?: bigint): Promise<any>;
276
+ /**
277
+ * Previews the total cost of purchasing multiple IP-NFT licenses.
278
+ * This is a view function that doesn't require a transaction.
279
+ *
280
+ * @param tokenIds Array of token IDs to preview costs for.
281
+ * @returns A promise that resolves with the cost preview including total costs and invalid tokens.
282
+ *
283
+ * @example
284
+ * ```typescript
285
+ * const preview = await origin.previewBulkCost([1n, 2n, 3n]);
286
+ * console.log(`Total cost: ${preview.totalNativeCost} wei`);
287
+ * console.log(`Valid tokens: ${preview.validCount}`);
288
+ * ```
289
+ */
290
+ declare function previewBulkCost(this: Origin, tokenIds: bigint[]): Promise<BulkCostPreview>;
291
+ /**
292
+ * Builds purchase parameters for multiple tokens by fetching their current license terms.
293
+ * This is a view function that doesn't require a transaction.
294
+ *
295
+ * @param tokenIds Array of token IDs to build parameters for.
296
+ * @returns A promise that resolves with an array of BuyParams ready for bulk purchase.
297
+ *
298
+ * @example
299
+ * ```typescript
300
+ * const params = await origin.buildPurchaseParams([1n, 2n, 3n]);
301
+ * await origin.bulkBuyAccess(buyer, params, totalValue);
302
+ * ```
303
+ */
304
+ declare function buildPurchaseParams(this: Origin, tokenIds: bigint[]): Promise<BuyParams[]>;
305
+ /**
306
+ * Checks the active status of multiple tokens.
307
+ *
308
+ * @param tokenIds Array of token IDs to check.
309
+ * @returns A promise that resolves with an array of boolean flags indicating active status.
310
+ *
311
+ * @example
312
+ * ```typescript
313
+ * const activeFlags = await origin.checkActiveStatus([1n, 2n, 3n]);
314
+ * const activeTokens = tokenIds.filter((_, i) => activeFlags[i]);
315
+ * ```
316
+ */
317
+ declare function checkActiveStatus(this: Origin, tokenIds: bigint[]): Promise<boolean[]>;
318
+ /**
319
+ * Smart bulk purchase that automatically fetches terms and handles the entire purchase flow.
320
+ * This is the recommended method for most use cases.
321
+ *
322
+ * @param tokenIds Array of token IDs to purchase.
323
+ * @param options Optional configuration for the purchase.
324
+ * @returns A promise that resolves with the transaction result.
325
+ *
326
+ * @example
327
+ * ```typescript
328
+ * // Atomic purchase - all succeed or all fail
329
+ * const result = await origin.bulkBuyAccessSmart([1n, 2n, 3n]);
330
+ *
331
+ * // Tolerant purchase - continue even if some fail
332
+ * const result = await origin.bulkBuyAccessSmart([1n, 2n, 3n], { tolerant: true });
333
+ * ```
334
+ */
335
+ declare function bulkBuyAccessSmart(this: Origin, tokenIds: bigint[], options?: {
336
+ tolerant?: boolean;
337
+ }): Promise<any>;
338
+
218
339
  interface RoyaltyInfo {
219
340
  tokenBoundAccount: Address;
220
341
  balance: bigint;
@@ -252,6 +373,12 @@ declare class Origin {
252
373
  subscriptionExpiry: typeof subscriptionExpiry;
253
374
  settlePaymentIntent: typeof settlePaymentIntent;
254
375
  getDataWithIntent: typeof getDataWithIntent;
376
+ bulkBuyAccess: typeof bulkBuyAccess;
377
+ bulkBuyAccessTolerant: typeof bulkBuyAccessTolerant;
378
+ bulkBuyAccessSmart: typeof bulkBuyAccessSmart;
379
+ previewBulkCost: typeof previewBulkCost;
380
+ buildPurchaseParams: typeof buildPurchaseParams;
381
+ checkActiveStatus: typeof checkActiveStatus;
255
382
  private jwt?;
256
383
  environment: Environment;
257
384
  private viemClient?;