@campnetwork/origin 1.3.0-alpha.5 → 1.3.0-alpha.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 +169 -78
- package/dist/core.d.ts +70 -5
- package/dist/core.esm.d.ts +70 -5
- package/dist/core.esm.js +231 -140
- package/dist/react/index.esm.d.ts +70 -5
- package/dist/react/index.esm.js +258 -7
- package/package.json +2 -1
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,
|
|
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,13 +479,11 @@ interface RaiseDisputeSmartResult {
|
|
|
475
479
|
* "0x696e6672696e67656d656e74..." // dispute tag
|
|
476
480
|
* );
|
|
477
481
|
*
|
|
478
|
-
* //
|
|
482
|
+
* // The CID can be recovered from evidenceHash using decodeCidFromBytes32
|
|
479
483
|
* console.log("Evidence CID:", result.evidenceCid);
|
|
480
484
|
*
|
|
481
|
-
* // Fetch evidence
|
|
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>;
|
|
@@ -501,6 +503,42 @@ declare function raiseDisputeSmart(this: Origin, targetIpId: bigint, evidence: R
|
|
|
501
503
|
*/
|
|
502
504
|
declare function disputeAssertion(this: Origin, disputeId: bigint, counterEvidenceHash: Hex): Promise<any>;
|
|
503
505
|
|
|
506
|
+
interface DisputeAssertionSmartResult {
|
|
507
|
+
transactionResult: any;
|
|
508
|
+
counterEvidenceCid: string;
|
|
509
|
+
counterEvidenceHash: Hex;
|
|
510
|
+
}
|
|
511
|
+
/**
|
|
512
|
+
* Asserts a dispute with automatic counter-evidence upload to IPFS.
|
|
513
|
+
* Uploads counter-evidence JSON to IPFS, encodes the CID to bytes32 for on-chain storage,
|
|
514
|
+
* and calls disputeAssertion.
|
|
515
|
+
*
|
|
516
|
+
* The CID is encoded by stripping the 0x1220 multihash prefix from CIDv0,
|
|
517
|
+
* leaving only the 32-byte SHA-256 digest. This encoding is reversible,
|
|
518
|
+
* allowing the original CID to be reconstructed from the on-chain data.
|
|
519
|
+
*
|
|
520
|
+
* Must be called by the owner of the disputed IP within the cooldown period.
|
|
521
|
+
*
|
|
522
|
+
* @param disputeId The ID of the dispute to assert.
|
|
523
|
+
* @param counterEvidence The counter-evidence JSON object to upload to IPFS.
|
|
524
|
+
* @returns A promise that resolves with the transaction result, IPFS CID, and counter-evidence hash.
|
|
525
|
+
*
|
|
526
|
+
* @example
|
|
527
|
+
* ```typescript
|
|
528
|
+
* const result = await origin.disputeAssertionSmart(
|
|
529
|
+
* 1n,
|
|
530
|
+
* { description: "This is my original work", proofUrl: "https://..." }
|
|
531
|
+
* );
|
|
532
|
+
*
|
|
533
|
+
* // The CID can be recovered from counterEvidenceHash using decodeCidFromBytes32
|
|
534
|
+
* console.log("Counter-evidence CID:", result.counterEvidenceCid);
|
|
535
|
+
*
|
|
536
|
+
* // Fetch counter-evidence via IPFS gateway
|
|
537
|
+
* // https://ipfs.io/ipfs/{result.counterEvidenceCid}
|
|
538
|
+
* ```
|
|
539
|
+
*/
|
|
540
|
+
declare function disputeAssertionSmart(this: Origin, disputeId: bigint, counterEvidence: Record<string, any>): Promise<DisputeAssertionSmartResult>;
|
|
541
|
+
|
|
504
542
|
/**
|
|
505
543
|
* Votes on a dispute as a CAMP token staker.
|
|
506
544
|
* Only users who staked before the dispute was raised can vote.
|
|
@@ -680,6 +718,31 @@ interface DisputeProgress {
|
|
|
680
718
|
*/
|
|
681
719
|
declare function getDisputeProgress(this: Origin, disputeId: bigint): Promise<DisputeProgress>;
|
|
682
720
|
|
|
721
|
+
interface DisputeRequirements {
|
|
722
|
+
bondAmount: bigint;
|
|
723
|
+
protocolFee: bigint;
|
|
724
|
+
totalRequired: bigint;
|
|
725
|
+
tokenAddress: Address;
|
|
726
|
+
isNativeToken: boolean;
|
|
727
|
+
userBalance: bigint;
|
|
728
|
+
hasSufficientBalance: boolean;
|
|
729
|
+
}
|
|
730
|
+
/**
|
|
731
|
+
* Gets the requirements for raising a dispute, including balance check.
|
|
732
|
+
*
|
|
733
|
+
* @param userAddress The address to check balance for.
|
|
734
|
+
* @returns A promise that resolves with the dispute requirements.
|
|
735
|
+
*
|
|
736
|
+
* @example
|
|
737
|
+
* ```typescript
|
|
738
|
+
* const requirements = await origin.getDisputeRequirements(walletAddress);
|
|
739
|
+
* if (!requirements.hasSufficientBalance) {
|
|
740
|
+
* console.log(`Need ${requirements.totalRequired} but only have ${requirements.userBalance}`);
|
|
741
|
+
* }
|
|
742
|
+
* ```
|
|
743
|
+
*/
|
|
744
|
+
declare function getDisputeRequirements(this: Origin, userAddress: Address): Promise<DisputeRequirements>;
|
|
745
|
+
|
|
683
746
|
/**
|
|
684
747
|
* Fractionalizes an IP NFT into fungible ERC20 tokens.
|
|
685
748
|
* The NFT is transferred to the fractionalizer contract and a new ERC20 token is created.
|
|
@@ -1051,6 +1114,7 @@ declare class Origin {
|
|
|
1051
1114
|
raiseDispute: typeof raiseDispute;
|
|
1052
1115
|
raiseDisputeSmart: typeof raiseDisputeSmart;
|
|
1053
1116
|
disputeAssertion: typeof disputeAssertion;
|
|
1117
|
+
disputeAssertionSmart: typeof disputeAssertionSmart;
|
|
1054
1118
|
voteOnDispute: typeof voteOnDispute;
|
|
1055
1119
|
resolveDispute: typeof resolveDispute;
|
|
1056
1120
|
cancelDispute: typeof cancelDispute;
|
|
@@ -1058,6 +1122,7 @@ declare class Origin {
|
|
|
1058
1122
|
getDispute: typeof getDispute;
|
|
1059
1123
|
canVoteOnDispute: typeof canVoteOnDispute;
|
|
1060
1124
|
getDisputeProgress: typeof getDisputeProgress;
|
|
1125
|
+
getDisputeRequirements: typeof getDisputeRequirements;
|
|
1061
1126
|
fractionalize: typeof fractionalize;
|
|
1062
1127
|
redeem: typeof redeem;
|
|
1063
1128
|
getTokenForNFT: typeof getTokenForNFT;
|
package/dist/core.esm.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,
|
|
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,13 +479,11 @@ interface RaiseDisputeSmartResult {
|
|
|
475
479
|
* "0x696e6672696e67656d656e74..." // dispute tag
|
|
476
480
|
* );
|
|
477
481
|
*
|
|
478
|
-
* //
|
|
482
|
+
* // The CID can be recovered from evidenceHash using decodeCidFromBytes32
|
|
479
483
|
* console.log("Evidence CID:", result.evidenceCid);
|
|
480
484
|
*
|
|
481
|
-
* // Fetch evidence
|
|
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>;
|
|
@@ -501,6 +503,42 @@ declare function raiseDisputeSmart(this: Origin, targetIpId: bigint, evidence: R
|
|
|
501
503
|
*/
|
|
502
504
|
declare function disputeAssertion(this: Origin, disputeId: bigint, counterEvidenceHash: Hex): Promise<any>;
|
|
503
505
|
|
|
506
|
+
interface DisputeAssertionSmartResult {
|
|
507
|
+
transactionResult: any;
|
|
508
|
+
counterEvidenceCid: string;
|
|
509
|
+
counterEvidenceHash: Hex;
|
|
510
|
+
}
|
|
511
|
+
/**
|
|
512
|
+
* Asserts a dispute with automatic counter-evidence upload to IPFS.
|
|
513
|
+
* Uploads counter-evidence JSON to IPFS, encodes the CID to bytes32 for on-chain storage,
|
|
514
|
+
* and calls disputeAssertion.
|
|
515
|
+
*
|
|
516
|
+
* The CID is encoded by stripping the 0x1220 multihash prefix from CIDv0,
|
|
517
|
+
* leaving only the 32-byte SHA-256 digest. This encoding is reversible,
|
|
518
|
+
* allowing the original CID to be reconstructed from the on-chain data.
|
|
519
|
+
*
|
|
520
|
+
* Must be called by the owner of the disputed IP within the cooldown period.
|
|
521
|
+
*
|
|
522
|
+
* @param disputeId The ID of the dispute to assert.
|
|
523
|
+
* @param counterEvidence The counter-evidence JSON object to upload to IPFS.
|
|
524
|
+
* @returns A promise that resolves with the transaction result, IPFS CID, and counter-evidence hash.
|
|
525
|
+
*
|
|
526
|
+
* @example
|
|
527
|
+
* ```typescript
|
|
528
|
+
* const result = await origin.disputeAssertionSmart(
|
|
529
|
+
* 1n,
|
|
530
|
+
* { description: "This is my original work", proofUrl: "https://..." }
|
|
531
|
+
* );
|
|
532
|
+
*
|
|
533
|
+
* // The CID can be recovered from counterEvidenceHash using decodeCidFromBytes32
|
|
534
|
+
* console.log("Counter-evidence CID:", result.counterEvidenceCid);
|
|
535
|
+
*
|
|
536
|
+
* // Fetch counter-evidence via IPFS gateway
|
|
537
|
+
* // https://ipfs.io/ipfs/{result.counterEvidenceCid}
|
|
538
|
+
* ```
|
|
539
|
+
*/
|
|
540
|
+
declare function disputeAssertionSmart(this: Origin, disputeId: bigint, counterEvidence: Record<string, any>): Promise<DisputeAssertionSmartResult>;
|
|
541
|
+
|
|
504
542
|
/**
|
|
505
543
|
* Votes on a dispute as a CAMP token staker.
|
|
506
544
|
* Only users who staked before the dispute was raised can vote.
|
|
@@ -680,6 +718,31 @@ interface DisputeProgress {
|
|
|
680
718
|
*/
|
|
681
719
|
declare function getDisputeProgress(this: Origin, disputeId: bigint): Promise<DisputeProgress>;
|
|
682
720
|
|
|
721
|
+
interface DisputeRequirements {
|
|
722
|
+
bondAmount: bigint;
|
|
723
|
+
protocolFee: bigint;
|
|
724
|
+
totalRequired: bigint;
|
|
725
|
+
tokenAddress: Address;
|
|
726
|
+
isNativeToken: boolean;
|
|
727
|
+
userBalance: bigint;
|
|
728
|
+
hasSufficientBalance: boolean;
|
|
729
|
+
}
|
|
730
|
+
/**
|
|
731
|
+
* Gets the requirements for raising a dispute, including balance check.
|
|
732
|
+
*
|
|
733
|
+
* @param userAddress The address to check balance for.
|
|
734
|
+
* @returns A promise that resolves with the dispute requirements.
|
|
735
|
+
*
|
|
736
|
+
* @example
|
|
737
|
+
* ```typescript
|
|
738
|
+
* const requirements = await origin.getDisputeRequirements(walletAddress);
|
|
739
|
+
* if (!requirements.hasSufficientBalance) {
|
|
740
|
+
* console.log(`Need ${requirements.totalRequired} but only have ${requirements.userBalance}`);
|
|
741
|
+
* }
|
|
742
|
+
* ```
|
|
743
|
+
*/
|
|
744
|
+
declare function getDisputeRequirements(this: Origin, userAddress: Address): Promise<DisputeRequirements>;
|
|
745
|
+
|
|
683
746
|
/**
|
|
684
747
|
* Fractionalizes an IP NFT into fungible ERC20 tokens.
|
|
685
748
|
* The NFT is transferred to the fractionalizer contract and a new ERC20 token is created.
|
|
@@ -1051,6 +1114,7 @@ declare class Origin {
|
|
|
1051
1114
|
raiseDispute: typeof raiseDispute;
|
|
1052
1115
|
raiseDisputeSmart: typeof raiseDisputeSmart;
|
|
1053
1116
|
disputeAssertion: typeof disputeAssertion;
|
|
1117
|
+
disputeAssertionSmart: typeof disputeAssertionSmart;
|
|
1054
1118
|
voteOnDispute: typeof voteOnDispute;
|
|
1055
1119
|
resolveDispute: typeof resolveDispute;
|
|
1056
1120
|
cancelDispute: typeof cancelDispute;
|
|
@@ -1058,6 +1122,7 @@ declare class Origin {
|
|
|
1058
1122
|
getDispute: typeof getDispute;
|
|
1059
1123
|
canVoteOnDispute: typeof canVoteOnDispute;
|
|
1060
1124
|
getDisputeProgress: typeof getDisputeProgress;
|
|
1125
|
+
getDisputeRequirements: typeof getDisputeRequirements;
|
|
1061
1126
|
fractionalize: typeof fractionalize;
|
|
1062
1127
|
redeem: typeof redeem;
|
|
1063
1128
|
getTokenForNFT: typeof getTokenForNFT;
|