@story-protocol/core-sdk 1.0.0-rc.17 → 1.0.0-rc.18

Sign up to get free protection for your applications and to get access to all the features.
@@ -478,9 +478,9 @@ function _asyncToGenerator(fn) {
478
478
  };
479
479
  }
480
480
 
481
- var storyTestChain = defineChain({
481
+ var iliad = defineChain({
482
482
  id: 1513,
483
- name: "story-testnet",
483
+ name: "iliad",
484
484
  nativeCurrency: {
485
485
  name: "IP",
486
486
  symbol: "IP",
@@ -510,7 +510,7 @@ function chainStringToViemChain(chainId) {
510
510
  switch (chainId) {
511
511
  case "1513":
512
512
  case "iliad":
513
- return storyTestChain;
513
+ return iliad;
514
514
  default:
515
515
  throw new Error("chainId ".concat(chainId, " not supported"));
516
516
  }
@@ -9300,6 +9300,22 @@ var spgAbi = [{
9300
9300
  type: "error",
9301
9301
  inputs: [],
9302
9302
  name: "NotInitializing"
9303
+ }, {
9304
+ type: "error",
9305
+ inputs: [{
9306
+ name: "tokenId",
9307
+ internalType: "uint256",
9308
+ type: "uint256"
9309
+ }, {
9310
+ name: "caller",
9311
+ internalType: "address",
9312
+ type: "address"
9313
+ }, {
9314
+ name: "actualTokenOwner",
9315
+ internalType: "address",
9316
+ type: "address"
9317
+ }],
9318
+ name: "SPG__CallerAndNotTokenOwner"
9303
9319
  }, {
9304
9320
  type: "error",
9305
9321
  inputs: [],
@@ -9613,7 +9629,7 @@ var spgAbi = [{
9613
9629
  internalType: "address",
9614
9630
  type: "address"
9615
9631
  }, {
9616
- name: "mintingFee",
9632
+ name: "defaultMintingFee",
9617
9633
  internalType: "uint256",
9618
9634
  type: "uint256"
9619
9635
  }, {
@@ -9641,7 +9657,7 @@ var spgAbi = [{
9641
9657
  internalType: "uint32",
9642
9658
  type: "uint32"
9643
9659
  }, {
9644
- name: "commercialRevCelling",
9660
+ name: "commercialRevCeiling",
9645
9661
  internalType: "uint256",
9646
9662
  type: "uint256"
9647
9663
  }, {
@@ -9661,7 +9677,7 @@ var spgAbi = [{
9661
9677
  internalType: "bool",
9662
9678
  type: "bool"
9663
9679
  }, {
9664
- name: "derivativeRevCelling",
9680
+ name: "derivativeRevCeiling",
9665
9681
  internalType: "uint256",
9666
9682
  type: "uint256"
9667
9683
  }, {
@@ -9804,6 +9820,32 @@ var spgAbi = [{
9804
9820
  type: "uint256"
9805
9821
  }],
9806
9822
  stateMutability: "nonpayable"
9823
+ }, {
9824
+ type: "function",
9825
+ inputs: [{
9826
+ name: "",
9827
+ internalType: "address",
9828
+ type: "address"
9829
+ }, {
9830
+ name: "",
9831
+ internalType: "address",
9832
+ type: "address"
9833
+ }, {
9834
+ name: "",
9835
+ internalType: "uint256",
9836
+ type: "uint256"
9837
+ }, {
9838
+ name: "",
9839
+ internalType: "bytes",
9840
+ type: "bytes"
9841
+ }],
9842
+ name: "onERC721Received",
9843
+ outputs: [{
9844
+ name: "",
9845
+ internalType: "bytes4",
9846
+ type: "bytes4"
9847
+ }],
9848
+ stateMutability: "nonpayable"
9807
9849
  }, {
9808
9850
  type: "function",
9809
9851
  inputs: [],
@@ -9906,7 +9948,7 @@ var spgAbi = [{
9906
9948
  internalType: "address",
9907
9949
  type: "address"
9908
9950
  }, {
9909
- name: "mintingFee",
9951
+ name: "defaultMintingFee",
9910
9952
  internalType: "uint256",
9911
9953
  type: "uint256"
9912
9954
  }, {
@@ -9934,7 +9976,7 @@ var spgAbi = [{
9934
9976
  internalType: "uint32",
9935
9977
  type: "uint32"
9936
9978
  }, {
9937
- name: "commercialRevCelling",
9979
+ name: "commercialRevCeiling",
9938
9980
  internalType: "uint256",
9939
9981
  type: "uint256"
9940
9982
  }, {
@@ -9954,7 +9996,7 @@ var spgAbi = [{
9954
9996
  internalType: "bool",
9955
9997
  type: "bool"
9956
9998
  }, {
9957
- name: "derivativeRevCelling",
9999
+ name: "derivativeRevCeiling",
9958
10000
  internalType: "uint256",
9959
10001
  type: "uint256"
9960
10002
  }, {
@@ -10198,7 +10240,7 @@ var spgAbi = [{
10198
10240
  internalType: "address",
10199
10241
  type: "address"
10200
10242
  }, {
10201
- name: "mintingFee",
10243
+ name: "defaultMintingFee",
10202
10244
  internalType: "uint256",
10203
10245
  type: "uint256"
10204
10246
  }, {
@@ -10226,7 +10268,7 @@ var spgAbi = [{
10226
10268
  internalType: "uint32",
10227
10269
  type: "uint32"
10228
10270
  }, {
10229
- name: "commercialRevCelling",
10271
+ name: "commercialRevCeiling",
10230
10272
  internalType: "uint256",
10231
10273
  type: "uint256"
10232
10274
  }, {
@@ -10246,7 +10288,7 @@ var spgAbi = [{
10246
10288
  internalType: "bool",
10247
10289
  type: "bool"
10248
10290
  }, {
10249
- name: "derivativeRevCelling",
10291
+ name: "derivativeRevCeiling",
10250
10292
  internalType: "uint256",
10251
10293
  type: "uint256"
10252
10294
  }, {
@@ -18910,11 +18952,7 @@ var IPAssetClient = /*#__PURE__*/function () {
18910
18952
  object = {
18911
18953
  nftContract: getAddress$1(request.nftContract, "request.nftContract"),
18912
18954
  recipient: request.recipient && getAddress$1(request.recipient, "request.recipient") || this.wallet.account.address,
18913
- terms: _objectSpread2(_objectSpread2({}, licenseTerm), {}, {
18914
- mintingFee: BigInt(licenseTerm.defaultMintingFee),
18915
- derivativeRevCelling: licenseTerm.commercialRevCeiling,
18916
- commercialRevCelling: licenseTerm.commercialRevCeiling
18917
- }),
18955
+ terms: licenseTerm,
18918
18956
  ipMetadata: {
18919
18957
  metadataURI: "",
18920
18958
  metadataHash: zeroHash,
@@ -19063,11 +19101,7 @@ var IPAssetClient = /*#__PURE__*/function () {
19063
19101
  object = {
19064
19102
  nftContract: getAddress$1(request.nftContract, "request.nftContract"),
19065
19103
  tokenId: request.tokenId,
19066
- terms: _objectSpread2(_objectSpread2({}, licenseTerm), {}, {
19067
- mintingFee: BigInt(licenseTerm.defaultMintingFee),
19068
- derivativeRevCelling: licenseTerm.commercialRevCeiling,
19069
- commercialRevCelling: licenseTerm.commercialRevCeiling
19070
- }),
19104
+ terms: licenseTerm,
19071
19105
  ipMetadata: {
19072
19106
  metadataURI: "",
19073
19107
  metadataHash: zeroHash,
@@ -19370,31 +19404,160 @@ var IPAssetClient = /*#__PURE__*/function () {
19370
19404
  return _registerDerivativeIp.apply(this, arguments);
19371
19405
  }
19372
19406
  return registerDerivativeIp;
19407
+ }()
19408
+ /**
19409
+ * Mint an NFT from a collection and register it as a derivative IP without license tokens.
19410
+ * @param request - The request object that contains all data needed to mint and register ip and make derivative.
19411
+ * @param request.nftContract The address of the NFT collection.
19412
+ * @param request.derivData The derivative data to be used for registerDerivative.
19413
+ * @param request.derivData.parentIpIds The IDs of the parent IPs to link the registered derivative IP.
19414
+ * @param request.derivData.licenseTermsIds The IDs of the license terms to be used for the linking.
19415
+ * @param request.derivData.licenseTemplate [Optional] The address of the license template to be used for the linking.
19416
+ * @param request.ipMetadata - [Optional] The desired ipMetadata for the newly registered IP.
19417
+ * @param request.ipMetadata.metadataURI [Optional] The URI of the ipMetadata for the IP.
19418
+ * @param request.ipMetadata.metadataHash [Optional] The ipMetadata for the IP.
19419
+ * @param request.ipMetadata.nftMetadataHash [Optional] The the ipMetadata for the IP NFT.
19420
+ * @param request.recipient [Optional] The address of the recipient of the minted NFT.
19421
+ * @param request.txOptions [Optional] The transaction options.
19422
+ * @returns A Promise that resolves to an object containing the transaction hash and optional IP ID if waitForTxn is set to true.
19423
+ * @emits IPRegistered (ipId, chainId, tokenContract, tokenId, name, uri, registrationDate)
19424
+ */
19425
+ )
19426
+ }, {
19427
+ key: "mintAndRegisterIpAndMakeDerivative",
19428
+ value: (function () {
19429
+ var _mintAndRegisterIpAndMakeDerivative = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(request) {
19430
+ var _request$txOptions13, i, isAttachedLicenseTerms, object, _request$txOptions14, txHash, receipt, log;
19431
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
19432
+ while (1) switch (_context7.prev = _context7.next) {
19433
+ case 0:
19434
+ _context7.prev = 0;
19435
+ if (!(request.derivData.parentIpIds.length !== request.derivData.licenseTermsIds.length)) {
19436
+ _context7.next = 3;
19437
+ break;
19438
+ }
19439
+ throw new Error("Parent IP IDs and License terms IDs must be provided in pairs.");
19440
+ case 3:
19441
+ i = 0;
19442
+ case 4:
19443
+ if (!(i < request.derivData.parentIpIds.length)) {
19444
+ _context7.next = 13;
19445
+ break;
19446
+ }
19447
+ _context7.next = 7;
19448
+ return this.licenseRegistryReadOnlyClient.hasIpAttachedLicenseTerms({
19449
+ ipId: getAddress$1(request.derivData.parentIpIds[i], "request.derivData.parentIpIds"),
19450
+ licenseTemplate: request.derivData.licenseTemplate && getAddress$1(request.derivData.licenseTemplate, "request.derivData.licenseTemplate") || this.licenseTemplateClient.address,
19451
+ licenseTermsId: BigInt(request.derivData.licenseTermsIds[i])
19452
+ });
19453
+ case 7:
19454
+ isAttachedLicenseTerms = _context7.sent;
19455
+ if (isAttachedLicenseTerms) {
19456
+ _context7.next = 10;
19457
+ break;
19458
+ }
19459
+ throw new Error("License terms id ".concat(request.derivData.licenseTermsIds[i], " must be attached to the parent ipId ").concat(request.derivData.parentIpIds[i], " before registering derivative."));
19460
+ case 10:
19461
+ i++;
19462
+ _context7.next = 4;
19463
+ break;
19464
+ case 13:
19465
+ object = _objectSpread2(_objectSpread2({}, request), {}, {
19466
+ derivData: _objectSpread2(_objectSpread2({}, request.derivData), {}, {
19467
+ royaltyContext: zeroAddress,
19468
+ licenseTemplate: request.derivData.licenseTemplate || this.licenseTemplateClient.address,
19469
+ licenseTermsIds: request.derivData.licenseTermsIds.map(function (id) {
19470
+ return BigInt(id);
19471
+ })
19472
+ }),
19473
+ nftMetadata: request.nftMetadata || "",
19474
+ ipMetadata: {
19475
+ metadataURI: "",
19476
+ metadataHash: zeroHash,
19477
+ nftMetadataHash: zeroHash
19478
+ },
19479
+ recipient: request.recipient && getAddress$1(request.recipient, "request.recipient") || this.wallet.account.address
19480
+ });
19481
+ if (request.ipMetadata && (request.ipMetadata.metadataHash !== zeroHash || request.ipMetadata.metadataURI !== "" || request.ipMetadata.nftMetadataHash !== zeroHash)) {
19482
+ object.ipMetadata = {
19483
+ metadataURI: request.ipMetadata.metadataURI || object.ipMetadata.metadataURI,
19484
+ metadataHash: request.ipMetadata.metadataHash || object.ipMetadata.metadataHash,
19485
+ nftMetadataHash: request.ipMetadata.nftMetadataHash || object.ipMetadata.nftMetadataHash
19486
+ };
19487
+ }
19488
+ if (!((_request$txOptions13 = request.txOptions) !== null && _request$txOptions13 !== void 0 && _request$txOptions13.encodedTxDataOnly)) {
19489
+ _context7.next = 19;
19490
+ break;
19491
+ }
19492
+ return _context7.abrupt("return", {
19493
+ encodedTxData: this.spgClient.mintAndRegisterIpAndMakeDerivativeEncode(object)
19494
+ });
19495
+ case 19:
19496
+ _context7.next = 21;
19497
+ return this.spgClient.mintAndRegisterIpAndMakeDerivative(object);
19498
+ case 21:
19499
+ txHash = _context7.sent;
19500
+ if (!((_request$txOptions14 = request.txOptions) !== null && _request$txOptions14 !== void 0 && _request$txOptions14.waitForTransaction)) {
19501
+ _context7.next = 28;
19502
+ break;
19503
+ }
19504
+ _context7.next = 25;
19505
+ return this.rpcClient.waitForTransactionReceipt({
19506
+ hash: txHash
19507
+ });
19508
+ case 25:
19509
+ receipt = _context7.sent;
19510
+ log = this.ipAssetRegistryClient.parseTxIpRegisteredEvent(receipt)[0];
19511
+ return _context7.abrupt("return", {
19512
+ txHash: txHash,
19513
+ childIpId: log.ipId
19514
+ });
19515
+ case 28:
19516
+ return _context7.abrupt("return", {
19517
+ txHash: txHash
19518
+ });
19519
+ case 29:
19520
+ _context7.next = 34;
19521
+ break;
19522
+ case 31:
19523
+ _context7.prev = 31;
19524
+ _context7.t0 = _context7["catch"](0);
19525
+ handleError(_context7.t0, "Failed to mint and register IP and make derivative");
19526
+ case 34:
19527
+ case "end":
19528
+ return _context7.stop();
19529
+ }
19530
+ }, _callee7, this, [[0, 31]]);
19531
+ }));
19532
+ function mintAndRegisterIpAndMakeDerivative(_x7) {
19533
+ return _mintAndRegisterIpAndMakeDerivative.apply(this, arguments);
19534
+ }
19535
+ return mintAndRegisterIpAndMakeDerivative;
19373
19536
  }())
19374
19537
  }, {
19375
19538
  key: "getIpIdAddress",
19376
19539
  value: function () {
19377
- var _getIpIdAddress = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(nftContract, tokenId) {
19540
+ var _getIpIdAddress = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(nftContract, tokenId) {
19378
19541
  var ipId;
19379
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
19380
- while (1) switch (_context7.prev = _context7.next) {
19542
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
19543
+ while (1) switch (_context8.prev = _context8.next) {
19381
19544
  case 0:
19382
- _context7.next = 2;
19545
+ _context8.next = 2;
19383
19546
  return this.ipAssetRegistryClient.ipId({
19384
19547
  chainId: chain[this.chainId],
19385
19548
  tokenContract: getAddress$1(nftContract, "nftContract"),
19386
19549
  tokenId: BigInt(tokenId)
19387
19550
  });
19388
19551
  case 2:
19389
- ipId = _context7.sent;
19390
- return _context7.abrupt("return", ipId);
19552
+ ipId = _context8.sent;
19553
+ return _context8.abrupt("return", ipId);
19391
19554
  case 4:
19392
19555
  case "end":
19393
- return _context7.stop();
19556
+ return _context8.stop();
19394
19557
  }
19395
- }, _callee7, this);
19558
+ }, _callee8, this);
19396
19559
  }));
19397
- function getIpIdAddress(_x7, _x8) {
19560
+ function getIpIdAddress(_x8, _x9) {
19398
19561
  return _getIpIdAddress.apply(this, arguments);
19399
19562
  }
19400
19563
  return getIpIdAddress;
@@ -19402,23 +19565,23 @@ var IPAssetClient = /*#__PURE__*/function () {
19402
19565
  }, {
19403
19566
  key: "isRegistered",
19404
19567
  value: function () {
19405
- var _isRegistered = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(ipId) {
19406
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
19407
- while (1) switch (_context8.prev = _context8.next) {
19568
+ var _isRegistered = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(ipId) {
19569
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
19570
+ while (1) switch (_context9.prev = _context9.next) {
19408
19571
  case 0:
19409
- _context8.next = 2;
19572
+ _context9.next = 2;
19410
19573
  return this.ipAssetRegistryClient.isRegistered({
19411
19574
  id: getAddress$1(ipId, "ipId")
19412
19575
  });
19413
19576
  case 2:
19414
- return _context8.abrupt("return", _context8.sent);
19577
+ return _context9.abrupt("return", _context9.sent);
19415
19578
  case 3:
19416
19579
  case "end":
19417
- return _context8.stop();
19580
+ return _context9.stop();
19418
19581
  }
19419
- }, _callee8, this);
19582
+ }, _callee9, this);
19420
19583
  }));
19421
- function isRegistered(_x9) {
19584
+ function isRegistered(_x10) {
19422
19585
  return _isRegistered.apply(this, arguments);
19423
19586
  }
19424
19587
  return isRegistered;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@story-protocol/core-sdk",
3
- "version": "1.0.0-rc.17",
3
+ "version": "1.0.0-rc.18",
4
4
  "description": "Story Protocol Core SDK",
5
5
  "main": "dist/story-protocol-core-sdk.cjs.js",
6
6
  "module": "dist/story-protocol-core-sdk.esm.js",