@campnetwork/origin 1.2.3 → 1.2.5
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/README.md +2 -0
- package/dist/core.cjs +97 -76
- package/dist/core.d.ts +29 -9
- package/dist/core.esm.d.ts +29 -9
- package/dist/core.esm.js +92 -71
- package/dist/react/index.esm.d.ts +29 -9
- package/dist/react/index.esm.js +190 -27
- package/package.json +1 -1
package/dist/core.d.ts
CHANGED
|
@@ -331,26 +331,28 @@ interface TransactionResult {
|
|
|
331
331
|
receipt?: any;
|
|
332
332
|
}
|
|
333
333
|
/**
|
|
334
|
-
*
|
|
334
|
+
* EXPERIMENTAL METHOD
|
|
335
|
+
* Settles a payment intent response by purchasing access if needed.
|
|
335
336
|
* This method checks if the user already has access to the item, and if not,
|
|
336
|
-
* it calls buyAccess with the parameters from the
|
|
337
|
+
* it calls buyAccess with the parameters from the payment intent response.
|
|
337
338
|
* Supports viem WalletClient, ethers Signer, and custom signer implementations.
|
|
338
339
|
*
|
|
339
|
-
* @param
|
|
340
|
+
* @param paymentIntentResponse - The response from getDataWithIntent containing payment details.
|
|
340
341
|
* @param signer - Optional signer object used to interact with the blockchain. If not provided, uses the connected wallet client.
|
|
341
342
|
* @returns A promise that resolves with the transaction hash and receipt, or null if access already exists.
|
|
342
343
|
* @throws {Error} If the response doesn't contain marketplace action or if the method is not buyAccess.
|
|
343
344
|
*/
|
|
344
|
-
declare function
|
|
345
|
+
declare function settlePaymentIntent(this: Origin, paymentIntentResponse: X402Response, signer?: any): Promise<TransactionResult | null>;
|
|
345
346
|
|
|
346
347
|
/**
|
|
348
|
+
* EXPERIMENTAL METHOD
|
|
347
349
|
* Fetch data with X402 payment handling.
|
|
348
350
|
* @param {bigint} tokenId The token ID to fetch data for.
|
|
349
351
|
* @param {any} [signer] Optional signer object for signing the X402 intent.
|
|
350
352
|
* @returns {Promise<any>} A promise that resolves with the fetched data.
|
|
351
353
|
* @throws {Error} Throws an error if the data cannot be fetched or if no signer/wallet client is provided.
|
|
352
354
|
*/
|
|
353
|
-
declare function
|
|
355
|
+
declare function getDataWithIntent(this: Origin, tokenId: bigint, signer?: any, decide?: (terms: any) => Promise<boolean>): Promise<any>;
|
|
354
356
|
|
|
355
357
|
interface RoyaltyInfo {
|
|
356
358
|
tokenBoundAccount: Address;
|
|
@@ -365,7 +367,7 @@ type CallOptions = {
|
|
|
365
367
|
};
|
|
366
368
|
/**
|
|
367
369
|
* The Origin class
|
|
368
|
-
* Handles
|
|
370
|
+
* Handles interactions with Origin protocol.
|
|
369
371
|
*/
|
|
370
372
|
declare class Origin {
|
|
371
373
|
#private;
|
|
@@ -387,18 +389,36 @@ declare class Origin {
|
|
|
387
389
|
buyAccess: typeof buyAccess;
|
|
388
390
|
hasAccess: typeof hasAccess;
|
|
389
391
|
subscriptionExpiry: typeof subscriptionExpiry;
|
|
390
|
-
|
|
391
|
-
|
|
392
|
+
settlePaymentIntent: typeof settlePaymentIntent;
|
|
393
|
+
getDataWithIntent: typeof getDataWithIntent;
|
|
392
394
|
private jwt?;
|
|
393
395
|
environment: Environment;
|
|
394
396
|
private viemClient?;
|
|
395
397
|
baseParentId?: bigint;
|
|
396
|
-
constructor(environment
|
|
398
|
+
constructor(environment?: Environment | string, jwt?: string, viemClient?: WalletClient, baseParentId?: bigint);
|
|
397
399
|
getJwt(): string | undefined;
|
|
398
400
|
setViemClient(client: WalletClient): void;
|
|
401
|
+
/**
|
|
402
|
+
* Mints a file-based IpNFT.
|
|
403
|
+
* @param file The file to mint.
|
|
404
|
+
* @param metadata The metadata associated with the file.
|
|
405
|
+
* @param license The license terms for the IpNFT.
|
|
406
|
+
* @param parents Optional parent token IDs for lineage tracking.
|
|
407
|
+
* @param options Optional parameters including progress callback, preview image, and use asset as preview flag.
|
|
408
|
+
* @returns The token ID of the minted IpNFT as a string, or null if minting failed.
|
|
409
|
+
*/
|
|
399
410
|
mintFile(file: File, metadata: Record<string, unknown>, license: LicenseTerms, parents?: bigint[], options?: {
|
|
400
411
|
progressCallback?: (percent: number) => void;
|
|
412
|
+
previewImage?: File | null;
|
|
413
|
+
useAssetAsPreview?: boolean;
|
|
401
414
|
}): Promise<string | null>;
|
|
415
|
+
/**
|
|
416
|
+
* Mints a social IpNFT.
|
|
417
|
+
* @param source The social media source (spotify, twitter, tiktok).
|
|
418
|
+
* @param metadata The metadata associated with the social media content.
|
|
419
|
+
* @param license The license terms for the IpNFT.
|
|
420
|
+
* @return The token ID of the minted IpNFT as a string, or null if minting failed.
|
|
421
|
+
*/
|
|
402
422
|
mintSocial(source: "spotify" | "twitter" | "tiktok", metadata: Record<string, unknown>, license: LicenseTerms): Promise<string | null>;
|
|
403
423
|
/**
|
|
404
424
|
* Call a contract method.
|
package/dist/core.esm.d.ts
CHANGED
|
@@ -331,26 +331,28 @@ interface TransactionResult {
|
|
|
331
331
|
receipt?: any;
|
|
332
332
|
}
|
|
333
333
|
/**
|
|
334
|
-
*
|
|
334
|
+
* EXPERIMENTAL METHOD
|
|
335
|
+
* Settles a payment intent response by purchasing access if needed.
|
|
335
336
|
* This method checks if the user already has access to the item, and if not,
|
|
336
|
-
* it calls buyAccess with the parameters from the
|
|
337
|
+
* it calls buyAccess with the parameters from the payment intent response.
|
|
337
338
|
* Supports viem WalletClient, ethers Signer, and custom signer implementations.
|
|
338
339
|
*
|
|
339
|
-
* @param
|
|
340
|
+
* @param paymentIntentResponse - The response from getDataWithIntent containing payment details.
|
|
340
341
|
* @param signer - Optional signer object used to interact with the blockchain. If not provided, uses the connected wallet client.
|
|
341
342
|
* @returns A promise that resolves with the transaction hash and receipt, or null if access already exists.
|
|
342
343
|
* @throws {Error} If the response doesn't contain marketplace action or if the method is not buyAccess.
|
|
343
344
|
*/
|
|
344
|
-
declare function
|
|
345
|
+
declare function settlePaymentIntent(this: Origin, paymentIntentResponse: X402Response, signer?: any): Promise<TransactionResult | null>;
|
|
345
346
|
|
|
346
347
|
/**
|
|
348
|
+
* EXPERIMENTAL METHOD
|
|
347
349
|
* Fetch data with X402 payment handling.
|
|
348
350
|
* @param {bigint} tokenId The token ID to fetch data for.
|
|
349
351
|
* @param {any} [signer] Optional signer object for signing the X402 intent.
|
|
350
352
|
* @returns {Promise<any>} A promise that resolves with the fetched data.
|
|
351
353
|
* @throws {Error} Throws an error if the data cannot be fetched or if no signer/wallet client is provided.
|
|
352
354
|
*/
|
|
353
|
-
declare function
|
|
355
|
+
declare function getDataWithIntent(this: Origin, tokenId: bigint, signer?: any, decide?: (terms: any) => Promise<boolean>): Promise<any>;
|
|
354
356
|
|
|
355
357
|
interface RoyaltyInfo {
|
|
356
358
|
tokenBoundAccount: Address;
|
|
@@ -365,7 +367,7 @@ type CallOptions = {
|
|
|
365
367
|
};
|
|
366
368
|
/**
|
|
367
369
|
* The Origin class
|
|
368
|
-
* Handles
|
|
370
|
+
* Handles interactions with Origin protocol.
|
|
369
371
|
*/
|
|
370
372
|
declare class Origin {
|
|
371
373
|
#private;
|
|
@@ -387,18 +389,36 @@ declare class Origin {
|
|
|
387
389
|
buyAccess: typeof buyAccess;
|
|
388
390
|
hasAccess: typeof hasAccess;
|
|
389
391
|
subscriptionExpiry: typeof subscriptionExpiry;
|
|
390
|
-
|
|
391
|
-
|
|
392
|
+
settlePaymentIntent: typeof settlePaymentIntent;
|
|
393
|
+
getDataWithIntent: typeof getDataWithIntent;
|
|
392
394
|
private jwt?;
|
|
393
395
|
environment: Environment;
|
|
394
396
|
private viemClient?;
|
|
395
397
|
baseParentId?: bigint;
|
|
396
|
-
constructor(environment
|
|
398
|
+
constructor(environment?: Environment | string, jwt?: string, viemClient?: WalletClient, baseParentId?: bigint);
|
|
397
399
|
getJwt(): string | undefined;
|
|
398
400
|
setViemClient(client: WalletClient): void;
|
|
401
|
+
/**
|
|
402
|
+
* Mints a file-based IpNFT.
|
|
403
|
+
* @param file The file to mint.
|
|
404
|
+
* @param metadata The metadata associated with the file.
|
|
405
|
+
* @param license The license terms for the IpNFT.
|
|
406
|
+
* @param parents Optional parent token IDs for lineage tracking.
|
|
407
|
+
* @param options Optional parameters including progress callback, preview image, and use asset as preview flag.
|
|
408
|
+
* @returns The token ID of the minted IpNFT as a string, or null if minting failed.
|
|
409
|
+
*/
|
|
399
410
|
mintFile(file: File, metadata: Record<string, unknown>, license: LicenseTerms, parents?: bigint[], options?: {
|
|
400
411
|
progressCallback?: (percent: number) => void;
|
|
412
|
+
previewImage?: File | null;
|
|
413
|
+
useAssetAsPreview?: boolean;
|
|
401
414
|
}): Promise<string | null>;
|
|
415
|
+
/**
|
|
416
|
+
* Mints a social IpNFT.
|
|
417
|
+
* @param source The social media source (spotify, twitter, tiktok).
|
|
418
|
+
* @param metadata The metadata associated with the social media content.
|
|
419
|
+
* @param license The license terms for the IpNFT.
|
|
420
|
+
* @return The token ID of the minted IpNFT as a string, or null if minting failed.
|
|
421
|
+
*/
|
|
402
422
|
mintSocial(source: "spotify" | "twitter" | "tiktok", metadata: Record<string, unknown>, license: LicenseTerms): Promise<string | null>;
|
|
403
423
|
/**
|
|
404
424
|
* Call a contract method.
|