@campnetwork/origin 1.2.8 → 1.3.0-alpha.1
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 +403 -34
- package/dist/core.cjs +570 -93
- package/dist/core.d.ts +596 -18
- package/dist/core.esm.d.ts +596 -18
- package/dist/core.esm.js +566 -105
- package/dist/react/index.esm.d.ts +594 -16
- package/dist/react/index.esm.js +4561 -892
- package/package.json +1 -1
package/dist/core.esm.d.ts
CHANGED
|
@@ -134,51 +134,124 @@ declare const mainnet: {
|
|
|
134
134
|
interface Environment {
|
|
135
135
|
NAME: string;
|
|
136
136
|
AUTH_HUB_BASE_API: string;
|
|
137
|
-
AUTH_ENDPOINT: string;
|
|
138
137
|
ORIGIN_DASHBOARD: string;
|
|
139
138
|
DATANFT_CONTRACT_ADDRESS: string;
|
|
140
139
|
MARKETPLACE_CONTRACT_ADDRESS: string;
|
|
141
140
|
BATCH_PURCHASE_CONTRACT_ADDRESS: string;
|
|
141
|
+
DISPUTE_CONTRACT_ADDRESS?: string;
|
|
142
|
+
FRACTIONALIZER_CONTRACT_ADDRESS?: string;
|
|
143
|
+
APP_REGISTRY_CONTRACT_ADDRESS?: string;
|
|
144
|
+
USDC_CONTRACT_ADDRESS: string;
|
|
142
145
|
CHAIN: any;
|
|
143
146
|
IPNFT_ABI?: any;
|
|
144
147
|
MARKETPLACE_ABI?: any;
|
|
145
148
|
TBA_ABI?: any;
|
|
146
149
|
BATCH_PURCHASE_ABI?: any;
|
|
150
|
+
DISPUTE_ABI?: any;
|
|
151
|
+
FRACTIONALIZER_ABI?: any;
|
|
152
|
+
APP_REGISTRY_ABI?: any;
|
|
147
153
|
}
|
|
148
154
|
|
|
155
|
+
/**
|
|
156
|
+
* Enum representing the type of license for an IP NFT.
|
|
157
|
+
* - DURATION_BASED: License expires after a set duration (subscription model).
|
|
158
|
+
* - SINGLE_PAYMENT: One-time payment for perpetual access.
|
|
159
|
+
* - X402: HTTP 402-based micropayment license (no on-chain payments).
|
|
160
|
+
*/
|
|
161
|
+
declare enum LicenseType {
|
|
162
|
+
DURATION_BASED = 0,
|
|
163
|
+
SINGLE_PAYMENT = 1,
|
|
164
|
+
X402 = 2
|
|
165
|
+
}
|
|
149
166
|
/**
|
|
150
167
|
* Represents the terms of a license for a digital asset.
|
|
151
168
|
* @property price - The price of the asset in wei.
|
|
152
|
-
* @property duration - The duration of the license in seconds.
|
|
169
|
+
* @property duration - The duration of the license in seconds (0 for SINGLE_PAYMENT and X402).
|
|
153
170
|
* @property royaltyBps - The royalty percentage in basis points (0-10000).
|
|
154
171
|
* @property paymentToken - The address of the payment token (ERC20 / address(0) for native currency).
|
|
172
|
+
* @property licenseType - The type of license (DURATION_BASED, SINGLE_PAYMENT, or X402).
|
|
155
173
|
*/
|
|
156
174
|
type LicenseTerms = {
|
|
157
175
|
price: bigint;
|
|
158
176
|
duration: number;
|
|
159
177
|
royaltyBps: number;
|
|
160
178
|
paymentToken: Address;
|
|
179
|
+
licenseType: LicenseType;
|
|
161
180
|
};
|
|
162
181
|
/**
|
|
163
182
|
* Enum representing the status of data in the system.
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
183
|
+
* - ACTIVE: The data is currently active and available.
|
|
184
|
+
* - DELETED: The data has been deleted and is no longer available.
|
|
185
|
+
* - DISPUTED: The data has been disputed and marked as potentially infringing.
|
|
167
186
|
*/
|
|
168
187
|
declare enum DataStatus {
|
|
169
188
|
ACTIVE = 0,
|
|
170
|
-
|
|
171
|
-
|
|
189
|
+
DELETED = 1,
|
|
190
|
+
DISPUTED = 2
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Enum representing the status of a dispute.
|
|
194
|
+
* - Uninitialized: Dispute does not exist.
|
|
195
|
+
* - Raised: Dispute has been raised but not yet asserted by IP owner.
|
|
196
|
+
* - Asserted: IP owner has responded to the dispute.
|
|
197
|
+
* - Resolved: Dispute has been resolved (either valid or invalid).
|
|
198
|
+
* - Cancelled: Dispute was cancelled by the initiator.
|
|
199
|
+
*/
|
|
200
|
+
declare enum DisputeStatus {
|
|
201
|
+
Uninitialized = 0,
|
|
202
|
+
Raised = 1,
|
|
203
|
+
Asserted = 2,
|
|
204
|
+
Resolved = 3,
|
|
205
|
+
Cancelled = 4
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Represents a dispute against an IP NFT.
|
|
209
|
+
*/
|
|
210
|
+
interface Dispute {
|
|
211
|
+
initiator: Address;
|
|
212
|
+
targetId: bigint;
|
|
213
|
+
disputeTag: Hex;
|
|
214
|
+
disputeEvidenceHash: Hex;
|
|
215
|
+
counterEvidenceHash: Hex;
|
|
216
|
+
disputeTimestamp: bigint;
|
|
217
|
+
assertionTimestamp: bigint;
|
|
218
|
+
yesVotes: bigint;
|
|
219
|
+
noVotes: bigint;
|
|
220
|
+
status: DisputeStatus;
|
|
221
|
+
bondAmount: bigint;
|
|
222
|
+
protocolFeeAmount: bigint;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Represents app information from the AppRegistry.
|
|
226
|
+
*/
|
|
227
|
+
interface AppInfo {
|
|
228
|
+
treasury: Address;
|
|
229
|
+
revenueShareBps: number;
|
|
230
|
+
isActive: boolean;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Comprehensive token information returned by getTokenInfoSmart.
|
|
234
|
+
*/
|
|
235
|
+
interface TokenInfo {
|
|
236
|
+
tokenId: bigint;
|
|
237
|
+
owner: Address;
|
|
238
|
+
uri: string;
|
|
239
|
+
status: DataStatus;
|
|
240
|
+
terms: LicenseTerms;
|
|
241
|
+
hasAccess: boolean;
|
|
242
|
+
accessExpiry: bigint | null;
|
|
243
|
+
appId: string;
|
|
172
244
|
}
|
|
173
245
|
/**
|
|
174
246
|
* Creates license terms for a digital asset.
|
|
175
247
|
* @param price The price of the asset in wei.
|
|
176
|
-
* @param duration The duration of the license in seconds.
|
|
248
|
+
* @param duration The duration of the license in seconds (use 0 for SINGLE_PAYMENT and X402).
|
|
177
249
|
* @param royaltyBps The royalty percentage in basis points (0-10000).
|
|
178
250
|
* @param paymentToken The address of the payment token (ERC20 / address(0) for native currency).
|
|
251
|
+
* @param licenseType The type of license (defaults to DURATION_BASED).
|
|
179
252
|
* @returns The created license terms.
|
|
180
253
|
*/
|
|
181
|
-
declare const createLicenseTerms: (price: bigint, duration: number, royaltyBps: number, paymentToken: Address) => LicenseTerms;
|
|
254
|
+
declare const createLicenseTerms: (price: bigint, duration: number, royaltyBps: number, paymentToken: Address, licenseType?: LicenseType) => LicenseTerms;
|
|
182
255
|
/**
|
|
183
256
|
* Represents the source of an IpNFT.
|
|
184
257
|
* This can be one of the supported social media platforms or a file upload.
|
|
@@ -196,9 +269,10 @@ type IpNFTSource = "spotify" | "twitter" | "tiktok" | "file";
|
|
|
196
269
|
* @param licenseTerms The terms of the license for the NFT.
|
|
197
270
|
* @param deadline The deadline for the minting operation.
|
|
198
271
|
* @param signature The signature for the minting operation.
|
|
272
|
+
* @param appId Optional app ID for the minting operation.
|
|
199
273
|
* @returns A promise that resolves when the minting is complete.
|
|
200
274
|
*/
|
|
201
|
-
declare function mintWithSignature(this: Origin, to: Address, tokenId: bigint, parents: bigint[], isIp: boolean, hash: Hex, uri: string, licenseTerms: LicenseTerms, deadline: bigint, signature: Hex): Promise<any>;
|
|
275
|
+
declare function mintWithSignature(this: Origin, to: Address, tokenId: bigint, parents: bigint[], isIp: boolean, hash: Hex, uri: string, licenseTerms: LicenseTerms, deadline: bigint, signature: Hex, appId?: string): Promise<any>;
|
|
202
276
|
/**
|
|
203
277
|
* Registers a Data NFT with the Origin service in order to obtain a signature for minting.
|
|
204
278
|
* @param source The source of the Data NFT (e.g., "spotify", "twitter", "tiktok", or "file").
|
|
@@ -209,7 +283,7 @@ declare function mintWithSignature(this: Origin, to: Address, tokenId: bigint, p
|
|
|
209
283
|
* @param parents The IDs of the parent NFTs, if applicable.
|
|
210
284
|
* @return A promise that resolves with the registration data.
|
|
211
285
|
*/
|
|
212
|
-
declare function registerIpNFT(this: Origin, source: IpNFTSource, deadline: bigint, licenseTerms: LicenseTerms, metadata: Record<string, unknown>, fileKey?: string | string[], parents?: bigint[]): Promise<any>;
|
|
286
|
+
declare function registerIpNFT(this: Origin, source: IpNFTSource, deadline: bigint, licenseTerms: LicenseTerms, metadata: Record<string, unknown>, isIp: boolean, fileKey?: string | string[], parents?: bigint[], appId?: string): Promise<any>;
|
|
213
287
|
|
|
214
288
|
/**
|
|
215
289
|
* Updates the license terms of a specified IPNFT.
|
|
@@ -292,10 +366,12 @@ declare function setApprovalForAll(this: Origin, operator: Address, approved: bo
|
|
|
292
366
|
* @param expectedPrice The expected price for the access.
|
|
293
367
|
* @param expectedDuration The expected duration of the access in seconds.
|
|
294
368
|
* @param expectedPaymentToken The address of the payment token (use zero address for native token).
|
|
369
|
+
* @param expectedProtocolFeeBps The expected protocol fee in basis points (0-10000). Defaults to 0.
|
|
370
|
+
* @param expectedAppFeeBps The expected app fee in basis points (0-10000). Defaults to 0.
|
|
295
371
|
* @param value The amount of native token to send (only required if paying with native token).
|
|
296
372
|
* @returns A promise that resolves when the transaction is confirmed.
|
|
297
373
|
*/
|
|
298
|
-
declare function buyAccess(this: Origin, buyer: Address, tokenId: bigint, expectedPrice: bigint, expectedDuration: bigint, expectedPaymentToken: Address, value?: bigint): Promise<any>;
|
|
374
|
+
declare function buyAccess(this: Origin, buyer: Address, tokenId: bigint, expectedPrice: bigint, expectedDuration: bigint, expectedPaymentToken: Address, expectedProtocolFeeBps?: number, expectedAppFeeBps?: number, value?: bigint): Promise<any>;
|
|
299
375
|
|
|
300
376
|
/**
|
|
301
377
|
* Checks if a user has access to a specific token based on subscription expiry.
|
|
@@ -355,6 +431,448 @@ declare function settlePaymentIntent(this: Origin, paymentIntentResponse: X402Re
|
|
|
355
431
|
*/
|
|
356
432
|
declare function getDataWithIntent(this: Origin, tokenId: bigint, signer?: any, decide?: (terms: any) => Promise<boolean>): Promise<any>;
|
|
357
433
|
|
|
434
|
+
/**
|
|
435
|
+
* Raises a dispute against an IP NFT.
|
|
436
|
+
* Requires the caller to have the dispute bond amount in dispute tokens.
|
|
437
|
+
*
|
|
438
|
+
* @param targetIpId The token ID of the IP NFT to dispute.
|
|
439
|
+
* @param evidenceHash The hash of evidence supporting the dispute.
|
|
440
|
+
* @param disputeTag A tag identifying the type of dispute.
|
|
441
|
+
* @returns A promise that resolves with the transaction result including the dispute ID.
|
|
442
|
+
*
|
|
443
|
+
* @example
|
|
444
|
+
* ```typescript
|
|
445
|
+
* const result = await origin.raiseDispute(
|
|
446
|
+
* 1n,
|
|
447
|
+
* "0x1234...", // evidence hash
|
|
448
|
+
* "0x5678..." // dispute tag (e.g., "infringement", "fraud")
|
|
449
|
+
* );
|
|
450
|
+
* ```
|
|
451
|
+
*/
|
|
452
|
+
declare function raiseDispute(this: Origin, targetIpId: bigint, evidenceHash: Hex, disputeTag: Hex): Promise<any>;
|
|
453
|
+
|
|
454
|
+
interface RaiseDisputeSmartResult {
|
|
455
|
+
transactionResult: any;
|
|
456
|
+
evidenceCid: string;
|
|
457
|
+
evidenceHash: Hex;
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Raises a dispute with automatic evidence upload to IPFS.
|
|
461
|
+
* Uploads evidence JSON to IPFS, hashes the CID to bytes32 for on-chain storage,
|
|
462
|
+
* and calls raiseDispute.
|
|
463
|
+
*
|
|
464
|
+
* @param targetIpId The token ID of the IP NFT to dispute.
|
|
465
|
+
* @param evidence The evidence JSON object to upload to IPFS.
|
|
466
|
+
* @param disputeTag A tag identifying the type of dispute.
|
|
467
|
+
* @returns A promise that resolves with the transaction result, IPFS CID, and evidence hash.
|
|
468
|
+
*
|
|
469
|
+
* @example
|
|
470
|
+
* ```typescript
|
|
471
|
+
* const result = await origin.raiseDisputeSmart(
|
|
472
|
+
* 1n,
|
|
473
|
+
* { reason: "copyright", details: "Unauthorized use of copyrighted material" },
|
|
474
|
+
* "0x696e6672696e67656d656e74..." // dispute tag
|
|
475
|
+
* );
|
|
476
|
+
*
|
|
477
|
+
* // Store the CID for evidence retrieval
|
|
478
|
+
* console.log("Evidence CID:", result.evidenceCid);
|
|
479
|
+
*
|
|
480
|
+
* // Fetch evidence later via IPFS gateway
|
|
481
|
+
* // https://ipfs.io/ipfs/{result.evidenceCid}
|
|
482
|
+
*
|
|
483
|
+
* // Verify evidence hash matches on-chain: keccak256(toHex(evidenceCid)) === evidenceHash
|
|
484
|
+
* ```
|
|
485
|
+
*/
|
|
486
|
+
declare function raiseDisputeSmart(this: Origin, targetIpId: bigint, evidence: Record<string, any>, disputeTag: Hex): Promise<RaiseDisputeSmartResult>;
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* Asserts a dispute as the IP owner with counter-evidence.
|
|
490
|
+
* Must be called by the owner of the disputed IP within the cooldown period.
|
|
491
|
+
*
|
|
492
|
+
* @param disputeId The ID of the dispute to assert.
|
|
493
|
+
* @param counterEvidenceHash The hash of evidence countering the dispute.
|
|
494
|
+
* @returns A promise that resolves with the transaction result.
|
|
495
|
+
*
|
|
496
|
+
* @example
|
|
497
|
+
* ```typescript
|
|
498
|
+
* await origin.disputeAssertion(1n, "0x1234..."); // counter-evidence hash
|
|
499
|
+
* ```
|
|
500
|
+
*/
|
|
501
|
+
declare function disputeAssertion(this: Origin, disputeId: bigint, counterEvidenceHash: Hex): Promise<any>;
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* Votes on a dispute as a CAMP token staker.
|
|
505
|
+
* Only users who staked before the dispute was raised can vote.
|
|
506
|
+
* Requires the caller to have voting power >= staking threshold.
|
|
507
|
+
*
|
|
508
|
+
* @param disputeId The ID of the dispute to vote on.
|
|
509
|
+
* @param support True to vote in favor of the dispute, false to vote against.
|
|
510
|
+
* @returns A promise that resolves with the transaction result.
|
|
511
|
+
*
|
|
512
|
+
* @example
|
|
513
|
+
* ```typescript
|
|
514
|
+
* // Vote in favor of the dispute
|
|
515
|
+
* await origin.voteOnDispute(1n, true);
|
|
516
|
+
*
|
|
517
|
+
* // Vote against the dispute
|
|
518
|
+
* await origin.voteOnDispute(1n, false);
|
|
519
|
+
* ```
|
|
520
|
+
*/
|
|
521
|
+
declare function voteOnDispute(this: Origin, disputeId: bigint, support: boolean): Promise<any>;
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* Resolves a dispute after the voting period has ended.
|
|
525
|
+
* Can be called by anyone - resolution is deterministic based on votes and quorum.
|
|
526
|
+
* If the dispute is valid, the IP is marked as disputed and bond is returned.
|
|
527
|
+
* If invalid, the bond is split between the IP owner and resolver (protocol fee to caller).
|
|
528
|
+
*
|
|
529
|
+
* @param disputeId The ID of the dispute to resolve.
|
|
530
|
+
* @returns A promise that resolves with the transaction result.
|
|
531
|
+
*
|
|
532
|
+
* @example
|
|
533
|
+
* ```typescript
|
|
534
|
+
* await origin.resolveDispute(1n);
|
|
535
|
+
* ```
|
|
536
|
+
*/
|
|
537
|
+
declare function resolveDispute(this: Origin, disputeId: bigint): Promise<any>;
|
|
538
|
+
|
|
539
|
+
/**
|
|
540
|
+
* Cancels a dispute that is still in the raised state.
|
|
541
|
+
* Can only be called by the dispute initiator during the cooldown period.
|
|
542
|
+
* The bond is returned to the initiator.
|
|
543
|
+
*
|
|
544
|
+
* @param disputeId The ID of the dispute to cancel.
|
|
545
|
+
* @returns A promise that resolves with the transaction result.
|
|
546
|
+
*
|
|
547
|
+
* @example
|
|
548
|
+
* ```typescript
|
|
549
|
+
* await origin.cancelDispute(1n);
|
|
550
|
+
* ```
|
|
551
|
+
*/
|
|
552
|
+
declare function cancelDispute(this: Origin, disputeId: bigint): Promise<any>;
|
|
553
|
+
|
|
554
|
+
/**
|
|
555
|
+
* Tags a child IP as disputed if its parent has been successfully disputed.
|
|
556
|
+
* This propagates the dispute status to derivative IPs.
|
|
557
|
+
*
|
|
558
|
+
* @param childIpId The token ID of the child IP to tag.
|
|
559
|
+
* @param infringerDisputeId The ID of the resolved dispute against the parent IP.
|
|
560
|
+
* @returns A promise that resolves with the transaction result.
|
|
561
|
+
*
|
|
562
|
+
* @example
|
|
563
|
+
* ```typescript
|
|
564
|
+
* // After parent IP (tokenId 1) has been disputed, tag child IP (tokenId 2)
|
|
565
|
+
* await origin.tagChildIp(2n, 1n); // childIpId, disputeId of parent
|
|
566
|
+
* ```
|
|
567
|
+
*/
|
|
568
|
+
declare function tagChildIp(this: Origin, childIpId: bigint, infringerDisputeId: bigint): Promise<any>;
|
|
569
|
+
|
|
570
|
+
/**
|
|
571
|
+
* Gets the details of a dispute by its ID.
|
|
572
|
+
*
|
|
573
|
+
* @param disputeId The ID of the dispute to fetch.
|
|
574
|
+
* @returns A promise that resolves with the dispute details.
|
|
575
|
+
*
|
|
576
|
+
* @example
|
|
577
|
+
* ```typescript
|
|
578
|
+
* const dispute = await origin.getDispute(1n);
|
|
579
|
+
* console.log(`Status: ${dispute.status}`);
|
|
580
|
+
* console.log(`Yes votes: ${dispute.yesVotes}`);
|
|
581
|
+
* console.log(`No votes: ${dispute.noVotes}`);
|
|
582
|
+
* ```
|
|
583
|
+
*/
|
|
584
|
+
declare function getDispute(this: Origin, disputeId: bigint): Promise<Dispute>;
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* Result of checking if a user can vote on a dispute.
|
|
588
|
+
*/
|
|
589
|
+
interface VoteEligibility {
|
|
590
|
+
canVote: boolean;
|
|
591
|
+
/** Reason why user cannot vote (if canVote is false) */
|
|
592
|
+
reason?: string;
|
|
593
|
+
/** User's voting weight (staked CAMP balance) */
|
|
594
|
+
votingWeight: bigint;
|
|
595
|
+
/** Minimum required stake to vote */
|
|
596
|
+
stakingThreshold: bigint;
|
|
597
|
+
hasAlreadyVoted: boolean;
|
|
598
|
+
/** Timestamp when user staked (0 if never staked) */
|
|
599
|
+
userStakeTimestamp: bigint;
|
|
600
|
+
disputeTimestamp: bigint;
|
|
601
|
+
disputeStatus: DisputeStatus;
|
|
602
|
+
isVotingPeriodActive: boolean;
|
|
603
|
+
}
|
|
604
|
+
/**
|
|
605
|
+
* Checks if a user meets the requirements to vote on a dispute.
|
|
606
|
+
* Returns detailed information about eligibility and reason if ineligible.
|
|
607
|
+
*
|
|
608
|
+
* @param disputeId The ID of the dispute to check.
|
|
609
|
+
* @param voter Optional address to check. If not provided, uses connected wallet.
|
|
610
|
+
* @returns A promise that resolves with the vote eligibility details.
|
|
611
|
+
*
|
|
612
|
+
* @example
|
|
613
|
+
* ```typescript
|
|
614
|
+
* const eligibility = await origin.canVoteOnDispute(1n);
|
|
615
|
+
*
|
|
616
|
+
* if (eligibility.canVote) {
|
|
617
|
+
* console.log(`You can vote with weight: ${eligibility.votingWeight}`);
|
|
618
|
+
* await origin.voteOnDispute(1n, true);
|
|
619
|
+
* } else {
|
|
620
|
+
* console.log(`Cannot vote: ${eligibility.reason}`);
|
|
621
|
+
* }
|
|
622
|
+
* ```
|
|
623
|
+
*/
|
|
624
|
+
declare function canVoteOnDispute(this: Origin, disputeId: bigint, voter?: Address): Promise<VoteEligibility>;
|
|
625
|
+
|
|
626
|
+
/**
|
|
627
|
+
* Progress and voting statistics for a dispute.
|
|
628
|
+
*/
|
|
629
|
+
interface DisputeProgress {
|
|
630
|
+
disputeId: bigint;
|
|
631
|
+
status: DisputeStatus;
|
|
632
|
+
/** Total YES votes (weighted by stake) */
|
|
633
|
+
yesVotes: bigint;
|
|
634
|
+
/** Total NO votes (weighted by stake) */
|
|
635
|
+
noVotes: bigint;
|
|
636
|
+
totalVotes: bigint;
|
|
637
|
+
/** YES votes as percentage (0-100) */
|
|
638
|
+
yesPercentage: number;
|
|
639
|
+
/** NO votes as percentage (0-100) */
|
|
640
|
+
noPercentage: number;
|
|
641
|
+
/** Required quorum for valid resolution */
|
|
642
|
+
quorum: bigint;
|
|
643
|
+
/** Current progress toward quorum (0-100+) */
|
|
644
|
+
quorumPercentage: number;
|
|
645
|
+
quorumMet: boolean;
|
|
646
|
+
/** Projected outcome if resolved now */
|
|
647
|
+
projectedOutcome: "dispute_succeeds" | "dispute_fails" | "no_quorum";
|
|
648
|
+
timeline: {
|
|
649
|
+
raisedAt: Date;
|
|
650
|
+
/** When the cooldown period ends (owner can no longer assert) */
|
|
651
|
+
cooldownEndsAt: Date;
|
|
652
|
+
votingEndsAt: Date;
|
|
653
|
+
canResolveNow: boolean;
|
|
654
|
+
/** Time remaining until resolution (in seconds, 0 if can resolve) */
|
|
655
|
+
timeUntilResolution: number;
|
|
656
|
+
};
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* Gets detailed progress and voting statistics for a dispute.
|
|
660
|
+
* Includes vote counts, percentages, quorum progress, and timeline.
|
|
661
|
+
*
|
|
662
|
+
* @param disputeId The ID of the dispute to check.
|
|
663
|
+
* @returns A promise that resolves with the dispute progress details.
|
|
664
|
+
*
|
|
665
|
+
* @example
|
|
666
|
+
* ```typescript
|
|
667
|
+
* const progress = await origin.getDisputeProgress(1n);
|
|
668
|
+
*
|
|
669
|
+
* console.log(`Yes: ${progress.yesPercentage}% | No: ${progress.noPercentage}%`);
|
|
670
|
+
* console.log(`Quorum: ${progress.quorumPercentage}% (${progress.quorumMet ? 'met' : 'not met'})`);
|
|
671
|
+
* console.log(`Projected outcome: ${progress.projectedOutcome}`);
|
|
672
|
+
*
|
|
673
|
+
* if (progress.timeline.canResolveNow) {
|
|
674
|
+
* await origin.resolveDispute(1n);
|
|
675
|
+
* } else {
|
|
676
|
+
* console.log(`Can resolve in ${progress.timeline.timeUntilResolution} seconds`);
|
|
677
|
+
* }
|
|
678
|
+
* ```
|
|
679
|
+
*/
|
|
680
|
+
declare function getDisputeProgress(this: Origin, disputeId: bigint): Promise<DisputeProgress>;
|
|
681
|
+
|
|
682
|
+
/**
|
|
683
|
+
* Fractionalizes an IP NFT into fungible ERC20 tokens.
|
|
684
|
+
* The NFT is transferred to the fractionalizer contract and a new ERC20 token is created.
|
|
685
|
+
* The caller receives the full supply of fractional tokens.
|
|
686
|
+
*
|
|
687
|
+
* @param tokenId The token ID of the IP NFT to fractionalize.
|
|
688
|
+
* @returns A promise that resolves with the transaction result.
|
|
689
|
+
*
|
|
690
|
+
* @example
|
|
691
|
+
* ```typescript
|
|
692
|
+
* // First approve the fractionalizer contract to transfer your NFT
|
|
693
|
+
* await origin.approve(fractionalizerAddress, tokenId);
|
|
694
|
+
*
|
|
695
|
+
* // Then fractionalize
|
|
696
|
+
* const result = await origin.fractionalize(1n);
|
|
697
|
+
* ```
|
|
698
|
+
*/
|
|
699
|
+
declare function fractionalize(this: Origin, tokenId: bigint): Promise<any>;
|
|
700
|
+
|
|
701
|
+
/**
|
|
702
|
+
* Redeems an IP NFT by burning all of its fractional tokens.
|
|
703
|
+
* The caller must hold the entire supply of the NFT's fractional token.
|
|
704
|
+
* After redemption, the NFT is transferred back to the caller.
|
|
705
|
+
*
|
|
706
|
+
* @param tokenId The token ID of the IP NFT to redeem.
|
|
707
|
+
* @returns A promise that resolves with the transaction result.
|
|
708
|
+
*
|
|
709
|
+
* @example
|
|
710
|
+
* ```typescript
|
|
711
|
+
* // Requires holding 100% of the fractional token supply
|
|
712
|
+
* await origin.redeem(1n);
|
|
713
|
+
* ```
|
|
714
|
+
*/
|
|
715
|
+
declare function redeem(this: Origin, tokenId: bigint): Promise<any>;
|
|
716
|
+
|
|
717
|
+
/**
|
|
718
|
+
* Gets the fractional ERC20 token address for a specific IP NFT.
|
|
719
|
+
* Returns zero address if the NFT has not been fractionalized.
|
|
720
|
+
*
|
|
721
|
+
* @param tokenId The token ID of the IP NFT.
|
|
722
|
+
* @returns A promise that resolves with the fractional token address.
|
|
723
|
+
*
|
|
724
|
+
* @example
|
|
725
|
+
* ```typescript
|
|
726
|
+
* const fractionalToken = await origin.getTokenForNFT(1n);
|
|
727
|
+
* if (fractionalToken !== zeroAddress) {
|
|
728
|
+
* console.log(`Fractional token: ${fractionalToken}`);
|
|
729
|
+
* } else {
|
|
730
|
+
* console.log("NFT has not been fractionalized");
|
|
731
|
+
* }
|
|
732
|
+
* ```
|
|
733
|
+
*/
|
|
734
|
+
declare function getTokenForNFT(this: Origin, tokenId: bigint): Promise<Address>;
|
|
735
|
+
|
|
736
|
+
/**
|
|
737
|
+
* Fractionalizes an IP NFT with automatic approval.
|
|
738
|
+
* This method first approves the fractionalizer contract to transfer your NFT,
|
|
739
|
+
* then calls fractionalize. This is the recommended method for most use cases.
|
|
740
|
+
*
|
|
741
|
+
* @param tokenId The token ID of the IP NFT to fractionalize.
|
|
742
|
+
* @returns A promise that resolves with the transaction result.
|
|
743
|
+
*
|
|
744
|
+
* @example
|
|
745
|
+
* ```typescript
|
|
746
|
+
* // Single call handles approval and fractionalization
|
|
747
|
+
* const result = await origin.fractionalizeWithApproval(1n);
|
|
748
|
+
* ```
|
|
749
|
+
*/
|
|
750
|
+
declare function fractionalizeWithApproval(this: Origin, tokenId: bigint): Promise<any>;
|
|
751
|
+
|
|
752
|
+
/**
|
|
753
|
+
* Redeems fractional tokens for the underlying NFT, but only if the caller owns 100% of the supply.
|
|
754
|
+
* This method checks the caller's balance before attempting to redeem, providing a clear error
|
|
755
|
+
* if they don't hold the full supply.
|
|
756
|
+
*
|
|
757
|
+
* @param tokenId The token ID of the original NFT to redeem.
|
|
758
|
+
* @returns A promise that resolves with the transaction result.
|
|
759
|
+
* @throws Error if the caller doesn't own 100% of the fractional tokens.
|
|
760
|
+
*
|
|
761
|
+
* @example
|
|
762
|
+
* ```typescript
|
|
763
|
+
* try {
|
|
764
|
+
* const result = await origin.redeemIfComplete(1n);
|
|
765
|
+
* console.log("NFT redeemed successfully!");
|
|
766
|
+
* } catch (error) {
|
|
767
|
+
* console.log("You don't own all fractional tokens yet");
|
|
768
|
+
* }
|
|
769
|
+
* ```
|
|
770
|
+
*/
|
|
771
|
+
declare function redeemIfComplete(this: Origin, tokenId: bigint): Promise<any>;
|
|
772
|
+
|
|
773
|
+
/**
|
|
774
|
+
* Ownership information for fractional tokens.
|
|
775
|
+
*/
|
|
776
|
+
interface FractionOwnership {
|
|
777
|
+
tokenId: bigint;
|
|
778
|
+
/** The ERC20 token address (zero if not fractionalized) */
|
|
779
|
+
erc20Address: Address;
|
|
780
|
+
isFractionalized: boolean;
|
|
781
|
+
/** User's balance of fractional tokens */
|
|
782
|
+
balance: bigint;
|
|
783
|
+
/** Total supply of fractional tokens */
|
|
784
|
+
totalSupply: bigint;
|
|
785
|
+
/** User's ownership percentage (0-100) */
|
|
786
|
+
ownershipPercentage: number;
|
|
787
|
+
/** Whether user owns 100% and can redeem */
|
|
788
|
+
canRedeem: boolean;
|
|
789
|
+
decimals: number;
|
|
790
|
+
}
|
|
791
|
+
/**
|
|
792
|
+
* Gets a user's ownership percentage of a fractionalized NFT.
|
|
793
|
+
* Returns detailed information about the user's fractional token holdings.
|
|
794
|
+
*
|
|
795
|
+
* @param tokenId The token ID of the original NFT.
|
|
796
|
+
* @param owner Optional address to check. If not provided, uses connected wallet.
|
|
797
|
+
* @returns A promise that resolves with the ownership details.
|
|
798
|
+
*
|
|
799
|
+
* @example
|
|
800
|
+
* ```typescript
|
|
801
|
+
* const ownership = await origin.getFractionOwnership(1n);
|
|
802
|
+
*
|
|
803
|
+
* if (!ownership.isFractionalized) {
|
|
804
|
+
* console.log("This NFT has not been fractionalized");
|
|
805
|
+
* } else {
|
|
806
|
+
* console.log(`You own ${ownership.ownershipPercentage}% of this NFT`);
|
|
807
|
+
* console.log(`Balance: ${ownership.balance} / ${ownership.totalSupply}`);
|
|
808
|
+
*
|
|
809
|
+
* if (ownership.canRedeem) {
|
|
810
|
+
* console.log("You can redeem the original NFT!");
|
|
811
|
+
* await origin.redeem(1n);
|
|
812
|
+
* }
|
|
813
|
+
* }
|
|
814
|
+
* ```
|
|
815
|
+
*/
|
|
816
|
+
declare function getFractionOwnership(this: Origin, tokenId: bigint, owner?: Address): Promise<FractionOwnership>;
|
|
817
|
+
|
|
818
|
+
/**
|
|
819
|
+
* Result of checking if a user can fractionalize an NFT.
|
|
820
|
+
*/
|
|
821
|
+
interface FractionalizeEligibility {
|
|
822
|
+
canFractionalize: boolean;
|
|
823
|
+
/** Reason why user cannot fractionalize (if canFractionalize is false) */
|
|
824
|
+
reason?: string;
|
|
825
|
+
isOwner: boolean;
|
|
826
|
+
currentOwner: Address;
|
|
827
|
+
isAlreadyFractionalized: boolean;
|
|
828
|
+
/** ERC20 address if already fractionalized */
|
|
829
|
+
existingErc20Address?: Address;
|
|
830
|
+
dataStatus: DataStatus;
|
|
831
|
+
isApproved: boolean;
|
|
832
|
+
needsApproval: boolean;
|
|
833
|
+
}
|
|
834
|
+
/**
|
|
835
|
+
* Checks if a user can fractionalize an NFT and why not if they can't.
|
|
836
|
+
* Returns detailed information about eligibility requirements.
|
|
837
|
+
*
|
|
838
|
+
* @param tokenId The token ID of the NFT to check.
|
|
839
|
+
* @param owner Optional address to check. If not provided, uses connected wallet.
|
|
840
|
+
* @returns A promise that resolves with the fractionalize eligibility details.
|
|
841
|
+
*
|
|
842
|
+
* @example
|
|
843
|
+
* ```typescript
|
|
844
|
+
* const eligibility = await origin.canFractionalize(1n);
|
|
845
|
+
*
|
|
846
|
+
* if (eligibility.canFractionalize) {
|
|
847
|
+
* if (eligibility.needsApproval) {
|
|
848
|
+
* // Use fractionalizeWithApproval for convenience
|
|
849
|
+
* await origin.fractionalizeWithApproval(1n);
|
|
850
|
+
* } else {
|
|
851
|
+
* await origin.fractionalize(1n);
|
|
852
|
+
* }
|
|
853
|
+
* } else {
|
|
854
|
+
* console.log(`Cannot fractionalize: ${eligibility.reason}`);
|
|
855
|
+
* }
|
|
856
|
+
* ```
|
|
857
|
+
*/
|
|
858
|
+
declare function canFractionalize(this: Origin, tokenId: bigint, owner?: Address): Promise<FractionalizeEligibility>;
|
|
859
|
+
|
|
860
|
+
/**
|
|
861
|
+
* Gets information about a registered app from the AppRegistry.
|
|
862
|
+
*
|
|
863
|
+
* @param appId The app ID to look up.
|
|
864
|
+
* @returns A promise that resolves with the app information.
|
|
865
|
+
*
|
|
866
|
+
* @example
|
|
867
|
+
* ```typescript
|
|
868
|
+
* const appInfo = await origin.getAppInfo("my-app-id");
|
|
869
|
+
* console.log(`Treasury: ${appInfo.treasury}`);
|
|
870
|
+
* console.log(`Revenue Share: ${appInfo.revenueShareBps / 100}%`);
|
|
871
|
+
* console.log(`Active: ${appInfo.isActive}`);
|
|
872
|
+
* ```
|
|
873
|
+
*/
|
|
874
|
+
declare function getAppInfo(this: Origin, appId: string): Promise<AppInfo>;
|
|
875
|
+
|
|
358
876
|
/**
|
|
359
877
|
* Parameters for a single purchase in a bulk buy operation.
|
|
360
878
|
*/
|
|
@@ -363,6 +881,8 @@ interface BuyParams {
|
|
|
363
881
|
expectedPrice: bigint;
|
|
364
882
|
expectedDuration: number;
|
|
365
883
|
expectedPaymentToken: Address;
|
|
884
|
+
expectedProtocolFeeBps: number;
|
|
885
|
+
expectedAppFeeBps: number;
|
|
366
886
|
}
|
|
367
887
|
/**
|
|
368
888
|
* Result of a tolerant bulk purchase operation.
|
|
@@ -527,13 +1047,39 @@ declare class Origin {
|
|
|
527
1047
|
previewBulkCost: typeof previewBulkCost;
|
|
528
1048
|
buildPurchaseParams: typeof buildPurchaseParams;
|
|
529
1049
|
checkActiveStatus: typeof checkActiveStatus;
|
|
1050
|
+
raiseDispute: typeof raiseDispute;
|
|
1051
|
+
raiseDisputeSmart: typeof raiseDisputeSmart;
|
|
1052
|
+
disputeAssertion: typeof disputeAssertion;
|
|
1053
|
+
voteOnDispute: typeof voteOnDispute;
|
|
1054
|
+
resolveDispute: typeof resolveDispute;
|
|
1055
|
+
cancelDispute: typeof cancelDispute;
|
|
1056
|
+
tagChildIp: typeof tagChildIp;
|
|
1057
|
+
getDispute: typeof getDispute;
|
|
1058
|
+
canVoteOnDispute: typeof canVoteOnDispute;
|
|
1059
|
+
getDisputeProgress: typeof getDisputeProgress;
|
|
1060
|
+
fractionalize: typeof fractionalize;
|
|
1061
|
+
redeem: typeof redeem;
|
|
1062
|
+
getTokenForNFT: typeof getTokenForNFT;
|
|
1063
|
+
fractionalizeWithApproval: typeof fractionalizeWithApproval;
|
|
1064
|
+
redeemIfComplete: typeof redeemIfComplete;
|
|
1065
|
+
getFractionOwnership: typeof getFractionOwnership;
|
|
1066
|
+
canFractionalize: typeof canFractionalize;
|
|
1067
|
+
getAppInfo: typeof getAppInfo;
|
|
530
1068
|
private jwt?;
|
|
531
1069
|
environment: Environment;
|
|
532
1070
|
private viemClient?;
|
|
533
1071
|
baseParentId?: bigint;
|
|
534
|
-
|
|
1072
|
+
appId?: string;
|
|
1073
|
+
constructor(environment?: Environment | string, jwt?: string, viemClient?: WalletClient, baseParentId?: bigint, appId?: string);
|
|
535
1074
|
getJwt(): string | undefined;
|
|
536
1075
|
setViemClient(client: WalletClient): void;
|
|
1076
|
+
/**
|
|
1077
|
+
* Uploads a JSON object to IPFS and returns the resulting CID.
|
|
1078
|
+
* @param data The JSON object to upload.
|
|
1079
|
+
* @returns The CID of the uploaded JSON.
|
|
1080
|
+
* @throws {APIError} If the upload fails.
|
|
1081
|
+
*/
|
|
1082
|
+
uploadJSONToIPFS(data: Record<string, any>): Promise<string>;
|
|
537
1083
|
/**
|
|
538
1084
|
* Mints a file-based IpNFT.
|
|
539
1085
|
* @param file The file to mint.
|
|
@@ -567,12 +1113,42 @@ declare class Origin {
|
|
|
567
1113
|
* @throws {Error} - Throws an error if the wallet client is not connected and the method is not a view function.
|
|
568
1114
|
*/
|
|
569
1115
|
callContractMethod(contractAddress: string, abi: Abi, methodName: string, params: any[], options?: CallOptions): Promise<any>;
|
|
1116
|
+
/**
|
|
1117
|
+
* Gets comprehensive token information in a single call.
|
|
1118
|
+
* Combines owner, status, terms, URI, and access information.
|
|
1119
|
+
*
|
|
1120
|
+
* @param tokenId The token ID to get information for.
|
|
1121
|
+
* @param owner Optional address to check access for. If not provided, uses connected wallet.
|
|
1122
|
+
* @returns A promise that resolves with comprehensive token information.
|
|
1123
|
+
*
|
|
1124
|
+
* @example
|
|
1125
|
+
* ```typescript
|
|
1126
|
+
* const info = await origin.getTokenInfoSmart(1n);
|
|
1127
|
+
* console.log(`Owner: ${info.owner}`);
|
|
1128
|
+
* console.log(`Price: ${info.terms.price}`);
|
|
1129
|
+
* console.log(`Has access: ${info.hasAccess}`);
|
|
1130
|
+
* ```
|
|
1131
|
+
*/
|
|
1132
|
+
getTokenInfoSmart(tokenId: bigint, owner?: Address): Promise<TokenInfo>;
|
|
570
1133
|
/**
|
|
571
1134
|
* Buy access to an asset by first checking its price via getTerms, then calling buyAccess.
|
|
572
|
-
*
|
|
573
|
-
*
|
|
1135
|
+
* Automatically fetches protocol and app fees from the contracts.
|
|
1136
|
+
* If the user already has access, returns null without making a transaction.
|
|
1137
|
+
*
|
|
1138
|
+
* @param tokenId The token ID of the asset.
|
|
1139
|
+
* @returns The result of the buyAccess call, or null if user already has access.
|
|
1140
|
+
*
|
|
1141
|
+
* @example
|
|
1142
|
+
* ```typescript
|
|
1143
|
+
* const result = await origin.buyAccessSmart(1n);
|
|
1144
|
+
* if (result === null) {
|
|
1145
|
+
* console.log("You already have access to this asset");
|
|
1146
|
+
* } else {
|
|
1147
|
+
* console.log("Access purchased:", result.txHash);
|
|
1148
|
+
* }
|
|
1149
|
+
* ```
|
|
574
1150
|
*/
|
|
575
|
-
buyAccessSmart(tokenId: bigint): Promise<any>;
|
|
1151
|
+
buyAccessSmart(tokenId: bigint): Promise<any | null>;
|
|
576
1152
|
/**
|
|
577
1153
|
* Fetch the underlying data associated with a specific token ID.
|
|
578
1154
|
* @param {bigint} tokenId - The token ID to fetch data for.
|
|
@@ -641,6 +1217,7 @@ declare class Auth {
|
|
|
641
1217
|
#private;
|
|
642
1218
|
redirectUri: Record<string, string>;
|
|
643
1219
|
clientId: string;
|
|
1220
|
+
appId: string;
|
|
644
1221
|
isAuthenticated: boolean;
|
|
645
1222
|
jwt: string | null;
|
|
646
1223
|
walletAddress: string | null;
|
|
@@ -658,8 +1235,9 @@ declare class Auth {
|
|
|
658
1235
|
* @param {StorageAdapter} [options.storage] Custom storage adapter. Defaults to localStorage in browser, memory storage in Node.js.
|
|
659
1236
|
* @throws {APIError} - Throws an error if the clientId is not provided.
|
|
660
1237
|
*/
|
|
661
|
-
constructor({ clientId, redirectUri, environment, baseParentId, storage, }: {
|
|
1238
|
+
constructor({ clientId, appId, redirectUri, environment, baseParentId, storage, }: {
|
|
662
1239
|
clientId: string;
|
|
1240
|
+
appId: string;
|
|
663
1241
|
redirectUri: string | Record<string, string>;
|
|
664
1242
|
environment?: "DEVELOPMENT" | "PRODUCTION";
|
|
665
1243
|
baseParentId?: bigint;
|
|
@@ -841,4 +1419,4 @@ declare class Auth {
|
|
|
841
1419
|
unlinkTelegram(): Promise<any>;
|
|
842
1420
|
}
|
|
843
1421
|
|
|
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 };
|
|
1422
|
+
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 };
|