@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.
@@ -502,9 +502,9 @@ function _asyncToGenerator(fn) {
502
502
  };
503
503
  }
504
504
 
505
- var storyTestChain = viem.defineChain({
505
+ var iliad = viem.defineChain({
506
506
  id: 1513,
507
- name: "story-testnet",
507
+ name: "iliad",
508
508
  nativeCurrency: {
509
509
  name: "IP",
510
510
  symbol: "IP",
@@ -534,7 +534,7 @@ function chainStringToViemChain(chainId) {
534
534
  switch (chainId) {
535
535
  case "1513":
536
536
  case "iliad":
537
- return storyTestChain;
537
+ return iliad;
538
538
  default:
539
539
  throw new Error("chainId ".concat(chainId, " not supported"));
540
540
  }
@@ -9324,6 +9324,22 @@ var spgAbi = [{
9324
9324
  type: "error",
9325
9325
  inputs: [],
9326
9326
  name: "NotInitializing"
9327
+ }, {
9328
+ type: "error",
9329
+ inputs: [{
9330
+ name: "tokenId",
9331
+ internalType: "uint256",
9332
+ type: "uint256"
9333
+ }, {
9334
+ name: "caller",
9335
+ internalType: "address",
9336
+ type: "address"
9337
+ }, {
9338
+ name: "actualTokenOwner",
9339
+ internalType: "address",
9340
+ type: "address"
9341
+ }],
9342
+ name: "SPG__CallerAndNotTokenOwner"
9327
9343
  }, {
9328
9344
  type: "error",
9329
9345
  inputs: [],
@@ -9637,7 +9653,7 @@ var spgAbi = [{
9637
9653
  internalType: "address",
9638
9654
  type: "address"
9639
9655
  }, {
9640
- name: "mintingFee",
9656
+ name: "defaultMintingFee",
9641
9657
  internalType: "uint256",
9642
9658
  type: "uint256"
9643
9659
  }, {
@@ -9665,7 +9681,7 @@ var spgAbi = [{
9665
9681
  internalType: "uint32",
9666
9682
  type: "uint32"
9667
9683
  }, {
9668
- name: "commercialRevCelling",
9684
+ name: "commercialRevCeiling",
9669
9685
  internalType: "uint256",
9670
9686
  type: "uint256"
9671
9687
  }, {
@@ -9685,7 +9701,7 @@ var spgAbi = [{
9685
9701
  internalType: "bool",
9686
9702
  type: "bool"
9687
9703
  }, {
9688
- name: "derivativeRevCelling",
9704
+ name: "derivativeRevCeiling",
9689
9705
  internalType: "uint256",
9690
9706
  type: "uint256"
9691
9707
  }, {
@@ -9828,6 +9844,32 @@ var spgAbi = [{
9828
9844
  type: "uint256"
9829
9845
  }],
9830
9846
  stateMutability: "nonpayable"
9847
+ }, {
9848
+ type: "function",
9849
+ inputs: [{
9850
+ name: "",
9851
+ internalType: "address",
9852
+ type: "address"
9853
+ }, {
9854
+ name: "",
9855
+ internalType: "address",
9856
+ type: "address"
9857
+ }, {
9858
+ name: "",
9859
+ internalType: "uint256",
9860
+ type: "uint256"
9861
+ }, {
9862
+ name: "",
9863
+ internalType: "bytes",
9864
+ type: "bytes"
9865
+ }],
9866
+ name: "onERC721Received",
9867
+ outputs: [{
9868
+ name: "",
9869
+ internalType: "bytes4",
9870
+ type: "bytes4"
9871
+ }],
9872
+ stateMutability: "nonpayable"
9831
9873
  }, {
9832
9874
  type: "function",
9833
9875
  inputs: [],
@@ -9930,7 +9972,7 @@ var spgAbi = [{
9930
9972
  internalType: "address",
9931
9973
  type: "address"
9932
9974
  }, {
9933
- name: "mintingFee",
9975
+ name: "defaultMintingFee",
9934
9976
  internalType: "uint256",
9935
9977
  type: "uint256"
9936
9978
  }, {
@@ -9958,7 +10000,7 @@ var spgAbi = [{
9958
10000
  internalType: "uint32",
9959
10001
  type: "uint32"
9960
10002
  }, {
9961
- name: "commercialRevCelling",
10003
+ name: "commercialRevCeiling",
9962
10004
  internalType: "uint256",
9963
10005
  type: "uint256"
9964
10006
  }, {
@@ -9978,7 +10020,7 @@ var spgAbi = [{
9978
10020
  internalType: "bool",
9979
10021
  type: "bool"
9980
10022
  }, {
9981
- name: "derivativeRevCelling",
10023
+ name: "derivativeRevCeiling",
9982
10024
  internalType: "uint256",
9983
10025
  type: "uint256"
9984
10026
  }, {
@@ -10222,7 +10264,7 @@ var spgAbi = [{
10222
10264
  internalType: "address",
10223
10265
  type: "address"
10224
10266
  }, {
10225
- name: "mintingFee",
10267
+ name: "defaultMintingFee",
10226
10268
  internalType: "uint256",
10227
10269
  type: "uint256"
10228
10270
  }, {
@@ -10250,7 +10292,7 @@ var spgAbi = [{
10250
10292
  internalType: "uint32",
10251
10293
  type: "uint32"
10252
10294
  }, {
10253
- name: "commercialRevCelling",
10295
+ name: "commercialRevCeiling",
10254
10296
  internalType: "uint256",
10255
10297
  type: "uint256"
10256
10298
  }, {
@@ -10270,7 +10312,7 @@ var spgAbi = [{
10270
10312
  internalType: "bool",
10271
10313
  type: "bool"
10272
10314
  }, {
10273
- name: "derivativeRevCelling",
10315
+ name: "derivativeRevCeiling",
10274
10316
  internalType: "uint256",
10275
10317
  type: "uint256"
10276
10318
  }, {
@@ -18934,11 +18976,7 @@ var IPAssetClient = /*#__PURE__*/function () {
18934
18976
  object = {
18935
18977
  nftContract: getAddress$1(request.nftContract, "request.nftContract"),
18936
18978
  recipient: request.recipient && getAddress$1(request.recipient, "request.recipient") || this.wallet.account.address,
18937
- terms: _objectSpread2(_objectSpread2({}, licenseTerm), {}, {
18938
- mintingFee: BigInt(licenseTerm.defaultMintingFee),
18939
- derivativeRevCelling: licenseTerm.commercialRevCeiling,
18940
- commercialRevCelling: licenseTerm.commercialRevCeiling
18941
- }),
18979
+ terms: licenseTerm,
18942
18980
  ipMetadata: {
18943
18981
  metadataURI: "",
18944
18982
  metadataHash: viem.zeroHash,
@@ -19087,11 +19125,7 @@ var IPAssetClient = /*#__PURE__*/function () {
19087
19125
  object = {
19088
19126
  nftContract: getAddress$1(request.nftContract, "request.nftContract"),
19089
19127
  tokenId: request.tokenId,
19090
- terms: _objectSpread2(_objectSpread2({}, licenseTerm), {}, {
19091
- mintingFee: BigInt(licenseTerm.defaultMintingFee),
19092
- derivativeRevCelling: licenseTerm.commercialRevCeiling,
19093
- commercialRevCelling: licenseTerm.commercialRevCeiling
19094
- }),
19128
+ terms: licenseTerm,
19095
19129
  ipMetadata: {
19096
19130
  metadataURI: "",
19097
19131
  metadataHash: viem.zeroHash,
@@ -19394,31 +19428,160 @@ var IPAssetClient = /*#__PURE__*/function () {
19394
19428
  return _registerDerivativeIp.apply(this, arguments);
19395
19429
  }
19396
19430
  return registerDerivativeIp;
19431
+ }()
19432
+ /**
19433
+ * Mint an NFT from a collection and register it as a derivative IP without license tokens.
19434
+ * @param request - The request object that contains all data needed to mint and register ip and make derivative.
19435
+ * @param request.nftContract The address of the NFT collection.
19436
+ * @param request.derivData The derivative data to be used for registerDerivative.
19437
+ * @param request.derivData.parentIpIds The IDs of the parent IPs to link the registered derivative IP.
19438
+ * @param request.derivData.licenseTermsIds The IDs of the license terms to be used for the linking.
19439
+ * @param request.derivData.licenseTemplate [Optional] The address of the license template to be used for the linking.
19440
+ * @param request.ipMetadata - [Optional] The desired ipMetadata for the newly registered IP.
19441
+ * @param request.ipMetadata.metadataURI [Optional] The URI of the ipMetadata for the IP.
19442
+ * @param request.ipMetadata.metadataHash [Optional] The ipMetadata for the IP.
19443
+ * @param request.ipMetadata.nftMetadataHash [Optional] The the ipMetadata for the IP NFT.
19444
+ * @param request.recipient [Optional] The address of the recipient of the minted NFT.
19445
+ * @param request.txOptions [Optional] The transaction options.
19446
+ * @returns A Promise that resolves to an object containing the transaction hash and optional IP ID if waitForTxn is set to true.
19447
+ * @emits IPRegistered (ipId, chainId, tokenContract, tokenId, name, uri, registrationDate)
19448
+ */
19449
+ )
19450
+ }, {
19451
+ key: "mintAndRegisterIpAndMakeDerivative",
19452
+ value: (function () {
19453
+ var _mintAndRegisterIpAndMakeDerivative = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(request) {
19454
+ var _request$txOptions13, i, isAttachedLicenseTerms, object, _request$txOptions14, txHash, receipt, log;
19455
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
19456
+ while (1) switch (_context7.prev = _context7.next) {
19457
+ case 0:
19458
+ _context7.prev = 0;
19459
+ if (!(request.derivData.parentIpIds.length !== request.derivData.licenseTermsIds.length)) {
19460
+ _context7.next = 3;
19461
+ break;
19462
+ }
19463
+ throw new Error("Parent IP IDs and License terms IDs must be provided in pairs.");
19464
+ case 3:
19465
+ i = 0;
19466
+ case 4:
19467
+ if (!(i < request.derivData.parentIpIds.length)) {
19468
+ _context7.next = 13;
19469
+ break;
19470
+ }
19471
+ _context7.next = 7;
19472
+ return this.licenseRegistryReadOnlyClient.hasIpAttachedLicenseTerms({
19473
+ ipId: getAddress$1(request.derivData.parentIpIds[i], "request.derivData.parentIpIds"),
19474
+ licenseTemplate: request.derivData.licenseTemplate && getAddress$1(request.derivData.licenseTemplate, "request.derivData.licenseTemplate") || this.licenseTemplateClient.address,
19475
+ licenseTermsId: BigInt(request.derivData.licenseTermsIds[i])
19476
+ });
19477
+ case 7:
19478
+ isAttachedLicenseTerms = _context7.sent;
19479
+ if (isAttachedLicenseTerms) {
19480
+ _context7.next = 10;
19481
+ break;
19482
+ }
19483
+ 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."));
19484
+ case 10:
19485
+ i++;
19486
+ _context7.next = 4;
19487
+ break;
19488
+ case 13:
19489
+ object = _objectSpread2(_objectSpread2({}, request), {}, {
19490
+ derivData: _objectSpread2(_objectSpread2({}, request.derivData), {}, {
19491
+ royaltyContext: viem.zeroAddress,
19492
+ licenseTemplate: request.derivData.licenseTemplate || this.licenseTemplateClient.address,
19493
+ licenseTermsIds: request.derivData.licenseTermsIds.map(function (id) {
19494
+ return BigInt(id);
19495
+ })
19496
+ }),
19497
+ nftMetadata: request.nftMetadata || "",
19498
+ ipMetadata: {
19499
+ metadataURI: "",
19500
+ metadataHash: viem.zeroHash,
19501
+ nftMetadataHash: viem.zeroHash
19502
+ },
19503
+ recipient: request.recipient && getAddress$1(request.recipient, "request.recipient") || this.wallet.account.address
19504
+ });
19505
+ if (request.ipMetadata && (request.ipMetadata.metadataHash !== viem.zeroHash || request.ipMetadata.metadataURI !== "" || request.ipMetadata.nftMetadataHash !== viem.zeroHash)) {
19506
+ object.ipMetadata = {
19507
+ metadataURI: request.ipMetadata.metadataURI || object.ipMetadata.metadataURI,
19508
+ metadataHash: request.ipMetadata.metadataHash || object.ipMetadata.metadataHash,
19509
+ nftMetadataHash: request.ipMetadata.nftMetadataHash || object.ipMetadata.nftMetadataHash
19510
+ };
19511
+ }
19512
+ if (!((_request$txOptions13 = request.txOptions) !== null && _request$txOptions13 !== void 0 && _request$txOptions13.encodedTxDataOnly)) {
19513
+ _context7.next = 19;
19514
+ break;
19515
+ }
19516
+ return _context7.abrupt("return", {
19517
+ encodedTxData: this.spgClient.mintAndRegisterIpAndMakeDerivativeEncode(object)
19518
+ });
19519
+ case 19:
19520
+ _context7.next = 21;
19521
+ return this.spgClient.mintAndRegisterIpAndMakeDerivative(object);
19522
+ case 21:
19523
+ txHash = _context7.sent;
19524
+ if (!((_request$txOptions14 = request.txOptions) !== null && _request$txOptions14 !== void 0 && _request$txOptions14.waitForTransaction)) {
19525
+ _context7.next = 28;
19526
+ break;
19527
+ }
19528
+ _context7.next = 25;
19529
+ return this.rpcClient.waitForTransactionReceipt({
19530
+ hash: txHash
19531
+ });
19532
+ case 25:
19533
+ receipt = _context7.sent;
19534
+ log = this.ipAssetRegistryClient.parseTxIpRegisteredEvent(receipt)[0];
19535
+ return _context7.abrupt("return", {
19536
+ txHash: txHash,
19537
+ childIpId: log.ipId
19538
+ });
19539
+ case 28:
19540
+ return _context7.abrupt("return", {
19541
+ txHash: txHash
19542
+ });
19543
+ case 29:
19544
+ _context7.next = 34;
19545
+ break;
19546
+ case 31:
19547
+ _context7.prev = 31;
19548
+ _context7.t0 = _context7["catch"](0);
19549
+ handleError(_context7.t0, "Failed to mint and register IP and make derivative");
19550
+ case 34:
19551
+ case "end":
19552
+ return _context7.stop();
19553
+ }
19554
+ }, _callee7, this, [[0, 31]]);
19555
+ }));
19556
+ function mintAndRegisterIpAndMakeDerivative(_x7) {
19557
+ return _mintAndRegisterIpAndMakeDerivative.apply(this, arguments);
19558
+ }
19559
+ return mintAndRegisterIpAndMakeDerivative;
19397
19560
  }())
19398
19561
  }, {
19399
19562
  key: "getIpIdAddress",
19400
19563
  value: function () {
19401
- var _getIpIdAddress = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(nftContract, tokenId) {
19564
+ var _getIpIdAddress = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(nftContract, tokenId) {
19402
19565
  var ipId;
19403
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
19404
- while (1) switch (_context7.prev = _context7.next) {
19566
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
19567
+ while (1) switch (_context8.prev = _context8.next) {
19405
19568
  case 0:
19406
- _context7.next = 2;
19569
+ _context8.next = 2;
19407
19570
  return this.ipAssetRegistryClient.ipId({
19408
19571
  chainId: chain[this.chainId],
19409
19572
  tokenContract: getAddress$1(nftContract, "nftContract"),
19410
19573
  tokenId: BigInt(tokenId)
19411
19574
  });
19412
19575
  case 2:
19413
- ipId = _context7.sent;
19414
- return _context7.abrupt("return", ipId);
19576
+ ipId = _context8.sent;
19577
+ return _context8.abrupt("return", ipId);
19415
19578
  case 4:
19416
19579
  case "end":
19417
- return _context7.stop();
19580
+ return _context8.stop();
19418
19581
  }
19419
- }, _callee7, this);
19582
+ }, _callee8, this);
19420
19583
  }));
19421
- function getIpIdAddress(_x7, _x8) {
19584
+ function getIpIdAddress(_x8, _x9) {
19422
19585
  return _getIpIdAddress.apply(this, arguments);
19423
19586
  }
19424
19587
  return getIpIdAddress;
@@ -19426,23 +19589,23 @@ var IPAssetClient = /*#__PURE__*/function () {
19426
19589
  }, {
19427
19590
  key: "isRegistered",
19428
19591
  value: function () {
19429
- var _isRegistered = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(ipId) {
19430
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
19431
- while (1) switch (_context8.prev = _context8.next) {
19592
+ var _isRegistered = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(ipId) {
19593
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
19594
+ while (1) switch (_context9.prev = _context9.next) {
19432
19595
  case 0:
19433
- _context8.next = 2;
19596
+ _context9.next = 2;
19434
19597
  return this.ipAssetRegistryClient.isRegistered({
19435
19598
  id: getAddress$1(ipId, "ipId")
19436
19599
  });
19437
19600
  case 2:
19438
- return _context8.abrupt("return", _context8.sent);
19601
+ return _context9.abrupt("return", _context9.sent);
19439
19602
  case 3:
19440
19603
  case "end":
19441
- return _context8.stop();
19604
+ return _context9.stop();
19442
19605
  }
19443
- }, _callee8, this);
19606
+ }, _callee9, this);
19444
19607
  }));
19445
- function isRegistered(_x9) {
19608
+ function isRegistered(_x10) {
19446
19609
  return _isRegistered.apply(this, arguments);
19447
19610
  }
19448
19611
  return isRegistered;