@campnetwork/origin 1.4.0-alpha.8 → 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.
- package/dist/core.cjs +44 -33
- package/dist/core.d.ts +12 -2
- package/dist/core.esm.d.ts +12 -2
- package/dist/core.esm.js +53 -42
- package/dist/react/index.esm.d.ts +12 -2
- package/dist/react/index.esm.js +60 -0
- package/package.json +1 -1
|
@@ -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
|
|
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.
|
package/dist/react/index.esm.js
CHANGED
|
@@ -9284,6 +9284,66 @@ class Origin {
|
|
|
9284
9284
|
return tokenId.toString();
|
|
9285
9285
|
});
|
|
9286
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
|
+
}
|
|
9287
9347
|
/**
|
|
9288
9348
|
* Call a contract method.
|
|
9289
9349
|
* @param {string} contractAddress The contract address.
|