@campnetwork/origin 1.3.0-alpha.9 → 1.3.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 CHANGED
@@ -328,7 +328,7 @@ import { ethers } from "ethers";
328
328
 
329
329
  // Setup ethers provider and signer
330
330
  const provider = new ethers.JsonRpcProvider(
331
- process.env.RPC_URL || campMainnet.rpcUrls.default.http[0]
331
+ process.env.RPC_URL || campMainnet.rpcUrls.default.http[0],
332
332
  );
333
333
  const signer = new ethers.Wallet(process.env.PRIVATE_KEY, provider);
334
334
 
@@ -367,7 +367,7 @@ const account = privateKeyToAccount(process.env.PRIVATE_KEY);
367
367
  const client = createNodeWalletClient(
368
368
  account,
369
369
  campMainnet,
370
- process.env.RPC_URL || campMainnet.rpcUrls.default.http[0]
370
+ process.env.RPC_URL || campMainnet.rpcUrls.default.http[0],
371
371
  );
372
372
 
373
373
  // Create Auth instance
@@ -529,7 +529,7 @@ createRoot(document.getElementById("root")).render(
529
529
  <App />
530
530
  </CampProvider>
531
531
  </QueryClientProvider>
532
- </StrictMode>
532
+ </StrictMode>,
533
533
  );
534
534
  ```
535
535
 
@@ -1053,14 +1053,30 @@ interface TokenInfo {
1053
1053
  }
1054
1054
  ```
1055
1055
 
1056
+ #### `BulkMintFileEntry`
1057
+
1058
+ An entry for the `bulkMintFile` method:
1059
+
1060
+ ```typescript
1061
+ interface BulkMintFileEntry {
1062
+ file: File; // The file to mint as an IpNFT
1063
+ metadata: Record<string, unknown>; // Metadata (name, description, etc.)
1064
+ license: LicenseTerms; // License terms for this entry
1065
+ parents?: bigint[]; // Optional parent token IDs for derivatives
1066
+ previewImage?: File | null; // Optional preview image
1067
+ useAssetAsPreview?: boolean; // Use the asset itself as preview (images only)
1068
+ }
1069
+ ```
1070
+
1056
1071
  ### Minting Constraints
1057
1072
 
1058
1073
  When minting or updating an IpNFT, the following constraints apply to the `LicenseTerms`:
1059
1074
 
1060
1075
  - The price must be at least `1000000000000000` wei (0.001 $CAMP).
1061
1076
  - The royaltyBps must be between `1` and `10000` (0.01% to 100%).
1077
+ - The paymentToken must be either `address(0)` (native currency) or the wCAMP token address.
1062
1078
  - For `DURATION_BASED` licenses, the duration must be between `86400` seconds and `2628000` seconds (1 day to 30 days).
1063
- - For `SINGLE_PAYMENT` and `X402` licenses, duration must be `0`.
1079
+ - For `SINGLE_PAYMENT` and `X402` licenses, duration **must** be `0`. Setting a non-zero duration will cause the transaction to revert.
1064
1080
 
1065
1081
  ### `createLicenseTerms(price, duration, royaltyBps, paymentToken, licenseType?)`
1066
1082
 
@@ -1085,7 +1101,7 @@ const subscriptionLicense = createLicenseTerms(
1085
1101
  BigInt("1000000000000000"), // 0.001 CAMP in wei
1086
1102
  86400, // 1 day in seconds
1087
1103
  1000, // 10% royalty (1000 basis points)
1088
- zeroAddress // Native currency (CAMP)
1104
+ zeroAddress, // Native currency (CAMP)
1089
1105
  );
1090
1106
 
1091
1107
  // Create single payment license (perpetual access)
@@ -1094,7 +1110,7 @@ const perpetualLicense = createLicenseTerms(
1094
1110
  0, // Duration must be 0 for single payment
1095
1111
  500, // 5% royalty
1096
1112
  zeroAddress,
1097
- LicenseType.SINGLE_PAYMENT
1113
+ LicenseType.SINGLE_PAYMENT,
1098
1114
  );
1099
1115
 
1100
1116
  // Use with minting functions
@@ -1130,14 +1146,59 @@ Mints an IpNFT for a connected social account.
1130
1146
  - `license`: LicenseTerms object
1131
1147
  - **Returns:** Minted token ID as a string, or throws on failure
1132
1148
 
1149
+ #### `bulkMintFile(entries, options?)`
1150
+
1151
+ Mints multiple file-based IpNFTs in a single transaction using the BatchOperations contract. Each file is uploaded and registered individually, then all mints are batched into one on-chain call.
1152
+
1153
+ - `entries`: Array of `BulkMintFileEntry` objects
1154
+ - `options.tolerant`: When `true`, individual mints can fail without reverting the entire transaction (default: `false`)
1155
+ - `options.progressCallback`: Optional callback for tracking progress
1156
+ - `fileIndex`: Current file index (0-based)
1157
+ - `fileCount`: Total number of files
1158
+ - `stage`: `"uploading"` or `"registering"`
1159
+ - `percent`: Progress percentage (0-100)
1160
+ - **Returns:** `{ tokenIds: string[], result: any }` — array of minted token IDs and the transaction result
1161
+
1162
+ **Example:**
1163
+
1164
+ ```typescript
1165
+ import { createLicenseTerms, LicenseType } from "@campnetwork/origin";
1166
+ import { zeroAddress } from "viem";
1167
+
1168
+ const license = createLicenseTerms(
1169
+ BigInt("2000000000000000"), // 0.002 CAMP
1170
+ 0, // duration must be 0 for SINGLE_PAYMENT
1171
+ 10, // 0.1% royalty
1172
+ zeroAddress,
1173
+ LicenseType.SINGLE_PAYMENT,
1174
+ );
1175
+
1176
+ const result = await auth.origin.bulkMintFile(
1177
+ [
1178
+ { file: file1, metadata: { name: "Asset 1" }, license },
1179
+ { file: file2, metadata: { name: "Asset 2" }, license },
1180
+ ],
1181
+ {
1182
+ tolerant: false,
1183
+ progressCallback: ({ fileIndex, fileCount, stage, percent }) => {
1184
+ console.log(`[${fileIndex + 1}/${fileCount}] ${stage}: ${percent}%`);
1185
+ },
1186
+ },
1187
+ );
1188
+
1189
+ console.log("Minted token IDs:", result.tokenIds);
1190
+ ```
1191
+
1133
1192
  ### IpNFT & Marketplace Methods
1134
1193
 
1135
1194
  Most methods mirror smart contract functions and require appropriate permissions.
1136
1195
 
1137
1196
  #### Core IpNFT Methods
1138
1197
 
1139
- - `mintWithSignature(to, tokenId, parents, isIp, hash, uri, license, deadline, signature, appId?)` — Mint with a backend signature.
1198
+ - `mintWithSignature(to, tokenId, parents, isIp, hash, uri, license, deadline, signature, appId?)` — Mint with a backend signature
1140
1199
  - `registerIpNFT(source, deadline, license, metadata, fileKey?, parents?)` — Register IP with backend
1200
+ - `bulkMint(mints)` — Low-level atomic bulk mint via BatchOperations (all succeed or all fail)
1201
+ - `bulkMintTolerant(mints)` — Low-level tolerant bulk mint (partial success allowed, returns success/failure counts)
1141
1202
  - `updateTerms(tokenId, license)` — Update license terms
1142
1203
  - `finalizeDelete(tokenId)` — Finalize deletion of an IP NFT
1143
1204
  - `getOrCreateRoyaltyVault(tokenId)` — Get or create Token Bound Account for royalties
@@ -1276,7 +1337,7 @@ const disputeTag = keccak256(toBytes("copyright_infringement"));
1276
1337
  const result = await auth.origin.raiseDispute(
1277
1338
  1n, // Token ID to dispute
1278
1339
  evidenceHash,
1279
- disputeTag
1340
+ disputeTag,
1280
1341
  );
1281
1342
 
1282
1343
  // Check if you can vote before voting
@@ -1299,13 +1360,17 @@ if (eligibility.canVote) {
1299
1360
  // Get detailed dispute progress
1300
1361
  const progress = await auth.origin.getDisputeProgress(disputeId);
1301
1362
  console.log(`Yes: ${progress.yesPercentage}% | No: ${progress.noPercentage}%`);
1302
- console.log(`Quorum: ${progress.quorumPercentage}% (${progress.quorumMet ? "met" : "not met"})`);
1363
+ console.log(
1364
+ `Quorum: ${progress.quorumPercentage}% (${progress.quorumMet ? "met" : "not met"})`,
1365
+ );
1303
1366
  console.log(`Projected outcome: ${progress.projectedOutcome}`);
1304
1367
 
1305
1368
  if (progress.timeline.canResolveNow) {
1306
1369
  await auth.origin.resolveDispute(disputeId);
1307
1370
  } else {
1308
- console.log(`Can resolve in ${progress.timeline.timeUntilResolution} seconds`);
1371
+ console.log(
1372
+ `Can resolve in ${progress.timeline.timeUntilResolution} seconds`,
1373
+ );
1309
1374
  }
1310
1375
  ```
1311
1376