@campnetwork/origin 1.3.0-alpha.0 → 1.3.0-alpha.10
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 +1 -1
- package/dist/core.cjs +287 -112
- package/dist/core.d.ts +137 -8
- package/dist/core.esm.d.ts +137 -8
- package/dist/core.esm.js +299 -125
- package/dist/react/index.esm.d.ts +127 -8
- package/dist/react/index.esm.js +1480 -916
- package/package.json +2 -1
|
@@ -5,7 +5,6 @@ import { UseQueryResult } from '@tanstack/react-query';
|
|
|
5
5
|
interface Environment {
|
|
6
6
|
NAME: string;
|
|
7
7
|
AUTH_HUB_BASE_API: string;
|
|
8
|
-
AUTH_ENDPOINT: string;
|
|
9
8
|
ORIGIN_DASHBOARD: string;
|
|
10
9
|
DATANFT_CONTRACT_ADDRESS: string;
|
|
11
10
|
MARKETPLACE_CONTRACT_ADDRESS: string;
|
|
@@ -13,6 +12,7 @@ interface Environment {
|
|
|
13
12
|
DISPUTE_CONTRACT_ADDRESS?: string;
|
|
14
13
|
FRACTIONALIZER_CONTRACT_ADDRESS?: string;
|
|
15
14
|
APP_REGISTRY_CONTRACT_ADDRESS?: string;
|
|
15
|
+
USDC_CONTRACT_ADDRESS: string;
|
|
16
16
|
CHAIN: any;
|
|
17
17
|
IPNFT_ABI?: any;
|
|
18
18
|
MARKETPLACE_ABI?: any;
|
|
@@ -130,7 +130,7 @@ type IpNFTSource = "spotify" | "twitter" | "tiktok" | "file";
|
|
|
130
130
|
* @param licenseTerms The terms of the license for the NFT.
|
|
131
131
|
* @param deadline The deadline for the minting operation.
|
|
132
132
|
* @param signature The signature for the minting operation.
|
|
133
|
-
* @param appId Optional app ID for the minting operation.
|
|
133
|
+
* @param appId Optional app ID for the minting operation.
|
|
134
134
|
* @returns A promise that resolves when the minting is complete.
|
|
135
135
|
*/
|
|
136
136
|
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>;
|
|
@@ -144,7 +144,7 @@ declare function mintWithSignature(this: Origin, to: Address, tokenId: bigint, p
|
|
|
144
144
|
* @param parents The IDs of the parent NFTs, if applicable.
|
|
145
145
|
* @return A promise that resolves with the registration data.
|
|
146
146
|
*/
|
|
147
|
-
declare function registerIpNFT(this: Origin, source: IpNFTSource, deadline: bigint, licenseTerms: LicenseTerms, metadata: Record<string, unknown>, fileKey?: string | string[], parents?: bigint[]): Promise<any>;
|
|
147
|
+
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>;
|
|
148
148
|
|
|
149
149
|
/**
|
|
150
150
|
* Updates the license terms of a specified IPNFT.
|
|
@@ -294,11 +294,12 @@ declare function getDataWithIntent(this: Origin, tokenId: bigint, signer?: any,
|
|
|
294
294
|
|
|
295
295
|
/**
|
|
296
296
|
* Raises a dispute against an IP NFT.
|
|
297
|
-
*
|
|
297
|
+
* Automatically handles token approval for ERC20 bonds or native token value.
|
|
298
|
+
* Includes the protocol dispute fee in the transaction.
|
|
298
299
|
*
|
|
299
300
|
* @param targetIpId The token ID of the IP NFT to dispute.
|
|
300
301
|
* @param evidenceHash The hash of evidence supporting the dispute.
|
|
301
|
-
* @param disputeTag A tag identifying the type of dispute.
|
|
302
|
+
* @param disputeTag A tag identifying the type of dispute (bytes32).
|
|
302
303
|
* @returns A promise that resolves with the transaction result including the dispute ID.
|
|
303
304
|
*
|
|
304
305
|
* @example
|
|
@@ -306,12 +307,48 @@ declare function getDataWithIntent(this: Origin, tokenId: bigint, signer?: any,
|
|
|
306
307
|
* const result = await origin.raiseDispute(
|
|
307
308
|
* 1n,
|
|
308
309
|
* "0x1234...", // evidence hash
|
|
309
|
-
* "
|
|
310
|
+
* "0x0100000000000000000000000000000000000000000000000000000000000000" // dispute tag (bytes32)
|
|
310
311
|
* );
|
|
311
312
|
* ```
|
|
312
313
|
*/
|
|
313
314
|
declare function raiseDispute(this: Origin, targetIpId: bigint, evidenceHash: Hex, disputeTag: Hex): Promise<any>;
|
|
314
315
|
|
|
316
|
+
interface RaiseDisputeSmartResult {
|
|
317
|
+
transactionResult: any;
|
|
318
|
+
evidenceCid: string;
|
|
319
|
+
evidenceHash: Hex;
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Raises a dispute with automatic evidence upload to IPFS.
|
|
323
|
+
* Uploads evidence JSON to IPFS, encodes the CID to bytes32 for on-chain storage,
|
|
324
|
+
* and calls raiseDispute.
|
|
325
|
+
*
|
|
326
|
+
* The CID is encoded by stripping the 0x1220 multihash prefix from CIDv0,
|
|
327
|
+
* leaving only the 32-byte SHA-256 digest. This encoding is reversible,
|
|
328
|
+
* allowing the original CID to be reconstructed from the on-chain data.
|
|
329
|
+
*
|
|
330
|
+
* @param targetIpId The token ID of the IP NFT to dispute.
|
|
331
|
+
* @param evidence The evidence JSON object to upload to IPFS.
|
|
332
|
+
* @param disputeTag A tag identifying the type of dispute.
|
|
333
|
+
* @returns A promise that resolves with the transaction result, IPFS CID, and evidence hash.
|
|
334
|
+
*
|
|
335
|
+
* @example
|
|
336
|
+
* ```typescript
|
|
337
|
+
* const result = await origin.raiseDisputeSmart(
|
|
338
|
+
* 1n,
|
|
339
|
+
* { reason: "copyright", details: "Unauthorized use of copyrighted material" },
|
|
340
|
+
* "0x696e6672696e67656d656e74..." // dispute tag
|
|
341
|
+
* );
|
|
342
|
+
*
|
|
343
|
+
* // The CID can be recovered from evidenceHash using decodeCidFromBytes32
|
|
344
|
+
* console.log("Evidence CID:", result.evidenceCid);
|
|
345
|
+
*
|
|
346
|
+
* // Fetch evidence via IPFS gateway
|
|
347
|
+
* // https://ipfs.io/ipfs/{result.evidenceCid}
|
|
348
|
+
* ```
|
|
349
|
+
*/
|
|
350
|
+
declare function raiseDisputeSmart(this: Origin, targetIpId: bigint, evidence: Record<string, any>, disputeTag: Hex): Promise<RaiseDisputeSmartResult>;
|
|
351
|
+
|
|
315
352
|
/**
|
|
316
353
|
* Asserts a dispute as the IP owner with counter-evidence.
|
|
317
354
|
* Must be called by the owner of the disputed IP within the cooldown period.
|
|
@@ -327,6 +364,42 @@ declare function raiseDispute(this: Origin, targetIpId: bigint, evidenceHash: He
|
|
|
327
364
|
*/
|
|
328
365
|
declare function disputeAssertion(this: Origin, disputeId: bigint, counterEvidenceHash: Hex): Promise<any>;
|
|
329
366
|
|
|
367
|
+
interface DisputeAssertionSmartResult {
|
|
368
|
+
transactionResult: any;
|
|
369
|
+
counterEvidenceCid: string;
|
|
370
|
+
counterEvidenceHash: Hex;
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Asserts a dispute with automatic counter-evidence upload to IPFS.
|
|
374
|
+
* Uploads counter-evidence JSON to IPFS, encodes the CID to bytes32 for on-chain storage,
|
|
375
|
+
* and calls disputeAssertion.
|
|
376
|
+
*
|
|
377
|
+
* The CID is encoded by stripping the 0x1220 multihash prefix from CIDv0,
|
|
378
|
+
* leaving only the 32-byte SHA-256 digest. This encoding is reversible,
|
|
379
|
+
* allowing the original CID to be reconstructed from the on-chain data.
|
|
380
|
+
*
|
|
381
|
+
* Must be called by the owner of the disputed IP within the cooldown period.
|
|
382
|
+
*
|
|
383
|
+
* @param disputeId The ID of the dispute to assert.
|
|
384
|
+
* @param counterEvidence The counter-evidence JSON object to upload to IPFS.
|
|
385
|
+
* @returns A promise that resolves with the transaction result, IPFS CID, and counter-evidence hash.
|
|
386
|
+
*
|
|
387
|
+
* @example
|
|
388
|
+
* ```typescript
|
|
389
|
+
* const result = await origin.disputeAssertionSmart(
|
|
390
|
+
* 1n,
|
|
391
|
+
* { description: "This is my original work", proofUrl: "https://..." }
|
|
392
|
+
* );
|
|
393
|
+
*
|
|
394
|
+
* // The CID can be recovered from counterEvidenceHash using decodeCidFromBytes32
|
|
395
|
+
* console.log("Counter-evidence CID:", result.counterEvidenceCid);
|
|
396
|
+
*
|
|
397
|
+
* // Fetch counter-evidence via IPFS gateway
|
|
398
|
+
* // https://ipfs.io/ipfs/{result.counterEvidenceCid}
|
|
399
|
+
* ```
|
|
400
|
+
*/
|
|
401
|
+
declare function disputeAssertionSmart(this: Origin, disputeId: bigint, counterEvidence: Record<string, any>): Promise<DisputeAssertionSmartResult>;
|
|
402
|
+
|
|
330
403
|
/**
|
|
331
404
|
* Votes on a dispute as a CAMP token staker.
|
|
332
405
|
* Only users who staked before the dispute was raised can vote.
|
|
@@ -506,6 +579,31 @@ interface DisputeProgress {
|
|
|
506
579
|
*/
|
|
507
580
|
declare function getDisputeProgress(this: Origin, disputeId: bigint): Promise<DisputeProgress>;
|
|
508
581
|
|
|
582
|
+
interface DisputeRequirements {
|
|
583
|
+
bondAmount: bigint;
|
|
584
|
+
protocolFee: bigint;
|
|
585
|
+
totalRequired: bigint;
|
|
586
|
+
tokenAddress: Address;
|
|
587
|
+
isNativeToken: boolean;
|
|
588
|
+
userBalance: bigint;
|
|
589
|
+
hasSufficientBalance: boolean;
|
|
590
|
+
}
|
|
591
|
+
/**
|
|
592
|
+
* Gets the requirements for raising a dispute, including balance check.
|
|
593
|
+
*
|
|
594
|
+
* @param userAddress The address to check balance for.
|
|
595
|
+
* @returns A promise that resolves with the dispute requirements.
|
|
596
|
+
*
|
|
597
|
+
* @example
|
|
598
|
+
* ```typescript
|
|
599
|
+
* const requirements = await origin.getDisputeRequirements(walletAddress);
|
|
600
|
+
* if (!requirements.hasSufficientBalance) {
|
|
601
|
+
* console.log(`Need ${requirements.totalRequired} but only have ${requirements.userBalance}`);
|
|
602
|
+
* }
|
|
603
|
+
* ```
|
|
604
|
+
*/
|
|
605
|
+
declare function getDisputeRequirements(this: Origin, userAddress: Address): Promise<DisputeRequirements>;
|
|
606
|
+
|
|
509
607
|
/**
|
|
510
608
|
* Fractionalizes an IP NFT into fungible ERC20 tokens.
|
|
511
609
|
* The NFT is transferred to the fractionalizer contract and a new ERC20 token is created.
|
|
@@ -865,7 +963,9 @@ declare class Origin {
|
|
|
865
963
|
buildPurchaseParams: typeof buildPurchaseParams;
|
|
866
964
|
checkActiveStatus: typeof checkActiveStatus;
|
|
867
965
|
raiseDispute: typeof raiseDispute;
|
|
966
|
+
raiseDisputeSmart: typeof raiseDisputeSmart;
|
|
868
967
|
disputeAssertion: typeof disputeAssertion;
|
|
968
|
+
disputeAssertionSmart: typeof disputeAssertionSmart;
|
|
869
969
|
voteOnDispute: typeof voteOnDispute;
|
|
870
970
|
resolveDispute: typeof resolveDispute;
|
|
871
971
|
cancelDispute: typeof cancelDispute;
|
|
@@ -873,6 +973,7 @@ declare class Origin {
|
|
|
873
973
|
getDispute: typeof getDispute;
|
|
874
974
|
canVoteOnDispute: typeof canVoteOnDispute;
|
|
875
975
|
getDisputeProgress: typeof getDisputeProgress;
|
|
976
|
+
getDisputeRequirements: typeof getDisputeRequirements;
|
|
876
977
|
fractionalize: typeof fractionalize;
|
|
877
978
|
redeem: typeof redeem;
|
|
878
979
|
getTokenForNFT: typeof getTokenForNFT;
|
|
@@ -889,6 +990,21 @@ declare class Origin {
|
|
|
889
990
|
constructor(environment?: Environment | string, jwt?: string, viemClient?: WalletClient, baseParentId?: bigint, appId?: string);
|
|
890
991
|
getJwt(): string | undefined;
|
|
891
992
|
setViemClient(client: WalletClient): void;
|
|
993
|
+
/**
|
|
994
|
+
* Approves an ERC20 token for spending by a spender address if the current allowance is insufficient.
|
|
995
|
+
* Waits for the approval transaction to be confirmed before returning.
|
|
996
|
+
* @param tokenAddress The address of the ERC20 token.
|
|
997
|
+
* @param spender The address that will be approved to spend the tokens.
|
|
998
|
+
* @param amount The amount of tokens to approve.
|
|
999
|
+
*/
|
|
1000
|
+
approveERC20IfNeeded(tokenAddress: Address, spender: Address, amount: bigint): Promise<void>;
|
|
1001
|
+
/**
|
|
1002
|
+
* Uploads a JSON object to IPFS and returns the resulting CID.
|
|
1003
|
+
* @param data The JSON object to upload.
|
|
1004
|
+
* @returns The CID of the uploaded JSON.
|
|
1005
|
+
* @throws {APIError} If the upload fails.
|
|
1006
|
+
*/
|
|
1007
|
+
uploadJSONToIPFS(data: Record<string, any>): Promise<string>;
|
|
892
1008
|
/**
|
|
893
1009
|
* Mints a file-based IpNFT.
|
|
894
1010
|
* @param file The file to mint.
|
|
@@ -1032,6 +1148,7 @@ declare class Auth {
|
|
|
1032
1148
|
#private;
|
|
1033
1149
|
redirectUri: Record<string, string>;
|
|
1034
1150
|
clientId: string;
|
|
1151
|
+
appId: string;
|
|
1035
1152
|
isAuthenticated: boolean;
|
|
1036
1153
|
jwt: string | null;
|
|
1037
1154
|
walletAddress: string | null;
|
|
@@ -1049,8 +1166,9 @@ declare class Auth {
|
|
|
1049
1166
|
* @param {StorageAdapter} [options.storage] Custom storage adapter. Defaults to localStorage in browser, memory storage in Node.js.
|
|
1050
1167
|
* @throws {APIError} - Throws an error if the clientId is not provided.
|
|
1051
1168
|
*/
|
|
1052
|
-
constructor({ clientId, redirectUri, environment, baseParentId, storage, }: {
|
|
1169
|
+
constructor({ clientId, appId, redirectUri, environment, baseParentId, storage, }: {
|
|
1053
1170
|
clientId: string;
|
|
1171
|
+
appId: string;
|
|
1054
1172
|
redirectUri: string | Record<string, string>;
|
|
1055
1173
|
environment?: "DEVELOPMENT" | "PRODUCTION";
|
|
1056
1174
|
baseParentId?: bigint;
|
|
@@ -1258,8 +1376,9 @@ declare const CampContext: React.Context<CampContextType>;
|
|
|
1258
1376
|
* @param {string} props.environment The environment to use ("DEVELOPMENT" or "PRODUCTION")
|
|
1259
1377
|
* @returns {JSX.Element} The CampProvider component
|
|
1260
1378
|
*/
|
|
1261
|
-
declare const CampProvider: ({ clientId, redirectUri, children, environment, baseParentId, }: {
|
|
1379
|
+
declare const CampProvider: ({ clientId, appId, redirectUri, children, environment, baseParentId, }: {
|
|
1262
1380
|
clientId: string;
|
|
1381
|
+
appId: string;
|
|
1263
1382
|
redirectUri?: string;
|
|
1264
1383
|
children: React.ReactNode;
|
|
1265
1384
|
environment?: "DEVELOPMENT" | "PRODUCTION";
|