@campnetwork/origin 1.3.0-alpha.6 → 1.3.0-alpha.8

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.d.ts CHANGED
@@ -459,9 +459,13 @@ interface RaiseDisputeSmartResult {
459
459
  }
460
460
  /**
461
461
  * Raises a dispute with automatic evidence upload to IPFS.
462
- * Uploads evidence JSON to IPFS, hashes the CID to bytes32 for on-chain storage,
462
+ * Uploads evidence JSON to IPFS, encodes the CID to bytes32 for on-chain storage,
463
463
  * and calls raiseDispute.
464
464
  *
465
+ * The CID is encoded by stripping the 0x1220 multihash prefix from CIDv0,
466
+ * leaving only the 32-byte SHA-256 digest. This encoding is reversible,
467
+ * allowing the original CID to be reconstructed from the on-chain data.
468
+ *
465
469
  * @param targetIpId The token ID of the IP NFT to dispute.
466
470
  * @param evidence The evidence JSON object to upload to IPFS.
467
471
  * @param disputeTag A tag identifying the type of dispute.
@@ -475,17 +479,25 @@ interface RaiseDisputeSmartResult {
475
479
  * "0x696e6672696e67656d656e74..." // dispute tag
476
480
  * );
477
481
  *
478
- * // Store the CID for evidence retrieval
482
+ * // The CID can be recovered from evidenceHash using decodeCidFromBytes32
479
483
  * console.log("Evidence CID:", result.evidenceCid);
480
484
  *
481
- * // Fetch evidence later via IPFS gateway
485
+ * // Fetch evidence via IPFS gateway
482
486
  * // https://ipfs.io/ipfs/{result.evidenceCid}
483
- *
484
- * // Verify evidence hash matches on-chain: keccak256(toHex(evidenceCid)) === evidenceHash
485
487
  * ```
486
488
  */
487
489
  declare function raiseDisputeSmart(this: Origin, targetIpId: bigint, evidence: Record<string, any>, disputeTag: Hex): Promise<RaiseDisputeSmartResult>;
488
490
 
491
+ /**
492
+ * Encode CIDv0 to bytes32 by stripping the 0x1220 multihash prefix.
493
+ * Only works with CIDv0 (SHA-256 hash, starts with "Qm").
494
+ */
495
+ declare function encodeCidToBytes32(cid: string): Hex;
496
+ /**
497
+ * Decode bytes32 back to CIDv0 by prepending 0x1220 multihash prefix.
498
+ */
499
+ declare function decodeCidFromBytes32(bytes32: Hex): string;
500
+
489
501
  /**
490
502
  * Asserts a dispute as the IP owner with counter-evidence.
491
503
  * Must be called by the owner of the disputed IP within the cooldown period.
@@ -501,6 +513,42 @@ declare function raiseDisputeSmart(this: Origin, targetIpId: bigint, evidence: R
501
513
  */
502
514
  declare function disputeAssertion(this: Origin, disputeId: bigint, counterEvidenceHash: Hex): Promise<any>;
503
515
 
516
+ interface DisputeAssertionSmartResult {
517
+ transactionResult: any;
518
+ counterEvidenceCid: string;
519
+ counterEvidenceHash: Hex;
520
+ }
521
+ /**
522
+ * Asserts a dispute with automatic counter-evidence upload to IPFS.
523
+ * Uploads counter-evidence JSON to IPFS, encodes the CID to bytes32 for on-chain storage,
524
+ * and calls disputeAssertion.
525
+ *
526
+ * The CID is encoded by stripping the 0x1220 multihash prefix from CIDv0,
527
+ * leaving only the 32-byte SHA-256 digest. This encoding is reversible,
528
+ * allowing the original CID to be reconstructed from the on-chain data.
529
+ *
530
+ * Must be called by the owner of the disputed IP within the cooldown period.
531
+ *
532
+ * @param disputeId The ID of the dispute to assert.
533
+ * @param counterEvidence The counter-evidence JSON object to upload to IPFS.
534
+ * @returns A promise that resolves with the transaction result, IPFS CID, and counter-evidence hash.
535
+ *
536
+ * @example
537
+ * ```typescript
538
+ * const result = await origin.disputeAssertionSmart(
539
+ * 1n,
540
+ * { description: "This is my original work", proofUrl: "https://..." }
541
+ * );
542
+ *
543
+ * // The CID can be recovered from counterEvidenceHash using decodeCidFromBytes32
544
+ * console.log("Counter-evidence CID:", result.counterEvidenceCid);
545
+ *
546
+ * // Fetch counter-evidence via IPFS gateway
547
+ * // https://ipfs.io/ipfs/{result.counterEvidenceCid}
548
+ * ```
549
+ */
550
+ declare function disputeAssertionSmart(this: Origin, disputeId: bigint, counterEvidence: Record<string, any>): Promise<DisputeAssertionSmartResult>;
551
+
504
552
  /**
505
553
  * Votes on a dispute as a CAMP token staker.
506
554
  * Only users who staked before the dispute was raised can vote.
@@ -1076,6 +1124,7 @@ declare class Origin {
1076
1124
  raiseDispute: typeof raiseDispute;
1077
1125
  raiseDisputeSmart: typeof raiseDisputeSmart;
1078
1126
  disputeAssertion: typeof disputeAssertion;
1127
+ disputeAssertionSmart: typeof disputeAssertionSmart;
1079
1128
  voteOnDispute: typeof voteOnDispute;
1080
1129
  resolveDispute: typeof resolveDispute;
1081
1130
  cancelDispute: typeof cancelDispute;
@@ -1454,4 +1503,4 @@ declare class Auth {
1454
1503
  unlinkTelegram(): Promise<any>;
1455
1504
  }
1456
1505
 
1457
- export { type AppInfo, Auth, type BaseSigner, BrowserStorage, type BulkCostPreview, type BuyParams, CustomSignerAdapter, DataStatus, type Dispute, type DisputeProgress, DisputeStatus, EthersSignerAdapter, type FractionOwnership, type FractionalizeEligibility, type LicenseTerms, LicenseType, MemoryStorage, Origin, type SignerAdapter, type SignerType, type StorageAdapter, type TokenInfo, type TolerantResult, ViemSignerAdapter, type VoteEligibility, mainnet as campMainnet, testnet as campTestnet, createLicenseTerms, createNodeWalletClient, createSignerAdapter };
1506
+ export { type AppInfo, Auth, type BaseSigner, BrowserStorage, type BulkCostPreview, type BuyParams, CustomSignerAdapter, DataStatus, type Dispute, type DisputeProgress, DisputeStatus, EthersSignerAdapter, type FractionOwnership, type FractionalizeEligibility, type LicenseTerms, LicenseType, MemoryStorage, Origin, type SignerAdapter, type SignerType, type StorageAdapter, type TokenInfo, type TolerantResult, ViemSignerAdapter, type VoteEligibility, mainnet as campMainnet, testnet as campTestnet, createLicenseTerms, createNodeWalletClient, createSignerAdapter, decodeCidFromBytes32, encodeCidToBytes32 };
@@ -459,9 +459,13 @@ interface RaiseDisputeSmartResult {
459
459
  }
460
460
  /**
461
461
  * Raises a dispute with automatic evidence upload to IPFS.
462
- * Uploads evidence JSON to IPFS, hashes the CID to bytes32 for on-chain storage,
462
+ * Uploads evidence JSON to IPFS, encodes the CID to bytes32 for on-chain storage,
463
463
  * and calls raiseDispute.
464
464
  *
465
+ * The CID is encoded by stripping the 0x1220 multihash prefix from CIDv0,
466
+ * leaving only the 32-byte SHA-256 digest. This encoding is reversible,
467
+ * allowing the original CID to be reconstructed from the on-chain data.
468
+ *
465
469
  * @param targetIpId The token ID of the IP NFT to dispute.
466
470
  * @param evidence The evidence JSON object to upload to IPFS.
467
471
  * @param disputeTag A tag identifying the type of dispute.
@@ -475,17 +479,25 @@ interface RaiseDisputeSmartResult {
475
479
  * "0x696e6672696e67656d656e74..." // dispute tag
476
480
  * );
477
481
  *
478
- * // Store the CID for evidence retrieval
482
+ * // The CID can be recovered from evidenceHash using decodeCidFromBytes32
479
483
  * console.log("Evidence CID:", result.evidenceCid);
480
484
  *
481
- * // Fetch evidence later via IPFS gateway
485
+ * // Fetch evidence via IPFS gateway
482
486
  * // https://ipfs.io/ipfs/{result.evidenceCid}
483
- *
484
- * // Verify evidence hash matches on-chain: keccak256(toHex(evidenceCid)) === evidenceHash
485
487
  * ```
486
488
  */
487
489
  declare function raiseDisputeSmart(this: Origin, targetIpId: bigint, evidence: Record<string, any>, disputeTag: Hex): Promise<RaiseDisputeSmartResult>;
488
490
 
491
+ /**
492
+ * Encode CIDv0 to bytes32 by stripping the 0x1220 multihash prefix.
493
+ * Only works with CIDv0 (SHA-256 hash, starts with "Qm").
494
+ */
495
+ declare function encodeCidToBytes32(cid: string): Hex;
496
+ /**
497
+ * Decode bytes32 back to CIDv0 by prepending 0x1220 multihash prefix.
498
+ */
499
+ declare function decodeCidFromBytes32(bytes32: Hex): string;
500
+
489
501
  /**
490
502
  * Asserts a dispute as the IP owner with counter-evidence.
491
503
  * Must be called by the owner of the disputed IP within the cooldown period.
@@ -501,6 +513,42 @@ declare function raiseDisputeSmart(this: Origin, targetIpId: bigint, evidence: R
501
513
  */
502
514
  declare function disputeAssertion(this: Origin, disputeId: bigint, counterEvidenceHash: Hex): Promise<any>;
503
515
 
516
+ interface DisputeAssertionSmartResult {
517
+ transactionResult: any;
518
+ counterEvidenceCid: string;
519
+ counterEvidenceHash: Hex;
520
+ }
521
+ /**
522
+ * Asserts a dispute with automatic counter-evidence upload to IPFS.
523
+ * Uploads counter-evidence JSON to IPFS, encodes the CID to bytes32 for on-chain storage,
524
+ * and calls disputeAssertion.
525
+ *
526
+ * The CID is encoded by stripping the 0x1220 multihash prefix from CIDv0,
527
+ * leaving only the 32-byte SHA-256 digest. This encoding is reversible,
528
+ * allowing the original CID to be reconstructed from the on-chain data.
529
+ *
530
+ * Must be called by the owner of the disputed IP within the cooldown period.
531
+ *
532
+ * @param disputeId The ID of the dispute to assert.
533
+ * @param counterEvidence The counter-evidence JSON object to upload to IPFS.
534
+ * @returns A promise that resolves with the transaction result, IPFS CID, and counter-evidence hash.
535
+ *
536
+ * @example
537
+ * ```typescript
538
+ * const result = await origin.disputeAssertionSmart(
539
+ * 1n,
540
+ * { description: "This is my original work", proofUrl: "https://..." }
541
+ * );
542
+ *
543
+ * // The CID can be recovered from counterEvidenceHash using decodeCidFromBytes32
544
+ * console.log("Counter-evidence CID:", result.counterEvidenceCid);
545
+ *
546
+ * // Fetch counter-evidence via IPFS gateway
547
+ * // https://ipfs.io/ipfs/{result.counterEvidenceCid}
548
+ * ```
549
+ */
550
+ declare function disputeAssertionSmart(this: Origin, disputeId: bigint, counterEvidence: Record<string, any>): Promise<DisputeAssertionSmartResult>;
551
+
504
552
  /**
505
553
  * Votes on a dispute as a CAMP token staker.
506
554
  * Only users who staked before the dispute was raised can vote.
@@ -1076,6 +1124,7 @@ declare class Origin {
1076
1124
  raiseDispute: typeof raiseDispute;
1077
1125
  raiseDisputeSmart: typeof raiseDisputeSmart;
1078
1126
  disputeAssertion: typeof disputeAssertion;
1127
+ disputeAssertionSmart: typeof disputeAssertionSmart;
1079
1128
  voteOnDispute: typeof voteOnDispute;
1080
1129
  resolveDispute: typeof resolveDispute;
1081
1130
  cancelDispute: typeof cancelDispute;
@@ -1454,4 +1503,4 @@ declare class Auth {
1454
1503
  unlinkTelegram(): Promise<any>;
1455
1504
  }
1456
1505
 
1457
- export { type AppInfo, Auth, type BaseSigner, BrowserStorage, type BulkCostPreview, type BuyParams, CustomSignerAdapter, DataStatus, type Dispute, type DisputeProgress, DisputeStatus, EthersSignerAdapter, type FractionOwnership, type FractionalizeEligibility, type LicenseTerms, LicenseType, MemoryStorage, Origin, type SignerAdapter, type SignerType, type StorageAdapter, type TokenInfo, type TolerantResult, ViemSignerAdapter, type VoteEligibility, mainnet as campMainnet, testnet as campTestnet, createLicenseTerms, createNodeWalletClient, createSignerAdapter };
1506
+ export { type AppInfo, Auth, type BaseSigner, BrowserStorage, type BulkCostPreview, type BuyParams, CustomSignerAdapter, DataStatus, type Dispute, type DisputeProgress, DisputeStatus, EthersSignerAdapter, type FractionOwnership, type FractionalizeEligibility, type LicenseTerms, LicenseType, MemoryStorage, Origin, type SignerAdapter, type SignerType, type StorageAdapter, type TokenInfo, type TolerantResult, ViemSignerAdapter, type VoteEligibility, mainnet as campMainnet, testnet as campTestnet, createLicenseTerms, createNodeWalletClient, createSignerAdapter, decodeCidFromBytes32, encodeCidToBytes32 };