@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.
- package/dist/core.cjs +185 -79
- package/dist/core.d.ts +138 -1
- package/dist/core.esm.d.ts +138 -1
- package/dist/core.esm.js +189 -83
- package/dist/react/index.esm.d.ts +127 -0
- package/dist/react/index.esm.js +550 -0
- package/package.json +1 -1
package/dist/core.d.ts
CHANGED
|
@@ -138,10 +138,12 @@ interface Environment {
|
|
|
138
138
|
ORIGIN_DASHBOARD: string;
|
|
139
139
|
DATANFT_CONTRACT_ADDRESS: string;
|
|
140
140
|
MARKETPLACE_CONTRACT_ADDRESS: string;
|
|
141
|
+
BATCH_PURCHASE_CONTRACT_ADDRESS: string;
|
|
141
142
|
CHAIN: any;
|
|
142
143
|
IPNFT_ABI?: any;
|
|
143
144
|
MARKETPLACE_ABI?: any;
|
|
144
145
|
TBA_ABI?: any;
|
|
146
|
+
BATCH_PURCHASE_ABI?: any;
|
|
145
147
|
}
|
|
146
148
|
|
|
147
149
|
/**
|
|
@@ -353,6 +355,135 @@ declare function settlePaymentIntent(this: Origin, paymentIntentResponse: X402Re
|
|
|
353
355
|
*/
|
|
354
356
|
declare function getDataWithIntent(this: Origin, tokenId: bigint, signer?: any, decide?: (terms: any) => Promise<boolean>): Promise<any>;
|
|
355
357
|
|
|
358
|
+
/**
|
|
359
|
+
* Parameters for a single purchase in a bulk buy operation.
|
|
360
|
+
*/
|
|
361
|
+
interface BuyParams {
|
|
362
|
+
tokenId: bigint;
|
|
363
|
+
expectedPrice: bigint;
|
|
364
|
+
expectedDuration: number;
|
|
365
|
+
expectedPaymentToken: Address;
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Result of a tolerant bulk purchase operation.
|
|
369
|
+
*/
|
|
370
|
+
interface TolerantResult {
|
|
371
|
+
successCount: bigint;
|
|
372
|
+
failureCount: bigint;
|
|
373
|
+
totalSpent: bigint;
|
|
374
|
+
refundAmount: bigint;
|
|
375
|
+
failedTokenIds: bigint[];
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Preview of bulk purchase costs.
|
|
379
|
+
*/
|
|
380
|
+
interface BulkCostPreview {
|
|
381
|
+
totalNativeCost: bigint;
|
|
382
|
+
totalERC20Cost: bigint;
|
|
383
|
+
validCount: bigint;
|
|
384
|
+
invalidTokenIds: bigint[];
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Executes an atomic bulk purchase of multiple IP-NFT licenses.
|
|
388
|
+
* All purchases succeed or all fail together.
|
|
389
|
+
*
|
|
390
|
+
* @param buyer The address that will receive the licenses.
|
|
391
|
+
* @param purchases Array of purchase parameters for each token.
|
|
392
|
+
* @param value Total native token value to send (sum of all native token purchases).
|
|
393
|
+
* @returns A promise that resolves with the transaction result.
|
|
394
|
+
*
|
|
395
|
+
* @example
|
|
396
|
+
* ```typescript
|
|
397
|
+
* const purchases = [
|
|
398
|
+
* { tokenId: 1n, expectedPrice: 1000000000000000n, expectedDuration: 86400, expectedPaymentToken: zeroAddress },
|
|
399
|
+
* { tokenId: 2n, expectedPrice: 2000000000000000n, expectedDuration: 86400, expectedPaymentToken: zeroAddress },
|
|
400
|
+
* ];
|
|
401
|
+
* const totalValue = 3000000000000000n;
|
|
402
|
+
* await origin.bulkBuyAccess(buyerAddress, purchases, totalValue);
|
|
403
|
+
* ```
|
|
404
|
+
*/
|
|
405
|
+
declare function bulkBuyAccess(this: Origin, buyer: Address, purchases: BuyParams[], value?: bigint): Promise<any>;
|
|
406
|
+
/**
|
|
407
|
+
* Executes a fault-tolerant bulk purchase of multiple IP-NFT licenses.
|
|
408
|
+
* Individual purchases can fail without reverting the entire transaction.
|
|
409
|
+
* Unused funds are automatically refunded.
|
|
410
|
+
*
|
|
411
|
+
* @param buyer The address that will receive the licenses.
|
|
412
|
+
* @param purchases Array of purchase parameters for each token.
|
|
413
|
+
* @param value Total native token value to send (can be more than needed; excess is refunded).
|
|
414
|
+
* @returns A promise that resolves with the tolerant result including success/failure counts.
|
|
415
|
+
*
|
|
416
|
+
* @example
|
|
417
|
+
* ```typescript
|
|
418
|
+
* const result = await origin.bulkBuyAccessTolerant(buyerAddress, purchases, totalValue);
|
|
419
|
+
* console.log(`Purchased ${result.successCount} of ${purchases.length} IPs`);
|
|
420
|
+
* console.log(`Failed tokens: ${result.failedTokenIds}`);
|
|
421
|
+
* ```
|
|
422
|
+
*/
|
|
423
|
+
declare function bulkBuyAccessTolerant(this: Origin, buyer: Address, purchases: BuyParams[], value?: bigint): Promise<any>;
|
|
424
|
+
/**
|
|
425
|
+
* Previews the total cost of purchasing multiple IP-NFT licenses.
|
|
426
|
+
* This is a view function that doesn't require a transaction.
|
|
427
|
+
*
|
|
428
|
+
* @param tokenIds Array of token IDs to preview costs for.
|
|
429
|
+
* @returns A promise that resolves with the cost preview including total costs and invalid tokens.
|
|
430
|
+
*
|
|
431
|
+
* @example
|
|
432
|
+
* ```typescript
|
|
433
|
+
* const preview = await origin.previewBulkCost([1n, 2n, 3n]);
|
|
434
|
+
* console.log(`Total cost: ${preview.totalNativeCost} wei`);
|
|
435
|
+
* console.log(`Valid tokens: ${preview.validCount}`);
|
|
436
|
+
* ```
|
|
437
|
+
*/
|
|
438
|
+
declare function previewBulkCost(this: Origin, tokenIds: bigint[]): Promise<BulkCostPreview>;
|
|
439
|
+
/**
|
|
440
|
+
* Builds purchase parameters for multiple tokens by fetching their current license terms.
|
|
441
|
+
* This is a view function that doesn't require a transaction.
|
|
442
|
+
*
|
|
443
|
+
* @param tokenIds Array of token IDs to build parameters for.
|
|
444
|
+
* @returns A promise that resolves with an array of BuyParams ready for bulk purchase.
|
|
445
|
+
*
|
|
446
|
+
* @example
|
|
447
|
+
* ```typescript
|
|
448
|
+
* const params = await origin.buildPurchaseParams([1n, 2n, 3n]);
|
|
449
|
+
* await origin.bulkBuyAccess(buyer, params, totalValue);
|
|
450
|
+
* ```
|
|
451
|
+
*/
|
|
452
|
+
declare function buildPurchaseParams(this: Origin, tokenIds: bigint[]): Promise<BuyParams[]>;
|
|
453
|
+
/**
|
|
454
|
+
* Checks the active status of multiple tokens.
|
|
455
|
+
*
|
|
456
|
+
* @param tokenIds Array of token IDs to check.
|
|
457
|
+
* @returns A promise that resolves with an array of boolean flags indicating active status.
|
|
458
|
+
*
|
|
459
|
+
* @example
|
|
460
|
+
* ```typescript
|
|
461
|
+
* const activeFlags = await origin.checkActiveStatus([1n, 2n, 3n]);
|
|
462
|
+
* const activeTokens = tokenIds.filter((_, i) => activeFlags[i]);
|
|
463
|
+
* ```
|
|
464
|
+
*/
|
|
465
|
+
declare function checkActiveStatus(this: Origin, tokenIds: bigint[]): Promise<boolean[]>;
|
|
466
|
+
/**
|
|
467
|
+
* Smart bulk purchase that automatically fetches terms and handles the entire purchase flow.
|
|
468
|
+
* This is the recommended method for most use cases.
|
|
469
|
+
*
|
|
470
|
+
* @param tokenIds Array of token IDs to purchase.
|
|
471
|
+
* @param options Optional configuration for the purchase.
|
|
472
|
+
* @returns A promise that resolves with the transaction result.
|
|
473
|
+
*
|
|
474
|
+
* @example
|
|
475
|
+
* ```typescript
|
|
476
|
+
* // Atomic purchase - all succeed or all fail
|
|
477
|
+
* const result = await origin.bulkBuyAccessSmart([1n, 2n, 3n]);
|
|
478
|
+
*
|
|
479
|
+
* // Tolerant purchase - continue even if some fail
|
|
480
|
+
* const result = await origin.bulkBuyAccessSmart([1n, 2n, 3n], { tolerant: true });
|
|
481
|
+
* ```
|
|
482
|
+
*/
|
|
483
|
+
declare function bulkBuyAccessSmart(this: Origin, tokenIds: bigint[], options?: {
|
|
484
|
+
tolerant?: boolean;
|
|
485
|
+
}): Promise<any>;
|
|
486
|
+
|
|
356
487
|
interface RoyaltyInfo {
|
|
357
488
|
tokenBoundAccount: Address;
|
|
358
489
|
balance: bigint;
|
|
@@ -390,6 +521,12 @@ declare class Origin {
|
|
|
390
521
|
subscriptionExpiry: typeof subscriptionExpiry;
|
|
391
522
|
settlePaymentIntent: typeof settlePaymentIntent;
|
|
392
523
|
getDataWithIntent: typeof getDataWithIntent;
|
|
524
|
+
bulkBuyAccess: typeof bulkBuyAccess;
|
|
525
|
+
bulkBuyAccessTolerant: typeof bulkBuyAccessTolerant;
|
|
526
|
+
bulkBuyAccessSmart: typeof bulkBuyAccessSmart;
|
|
527
|
+
previewBulkCost: typeof previewBulkCost;
|
|
528
|
+
buildPurchaseParams: typeof buildPurchaseParams;
|
|
529
|
+
checkActiveStatus: typeof checkActiveStatus;
|
|
393
530
|
private jwt?;
|
|
394
531
|
environment: Environment;
|
|
395
532
|
private viemClient?;
|
|
@@ -704,4 +841,4 @@ declare class Auth {
|
|
|
704
841
|
unlinkTelegram(): Promise<any>;
|
|
705
842
|
}
|
|
706
843
|
|
|
707
|
-
export { Auth, type BaseSigner, BrowserStorage, CustomSignerAdapter, DataStatus, EthersSignerAdapter, type LicenseTerms, MemoryStorage, Origin, type SignerAdapter, type SignerType, type StorageAdapter, ViemSignerAdapter, mainnet as campMainnet, testnet as campTestnet, createLicenseTerms, createNodeWalletClient, createSignerAdapter };
|
|
844
|
+
export { Auth, type BaseSigner, BrowserStorage, type BulkCostPreview, type BuyParams, CustomSignerAdapter, DataStatus, EthersSignerAdapter, type LicenseTerms, MemoryStorage, Origin, type SignerAdapter, type SignerType, type StorageAdapter, type TolerantResult, ViemSignerAdapter, mainnet as campMainnet, testnet as campTestnet, createLicenseTerms, createNodeWalletClient, createSignerAdapter };
|
package/dist/core.esm.d.ts
CHANGED
|
@@ -138,10 +138,12 @@ interface Environment {
|
|
|
138
138
|
ORIGIN_DASHBOARD: string;
|
|
139
139
|
DATANFT_CONTRACT_ADDRESS: string;
|
|
140
140
|
MARKETPLACE_CONTRACT_ADDRESS: string;
|
|
141
|
+
BATCH_PURCHASE_CONTRACT_ADDRESS: string;
|
|
141
142
|
CHAIN: any;
|
|
142
143
|
IPNFT_ABI?: any;
|
|
143
144
|
MARKETPLACE_ABI?: any;
|
|
144
145
|
TBA_ABI?: any;
|
|
146
|
+
BATCH_PURCHASE_ABI?: any;
|
|
145
147
|
}
|
|
146
148
|
|
|
147
149
|
/**
|
|
@@ -353,6 +355,135 @@ declare function settlePaymentIntent(this: Origin, paymentIntentResponse: X402Re
|
|
|
353
355
|
*/
|
|
354
356
|
declare function getDataWithIntent(this: Origin, tokenId: bigint, signer?: any, decide?: (terms: any) => Promise<boolean>): Promise<any>;
|
|
355
357
|
|
|
358
|
+
/**
|
|
359
|
+
* Parameters for a single purchase in a bulk buy operation.
|
|
360
|
+
*/
|
|
361
|
+
interface BuyParams {
|
|
362
|
+
tokenId: bigint;
|
|
363
|
+
expectedPrice: bigint;
|
|
364
|
+
expectedDuration: number;
|
|
365
|
+
expectedPaymentToken: Address;
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Result of a tolerant bulk purchase operation.
|
|
369
|
+
*/
|
|
370
|
+
interface TolerantResult {
|
|
371
|
+
successCount: bigint;
|
|
372
|
+
failureCount: bigint;
|
|
373
|
+
totalSpent: bigint;
|
|
374
|
+
refundAmount: bigint;
|
|
375
|
+
failedTokenIds: bigint[];
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Preview of bulk purchase costs.
|
|
379
|
+
*/
|
|
380
|
+
interface BulkCostPreview {
|
|
381
|
+
totalNativeCost: bigint;
|
|
382
|
+
totalERC20Cost: bigint;
|
|
383
|
+
validCount: bigint;
|
|
384
|
+
invalidTokenIds: bigint[];
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Executes an atomic bulk purchase of multiple IP-NFT licenses.
|
|
388
|
+
* All purchases succeed or all fail together.
|
|
389
|
+
*
|
|
390
|
+
* @param buyer The address that will receive the licenses.
|
|
391
|
+
* @param purchases Array of purchase parameters for each token.
|
|
392
|
+
* @param value Total native token value to send (sum of all native token purchases).
|
|
393
|
+
* @returns A promise that resolves with the transaction result.
|
|
394
|
+
*
|
|
395
|
+
* @example
|
|
396
|
+
* ```typescript
|
|
397
|
+
* const purchases = [
|
|
398
|
+
* { tokenId: 1n, expectedPrice: 1000000000000000n, expectedDuration: 86400, expectedPaymentToken: zeroAddress },
|
|
399
|
+
* { tokenId: 2n, expectedPrice: 2000000000000000n, expectedDuration: 86400, expectedPaymentToken: zeroAddress },
|
|
400
|
+
* ];
|
|
401
|
+
* const totalValue = 3000000000000000n;
|
|
402
|
+
* await origin.bulkBuyAccess(buyerAddress, purchases, totalValue);
|
|
403
|
+
* ```
|
|
404
|
+
*/
|
|
405
|
+
declare function bulkBuyAccess(this: Origin, buyer: Address, purchases: BuyParams[], value?: bigint): Promise<any>;
|
|
406
|
+
/**
|
|
407
|
+
* Executes a fault-tolerant bulk purchase of multiple IP-NFT licenses.
|
|
408
|
+
* Individual purchases can fail without reverting the entire transaction.
|
|
409
|
+
* Unused funds are automatically refunded.
|
|
410
|
+
*
|
|
411
|
+
* @param buyer The address that will receive the licenses.
|
|
412
|
+
* @param purchases Array of purchase parameters for each token.
|
|
413
|
+
* @param value Total native token value to send (can be more than needed; excess is refunded).
|
|
414
|
+
* @returns A promise that resolves with the tolerant result including success/failure counts.
|
|
415
|
+
*
|
|
416
|
+
* @example
|
|
417
|
+
* ```typescript
|
|
418
|
+
* const result = await origin.bulkBuyAccessTolerant(buyerAddress, purchases, totalValue);
|
|
419
|
+
* console.log(`Purchased ${result.successCount} of ${purchases.length} IPs`);
|
|
420
|
+
* console.log(`Failed tokens: ${result.failedTokenIds}`);
|
|
421
|
+
* ```
|
|
422
|
+
*/
|
|
423
|
+
declare function bulkBuyAccessTolerant(this: Origin, buyer: Address, purchases: BuyParams[], value?: bigint): Promise<any>;
|
|
424
|
+
/**
|
|
425
|
+
* Previews the total cost of purchasing multiple IP-NFT licenses.
|
|
426
|
+
* This is a view function that doesn't require a transaction.
|
|
427
|
+
*
|
|
428
|
+
* @param tokenIds Array of token IDs to preview costs for.
|
|
429
|
+
* @returns A promise that resolves with the cost preview including total costs and invalid tokens.
|
|
430
|
+
*
|
|
431
|
+
* @example
|
|
432
|
+
* ```typescript
|
|
433
|
+
* const preview = await origin.previewBulkCost([1n, 2n, 3n]);
|
|
434
|
+
* console.log(`Total cost: ${preview.totalNativeCost} wei`);
|
|
435
|
+
* console.log(`Valid tokens: ${preview.validCount}`);
|
|
436
|
+
* ```
|
|
437
|
+
*/
|
|
438
|
+
declare function previewBulkCost(this: Origin, tokenIds: bigint[]): Promise<BulkCostPreview>;
|
|
439
|
+
/**
|
|
440
|
+
* Builds purchase parameters for multiple tokens by fetching their current license terms.
|
|
441
|
+
* This is a view function that doesn't require a transaction.
|
|
442
|
+
*
|
|
443
|
+
* @param tokenIds Array of token IDs to build parameters for.
|
|
444
|
+
* @returns A promise that resolves with an array of BuyParams ready for bulk purchase.
|
|
445
|
+
*
|
|
446
|
+
* @example
|
|
447
|
+
* ```typescript
|
|
448
|
+
* const params = await origin.buildPurchaseParams([1n, 2n, 3n]);
|
|
449
|
+
* await origin.bulkBuyAccess(buyer, params, totalValue);
|
|
450
|
+
* ```
|
|
451
|
+
*/
|
|
452
|
+
declare function buildPurchaseParams(this: Origin, tokenIds: bigint[]): Promise<BuyParams[]>;
|
|
453
|
+
/**
|
|
454
|
+
* Checks the active status of multiple tokens.
|
|
455
|
+
*
|
|
456
|
+
* @param tokenIds Array of token IDs to check.
|
|
457
|
+
* @returns A promise that resolves with an array of boolean flags indicating active status.
|
|
458
|
+
*
|
|
459
|
+
* @example
|
|
460
|
+
* ```typescript
|
|
461
|
+
* const activeFlags = await origin.checkActiveStatus([1n, 2n, 3n]);
|
|
462
|
+
* const activeTokens = tokenIds.filter((_, i) => activeFlags[i]);
|
|
463
|
+
* ```
|
|
464
|
+
*/
|
|
465
|
+
declare function checkActiveStatus(this: Origin, tokenIds: bigint[]): Promise<boolean[]>;
|
|
466
|
+
/**
|
|
467
|
+
* Smart bulk purchase that automatically fetches terms and handles the entire purchase flow.
|
|
468
|
+
* This is the recommended method for most use cases.
|
|
469
|
+
*
|
|
470
|
+
* @param tokenIds Array of token IDs to purchase.
|
|
471
|
+
* @param options Optional configuration for the purchase.
|
|
472
|
+
* @returns A promise that resolves with the transaction result.
|
|
473
|
+
*
|
|
474
|
+
* @example
|
|
475
|
+
* ```typescript
|
|
476
|
+
* // Atomic purchase - all succeed or all fail
|
|
477
|
+
* const result = await origin.bulkBuyAccessSmart([1n, 2n, 3n]);
|
|
478
|
+
*
|
|
479
|
+
* // Tolerant purchase - continue even if some fail
|
|
480
|
+
* const result = await origin.bulkBuyAccessSmart([1n, 2n, 3n], { tolerant: true });
|
|
481
|
+
* ```
|
|
482
|
+
*/
|
|
483
|
+
declare function bulkBuyAccessSmart(this: Origin, tokenIds: bigint[], options?: {
|
|
484
|
+
tolerant?: boolean;
|
|
485
|
+
}): Promise<any>;
|
|
486
|
+
|
|
356
487
|
interface RoyaltyInfo {
|
|
357
488
|
tokenBoundAccount: Address;
|
|
358
489
|
balance: bigint;
|
|
@@ -390,6 +521,12 @@ declare class Origin {
|
|
|
390
521
|
subscriptionExpiry: typeof subscriptionExpiry;
|
|
391
522
|
settlePaymentIntent: typeof settlePaymentIntent;
|
|
392
523
|
getDataWithIntent: typeof getDataWithIntent;
|
|
524
|
+
bulkBuyAccess: typeof bulkBuyAccess;
|
|
525
|
+
bulkBuyAccessTolerant: typeof bulkBuyAccessTolerant;
|
|
526
|
+
bulkBuyAccessSmart: typeof bulkBuyAccessSmart;
|
|
527
|
+
previewBulkCost: typeof previewBulkCost;
|
|
528
|
+
buildPurchaseParams: typeof buildPurchaseParams;
|
|
529
|
+
checkActiveStatus: typeof checkActiveStatus;
|
|
393
530
|
private jwt?;
|
|
394
531
|
environment: Environment;
|
|
395
532
|
private viemClient?;
|
|
@@ -704,4 +841,4 @@ declare class Auth {
|
|
|
704
841
|
unlinkTelegram(): Promise<any>;
|
|
705
842
|
}
|
|
706
843
|
|
|
707
|
-
export { Auth, type BaseSigner, BrowserStorage, CustomSignerAdapter, DataStatus, EthersSignerAdapter, type LicenseTerms, MemoryStorage, Origin, type SignerAdapter, type SignerType, type StorageAdapter, ViemSignerAdapter, mainnet as campMainnet, testnet as campTestnet, createLicenseTerms, createNodeWalletClient, createSignerAdapter };
|
|
844
|
+
export { Auth, type BaseSigner, BrowserStorage, type BulkCostPreview, type BuyParams, CustomSignerAdapter, DataStatus, EthersSignerAdapter, type LicenseTerms, MemoryStorage, Origin, type SignerAdapter, type SignerType, type StorageAdapter, type TolerantResult, ViemSignerAdapter, mainnet as campMainnet, testnet as campTestnet, createLicenseTerms, createNodeWalletClient, createSignerAdapter };
|