@campnetwork/origin 1.4.0-alpha.7 → 1.4.0-alpha.9

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.
@@ -114,9 +114,9 @@ interface TokenInfo {
114
114
  }
115
115
  /**
116
116
  * Represents the source of an IpNFT.
117
- * This can be one of the supported social media platforms or a file upload.
117
+ * This can be one of the supported social media platforms, a file upload, or a GitHub repository.
118
118
  */
119
- type IpNFTSource = "spotify" | "twitter" | "tiktok" | "file" | "api";
119
+ type IpNFTSource = "spotify" | "twitter" | "tiktok" | "file" | "api" | "repo";
120
120
 
121
121
  /**
122
122
  * Mints a Data NFT with a signature.
@@ -1083,6 +1083,16 @@ declare class Origin {
1083
1083
  * @return The token ID of the minted IpNFT as a string, or null if minting failed.
1084
1084
  */
1085
1085
  mintAPI(endpointURL: string, metadata: Record<string, unknown>, license: LicenseTerms, parents?: bigint[]): Promise<string | null>;
1086
+ /**
1087
+ * Mints a GitHub repository as an IpNFT.
1088
+ * @param githubOwner The GitHub owner (user or organization).
1089
+ * @param githubRepo The GitHub repository name.
1090
+ * @param metadata The metadata associated with the repository.
1091
+ * @param license The license terms for the IpNFT.
1092
+ * @param parents Optional parent token IDs for lineage tracking.
1093
+ * @return The token ID of the minted IpNFT as a string, or null if minting failed.
1094
+ */
1095
+ mintRepo(githubOwner: string, githubRepo: string, metadata: Record<string, unknown>, license: LicenseTerms, parents?: bigint[]): Promise<string | null>;
1086
1096
  /**
1087
1097
  * Call a contract method.
1088
1098
  * @param {string} contractAddress The contract address.
@@ -6611,12 +6611,13 @@ const ENVIRONMENTS = {
6611
6611
  DEVELOPMENT: {
6612
6612
  NAME: "DEVELOPMENT",
6613
6613
  AUTH_HUB_BASE_API: "https://origin-backend-iota.vercel.app",
6614
+ // AUTH_HUB_BASE_API: "http://localhost:4001",
6614
6615
  ORIGIN_DASHBOARD: "https://origin.campnetwork.xyz",
6615
- DATANFT_CONTRACT_ADDRESS: "0x4d9aF5800701A4A686Df6b096A27B81486de36eB",
6616
- MARKETPLACE_CONTRACT_ADDRESS: "0x68B202caA162C418d3A2DF92F29fA1CAF90C58c1",
6617
- BATCH_OPERATIONS_CONTRACT_ADDRESS: "0xe1247F1663925B99Db62e60480B53e37f2bb8738",
6618
- DISPUTE_CONTRACT_ADDRESS: "0x45719337b1450b0D105cA671972be4263E6A9380",
6619
- APP_REGISTRY_CONTRACT_ADDRESS: "0x2096eb980Dd590DDF690Cb698572b80552B6F9Bb",
6616
+ DATANFT_CONTRACT_ADDRESS: "0x36262f0aBa3133250D5d2F4Fc28C2Ce3CAC848e1",
6617
+ MARKETPLACE_CONTRACT_ADDRESS: "0xab47f44B449e718386d016b6e0Cf692565bd4435",
6618
+ BATCH_OPERATIONS_CONTRACT_ADDRESS: "0x3095A7B316aF3adA2c4e2b106ADE891Df05e0790",
6619
+ DISPUTE_CONTRACT_ADDRESS: "0x2ad44AfC60ECAFB932c2A7457D356862DDCE9C84",
6620
+ APP_REGISTRY_CONTRACT_ADDRESS: "0x50bCC8f2d8aE74acC69Dcf61d17B11a119d5CC04",
6620
6621
  IP_ROYALTY_VAULT_FACTORY_CONTRACT_ADDRESS: "0x16e01D1CB5de9460f8ed9D1883f5aFD377798f38",
6621
6622
  CHAIN: testnet,
6622
6623
  IPNFT_ABI: ipnftMainnetAbi,
@@ -9283,6 +9284,66 @@ class Origin {
9283
9284
  return tokenId.toString();
9284
9285
  });
9285
9286
  }
9287
+ /**
9288
+ * Mints a GitHub repository as an IpNFT.
9289
+ * @param githubOwner The GitHub owner (user or organization).
9290
+ * @param githubRepo The GitHub repository name.
9291
+ * @param metadata The metadata associated with the repository.
9292
+ * @param license The license terms for the IpNFT.
9293
+ * @param parents Optional parent token IDs for lineage tracking.
9294
+ * @return The token ID of the minted IpNFT as a string, or null if minting failed.
9295
+ */
9296
+ mintRepo(githubOwner, githubRepo, metadata, license, parents) {
9297
+ return __awaiter(this, void 0, void 0, function* () {
9298
+ let account = null;
9299
+ try {
9300
+ account = yield __classPrivateFieldGet(this, _Origin_instances, "m", _Origin_getCurrentAccount).call(this);
9301
+ }
9302
+ catch (error) {
9303
+ throw new WalletError(`Cannot mint repository: wallet not connected. Please connect a wallet first.`);
9304
+ }
9305
+ if (!githubOwner || !githubRepo) {
9306
+ throw new ValidationError("GitHub owner and repository name are required.");
9307
+ }
9308
+ metadata.mimetype = "git/repository";
9309
+ metadata.githubOwner = githubOwner;
9310
+ metadata.githubRepo = githubRepo;
9311
+ const deadline = BigInt(Math.floor(Date.now() / 1000) + 600);
9312
+ if (this.baseParentId) {
9313
+ if (!parents) {
9314
+ parents = [];
9315
+ }
9316
+ parents.unshift(this.baseParentId);
9317
+ }
9318
+ let registration;
9319
+ try {
9320
+ registration = yield this.registerIpNFT("repo", deadline, license, metadata, true, // isIp
9321
+ undefined, // fileKey
9322
+ parents, this.appId);
9323
+ }
9324
+ catch (error) {
9325
+ throw new Error(`Failed to register Repository IpNFT: ${error instanceof Error ? error.message : String(error)}`);
9326
+ }
9327
+ const { tokenId, signerAddress, creatorContentHash, signature, uri } = registration;
9328
+ if (!tokenId ||
9329
+ !signerAddress ||
9330
+ !creatorContentHash ||
9331
+ signature === undefined ||
9332
+ !uri) {
9333
+ throw new Error("Failed to register Repository IpNFT: Missing required fields in registration response.");
9334
+ }
9335
+ try {
9336
+ const mintResult = yield this.mintWithSignature(account, tokenId, parents || [], true, creatorContentHash, uri, license, deadline, signature, this.appId);
9337
+ if (["0x1", "success"].indexOf(mintResult.receipt.status) === -1) {
9338
+ throw new Error(`Minting Repository IpNFT failed with status: ${mintResult.receipt.status}`);
9339
+ }
9340
+ }
9341
+ catch (error) {
9342
+ throw new Error(`Minting transaction failed: ${error instanceof Error ? error.message : String(error)}`);
9343
+ }
9344
+ return tokenId.toString();
9345
+ });
9346
+ }
9286
9347
  /**
9287
9348
  * Call a contract method.
9288
9349
  * @param {string} contractAddress The contract address.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@campnetwork/origin",
3
- "version": "1.4.0-alpha.7",
3
+ "version": "1.4.0-alpha.9",
4
4
  "main": "dist/core.cjs",
5
5
  "exports": {
6
6
  ".": {