@story-protocol/core-sdk 1.4.0-rc.1 → 1.4.0

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.
Files changed (31) hide show
  1. package/dist/declarations/src/resources/group.d.ts.map +1 -1
  2. package/dist/declarations/src/resources/ipAsset.d.ts +193 -10
  3. package/dist/declarations/src/resources/ipAsset.d.ts.map +1 -1
  4. package/dist/declarations/src/resources/license.d.ts +56 -49
  5. package/dist/declarations/src/resources/license.d.ts.map +1 -1
  6. package/dist/declarations/src/types/common.d.ts +28 -4
  7. package/dist/declarations/src/types/common.d.ts.map +1 -1
  8. package/dist/declarations/src/types/resources/dispute.d.ts +6 -5
  9. package/dist/declarations/src/types/resources/dispute.d.ts.map +1 -1
  10. package/dist/declarations/src/types/resources/group.d.ts +19 -10
  11. package/dist/declarations/src/types/resources/group.d.ts.map +1 -1
  12. package/dist/declarations/src/types/resources/ipAccount.d.ts +3 -3
  13. package/dist/declarations/src/types/resources/ipAccount.d.ts.map +1 -1
  14. package/dist/declarations/src/types/resources/ipAsset.d.ts +328 -75
  15. package/dist/declarations/src/types/resources/ipAsset.d.ts.map +1 -1
  16. package/dist/declarations/src/types/resources/license.d.ts +113 -78
  17. package/dist/declarations/src/types/resources/license.d.ts.map +1 -1
  18. package/dist/declarations/src/types/resources/nftClient.d.ts +4 -3
  19. package/dist/declarations/src/types/resources/nftClient.d.ts.map +1 -1
  20. package/dist/declarations/src/types/resources/permission.d.ts +13 -4
  21. package/dist/declarations/src/types/resources/permission.d.ts.map +1 -1
  22. package/dist/declarations/src/types/utils/pilFlavor.d.ts +4 -3
  23. package/dist/declarations/src/types/utils/pilFlavor.d.ts.map +1 -1
  24. package/dist/declarations/src/utils/oov3.d.ts +2 -1
  25. package/dist/declarations/src/utils/oov3.d.ts.map +1 -1
  26. package/dist/declarations/src/utils/sign.d.ts +2 -1
  27. package/dist/declarations/src/utils/sign.d.ts.map +1 -1
  28. package/dist/story-protocol-core-sdk.cjs.dev.js +1633 -1086
  29. package/dist/story-protocol-core-sdk.cjs.prod.js +1633 -1086
  30. package/dist/story-protocol-core-sdk.esm.js +1633 -1086
  31. package/package.json +1 -1
@@ -4442,6 +4442,11 @@ var DisputeClient = /*#__PURE__*/function () {
4442
4442
  * Will be converted to bigint for contract calls.
4443
4443
  */
4444
4444
 
4445
+ /**
4446
+ * Input for token id, can be bigint or number.
4447
+ * Will be converted to bigint for contract calls.
4448
+ */
4449
+
4445
4450
  /**
4446
4451
  * The type of revenue share.
4447
4452
  * It is used to determine the type of revenue share to be used in the revenue share calculation and throw error when the revenue share is not valid.
@@ -4455,6 +4460,25 @@ var RevShareType = /*#__PURE__*/function (RevShareType) {
4455
4460
  return RevShareType;
4456
4461
  }({});
4457
4462
 
4463
+ /**
4464
+ * Input for license terms id, can be bigint or number.
4465
+ * Will be converted to bigint for contract calls.
4466
+ */
4467
+
4468
+ /**
4469
+ * Input for deadline, can be bigint or number.
4470
+ * Will be converted to bigint for contract calls.
4471
+ */
4472
+
4473
+ /**
4474
+ * Input for revenue share, can be number.
4475
+ */
4476
+
4477
+ /**
4478
+ * Input for fee, can be bigint or number.
4479
+ * Will be converted to bigint for contract calls.
4480
+ */
4481
+
4458
4482
  /**
4459
4483
  * Permission level
4460
4484
  */
@@ -4552,9 +4576,6 @@ var royaltyPolicyInputToAddress = function royaltyPolicyInputToAddress(input, ch
4552
4576
  var getRevenueShare = function getRevenueShare(revShare) {
4553
4577
  var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : RevShareType.COMMERCIAL_REVENUE_SHARE;
4554
4578
  var revShareNumber = Number(revShare);
4555
- if (isNaN(revShareNumber)) {
4556
- throw new Error("".concat(type, " must be a valid number."));
4557
- }
4558
4579
  if (revShareNumber < 0 || revShareNumber > 100) {
4559
4580
  throw new Error("".concat(type, " must be between 0 and 100."));
4560
4581
  }
@@ -4606,7 +4627,7 @@ var getPermissionSignature = /*#__PURE__*/function () {
4606
4627
  };
4607
4628
  }();
4608
4629
  var getDeadline = function getDeadline(unixTimestamp, deadline) {
4609
- if (deadline && (isNaN(Number(deadline)) || BigInt(deadline) < 0n)) {
4630
+ if (deadline && BigInt(deadline) < 0n) {
4610
4631
  throw new Error("Invalid deadline value.");
4611
4632
  }
4612
4633
  return deadline ? unixTimestamp + BigInt(deadline) : unixTimestamp + 1000n;
@@ -4709,7 +4730,7 @@ var validateLicenseConfig = function validateLicenseConfig(licensingConfig) {
4709
4730
  };
4710
4731
  }
4711
4732
  var licenseConfig = {
4712
- expectMinimumGroupRewardShare: Number(licensingConfig.expectMinimumGroupRewardShare),
4733
+ expectMinimumGroupRewardShare: getRevenueShare(licensingConfig.expectMinimumGroupRewardShare, RevShareType.EXPECT_MINIMUM_GROUP_REWARD_SHARE),
4713
4734
  commercialRevShare: getRevenueShare(licensingConfig.commercialRevShare),
4714
4735
  mintingFee: BigInt(licensingConfig.mintingFee),
4715
4736
  expectGroupRewardPool: validateAddress(licensingConfig.expectGroupRewardPool),
@@ -4718,14 +4739,6 @@ var validateLicenseConfig = function validateLicenseConfig(licensingConfig) {
4718
4739
  isSet: licensingConfig.isSet,
4719
4740
  disabled: licensingConfig.disabled
4720
4741
  };
4721
- if (isNaN(licenseConfig.expectMinimumGroupRewardShare)) {
4722
- throw new Error("The expectMinimumGroupRewardShare must be a valid number.");
4723
- }
4724
- if (licenseConfig.expectMinimumGroupRewardShare < 0 || licenseConfig.expectMinimumGroupRewardShare > 100) {
4725
- throw new Error("The expectMinimumGroupRewardShare must be greater than 0 and less than 100.");
4726
- } else {
4727
- licenseConfig.expectMinimumGroupRewardShare = getRevenueShare(licenseConfig.expectMinimumGroupRewardShare, RevShareType.EXPECT_MINIMUM_GROUP_REWARD_SHARE);
4728
- }
4729
4742
  if (licenseConfig.mintingFee < 0) {
4730
4743
  throw new Error("The mintingFee must be greater than 0.");
4731
4744
  }
@@ -4815,7 +4828,7 @@ var GroupClient = /*#__PURE__*/function () {
4815
4828
  key: "mintAndRegisterIpAndAttachLicenseAndAddToGroup",
4816
4829
  value: (function () {
4817
4830
  var _mintAndRegisterIpAndAttachLicenseAndAddToGroup = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(request) {
4818
- var _request$txOptions2, groupId, recipient, spgNftContract, deadline, isRegistered, ipAccount, _yield$ipAccount$stat, state, blockTimestamp, calculatedDeadline, _yield$getPermissionS, sigAddToGroupSignature, object, txHash, receipt, log, _t2;
4831
+ var _request$maxAllowedRe, _request$txOptions2, groupId, recipient, spgNftContract, deadline, isRegistered, ipAccount, _yield$ipAccount$stat, state, blockTimestamp, calculatedDeadline, _yield$getPermissionS, sigAddToGroupSignature, object, txHash, receipt, log, _t2;
4819
4832
  return _regenerator().w(function (_context2) {
4820
4833
  while (1) switch (_context2.p = _context2.n) {
4821
4834
  case 0:
@@ -4866,7 +4879,7 @@ var GroupClient = /*#__PURE__*/function () {
4866
4879
  allowDuplicates: request.allowDuplicates || true,
4867
4880
  spgNftContract: validateAddress(spgNftContract),
4868
4881
  recipient: validateAddress(recipient || this.wallet.account.address),
4869
- maxAllowedRewardShare: BigInt(getRevenueShare(request.maxAllowedRewardShare, RevShareType.MAX_ALLOWED_REWARD_SHARE)),
4882
+ maxAllowedRewardShare: BigInt(getRevenueShare((_request$maxAllowedRe = request.maxAllowedRewardShare) !== null && _request$maxAllowedRe !== void 0 ? _request$maxAllowedRe : 100, RevShareType.MAX_ALLOWED_REWARD_SHARE)),
4870
4883
  licensesData: this.getLicenseData(request.licenseData),
4871
4884
  ipMetadata: getIpMetadataForWorkflow(request.ipMetadata),
4872
4885
  sigAddToGroup: {
@@ -4925,7 +4938,7 @@ var GroupClient = /*#__PURE__*/function () {
4925
4938
  key: "registerIpAndAttachLicenseAndAddToGroup",
4926
4939
  value: (function () {
4927
4940
  var _registerIpAndAttachLicenseAndAddToGroup = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(request) {
4928
- var _request$txOptions3, ipIdAddress, isRegistered, ipAccount, _yield$ipAccount$stat2, state, blockTimestamp, calculatedDeadline, _yield$getPermissionS2, sigAddToGroupSignature, _yield$getPermissionS3, sigMetadataAndAttachSignature, object, txHash, receipt, log, _t3;
4941
+ var _request$maxAllowedRe2, _request$txOptions3, ipIdAddress, isRegistered, ipAccount, _yield$ipAccount$stat2, state, blockTimestamp, calculatedDeadline, _yield$getPermissionS2, sigAddToGroupSignature, _yield$getPermissionS3, sigMetadataAndAttachSignature, object, txHash, receipt, log, _t3;
4929
4942
  return _regenerator().w(function (_context3) {
4930
4943
  while (1) switch (_context3.p = _context3.n) {
4931
4944
  case 0:
@@ -5017,7 +5030,7 @@ var GroupClient = /*#__PURE__*/function () {
5017
5030
  licensesData: this.getLicenseData(request.licenseData),
5018
5031
  ipMetadata: getIpMetadataForWorkflow(request.ipMetadata),
5019
5032
  tokenId: BigInt(request.tokenId),
5020
- maxAllowedRewardShare: BigInt(getRevenueShare(request.maxAllowedRewardShare, RevShareType.MAX_ALLOWED_REWARD_SHARE)),
5033
+ maxAllowedRewardShare: BigInt(getRevenueShare((_request$maxAllowedRe2 = request.maxAllowedRewardShare) !== null && _request$maxAllowedRe2 !== void 0 ? _request$maxAllowedRe2 : 100, RevShareType.MAX_ALLOWED_REWARD_SHARE)),
5021
5034
  sigAddToGroup: {
5022
5035
  signer: validateAddress(this.wallet.account.address),
5023
5036
  deadline: calculatedDeadline,
@@ -5127,7 +5140,7 @@ var GroupClient = /*#__PURE__*/function () {
5127
5140
  key: "registerGroupAndAttachLicenseAndAddIps",
5128
5141
  value: (function () {
5129
5142
  var _registerGroupAndAttachLicenseAndAddIps = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(request) {
5130
- var _request$txOptions5, object, i, isRegistered, _i, isAttachedLicenseTerms, txHash, txReceipt, groupId, _t5;
5143
+ var _request$maxAllowedRe3, _request$txOptions5, object, i, isRegistered, _i, isAttachedLicenseTerms, txHash, txReceipt, groupId, _t5;
5131
5144
  return _regenerator().w(function (_context5) {
5132
5145
  while (1) switch (_context5.p = _context5.n) {
5133
5146
  case 0:
@@ -5136,7 +5149,7 @@ var GroupClient = /*#__PURE__*/function () {
5136
5149
  groupPool: validateAddress(request.groupPool),
5137
5150
  ipIds: request.ipIds,
5138
5151
  licenseData: this.getLicenseData(request.licenseData)[0],
5139
- maxAllowedRewardShare: BigInt(getRevenueShare(request.maxAllowedRewardShare))
5152
+ maxAllowedRewardShare: BigInt(getRevenueShare((_request$maxAllowedRe3 = request.maxAllowedRewardShare) !== null && _request$maxAllowedRe3 !== void 0 ? _request$maxAllowedRe3 : 100, RevShareType.MAX_ALLOWED_REWARD_SHARE))
5140
5153
  };
5141
5154
  i = 0;
5142
5155
  case 1:
@@ -5379,7 +5392,7 @@ var GroupClient = /*#__PURE__*/function () {
5379
5392
  addIpParam = {
5380
5393
  groupIpId: validateAddress(groupIpId),
5381
5394
  ipIds: validateAddresses(ipIds),
5382
- maxAllowedRewardShare: BigInt(getRevenueShare(maxAllowedRewardSharePercentage === undefined ? 100 : maxAllowedRewardSharePercentage, RevShareType.MAX_ALLOWED_REWARD_SHARE_PERCENTAGE))
5395
+ maxAllowedRewardShare: BigInt(getRevenueShare(maxAllowedRewardSharePercentage !== null && maxAllowedRewardSharePercentage !== void 0 ? maxAllowedRewardSharePercentage : 100, RevShareType.MAX_ALLOWED_REWARD_SHARE_PERCENTAGE))
5383
5396
  };
5384
5397
  _context8.n = 2;
5385
5398
  return this.groupingModuleClient.addIp(addIpParam);
@@ -6429,9 +6442,9 @@ _defineProperty(PILFlavor, "validateLicenseTerms", function (params, chainId) {
6429
6442
  // Validate commercial use and derivatives
6430
6443
  _PILFlavor.verifyCommercialUse(normalized);
6431
6444
  _PILFlavor.verifyDerivatives(normalized);
6432
-
6433
- // Validate and normalize commercialRevShare
6434
- normalized.commercialRevShare = getRevenueShare(normalized.commercialRevShare);
6445
+ if (normalized.commercialRevShare > 100 || normalized.commercialRevShare < 0) {
6446
+ throw new PILFlavorError("commercialRevShare must be between 0 and 100.");
6447
+ }
6435
6448
  return normalized;
6436
6449
  });
6437
6450
  _defineProperty(PILFlavor, "verifyCommercialUse", function (terms) {
@@ -6557,6 +6570,7 @@ var validateLicenseTermsData = /*#__PURE__*/function () {
6557
6570
  break;
6558
6571
  }
6559
6572
  licenseTerm = PILFlavor.validateLicenseTerms(licenseTermsData[i].terms, chainId);
6573
+ licenseTerm.commercialRevShare = getRevenueShare(licenseTerm.commercialRevShare);
6560
6574
  royaltyModuleReadOnlyClient = new RoyaltyModuleReadOnlyClient(rpcClient);
6561
6575
  if (!(validateAddress(licenseTerm.royaltyPolicy) !== zeroAddress)) {
6562
6576
  _context2.n = 3;
@@ -6660,6 +6674,7 @@ var getRoyaltyShares = function getRoyaltyShares(royaltyShares) {
6660
6674
  };
6661
6675
  var validateDerivativeData = /*#__PURE__*/function () {
6662
6676
  var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(_ref3) {
6677
+ var _derivativeDataInput$, _derivativeDataInput$2;
6663
6678
  var derivativeDataInput, rpcClient, wallet, chainId, licenseTemplateAddress, ipAssetRegistryClient, licenseRegistryReadOnlyClient, derivativeData, i, parentId, isParentIpRegistered, isAttachedLicenseTerms, _yield$licenseRegistr, royaltyPercent;
6664
6679
  return _regenerator().w(function (_context3) {
6665
6680
  while (1) switch (_context3.n) {
@@ -6675,9 +6690,9 @@ var validateDerivativeData = /*#__PURE__*/function () {
6675
6690
  }),
6676
6691
  licenseTemplate: validateAddress(derivativeDataInput.licenseTemplate || licenseTemplateAddress),
6677
6692
  royaltyContext: zeroAddress,
6678
- maxMintingFee: BigInt(derivativeDataInput.maxMintingFee || 0),
6679
- maxRts: Number(derivativeDataInput.maxRts === undefined ? MAX_ROYALTY_TOKEN : derivativeDataInput.maxRts),
6680
- maxRevenueShare: getRevenueShare(derivativeDataInput.maxRevenueShare === undefined ? 100 : derivativeDataInput.maxRevenueShare, RevShareType.MAX_REVENUE_SHARE)
6693
+ maxMintingFee: BigInt((_derivativeDataInput$ = derivativeDataInput.maxMintingFee) !== null && _derivativeDataInput$ !== void 0 ? _derivativeDataInput$ : 0),
6694
+ maxRts: validateMaxRts(derivativeDataInput.maxRts),
6695
+ maxRevenueShare: getRevenueShare((_derivativeDataInput$2 = derivativeDataInput.maxRevenueShare) !== null && _derivativeDataInput$2 !== void 0 ? _derivativeDataInput$2 : 100, RevShareType.MAX_REVENUE_SHARE)
6681
6696
  };
6682
6697
  if (!(derivativeData.parentIpIds.length === 0)) {
6683
6698
  _context3.n = 1;
@@ -6703,7 +6718,6 @@ var validateDerivativeData = /*#__PURE__*/function () {
6703
6718
  }
6704
6719
  throw new Error("The maxMintingFee must be greater than 0.");
6705
6720
  case 4:
6706
- validateMaxRts(derivativeData.maxRts);
6707
6721
  i = 0;
6708
6722
  case 5:
6709
6723
  if (!(i < derivativeData.parentIpIds.length)) {
@@ -6765,12 +6779,12 @@ var validateDerivativeData = /*#__PURE__*/function () {
6765
6779
  };
6766
6780
  }();
6767
6781
  var validateMaxRts = function validateMaxRts(maxRts) {
6768
- if (isNaN(maxRts)) {
6769
- throw new Error("The maxRts must be a number.");
6770
- }
6771
- if (maxRts < 0 || maxRts > MAX_ROYALTY_TOKEN) {
6782
+ if (maxRts === undefined) {
6783
+ return MAX_ROYALTY_TOKEN;
6784
+ } else if (maxRts < 0 || maxRts > MAX_ROYALTY_TOKEN) {
6772
6785
  throw new Error("The maxRts must be greater than 0 and less than ".concat(MAX_ROYALTY_TOKEN, "."));
6773
6786
  }
6787
+ return maxRts;
6774
6788
  };
6775
6789
  var getIpIdAddress = /*#__PURE__*/function () {
6776
6790
  var _ref6 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(_ref5) {
@@ -7969,6 +7983,53 @@ var prepareRoyaltyTokensDistributionRequests = /*#__PURE__*/function () {
7969
7983
  };
7970
7984
  }();
7971
7985
 
7986
+ var setMaxLicenseTokens = /*#__PURE__*/function () {
7987
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
7988
+ var maxLicenseTokensData, licensorIpId, licenseTermsIds, totalLicenseTokenLimitHookClient, templateAddress, licenseTermsMaxLimitTxHashes, i, maxLicenseTokens, txHash;
7989
+ return _regenerator().w(function (_context) {
7990
+ while (1) switch (_context.n) {
7991
+ case 0:
7992
+ maxLicenseTokensData = _ref.maxLicenseTokensData, licensorIpId = _ref.licensorIpId, licenseTermsIds = _ref.licenseTermsIds, totalLicenseTokenLimitHookClient = _ref.totalLicenseTokenLimitHookClient, templateAddress = _ref.templateAddress;
7993
+ licenseTermsMaxLimitTxHashes = [];
7994
+ i = 0;
7995
+ case 1:
7996
+ if (!(i < maxLicenseTokensData.length)) {
7997
+ _context.n = 5;
7998
+ break;
7999
+ }
8000
+ maxLicenseTokens = maxLicenseTokensData[i].maxLicenseTokens;
8001
+ if (!(maxLicenseTokens === undefined || maxLicenseTokens < 0n)) {
8002
+ _context.n = 2;
8003
+ break;
8004
+ }
8005
+ return _context.a(3, 4);
8006
+ case 2:
8007
+ _context.n = 3;
8008
+ return totalLicenseTokenLimitHookClient.setTotalLicenseTokenLimit({
8009
+ licensorIpId: licensorIpId,
8010
+ licenseTemplate: templateAddress,
8011
+ licenseTermsId: licenseTermsIds[i],
8012
+ limit: BigInt(maxLicenseTokens)
8013
+ });
8014
+ case 3:
8015
+ txHash = _context.v;
8016
+ if (txHash) {
8017
+ licenseTermsMaxLimitTxHashes.push(txHash);
8018
+ }
8019
+ case 4:
8020
+ i++;
8021
+ _context.n = 1;
8022
+ break;
8023
+ case 5:
8024
+ return _context.a(2, licenseTermsMaxLimitTxHashes);
8025
+ }
8026
+ }, _callee);
8027
+ }));
8028
+ return function setMaxLicenseTokens(_x) {
8029
+ return _ref2.apply(this, arguments);
8030
+ };
8031
+ }();
8032
+
7972
8033
  var IPAssetClient = /*#__PURE__*/function () {
7973
8034
  function IPAssetClient(rpcClient, wallet, chainId) {
7974
8035
  _classCallCheck(this, IPAssetClient);
@@ -7992,6 +8053,7 @@ var IPAssetClient = /*#__PURE__*/function () {
7992
8053
  this.wallet = wallet;
7993
8054
  this.chainId = chainId;
7994
8055
  this.walletAddress = this.wallet.account.address;
8056
+ this.licenseTemplateAddress = this.licenseTemplateClient.address;
7995
8057
  }
7996
8058
  return _createClass(IPAssetClient, [{
7997
8059
  key: "generateCreatorMetadata",
@@ -8378,7 +8440,7 @@ var IPAssetClient = /*#__PURE__*/function () {
8378
8440
  key: "batchRegisterDerivative",
8379
8441
  value: (function () {
8380
8442
  var _batchRegisterDerivative = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(request) {
8381
- var contracts, licenseModuleAddress, _iterator2, _step2, arg, calculatedDeadline, ipAccount, data, _yield$ipAccount$stat, state, signature, txHash, _t6, _t7, _t8;
8443
+ var contracts, licenseModuleAddress, _iterator2, _step2, _arg$maxMintingFee, _arg$maxRevenueShare, arg, calculatedDeadline, ipAccount, data, _yield$ipAccount$stat, state, signature, txHash, _t6, _t7, _t8;
8382
8444
  return _regenerator().w(function (_context5) {
8383
8445
  while (1) switch (_context5.p = _context5.n) {
8384
8446
  case 0:
@@ -8419,7 +8481,7 @@ var IPAssetClient = /*#__PURE__*/function () {
8419
8481
  functionName: "registerDerivative",
8420
8482
  args: [arg.childIpId, arg.parentIpIds, arg.licenseTermsIds.map(function (id) {
8421
8483
  return BigInt(id);
8422
- }), arg.licenseTemplate || this.licenseTemplateClient.address, zeroAddress, BigInt(arg.maxMintingFee || 0), Number(arg.maxRts === undefined ? MAX_ROYALTY_TOKEN : arg.maxRts), getRevenueShare(arg.maxRevenueShare === undefined ? 100 : arg.maxRevenueShare, RevShareType.MAX_REVENUE_SHARE)]
8484
+ }), arg.licenseTemplate || this.licenseTemplateAddress, zeroAddress, BigInt((_arg$maxMintingFee = arg.maxMintingFee) !== null && _arg$maxMintingFee !== void 0 ? _arg$maxMintingFee : 0), validateMaxRts(arg.maxRts), getRevenueShare((_arg$maxRevenueShare = arg.maxRevenueShare) !== null && _arg$maxRevenueShare !== void 0 ? _arg$maxRevenueShare : 100, RevShareType.MAX_REVENUE_SHARE)]
8423
8485
  });
8424
8486
  _context5.n = 8;
8425
8487
  return ipAccount.state();
@@ -8509,9 +8571,8 @@ var IPAssetClient = /*#__PURE__*/function () {
8509
8571
  return BigInt(id);
8510
8572
  }),
8511
8573
  royaltyContext: zeroAddress,
8512
- maxRts: Number(request.maxRts)
8574
+ maxRts: validateMaxRts(request.maxRts)
8513
8575
  };
8514
- validateMaxRts(req.maxRts);
8515
8576
  _context6.n = 1;
8516
8577
  return this.isRegistered(request.childIpId);
8517
8578
  case 1:
@@ -8580,39 +8641,34 @@ var IPAssetClient = /*#__PURE__*/function () {
8580
8641
  value: (function () {
8581
8642
  var _mintAndRegisterIpAssetWithPilTerms = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(request) {
8582
8643
  var _this3 = this;
8583
- var _request$txOptions4, _request$options2, _yield$validateLicens, licenseTerms, _yield$transformRegis, transformRequest, encodedTxData, contractCall, rsp, computedLicenseTermsIds, maxLicenseTokensTxHashes, _t0;
8644
+ var _request$txOptions4, _request$options2, _yield$transformRegis, transformRequest, encodedTxData, contractCall, rsp, computedLicenseTermsIds, maxLicenseTokensTxHashes, _t0;
8584
8645
  return _regenerator().w(function (_context7) {
8585
8646
  while (1) switch (_context7.p = _context7.n) {
8586
8647
  case 0:
8587
8648
  _context7.p = 0;
8588
8649
  _context7.n = 1;
8589
- return validateLicenseTermsData(request.licenseTermsData, this.rpcClient, this.chainId);
8590
- case 1:
8591
- _yield$validateLicens = _context7.v;
8592
- licenseTerms = _yield$validateLicens.licenseTerms;
8593
- _context7.n = 2;
8594
8650
  return transformRegistrationRequest({
8595
8651
  request: request,
8596
8652
  rpcClient: this.rpcClient,
8597
8653
  wallet: this.wallet,
8598
8654
  chainId: this.chainId
8599
8655
  });
8600
- case 2:
8656
+ case 1:
8601
8657
  _yield$transformRegis = _context7.v;
8602
8658
  transformRequest = _yield$transformRegis.transformRequest;
8603
8659
  encodedTxData = this.licenseAttachmentWorkflowsClient.mintAndRegisterIpAndAttachPilTermsEncode(transformRequest);
8604
8660
  if (!((_request$txOptions4 = request.txOptions) !== null && _request$txOptions4 !== void 0 && _request$txOptions4.encodedTxDataOnly)) {
8605
- _context7.n = 3;
8661
+ _context7.n = 2;
8606
8662
  break;
8607
8663
  }
8608
8664
  return _context7.a(2, {
8609
8665
  encodedTxData: encodedTxData
8610
8666
  });
8611
- case 3:
8667
+ case 2:
8612
8668
  contractCall = function contractCall() {
8613
8669
  return _this3.licenseAttachmentWorkflowsClient.mintAndRegisterIpAndAttachPilTerms(transformRequest);
8614
8670
  };
8615
- _context7.n = 4;
8671
+ _context7.n = 3;
8616
8672
  return this.handleRegistrationWithFees({
8617
8673
  wipOptions: (_request$options2 = request.options) === null || _request$options2 === void 0 ? void 0 : _request$options2.wipOptions,
8618
8674
  sender: this.walletAddress,
@@ -8622,31 +8678,35 @@ var IPAssetClient = /*#__PURE__*/function () {
8622
8678
  contractCall: contractCall,
8623
8679
  txOptions: request.txOptions
8624
8680
  });
8625
- case 4:
8681
+ case 3:
8626
8682
  rsp = _context7.v;
8627
- _context7.n = 5;
8628
- return this.getLicenseTermsId(licenseTerms);
8629
- case 5:
8683
+ _context7.n = 4;
8684
+ return this.getLicenseTermsId(transformRequest.licenseTermsData.map(function (data) {
8685
+ return data.terms;
8686
+ }));
8687
+ case 4:
8630
8688
  computedLicenseTermsIds = _context7.v;
8631
- _context7.n = 6;
8632
- return this.setMaxLicenseTokens({
8689
+ _context7.n = 5;
8690
+ return setMaxLicenseTokens({
8633
8691
  maxLicenseTokensData: request.licenseTermsData,
8634
8692
  licensorIpId: rsp.ipId,
8635
- licenseTermsIds: computedLicenseTermsIds
8693
+ licenseTermsIds: computedLicenseTermsIds,
8694
+ totalLicenseTokenLimitHookClient: this.totalLicenseTokenLimitHookClient,
8695
+ templateAddress: this.licenseTemplateAddress
8636
8696
  });
8637
- case 6:
8697
+ case 5:
8638
8698
  maxLicenseTokensTxHashes = _context7.v;
8639
8699
  return _context7.a(2, _objectSpread2(_objectSpread2({}, rsp), {}, {
8640
8700
  licenseTermsIds: computedLicenseTermsIds
8641
8701
  }, maxLicenseTokensTxHashes.length > 0 && {
8642
8702
  maxLicenseTokensTxHashes: maxLicenseTokensTxHashes
8643
8703
  }));
8644
- case 7:
8645
- _context7.p = 7;
8704
+ case 6:
8705
+ _context7.p = 6;
8646
8706
  _t0 = _context7.v;
8647
8707
  return _context7.a(2, handleError(_t0, "Failed to mint and register IP and attach PIL terms"));
8648
8708
  }
8649
- }, _callee7, this, [[0, 7]]);
8709
+ }, _callee7, this, [[0, 6]]);
8650
8710
  }));
8651
8711
  function mintAndRegisterIpAssetWithPilTerms(_x8) {
8652
8712
  return _mintAndRegisterIpAssetWithPilTerms.apply(this, arguments);
@@ -8740,10 +8800,12 @@ var IPAssetClient = /*#__PURE__*/function () {
8740
8800
  licenseTermsIds = _context8.v;
8741
8801
  results[j].licenseTermsIds = licenseTermsIds;
8742
8802
  _context8.n = 13;
8743
- return this.setMaxLicenseTokens({
8803
+ return setMaxLicenseTokens({
8744
8804
  maxLicenseTokensData: licenseTermsData,
8745
8805
  licensorIpId: results[j].ipId,
8746
- licenseTermsIds: licenseTermsIds
8806
+ licenseTermsIds: licenseTermsIds,
8807
+ totalLicenseTokenLimitHookClient: this.totalLicenseTokenLimitHookClient,
8808
+ templateAddress: this.licenseTemplateAddress
8747
8809
  });
8748
8810
  case 13:
8749
8811
  maxLicenseTokensTxHashes = _context8.v;
@@ -8781,7 +8843,7 @@ var IPAssetClient = /*#__PURE__*/function () {
8781
8843
  key: "registerIpAndAttachPilTerms",
8782
8844
  value: (function () {
8783
8845
  var _registerIpAndAttachPilTerms = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(request) {
8784
- var _request$txOptions5, ipIdAddress, isRegistered, _yield$validateLicens2, licenseTerms, _yield$transformRegis2, _transformRequest, txHash, txReceipt, log, licenseTermsIds, maxLicenseTokensTxHashes, _t11;
8846
+ var _request$txOptions5, ipIdAddress, isRegistered, _yield$validateLicens, licenseTerms, _yield$transformRegis2, _transformRequest, txHash, txReceipt, log, licenseTermsIds, maxLicenseTokensTxHashes, _t11;
8785
8847
  return _regenerator().w(function (_context9) {
8786
8848
  while (1) switch (_context9.p = _context9.n) {
8787
8849
  case 0:
@@ -8810,8 +8872,8 @@ var IPAssetClient = /*#__PURE__*/function () {
8810
8872
  _context9.n = 4;
8811
8873
  return validateLicenseTermsData(request.licenseTermsData, this.rpcClient, this.chainId);
8812
8874
  case 4:
8813
- _yield$validateLicens2 = _context9.v;
8814
- licenseTerms = _yield$validateLicens2.licenseTerms;
8875
+ _yield$validateLicens = _context9.v;
8876
+ licenseTerms = _yield$validateLicens.licenseTerms;
8815
8877
  _context9.n = 5;
8816
8878
  return transformRegistrationRequest({
8817
8879
  request: request,
@@ -8846,10 +8908,12 @@ var IPAssetClient = /*#__PURE__*/function () {
8846
8908
  case 9:
8847
8909
  licenseTermsIds = _context9.v;
8848
8910
  _context9.n = 10;
8849
- return this.setMaxLicenseTokens({
8911
+ return setMaxLicenseTokens({
8850
8912
  maxLicenseTokensData: request.licenseTermsData,
8851
8913
  licensorIpId: log.ipId,
8852
- licenseTermsIds: licenseTermsIds
8914
+ licenseTermsIds: licenseTermsIds,
8915
+ totalLicenseTokenLimitHookClient: this.totalLicenseTokenLimitHookClient,
8916
+ templateAddress: this.licenseTemplateAddress
8853
8917
  });
8854
8918
  case 10:
8855
8919
  maxLicenseTokensTxHashes = _context9.v;
@@ -9395,120 +9459,6 @@ var IPAssetClient = /*#__PURE__*/function () {
9395
9459
  }
9396
9460
  return batchMintAndRegisterIp;
9397
9461
  }()
9398
- /**
9399
- * Register Programmable IP License Terms (if unregistered) and attach it to IP.
9400
- *
9401
- * Emits an on-chain {@link https://github.com/storyprotocol/protocol-core-v1/blob/v1.3.1/contracts/interfaces/modules/licensing/ILicensingModule.sol#L19 | `LicenseTermsAttached`} event.
9402
- */
9403
- )
9404
- }, {
9405
- key: "registerPilTermsAndAttach",
9406
- value: (function () {
9407
- var _registerPilTermsAndAttach = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15(request) {
9408
- var _request$txOptions9, ipId, isRegistered, _yield$validateLicens3, licenseTerms, licenseTermsData, calculatedDeadline, ipAccount, _yield$ipAccount$stat2, state, signature, _object2, txHash, licenseTermsIds, maxLicenseTokensTxHashes, _t22;
9409
- return _regenerator().w(function (_context15) {
9410
- while (1) switch (_context15.p = _context15.n) {
9411
- case 0:
9412
- _context15.p = 0;
9413
- ipId = request.ipId;
9414
- _context15.n = 1;
9415
- return this.isRegistered(ipId);
9416
- case 1:
9417
- isRegistered = _context15.v;
9418
- if (isRegistered) {
9419
- _context15.n = 2;
9420
- break;
9421
- }
9422
- throw new Error("The IP with id ".concat(ipId, " is not registered."));
9423
- case 2:
9424
- _context15.n = 3;
9425
- return validateLicenseTermsData(request.licenseTermsData, this.rpcClient, this.chainId);
9426
- case 3:
9427
- _yield$validateLicens3 = _context15.v;
9428
- licenseTerms = _yield$validateLicens3.licenseTerms;
9429
- licenseTermsData = _yield$validateLicens3.licenseTermsData;
9430
- _context15.n = 4;
9431
- return getCalculatedDeadline(this.rpcClient, request.deadline);
9432
- case 4:
9433
- calculatedDeadline = _context15.v;
9434
- ipAccount = new IpAccountImplClient(this.rpcClient, this.wallet, ipId);
9435
- _context15.n = 5;
9436
- return ipAccount.state();
9437
- case 5:
9438
- _yield$ipAccount$stat2 = _context15.v;
9439
- state = _yield$ipAccount$stat2.result;
9440
- _context15.n = 6;
9441
- return generateOperationSignature({
9442
- ipIdAddress: ipId,
9443
- methodType: SignatureMethodType.REGISTER_PIL_TERMS_AND_ATTACH,
9444
- deadline: calculatedDeadline,
9445
- state: state,
9446
- wallet: this.wallet,
9447
- chainId: this.chainId
9448
- });
9449
- case 6:
9450
- signature = _context15.v;
9451
- _object2 = {
9452
- ipId: ipId,
9453
- licenseTermsData: licenseTermsData,
9454
- sigAttachAndConfig: {
9455
- signer: validateAddress(this.walletAddress),
9456
- deadline: calculatedDeadline,
9457
- signature: signature
9458
- }
9459
- };
9460
- if (!((_request$txOptions9 = request.txOptions) !== null && _request$txOptions9 !== void 0 && _request$txOptions9.encodedTxDataOnly)) {
9461
- _context15.n = 7;
9462
- break;
9463
- }
9464
- return _context15.a(2, {
9465
- encodedTxData: this.licenseAttachmentWorkflowsClient.registerPilTermsAndAttachEncode(_object2)
9466
- });
9467
- case 7:
9468
- _context15.n = 8;
9469
- return this.licenseAttachmentWorkflowsClient.registerPilTermsAndAttach(_object2);
9470
- case 8:
9471
- txHash = _context15.v;
9472
- _context15.n = 9;
9473
- return this.rpcClient.waitForTransactionReceipt(_objectSpread2(_objectSpread2({}, request.txOptions), {}, {
9474
- hash: txHash
9475
- }));
9476
- case 9:
9477
- _context15.n = 10;
9478
- return this.getLicenseTermsId(licenseTerms);
9479
- case 10:
9480
- licenseTermsIds = _context15.v;
9481
- _context15.n = 11;
9482
- return this.setMaxLicenseTokens({
9483
- maxLicenseTokensData: request.licenseTermsData,
9484
- licensorIpId: ipId,
9485
- licenseTermsIds: licenseTermsIds
9486
- });
9487
- case 11:
9488
- maxLicenseTokensTxHashes = _context15.v;
9489
- return _context15.a(2, _objectSpread2({
9490
- txHash: txHash,
9491
- licenseTermsIds: licenseTermsIds
9492
- }, maxLicenseTokensTxHashes.length > 0 && {
9493
- maxLicenseTokensTxHashes: maxLicenseTokensTxHashes
9494
- }));
9495
- case 12:
9496
- _context15.n = 14;
9497
- break;
9498
- case 13:
9499
- _context15.p = 13;
9500
- _t22 = _context15.v;
9501
- return _context15.a(2, handleError(_t22, "Failed to register PIL terms and attach"));
9502
- case 14:
9503
- return _context15.a(2);
9504
- }
9505
- }, _callee15, this, [[0, 13]]);
9506
- }));
9507
- function registerPilTermsAndAttach(_x14) {
9508
- return _registerPilTermsAndAttach.apply(this, arguments);
9509
- }
9510
- return registerPilTermsAndAttach;
9511
- }()
9512
9462
  /**
9513
9463
  * Mint an NFT from a collection and register it as a derivative IP using license tokens.
9514
9464
  * Requires caller to have the minter role or the SPG NFT to allow public minting. Caller must own the license tokens and have approved DerivativeWorkflows to transfer them.
@@ -9519,70 +9469,69 @@ var IPAssetClient = /*#__PURE__*/function () {
9519
9469
  }, {
9520
9470
  key: "mintAndRegisterIpAndMakeDerivativeWithLicenseTokens",
9521
9471
  value: (function () {
9522
- var _mintAndRegisterIpAndMakeDerivativeWithLicenseTokens = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17(request) {
9472
+ var _mintAndRegisterIpAndMakeDerivativeWithLicenseTokens = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16(request) {
9523
9473
  var _this8 = this;
9524
- var _request$txOptions0, _request$options6, licenseTokenIds, _object3, encodedTxData, contractCall, _t23;
9525
- return _regenerator().w(function (_context17) {
9526
- while (1) switch (_context17.p = _context17.n) {
9474
+ var _request$txOptions9, _request$options6, licenseTokenIds, _object2, encodedTxData, contractCall, _t22;
9475
+ return _regenerator().w(function (_context16) {
9476
+ while (1) switch (_context16.p = _context16.n) {
9527
9477
  case 0:
9528
- _context17.p = 0;
9529
- _context17.n = 1;
9478
+ _context16.p = 0;
9479
+ _context16.n = 1;
9530
9480
  return this.validateLicenseTokenIds(request.licenseTokenIds);
9531
9481
  case 1:
9532
- licenseTokenIds = _context17.v;
9533
- _object3 = {
9482
+ licenseTokenIds = _context16.v;
9483
+ _object2 = {
9534
9484
  spgNftContract: validateAddress(request.spgNftContract),
9535
9485
  recipient: validateAddress(request.recipient || this.walletAddress),
9536
9486
  ipMetadata: getIpMetadataForWorkflow(request.ipMetadata),
9537
9487
  licenseTokenIds: licenseTokenIds,
9538
9488
  royaltyContext: zeroAddress,
9539
- maxRts: Number(request.maxRts),
9489
+ maxRts: validateMaxRts(request.maxRts),
9540
9490
  allowDuplicates: request.allowDuplicates || true
9541
9491
  };
9542
- validateMaxRts(_object3.maxRts);
9543
- encodedTxData = this.derivativeWorkflowsClient.mintAndRegisterIpAndMakeDerivativeWithLicenseTokensEncode(_object3);
9544
- if (!((_request$txOptions0 = request.txOptions) !== null && _request$txOptions0 !== void 0 && _request$txOptions0.encodedTxDataOnly)) {
9545
- _context17.n = 2;
9492
+ encodedTxData = this.derivativeWorkflowsClient.mintAndRegisterIpAndMakeDerivativeWithLicenseTokensEncode(_object2);
9493
+ if (!((_request$txOptions9 = request.txOptions) !== null && _request$txOptions9 !== void 0 && _request$txOptions9.encodedTxDataOnly)) {
9494
+ _context16.n = 2;
9546
9495
  break;
9547
9496
  }
9548
- return _context17.a(2, {
9497
+ return _context16.a(2, {
9549
9498
  encodedTxData: encodedTxData
9550
9499
  });
9551
9500
  case 2:
9552
9501
  contractCall = /*#__PURE__*/function () {
9553
- var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16() {
9554
- return _regenerator().w(function (_context16) {
9555
- while (1) switch (_context16.n) {
9502
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15() {
9503
+ return _regenerator().w(function (_context15) {
9504
+ while (1) switch (_context15.n) {
9556
9505
  case 0:
9557
- return _context16.a(2, _this8.derivativeWorkflowsClient.mintAndRegisterIpAndMakeDerivativeWithLicenseTokens(_object3));
9506
+ return _context15.a(2, _this8.derivativeWorkflowsClient.mintAndRegisterIpAndMakeDerivativeWithLicenseTokens(_object2));
9558
9507
  }
9559
- }, _callee16);
9508
+ }, _callee15);
9560
9509
  }));
9561
9510
  return function contractCall() {
9562
9511
  return _ref4.apply(this, arguments);
9563
9512
  };
9564
9513
  }();
9565
- return _context17.a(2, this.handleRegistrationWithFees({
9514
+ return _context16.a(2, this.handleRegistrationWithFees({
9566
9515
  wipOptions: _objectSpread2(_objectSpread2({}, (_request$options6 = request.options) === null || _request$options6 === void 0 ? void 0 : _request$options6.wipOptions), {}, {
9567
9516
  // need to disable multicall to avoid needing to transfer the license
9568
9517
  // token to the multicall contract.
9569
9518
  useMulticallWhenPossible: false
9570
9519
  }),
9571
9520
  sender: this.walletAddress,
9572
- spgNftContract: _object3.spgNftContract,
9521
+ spgNftContract: _object2.spgNftContract,
9573
9522
  spgSpenderAddress: this.derivativeWorkflowsClient.address,
9574
9523
  encodedTxs: [encodedTxData],
9575
9524
  contractCall: contractCall,
9576
9525
  txOptions: request.txOptions
9577
9526
  }));
9578
9527
  case 3:
9579
- _context17.p = 3;
9580
- _t23 = _context17.v;
9581
- return _context17.a(2, handleError(_t23, "Failed to mint and register IP and make derivative with license tokens"));
9528
+ _context16.p = 3;
9529
+ _t22 = _context16.v;
9530
+ return _context16.a(2, handleError(_t22, "Failed to mint and register IP and make derivative with license tokens"));
9582
9531
  }
9583
- }, _callee17, this, [[0, 3]]);
9532
+ }, _callee16, this, [[0, 3]]);
9584
9533
  }));
9585
- function mintAndRegisterIpAndMakeDerivativeWithLicenseTokens(_x15) {
9534
+ function mintAndRegisterIpAndMakeDerivativeWithLicenseTokens(_x14) {
9586
9535
  return _mintAndRegisterIpAndMakeDerivativeWithLicenseTokens.apply(this, arguments);
9587
9536
  }
9588
9537
  return mintAndRegisterIpAndMakeDerivativeWithLicenseTokens;
@@ -9596,14 +9545,14 @@ var IPAssetClient = /*#__PURE__*/function () {
9596
9545
  }, {
9597
9546
  key: "registerIpAndMakeDerivativeWithLicenseTokens",
9598
9547
  value: (function () {
9599
- var _registerIpAndMakeDerivativeWithLicenseTokens = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18(request) {
9600
- var _request$txOptions1, tokenId, ipIdAddress, isRegistered, licenseTokenIds, calculatedDeadline, signature, _object4, txHash, receipt, log, _t24;
9601
- return _regenerator().w(function (_context18) {
9602
- while (1) switch (_context18.p = _context18.n) {
9548
+ var _registerIpAndMakeDerivativeWithLicenseTokens = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17(request) {
9549
+ var _request$txOptions0, tokenId, ipIdAddress, isRegistered, licenseTokenIds, calculatedDeadline, signature, _object3, txHash, receipt, log, _t23;
9550
+ return _regenerator().w(function (_context17) {
9551
+ while (1) switch (_context17.p = _context17.n) {
9603
9552
  case 0:
9604
- _context18.p = 0;
9553
+ _context17.p = 0;
9605
9554
  tokenId = BigInt(request.tokenId);
9606
- _context18.n = 1;
9555
+ _context17.n = 1;
9607
9556
  return getIpIdAddress({
9608
9557
  nftContract: request.nftContract,
9609
9558
  tokenId: tokenId,
@@ -9612,26 +9561,26 @@ var IPAssetClient = /*#__PURE__*/function () {
9612
9561
  chainId: this.chainId
9613
9562
  });
9614
9563
  case 1:
9615
- ipIdAddress = _context18.v;
9616
- _context18.n = 2;
9564
+ ipIdAddress = _context17.v;
9565
+ _context17.n = 2;
9617
9566
  return this.isRegistered(ipIdAddress);
9618
9567
  case 2:
9619
- isRegistered = _context18.v;
9568
+ isRegistered = _context17.v;
9620
9569
  if (!isRegistered) {
9621
- _context18.n = 3;
9570
+ _context17.n = 3;
9622
9571
  break;
9623
9572
  }
9624
9573
  throw new Error("The NFT with id ".concat(tokenId, " is already registered as IP."));
9625
9574
  case 3:
9626
- _context18.n = 4;
9575
+ _context17.n = 4;
9627
9576
  return this.validateLicenseTokenIds(request.licenseTokenIds);
9628
9577
  case 4:
9629
- licenseTokenIds = _context18.v;
9630
- _context18.n = 5;
9578
+ licenseTokenIds = _context17.v;
9579
+ _context17.n = 5;
9631
9580
  return getCalculatedDeadline(this.rpcClient, request.deadline);
9632
9581
  case 5:
9633
- calculatedDeadline = _context18.v;
9634
- _context18.n = 6;
9582
+ calculatedDeadline = _context17.v;
9583
+ _context17.n = 6;
9635
9584
  return generateOperationSignature({
9636
9585
  ipIdAddress: ipIdAddress,
9637
9586
  methodType: SignatureMethodType.REGISTER_IP_AND_MAKE_DERIVATIVE_WITH_LICENSE_TOKENS,
@@ -9640,8 +9589,8 @@ var IPAssetClient = /*#__PURE__*/function () {
9640
9589
  chainId: this.chainId
9641
9590
  });
9642
9591
  case 6:
9643
- signature = _context18.v;
9644
- _object4 = _objectSpread2(_objectSpread2({}, request), {}, {
9592
+ signature = _context17.v;
9593
+ _object3 = _objectSpread2(_objectSpread2({}, request), {}, {
9645
9594
  tokenId: tokenId,
9646
9595
  licenseTokenIds: licenseTokenIds,
9647
9596
  royaltyContext: zeroAddress,
@@ -9651,44 +9600,43 @@ var IPAssetClient = /*#__PURE__*/function () {
9651
9600
  deadline: calculatedDeadline,
9652
9601
  signature: signature
9653
9602
  },
9654
- maxRts: Number(request.maxRts)
9603
+ maxRts: validateMaxRts(request.maxRts)
9655
9604
  });
9656
- validateMaxRts(_object4.maxRts);
9657
- if (!((_request$txOptions1 = request.txOptions) !== null && _request$txOptions1 !== void 0 && _request$txOptions1.encodedTxDataOnly)) {
9658
- _context18.n = 7;
9605
+ if (!((_request$txOptions0 = request.txOptions) !== null && _request$txOptions0 !== void 0 && _request$txOptions0.encodedTxDataOnly)) {
9606
+ _context17.n = 7;
9659
9607
  break;
9660
9608
  }
9661
- return _context18.a(2, {
9662
- encodedTxData: this.derivativeWorkflowsClient.registerIpAndMakeDerivativeWithLicenseTokensEncode(_object4)
9609
+ return _context17.a(2, {
9610
+ encodedTxData: this.derivativeWorkflowsClient.registerIpAndMakeDerivativeWithLicenseTokensEncode(_object3)
9663
9611
  });
9664
9612
  case 7:
9665
- _context18.n = 8;
9666
- return this.derivativeWorkflowsClient.registerIpAndMakeDerivativeWithLicenseTokens(_object4);
9613
+ _context17.n = 8;
9614
+ return this.derivativeWorkflowsClient.registerIpAndMakeDerivativeWithLicenseTokens(_object3);
9667
9615
  case 8:
9668
- txHash = _context18.v;
9669
- _context18.n = 9;
9616
+ txHash = _context17.v;
9617
+ _context17.n = 9;
9670
9618
  return this.rpcClient.waitForTransactionReceipt(_objectSpread2(_objectSpread2({}, request.txOptions), {}, {
9671
9619
  hash: txHash
9672
9620
  }));
9673
9621
  case 9:
9674
- receipt = _context18.v;
9622
+ receipt = _context17.v;
9675
9623
  log = this.getIpIdAndTokenIdsFromEvent(receipt)[0];
9676
- return _context18.a(2, _objectSpread2({
9624
+ return _context17.a(2, _objectSpread2({
9677
9625
  txHash: txHash
9678
9626
  }, log));
9679
9627
  case 10:
9680
- _context18.n = 12;
9628
+ _context17.n = 12;
9681
9629
  break;
9682
9630
  case 11:
9683
- _context18.p = 11;
9684
- _t24 = _context18.v;
9685
- return _context18.a(2, handleError(_t24, "Failed to register IP and make derivative with license tokens"));
9631
+ _context17.p = 11;
9632
+ _t23 = _context17.v;
9633
+ return _context17.a(2, handleError(_t23, "Failed to register IP and make derivative with license tokens"));
9686
9634
  case 12:
9687
- return _context18.a(2);
9635
+ return _context17.a(2);
9688
9636
  }
9689
- }, _callee18, this, [[0, 11]]);
9637
+ }, _callee17, this, [[0, 11]]);
9690
9638
  }));
9691
- function registerIpAndMakeDerivativeWithLicenseTokens(_x16) {
9639
+ function registerIpAndMakeDerivativeWithLicenseTokens(_x15) {
9692
9640
  return _registerIpAndMakeDerivativeWithLicenseTokens.apply(this, arguments);
9693
9641
  }
9694
9642
  return registerIpAndMakeDerivativeWithLicenseTokens;
@@ -9704,23 +9652,23 @@ var IPAssetClient = /*#__PURE__*/function () {
9704
9652
  }, {
9705
9653
  key: "registerIPAndAttachLicenseTermsAndDistributeRoyaltyTokens",
9706
9654
  value: (function () {
9707
- var _registerIPAndAttachLicenseTermsAndDistributeRoyaltyTokens = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19(request) {
9708
- var _getRoyaltyShares, royaltyShares, totalAmount, _yield$validateLicens4, licenseTerms, calculatedDeadline, ipIdAddress, isRegistered, _yield$transformRegis5, _transformRequest4, registerIpAndAttachPilTermsAndDeployRoyaltyVaultTxHash, txReceipt, ipId, licenseTermsIds, ipRoyaltyVault, distributeRoyaltyTokensTxHash, maxLicenseTokensTxHashes, _t25;
9709
- return _regenerator().w(function (_context19) {
9710
- while (1) switch (_context19.p = _context19.n) {
9655
+ var _registerIPAndAttachLicenseTermsAndDistributeRoyaltyTokens = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18(request) {
9656
+ var _getRoyaltyShares, royaltyShares, totalAmount, _yield$validateLicens2, licenseTerms, calculatedDeadline, ipIdAddress, isRegistered, _yield$transformRegis5, _transformRequest4, registerIpAndAttachPilTermsAndDeployRoyaltyVaultTxHash, txReceipt, ipId, licenseTermsIds, ipRoyaltyVault, distributeRoyaltyTokensTxHash, maxLicenseTokensTxHashes, _t24;
9657
+ return _regenerator().w(function (_context18) {
9658
+ while (1) switch (_context18.p = _context18.n) {
9711
9659
  case 0:
9712
- _context19.p = 0;
9660
+ _context18.p = 0;
9713
9661
  _getRoyaltyShares = getRoyaltyShares(request.royaltyShares), royaltyShares = _getRoyaltyShares.royaltyShares, totalAmount = _getRoyaltyShares.totalAmount;
9714
- _context19.n = 1;
9662
+ _context18.n = 1;
9715
9663
  return validateLicenseTermsData(request.licenseTermsData, this.rpcClient, this.chainId);
9716
9664
  case 1:
9717
- _yield$validateLicens4 = _context19.v;
9718
- licenseTerms = _yield$validateLicens4.licenseTerms;
9719
- _context19.n = 2;
9665
+ _yield$validateLicens2 = _context18.v;
9666
+ licenseTerms = _yield$validateLicens2.licenseTerms;
9667
+ _context18.n = 2;
9720
9668
  return getCalculatedDeadline(this.rpcClient, request.deadline);
9721
9669
  case 2:
9722
- calculatedDeadline = _context19.v;
9723
- _context19.n = 3;
9670
+ calculatedDeadline = _context18.v;
9671
+ _context18.n = 3;
9724
9672
  return getIpIdAddress({
9725
9673
  nftContract: validateAddress(request.nftContract),
9726
9674
  tokenId: BigInt(request.tokenId),
@@ -9729,18 +9677,18 @@ var IPAssetClient = /*#__PURE__*/function () {
9729
9677
  chainId: this.chainId
9730
9678
  });
9731
9679
  case 3:
9732
- ipIdAddress = _context19.v;
9733
- _context19.n = 4;
9680
+ ipIdAddress = _context18.v;
9681
+ _context18.n = 4;
9734
9682
  return this.isRegistered(ipIdAddress);
9735
9683
  case 4:
9736
- isRegistered = _context19.v;
9684
+ isRegistered = _context18.v;
9737
9685
  if (!isRegistered) {
9738
- _context19.n = 5;
9686
+ _context18.n = 5;
9739
9687
  break;
9740
9688
  }
9741
9689
  throw new Error("The NFT with id ".concat(request.tokenId, " is already registered as IP."));
9742
9690
  case 5:
9743
- _context19.n = 6;
9691
+ _context18.n = 6;
9744
9692
  return transformRegistrationRequest({
9745
9693
  request: request,
9746
9694
  rpcClient: this.rpcClient,
@@ -9748,25 +9696,25 @@ var IPAssetClient = /*#__PURE__*/function () {
9748
9696
  chainId: this.chainId
9749
9697
  });
9750
9698
  case 6:
9751
- _yield$transformRegis5 = _context19.v;
9699
+ _yield$transformRegis5 = _context18.v;
9752
9700
  _transformRequest4 = _yield$transformRegis5.transformRequest;
9753
- _context19.n = 7;
9701
+ _context18.n = 7;
9754
9702
  return this.royaltyTokenDistributionWorkflowsClient.registerIpAndAttachPilTermsAndDeployRoyaltyVault(_transformRequest4);
9755
9703
  case 7:
9756
- registerIpAndAttachPilTermsAndDeployRoyaltyVaultTxHash = _context19.v;
9757
- _context19.n = 8;
9704
+ registerIpAndAttachPilTermsAndDeployRoyaltyVaultTxHash = _context18.v;
9705
+ _context18.n = 8;
9758
9706
  return this.rpcClient.waitForTransactionReceipt(_objectSpread2(_objectSpread2({}, request.txOptions), {}, {
9759
9707
  hash: registerIpAndAttachPilTermsAndDeployRoyaltyVaultTxHash
9760
9708
  }));
9761
9709
  case 8:
9762
- txReceipt = _context19.v;
9710
+ txReceipt = _context18.v;
9763
9711
  ipId = this.getIpIdAndTokenIdsFromEvent(txReceipt)[0].ipId;
9764
- _context19.n = 9;
9712
+ _context18.n = 9;
9765
9713
  return this.getLicenseTermsId(licenseTerms);
9766
9714
  case 9:
9767
- licenseTermsIds = _context19.v;
9715
+ licenseTermsIds = _context18.v;
9768
9716
  ipRoyaltyVault = this.royaltyModuleEventClient.parseTxIpRoyaltyVaultDeployedEvent(txReceipt)[0].ipRoyaltyVault;
9769
- _context19.n = 10;
9717
+ _context18.n = 10;
9770
9718
  return this.distributeRoyaltyTokens({
9771
9719
  ipId: ipId,
9772
9720
  deadline: calculatedDeadline,
@@ -9776,21 +9724,23 @@ var IPAssetClient = /*#__PURE__*/function () {
9776
9724
  txOptions: request.txOptions
9777
9725
  });
9778
9726
  case 10:
9779
- distributeRoyaltyTokensTxHash = _context19.v;
9780
- _context19.n = 11;
9727
+ distributeRoyaltyTokensTxHash = _context18.v;
9728
+ _context18.n = 11;
9781
9729
  return this.rpcClient.waitForTransactionReceipt(_objectSpread2(_objectSpread2({}, request.txOptions), {}, {
9782
9730
  hash: distributeRoyaltyTokensTxHash
9783
9731
  }));
9784
9732
  case 11:
9785
- _context19.n = 12;
9786
- return this.setMaxLicenseTokens({
9733
+ _context18.n = 12;
9734
+ return setMaxLicenseTokens({
9787
9735
  maxLicenseTokensData: request.licenseTermsData,
9788
9736
  licensorIpId: ipId,
9789
- licenseTermsIds: licenseTermsIds
9737
+ licenseTermsIds: licenseTermsIds,
9738
+ totalLicenseTokenLimitHookClient: this.totalLicenseTokenLimitHookClient,
9739
+ templateAddress: this.licenseTemplateAddress
9790
9740
  });
9791
9741
  case 12:
9792
- maxLicenseTokensTxHashes = _context19.v;
9793
- return _context19.a(2, _objectSpread2({
9742
+ maxLicenseTokensTxHashes = _context18.v;
9743
+ return _context18.a(2, _objectSpread2({
9794
9744
  registerIpAndAttachPilTermsAndDeployRoyaltyVaultTxHash: registerIpAndAttachPilTermsAndDeployRoyaltyVaultTxHash,
9795
9745
  distributeRoyaltyTokensTxHash: distributeRoyaltyTokensTxHash,
9796
9746
  ipId: ipId,
@@ -9800,13 +9750,13 @@ var IPAssetClient = /*#__PURE__*/function () {
9800
9750
  maxLicenseTokensTxHashes: maxLicenseTokensTxHashes
9801
9751
  }));
9802
9752
  case 13:
9803
- _context19.p = 13;
9804
- _t25 = _context19.v;
9805
- return _context19.a(2, handleError(_t25, "Failed to register IP and attach license terms and distribute royalty tokens"));
9753
+ _context18.p = 13;
9754
+ _t24 = _context18.v;
9755
+ return _context18.a(2, handleError(_t24, "Failed to register IP and attach license terms and distribute royalty tokens"));
9806
9756
  }
9807
- }, _callee19, this, [[0, 13]]);
9757
+ }, _callee18, this, [[0, 13]]);
9808
9758
  }));
9809
- function registerIPAndAttachLicenseTermsAndDistributeRoyaltyTokens(_x17) {
9759
+ function registerIPAndAttachLicenseTermsAndDistributeRoyaltyTokens(_x16) {
9810
9760
  return _registerIPAndAttachLicenseTermsAndDistributeRoyaltyTokens.apply(this, arguments);
9811
9761
  }
9812
9762
  return registerIPAndAttachLicenseTermsAndDistributeRoyaltyTokens;
@@ -9821,14 +9771,14 @@ var IPAssetClient = /*#__PURE__*/function () {
9821
9771
  }, {
9822
9772
  key: "registerDerivativeIpAndAttachLicenseTermsAndDistributeRoyaltyTokens",
9823
9773
  value: (function () {
9824
- var _registerDerivativeIpAndAttachLicenseTermsAndDistributeRoyaltyTokens = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee20(request) {
9774
+ var _registerDerivativeIpAndAttachLicenseTermsAndDistributeRoyaltyTokens = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19(request) {
9825
9775
  var _this9 = this;
9826
- var _request$options7, ipIdAddress, _yield$transformRegis6, _transformRequest5, _getRoyaltyShares2, royaltyShares, totalAmount, isRegistered, encodedTxData, contractCall, _yield$this$handleReg, txHash, ipId, tokenId, receipt, ipRoyaltyVault, distributeRoyaltyTokensTxHash, _t26;
9827
- return _regenerator().w(function (_context20) {
9828
- while (1) switch (_context20.p = _context20.n) {
9776
+ var _request$options7, ipIdAddress, _yield$transformRegis6, _transformRequest5, _getRoyaltyShares2, royaltyShares, totalAmount, isRegistered, encodedTxData, contractCall, _yield$this$handleReg, txHash, ipId, tokenId, receipt, ipRoyaltyVault, distributeRoyaltyTokensTxHash, _t25;
9777
+ return _regenerator().w(function (_context19) {
9778
+ while (1) switch (_context19.p = _context19.n) {
9829
9779
  case 0:
9830
- _context20.p = 0;
9831
- _context20.n = 1;
9780
+ _context19.p = 0;
9781
+ _context19.n = 1;
9832
9782
  return getIpIdAddress({
9833
9783
  nftContract: validateAddress(request.nftContract),
9834
9784
  tokenId: BigInt(request.tokenId),
@@ -9837,8 +9787,8 @@ var IPAssetClient = /*#__PURE__*/function () {
9837
9787
  chainId: this.chainId
9838
9788
  });
9839
9789
  case 1:
9840
- ipIdAddress = _context20.v;
9841
- _context20.n = 2;
9790
+ ipIdAddress = _context19.v;
9791
+ _context19.n = 2;
9842
9792
  return transformRegistrationRequest({
9843
9793
  request: request,
9844
9794
  rpcClient: this.rpcClient,
@@ -9846,15 +9796,15 @@ var IPAssetClient = /*#__PURE__*/function () {
9846
9796
  chainId: this.chainId
9847
9797
  });
9848
9798
  case 2:
9849
- _yield$transformRegis6 = _context20.v;
9799
+ _yield$transformRegis6 = _context19.v;
9850
9800
  _transformRequest5 = _yield$transformRegis6.transformRequest;
9851
9801
  _getRoyaltyShares2 = getRoyaltyShares(request.royaltyShares), royaltyShares = _getRoyaltyShares2.royaltyShares, totalAmount = _getRoyaltyShares2.totalAmount;
9852
- _context20.n = 3;
9802
+ _context19.n = 3;
9853
9803
  return this.isRegistered(ipIdAddress);
9854
9804
  case 3:
9855
- isRegistered = _context20.v;
9805
+ isRegistered = _context19.v;
9856
9806
  if (!isRegistered) {
9857
- _context20.n = 4;
9807
+ _context19.n = 4;
9858
9808
  break;
9859
9809
  }
9860
9810
  throw new Error("The NFT with id ".concat(request.tokenId, " is already registered as IP."));
@@ -9863,7 +9813,7 @@ var IPAssetClient = /*#__PURE__*/function () {
9863
9813
  contractCall = function contractCall() {
9864
9814
  return _this9.royaltyTokenDistributionWorkflowsClient.registerIpAndMakeDerivativeAndDeployRoyaltyVault(_transformRequest5);
9865
9815
  };
9866
- _context20.n = 5;
9816
+ _context19.n = 5;
9867
9817
  return this.handleRegistrationWithFees({
9868
9818
  wipOptions: _objectSpread2(_objectSpread2({}, (_request$options7 = request.options) === null || _request$options7 === void 0 ? void 0 : _request$options7.wipOptions), {}, {
9869
9819
  useMulticallWhenPossible: false
@@ -9876,13 +9826,13 @@ var IPAssetClient = /*#__PURE__*/function () {
9876
9826
  txOptions: _objectSpread2({}, request.txOptions)
9877
9827
  });
9878
9828
  case 5:
9879
- _yield$this$handleReg = _context20.v;
9829
+ _yield$this$handleReg = _context19.v;
9880
9830
  txHash = _yield$this$handleReg.txHash;
9881
9831
  ipId = _yield$this$handleReg.ipId;
9882
9832
  tokenId = _yield$this$handleReg.tokenId;
9883
9833
  receipt = _yield$this$handleReg.receipt;
9884
9834
  if (!(tokenId === undefined || !ipId || !receipt)) {
9885
- _context20.n = 6;
9835
+ _context19.n = 6;
9886
9836
  break;
9887
9837
  }
9888
9838
  throw new Error("Failed to register derivative ip and deploy royalty vault.");
@@ -9890,7 +9840,7 @@ var IPAssetClient = /*#__PURE__*/function () {
9890
9840
  ipRoyaltyVault = this.royaltyModuleEventClient.parseTxIpRoyaltyVaultDeployedEvent(receipt).filter(function (item) {
9891
9841
  return item.ipId === ipId;
9892
9842
  })[0].ipRoyaltyVault;
9893
- _context20.n = 7;
9843
+ _context19.n = 7;
9894
9844
  return this.distributeRoyaltyTokens({
9895
9845
  ipId: ipId,
9896
9846
  deadline: request.deadline,
@@ -9900,13 +9850,13 @@ var IPAssetClient = /*#__PURE__*/function () {
9900
9850
  txOptions: request.txOptions
9901
9851
  });
9902
9852
  case 7:
9903
- distributeRoyaltyTokensTxHash = _context20.v;
9904
- _context20.n = 8;
9853
+ distributeRoyaltyTokensTxHash = _context19.v;
9854
+ _context19.n = 8;
9905
9855
  return this.rpcClient.waitForTransactionReceipt(_objectSpread2(_objectSpread2({}, request.txOptions), {}, {
9906
9856
  hash: distributeRoyaltyTokensTxHash
9907
9857
  }));
9908
9858
  case 8:
9909
- return _context20.a(2, {
9859
+ return _context19.a(2, {
9910
9860
  registerDerivativeIpAndAttachLicenseTermsAndDistributeRoyaltyTokensTxHash: txHash,
9911
9861
  distributeRoyaltyTokensTxHash: distributeRoyaltyTokensTxHash,
9912
9862
  ipId: ipId,
@@ -9914,13 +9864,13 @@ var IPAssetClient = /*#__PURE__*/function () {
9914
9864
  ipRoyaltyVault: ipRoyaltyVault
9915
9865
  });
9916
9866
  case 9:
9917
- _context20.p = 9;
9918
- _t26 = _context20.v;
9919
- return _context20.a(2, handleError(_t26, "Failed to register derivative IP and attach license terms and distribute royalty tokens"));
9867
+ _context19.p = 9;
9868
+ _t25 = _context19.v;
9869
+ return _context19.a(2, handleError(_t25, "Failed to register derivative IP and attach license terms and distribute royalty tokens"));
9920
9870
  }
9921
- }, _callee20, this, [[0, 9]]);
9871
+ }, _callee19, this, [[0, 9]]);
9922
9872
  }));
9923
- function registerDerivativeIpAndAttachLicenseTermsAndDistributeRoyaltyTokens(_x18) {
9873
+ function registerDerivativeIpAndAttachLicenseTermsAndDistributeRoyaltyTokens(_x17) {
9924
9874
  return _registerDerivativeIpAndAttachLicenseTermsAndDistributeRoyaltyTokens.apply(this, arguments);
9925
9875
  }
9926
9876
  return registerDerivativeIpAndAttachLicenseTermsAndDistributeRoyaltyTokens;
@@ -9934,19 +9884,19 @@ var IPAssetClient = /*#__PURE__*/function () {
9934
9884
  }, {
9935
9885
  key: "mintAndRegisterIpAndAttachPilTermsAndDistributeRoyaltyTokens",
9936
9886
  value: (function () {
9937
- var _mintAndRegisterIpAndAttachPilTermsAndDistributeRoyaltyTokens = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee21(request) {
9887
+ var _mintAndRegisterIpAndAttachPilTermsAndDistributeRoyaltyTokens = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee20(request) {
9938
9888
  var _this0 = this;
9939
- var _request$options8, _yield$validateLicens5, licenseTerms, _yield$transformRegis7, _transformRequest6, encodedTxData, contractCall, _yield$this$handleReg2, txHash, ipId, tokenId, receipt, licenseTermsIds, ipRoyaltyVault, maxLicenseTokensTxHashes, _t27;
9940
- return _regenerator().w(function (_context21) {
9941
- while (1) switch (_context21.p = _context21.n) {
9889
+ var _request$options8, _yield$validateLicens3, licenseTerms, _yield$transformRegis7, _transformRequest6, encodedTxData, contractCall, _yield$this$handleReg2, txHash, ipId, tokenId, receipt, licenseTermsIds, ipRoyaltyVault, maxLicenseTokensTxHashes, _t26;
9890
+ return _regenerator().w(function (_context20) {
9891
+ while (1) switch (_context20.p = _context20.n) {
9942
9892
  case 0:
9943
- _context21.p = 0;
9944
- _context21.n = 1;
9893
+ _context20.p = 0;
9894
+ _context20.n = 1;
9945
9895
  return validateLicenseTermsData(request.licenseTermsData, this.rpcClient, this.chainId);
9946
9896
  case 1:
9947
- _yield$validateLicens5 = _context21.v;
9948
- licenseTerms = _yield$validateLicens5.licenseTerms;
9949
- _context21.n = 2;
9897
+ _yield$validateLicens3 = _context20.v;
9898
+ licenseTerms = _yield$validateLicens3.licenseTerms;
9899
+ _context20.n = 2;
9950
9900
  return transformRegistrationRequest({
9951
9901
  request: request,
9952
9902
  rpcClient: this.rpcClient,
@@ -9954,13 +9904,13 @@ var IPAssetClient = /*#__PURE__*/function () {
9954
9904
  chainId: this.chainId
9955
9905
  });
9956
9906
  case 2:
9957
- _yield$transformRegis7 = _context21.v;
9907
+ _yield$transformRegis7 = _context20.v;
9958
9908
  _transformRequest6 = _yield$transformRegis7.transformRequest;
9959
9909
  encodedTxData = this.royaltyTokenDistributionWorkflowsClient.mintAndRegisterIpAndAttachPilTermsAndDistributeRoyaltyTokensEncode(_transformRequest6);
9960
9910
  contractCall = function contractCall() {
9961
9911
  return _this0.royaltyTokenDistributionWorkflowsClient.mintAndRegisterIpAndAttachPilTermsAndDistributeRoyaltyTokens(_transformRequest6);
9962
9912
  };
9963
- _context21.n = 3;
9913
+ _context20.n = 3;
9964
9914
  return this.handleRegistrationWithFees({
9965
9915
  wipOptions: (_request$options8 = request.options) === null || _request$options8 === void 0 ? void 0 : _request$options8.wipOptions,
9966
9916
  sender: this.walletAddress,
@@ -9971,33 +9921,35 @@ var IPAssetClient = /*#__PURE__*/function () {
9971
9921
  txOptions: request.txOptions
9972
9922
  });
9973
9923
  case 3:
9974
- _yield$this$handleReg2 = _context21.v;
9924
+ _yield$this$handleReg2 = _context20.v;
9975
9925
  txHash = _yield$this$handleReg2.txHash;
9976
9926
  ipId = _yield$this$handleReg2.ipId;
9977
9927
  tokenId = _yield$this$handleReg2.tokenId;
9978
9928
  receipt = _yield$this$handleReg2.receipt;
9979
9929
  if (receipt) {
9980
- _context21.n = 4;
9930
+ _context20.n = 4;
9981
9931
  break;
9982
9932
  }
9983
- return _context21.a(2, {
9933
+ return _context20.a(2, {
9984
9934
  txHash: txHash
9985
9935
  });
9986
9936
  case 4:
9987
- _context21.n = 5;
9937
+ _context20.n = 5;
9988
9938
  return this.getLicenseTermsId(licenseTerms);
9989
9939
  case 5:
9990
- licenseTermsIds = _context21.v;
9940
+ licenseTermsIds = _context20.v;
9991
9941
  ipRoyaltyVault = this.royaltyModuleEventClient.parseTxIpRoyaltyVaultDeployedEvent(receipt)[0].ipRoyaltyVault;
9992
- _context21.n = 6;
9993
- return this.setMaxLicenseTokens({
9942
+ _context20.n = 6;
9943
+ return setMaxLicenseTokens({
9994
9944
  maxLicenseTokensData: request.licenseTermsData,
9995
9945
  licensorIpId: ipId,
9996
- licenseTermsIds: licenseTermsIds
9946
+ licenseTermsIds: licenseTermsIds,
9947
+ totalLicenseTokenLimitHookClient: this.totalLicenseTokenLimitHookClient,
9948
+ templateAddress: this.licenseTemplateAddress
9997
9949
  });
9998
9950
  case 6:
9999
- maxLicenseTokensTxHashes = _context21.v;
10000
- return _context21.a(2, _objectSpread2({
9951
+ maxLicenseTokensTxHashes = _context20.v;
9952
+ return _context20.a(2, _objectSpread2({
10001
9953
  txHash: txHash,
10002
9954
  ipId: ipId,
10003
9955
  licenseTermsIds: licenseTermsIds,
@@ -10007,13 +9959,13 @@ var IPAssetClient = /*#__PURE__*/function () {
10007
9959
  maxLicenseTokensTxHashes: maxLicenseTokensTxHashes
10008
9960
  }));
10009
9961
  case 7:
10010
- _context21.p = 7;
10011
- _t27 = _context21.v;
10012
- return _context21.a(2, handleError(_t27, "Failed to mint and register IP and attach PIL terms and distribute royalty tokens"));
9962
+ _context20.p = 7;
9963
+ _t26 = _context20.v;
9964
+ return _context20.a(2, handleError(_t26, "Failed to mint and register IP and attach PIL terms and distribute royalty tokens"));
10013
9965
  }
10014
- }, _callee21, this, [[0, 7]]);
9966
+ }, _callee20, this, [[0, 7]]);
10015
9967
  }));
10016
- function mintAndRegisterIpAndAttachPilTermsAndDistributeRoyaltyTokens(_x19) {
9968
+ function mintAndRegisterIpAndAttachPilTermsAndDistributeRoyaltyTokens(_x18) {
10017
9969
  return _mintAndRegisterIpAndAttachPilTermsAndDistributeRoyaltyTokens.apply(this, arguments);
10018
9970
  }
10019
9971
  return mintAndRegisterIpAndAttachPilTermsAndDistributeRoyaltyTokens;
@@ -10027,14 +9979,14 @@ var IPAssetClient = /*#__PURE__*/function () {
10027
9979
  }, {
10028
9980
  key: "mintAndRegisterIpAndMakeDerivativeAndDistributeRoyaltyTokens",
10029
9981
  value: (function () {
10030
- var _mintAndRegisterIpAndMakeDerivativeAndDistributeRoyaltyTokens = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee22(request) {
9982
+ var _mintAndRegisterIpAndMakeDerivativeAndDistributeRoyaltyTokens = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee21(request) {
10031
9983
  var _this1 = this;
10032
- var _request$options9, _yield$transformRegis8, _transformRequest7, encodedTxData, contractCall, _t28;
10033
- return _regenerator().w(function (_context22) {
10034
- while (1) switch (_context22.p = _context22.n) {
9984
+ var _request$options9, _yield$transformRegis8, _transformRequest7, encodedTxData, contractCall, _t27;
9985
+ return _regenerator().w(function (_context21) {
9986
+ while (1) switch (_context21.p = _context21.n) {
10035
9987
  case 0:
10036
- _context22.p = 0;
10037
- _context22.n = 1;
9988
+ _context21.p = 0;
9989
+ _context21.n = 1;
10038
9990
  return transformRegistrationRequest({
10039
9991
  request: request,
10040
9992
  rpcClient: this.rpcClient,
@@ -10042,13 +9994,13 @@ var IPAssetClient = /*#__PURE__*/function () {
10042
9994
  chainId: this.chainId
10043
9995
  });
10044
9996
  case 1:
10045
- _yield$transformRegis8 = _context22.v;
9997
+ _yield$transformRegis8 = _context21.v;
10046
9998
  _transformRequest7 = _yield$transformRegis8.transformRequest;
10047
9999
  encodedTxData = this.royaltyTokenDistributionWorkflowsClient.mintAndRegisterIpAndMakeDerivativeAndDistributeRoyaltyTokensEncode(_transformRequest7);
10048
10000
  contractCall = function contractCall() {
10049
10001
  return _this1.royaltyTokenDistributionWorkflowsClient.mintAndRegisterIpAndMakeDerivativeAndDistributeRoyaltyTokens(_transformRequest7);
10050
10002
  };
10051
- _context22.n = 2;
10003
+ _context21.n = 2;
10052
10004
  return this.handleRegistrationWithFees({
10053
10005
  spgNftContract: _transformRequest7.spgNftContract,
10054
10006
  wipOptions: (_request$options9 = request.options) === null || _request$options9 === void 0 ? void 0 : _request$options9.wipOptions,
@@ -10060,15 +10012,15 @@ var IPAssetClient = /*#__PURE__*/function () {
10060
10012
  txOptions: request.txOptions
10061
10013
  });
10062
10014
  case 2:
10063
- return _context22.a(2, _context22.v);
10015
+ return _context21.a(2, _context21.v);
10064
10016
  case 3:
10065
- _context22.p = 3;
10066
- _t28 = _context22.v;
10067
- return _context22.a(2, handleError(_t28, "Failed to mint and register IP and make derivative and distribute royalty tokens"));
10017
+ _context21.p = 3;
10018
+ _t27 = _context21.v;
10019
+ return _context21.a(2, handleError(_t27, "Failed to mint and register IP and make derivative and distribute royalty tokens"));
10068
10020
  }
10069
- }, _callee22, this, [[0, 3]]);
10021
+ }, _callee21, this, [[0, 3]]);
10070
10022
  }));
10071
- function mintAndRegisterIpAndMakeDerivativeAndDistributeRoyaltyTokens(_x20) {
10023
+ function mintAndRegisterIpAndMakeDerivativeAndDistributeRoyaltyTokens(_x19) {
10072
10024
  return _mintAndRegisterIpAndMakeDerivativeAndDistributeRoyaltyTokens.apply(this, arguments);
10073
10025
  }
10074
10026
  return mintAndRegisterIpAndMakeDerivativeAndDistributeRoyaltyTokens;
@@ -10076,12 +10028,12 @@ var IPAssetClient = /*#__PURE__*/function () {
10076
10028
  }, {
10077
10029
  key: "distributeRoyaltyTokens",
10078
10030
  value: function () {
10079
- var _distributeRoyaltyTokens = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee23(request) {
10031
+ var _distributeRoyaltyTokens = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee22(request) {
10080
10032
  var _yield$transferDistri, transformRequest, txHash;
10081
- return _regenerator().w(function (_context23) {
10082
- while (1) switch (_context23.n) {
10033
+ return _regenerator().w(function (_context22) {
10034
+ while (1) switch (_context22.n) {
10083
10035
  case 0:
10084
- _context23.n = 1;
10036
+ _context22.n = 1;
10085
10037
  return transferDistributeRoyaltyTokensRequest({
10086
10038
  request: request,
10087
10039
  rpcClient: this.rpcClient,
@@ -10089,22 +10041,22 @@ var IPAssetClient = /*#__PURE__*/function () {
10089
10041
  chainId: this.chainId
10090
10042
  });
10091
10043
  case 1:
10092
- _yield$transferDistri = _context23.v;
10044
+ _yield$transferDistri = _context22.v;
10093
10045
  transformRequest = _yield$transferDistri.transformRequest;
10094
- _context23.n = 2;
10046
+ _context22.n = 2;
10095
10047
  return this.royaltyTokenDistributionWorkflowsClient.distributeRoyaltyTokens(transformRequest);
10096
10048
  case 2:
10097
- txHash = _context23.v;
10098
- _context23.n = 3;
10049
+ txHash = _context22.v;
10050
+ _context22.n = 3;
10099
10051
  return this.rpcClient.waitForTransactionReceipt(_objectSpread2(_objectSpread2({}, request.txOptions), {}, {
10100
10052
  hash: txHash
10101
10053
  }));
10102
10054
  case 3:
10103
- return _context23.a(2, txHash);
10055
+ return _context22.a(2, txHash);
10104
10056
  }
10105
- }, _callee23, this);
10057
+ }, _callee22, this);
10106
10058
  }));
10107
- function distributeRoyaltyTokens(_x21) {
10059
+ function distributeRoyaltyTokens(_x20) {
10108
10060
  return _distributeRoyaltyTokens.apply(this, arguments);
10109
10061
  }
10110
10062
  return distributeRoyaltyTokens;
@@ -10112,20 +10064,20 @@ var IPAssetClient = /*#__PURE__*/function () {
10112
10064
  }, {
10113
10065
  key: "isRegistered",
10114
10066
  value: function () {
10115
- var _isRegistered = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee24(ipId) {
10116
- return _regenerator().w(function (_context24) {
10117
- while (1) switch (_context24.n) {
10067
+ var _isRegistered = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee23(ipId) {
10068
+ return _regenerator().w(function (_context23) {
10069
+ while (1) switch (_context23.n) {
10118
10070
  case 0:
10119
- _context24.n = 1;
10071
+ _context23.n = 1;
10120
10072
  return this.ipAssetRegistryClient.isRegistered({
10121
10073
  id: validateAddress(ipId)
10122
10074
  });
10123
10075
  case 1:
10124
- return _context24.a(2, _context24.v);
10076
+ return _context23.a(2, _context23.v);
10125
10077
  }
10126
- }, _callee24, this);
10078
+ }, _callee23, this);
10127
10079
  }));
10128
- function isRegistered(_x22) {
10080
+ function isRegistered(_x21) {
10129
10081
  return _isRegistered.apply(this, arguments);
10130
10082
  }
10131
10083
  return isRegistered;
@@ -10169,24 +10121,24 @@ var IPAssetClient = /*#__PURE__*/function () {
10169
10121
  }, {
10170
10122
  key: "batchRegisterIpAssetsWithOptimizedWorkflows",
10171
10123
  value: (function () {
10172
- var _batchRegisterIpAssetsWithOptimizedWorkflows = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee25(request) {
10173
- var _request$options0, _request$options10, transferWorkflowRequests, _iterator6, _step6, req, res, royaltyDistributionRequests, _yield$handleMultical, txResponses, aggregateRegistrationRequest, responses, royaltyTokensDistributionRequests, _iterator7, _step7, _step7$value, txHash, receipt, iPRegisteredLog, ipRoyaltyVaultEvent, response, distributeRoyaltyTokensTxHashes, _request$options1, _yield$handleMultical2, txResponse, registrationResults, _t29, _t30, _t31;
10174
- return _regenerator().w(function (_context25) {
10175
- while (1) switch (_context25.p = _context25.n) {
10124
+ var _batchRegisterIpAssetsWithOptimizedWorkflows = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee24(request) {
10125
+ var _request$options0, _request$options10, transferWorkflowRequests, _iterator6, _step6, req, res, royaltyDistributionRequests, _yield$handleMultical, txResponses, aggregateRegistrationRequest, responses, royaltyTokensDistributionRequests, _iterator7, _step7, _step7$value, txHash, receipt, iPRegisteredLog, ipRoyaltyVaultEvent, response, distributeRoyaltyTokensTxHashes, _request$options1, _yield$handleMultical2, txResponse, registrationResults, _t28, _t29, _t30;
10126
+ return _regenerator().w(function (_context24) {
10127
+ while (1) switch (_context24.p = _context24.n) {
10176
10128
  case 0:
10177
- _context25.p = 0;
10129
+ _context24.p = 0;
10178
10130
  // Transform requests into workflow format
10179
10131
  transferWorkflowRequests = [];
10180
10132
  _iterator6 = _createForOfIteratorHelper(request.requests);
10181
- _context25.p = 1;
10133
+ _context24.p = 1;
10182
10134
  _iterator6.s();
10183
10135
  case 2:
10184
10136
  if ((_step6 = _iterator6.n()).done) {
10185
- _context25.n = 5;
10137
+ _context24.n = 5;
10186
10138
  break;
10187
10139
  }
10188
10140
  req = _step6.value;
10189
- _context25.n = 3;
10141
+ _context24.n = 3;
10190
10142
  return transformRegistrationRequest({
10191
10143
  request: req,
10192
10144
  rpcClient: this.rpcClient,
@@ -10194,22 +10146,22 @@ var IPAssetClient = /*#__PURE__*/function () {
10194
10146
  chainId: this.chainId
10195
10147
  });
10196
10148
  case 3:
10197
- res = _context25.v;
10149
+ res = _context24.v;
10198
10150
  transferWorkflowRequests.push(res);
10199
10151
  case 4:
10200
- _context25.n = 2;
10152
+ _context24.n = 2;
10201
10153
  break;
10202
10154
  case 5:
10203
- _context25.n = 7;
10155
+ _context24.n = 7;
10204
10156
  break;
10205
10157
  case 6:
10206
- _context25.p = 6;
10207
- _t29 = _context25.v;
10208
- _iterator6.e(_t29);
10158
+ _context24.p = 6;
10159
+ _t28 = _context24.v;
10160
+ _iterator6.e(_t28);
10209
10161
  case 7:
10210
- _context25.p = 7;
10162
+ _context24.p = 7;
10211
10163
  _iterator6.f();
10212
- return _context25.f(7);
10164
+ return _context24.f(7);
10213
10165
  case 8:
10214
10166
  /**
10215
10167
  * Extract royalty distribution requests from workflow responses that contain royalty shares
@@ -10227,7 +10179,7 @@ var IPAssetClient = /*#__PURE__*/function () {
10227
10179
  deadline: res.extraData.deadline
10228
10180
  };
10229
10181
  }); // Process initial registration transactions
10230
- _context25.n = 9;
10182
+ _context24.n = 9;
10231
10183
  return handleMulticall({
10232
10184
  transferWorkflowRequests: transferWorkflowRequests,
10233
10185
  multicall3Address: this.multicall3Client.address,
@@ -10238,23 +10190,23 @@ var IPAssetClient = /*#__PURE__*/function () {
10238
10190
  chainId: this.chainId
10239
10191
  });
10240
10192
  case 9:
10241
- _yield$handleMultical = _context25.v;
10193
+ _yield$handleMultical = _context24.v;
10242
10194
  txResponses = _yield$handleMultical.response;
10243
10195
  aggregateRegistrationRequest = _yield$handleMultical.aggregateRegistrationRequest;
10244
10196
  responses = [];
10245
10197
  royaltyTokensDistributionRequests = []; // Process each transaction response
10246
10198
  _iterator7 = _createForOfIteratorHelper(txResponses);
10247
- _context25.p = 10;
10199
+ _context24.p = 10;
10248
10200
  _iterator7.s();
10249
10201
  case 11:
10250
10202
  if ((_step7 = _iterator7.n()).done) {
10251
- _context25.n = 14;
10203
+ _context24.n = 14;
10252
10204
  break;
10253
10205
  }
10254
10206
  _step7$value = _step7.value, txHash = _step7$value.txHash, receipt = _step7$value.receipt;
10255
10207
  iPRegisteredLog = this.ipAssetRegistryClient.parseTxIpRegisteredEvent(receipt);
10256
10208
  ipRoyaltyVaultEvent = this.royaltyModuleEventClient.parseTxIpRoyaltyVaultDeployedEvent(receipt); // Prepare royalty distribution if needed
10257
- _context25.n = 12;
10209
+ _context24.n = 12;
10258
10210
  return prepareRoyaltyTokensDistributionRequests({
10259
10211
  royaltyDistributionRequests: royaltyDistributionRequests,
10260
10212
  ipRegisteredLog: iPRegisteredLog,
@@ -10264,7 +10216,7 @@ var IPAssetClient = /*#__PURE__*/function () {
10264
10216
  chainId: this.chainId
10265
10217
  });
10266
10218
  case 12:
10267
- response = _context25.v;
10219
+ response = _context24.v;
10268
10220
  royaltyTokensDistributionRequests.push.apply(royaltyTokensDistributionRequests, _toConsumableArray(response));
10269
10221
  responses.push({
10270
10222
  txHash: txHash,
@@ -10277,25 +10229,25 @@ var IPAssetClient = /*#__PURE__*/function () {
10277
10229
  })
10278
10230
  });
10279
10231
  case 13:
10280
- _context25.n = 11;
10232
+ _context24.n = 11;
10281
10233
  break;
10282
10234
  case 14:
10283
- _context25.n = 16;
10235
+ _context24.n = 16;
10284
10236
  break;
10285
10237
  case 15:
10286
- _context25.p = 15;
10287
- _t30 = _context25.v;
10288
- _iterator7.e(_t30);
10238
+ _context24.p = 15;
10239
+ _t29 = _context24.v;
10240
+ _iterator7.e(_t29);
10289
10241
  case 16:
10290
- _context25.p = 16;
10242
+ _context24.p = 16;
10291
10243
  _iterator7.f();
10292
- return _context25.f(16);
10244
+ return _context24.f(16);
10293
10245
  case 17:
10294
10246
  if (!(royaltyTokensDistributionRequests.length > 0)) {
10295
- _context25.n = 19;
10247
+ _context24.n = 19;
10296
10248
  break;
10297
10249
  }
10298
- _context25.n = 18;
10250
+ _context24.n = 18;
10299
10251
  return handleMulticall({
10300
10252
  transferWorkflowRequests: royaltyTokensDistributionRequests,
10301
10253
  multicall3Address: this.multicall3Client.address,
@@ -10306,315 +10258,776 @@ var IPAssetClient = /*#__PURE__*/function () {
10306
10258
  chainId: this.chainId
10307
10259
  });
10308
10260
  case 18:
10309
- _yield$handleMultical2 = _context25.v;
10261
+ _yield$handleMultical2 = _context24.v;
10310
10262
  txResponse = _yield$handleMultical2.response;
10311
10263
  distributeRoyaltyTokensTxHashes = txResponse.map(function (tx) {
10312
10264
  return tx.txHash;
10313
10265
  });
10314
10266
  case 19:
10315
- _context25.n = 20;
10267
+ _context24.n = 20;
10316
10268
  return this.processResponses(responses, aggregateRegistrationRequest, ((_request$options10 = request.options) === null || _request$options10 === void 0 || (_request$options10 = _request$options10.wipOptions) === null || _request$options10 === void 0 ? void 0 : _request$options10.useMulticallWhenPossible) !== false);
10317
10269
  case 20:
10318
- registrationResults = _context25.v;
10319
- return _context25.a(2, _objectSpread2({
10270
+ registrationResults = _context24.v;
10271
+ return _context24.a(2, _objectSpread2({
10320
10272
  registrationResults: registrationResults
10321
10273
  }, distributeRoyaltyTokensTxHashes && {
10322
10274
  distributeRoyaltyTokensTxHashes: distributeRoyaltyTokensTxHashes
10323
10275
  }));
10324
10276
  case 21:
10325
- _context25.p = 21;
10326
- _t31 = _context25.v;
10327
- return _context25.a(2, handleError(_t31, "Failed to batch register IP assets with optimized workflows"));
10277
+ _context24.p = 21;
10278
+ _t30 = _context24.v;
10279
+ return _context24.a(2, handleError(_t30, "Failed to batch register IP assets with optimized workflows"));
10328
10280
  }
10329
- }, _callee25, this, [[10, 15, 16, 17], [1, 6, 7, 8], [0, 21]]);
10281
+ }, _callee24, this, [[10, 15, 16, 17], [1, 6, 7, 8], [0, 21]]);
10330
10282
  }));
10331
- function batchRegisterIpAssetsWithOptimizedWorkflows(_x23) {
10283
+ function batchRegisterIpAssetsWithOptimizedWorkflows(_x22) {
10332
10284
  return _batchRegisterIpAssetsWithOptimizedWorkflows.apply(this, arguments);
10333
10285
  }
10334
10286
  return batchRegisterIpAssetsWithOptimizedWorkflows;
10335
- }())
10287
+ }()
10288
+ /**
10289
+ * Register an IP asset, supporting both minted and mint-on-demand NFTs, with optional `licenseTermsData` and `royaltyShares`.
10290
+ *
10291
+ * This method automatically selects and calls the appropriate workflow from 6 available methods based on your input parameters.
10292
+ * Here are three common usage patterns:
10293
+ *
10294
+ * **1. Minted NFT with License Terms and Royalty Distribution:**
10295
+ * ```typescript
10296
+ * const result = await client.ipAsset.registerIpAsset({
10297
+ * nft: { type: "minted", nftContract: "0x...", tokenId: 1n },
10298
+ * licenseTermsData: [
10299
+ * {
10300
+ * terms: PILFlavor.commercialRemix({
10301
+ * defaultMintingFee: 10000n,
10302
+ * commercialRevShare: 100,
10303
+ * currency: "0x..."
10304
+ * })
10305
+ * }
10306
+ * ],
10307
+ * royaltyShares: [
10308
+ * { recipient: "0x...", percentage: 100 }
10309
+ * ]
10310
+ * });
10311
+ * ```
10312
+ *
10313
+ * **2. Minted NFT with Basic License Terms:**
10314
+ * ```typescript
10315
+ * const result = await client.ipAsset.registerIpAsset({
10316
+ * nft: { type: "minted", nftContract: "0x...", tokenId: 1n },
10317
+ * licenseTermsData: [
10318
+ * {
10319
+ * terms: PILFlavor.nonCommercialSocialRemixing()
10320
+ * }
10321
+ * ]
10322
+ * });
10323
+ * ```
10324
+ *
10325
+ * **3. Mint NFT with IP Asset:**
10326
+ * ```typescript
10327
+ * const result = await client.ipAsset.registerIpAsset({
10328
+ * nft: { type: "mint", spgNftContract: "0x...", recipient: "0x...", allowDuplicates: false },
10329
+ * });
10330
+ * ```
10331
+ *
10332
+ * **Supported Workflows (6 methods automatically selected based on parameters):**
10333
+ * - {@link registerIPAndAttachLicenseTermsAndDistributeRoyaltyTokens} - Register IP with license terms and royalty distribution
10334
+ * - {@link registerIpAndAttachPilTerms} - Register IP with license terms
10335
+ * - {@link register} - Register basic IP asset
10336
+ * - {@link mintAndRegisterIpAndAttachPilTermsAndDistributeRoyaltyTokens} - Mint NFT and register IP with license terms and royalty distribution
10337
+ * - {@link mintAndRegisterIpAssetWithPilTerms} - Mint NFT and register IP with license terms
10338
+ * - {@link mintAndRegisterIp} - Mint NFT and register basic IP asset
10339
+ *
10340
+ * **Automatic Token Handling:**
10341
+ * - If the wallet's IP token balance is insufficient to cover minting fees, it automatically wraps native IP tokens into WIP tokens.
10342
+ * - It checks allowances for all required spenders and automatically approves them if their current allowance is lower than needed.
10343
+ * - These automatic processes can be configured through the `wipOptions` parameter to control behavior like multicall usage and approval settings.
10344
+ *
10345
+ * @throws {Error} If the NFT type is invalid.
10346
+ * @throws {Error} If `licenseTermsData` is not provided when `royaltyShares` are specified.
10347
+ *
10348
+ */
10349
+ )
10336
10350
  }, {
10337
- key: "getLicenseTermsId",
10338
- value: function () {
10339
- var _getLicenseTermsId = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee26(licenseTerms) {
10340
- var licenseTermsIds, _iterator8, _step8, licenseTerm, licenseRes, _t32;
10341
- return _regenerator().w(function (_context26) {
10342
- while (1) switch (_context26.p = _context26.n) {
10351
+ key: "registerIpAsset",
10352
+ value: (function () {
10353
+ var _registerIpAsset = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee25(request) {
10354
+ var nft, licenseTermsData, royaltyShares, _t31;
10355
+ return _regenerator().w(function (_context25) {
10356
+ while (1) switch (_context25.p = _context25.n) {
10343
10357
  case 0:
10344
- licenseTermsIds = [];
10345
- _iterator8 = _createForOfIteratorHelper(licenseTerms);
10346
- _context26.p = 1;
10347
- _iterator8.s();
10348
- case 2:
10349
- if ((_step8 = _iterator8.n()).done) {
10350
- _context26.n = 5;
10358
+ _context25.p = 0;
10359
+ nft = request.nft, licenseTermsData = request.licenseTermsData, royaltyShares = request.royaltyShares; // Validate royalty shares without license terms
10360
+ if (!(royaltyShares && !licenseTermsData)) {
10361
+ _context25.n = 1;
10351
10362
  break;
10352
10363
  }
10353
- licenseTerm = _step8.value;
10354
- _context26.n = 3;
10355
- return this.licenseTemplateClient.getLicenseTermsId({
10356
- terms: licenseTerm
10357
- });
10364
+ throw new Error("License terms data must be provided when royalty shares are specified.");
10365
+ case 1:
10366
+ if (!(nft.type === "minted")) {
10367
+ _context25.n = 3;
10368
+ break;
10369
+ }
10370
+ _context25.n = 2;
10371
+ return this.handleMintedNftRegistration(request);
10372
+ case 2:
10373
+ return _context25.a(2, _context25.v);
10358
10374
  case 3:
10359
- licenseRes = _context26.v;
10360
- licenseTermsIds.push(licenseRes.selectedLicenseTermsId);
10375
+ if (!(nft.type === "mint")) {
10376
+ _context25.n = 5;
10377
+ break;
10378
+ }
10379
+ _context25.n = 4;
10380
+ return this.handleMintNftRegistration(request);
10361
10381
  case 4:
10362
- _context26.n = 2;
10363
- break;
10382
+ return _context25.a(2, _context25.v);
10364
10383
  case 5:
10365
- _context26.n = 7;
10366
- break;
10384
+ throw new Error("Invalid NFT type");
10367
10385
  case 6:
10368
- _context26.p = 6;
10369
- _t32 = _context26.v;
10370
- _iterator8.e(_t32);
10386
+ _context25.n = 8;
10387
+ break;
10371
10388
  case 7:
10372
- _context26.p = 7;
10373
- _iterator8.f();
10374
- return _context26.f(7);
10389
+ _context25.p = 7;
10390
+ _t31 = _context25.v;
10391
+ return _context25.a(2, handleError(_t31, "Failed to register IP Asset"));
10375
10392
  case 8:
10376
- return _context26.a(2, licenseTermsIds);
10393
+ return _context25.a(2);
10377
10394
  }
10378
- }, _callee26, this, [[1, 6, 7, 8]]);
10395
+ }, _callee25, this, [[0, 7]]);
10379
10396
  }));
10380
- function getLicenseTermsId(_x24) {
10381
- return _getLicenseTermsId.apply(this, arguments);
10397
+ function registerIpAsset(_x23) {
10398
+ return _registerIpAsset.apply(this, arguments);
10382
10399
  }
10383
- return getLicenseTermsId;
10400
+ return registerIpAsset;
10384
10401
  }()
10402
+ /**
10403
+ * Register a derivative IP asset, supporting both minted and mint-on-demand NFTs, with optional `derivData`, `royaltyShares` and `licenseTokenIds`.
10404
+ *
10405
+ * This method automatically selects and calls the appropriate workflow from 6 available methods based on your input parameters.
10406
+ * Here are three common usage patterns:
10407
+ *
10408
+ * **1. Minted NFT with License Terms and Royalty Distribution:**
10409
+ * ```typescript
10410
+ * const result = await client.ipAsset.registerDerivativeIpAsset({
10411
+ * nft: { type: "minted", nftContract: "0x...", tokenId: 1n },
10412
+ * derivData: {
10413
+ * parentIpIds: ["0x..."],
10414
+ * licenseTermsIds: [1n],
10415
+ * maxMintingFee: 10000n,
10416
+ * maxRevenueShare: 100
10417
+ * },
10418
+ * royaltyShares: [
10419
+ * { recipient: "0x...", percentage: 100 }
10420
+ * ]
10421
+ * });
10422
+ * ```
10423
+ *
10424
+ * **2. Minted NFT with Basic Derivative Registration:**
10425
+ * ```typescript
10426
+ * const result = await client.ipAsset.registerDerivativeIpAsset({
10427
+ * nft: { type: "minted", nftContract: "0x...", tokenId: 1n },
10428
+ * derivData: {
10429
+ * parentIpIds: ["0x..."],
10430
+ * licenseTermsIds: [1n],
10431
+ * maxMintingFee: 10000n,
10432
+ * maxRevenueShare: 100
10433
+ * }
10434
+ * });
10435
+ * ```
10436
+ *
10437
+ * **3. Mint NFT with License Token IDs:**
10438
+ * ```typescript
10439
+ * const result = await client.ipAsset.registerDerivativeIpAsset({
10440
+ * nft: { type: "mint", spgNftContract: "0x...", recipient: "0x...", allowDuplicates: false },
10441
+ * licenseTokenIds: [1, 2, 3],
10442
+ * });
10443
+ * ```
10444
+ *
10445
+ * **Supported Workflows (6 methods automatically selected based on parameters):**
10446
+ * - {@link registerDerivativeIpAndAttachLicenseTermsAndDistributeRoyaltyTokens} - Register derivative with license terms and royalty distribution
10447
+ * - {@link registerDerivativeIp} - Register derivative with basic derivative data
10448
+ * - {@link registerIpAndMakeDerivativeWithLicenseTokens} - Register derivative using existing license tokens
10449
+ * - {@link mintAndRegisterIpAndMakeDerivativeAndDistributeRoyaltyTokens} - Mint NFT and register as derivative with royalty distribution
10450
+ * - {@link mintAndRegisterIpAndMakeDerivative} - Mint NFT and register as derivative
10451
+ * - {@link mintAndRegisterIpAndMakeDerivativeWithLicenseTokens} - Mint NFT and register as derivative using license tokens
10452
+ *
10453
+ * **Automatic Token Handling:**
10454
+ * - If the wallet's IP token balance is insufficient to cover minting fees, it automatically wraps native IP tokens into WIP tokens.
10455
+ * - It checks allowances for all required spenders and automatically approves them if their current allowance is lower than needed.
10456
+ * - These automatic processes can be configured through the `wipOptions` parameter to control behavior like multicall usage and approval settings.
10457
+ *
10458
+ * @throws {Error} If `derivData` is not provided when `royaltyShares` are provided.
10459
+ * @throws {Error} If neither `derivData` nor `licenseTokenIds` are provided.
10460
+ * @throws {Error} If the NFT type is invalid.
10461
+ */
10462
+ )
10385
10463
  }, {
10386
- key: "validateLicenseTokenIds",
10387
- value: function () {
10388
- var _validateLicenseTokenIds = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee27(licenseTokenIds) {
10389
- var newLicenseTokenIds, _iterator9, _step9, licenseTokenId, tokenOwnerAddress, _t33;
10390
- return _regenerator().w(function (_context27) {
10391
- while (1) switch (_context27.p = _context27.n) {
10464
+ key: "registerDerivativeIpAsset",
10465
+ value: (function () {
10466
+ var _registerDerivativeIpAsset = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee26(request) {
10467
+ var nft, licenseTokenIds, royaltyShares, derivData, hasDerivData, hasLicenseTokens, _t32;
10468
+ return _regenerator().w(function (_context26) {
10469
+ while (1) switch (_context26.p = _context26.n) {
10392
10470
  case 0:
10393
- if (!(licenseTokenIds.length === 0)) {
10394
- _context27.n = 1;
10471
+ _context26.p = 0;
10472
+ nft = request.nft, licenseTokenIds = request.licenseTokenIds, royaltyShares = request.royaltyShares, derivData = request.derivData;
10473
+ if (!(royaltyShares && !derivData)) {
10474
+ _context26.n = 1;
10395
10475
  break;
10396
10476
  }
10397
- throw new Error("License token IDs must be provided.");
10477
+ throw new Error("derivData must be provided when royaltyShares are provided.");
10398
10478
  case 1:
10399
- newLicenseTokenIds = licenseTokenIds.map(function (id) {
10400
- return BigInt(id);
10401
- });
10402
- _iterator9 = _createForOfIteratorHelper(newLicenseTokenIds);
10403
- _context27.p = 2;
10404
- _iterator9.s();
10405
- case 3:
10406
- if ((_step9 = _iterator9.n()).done) {
10407
- _context27.n = 6;
10479
+ // Validate that at least one valid combination is provided
10480
+ hasDerivData = !!derivData;
10481
+ hasLicenseTokens = !!(licenseTokenIds && licenseTokenIds.length > 0);
10482
+ if (!(!hasDerivData && !hasLicenseTokens)) {
10483
+ _context26.n = 2;
10408
10484
  break;
10409
10485
  }
10410
- licenseTokenId = _step9.value;
10411
- _context27.n = 4;
10412
- return this.licenseTokenReadOnlyClient.ownerOf({
10413
- tokenId: licenseTokenId
10414
- });
10486
+ throw new Error("Either derivData or licenseTokenIds must be provided.");
10487
+ case 2:
10488
+ if (!(nft.type === "minted")) {
10489
+ _context26.n = 4;
10490
+ break;
10491
+ }
10492
+ _context26.n = 3;
10493
+ return this.handleMintedNftDerivativeRegistration(request);
10494
+ case 3:
10495
+ return _context26.a(2, _context26.v);
10415
10496
  case 4:
10416
- tokenOwnerAddress = _context27.v;
10417
- if (tokenOwnerAddress) {
10418
- _context27.n = 5;
10497
+ if (!(nft.type === "mint")) {
10498
+ _context26.n = 6;
10419
10499
  break;
10420
10500
  }
10421
- throw new Error("License token id ".concat(licenseTokenId, " must be owned by the caller."));
10501
+ _context26.n = 5;
10502
+ return this.handleMintNftDerivativeRegistration(request);
10422
10503
  case 5:
10423
- _context27.n = 3;
10424
- break;
10504
+ return _context26.a(2, _context26.v);
10425
10505
  case 6:
10426
- _context27.n = 8;
10427
- break;
10506
+ throw new Error("Invalid NFT type.");
10428
10507
  case 7:
10429
- _context27.p = 7;
10430
- _t33 = _context27.v;
10431
- _iterator9.e(_t33);
10508
+ _context26.n = 9;
10509
+ break;
10432
10510
  case 8:
10433
- _context27.p = 8;
10434
- _iterator9.f();
10435
- return _context27.f(8);
10511
+ _context26.p = 8;
10512
+ _t32 = _context26.v;
10513
+ return _context26.a(2, handleError(_t32, "Failed to register derivative IP Asset"));
10436
10514
  case 9:
10437
- return _context27.a(2, newLicenseTokenIds);
10515
+ return _context26.a(2);
10438
10516
  }
10439
- }, _callee27, this, [[2, 7, 8, 9]]);
10517
+ }, _callee26, this, [[0, 8]]);
10440
10518
  }));
10441
- function validateLicenseTokenIds(_x25) {
10442
- return _validateLicenseTokenIds.apply(this, arguments);
10519
+ function registerDerivativeIpAsset(_x24) {
10520
+ return _registerDerivativeIpAsset.apply(this, arguments);
10443
10521
  }
10444
- return validateLicenseTokenIds;
10522
+ return registerDerivativeIpAsset;
10445
10523
  }()
10524
+ /**
10525
+ * Handles derivative registration for already minted NFTs with optional `derivData`, `royaltyShares` and `licenseTokenIds`.
10526
+ *
10527
+ * Supports the following workflows:
10528
+ * - {@link registerDerivativeIpAndAttachLicenseTermsAndDistributeRoyaltyTokens}
10529
+ * - {@link registerDerivativeIp}
10530
+ * - {@link registerIpAndMakeDerivativeWithLicenseTokens}
10531
+ */
10532
+ )
10446
10533
  }, {
10447
- key: "getIpIdAndTokenIdsFromEvent",
10448
- value: function getIpIdAndTokenIdsFromEvent(txReceipt, key) {
10449
- var ipRegisteredLog = this.ipAssetRegistryClient.parseTxIpRegisteredEvent(txReceipt);
10450
- return ipRegisteredLog.map(function (log) {
10451
- var baseResult = {
10452
- ipId: log.ipId,
10453
- tokenId: log.tokenId
10454
- };
10455
- if (key) {
10456
- return _objectSpread2(_objectSpread2({}, baseResult), {}, _defineProperty({}, key, log.tokenContract));
10457
- }
10458
- return baseResult;
10459
- });
10460
- }
10461
- }, {
10462
- key: "handleRegistrationWithFees",
10463
- value: function () {
10464
- var _handleRegistrationWithFees = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee28(_ref5) {
10465
- var _wipOptions$useMultic, _this$getIpIdAndToken, _event$ipId, _event$tokenId;
10466
- var sender, derivData, spgNftContract, spgSpenderAddress, txOptions, wipOptions, encodedTxs, contractCall, totalFees, wipSpenders, useMulticallWhenPossible, nftMintFee, publicMinting, totalDerivativeMintingFee, _yield$contractCallWi, txHash, receipt, event;
10467
- return _regenerator().w(function (_context28) {
10468
- while (1) switch (_context28.n) {
10534
+ key: "handleMintedNftDerivativeRegistration",
10535
+ value: (function () {
10536
+ var _handleMintedNftDerivativeRegistration = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee27(request) {
10537
+ var nft, royaltyShares, derivData, maxRts, licenseTokenIds, deadline, txOptions, options, ipMetadata, baseParams;
10538
+ return _regenerator().w(function (_context27) {
10539
+ while (1) switch (_context27.n) {
10469
10540
  case 0:
10470
- sender = _ref5.sender, derivData = _ref5.derivData, spgNftContract = _ref5.spgNftContract, spgSpenderAddress = _ref5.spgSpenderAddress, txOptions = _ref5.txOptions, wipOptions = _ref5.wipOptions, encodedTxs = _ref5.encodedTxs, contractCall = _ref5.contractCall;
10471
- totalFees = 0n;
10472
- wipSpenders = [];
10473
- useMulticallWhenPossible = (_wipOptions$useMultic = wipOptions === null || wipOptions === void 0 ? void 0 : wipOptions.useMulticallWhenPossible) !== null && _wipOptions$useMultic !== void 0 ? _wipOptions$useMultic : true; // get spg minting fee
10474
- if (!spgNftContract) {
10475
- _context28.n = 3;
10541
+ nft = request.nft, royaltyShares = request.royaltyShares, derivData = request.derivData, maxRts = request.maxRts, licenseTokenIds = request.licenseTokenIds, deadline = request.deadline, txOptions = request.txOptions, options = request.options, ipMetadata = request.ipMetadata;
10542
+ baseParams = {
10543
+ nftContract: nft.nftContract,
10544
+ tokenId: nft.tokenId,
10545
+ ipMetadata: ipMetadata,
10546
+ deadline: deadline,
10547
+ txOptions: txOptions,
10548
+ options: options
10549
+ };
10550
+ if (!(royaltyShares && derivData)) {
10551
+ _context27.n = 1;
10476
10552
  break;
10477
10553
  }
10478
- _context28.n = 1;
10479
- return calculateSPGWipMintFee(new SpgnftImplReadOnlyClient(this.rpcClient, spgNftContract));
10554
+ return _context27.a(2, this.registerDerivativeIpAndAttachLicenseTermsAndDistributeRoyaltyTokens(_objectSpread2(_objectSpread2({}, baseParams), {}, {
10555
+ royaltyShares: royaltyShares,
10556
+ derivData: derivData
10557
+ })));
10480
10558
  case 1:
10481
- nftMintFee = _context28.v;
10482
- _context28.n = 2;
10483
- return getPublicMinting(spgNftContract, this.rpcClient);
10484
- case 2:
10485
- publicMinting = _context28.v;
10486
- /**
10487
- * If the SPG NFT contract's public minting is disabled, we need to check if the caller has the `minter role`.
10488
- * When public minting is disabled, we can't use multicall because we need to perform additional role checks
10489
- * that aren't compatible with batched transactions.
10490
- *
10491
- * This is because role-based access control requires the transaction's msg.sender to be verified directly,
10492
- * which is not preserved when using multicall (where the multicall contract becomes the sender).
10493
- */
10494
- if (!publicMinting) {
10495
- useMulticallWhenPossible = false;
10496
- }
10497
- totalFees += nftMintFee;
10498
- wipSpenders.push({
10499
- address: spgNftContract,
10500
- amount: nftMintFee
10501
- });
10502
- case 3:
10503
10559
  if (!derivData) {
10504
- _context28.n = 5;
10505
- break;
10506
- }
10507
- _context28.n = 4;
10508
- return calculateDerivativeMintingFee({
10509
- derivData: derivData,
10510
- rpcClient: this.rpcClient,
10511
- wallet: this.wallet,
10512
- chainId: this.chainId,
10513
- sender: sender
10514
- });
10515
- case 4:
10516
- totalDerivativeMintingFee = _context28.v;
10517
- totalFees += totalDerivativeMintingFee;
10518
- if (totalDerivativeMintingFee > 0) {
10519
- wipSpenders.push({
10520
- address: spgSpenderAddress,
10521
- amount: totalDerivativeMintingFee
10522
- });
10523
- }
10524
- case 5:
10525
- if (!(totalFees < 0)) {
10526
- _context28.n = 6;
10560
+ _context27.n = 2;
10527
10561
  break;
10528
10562
  }
10529
- throw new Error("Total fees for registering derivative should never be negative: ".concat(totalFees));
10530
- case 6:
10531
- _context28.n = 7;
10532
- return contractCallWithFees({
10533
- totalFees: totalFees,
10534
- options: {
10535
- wipOptions: _objectSpread2(_objectSpread2({}, wipOptions), {}, {
10536
- useMulticallWhenPossible: useMulticallWhenPossible
10537
- })
10538
- },
10539
- multicall3Address: this.multicall3Client.address,
10540
- rpcClient: this.rpcClient,
10541
- tokenSpenders: wipSpenders,
10542
- contractCall: contractCall,
10543
- sender: sender,
10544
- wallet: this.wallet,
10545
- txOptions: txOptions,
10546
- encodedTxs: encodedTxs
10547
- });
10548
- case 7:
10549
- _yield$contractCallWi = _context28.v;
10550
- txHash = _yield$contractCallWi.txHash;
10551
- receipt = _yield$contractCallWi.receipt;
10552
- event = (_this$getIpIdAndToken = this.getIpIdAndTokenIdsFromEvent(receipt)) === null || _this$getIpIdAndToken === void 0 ? void 0 : _this$getIpIdAndToken[0];
10553
- return _context28.a(2, _objectSpread2({
10554
- txHash: txHash,
10555
- receipt: receipt
10556
- }, event && {
10557
- ipId: (_event$ipId = event.ipId) !== null && _event$ipId !== void 0 ? _event$ipId : undefined,
10558
- tokenId: (_event$tokenId = event.tokenId) !== null && _event$tokenId !== void 0 ? _event$tokenId : undefined
10559
- }));
10563
+ return _context27.a(2, this.registerDerivativeIp(_objectSpread2(_objectSpread2({}, baseParams), {}, {
10564
+ derivData: derivData
10565
+ })));
10566
+ case 2:
10567
+ return _context27.a(2, this.registerIpAndMakeDerivativeWithLicenseTokens(_objectSpread2(_objectSpread2({}, baseParams), {}, {
10568
+ licenseTokenIds: licenseTokenIds,
10569
+ maxRts: maxRts
10570
+ })));
10560
10571
  }
10561
- }, _callee28, this);
10572
+ }, _callee27, this);
10562
10573
  }));
10563
- function handleRegistrationWithFees(_x26) {
10564
- return _handleRegistrationWithFees.apply(this, arguments);
10574
+ function handleMintedNftDerivativeRegistration(_x25) {
10575
+ return _handleMintedNftDerivativeRegistration.apply(this, arguments);
10565
10576
  }
10566
- return handleRegistrationWithFees;
10577
+ return handleMintedNftDerivativeRegistration;
10567
10578
  }()
10568
- }, {
10569
- key: "setMaxLicenseTokens",
10570
- value: function () {
10571
- var _setMaxLicenseTokens = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee29(_ref6) {
10572
- var maxLicenseTokensData, licensorIpId, licenseTermsIds, licenseTermsMaxLimitTxHashes, i, maxLicenseTokens, txHash;
10573
- return _regenerator().w(function (_context29) {
10574
- while (1) switch (_context29.n) {
10579
+ /**
10580
+ * Handles derivative registration for minted NFTs with optional `derivData`, `royaltyShares` and `licenseTokenIds`.
10581
+ *
10582
+ * Supports the following workflows:
10583
+ * - {@link mintAndRegisterIpAndMakeDerivativeAndDistributeRoyaltyTokens}
10584
+ * - {@link mintAndRegisterIpAndMakeDerivative}
10585
+ * - {@link mintAndRegisterIpAndMakeDerivativeWithLicenseTokens}
10586
+ */
10587
+ )
10588
+ }, {
10589
+ key: "handleMintNftDerivativeRegistration",
10590
+ value: (function () {
10591
+ var _handleMintNftDerivativeRegistration = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee28(request) {
10592
+ var nft, royaltyShares, derivData, maxRts, licenseTokenIds, txOptions, options, ipMetadata, baseParams;
10593
+ return _regenerator().w(function (_context28) {
10594
+ while (1) switch (_context28.n) {
10575
10595
  case 0:
10576
- maxLicenseTokensData = _ref6.maxLicenseTokensData, licensorIpId = _ref6.licensorIpId, licenseTermsIds = _ref6.licenseTermsIds;
10577
- licenseTermsMaxLimitTxHashes = [];
10578
- i = 0;
10596
+ nft = request.nft, royaltyShares = request.royaltyShares, derivData = request.derivData, maxRts = request.maxRts, licenseTokenIds = request.licenseTokenIds, txOptions = request.txOptions, options = request.options, ipMetadata = request.ipMetadata;
10597
+ baseParams = {
10598
+ spgNftContract: nft.spgNftContract,
10599
+ recipient: nft.recipient,
10600
+ allowDuplicates: nft.allowDuplicates,
10601
+ ipMetadata: ipMetadata,
10602
+ txOptions: txOptions,
10603
+ options: options
10604
+ };
10605
+ if (!(royaltyShares && derivData)) {
10606
+ _context28.n = 1;
10607
+ break;
10608
+ }
10609
+ return _context28.a(2, this.mintAndRegisterIpAndMakeDerivativeAndDistributeRoyaltyTokens(_objectSpread2(_objectSpread2({}, baseParams), {}, {
10610
+ royaltyShares: royaltyShares,
10611
+ derivData: derivData
10612
+ })));
10579
10613
  case 1:
10580
- if (!(i < maxLicenseTokensData.length)) {
10581
- _context29.n = 5;
10614
+ if (!derivData) {
10615
+ _context28.n = 2;
10582
10616
  break;
10583
10617
  }
10584
- maxLicenseTokens = maxLicenseTokensData[i].maxLicenseTokens;
10585
- if (!(maxLicenseTokens === undefined || maxLicenseTokens < 0n)) {
10586
- _context29.n = 2;
10618
+ return _context28.a(2, this.mintAndRegisterIpAndMakeDerivative(_objectSpread2(_objectSpread2({}, baseParams), {}, {
10619
+ derivData: derivData
10620
+ })));
10621
+ case 2:
10622
+ return _context28.a(2, this.mintAndRegisterIpAndMakeDerivativeWithLicenseTokens(_objectSpread2(_objectSpread2({}, baseParams), {}, {
10623
+ licenseTokenIds: licenseTokenIds,
10624
+ maxRts: maxRts
10625
+ })));
10626
+ }
10627
+ }, _callee28, this);
10628
+ }));
10629
+ function handleMintNftDerivativeRegistration(_x26) {
10630
+ return _handleMintNftDerivativeRegistration.apply(this, arguments);
10631
+ }
10632
+ return handleMintNftDerivativeRegistration;
10633
+ }()
10634
+ /**
10635
+ * Link a derivative IP asset using parent IP's license terms or license tokens.
10636
+ *
10637
+ * Supports the following workflows:
10638
+ * - {@link registerDerivative}
10639
+ * - {@link registerDerivativeWithLicenseTokens}
10640
+ *
10641
+ * @example
10642
+ * ```typescript
10643
+ * const result = await client.ipAsset.linkDerivative({
10644
+ * licenseTokenIds: [1, 2, 3],
10645
+ * childIpId: "0x...",
10646
+ * });
10647
+ * ```
10648
+ *
10649
+ * @example
10650
+ * ```typescript
10651
+ * const result = await client.ipAsset.linkDerivative({
10652
+ * parentIpIds: ["0x..."],
10653
+ * licenseTermsIds: [1],
10654
+ * childIpId: "0x...",
10655
+ * });
10656
+ * ```
10657
+ *
10658
+ * **Automatic Token Handling:**
10659
+ * - If the wallet's IP token balance is insufficient to cover minting fees, it automatically wraps native IP tokens into WIP tokens.
10660
+ * - It checks allowances for all required spenders and automatically approves them if their current allowance is lower than needed.
10661
+ * - These automatic processes can be configured through the `wipOptions` parameter to control behavior like multicall usage and approval settings.
10662
+ */
10663
+ )
10664
+ }, {
10665
+ key: "linkDerivative",
10666
+ value: (function () {
10667
+ var _linkDerivative = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee29(request) {
10668
+ var _t33;
10669
+ return _regenerator().w(function (_context29) {
10670
+ while (1) switch (_context29.p = _context29.n) {
10671
+ case 0:
10672
+ _context29.p = 0;
10673
+ if (!("parentIpIds" in request)) {
10674
+ _context29.n = 1;
10587
10675
  break;
10588
10676
  }
10589
- return _context29.a(3, 4);
10677
+ return _context29.a(2, this.registerDerivative(request));
10678
+ case 1:
10679
+ return _context29.a(2, this.registerDerivativeWithLicenseTokens(request));
10590
10680
  case 2:
10591
- _context29.n = 3;
10592
- return this.totalLicenseTokenLimitHookClient.setTotalLicenseTokenLimit({
10593
- licensorIpId: licensorIpId,
10594
- // The contract now directly writes the `licenseTemplate` address internally,
10595
- // so we no longer need to pass it as a parameter
10596
- licenseTemplate: this.licenseTemplateClient.address,
10597
- licenseTermsId: licenseTermsIds[i],
10598
- limit: BigInt(maxLicenseTokens)
10681
+ _context29.n = 4;
10682
+ break;
10683
+ case 3:
10684
+ _context29.p = 3;
10685
+ _t33 = _context29.v;
10686
+ return _context29.a(2, handleError(_t33, "Failed to link derivative"));
10687
+ case 4:
10688
+ return _context29.a(2);
10689
+ }
10690
+ }, _callee29, this, [[0, 3]]);
10691
+ }));
10692
+ function linkDerivative(_x27) {
10693
+ return _linkDerivative.apply(this, arguments);
10694
+ }
10695
+ return linkDerivative;
10696
+ }()
10697
+ /**
10698
+ * Handles registration for already minted NFTs with optional license terms and royalty shares.
10699
+ *
10700
+ * Supports the following workflows:
10701
+ * - {@link registerIPAndAttachLicenseTermsAndDistributeRoyaltyTokens}
10702
+ * - {@link registerIpAndAttachPilTerms}
10703
+ * - {@link register}
10704
+ */
10705
+ )
10706
+ }, {
10707
+ key: "handleMintedNftRegistration",
10708
+ value: (function () {
10709
+ var _handleMintedNftRegistration = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee30(request) {
10710
+ var nft, ipMetadata, txOptions, licenseTermsData, royaltyShares, deadline, baseParams;
10711
+ return _regenerator().w(function (_context30) {
10712
+ while (1) switch (_context30.n) {
10713
+ case 0:
10714
+ nft = request.nft, ipMetadata = request.ipMetadata, txOptions = request.txOptions, licenseTermsData = request.licenseTermsData, royaltyShares = request.royaltyShares, deadline = request.deadline;
10715
+ baseParams = {
10716
+ nftContract: nft.nftContract,
10717
+ tokenId: nft.tokenId,
10718
+ ipMetadata: ipMetadata,
10719
+ deadline: deadline,
10720
+ txOptions: txOptions
10721
+ };
10722
+ if (!(licenseTermsData && royaltyShares)) {
10723
+ _context30.n = 1;
10724
+ break;
10725
+ }
10726
+ return _context30.a(2, this.registerIPAndAttachLicenseTermsAndDistributeRoyaltyTokens(_objectSpread2(_objectSpread2({}, baseParams), {}, {
10727
+ licenseTermsData: licenseTermsData,
10728
+ royaltyShares: royaltyShares
10729
+ })));
10730
+ case 1:
10731
+ if (!licenseTermsData) {
10732
+ _context30.n = 2;
10733
+ break;
10734
+ }
10735
+ return _context30.a(2, this.registerIpAndAttachPilTerms(_objectSpread2(_objectSpread2({}, baseParams), {}, {
10736
+ licenseTermsData: licenseTermsData
10737
+ })));
10738
+ case 2:
10739
+ return _context30.a(2, this.register(_objectSpread2({}, baseParams)));
10740
+ }
10741
+ }, _callee30, this);
10742
+ }));
10743
+ function handleMintedNftRegistration(_x28) {
10744
+ return _handleMintedNftRegistration.apply(this, arguments);
10745
+ }
10746
+ return handleMintedNftRegistration;
10747
+ }()
10748
+ /**
10749
+ * Handles minting and registration of new NFTs with optional license terms and royalty shares.
10750
+ *
10751
+ * Supports the following workflows:
10752
+ * - {@link mintAndRegisterIpAndAttachPilTermsAndDistributeRoyaltyTokens}
10753
+ * - {@link mintAndRegisterIpAssetWithPilTerms}
10754
+ * - {@link mintAndRegisterIp}
10755
+ */
10756
+ )
10757
+ }, {
10758
+ key: "handleMintNftRegistration",
10759
+ value: (function () {
10760
+ var _handleMintNftRegistration = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee31(request) {
10761
+ var nft, ipMetadata, txOptions, options, licenseTermsData, royaltyShares, baseParams;
10762
+ return _regenerator().w(function (_context31) {
10763
+ while (1) switch (_context31.n) {
10764
+ case 0:
10765
+ nft = request.nft, ipMetadata = request.ipMetadata, txOptions = request.txOptions, options = request.options, licenseTermsData = request.licenseTermsData, royaltyShares = request.royaltyShares;
10766
+ baseParams = {
10767
+ spgNftContract: nft.spgNftContract,
10768
+ recipient: nft.recipient,
10769
+ allowDuplicates: nft.allowDuplicates,
10770
+ ipMetadata: ipMetadata,
10771
+ txOptions: txOptions,
10772
+ options: options
10773
+ };
10774
+ if (!(licenseTermsData && royaltyShares)) {
10775
+ _context31.n = 1;
10776
+ break;
10777
+ }
10778
+ return _context31.a(2, this.mintAndRegisterIpAndAttachPilTermsAndDistributeRoyaltyTokens(_objectSpread2(_objectSpread2({}, baseParams), {}, {
10779
+ licenseTermsData: licenseTermsData,
10780
+ royaltyShares: royaltyShares
10781
+ })));
10782
+ case 1:
10783
+ if (!licenseTermsData) {
10784
+ _context31.n = 2;
10785
+ break;
10786
+ }
10787
+ return _context31.a(2, this.mintAndRegisterIpAssetWithPilTerms(_objectSpread2(_objectSpread2({}, baseParams), {}, {
10788
+ licenseTermsData: licenseTermsData
10789
+ })));
10790
+ case 2:
10791
+ return _context31.a(2, this.mintAndRegisterIp(_objectSpread2({}, baseParams)));
10792
+ }
10793
+ }, _callee31, this);
10794
+ }));
10795
+ function handleMintNftRegistration(_x29) {
10796
+ return _handleMintNftRegistration.apply(this, arguments);
10797
+ }
10798
+ return handleMintNftRegistration;
10799
+ }())
10800
+ }, {
10801
+ key: "getLicenseTermsId",
10802
+ value: function () {
10803
+ var _getLicenseTermsId = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee32(licenseTerms) {
10804
+ var licenseTermsIds, _iterator8, _step8, licenseTerm, licenseRes, _t34;
10805
+ return _regenerator().w(function (_context32) {
10806
+ while (1) switch (_context32.p = _context32.n) {
10807
+ case 0:
10808
+ licenseTermsIds = [];
10809
+ _iterator8 = _createForOfIteratorHelper(licenseTerms);
10810
+ _context32.p = 1;
10811
+ _iterator8.s();
10812
+ case 2:
10813
+ if ((_step8 = _iterator8.n()).done) {
10814
+ _context32.n = 5;
10815
+ break;
10816
+ }
10817
+ licenseTerm = _step8.value;
10818
+ _context32.n = 3;
10819
+ return this.licenseTemplateClient.getLicenseTermsId({
10820
+ terms: licenseTerm
10599
10821
  });
10600
10822
  case 3:
10601
- txHash = _context29.v;
10602
- if (txHash) {
10603
- licenseTermsMaxLimitTxHashes.push(txHash);
10823
+ licenseRes = _context32.v;
10824
+ licenseTermsIds.push(licenseRes.selectedLicenseTermsId);
10825
+ case 4:
10826
+ _context32.n = 2;
10827
+ break;
10828
+ case 5:
10829
+ _context32.n = 7;
10830
+ break;
10831
+ case 6:
10832
+ _context32.p = 6;
10833
+ _t34 = _context32.v;
10834
+ _iterator8.e(_t34);
10835
+ case 7:
10836
+ _context32.p = 7;
10837
+ _iterator8.f();
10838
+ return _context32.f(7);
10839
+ case 8:
10840
+ return _context32.a(2, licenseTermsIds);
10841
+ }
10842
+ }, _callee32, this, [[1, 6, 7, 8]]);
10843
+ }));
10844
+ function getLicenseTermsId(_x30) {
10845
+ return _getLicenseTermsId.apply(this, arguments);
10846
+ }
10847
+ return getLicenseTermsId;
10848
+ }()
10849
+ }, {
10850
+ key: "validateLicenseTokenIds",
10851
+ value: function () {
10852
+ var _validateLicenseTokenIds = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee33(licenseTokenIds) {
10853
+ var newLicenseTokenIds, _iterator9, _step9, licenseTokenId, tokenOwnerAddress, _t35;
10854
+ return _regenerator().w(function (_context33) {
10855
+ while (1) switch (_context33.p = _context33.n) {
10856
+ case 0:
10857
+ if (!(licenseTokenIds.length === 0)) {
10858
+ _context33.n = 1;
10859
+ break;
10604
10860
  }
10861
+ throw new Error("License token IDs must be provided.");
10862
+ case 1:
10863
+ newLicenseTokenIds = licenseTokenIds.map(function (id) {
10864
+ return BigInt(id);
10865
+ });
10866
+ _iterator9 = _createForOfIteratorHelper(newLicenseTokenIds);
10867
+ _context33.p = 2;
10868
+ _iterator9.s();
10869
+ case 3:
10870
+ if ((_step9 = _iterator9.n()).done) {
10871
+ _context33.n = 6;
10872
+ break;
10873
+ }
10874
+ licenseTokenId = _step9.value;
10875
+ _context33.n = 4;
10876
+ return this.licenseTokenReadOnlyClient.ownerOf({
10877
+ tokenId: licenseTokenId
10878
+ });
10605
10879
  case 4:
10606
- i++;
10607
- _context29.n = 1;
10880
+ tokenOwnerAddress = _context33.v;
10881
+ if (tokenOwnerAddress) {
10882
+ _context33.n = 5;
10883
+ break;
10884
+ }
10885
+ throw new Error("License token id ".concat(licenseTokenId, " must be owned by the caller."));
10886
+ case 5:
10887
+ _context33.n = 3;
10608
10888
  break;
10889
+ case 6:
10890
+ _context33.n = 8;
10891
+ break;
10892
+ case 7:
10893
+ _context33.p = 7;
10894
+ _t35 = _context33.v;
10895
+ _iterator9.e(_t35);
10896
+ case 8:
10897
+ _context33.p = 8;
10898
+ _iterator9.f();
10899
+ return _context33.f(8);
10900
+ case 9:
10901
+ return _context33.a(2, newLicenseTokenIds);
10902
+ }
10903
+ }, _callee33, this, [[2, 7, 8, 9]]);
10904
+ }));
10905
+ function validateLicenseTokenIds(_x31) {
10906
+ return _validateLicenseTokenIds.apply(this, arguments);
10907
+ }
10908
+ return validateLicenseTokenIds;
10909
+ }()
10910
+ }, {
10911
+ key: "getIpIdAndTokenIdsFromEvent",
10912
+ value: function getIpIdAndTokenIdsFromEvent(txReceipt, key) {
10913
+ var ipRegisteredLog = this.ipAssetRegistryClient.parseTxIpRegisteredEvent(txReceipt);
10914
+ return ipRegisteredLog.map(function (log) {
10915
+ var baseResult = {
10916
+ ipId: log.ipId,
10917
+ tokenId: log.tokenId
10918
+ };
10919
+ if (key) {
10920
+ return _objectSpread2(_objectSpread2({}, baseResult), {}, _defineProperty({}, key, log.tokenContract));
10921
+ }
10922
+ return baseResult;
10923
+ });
10924
+ }
10925
+ }, {
10926
+ key: "handleRegistrationWithFees",
10927
+ value: function () {
10928
+ var _handleRegistrationWithFees = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee34(_ref5) {
10929
+ var _wipOptions$useMultic, _this$getIpIdAndToken, _event$ipId, _event$tokenId;
10930
+ var sender, derivData, spgNftContract, spgSpenderAddress, txOptions, wipOptions, encodedTxs, contractCall, totalFees, wipSpenders, useMulticallWhenPossible, nftMintFee, publicMinting, totalDerivativeMintingFee, _yield$contractCallWi, txHash, receipt, event;
10931
+ return _regenerator().w(function (_context34) {
10932
+ while (1) switch (_context34.n) {
10933
+ case 0:
10934
+ sender = _ref5.sender, derivData = _ref5.derivData, spgNftContract = _ref5.spgNftContract, spgSpenderAddress = _ref5.spgSpenderAddress, txOptions = _ref5.txOptions, wipOptions = _ref5.wipOptions, encodedTxs = _ref5.encodedTxs, contractCall = _ref5.contractCall;
10935
+ totalFees = 0n;
10936
+ wipSpenders = [];
10937
+ useMulticallWhenPossible = (_wipOptions$useMultic = wipOptions === null || wipOptions === void 0 ? void 0 : wipOptions.useMulticallWhenPossible) !== null && _wipOptions$useMultic !== void 0 ? _wipOptions$useMultic : true; // get spg minting fee
10938
+ if (!spgNftContract) {
10939
+ _context34.n = 3;
10940
+ break;
10941
+ }
10942
+ _context34.n = 1;
10943
+ return calculateSPGWipMintFee(new SpgnftImplReadOnlyClient(this.rpcClient, spgNftContract));
10944
+ case 1:
10945
+ nftMintFee = _context34.v;
10946
+ _context34.n = 2;
10947
+ return getPublicMinting(spgNftContract, this.rpcClient);
10948
+ case 2:
10949
+ publicMinting = _context34.v;
10950
+ /**
10951
+ * If the SPG NFT contract's public minting is disabled, we need to check if the caller has the `minter role`.
10952
+ * When public minting is disabled, we can't use multicall because we need to perform additional role checks
10953
+ * that aren't compatible with batched transactions.
10954
+ *
10955
+ * This is because role-based access control requires the transaction's msg.sender to be verified directly,
10956
+ * which is not preserved when using multicall (where the multicall contract becomes the sender).
10957
+ */
10958
+ if (!publicMinting) {
10959
+ useMulticallWhenPossible = false;
10960
+ }
10961
+ totalFees += nftMintFee;
10962
+ wipSpenders.push({
10963
+ address: spgNftContract,
10964
+ amount: nftMintFee
10965
+ });
10966
+ case 3:
10967
+ if (!derivData) {
10968
+ _context34.n = 5;
10969
+ break;
10970
+ }
10971
+ _context34.n = 4;
10972
+ return calculateDerivativeMintingFee({
10973
+ derivData: derivData,
10974
+ rpcClient: this.rpcClient,
10975
+ wallet: this.wallet,
10976
+ chainId: this.chainId,
10977
+ sender: sender
10978
+ });
10979
+ case 4:
10980
+ totalDerivativeMintingFee = _context34.v;
10981
+ totalFees += totalDerivativeMintingFee;
10982
+ if (totalDerivativeMintingFee > 0) {
10983
+ wipSpenders.push({
10984
+ address: spgSpenderAddress,
10985
+ amount: totalDerivativeMintingFee
10986
+ });
10987
+ }
10609
10988
  case 5:
10610
- return _context29.a(2, licenseTermsMaxLimitTxHashes);
10989
+ if (!(totalFees < 0)) {
10990
+ _context34.n = 6;
10991
+ break;
10992
+ }
10993
+ throw new Error("Total fees for registering derivative should never be negative: ".concat(totalFees));
10994
+ case 6:
10995
+ _context34.n = 7;
10996
+ return contractCallWithFees({
10997
+ totalFees: totalFees,
10998
+ options: {
10999
+ wipOptions: _objectSpread2(_objectSpread2({}, wipOptions), {}, {
11000
+ useMulticallWhenPossible: useMulticallWhenPossible
11001
+ })
11002
+ },
11003
+ multicall3Address: this.multicall3Client.address,
11004
+ rpcClient: this.rpcClient,
11005
+ tokenSpenders: wipSpenders,
11006
+ contractCall: contractCall,
11007
+ sender: sender,
11008
+ wallet: this.wallet,
11009
+ txOptions: txOptions,
11010
+ encodedTxs: encodedTxs
11011
+ });
11012
+ case 7:
11013
+ _yield$contractCallWi = _context34.v;
11014
+ txHash = _yield$contractCallWi.txHash;
11015
+ receipt = _yield$contractCallWi.receipt;
11016
+ event = (_this$getIpIdAndToken = this.getIpIdAndTokenIdsFromEvent(receipt)) === null || _this$getIpIdAndToken === void 0 ? void 0 : _this$getIpIdAndToken[0];
11017
+ return _context34.a(2, _objectSpread2({
11018
+ txHash: txHash,
11019
+ receipt: receipt
11020
+ }, event && {
11021
+ ipId: (_event$ipId = event.ipId) !== null && _event$ipId !== void 0 ? _event$ipId : undefined,
11022
+ tokenId: (_event$tokenId = event.tokenId) !== null && _event$tokenId !== void 0 ? _event$tokenId : undefined
11023
+ }));
10611
11024
  }
10612
- }, _callee29, this);
11025
+ }, _callee34, this);
10613
11026
  }));
10614
- function setMaxLicenseTokens(_x27) {
10615
- return _setMaxLicenseTokens.apply(this, arguments);
11027
+ function handleRegistrationWithFees(_x32) {
11028
+ return _handleRegistrationWithFees.apply(this, arguments);
10616
11029
  }
10617
- return setMaxLicenseTokens;
11030
+ return handleRegistrationWithFees;
10618
11031
  }()
10619
11032
  /**
10620
11033
  * Process the `LicenseTermsIds` and `maxLicenseTokensTxHashes` for each IP asset.
@@ -10622,69 +11035,69 @@ var IPAssetClient = /*#__PURE__*/function () {
10622
11035
  }, {
10623
11036
  key: "processResponses",
10624
11037
  value: (function () {
10625
- var _processResponses = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee30(responses, aggregateRegistrationRequest, useMulticall) {
10626
- var _iterator0, _step0, _step0$value, responseIndex, response, _iterator1, _step1, _Object$values$respon, _step1$value, assetIndex, ipAsset, extraData, result, _extraData, i, _response, extraDataItem, _ipAsset, _t34, _t35;
10627
- return _regenerator().w(function (_context30) {
10628
- while (1) switch (_context30.p = _context30.n) {
11038
+ var _processResponses = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee35(responses, aggregateRegistrationRequest, useMulticall) {
11039
+ var _iterator0, _step0, _step0$value, responseIndex, response, _iterator1, _step1, _Object$values$respon, _step1$value, assetIndex, ipAsset, extraData, result, _extraData, i, _response, extraDataItem, _ipAsset, _t36, _t37;
11040
+ return _regenerator().w(function (_context35) {
11041
+ while (1) switch (_context35.p = _context35.n) {
10629
11042
  case 0:
10630
11043
  if (!useMulticall) {
10631
- _context30.n = 15;
11044
+ _context35.n = 15;
10632
11045
  break;
10633
11046
  }
10634
11047
  _iterator0 = _createForOfIteratorHelper(responses.entries());
10635
- _context30.p = 1;
11048
+ _context35.p = 1;
10636
11049
  _iterator0.s();
10637
11050
  case 2:
10638
11051
  if ((_step0 = _iterator0.n()).done) {
10639
- _context30.n = 11;
11052
+ _context35.n = 11;
10640
11053
  break;
10641
11054
  }
10642
11055
  _step0$value = _slicedToArray(_step0.value, 2), responseIndex = _step0$value[0], response = _step0$value[1];
10643
11056
  _iterator1 = _createForOfIteratorHelper(response.ipAssetsWithLicenseTerms.entries());
10644
- _context30.p = 3;
11057
+ _context35.p = 3;
10645
11058
  _iterator1.s();
10646
11059
  case 4:
10647
11060
  if ((_step1 = _iterator1.n()).done) {
10648
- _context30.n = 7;
11061
+ _context35.n = 7;
10649
11062
  break;
10650
11063
  }
10651
11064
  _step1$value = _slicedToArray(_step1.value, 2), assetIndex = _step1$value[0], ipAsset = _step1$value[1];
10652
11065
  extraData = (_Object$values$respon = Object.values(aggregateRegistrationRequest)[responseIndex]) === null || _Object$values$respon === void 0 || (_Object$values$respon = _Object$values$respon.extraData) === null || _Object$values$respon === void 0 ? void 0 : _Object$values$respon[assetIndex];
10653
- _context30.n = 5;
11066
+ _context35.n = 5;
10654
11067
  return this.processIpAssetLicenseTerms(ipAsset, extraData);
10655
11068
  case 5:
10656
- result = _context30.v;
11069
+ result = _context35.v;
10657
11070
  responses[responseIndex].ipAssetsWithLicenseTerms[assetIndex] = result;
10658
11071
  case 6:
10659
- _context30.n = 4;
11072
+ _context35.n = 4;
10660
11073
  break;
10661
11074
  case 7:
10662
- _context30.n = 9;
11075
+ _context35.n = 9;
10663
11076
  break;
10664
11077
  case 8:
10665
- _context30.p = 8;
10666
- _t34 = _context30.v;
10667
- _iterator1.e(_t34);
11078
+ _context35.p = 8;
11079
+ _t36 = _context35.v;
11080
+ _iterator1.e(_t36);
10668
11081
  case 9:
10669
- _context30.p = 9;
11082
+ _context35.p = 9;
10670
11083
  _iterator1.f();
10671
- return _context30.f(9);
11084
+ return _context35.f(9);
10672
11085
  case 10:
10673
- _context30.n = 2;
11086
+ _context35.n = 2;
10674
11087
  break;
10675
11088
  case 11:
10676
- _context30.n = 13;
11089
+ _context35.n = 13;
10677
11090
  break;
10678
11091
  case 12:
10679
- _context30.p = 12;
10680
- _t35 = _context30.v;
10681
- _iterator0.e(_t35);
11092
+ _context35.p = 12;
11093
+ _t37 = _context35.v;
11094
+ _iterator0.e(_t37);
10682
11095
  case 13:
10683
- _context30.p = 13;
11096
+ _context35.p = 13;
10684
11097
  _iterator0.f();
10685
- return _context30.f(13);
11098
+ return _context35.f(13);
10686
11099
  case 14:
10687
- _context30.n = 19;
11100
+ _context35.n = 19;
10688
11101
  break;
10689
11102
  case 15:
10690
11103
  _extraData = [];
@@ -10695,299 +11108,140 @@ var IPAssetClient = /*#__PURE__*/function () {
10695
11108
  i = 0;
10696
11109
  case 16:
10697
11110
  if (!(i < responses.length)) {
10698
- _context30.n = 19;
11111
+ _context35.n = 19;
10699
11112
  break;
10700
11113
  }
10701
11114
  _response = responses[i];
10702
11115
  extraDataItem = _extraData[i];
10703
- _context30.n = 17;
11116
+ _context35.n = 17;
10704
11117
  return this.processIpAssetLicenseTerms(_response.ipAssetsWithLicenseTerms[0], extraDataItem);
10705
11118
  case 17:
10706
- _ipAsset = _context30.v;
11119
+ _ipAsset = _context35.v;
10707
11120
  responses[i].ipAssetsWithLicenseTerms[0] = _ipAsset;
10708
11121
  case 18:
10709
11122
  i++;
10710
- _context30.n = 16;
11123
+ _context35.n = 16;
10711
11124
  break;
10712
11125
  case 19:
10713
- return _context30.a(2, responses);
11126
+ return _context35.a(2, responses);
10714
11127
  }
10715
- }, _callee30, this, [[3, 8, 9, 10], [1, 12, 13, 14]]);
11128
+ }, _callee35, this, [[3, 8, 9, 10], [1, 12, 13, 14]]);
10716
11129
  }));
10717
- function processResponses(_x28, _x29, _x30) {
11130
+ function processResponses(_x33, _x34, _x35) {
10718
11131
  return _processResponses.apply(this, arguments);
10719
11132
  }
10720
11133
  return processResponses;
10721
11134
  }())
10722
- }, {
10723
- key: "processIpAssetLicenseTerms",
10724
- value: function () {
10725
- var _processIpAssetLicenseTerms = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee31(ipAsset, extraData) {
10726
- var _extraData$licenseTer;
10727
- var licenseTermsIds, maxLicenseTokens, maxLicenseTokensData, maxLicenseTokensTxHashes;
10728
- return _regenerator().w(function (_context31) {
10729
- while (1) switch (_context31.n) {
10730
- case 0:
10731
- if (extraData !== null && extraData !== void 0 && (_extraData$licenseTer = extraData.licenseTermsData) !== null && _extraData$licenseTer !== void 0 && _extraData$licenseTer.length) {
10732
- _context31.n = 1;
10733
- break;
10734
- }
10735
- return _context31.a(2, ipAsset);
10736
- case 1:
10737
- _context31.n = 2;
10738
- return this.getLicenseTermsId(extraData.licenseTermsData.map(function (item) {
10739
- return item.terms;
10740
- }));
10741
- case 2:
10742
- licenseTermsIds = _context31.v;
10743
- ipAsset.licenseTermsIds = licenseTermsIds;
10744
- maxLicenseTokens = extraData.maxLicenseTokens;
10745
- if (maxLicenseTokens !== null && maxLicenseTokens !== void 0 && maxLicenseTokens.length) {
10746
- _context31.n = 3;
10747
- break;
10748
- }
10749
- return _context31.a(2, ipAsset);
10750
- case 3:
10751
- maxLicenseTokensData = maxLicenseTokens.filter(function (maxLicenseToken) {
10752
- return maxLicenseToken !== undefined;
10753
- }).map(function (maxLicenseToken) {
10754
- return {
10755
- maxLicenseTokens: maxLicenseToken
10756
- };
10757
- });
10758
- _context31.n = 4;
10759
- return this.setMaxLicenseTokens({
10760
- maxLicenseTokensData: maxLicenseTokensData,
10761
- licensorIpId: ipAsset.ipId,
10762
- licenseTermsIds: licenseTermsIds
10763
- });
10764
- case 4:
10765
- maxLicenseTokensTxHashes = _context31.v;
10766
- if (maxLicenseTokensTxHashes !== null && maxLicenseTokensTxHashes !== void 0 && maxLicenseTokensTxHashes.length) {
10767
- ipAsset.maxLicenseTokensTxHashes = maxLicenseTokensTxHashes;
10768
- }
10769
- return _context31.a(2, ipAsset);
10770
- }
10771
- }, _callee31, this);
10772
- }));
10773
- function processIpAssetLicenseTerms(_x31, _x32) {
10774
- return _processIpAssetLicenseTerms.apply(this, arguments);
10775
- }
10776
- return processIpAssetLicenseTerms;
10777
- }()
10778
- }]);
10779
- }();
10780
-
10781
- var LicenseClient = /*#__PURE__*/function () {
10782
- function LicenseClient(rpcClient, wallet, chainId) {
10783
- _classCallCheck(this, LicenseClient);
10784
- this.licensingModuleClient = new LicensingModuleClient(rpcClient, wallet);
10785
- this.piLicenseTemplateReadOnlyClient = new PiLicenseTemplateReadOnlyClient(rpcClient);
10786
- this.licenseTemplateClient = new PiLicenseTemplateClient(rpcClient, wallet);
10787
- this.licenseRegistryReadOnlyClient = new LicenseRegistryReadOnlyClient(rpcClient);
10788
- this.ipAssetRegistryClient = new IpAssetRegistryClient(rpcClient, wallet);
10789
- this.moduleRegistryReadOnlyClient = new ModuleRegistryReadOnlyClient(rpcClient);
10790
- this.multicall3Client = new Multicall3Client(rpcClient, wallet);
10791
- this.wipClient = new WrappedIpClient(rpcClient, wallet);
10792
- this.totalLicenseTokenLimitHookClient = new TotalLicenseTokenLimitHookClient(rpcClient, wallet);
10793
- this.rpcClient = rpcClient;
10794
- this.wallet = wallet;
10795
- this.chainId = chainId;
10796
- this.walletAddress = wallet.account.address;
10797
- }
10798
-
10799
- /**
10800
- * Registers new license terms and return the ID of the newly registered license terms.
10801
- *
10802
- * Emits an on-chain {@link https://github.com/storyprotocol/protocol-core-v1/blob/v1.3.1/contracts/interfaces/modules/licensing/ILicenseTemplate.sol#L19 | `LicenseTermsRegistered`} event.
10803
- */
10804
- return _createClass(LicenseClient, [{
10805
- key: "registerPILTerms",
10806
- value: (function () {
10807
- var _registerPILTerms = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(request) {
10808
- var object, _t;
10809
- return _regenerator().w(function (_context) {
10810
- while (1) switch (_context.p = _context.n) {
10811
- case 0:
10812
- _context.p = 0;
10813
- object = PILFlavor.validateLicenseTerms(request, this.chainId);
10814
- _context.n = 1;
10815
- return this.registerPILTermsHelper(object, request.txOptions);
10816
- case 1:
10817
- return _context.a(2, _context.v);
10818
- case 2:
10819
- _context.p = 2;
10820
- _t = _context.v;
10821
- return _context.a(2, handleError(_t, "Failed to register license terms"));
10822
- }
10823
- }, _callee, this, [[0, 2]]);
10824
- }));
10825
- function registerPILTerms(_x) {
10826
- return _registerPILTerms.apply(this, arguments);
10827
- }
10828
- return registerPILTerms;
10829
- }()
10830
- /**
10831
- * @deprecated Use {@link PILFlavor.nonCommercialSocialRemixing} with {@link LicenseClient.registerPILTerms} instead.
10832
- * The method will be removed in the `v1.4.0`.
10833
- *
10834
- * Convenient function to register a PIL non commercial social remix license to the registry
10835
- *
10836
- * For more details, see {@link https://docs.story.foundation/concepts/programmable-ip-license/pil-flavors#flavor-%231%3A-non-commercial-social-remixing | Non Commercial Social Remixing}.
10837
- *
10838
- * Emits an on-chain {@link https://github.com/storyprotocol/protocol-core-v1/blob/v1.3.1/contracts/interfaces/modules/licensing/ILicenseTemplate.sol#L19 | `LicenseTermsRegistered`} event.
10839
- */
10840
- )
10841
- }, {
10842
- key: "registerNonComSocialRemixingPIL",
10843
- value: (function () {
10844
- var _registerNonComSocialRemixingPIL = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(request) {
10845
- var licenseTerms, _t2;
10846
- return _regenerator().w(function (_context2) {
10847
- while (1) switch (_context2.p = _context2.n) {
10848
- case 0:
10849
- _context2.p = 0;
10850
- licenseTerms = PILFlavor.nonCommercialSocialRemixing();
10851
- _context2.n = 1;
10852
- return this.registerPILTermsHelper(licenseTerms, request === null || request === void 0 ? void 0 : request.txOptions);
10853
- case 1:
10854
- return _context2.a(2, _context2.v);
10855
- case 2:
10856
- _context2.p = 2;
10857
- _t2 = _context2.v;
10858
- return _context2.a(2, handleError(_t2, "Failed to register non commercial social remixing PIL"));
10859
- }
10860
- }, _callee2, this, [[0, 2]]);
10861
- }));
10862
- function registerNonComSocialRemixingPIL(_x2) {
10863
- return _registerNonComSocialRemixingPIL.apply(this, arguments);
10864
- }
10865
- return registerNonComSocialRemixingPIL;
10866
- }()
10867
- /**
10868
- * @deprecated Use {@link PILFlavor.commercialUse} with {@link LicenseClient.registerPILTerms} instead.
10869
- * The method will be removed in the `v1.4.0`.
10870
- *
10871
- * Convenient function to register a PIL commercial use license to the registry.
10872
- *
10873
- * For more details, see {@link https://docs.story.foundation/concepts/programmable-ip-license/pil-flavors#flavor-%232%3A-commercial-use | Commercial Use}.
10874
- *
10875
- * Emits an on-chain {@link https://github.com/storyprotocol/protocol-core-v1/blob/v1.3.1/contracts/interfaces/modules/licensing/ILicenseTemplate.sol#L19 | `LicenseTermsRegistered`} event.
10876
- */
10877
- )
10878
- }, {
10879
- key: "registerCommercialUsePIL",
10880
- value: (function () {
10881
- var _registerCommercialUsePIL = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(request) {
10882
- var licenseTerms, _t3;
10883
- return _regenerator().w(function (_context3) {
10884
- while (1) switch (_context3.p = _context3.n) {
10885
- case 0:
10886
- _context3.p = 0;
10887
- licenseTerms = PILFlavor.commercialUse({
10888
- defaultMintingFee: Number(request.defaultMintingFee),
10889
- currency: request.currency,
10890
- royaltyPolicy: request.royaltyPolicyAddress
10891
- });
10892
- _context3.n = 1;
10893
- return this.registerPILTermsHelper(licenseTerms, request.txOptions);
10894
- case 1:
10895
- return _context3.a(2, _context3.v);
10896
- case 2:
10897
- _context3.p = 2;
10898
- _t3 = _context3.v;
10899
- return _context3.a(2, handleError(_t3, "Failed to register commercial use PIL"));
10900
- }
10901
- }, _callee3, this, [[0, 2]]);
10902
- }));
10903
- function registerCommercialUsePIL(_x3) {
10904
- return _registerCommercialUsePIL.apply(this, arguments);
10905
- }
10906
- return registerCommercialUsePIL;
10907
- }()
10908
- /**
10909
- * @deprecated Use {@link PILFlavor.commercialRemix} with {@link LicenseClient.registerPILTerms} instead.
10910
- * The method will be removed in the v1.4.0.
10911
- *
10912
- * Convenient function to register a PIL commercial Remix license to the registry.
10913
- *
10914
- * For more details, see {@link https://docs.story.foundation/concepts/programmable-ip-license/pil-flavors#flavor-%233%3A-commercial-remix | Commercial Remix }.
10915
- *
10916
- * Emits an on-chain {@link https://github.com/storyprotocol/protocol-core-v1/blob/v1.3.1/contracts/interfaces/modules/licensing/ILicenseTemplate.sol#L19 | `LicenseTermsRegistered`} event.
10917
- */
10918
- )
10919
- }, {
10920
- key: "registerCommercialRemixPIL",
10921
- value: (function () {
10922
- var _registerCommercialRemixPIL = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(_ref) {
10923
- var defaultMintingFee, currency, royaltyPolicyAddress, commercialRevShare, txOptions, licenseTerms, _t4;
10924
- return _regenerator().w(function (_context4) {
10925
- while (1) switch (_context4.p = _context4.n) {
11135
+ }, {
11136
+ key: "processIpAssetLicenseTerms",
11137
+ value: function () {
11138
+ var _processIpAssetLicenseTerms = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee36(ipAsset, extraData) {
11139
+ var _extraData$licenseTer;
11140
+ var licenseTermsIds, maxLicenseTokens, maxLicenseTokensData, maxLicenseTokensTxHashes;
11141
+ return _regenerator().w(function (_context36) {
11142
+ while (1) switch (_context36.n) {
10926
11143
  case 0:
10927
- defaultMintingFee = _ref.defaultMintingFee, currency = _ref.currency, royaltyPolicyAddress = _ref.royaltyPolicyAddress, commercialRevShare = _ref.commercialRevShare, txOptions = _ref.txOptions;
10928
- _context4.p = 1;
10929
- licenseTerms = PILFlavor.commercialRemix({
10930
- defaultMintingFee: Number(defaultMintingFee),
10931
- currency: currency,
10932
- royaltyPolicy: royaltyPolicyAddress,
10933
- commercialRevShare: commercialRevShare
10934
- });
10935
- _context4.n = 2;
10936
- return this.registerPILTermsHelper(licenseTerms, txOptions);
11144
+ if (extraData !== null && extraData !== void 0 && (_extraData$licenseTer = extraData.licenseTermsData) !== null && _extraData$licenseTer !== void 0 && _extraData$licenseTer.length) {
11145
+ _context36.n = 1;
11146
+ break;
11147
+ }
11148
+ return _context36.a(2, ipAsset);
11149
+ case 1:
11150
+ _context36.n = 2;
11151
+ return this.getLicenseTermsId(extraData.licenseTermsData.map(function (item) {
11152
+ return item.terms;
11153
+ }));
10937
11154
  case 2:
10938
- return _context4.a(2, _context4.v);
11155
+ licenseTermsIds = _context36.v;
11156
+ ipAsset.licenseTermsIds = licenseTermsIds;
11157
+ maxLicenseTokens = extraData.maxLicenseTokens;
11158
+ if (maxLicenseTokens !== null && maxLicenseTokens !== void 0 && maxLicenseTokens.length) {
11159
+ _context36.n = 3;
11160
+ break;
11161
+ }
11162
+ return _context36.a(2, ipAsset);
10939
11163
  case 3:
10940
- _context4.p = 3;
10941
- _t4 = _context4.v;
10942
- return _context4.a(2, handleError(_t4, "Failed to register commercial remix PIL"));
11164
+ maxLicenseTokensData = maxLicenseTokens.filter(function (maxLicenseToken) {
11165
+ return maxLicenseToken !== undefined;
11166
+ }).map(function (maxLicenseToken) {
11167
+ return {
11168
+ maxLicenseTokens: maxLicenseToken
11169
+ };
11170
+ });
11171
+ _context36.n = 4;
11172
+ return setMaxLicenseTokens({
11173
+ maxLicenseTokensData: maxLicenseTokensData,
11174
+ licensorIpId: ipAsset.ipId,
11175
+ licenseTermsIds: licenseTermsIds,
11176
+ totalLicenseTokenLimitHookClient: this.totalLicenseTokenLimitHookClient,
11177
+ templateAddress: this.licenseTemplateAddress
11178
+ });
11179
+ case 4:
11180
+ maxLicenseTokensTxHashes = _context36.v;
11181
+ if (maxLicenseTokensTxHashes !== null && maxLicenseTokensTxHashes !== void 0 && maxLicenseTokensTxHashes.length) {
11182
+ ipAsset.maxLicenseTokensTxHashes = maxLicenseTokensTxHashes;
11183
+ }
11184
+ return _context36.a(2, ipAsset);
10943
11185
  }
10944
- }, _callee4, this, [[1, 3]]);
11186
+ }, _callee36, this);
10945
11187
  }));
10946
- function registerCommercialRemixPIL(_x4) {
10947
- return _registerCommercialRemixPIL.apply(this, arguments);
11188
+ function processIpAssetLicenseTerms(_x36, _x37) {
11189
+ return _processIpAssetLicenseTerms.apply(this, arguments);
10948
11190
  }
10949
- return registerCommercialRemixPIL;
11191
+ return processIpAssetLicenseTerms;
10950
11192
  }()
10951
- /**
10952
- * @deprecated Use {@link PILFlavor.creativeCommonsAttribution} with {@link LicenseClient.registerPILTerms} instead.
10953
- * The method will be removed in the `v1.4.0`.
10954
- *
10955
- * Convenient function to register a PIL creative commons attribution license to the registry.
10956
- * Creates a Creative Commons Attribution (CC-BY) license terms flavor.
10957
- *
10958
- * For more details, see {@link https://docs.story.foundation/concepts/programmable-ip-license/pil-flavors#flavor-%234%3A-creative-commons-attribution | Creative Commons Attribution}.
10959
- *
10960
- * Emits an on-chain {@link https://github.com/storyprotocol/protocol-core-v1/blob/v1.3.1/contracts/interfaces/modules/licensing/ILicenseTemplate.sol#L19 | `LicenseTermsRegistered`} event.
10961
- */
10962
- )
10963
- }, {
10964
- key: "registerCreativeCommonsAttributionPIL",
11193
+ }]);
11194
+ }();
11195
+
11196
+ var LicenseClient = /*#__PURE__*/function () {
11197
+ function LicenseClient(rpcClient, wallet, chainId) {
11198
+ _classCallCheck(this, LicenseClient);
11199
+ this.licensingModuleClient = new LicensingModuleClient(rpcClient, wallet);
11200
+ this.piLicenseTemplateReadOnlyClient = new PiLicenseTemplateReadOnlyClient(rpcClient);
11201
+ this.licenseTemplateClient = new PiLicenseTemplateClient(rpcClient, wallet);
11202
+ this.licenseRegistryReadOnlyClient = new LicenseRegistryReadOnlyClient(rpcClient);
11203
+ this.ipAssetRegistryClient = new IpAssetRegistryClient(rpcClient, wallet);
11204
+ this.moduleRegistryReadOnlyClient = new ModuleRegistryReadOnlyClient(rpcClient);
11205
+ this.multicall3Client = new Multicall3Client(rpcClient, wallet);
11206
+ this.wipClient = new WrappedIpClient(rpcClient, wallet);
11207
+ this.totalLicenseTokenLimitHookClient = new TotalLicenseTokenLimitHookClient(rpcClient, wallet);
11208
+ this.licenseAttachmentWorkflowsClient = new LicenseAttachmentWorkflowsClient(rpcClient, wallet);
11209
+ this.rpcClient = rpcClient;
11210
+ this.wallet = wallet;
11211
+ this.chainId = chainId;
11212
+ this.walletAddress = wallet.account.address;
11213
+ }
11214
+
11215
+ /**
11216
+ * Registers new license terms and return the ID of the newly registered license terms.
11217
+ *
11218
+ * Emits an on-chain {@link https://github.com/storyprotocol/protocol-core-v1/blob/v1.3.1/contracts/interfaces/modules/licensing/ILicenseTemplate.sol#L19 | `LicenseTermsRegistered`} event.
11219
+ */
11220
+ return _createClass(LicenseClient, [{
11221
+ key: "registerPILTerms",
10965
11222
  value: (function () {
10966
- var _registerCreativeCommonsAttributionPIL = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(_ref2) {
10967
- var currency, royaltyPolicyAddress, txOptions, _t5;
10968
- return _regenerator().w(function (_context5) {
10969
- while (1) switch (_context5.p = _context5.n) {
11223
+ var _registerPILTerms = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(request) {
11224
+ var object, _t;
11225
+ return _regenerator().w(function (_context) {
11226
+ while (1) switch (_context.p = _context.n) {
10970
11227
  case 0:
10971
- currency = _ref2.currency, royaltyPolicyAddress = _ref2.royaltyPolicyAddress, txOptions = _ref2.txOptions;
10972
- _context5.p = 1;
10973
- _context5.n = 2;
10974
- return this.registerPILTermsHelper(PILFlavor.creativeCommonsAttribution({
10975
- currency: currency,
10976
- royaltyPolicy: royaltyPolicyAddress
10977
- }), txOptions);
11228
+ _context.p = 0;
11229
+ object = PILFlavor.validateLicenseTerms(request, this.chainId);
11230
+ _context.n = 1;
11231
+ return this.registerPILTermsHelper(object, request.txOptions);
11232
+ case 1:
11233
+ return _context.a(2, _context.v);
10978
11234
  case 2:
10979
- return _context5.a(2, _context5.v);
10980
- case 3:
10981
- _context5.p = 3;
10982
- _t5 = _context5.v;
10983
- return _context5.a(2, handleError(_t5, "Failed to register creative commons attribution PIL"));
11235
+ _context.p = 2;
11236
+ _t = _context.v;
11237
+ return _context.a(2, handleError(_t, "Failed to register license terms"));
10984
11238
  }
10985
- }, _callee5, this, [[1, 3]]);
11239
+ }, _callee, this, [[0, 2]]);
10986
11240
  }));
10987
- function registerCreativeCommonsAttributionPIL(_x5) {
10988
- return _registerCreativeCommonsAttributionPIL.apply(this, arguments);
11241
+ function registerPILTerms(_x) {
11242
+ return _registerPILTerms.apply(this, arguments);
10989
11243
  }
10990
- return registerCreativeCommonsAttributionPIL;
11244
+ return registerPILTerms;
10991
11245
  }()
10992
11246
  /**
10993
11247
  * Attaches license terms to an IP.
@@ -10996,50 +11250,50 @@ var LicenseClient = /*#__PURE__*/function () {
10996
11250
  }, {
10997
11251
  key: "attachLicenseTerms",
10998
11252
  value: (function () {
10999
- var _attachLicenseTerms = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(request) {
11000
- var _request$txOptions, isRegistered, isExisted, isAttachedLicenseTerms, req, txHash, _t6;
11001
- return _regenerator().w(function (_context6) {
11002
- while (1) switch (_context6.p = _context6.n) {
11253
+ var _attachLicenseTerms = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(request) {
11254
+ var _request$txOptions, isRegistered, isExisted, isAttachedLicenseTerms, req, txHash, _t2;
11255
+ return _regenerator().w(function (_context2) {
11256
+ while (1) switch (_context2.p = _context2.n) {
11003
11257
  case 0:
11004
- _context6.p = 0;
11258
+ _context2.p = 0;
11005
11259
  request.licenseTermsId = BigInt(request.licenseTermsId);
11006
- _context6.n = 1;
11260
+ _context2.n = 1;
11007
11261
  return this.ipAssetRegistryClient.isRegistered({
11008
11262
  id: validateAddress(request.ipId)
11009
11263
  });
11010
11264
  case 1:
11011
- isRegistered = _context6.v;
11265
+ isRegistered = _context2.v;
11012
11266
  if (isRegistered) {
11013
- _context6.n = 2;
11267
+ _context2.n = 2;
11014
11268
  break;
11015
11269
  }
11016
11270
  throw new Error("The IP with id ".concat(request.ipId, " is not registered."));
11017
11271
  case 2:
11018
- _context6.n = 3;
11272
+ _context2.n = 3;
11019
11273
  return this.piLicenseTemplateReadOnlyClient.exists({
11020
11274
  licenseTermsId: request.licenseTermsId
11021
11275
  });
11022
11276
  case 3:
11023
- isExisted = _context6.v;
11277
+ isExisted = _context2.v;
11024
11278
  if (isExisted) {
11025
- _context6.n = 4;
11279
+ _context2.n = 4;
11026
11280
  break;
11027
11281
  }
11028
11282
  throw new Error("License terms id ".concat(request.licenseTermsId, " do not exist."));
11029
11283
  case 4:
11030
- _context6.n = 5;
11284
+ _context2.n = 5;
11031
11285
  return this.licenseRegistryReadOnlyClient.hasIpAttachedLicenseTerms({
11032
11286
  ipId: request.ipId,
11033
11287
  licenseTemplate: validateAddress(request.licenseTemplate || this.licenseTemplateClient.address),
11034
11288
  licenseTermsId: request.licenseTermsId
11035
11289
  });
11036
11290
  case 5:
11037
- isAttachedLicenseTerms = _context6.v;
11291
+ isAttachedLicenseTerms = _context2.v;
11038
11292
  if (!isAttachedLicenseTerms) {
11039
- _context6.n = 6;
11293
+ _context2.n = 6;
11040
11294
  break;
11041
11295
  }
11042
- return _context6.a(2, {
11296
+ return _context2.a(2, {
11043
11297
  success: false
11044
11298
  });
11045
11299
  case 6:
@@ -11049,39 +11303,39 @@ var LicenseClient = /*#__PURE__*/function () {
11049
11303
  licenseTermsId: request.licenseTermsId
11050
11304
  };
11051
11305
  if (!((_request$txOptions = request.txOptions) !== null && _request$txOptions !== void 0 && _request$txOptions.encodedTxDataOnly)) {
11052
- _context6.n = 7;
11306
+ _context2.n = 7;
11053
11307
  break;
11054
11308
  }
11055
- return _context6.a(2, {
11309
+ return _context2.a(2, {
11056
11310
  encodedTxData: this.licensingModuleClient.attachLicenseTermsEncode(req)
11057
11311
  });
11058
11312
  case 7:
11059
- _context6.n = 8;
11313
+ _context2.n = 8;
11060
11314
  return this.licensingModuleClient.attachLicenseTerms(req);
11061
11315
  case 8:
11062
- txHash = _context6.v;
11063
- _context6.n = 9;
11316
+ txHash = _context2.v;
11317
+ _context2.n = 9;
11064
11318
  return this.rpcClient.waitForTransactionReceipt(_objectSpread2(_objectSpread2({}, request.txOptions), {}, {
11065
11319
  hash: txHash
11066
11320
  }));
11067
11321
  case 9:
11068
- return _context6.a(2, {
11322
+ return _context2.a(2, {
11069
11323
  txHash: txHash,
11070
11324
  success: true
11071
11325
  });
11072
11326
  case 10:
11073
- _context6.n = 12;
11327
+ _context2.n = 12;
11074
11328
  break;
11075
11329
  case 11:
11076
- _context6.p = 11;
11077
- _t6 = _context6.v;
11078
- return _context6.a(2, handleError(_t6, "Failed to attach license terms"));
11330
+ _context2.p = 11;
11331
+ _t2 = _context2.v;
11332
+ return _context2.a(2, handleError(_t2, "Failed to attach license terms"));
11079
11333
  case 12:
11080
- return _context6.a(2);
11334
+ return _context2.a(2);
11081
11335
  }
11082
- }, _callee6, this, [[0, 11]]);
11336
+ }, _callee2, this, [[0, 11]]);
11083
11337
  }));
11084
- function attachLicenseTerms(_x6) {
11338
+ function attachLicenseTerms(_x2) {
11085
11339
  return _attachLicenseTerms.apply(this, arguments);
11086
11340
  }
11087
11341
  return attachLicenseTerms;
@@ -11105,13 +11359,13 @@ var LicenseClient = /*#__PURE__*/function () {
11105
11359
  }, {
11106
11360
  key: "mintLicenseTokens",
11107
11361
  value: (function () {
11108
- var _mintLicenseTokens = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(request) {
11362
+ var _mintLicenseTokens = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(request) {
11109
11363
  var _this = this;
11110
- var _request$txOptions2, _request$options, receiver, req, isLicenseIpIdRegistered, isExisted, ipAccount, ipOwner, isAttachedLicenseTerms, encodedTxData, licenseMintingFee, wipSpenders, _yield$contractCallWi, txHash, receipt, targetLogs, startLicenseTokenId, licenseTokenIds, i, _t7;
11111
- return _regenerator().w(function (_context7) {
11112
- while (1) switch (_context7.p = _context7.n) {
11364
+ var _request$maxMintingFe, _request$maxRevenueSh, _request$txOptions2, _request$options, receiver, req, isLicenseIpIdRegistered, isExisted, ipAccount, ipOwner, isAttachedLicenseTerms, encodedTxData, licenseMintingFee, wipSpenders, _yield$contractCallWi, txHash, receipt, targetLogs, startLicenseTokenId, licenseTokenIds, i, _t3;
11365
+ return _regenerator().w(function (_context3) {
11366
+ while (1) switch (_context3.p = _context3.n) {
11113
11367
  case 0:
11114
- _context7.p = 0;
11368
+ _context3.p = 0;
11115
11369
  receiver = validateAddress(request.receiver || this.walletAddress);
11116
11370
  req = {
11117
11371
  licensorIpId: validateAddress(request.licensorIpId),
@@ -11120,72 +11374,72 @@ var LicenseClient = /*#__PURE__*/function () {
11120
11374
  amount: BigInt(request.amount === undefined ? 1 : request.amount),
11121
11375
  receiver: receiver,
11122
11376
  royaltyContext: zeroAddress,
11123
- maxMintingFee: BigInt(request.maxMintingFee),
11124
- maxRevenueShare: getRevenueShare(request.maxRevenueShare, RevShareType.MAX_REVENUE_SHARE)
11377
+ maxMintingFee: BigInt((_request$maxMintingFe = request.maxMintingFee) !== null && _request$maxMintingFe !== void 0 ? _request$maxMintingFe : 0),
11378
+ maxRevenueShare: getRevenueShare((_request$maxRevenueSh = request.maxRevenueShare) !== null && _request$maxRevenueSh !== void 0 ? _request$maxRevenueSh : 100, RevShareType.MAX_REVENUE_SHARE)
11125
11379
  };
11126
11380
  if (!(req.maxMintingFee < 0)) {
11127
- _context7.n = 1;
11381
+ _context3.n = 1;
11128
11382
  break;
11129
11383
  }
11130
11384
  throw new Error("The maxMintingFee must be greater than 0.");
11131
11385
  case 1:
11132
- _context7.n = 2;
11386
+ _context3.n = 2;
11133
11387
  return this.ipAssetRegistryClient.isRegistered({
11134
11388
  id: validateAddress(request.licensorIpId)
11135
11389
  });
11136
11390
  case 2:
11137
- isLicenseIpIdRegistered = _context7.v;
11391
+ isLicenseIpIdRegistered = _context3.v;
11138
11392
  if (isLicenseIpIdRegistered) {
11139
- _context7.n = 3;
11393
+ _context3.n = 3;
11140
11394
  break;
11141
11395
  }
11142
11396
  throw new Error("The licensor IP with id ".concat(request.licensorIpId, " is not registered."));
11143
11397
  case 3:
11144
- _context7.n = 4;
11398
+ _context3.n = 4;
11145
11399
  return this.piLicenseTemplateReadOnlyClient.exists({
11146
11400
  licenseTermsId: req.licenseTermsId
11147
11401
  });
11148
11402
  case 4:
11149
- isExisted = _context7.v;
11403
+ isExisted = _context3.v;
11150
11404
  if (isExisted) {
11151
- _context7.n = 5;
11405
+ _context3.n = 5;
11152
11406
  break;
11153
11407
  }
11154
11408
  throw new Error("License terms id ".concat(request.licenseTermsId, " do not exist."));
11155
11409
  case 5:
11156
11410
  ipAccount = new IpAccountImplClient(this.rpcClient, this.wallet, req.licensorIpId);
11157
- _context7.n = 6;
11411
+ _context3.n = 6;
11158
11412
  return ipAccount.owner();
11159
11413
  case 6:
11160
- ipOwner = _context7.v;
11414
+ ipOwner = _context3.v;
11161
11415
  if (!(ipOwner !== this.walletAddress)) {
11162
- _context7.n = 8;
11416
+ _context3.n = 8;
11163
11417
  break;
11164
11418
  }
11165
- _context7.n = 7;
11419
+ _context3.n = 7;
11166
11420
  return this.licenseRegistryReadOnlyClient.hasIpAttachedLicenseTerms({
11167
11421
  ipId: req.licensorIpId,
11168
11422
  licenseTemplate: req.licenseTemplate,
11169
11423
  licenseTermsId: req.licenseTermsId
11170
11424
  });
11171
11425
  case 7:
11172
- isAttachedLicenseTerms = _context7.v;
11426
+ isAttachedLicenseTerms = _context3.v;
11173
11427
  if (isAttachedLicenseTerms) {
11174
- _context7.n = 8;
11428
+ _context3.n = 8;
11175
11429
  break;
11176
11430
  }
11177
11431
  throw new Error("License terms id ".concat(req.licenseTermsId, " is not attached to the IP with id ").concat(req.licensorIpId, "."));
11178
11432
  case 8:
11179
11433
  encodedTxData = this.licensingModuleClient.mintLicenseTokensEncode(req);
11180
11434
  if (!((_request$txOptions2 = request.txOptions) !== null && _request$txOptions2 !== void 0 && _request$txOptions2.encodedTxDataOnly)) {
11181
- _context7.n = 9;
11435
+ _context3.n = 9;
11182
11436
  break;
11183
11437
  }
11184
- return _context7.a(2, {
11438
+ return _context3.a(2, {
11185
11439
  encodedTxData: encodedTxData
11186
11440
  });
11187
11441
  case 9:
11188
- _context7.n = 10;
11442
+ _context3.n = 10;
11189
11443
  return calculateLicenseWipMintFee({
11190
11444
  predictMintingFeeRequest: req,
11191
11445
  rpcClient: this.rpcClient,
@@ -11193,7 +11447,7 @@ var LicenseClient = /*#__PURE__*/function () {
11193
11447
  walletAddress: this.walletAddress
11194
11448
  });
11195
11449
  case 10:
11196
- licenseMintingFee = _context7.v;
11450
+ licenseMintingFee = _context3.v;
11197
11451
  wipSpenders = [];
11198
11452
  if (licenseMintingFee > 0n) {
11199
11453
  wipSpenders.push({
@@ -11201,7 +11455,7 @@ var LicenseClient = /*#__PURE__*/function () {
11201
11455
  amount: licenseMintingFee
11202
11456
  });
11203
11457
  }
11204
- _context7.n = 11;
11458
+ _context3.n = 11;
11205
11459
  return contractCallWithFees({
11206
11460
  totalFees: licenseMintingFee,
11207
11461
  options: {
@@ -11219,7 +11473,7 @@ var LicenseClient = /*#__PURE__*/function () {
11219
11473
  encodedTxs: [encodedTxData]
11220
11474
  });
11221
11475
  case 11:
11222
- _yield$contractCallWi = _context7.v;
11476
+ _yield$contractCallWi = _context3.v;
11223
11477
  txHash = _yield$contractCallWi.txHash;
11224
11478
  receipt = _yield$contractCallWi.receipt;
11225
11479
  targetLogs = this.licensingModuleClient.parseTxLicenseTokensMintedEvent(receipt);
@@ -11228,19 +11482,19 @@ var LicenseClient = /*#__PURE__*/function () {
11228
11482
  for (i = 0; i < req.amount; i++) {
11229
11483
  licenseTokenIds.push(startLicenseTokenId + BigInt(i));
11230
11484
  }
11231
- return _context7.a(2, {
11485
+ return _context3.a(2, {
11232
11486
  txHash: txHash,
11233
11487
  licenseTokenIds: licenseTokenIds,
11234
11488
  receipt: receipt
11235
11489
  });
11236
11490
  case 12:
11237
- _context7.p = 12;
11238
- _t7 = _context7.v;
11239
- return _context7.a(2, handleError(_t7, "Failed to mint license tokens"));
11491
+ _context3.p = 12;
11492
+ _t3 = _context3.v;
11493
+ return _context3.a(2, handleError(_t3, "Failed to mint license tokens"));
11240
11494
  }
11241
- }, _callee7, this, [[0, 12]]);
11495
+ }, _callee3, this, [[0, 12]]);
11242
11496
  }));
11243
- function mintLicenseTokens(_x7) {
11497
+ function mintLicenseTokens(_x3) {
11244
11498
  return _mintLicenseTokens.apply(this, arguments);
11245
11499
  }
11246
11500
  return mintLicenseTokens;
@@ -11252,26 +11506,26 @@ var LicenseClient = /*#__PURE__*/function () {
11252
11506
  }, {
11253
11507
  key: "getLicenseTerms",
11254
11508
  value: (function () {
11255
- var _getLicenseTerms = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(selectedLicenseTermsId) {
11256
- var _t8;
11257
- return _regenerator().w(function (_context8) {
11258
- while (1) switch (_context8.p = _context8.n) {
11509
+ var _getLicenseTerms = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(selectedLicenseTermsId) {
11510
+ var _t4;
11511
+ return _regenerator().w(function (_context4) {
11512
+ while (1) switch (_context4.p = _context4.n) {
11259
11513
  case 0:
11260
- _context8.p = 0;
11261
- _context8.n = 1;
11514
+ _context4.p = 0;
11515
+ _context4.n = 1;
11262
11516
  return this.piLicenseTemplateReadOnlyClient.getLicenseTerms({
11263
11517
  selectedLicenseTermsId: BigInt(selectedLicenseTermsId)
11264
11518
  });
11265
11519
  case 1:
11266
- return _context8.a(2, _context8.v);
11520
+ return _context4.a(2, _context4.v);
11267
11521
  case 2:
11268
- _context8.p = 2;
11269
- _t8 = _context8.v;
11270
- return _context8.a(2, handleError(_t8, "Failed to get license terms"));
11522
+ _context4.p = 2;
11523
+ _t4 = _context4.v;
11524
+ return _context4.a(2, handleError(_t4, "Failed to get license terms"));
11271
11525
  }
11272
- }, _callee8, this, [[0, 2]]);
11526
+ }, _callee4, this, [[0, 2]]);
11273
11527
  }));
11274
- function getLicenseTerms(_x8) {
11528
+ function getLicenseTerms(_x4) {
11275
11529
  return _getLicenseTerms.apply(this, arguments);
11276
11530
  }
11277
11531
  return getLicenseTerms;
@@ -11283,33 +11537,33 @@ var LicenseClient = /*#__PURE__*/function () {
11283
11537
  }, {
11284
11538
  key: "predictMintingLicenseFee",
11285
11539
  value: (function () {
11286
- var _predictMintingLicenseFee2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(request) {
11287
- var isLicenseIpIdRegistered, licenseTermsId, isExisted, object, _t9;
11288
- return _regenerator().w(function (_context9) {
11289
- while (1) switch (_context9.p = _context9.n) {
11540
+ var _predictMintingLicenseFee2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(request) {
11541
+ var isLicenseIpIdRegistered, licenseTermsId, isExisted, object, _t5;
11542
+ return _regenerator().w(function (_context5) {
11543
+ while (1) switch (_context5.p = _context5.n) {
11290
11544
  case 0:
11291
- _context9.p = 0;
11292
- _context9.n = 1;
11545
+ _context5.p = 0;
11546
+ _context5.n = 1;
11293
11547
  return this.ipAssetRegistryClient.isRegistered({
11294
11548
  id: validateAddress(request.licensorIpId)
11295
11549
  });
11296
11550
  case 1:
11297
- isLicenseIpIdRegistered = _context9.v;
11551
+ isLicenseIpIdRegistered = _context5.v;
11298
11552
  if (isLicenseIpIdRegistered) {
11299
- _context9.n = 2;
11553
+ _context5.n = 2;
11300
11554
  break;
11301
11555
  }
11302
11556
  throw new Error("The licensor IP with id ".concat(request.licensorIpId, " is not registered."));
11303
11557
  case 2:
11304
11558
  licenseTermsId = BigInt(request.licenseTermsId);
11305
- _context9.n = 3;
11559
+ _context5.n = 3;
11306
11560
  return this.piLicenseTemplateReadOnlyClient.exists({
11307
11561
  licenseTermsId: licenseTermsId
11308
11562
  });
11309
11563
  case 3:
11310
- isExisted = _context9.v;
11564
+ isExisted = _context5.v;
11311
11565
  if (isExisted) {
11312
- _context9.n = 4;
11566
+ _context5.n = 4;
11313
11567
  break;
11314
11568
  }
11315
11569
  throw new Error("License terms id ".concat(request.licenseTermsId, " do not exist."));
@@ -11321,7 +11575,7 @@ var LicenseClient = /*#__PURE__*/function () {
11321
11575
  licenseTemplate: validateAddress(request.licenseTemplate || this.licenseTemplateClient.address),
11322
11576
  licenseTermsId: licenseTermsId
11323
11577
  });
11324
- _context9.n = 5;
11578
+ _context5.n = 5;
11325
11579
  return predictMintingLicenseFee({
11326
11580
  predictMintingFeeRequest: object,
11327
11581
  rpcClient: this.rpcClient,
@@ -11329,15 +11583,15 @@ var LicenseClient = /*#__PURE__*/function () {
11329
11583
  walletAddress: this.walletAddress
11330
11584
  });
11331
11585
  case 5:
11332
- return _context9.a(2, _context9.v);
11586
+ return _context5.a(2, _context5.v);
11333
11587
  case 6:
11334
- _context9.p = 6;
11335
- _t9 = _context9.v;
11336
- return _context9.a(2, handleError(_t9, "Failed to predict minting license fee"));
11588
+ _context5.p = 6;
11589
+ _t5 = _context5.v;
11590
+ return _context5.a(2, handleError(_t5, "Failed to predict minting license fee"));
11337
11591
  }
11338
- }, _callee9, this, [[0, 6]]);
11592
+ }, _callee5, this, [[0, 6]]);
11339
11593
  }));
11340
- function predictMintingLicenseFee$1(_x9) {
11594
+ function predictMintingLicenseFee$1(_x5) {
11341
11595
  return _predictMintingLicenseFee2.apply(this, arguments);
11342
11596
  }
11343
11597
  return predictMintingLicenseFee$1;
@@ -11349,12 +11603,12 @@ var LicenseClient = /*#__PURE__*/function () {
11349
11603
  }, {
11350
11604
  key: "setLicensingConfig",
11351
11605
  value: (function () {
11352
- var _setLicensingConfig = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(request) {
11353
- var _request$txOptions3, req, isLicenseIpIdRegistered, isExisted, isRegistered, txHash, _t0;
11354
- return _regenerator().w(function (_context0) {
11355
- while (1) switch (_context0.p = _context0.n) {
11606
+ var _setLicensingConfig = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(request) {
11607
+ var _request$txOptions3, req, isLicenseIpIdRegistered, isExisted, isRegistered, txHash, _t6;
11608
+ return _regenerator().w(function (_context6) {
11609
+ while (1) switch (_context6.p = _context6.n) {
11356
11610
  case 0:
11357
- _context0.p = 0;
11611
+ _context6.p = 0;
11358
11612
  req = {
11359
11613
  ipId: request.ipId,
11360
11614
  licenseTemplate: validateAddress(request.licenseTemplate || this.licenseTemplateClient.address),
@@ -11362,91 +11616,91 @@ var LicenseClient = /*#__PURE__*/function () {
11362
11616
  licensingConfig: validateLicenseConfig(request.licensingConfig)
11363
11617
  };
11364
11618
  if (!(req.licenseTemplate === zeroAddress && req.licensingConfig.commercialRevShare !== 0)) {
11365
- _context0.n = 1;
11619
+ _context6.n = 1;
11366
11620
  break;
11367
11621
  }
11368
11622
  throw new Error("The license template cannot be zero address if commercial revenue share is not zero.");
11369
11623
  case 1:
11370
- _context0.n = 2;
11624
+ _context6.n = 2;
11371
11625
  return this.ipAssetRegistryClient.isRegistered({
11372
11626
  id: validateAddress(req.ipId)
11373
11627
  });
11374
11628
  case 2:
11375
- isLicenseIpIdRegistered = _context0.v;
11629
+ isLicenseIpIdRegistered = _context6.v;
11376
11630
  if (isLicenseIpIdRegistered) {
11377
- _context0.n = 3;
11631
+ _context6.n = 3;
11378
11632
  break;
11379
11633
  }
11380
11634
  throw new Error("The licensor IP with id ".concat(req.ipId, " is not registered."));
11381
11635
  case 3:
11382
- _context0.n = 4;
11636
+ _context6.n = 4;
11383
11637
  return this.piLicenseTemplateReadOnlyClient.exists({
11384
11638
  licenseTermsId: req.licenseTermsId
11385
11639
  });
11386
11640
  case 4:
11387
- isExisted = _context0.v;
11641
+ isExisted = _context6.v;
11388
11642
  if (isExisted) {
11389
- _context0.n = 5;
11643
+ _context6.n = 5;
11390
11644
  break;
11391
11645
  }
11392
11646
  throw new Error("License terms id ".concat(req.licenseTermsId, " do not exist."));
11393
11647
  case 5:
11394
11648
  if (!(req.licensingConfig.licensingHook !== zeroAddress)) {
11395
- _context0.n = 7;
11649
+ _context6.n = 7;
11396
11650
  break;
11397
11651
  }
11398
- _context0.n = 6;
11652
+ _context6.n = 6;
11399
11653
  return this.moduleRegistryReadOnlyClient.isRegistered({
11400
11654
  moduleAddress: req.licensingConfig.licensingHook
11401
11655
  });
11402
11656
  case 6:
11403
- isRegistered = _context0.v;
11657
+ isRegistered = _context6.v;
11404
11658
  if (isRegistered) {
11405
- _context0.n = 7;
11659
+ _context6.n = 7;
11406
11660
  break;
11407
11661
  }
11408
11662
  throw new Error("The licensing hook is not registered.");
11409
11663
  case 7:
11410
11664
  if (!(req.licenseTemplate === zeroAddress && req.licenseTermsId !== 0n)) {
11411
- _context0.n = 8;
11665
+ _context6.n = 8;
11412
11666
  break;
11413
11667
  }
11414
11668
  throw new Error("The license template is zero address but license terms id is not zero.");
11415
11669
  case 8:
11416
11670
  if (!((_request$txOptions3 = request.txOptions) !== null && _request$txOptions3 !== void 0 && _request$txOptions3.encodedTxDataOnly)) {
11417
- _context0.n = 9;
11671
+ _context6.n = 9;
11418
11672
  break;
11419
11673
  }
11420
- return _context0.a(2, {
11674
+ return _context6.a(2, {
11421
11675
  encodedTxData: this.licensingModuleClient.setLicensingConfigEncode(req)
11422
11676
  });
11423
11677
  case 9:
11424
- _context0.n = 10;
11678
+ _context6.n = 10;
11425
11679
  return this.licensingModuleClient.setLicensingConfig(req);
11426
11680
  case 10:
11427
- txHash = _context0.v;
11428
- _context0.n = 11;
11681
+ txHash = _context6.v;
11682
+ _context6.n = 11;
11429
11683
  return this.rpcClient.waitForTransactionReceipt(_objectSpread2(_objectSpread2({}, request.txOptions), {}, {
11430
11684
  hash: txHash
11431
11685
  }));
11432
11686
  case 11:
11433
- return _context0.a(2, {
11687
+ return _context6.a(2, {
11434
11688
  txHash: txHash,
11435
11689
  success: true
11436
11690
  });
11437
11691
  case 12:
11438
- _context0.n = 14;
11692
+ _context6.n = 14;
11439
11693
  break;
11440
11694
  case 13:
11441
- _context0.p = 13;
11442
- _t0 = _context0.v;
11443
- return _context0.a(2, handleError(_t0, "Failed to set licensing config"));
11695
+ _context6.p = 13;
11696
+ _t6 = _context6.v;
11697
+ return _context6.a(2, handleError(_t6, "Failed to set licensing config"));
11444
11698
  case 14:
11445
- return _context0.a(2);
11699
+ return _context6.a(2);
11446
11700
  }
11447
- }, _callee0, this, [[0, 13]]);
11701
+ }, _callee6, this, [[0, 13]]);
11448
11702
  }));
11449
- function setLicensingConfig(_x0) {
11703
+ function setLicensingConfig(_x6) {
11450
11704
  return _setLicensingConfig.apply(this, arguments);
11451
11705
  }
11452
11706
  return setLicensingConfig;
@@ -11464,34 +11718,34 @@ var LicenseClient = /*#__PURE__*/function () {
11464
11718
  }, {
11465
11719
  key: "setMaxLicenseTokens",
11466
11720
  value: (function () {
11467
- var _setMaxLicenseTokens = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(_ref3) {
11468
- var ipId, licenseTermsId, maxLicenseTokens, licenseTemplate, txOptions, newLicenseTermsId, newLicenseTemplate, licensingConfig, txHash, _t1;
11469
- return _regenerator().w(function (_context1) {
11470
- while (1) switch (_context1.p = _context1.n) {
11721
+ var _setMaxLicenseTokens = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(_ref) {
11722
+ var ipId, licenseTermsId, maxLicenseTokens, licenseTemplate, txOptions, newLicenseTermsId, newLicenseTemplate, licensingConfig, txHash, _t7;
11723
+ return _regenerator().w(function (_context7) {
11724
+ while (1) switch (_context7.p = _context7.n) {
11471
11725
  case 0:
11472
- ipId = _ref3.ipId, licenseTermsId = _ref3.licenseTermsId, maxLicenseTokens = _ref3.maxLicenseTokens, licenseTemplate = _ref3.licenseTemplate, txOptions = _ref3.txOptions;
11473
- _context1.p = 1;
11726
+ ipId = _ref.ipId, licenseTermsId = _ref.licenseTermsId, maxLicenseTokens = _ref.maxLicenseTokens, licenseTemplate = _ref.licenseTemplate, txOptions = _ref.txOptions;
11727
+ _context7.p = 1;
11474
11728
  if (!(maxLicenseTokens < 0)) {
11475
- _context1.n = 2;
11729
+ _context7.n = 2;
11476
11730
  break;
11477
11731
  }
11478
11732
  throw new Error("The max license tokens must be greater than 0.");
11479
11733
  case 2:
11480
11734
  newLicenseTermsId = BigInt(licenseTermsId);
11481
11735
  newLicenseTemplate = validateAddress(licenseTemplate || this.licenseTemplateClient.address);
11482
- _context1.n = 3;
11736
+ _context7.n = 3;
11483
11737
  return this.getLicensingConfig({
11484
11738
  ipId: ipId,
11485
11739
  licenseTermsId: newLicenseTermsId,
11486
11740
  licenseTemplate: newLicenseTemplate
11487
11741
  });
11488
11742
  case 3:
11489
- licensingConfig = _context1.v;
11743
+ licensingConfig = _context7.v;
11490
11744
  if (!(licensingConfig.licensingHook !== this.totalLicenseTokenLimitHookClient.address)) {
11491
- _context1.n = 4;
11745
+ _context7.n = 4;
11492
11746
  break;
11493
11747
  }
11494
- _context1.n = 4;
11748
+ _context7.n = 4;
11495
11749
  return this.setLicensingConfig({
11496
11750
  ipId: ipId,
11497
11751
  licenseTermsId: newLicenseTermsId,
@@ -11502,7 +11756,7 @@ var LicenseClient = /*#__PURE__*/function () {
11502
11756
  })
11503
11757
  });
11504
11758
  case 4:
11505
- _context1.n = 5;
11759
+ _context7.n = 5;
11506
11760
  return this.totalLicenseTokenLimitHookClient.setTotalLicenseTokenLimit({
11507
11761
  licensorIpId: ipId,
11508
11762
  licenseTemplate: newLicenseTemplate,
@@ -11510,20 +11764,20 @@ var LicenseClient = /*#__PURE__*/function () {
11510
11764
  limit: BigInt(maxLicenseTokens)
11511
11765
  });
11512
11766
  case 5:
11513
- txHash = _context1.v;
11514
- return _context1.a(2, waitForTxReceipt({
11767
+ txHash = _context7.v;
11768
+ return _context7.a(2, waitForTxReceipt({
11515
11769
  txHash: txHash,
11516
11770
  txOptions: txOptions,
11517
11771
  rpcClient: this.rpcClient
11518
11772
  }));
11519
11773
  case 6:
11520
- _context1.p = 6;
11521
- _t1 = _context1.v;
11522
- return _context1.a(2, handleError(_t1, "Failed to set max license tokens"));
11774
+ _context7.p = 6;
11775
+ _t7 = _context7.v;
11776
+ return _context7.a(2, handleError(_t7, "Failed to set max license tokens"));
11523
11777
  }
11524
- }, _callee1, this, [[1, 6]]);
11778
+ }, _callee7, this, [[1, 6]]);
11525
11779
  }));
11526
- function setMaxLicenseTokens(_x1) {
11780
+ function setMaxLicenseTokens(_x7) {
11527
11781
  return _setMaxLicenseTokens.apply(this, arguments);
11528
11782
  }
11529
11783
  return setMaxLicenseTokens;
@@ -11531,52 +11785,344 @@ var LicenseClient = /*#__PURE__*/function () {
11531
11785
  }, {
11532
11786
  key: "getLicensingConfig",
11533
11787
  value: function () {
11534
- var _getLicensingConfig = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(request) {
11535
- var licensingConfigParam, _t10;
11536
- return _regenerator().w(function (_context10) {
11537
- while (1) switch (_context10.p = _context10.n) {
11788
+ var _getLicensingConfig = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(request) {
11789
+ var licensingConfigParam, _t8;
11790
+ return _regenerator().w(function (_context8) {
11791
+ while (1) switch (_context8.p = _context8.n) {
11538
11792
  case 0:
11539
- _context10.p = 0;
11793
+ _context8.p = 0;
11540
11794
  licensingConfigParam = {
11541
11795
  ipId: validateAddress(request.ipId),
11542
11796
  licenseTemplate: validateAddress(request.licenseTemplate || this.licenseTemplateClient.address),
11543
11797
  licenseTermsId: BigInt(request.licenseTermsId)
11544
11798
  };
11545
- _context10.n = 1;
11799
+ _context8.n = 1;
11546
11800
  return this.licenseRegistryReadOnlyClient.getLicensingConfig(licensingConfigParam);
11547
11801
  case 1:
11548
- return _context10.a(2, _context10.v);
11802
+ return _context8.a(2, _context8.v);
11549
11803
  case 2:
11550
- _context10.p = 2;
11551
- _t10 = _context10.v;
11552
- return _context10.a(2, handleError(_t10, "Failed to get licensing config"));
11804
+ _context8.p = 2;
11805
+ _t8 = _context8.v;
11806
+ return _context8.a(2, handleError(_t8, "Failed to get licensing config"));
11553
11807
  }
11554
- }, _callee10, this, [[0, 2]]);
11808
+ }, _callee8, this, [[0, 2]]);
11555
11809
  }));
11556
- function getLicensingConfig(_x10) {
11810
+ function getLicensingConfig(_x8) {
11557
11811
  return _getLicensingConfig.apply(this, arguments);
11558
11812
  }
11559
11813
  return getLicensingConfig;
11560
11814
  }()
11815
+ /**
11816
+ * Register Programmable IP License Terms (if unregistered) and attach it to IP.
11817
+ *
11818
+ * Emits an on-chain {@link https://github.com/storyprotocol/protocol-core-v1/blob/v1.3.1/contracts/interfaces/modules/licensing/ILicensingModule.sol#L19 | `LicenseTermsAttached`} event.
11819
+ */
11820
+ }, {
11821
+ key: "registerPilTermsAndAttach",
11822
+ value: (function () {
11823
+ var _registerPilTermsAndAttach = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(request) {
11824
+ var _request$txOptions4, ipId, isRegistered, _yield$validateLicens, licenseTerms, licenseTermsData, calculatedDeadline, ipAccount, _yield$ipAccount$stat, state, signature, object, txHash, licenseTermsIds, i, maxLicenseTokensTxHashes, _t9, _t0;
11825
+ return _regenerator().w(function (_context9) {
11826
+ while (1) switch (_context9.p = _context9.n) {
11827
+ case 0:
11828
+ _context9.p = 0;
11829
+ ipId = request.ipId;
11830
+ _context9.n = 1;
11831
+ return this.ipAssetRegistryClient.isRegistered({
11832
+ id: validateAddress(ipId)
11833
+ });
11834
+ case 1:
11835
+ isRegistered = _context9.v;
11836
+ if (isRegistered) {
11837
+ _context9.n = 2;
11838
+ break;
11839
+ }
11840
+ throw new Error("The IP with id ".concat(ipId, " is not registered."));
11841
+ case 2:
11842
+ _context9.n = 3;
11843
+ return validateLicenseTermsData(request.licenseTermsData, this.rpcClient, this.chainId);
11844
+ case 3:
11845
+ _yield$validateLicens = _context9.v;
11846
+ licenseTerms = _yield$validateLicens.licenseTerms;
11847
+ licenseTermsData = _yield$validateLicens.licenseTermsData;
11848
+ _context9.n = 4;
11849
+ return getCalculatedDeadline(this.rpcClient, request.deadline);
11850
+ case 4:
11851
+ calculatedDeadline = _context9.v;
11852
+ ipAccount = new IpAccountImplClient(this.rpcClient, this.wallet, ipId);
11853
+ _context9.n = 5;
11854
+ return ipAccount.state();
11855
+ case 5:
11856
+ _yield$ipAccount$stat = _context9.v;
11857
+ state = _yield$ipAccount$stat.result;
11858
+ _context9.n = 6;
11859
+ return generateOperationSignature({
11860
+ ipIdAddress: ipId,
11861
+ methodType: SignatureMethodType.REGISTER_PIL_TERMS_AND_ATTACH,
11862
+ deadline: calculatedDeadline,
11863
+ state: state,
11864
+ wallet: this.wallet,
11865
+ chainId: this.chainId
11866
+ });
11867
+ case 6:
11868
+ signature = _context9.v;
11869
+ object = {
11870
+ ipId: ipId,
11871
+ licenseTermsData: licenseTermsData,
11872
+ sigAttachAndConfig: {
11873
+ signer: validateAddress(this.walletAddress),
11874
+ deadline: calculatedDeadline,
11875
+ signature: signature
11876
+ }
11877
+ };
11878
+ if (!((_request$txOptions4 = request.txOptions) !== null && _request$txOptions4 !== void 0 && _request$txOptions4.encodedTxDataOnly)) {
11879
+ _context9.n = 7;
11880
+ break;
11881
+ }
11882
+ return _context9.a(2, {
11883
+ encodedTxData: this.licenseAttachmentWorkflowsClient.registerPilTermsAndAttachEncode(object)
11884
+ });
11885
+ case 7:
11886
+ _context9.n = 8;
11887
+ return this.licenseAttachmentWorkflowsClient.registerPilTermsAndAttach(object);
11888
+ case 8:
11889
+ txHash = _context9.v;
11890
+ _context9.n = 9;
11891
+ return this.rpcClient.waitForTransactionReceipt(_objectSpread2(_objectSpread2({}, request.txOptions), {}, {
11892
+ hash: txHash
11893
+ }));
11894
+ case 9:
11895
+ licenseTermsIds = [];
11896
+ i = 0;
11897
+ case 10:
11898
+ if (!(i < licenseTerms.length)) {
11899
+ _context9.n = 13;
11900
+ break;
11901
+ }
11902
+ _t9 = licenseTermsIds;
11903
+ _context9.n = 11;
11904
+ return this.getLicenseTermsId(licenseTerms[i]);
11905
+ case 11:
11906
+ _t9.push.call(_t9, _context9.v);
11907
+ case 12:
11908
+ i++;
11909
+ _context9.n = 10;
11910
+ break;
11911
+ case 13:
11912
+ _context9.n = 14;
11913
+ return setMaxLicenseTokens({
11914
+ maxLicenseTokensData: request.licenseTermsData,
11915
+ licensorIpId: ipId,
11916
+ licenseTermsIds: licenseTermsIds,
11917
+ totalLicenseTokenLimitHookClient: this.totalLicenseTokenLimitHookClient,
11918
+ templateAddress: this.licenseTemplateClient.address
11919
+ });
11920
+ case 14:
11921
+ maxLicenseTokensTxHashes = _context9.v;
11922
+ return _context9.a(2, _objectSpread2({
11923
+ txHash: txHash,
11924
+ licenseTermsIds: licenseTermsIds
11925
+ }, maxLicenseTokensTxHashes.length > 0 && {
11926
+ maxLicenseTokensTxHashes: maxLicenseTokensTxHashes
11927
+ }));
11928
+ case 15:
11929
+ _context9.n = 17;
11930
+ break;
11931
+ case 16:
11932
+ _context9.p = 16;
11933
+ _t0 = _context9.v;
11934
+ return _context9.a(2, handleError(_t0, "Failed to register PIL terms and attach"));
11935
+ case 17:
11936
+ return _context9.a(2);
11937
+ }
11938
+ }, _callee9, this, [[0, 16]]);
11939
+ }));
11940
+ function registerPilTermsAndAttach(_x9) {
11941
+ return _registerPilTermsAndAttach.apply(this, arguments);
11942
+ }
11943
+ return registerPilTermsAndAttach;
11944
+ }()
11945
+ /**
11946
+ * @deprecated Use {@link PILFlavor.nonCommercialSocialRemixing} with {@link LicenseClient.registerPILTerms} instead.
11947
+ * This method will be removed soon.
11948
+ *
11949
+ * Convenient function to register a PIL non commercial social remix license to the registry
11950
+ *
11951
+ * For more details, see {@link https://docs.story.foundation/concepts/programmable-ip-license/pil-flavors#flavor-%231%3A-non-commercial-social-remixing | Non Commercial Social Remixing}.
11952
+ *
11953
+ * Emits an on-chain {@link https://github.com/storyprotocol/protocol-core-v1/blob/v1.3.1/contracts/interfaces/modules/licensing/ILicenseTemplate.sol#L19 | `LicenseTermsRegistered`} event.
11954
+ */
11955
+ )
11956
+ }, {
11957
+ key: "registerNonComSocialRemixingPIL",
11958
+ value: (function () {
11959
+ var _registerNonComSocialRemixingPIL = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(request) {
11960
+ var licenseTerms, _t1;
11961
+ return _regenerator().w(function (_context0) {
11962
+ while (1) switch (_context0.p = _context0.n) {
11963
+ case 0:
11964
+ _context0.p = 0;
11965
+ licenseTerms = PILFlavor.nonCommercialSocialRemixing();
11966
+ _context0.n = 1;
11967
+ return this.registerPILTermsHelper(licenseTerms, request === null || request === void 0 ? void 0 : request.txOptions);
11968
+ case 1:
11969
+ return _context0.a(2, _context0.v);
11970
+ case 2:
11971
+ _context0.p = 2;
11972
+ _t1 = _context0.v;
11973
+ return _context0.a(2, handleError(_t1, "Failed to register non commercial social remixing PIL"));
11974
+ }
11975
+ }, _callee0, this, [[0, 2]]);
11976
+ }));
11977
+ function registerNonComSocialRemixingPIL(_x0) {
11978
+ return _registerNonComSocialRemixingPIL.apply(this, arguments);
11979
+ }
11980
+ return registerNonComSocialRemixingPIL;
11981
+ }()
11982
+ /**
11983
+ * @deprecated Use {@link PILFlavor.commercialUse} with {@link LicenseClient.registerPILTerms} instead.
11984
+ * This method will be removed soon.
11985
+ *
11986
+ * Convenient function to register a PIL commercial use license to the registry.
11987
+ *
11988
+ * For more details, see {@link https://docs.story.foundation/concepts/programmable-ip-license/pil-flavors#flavor-%232%3A-commercial-use | Commercial Use}.
11989
+ *
11990
+ * Emits an on-chain {@link https://github.com/storyprotocol/protocol-core-v1/blob/v1.3.1/contracts/interfaces/modules/licensing/ILicenseTemplate.sol#L19 | `LicenseTermsRegistered`} event.
11991
+ */
11992
+ )
11993
+ }, {
11994
+ key: "registerCommercialUsePIL",
11995
+ value: (function () {
11996
+ var _registerCommercialUsePIL = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(request) {
11997
+ var licenseTerms, _t10;
11998
+ return _regenerator().w(function (_context1) {
11999
+ while (1) switch (_context1.p = _context1.n) {
12000
+ case 0:
12001
+ _context1.p = 0;
12002
+ licenseTerms = PILFlavor.commercialUse({
12003
+ defaultMintingFee: Number(request.defaultMintingFee),
12004
+ currency: request.currency,
12005
+ royaltyPolicy: request.royaltyPolicyAddress
12006
+ });
12007
+ _context1.n = 1;
12008
+ return this.registerPILTermsHelper(licenseTerms, request.txOptions);
12009
+ case 1:
12010
+ return _context1.a(2, _context1.v);
12011
+ case 2:
12012
+ _context1.p = 2;
12013
+ _t10 = _context1.v;
12014
+ return _context1.a(2, handleError(_t10, "Failed to register commercial use PIL"));
12015
+ }
12016
+ }, _callee1, this, [[0, 2]]);
12017
+ }));
12018
+ function registerCommercialUsePIL(_x1) {
12019
+ return _registerCommercialUsePIL.apply(this, arguments);
12020
+ }
12021
+ return registerCommercialUsePIL;
12022
+ }()
12023
+ /**
12024
+ * @deprecated Use {@link PILFlavor.commercialRemix} with {@link LicenseClient.registerPILTerms} instead.
12025
+ * This method will be removed soon.
12026
+ *
12027
+ * Convenient function to register a PIL commercial Remix license to the registry.
12028
+ *
12029
+ * For more details, see {@link https://docs.story.foundation/concepts/programmable-ip-license/pil-flavors#flavor-%233%3A-commercial-remix | Commercial Remix }.
12030
+ *
12031
+ * Emits an on-chain {@link https://github.com/storyprotocol/protocol-core-v1/blob/v1.3.1/contracts/interfaces/modules/licensing/ILicenseTemplate.sol#L19 | `LicenseTermsRegistered`} event.
12032
+ */
12033
+ )
12034
+ }, {
12035
+ key: "registerCommercialRemixPIL",
12036
+ value: (function () {
12037
+ var _registerCommercialRemixPIL = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(_ref2) {
12038
+ var defaultMintingFee, currency, royaltyPolicyAddress, commercialRevShare, txOptions, licenseTerms, _t11;
12039
+ return _regenerator().w(function (_context10) {
12040
+ while (1) switch (_context10.p = _context10.n) {
12041
+ case 0:
12042
+ defaultMintingFee = _ref2.defaultMintingFee, currency = _ref2.currency, royaltyPolicyAddress = _ref2.royaltyPolicyAddress, commercialRevShare = _ref2.commercialRevShare, txOptions = _ref2.txOptions;
12043
+ _context10.p = 1;
12044
+ licenseTerms = PILFlavor.commercialRemix({
12045
+ defaultMintingFee: Number(defaultMintingFee),
12046
+ currency: currency,
12047
+ royaltyPolicy: royaltyPolicyAddress,
12048
+ commercialRevShare: commercialRevShare
12049
+ });
12050
+ _context10.n = 2;
12051
+ return this.registerPILTermsHelper(licenseTerms, txOptions);
12052
+ case 2:
12053
+ return _context10.a(2, _context10.v);
12054
+ case 3:
12055
+ _context10.p = 3;
12056
+ _t11 = _context10.v;
12057
+ return _context10.a(2, handleError(_t11, "Failed to register commercial remix PIL"));
12058
+ }
12059
+ }, _callee10, this, [[1, 3]]);
12060
+ }));
12061
+ function registerCommercialRemixPIL(_x10) {
12062
+ return _registerCommercialRemixPIL.apply(this, arguments);
12063
+ }
12064
+ return registerCommercialRemixPIL;
12065
+ }()
12066
+ /**
12067
+ * @deprecated Use {@link PILFlavor.creativeCommonsAttribution} with {@link LicenseClient.registerPILTerms} instead.
12068
+ * This method will be removed soon.
12069
+ *
12070
+ * Convenient function to register a PIL creative commons attribution license to the registry.
12071
+ * Creates a Creative Commons Attribution (CC-BY) license terms flavor.
12072
+ *
12073
+ * For more details, see {@link https://docs.story.foundation/concepts/programmable-ip-license/pil-flavors#flavor-%234%3A-creative-commons-attribution | Creative Commons Attribution}.
12074
+ *
12075
+ * Emits an on-chain {@link https://github.com/storyprotocol/protocol-core-v1/blob/v1.3.1/contracts/interfaces/modules/licensing/ILicenseTemplate.sol#L19 | `LicenseTermsRegistered`} event.
12076
+ */
12077
+ )
12078
+ }, {
12079
+ key: "registerCreativeCommonsAttributionPIL",
12080
+ value: (function () {
12081
+ var _registerCreativeCommonsAttributionPIL = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11(_ref3) {
12082
+ var currency, royaltyPolicyAddress, txOptions, _t12;
12083
+ return _regenerator().w(function (_context11) {
12084
+ while (1) switch (_context11.p = _context11.n) {
12085
+ case 0:
12086
+ currency = _ref3.currency, royaltyPolicyAddress = _ref3.royaltyPolicyAddress, txOptions = _ref3.txOptions;
12087
+ _context11.p = 1;
12088
+ _context11.n = 2;
12089
+ return this.registerPILTermsHelper(PILFlavor.creativeCommonsAttribution({
12090
+ currency: currency,
12091
+ royaltyPolicy: royaltyPolicyAddress
12092
+ }), txOptions);
12093
+ case 2:
12094
+ return _context11.a(2, _context11.v);
12095
+ case 3:
12096
+ _context11.p = 3;
12097
+ _t12 = _context11.v;
12098
+ return _context11.a(2, handleError(_t12, "Failed to register creative commons attribution PIL"));
12099
+ }
12100
+ }, _callee11, this, [[1, 3]]);
12101
+ }));
12102
+ function registerCreativeCommonsAttributionPIL(_x11) {
12103
+ return _registerCreativeCommonsAttributionPIL.apply(this, arguments);
12104
+ }
12105
+ return registerCreativeCommonsAttributionPIL;
12106
+ }())
11561
12107
  }, {
11562
12108
  key: "getLicenseTermsId",
11563
12109
  value: function () {
11564
- var _getLicenseTermsId = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11(request) {
12110
+ var _getLicenseTermsId = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12(licenseTerms) {
11565
12111
  var licenseRes;
11566
- return _regenerator().w(function (_context11) {
11567
- while (1) switch (_context11.n) {
12112
+ return _regenerator().w(function (_context12) {
12113
+ while (1) switch (_context12.n) {
11568
12114
  case 0:
11569
- _context11.n = 1;
12115
+ _context12.n = 1;
11570
12116
  return this.licenseTemplateClient.getLicenseTermsId({
11571
- terms: request
12117
+ terms: licenseTerms
11572
12118
  });
11573
12119
  case 1:
11574
- licenseRes = _context11.v;
11575
- return _context11.a(2, licenseRes.selectedLicenseTermsId);
12120
+ licenseRes = _context12.v;
12121
+ return _context12.a(2, licenseRes.selectedLicenseTermsId);
11576
12122
  }
11577
- }, _callee11, this);
12123
+ }, _callee12, this);
11578
12124
  }));
11579
- function getLicenseTermsId(_x11) {
12125
+ function getLicenseTermsId(_x12) {
11580
12126
  return _getLicenseTermsId.apply(this, arguments);
11581
12127
  }
11582
12128
  return getLicenseTermsId;
@@ -11584,59 +12130,60 @@ var LicenseClient = /*#__PURE__*/function () {
11584
12130
  }, {
11585
12131
  key: "registerPILTermsHelper",
11586
12132
  value: function () {
11587
- var _registerPILTermsHelper = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12(licenseTerms, txOptions) {
12133
+ var _registerPILTermsHelper = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13(licenseTerms, txOptions) {
11588
12134
  var licenseTermsId, txHash, _yield$waitForTxRecei, receipt, targetLogs;
11589
- return _regenerator().w(function (_context12) {
11590
- while (1) switch (_context12.n) {
12135
+ return _regenerator().w(function (_context13) {
12136
+ while (1) switch (_context13.n) {
11591
12137
  case 0:
12138
+ licenseTerms.commercialRevShare = getRevenueShare(licenseTerms.commercialRevShare);
11592
12139
  if (!(txOptions !== null && txOptions !== void 0 && txOptions.encodedTxDataOnly)) {
11593
- _context12.n = 1;
12140
+ _context13.n = 1;
11594
12141
  break;
11595
12142
  }
11596
- return _context12.a(2, {
12143
+ return _context13.a(2, {
11597
12144
  encodedTxData: this.licenseTemplateClient.registerLicenseTermsEncode({
11598
12145
  terms: licenseTerms
11599
12146
  })
11600
12147
  });
11601
12148
  case 1:
11602
- _context12.n = 2;
12149
+ _context13.n = 2;
11603
12150
  return this.getLicenseTermsId(licenseTerms);
11604
12151
  case 2:
11605
- licenseTermsId = _context12.v;
12152
+ licenseTermsId = _context13.v;
11606
12153
  if (!(licenseTermsId !== 0n)) {
11607
- _context12.n = 3;
12154
+ _context13.n = 3;
11608
12155
  break;
11609
12156
  }
11610
- return _context12.a(2, {
12157
+ return _context13.a(2, {
11611
12158
  licenseTermsId: licenseTermsId
11612
12159
  });
11613
12160
  case 3:
11614
- _context12.n = 4;
12161
+ _context13.n = 4;
11615
12162
  return this.licenseTemplateClient.registerLicenseTerms({
11616
12163
  terms: licenseTerms
11617
12164
  });
11618
12165
  case 4:
11619
- txHash = _context12.v;
11620
- _context12.n = 5;
12166
+ txHash = _context13.v;
12167
+ _context13.n = 5;
11621
12168
  return waitForTxReceipt({
11622
12169
  txOptions: txOptions,
11623
12170
  rpcClient: this.rpcClient,
11624
12171
  txHash: txHash
11625
12172
  });
11626
12173
  case 5:
11627
- _yield$waitForTxRecei = _context12.v;
12174
+ _yield$waitForTxRecei = _context13.v;
11628
12175
  receipt = _yield$waitForTxRecei.receipt;
11629
12176
  targetLogs = this.licenseTemplateClient.parseTxLicenseTermsRegisteredEvent(receipt);
11630
- return _context12.a(2, {
12177
+ return _context13.a(2, {
11631
12178
  txHash: txHash,
11632
12179
  licenseTermsId: targetLogs[0].licenseTermsId
11633
12180
  });
11634
12181
  case 6:
11635
- return _context12.a(2);
12182
+ return _context13.a(2);
11636
12183
  }
11637
- }, _callee12, this);
12184
+ }, _callee13, this);
11638
12185
  }));
11639
- function registerPILTermsHelper(_x12, _x13) {
12186
+ function registerPILTermsHelper(_x13, _x14) {
11640
12187
  return _registerPILTermsHelper.apply(this, arguments);
11641
12188
  }
11642
12189
  return registerPILTermsHelper;
@@ -11679,7 +12226,7 @@ var NftClient = /*#__PURE__*/function () {
11679
12226
  symbol: request.symbol,
11680
12227
  baseURI: (_request$baseURI = request.baseURI) !== null && _request$baseURI !== void 0 ? _request$baseURI : "",
11681
12228
  maxSupply: (_request$maxSupply = request.maxSupply) !== null && _request$maxSupply !== void 0 ? _request$maxSupply : Number(maxUint32),
11682
- mintFee: (_request$mintFee = request.mintFee) !== null && _request$mintFee !== void 0 ? _request$mintFee : 0n,
12229
+ mintFee: BigInt((_request$mintFee = request.mintFee) !== null && _request$mintFee !== void 0 ? _request$mintFee : 0),
11683
12230
  mintFeeToken: (_request$mintFeeToken = request.mintFeeToken) !== null && _request$mintFeeToken !== void 0 ? _request$mintFeeToken : zeroAddress,
11684
12231
  owner: validateAddress(request.owner || this.wallet.account.address),
11685
12232
  mintFeeRecipient: validateAddress(request.mintFeeRecipient),