@campnetwork/origin 1.4.0-alpha.6 → 1.4.0-alpha.8
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 +56 -1
- package/dist/core.cjs +46 -33
- package/dist/core.d.ts +11 -2
- package/dist/core.esm.d.ts +11 -2
- package/dist/core.esm.js +15 -2
- package/dist/react/index.esm.d.ts +11 -2
- package/dist/react/index.esm.js +73 -6
- package/package.json +1 -1
package/dist/react/index.esm.js
CHANGED
|
@@ -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: "
|
|
6616
|
-
MARKETPLACE_CONTRACT_ADDRESS: "
|
|
6617
|
-
BATCH_OPERATIONS_CONTRACT_ADDRESS: "
|
|
6618
|
-
DISPUTE_CONTRACT_ADDRESS: "
|
|
6619
|
-
APP_REGISTRY_CONTRACT_ADDRESS: "
|
|
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,
|
|
@@ -6903,7 +6904,7 @@ function mintWithSignature(to, tokenId, parents, isIp, hash, uri, licenseTerms,
|
|
|
6903
6904
|
* @param parents The IDs of the parent NFTs, if applicable.
|
|
6904
6905
|
* @return A promise that resolves with the registration data.
|
|
6905
6906
|
*/
|
|
6906
|
-
function registerIpNFT(source, deadline, licenseTerms, metadata, isIp, fileKey, parents, appId) {
|
|
6907
|
+
function registerIpNFT(source, deadline, licenseTerms, metadata, isIp, fileKey, parents, appId, endpointURL) {
|
|
6907
6908
|
return __awaiter(this, void 0, void 0, function* () {
|
|
6908
6909
|
var _a;
|
|
6909
6910
|
const effectiveAppId = (_a = appId !== null && appId !== void 0 ? appId : this.appId) !== null && _a !== void 0 ? _a : "";
|
|
@@ -6925,6 +6926,9 @@ function registerIpNFT(source, deadline, licenseTerms, metadata, isIp, fileKey,
|
|
|
6925
6926
|
if (fileKey !== undefined) {
|
|
6926
6927
|
body.fileKey = fileKey;
|
|
6927
6928
|
}
|
|
6929
|
+
if (endpointURL && endpointURL !== "") {
|
|
6930
|
+
body.endpointURL = endpointURL;
|
|
6931
|
+
}
|
|
6928
6932
|
const res = yield fetch(`${this.environment.AUTH_HUB_BASE_API}/origin/register`, {
|
|
6929
6933
|
method: "POST",
|
|
6930
6934
|
headers: {
|
|
@@ -9217,6 +9221,69 @@ class Origin {
|
|
|
9217
9221
|
return tokenId.toString();
|
|
9218
9222
|
});
|
|
9219
9223
|
}
|
|
9224
|
+
/**
|
|
9225
|
+
* Mints a API-based IpNFT.
|
|
9226
|
+
* @param endpointURL The API endpoint to mint as IP.
|
|
9227
|
+
* @param metadata The metadata associated with the API.
|
|
9228
|
+
* @param license The license terms for the IpNFT.
|
|
9229
|
+
* @param parents Optional parent token IDs for lineage tracking.
|
|
9230
|
+
* @return The token ID of the minted IpNFT as a string, or null if minting failed.
|
|
9231
|
+
*/
|
|
9232
|
+
mintAPI(endpointURL, metadata, license, parents) {
|
|
9233
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
9234
|
+
let account = null;
|
|
9235
|
+
try {
|
|
9236
|
+
account = yield __classPrivateFieldGet(this, _Origin_instances, "m", _Origin_getCurrentAccount).call(this);
|
|
9237
|
+
}
|
|
9238
|
+
catch (error) {
|
|
9239
|
+
throw new WalletError(`Cannot mint API: wallet not connected. Please connect a wallet first.`);
|
|
9240
|
+
}
|
|
9241
|
+
try {
|
|
9242
|
+
new URL(endpointURL);
|
|
9243
|
+
}
|
|
9244
|
+
catch (_a) {
|
|
9245
|
+
throw new Error(`Invalid URL provided: ${endpointURL}`);
|
|
9246
|
+
}
|
|
9247
|
+
if (license.licenseType !== 2) {
|
|
9248
|
+
throw new Error('Only x402 license supported for minting API');
|
|
9249
|
+
}
|
|
9250
|
+
metadata.mimetype = "api";
|
|
9251
|
+
const deadline = BigInt(Math.floor(Date.now() / 1000) + 600); // 10 minutes from now
|
|
9252
|
+
if (this.baseParentId) {
|
|
9253
|
+
if (!parents) {
|
|
9254
|
+
parents = [];
|
|
9255
|
+
}
|
|
9256
|
+
parents.unshift(this.baseParentId);
|
|
9257
|
+
}
|
|
9258
|
+
let registration;
|
|
9259
|
+
try {
|
|
9260
|
+
registration = yield this.registerIpNFT("api", deadline, license, metadata, true, // isIp
|
|
9261
|
+
undefined, // fileKey
|
|
9262
|
+
parents, this.appId, endpointURL);
|
|
9263
|
+
}
|
|
9264
|
+
catch (error) {
|
|
9265
|
+
throw new Error(`Failed to register API IpNFT: ${error instanceof Error ? error.message : String(error)}`);
|
|
9266
|
+
}
|
|
9267
|
+
const { tokenId, signerAddress, creatorContentHash, signature, uri } = registration;
|
|
9268
|
+
if (!tokenId ||
|
|
9269
|
+
!signerAddress ||
|
|
9270
|
+
!creatorContentHash ||
|
|
9271
|
+
signature === undefined ||
|
|
9272
|
+
!uri) {
|
|
9273
|
+
throw new Error("Failed to register API IpNFT: Missing required fields in registration response.");
|
|
9274
|
+
}
|
|
9275
|
+
try {
|
|
9276
|
+
const mintResult = yield this.mintWithSignature(account, tokenId, parents || [], true, creatorContentHash, uri, license, deadline, signature, this.appId);
|
|
9277
|
+
if (["0x1", "success"].indexOf(mintResult.receipt.status) === -1) {
|
|
9278
|
+
throw new Error(`Minting API IpNFT failed with status: ${mintResult.receipt.status}`);
|
|
9279
|
+
}
|
|
9280
|
+
}
|
|
9281
|
+
catch (error) {
|
|
9282
|
+
throw new Error(`Minting transaction failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
9283
|
+
}
|
|
9284
|
+
return tokenId.toString();
|
|
9285
|
+
});
|
|
9286
|
+
}
|
|
9220
9287
|
/**
|
|
9221
9288
|
* Call a contract method.
|
|
9222
9289
|
* @param {string} contractAddress The contract address.
|