@campnetwork/origin 0.0.8 → 0.0.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 +32 -31
- package/dist/core.d.ts +4 -3
- package/dist/core.esm.d.ts +4 -3
- package/dist/core.esm.js +52 -51
- package/dist/react/index.esm.d.ts +4 -3
- package/dist/react/index.esm.js +105 -12
- package/package.json +1 -1
package/dist/react/index.esm.js
CHANGED
|
@@ -164,8 +164,8 @@ var constants = {
|
|
|
164
164
|
TIKTOK_LINKED: "4a2ffdd3-f0e9-4784-8b49-ff76ec1c0a6a",
|
|
165
165
|
TELEGRAM_LINKED: "9006bc5d-bcc9-4d01-a860-4f1a201e8e47",
|
|
166
166
|
},
|
|
167
|
-
DATANFT_CONTRACT_ADDRESS: "
|
|
168
|
-
MARKETPLACE_CONTRACT_ADDRESS: "
|
|
167
|
+
DATANFT_CONTRACT_ADDRESS: "0xF90733b9eCDa3b49C250B2C3E3E42c96fC93324E",
|
|
168
|
+
MARKETPLACE_CONTRACT_ADDRESS: "0x5c5e6b458b2e3924E7688b8Dee1Bb49088F6Fef5",
|
|
169
169
|
};
|
|
170
170
|
|
|
171
171
|
let providers = [];
|
|
@@ -256,13 +256,23 @@ var abi$1 = [
|
|
|
256
256
|
inputs: [
|
|
257
257
|
{
|
|
258
258
|
internalType: "string",
|
|
259
|
-
name: "
|
|
259
|
+
name: "name_",
|
|
260
260
|
type: "string"
|
|
261
261
|
},
|
|
262
262
|
{
|
|
263
263
|
internalType: "string",
|
|
264
|
-
name: "
|
|
264
|
+
name: "symbol_",
|
|
265
265
|
type: "string"
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
internalType: "uint256",
|
|
269
|
+
name: "maxTermDuration_",
|
|
270
|
+
type: "uint256"
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
internalType: "address",
|
|
274
|
+
name: "signer_",
|
|
275
|
+
type: "address"
|
|
266
276
|
}
|
|
267
277
|
],
|
|
268
278
|
stateMutability: "nonpayable",
|
|
@@ -395,6 +405,12 @@ var abi$1 = [
|
|
|
395
405
|
name: "InvalidDeadline",
|
|
396
406
|
type: "error"
|
|
397
407
|
},
|
|
408
|
+
{
|
|
409
|
+
inputs: [
|
|
410
|
+
],
|
|
411
|
+
name: "InvalidDuration",
|
|
412
|
+
type: "error"
|
|
413
|
+
},
|
|
398
414
|
{
|
|
399
415
|
inputs: [
|
|
400
416
|
{
|
|
@@ -916,6 +932,20 @@ var abi$1 = [
|
|
|
916
932
|
stateMutability: "view",
|
|
917
933
|
type: "function"
|
|
918
934
|
},
|
|
935
|
+
{
|
|
936
|
+
inputs: [
|
|
937
|
+
],
|
|
938
|
+
name: "maxTermDuration",
|
|
939
|
+
outputs: [
|
|
940
|
+
{
|
|
941
|
+
internalType: "uint256",
|
|
942
|
+
name: "",
|
|
943
|
+
type: "uint256"
|
|
944
|
+
}
|
|
945
|
+
],
|
|
946
|
+
stateMutability: "view",
|
|
947
|
+
type: "function"
|
|
948
|
+
},
|
|
919
949
|
{
|
|
920
950
|
inputs: [
|
|
921
951
|
{
|
|
@@ -928,6 +958,11 @@ var abi$1 = [
|
|
|
928
958
|
name: "tokenId",
|
|
929
959
|
type: "uint256"
|
|
930
960
|
},
|
|
961
|
+
{
|
|
962
|
+
internalType: "uint256",
|
|
963
|
+
name: "parentId",
|
|
964
|
+
type: "uint256"
|
|
965
|
+
},
|
|
931
966
|
{
|
|
932
967
|
internalType: "bytes32",
|
|
933
968
|
name: "creatorContentHash",
|
|
@@ -1029,6 +1064,25 @@ var abi$1 = [
|
|
|
1029
1064
|
stateMutability: "view",
|
|
1030
1065
|
type: "function"
|
|
1031
1066
|
},
|
|
1067
|
+
{
|
|
1068
|
+
inputs: [
|
|
1069
|
+
{
|
|
1070
|
+
internalType: "uint256",
|
|
1071
|
+
name: "",
|
|
1072
|
+
type: "uint256"
|
|
1073
|
+
}
|
|
1074
|
+
],
|
|
1075
|
+
name: "parentIpOf",
|
|
1076
|
+
outputs: [
|
|
1077
|
+
{
|
|
1078
|
+
internalType: "uint256",
|
|
1079
|
+
name: "",
|
|
1080
|
+
type: "uint256"
|
|
1081
|
+
}
|
|
1082
|
+
],
|
|
1083
|
+
stateMutability: "view",
|
|
1084
|
+
type: "function"
|
|
1085
|
+
},
|
|
1032
1086
|
{
|
|
1033
1087
|
inputs: [
|
|
1034
1088
|
],
|
|
@@ -1200,6 +1254,34 @@ var abi$1 = [
|
|
|
1200
1254
|
stateMutability: "nonpayable",
|
|
1201
1255
|
type: "function"
|
|
1202
1256
|
},
|
|
1257
|
+
{
|
|
1258
|
+
inputs: [
|
|
1259
|
+
{
|
|
1260
|
+
internalType: "address",
|
|
1261
|
+
name: "_signer",
|
|
1262
|
+
type: "address"
|
|
1263
|
+
}
|
|
1264
|
+
],
|
|
1265
|
+
name: "setSigner",
|
|
1266
|
+
outputs: [
|
|
1267
|
+
],
|
|
1268
|
+
stateMutability: "nonpayable",
|
|
1269
|
+
type: "function"
|
|
1270
|
+
},
|
|
1271
|
+
{
|
|
1272
|
+
inputs: [
|
|
1273
|
+
],
|
|
1274
|
+
name: "signer",
|
|
1275
|
+
outputs: [
|
|
1276
|
+
{
|
|
1277
|
+
internalType: "address",
|
|
1278
|
+
name: "",
|
|
1279
|
+
type: "address"
|
|
1280
|
+
}
|
|
1281
|
+
],
|
|
1282
|
+
stateMutability: "view",
|
|
1283
|
+
type: "function"
|
|
1284
|
+
},
|
|
1203
1285
|
{
|
|
1204
1286
|
inputs: [
|
|
1205
1287
|
{
|
|
@@ -1404,6 +1486,7 @@ var abi$1 = [
|
|
|
1404
1486
|
* Mints a Data NFT with a signature.
|
|
1405
1487
|
* @param to The address to mint the NFT to.
|
|
1406
1488
|
* @param tokenId The ID of the token to mint.
|
|
1489
|
+
* @param parentId The ID of the parent NFT, if applicable.
|
|
1407
1490
|
* @param hash The hash of the data associated with the NFT.
|
|
1408
1491
|
* @param uri The URI of the NFT metadata.
|
|
1409
1492
|
* @param licenseTerms The terms of the license for the NFT.
|
|
@@ -1411,9 +1494,9 @@ var abi$1 = [
|
|
|
1411
1494
|
* @param signature The signature for the minting operation.
|
|
1412
1495
|
* @returns A promise that resolves when the minting is complete.
|
|
1413
1496
|
*/
|
|
1414
|
-
function mintWithSignature(to, tokenId, hash, uri, licenseTerms, deadline, signature) {
|
|
1497
|
+
function mintWithSignature(to, tokenId, parentId, hash, uri, licenseTerms, deadline, signature) {
|
|
1415
1498
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1416
|
-
return yield this.callContractMethod(constants.DATANFT_CONTRACT_ADDRESS, abi$1, "mintWithSignature", [to, tokenId, hash, uri, licenseTerms, deadline, signature], { waitForReceipt: true });
|
|
1499
|
+
return yield this.callContractMethod(constants.DATANFT_CONTRACT_ADDRESS, abi$1, "mintWithSignature", [to, tokenId, parentId, hash, uri, licenseTerms, deadline, signature], { waitForReceipt: true });
|
|
1417
1500
|
});
|
|
1418
1501
|
}
|
|
1419
1502
|
/**
|
|
@@ -1423,7 +1506,7 @@ function mintWithSignature(to, tokenId, hash, uri, licenseTerms, deadline, signa
|
|
|
1423
1506
|
* @param fileKey Optional file key for file uploads.
|
|
1424
1507
|
* @return A promise that resolves with the registration data.
|
|
1425
1508
|
*/
|
|
1426
|
-
function registerIpNFT(source, deadline, licenseTerms, fileKey) {
|
|
1509
|
+
function registerIpNFT(source, deadline, licenseTerms, metadata, fileKey, parentId) {
|
|
1427
1510
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1428
1511
|
const body = {
|
|
1429
1512
|
source,
|
|
@@ -1434,6 +1517,8 @@ function registerIpNFT(source, deadline, licenseTerms, fileKey) {
|
|
|
1434
1517
|
royaltyBps: licenseTerms.royaltyBps,
|
|
1435
1518
|
paymentToken: licenseTerms.paymentToken,
|
|
1436
1519
|
},
|
|
1520
|
+
metadata,
|
|
1521
|
+
parentId: Number(parentId) || 0,
|
|
1437
1522
|
};
|
|
1438
1523
|
if (fileKey !== undefined) {
|
|
1439
1524
|
body.fileKey = fileKey;
|
|
@@ -2187,7 +2272,7 @@ class Origin {
|
|
|
2187
2272
|
yield __classPrivateFieldGet(this, _Origin_setOriginStatus, "f").call(this, uploadInfo.key, "success");
|
|
2188
2273
|
return uploadInfo;
|
|
2189
2274
|
});
|
|
2190
|
-
this.mintFile = (file, license, options) => __awaiter(this, void 0, void 0, function* () {
|
|
2275
|
+
this.mintFile = (file, metadata, license, parentId, options) => __awaiter(this, void 0, void 0, function* () {
|
|
2191
2276
|
if (!this.viemClient) {
|
|
2192
2277
|
throw new Error("WalletClient not connected.");
|
|
2193
2278
|
}
|
|
@@ -2196,7 +2281,7 @@ class Origin {
|
|
|
2196
2281
|
throw new Error("Failed to upload file or get upload info.");
|
|
2197
2282
|
}
|
|
2198
2283
|
const deadline = BigInt(Math.floor(Date.now()) + 600); // 10 minutes from now
|
|
2199
|
-
const registration = yield this.registerIpNFT("file", deadline, license, info.key);
|
|
2284
|
+
const registration = yield this.registerIpNFT("file", deadline, license, metadata, info.key, parentId);
|
|
2200
2285
|
const { tokenId, signerAddress, creatorContentHash, signature, uri } = registration;
|
|
2201
2286
|
if (!tokenId ||
|
|
2202
2287
|
!signerAddress ||
|
|
@@ -2209,7 +2294,7 @@ class Origin {
|
|
|
2209
2294
|
method: "eth_requestAccounts",
|
|
2210
2295
|
params: [],
|
|
2211
2296
|
});
|
|
2212
|
-
const mintResult = yield this.mintWithSignature(account, tokenId, creatorContentHash, uri, license, deadline, signature);
|
|
2297
|
+
const mintResult = yield this.mintWithSignature(account, tokenId, parentId || BigInt(0), creatorContentHash, uri, license, deadline, signature);
|
|
2213
2298
|
if (mintResult.status !== "0x1") {
|
|
2214
2299
|
throw new Error(`Minting failed with status: ${mintResult.status}`);
|
|
2215
2300
|
}
|
|
@@ -2218,7 +2303,11 @@ class Origin {
|
|
|
2218
2303
|
this.mintSocial = (source, license) => __awaiter(this, void 0, void 0, function* () {
|
|
2219
2304
|
// try {
|
|
2220
2305
|
const deadline = BigInt(Math.floor(Date.now()) + 600); // 10 minutes from now (temp)
|
|
2221
|
-
const
|
|
2306
|
+
const metadata = {
|
|
2307
|
+
name: `${source} IpNFT`,
|
|
2308
|
+
description: `This is a ${source} IpNFT`,
|
|
2309
|
+
};
|
|
2310
|
+
const registration = yield this.registerIpNFT(source, deadline, license, metadata);
|
|
2222
2311
|
if (!registration) {
|
|
2223
2312
|
// console.error("Failed to register IpNFT");
|
|
2224
2313
|
// return null;
|
|
@@ -3933,7 +4022,11 @@ const FileUpload = ({ onFileUpload, accept, maxFileSize, }) => {
|
|
|
3933
4022
|
royaltyBps, // royalty basis points
|
|
3934
4023
|
zeroAddress // payment token
|
|
3935
4024
|
);
|
|
3936
|
-
const
|
|
4025
|
+
const metadata = {
|
|
4026
|
+
name: selectedFile.name,
|
|
4027
|
+
description: `This is a file uploaded by ${auth === null || auth === void 0 ? void 0 : auth.walletAddress}`,
|
|
4028
|
+
};
|
|
4029
|
+
const res = yield ((_a = auth === null || auth === void 0 ? void 0 : auth.origin) === null || _a === void 0 ? void 0 : _a.mintFile(selectedFile, metadata, license, BigInt(0), {
|
|
3937
4030
|
progressCallback(percent) {
|
|
3938
4031
|
setUploadProgress(percent);
|
|
3939
4032
|
},
|