@story-protocol/core-sdk 1.4.0-rc.2 → 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 +5 -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 +1420 -872
  29. package/dist/story-protocol-core-sdk.cjs.prod.js +1420 -872
  30. package/dist/story-protocol-core-sdk.esm.js +1420 -872
  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);
@@ -6661,6 +6674,7 @@ var getRoyaltyShares = function getRoyaltyShares(royaltyShares) {
6661
6674
  };
6662
6675
  var validateDerivativeData = /*#__PURE__*/function () {
6663
6676
  var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(_ref3) {
6677
+ var _derivativeDataInput$, _derivativeDataInput$2;
6664
6678
  var derivativeDataInput, rpcClient, wallet, chainId, licenseTemplateAddress, ipAssetRegistryClient, licenseRegistryReadOnlyClient, derivativeData, i, parentId, isParentIpRegistered, isAttachedLicenseTerms, _yield$licenseRegistr, royaltyPercent;
6665
6679
  return _regenerator().w(function (_context3) {
6666
6680
  while (1) switch (_context3.n) {
@@ -6676,9 +6690,9 @@ var validateDerivativeData = /*#__PURE__*/function () {
6676
6690
  }),
6677
6691
  licenseTemplate: validateAddress(derivativeDataInput.licenseTemplate || licenseTemplateAddress),
6678
6692
  royaltyContext: zeroAddress,
6679
- maxMintingFee: BigInt(derivativeDataInput.maxMintingFee || 0),
6680
- maxRts: Number(derivativeDataInput.maxRts === undefined ? MAX_ROYALTY_TOKEN : derivativeDataInput.maxRts),
6681
- 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)
6682
6696
  };
6683
6697
  if (!(derivativeData.parentIpIds.length === 0)) {
6684
6698
  _context3.n = 1;
@@ -6704,7 +6718,6 @@ var validateDerivativeData = /*#__PURE__*/function () {
6704
6718
  }
6705
6719
  throw new Error("The maxMintingFee must be greater than 0.");
6706
6720
  case 4:
6707
- validateMaxRts(derivativeData.maxRts);
6708
6721
  i = 0;
6709
6722
  case 5:
6710
6723
  if (!(i < derivativeData.parentIpIds.length)) {
@@ -6766,12 +6779,12 @@ var validateDerivativeData = /*#__PURE__*/function () {
6766
6779
  };
6767
6780
  }();
6768
6781
  var validateMaxRts = function validateMaxRts(maxRts) {
6769
- if (isNaN(maxRts)) {
6770
- throw new Error("The maxRts must be a number.");
6771
- }
6772
- 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) {
6773
6785
  throw new Error("The maxRts must be greater than 0 and less than ".concat(MAX_ROYALTY_TOKEN, "."));
6774
6786
  }
6787
+ return maxRts;
6775
6788
  };
6776
6789
  var getIpIdAddress = /*#__PURE__*/function () {
6777
6790
  var _ref6 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(_ref5) {
@@ -7970,6 +7983,53 @@ var prepareRoyaltyTokensDistributionRequests = /*#__PURE__*/function () {
7970
7983
  };
7971
7984
  }();
7972
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
+
7973
8033
  var IPAssetClient = /*#__PURE__*/function () {
7974
8034
  function IPAssetClient(rpcClient, wallet, chainId) {
7975
8035
  _classCallCheck(this, IPAssetClient);
@@ -7993,6 +8053,7 @@ var IPAssetClient = /*#__PURE__*/function () {
7993
8053
  this.wallet = wallet;
7994
8054
  this.chainId = chainId;
7995
8055
  this.walletAddress = this.wallet.account.address;
8056
+ this.licenseTemplateAddress = this.licenseTemplateClient.address;
7996
8057
  }
7997
8058
  return _createClass(IPAssetClient, [{
7998
8059
  key: "generateCreatorMetadata",
@@ -8379,7 +8440,7 @@ var IPAssetClient = /*#__PURE__*/function () {
8379
8440
  key: "batchRegisterDerivative",
8380
8441
  value: (function () {
8381
8442
  var _batchRegisterDerivative = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(request) {
8382
- 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;
8383
8444
  return _regenerator().w(function (_context5) {
8384
8445
  while (1) switch (_context5.p = _context5.n) {
8385
8446
  case 0:
@@ -8420,7 +8481,7 @@ var IPAssetClient = /*#__PURE__*/function () {
8420
8481
  functionName: "registerDerivative",
8421
8482
  args: [arg.childIpId, arg.parentIpIds, arg.licenseTermsIds.map(function (id) {
8422
8483
  return BigInt(id);
8423
- }), 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)]
8424
8485
  });
8425
8486
  _context5.n = 8;
8426
8487
  return ipAccount.state();
@@ -8510,9 +8571,8 @@ var IPAssetClient = /*#__PURE__*/function () {
8510
8571
  return BigInt(id);
8511
8572
  }),
8512
8573
  royaltyContext: zeroAddress,
8513
- maxRts: Number(request.maxRts)
8574
+ maxRts: validateMaxRts(request.maxRts)
8514
8575
  };
8515
- validateMaxRts(req.maxRts);
8516
8576
  _context6.n = 1;
8517
8577
  return this.isRegistered(request.childIpId);
8518
8578
  case 1:
@@ -8627,10 +8687,12 @@ var IPAssetClient = /*#__PURE__*/function () {
8627
8687
  case 4:
8628
8688
  computedLicenseTermsIds = _context7.v;
8629
8689
  _context7.n = 5;
8630
- return this.setMaxLicenseTokens({
8690
+ return setMaxLicenseTokens({
8631
8691
  maxLicenseTokensData: request.licenseTermsData,
8632
8692
  licensorIpId: rsp.ipId,
8633
- licenseTermsIds: computedLicenseTermsIds
8693
+ licenseTermsIds: computedLicenseTermsIds,
8694
+ totalLicenseTokenLimitHookClient: this.totalLicenseTokenLimitHookClient,
8695
+ templateAddress: this.licenseTemplateAddress
8634
8696
  });
8635
8697
  case 5:
8636
8698
  maxLicenseTokensTxHashes = _context7.v;
@@ -8738,10 +8800,12 @@ var IPAssetClient = /*#__PURE__*/function () {
8738
8800
  licenseTermsIds = _context8.v;
8739
8801
  results[j].licenseTermsIds = licenseTermsIds;
8740
8802
  _context8.n = 13;
8741
- return this.setMaxLicenseTokens({
8803
+ return setMaxLicenseTokens({
8742
8804
  maxLicenseTokensData: licenseTermsData,
8743
8805
  licensorIpId: results[j].ipId,
8744
- licenseTermsIds: licenseTermsIds
8806
+ licenseTermsIds: licenseTermsIds,
8807
+ totalLicenseTokenLimitHookClient: this.totalLicenseTokenLimitHookClient,
8808
+ templateAddress: this.licenseTemplateAddress
8745
8809
  });
8746
8810
  case 13:
8747
8811
  maxLicenseTokensTxHashes = _context8.v;
@@ -8844,10 +8908,12 @@ var IPAssetClient = /*#__PURE__*/function () {
8844
8908
  case 9:
8845
8909
  licenseTermsIds = _context9.v;
8846
8910
  _context9.n = 10;
8847
- return this.setMaxLicenseTokens({
8911
+ return setMaxLicenseTokens({
8848
8912
  maxLicenseTokensData: request.licenseTermsData,
8849
8913
  licensorIpId: log.ipId,
8850
- licenseTermsIds: licenseTermsIds
8914
+ licenseTermsIds: licenseTermsIds,
8915
+ totalLicenseTokenLimitHookClient: this.totalLicenseTokenLimitHookClient,
8916
+ templateAddress: this.licenseTemplateAddress
8851
8917
  });
8852
8918
  case 10:
8853
8919
  maxLicenseTokensTxHashes = _context9.v;
@@ -9393,120 +9459,6 @@ var IPAssetClient = /*#__PURE__*/function () {
9393
9459
  }
9394
9460
  return batchMintAndRegisterIp;
9395
9461
  }()
9396
- /**
9397
- * Register Programmable IP License Terms (if unregistered) and attach it to IP.
9398
- *
9399
- * 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.
9400
- */
9401
- )
9402
- }, {
9403
- key: "registerPilTermsAndAttach",
9404
- value: (function () {
9405
- var _registerPilTermsAndAttach = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15(request) {
9406
- var _request$txOptions9, ipId, isRegistered, _yield$validateLicens2, licenseTerms, licenseTermsData, calculatedDeadline, ipAccount, _yield$ipAccount$stat2, state, signature, _object2, txHash, licenseTermsIds, maxLicenseTokensTxHashes, _t22;
9407
- return _regenerator().w(function (_context15) {
9408
- while (1) switch (_context15.p = _context15.n) {
9409
- case 0:
9410
- _context15.p = 0;
9411
- ipId = request.ipId;
9412
- _context15.n = 1;
9413
- return this.isRegistered(ipId);
9414
- case 1:
9415
- isRegistered = _context15.v;
9416
- if (isRegistered) {
9417
- _context15.n = 2;
9418
- break;
9419
- }
9420
- throw new Error("The IP with id ".concat(ipId, " is not registered."));
9421
- case 2:
9422
- _context15.n = 3;
9423
- return validateLicenseTermsData(request.licenseTermsData, this.rpcClient, this.chainId);
9424
- case 3:
9425
- _yield$validateLicens2 = _context15.v;
9426
- licenseTerms = _yield$validateLicens2.licenseTerms;
9427
- licenseTermsData = _yield$validateLicens2.licenseTermsData;
9428
- _context15.n = 4;
9429
- return getCalculatedDeadline(this.rpcClient, request.deadline);
9430
- case 4:
9431
- calculatedDeadline = _context15.v;
9432
- ipAccount = new IpAccountImplClient(this.rpcClient, this.wallet, ipId);
9433
- _context15.n = 5;
9434
- return ipAccount.state();
9435
- case 5:
9436
- _yield$ipAccount$stat2 = _context15.v;
9437
- state = _yield$ipAccount$stat2.result;
9438
- _context15.n = 6;
9439
- return generateOperationSignature({
9440
- ipIdAddress: ipId,
9441
- methodType: SignatureMethodType.REGISTER_PIL_TERMS_AND_ATTACH,
9442
- deadline: calculatedDeadline,
9443
- state: state,
9444
- wallet: this.wallet,
9445
- chainId: this.chainId
9446
- });
9447
- case 6:
9448
- signature = _context15.v;
9449
- _object2 = {
9450
- ipId: ipId,
9451
- licenseTermsData: licenseTermsData,
9452
- sigAttachAndConfig: {
9453
- signer: validateAddress(this.walletAddress),
9454
- deadline: calculatedDeadline,
9455
- signature: signature
9456
- }
9457
- };
9458
- if (!((_request$txOptions9 = request.txOptions) !== null && _request$txOptions9 !== void 0 && _request$txOptions9.encodedTxDataOnly)) {
9459
- _context15.n = 7;
9460
- break;
9461
- }
9462
- return _context15.a(2, {
9463
- encodedTxData: this.licenseAttachmentWorkflowsClient.registerPilTermsAndAttachEncode(_object2)
9464
- });
9465
- case 7:
9466
- _context15.n = 8;
9467
- return this.licenseAttachmentWorkflowsClient.registerPilTermsAndAttach(_object2);
9468
- case 8:
9469
- txHash = _context15.v;
9470
- _context15.n = 9;
9471
- return this.rpcClient.waitForTransactionReceipt(_objectSpread2(_objectSpread2({}, request.txOptions), {}, {
9472
- hash: txHash
9473
- }));
9474
- case 9:
9475
- _context15.n = 10;
9476
- return this.getLicenseTermsId(licenseTerms);
9477
- case 10:
9478
- licenseTermsIds = _context15.v;
9479
- _context15.n = 11;
9480
- return this.setMaxLicenseTokens({
9481
- maxLicenseTokensData: request.licenseTermsData,
9482
- licensorIpId: ipId,
9483
- licenseTermsIds: licenseTermsIds
9484
- });
9485
- case 11:
9486
- maxLicenseTokensTxHashes = _context15.v;
9487
- return _context15.a(2, _objectSpread2({
9488
- txHash: txHash,
9489
- licenseTermsIds: licenseTermsIds
9490
- }, maxLicenseTokensTxHashes.length > 0 && {
9491
- maxLicenseTokensTxHashes: maxLicenseTokensTxHashes
9492
- }));
9493
- case 12:
9494
- _context15.n = 14;
9495
- break;
9496
- case 13:
9497
- _context15.p = 13;
9498
- _t22 = _context15.v;
9499
- return _context15.a(2, handleError(_t22, "Failed to register PIL terms and attach"));
9500
- case 14:
9501
- return _context15.a(2);
9502
- }
9503
- }, _callee15, this, [[0, 13]]);
9504
- }));
9505
- function registerPilTermsAndAttach(_x14) {
9506
- return _registerPilTermsAndAttach.apply(this, arguments);
9507
- }
9508
- return registerPilTermsAndAttach;
9509
- }()
9510
9462
  /**
9511
9463
  * Mint an NFT from a collection and register it as a derivative IP using license tokens.
9512
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.
@@ -9517,70 +9469,69 @@ var IPAssetClient = /*#__PURE__*/function () {
9517
9469
  }, {
9518
9470
  key: "mintAndRegisterIpAndMakeDerivativeWithLicenseTokens",
9519
9471
  value: (function () {
9520
- var _mintAndRegisterIpAndMakeDerivativeWithLicenseTokens = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17(request) {
9472
+ var _mintAndRegisterIpAndMakeDerivativeWithLicenseTokens = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16(request) {
9521
9473
  var _this8 = this;
9522
- var _request$txOptions0, _request$options6, licenseTokenIds, _object3, encodedTxData, contractCall, _t23;
9523
- return _regenerator().w(function (_context17) {
9524
- 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) {
9525
9477
  case 0:
9526
- _context17.p = 0;
9527
- _context17.n = 1;
9478
+ _context16.p = 0;
9479
+ _context16.n = 1;
9528
9480
  return this.validateLicenseTokenIds(request.licenseTokenIds);
9529
9481
  case 1:
9530
- licenseTokenIds = _context17.v;
9531
- _object3 = {
9482
+ licenseTokenIds = _context16.v;
9483
+ _object2 = {
9532
9484
  spgNftContract: validateAddress(request.spgNftContract),
9533
9485
  recipient: validateAddress(request.recipient || this.walletAddress),
9534
9486
  ipMetadata: getIpMetadataForWorkflow(request.ipMetadata),
9535
9487
  licenseTokenIds: licenseTokenIds,
9536
9488
  royaltyContext: zeroAddress,
9537
- maxRts: Number(request.maxRts),
9489
+ maxRts: validateMaxRts(request.maxRts),
9538
9490
  allowDuplicates: request.allowDuplicates || true
9539
9491
  };
9540
- validateMaxRts(_object3.maxRts);
9541
- encodedTxData = this.derivativeWorkflowsClient.mintAndRegisterIpAndMakeDerivativeWithLicenseTokensEncode(_object3);
9542
- if (!((_request$txOptions0 = request.txOptions) !== null && _request$txOptions0 !== void 0 && _request$txOptions0.encodedTxDataOnly)) {
9543
- _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;
9544
9495
  break;
9545
9496
  }
9546
- return _context17.a(2, {
9497
+ return _context16.a(2, {
9547
9498
  encodedTxData: encodedTxData
9548
9499
  });
9549
9500
  case 2:
9550
9501
  contractCall = /*#__PURE__*/function () {
9551
- var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16() {
9552
- return _regenerator().w(function (_context16) {
9553
- 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) {
9554
9505
  case 0:
9555
- return _context16.a(2, _this8.derivativeWorkflowsClient.mintAndRegisterIpAndMakeDerivativeWithLicenseTokens(_object3));
9506
+ return _context15.a(2, _this8.derivativeWorkflowsClient.mintAndRegisterIpAndMakeDerivativeWithLicenseTokens(_object2));
9556
9507
  }
9557
- }, _callee16);
9508
+ }, _callee15);
9558
9509
  }));
9559
9510
  return function contractCall() {
9560
9511
  return _ref4.apply(this, arguments);
9561
9512
  };
9562
9513
  }();
9563
- return _context17.a(2, this.handleRegistrationWithFees({
9514
+ return _context16.a(2, this.handleRegistrationWithFees({
9564
9515
  wipOptions: _objectSpread2(_objectSpread2({}, (_request$options6 = request.options) === null || _request$options6 === void 0 ? void 0 : _request$options6.wipOptions), {}, {
9565
9516
  // need to disable multicall to avoid needing to transfer the license
9566
9517
  // token to the multicall contract.
9567
9518
  useMulticallWhenPossible: false
9568
9519
  }),
9569
9520
  sender: this.walletAddress,
9570
- spgNftContract: _object3.spgNftContract,
9521
+ spgNftContract: _object2.spgNftContract,
9571
9522
  spgSpenderAddress: this.derivativeWorkflowsClient.address,
9572
9523
  encodedTxs: [encodedTxData],
9573
9524
  contractCall: contractCall,
9574
9525
  txOptions: request.txOptions
9575
9526
  }));
9576
9527
  case 3:
9577
- _context17.p = 3;
9578
- _t23 = _context17.v;
9579
- 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"));
9580
9531
  }
9581
- }, _callee17, this, [[0, 3]]);
9532
+ }, _callee16, this, [[0, 3]]);
9582
9533
  }));
9583
- function mintAndRegisterIpAndMakeDerivativeWithLicenseTokens(_x15) {
9534
+ function mintAndRegisterIpAndMakeDerivativeWithLicenseTokens(_x14) {
9584
9535
  return _mintAndRegisterIpAndMakeDerivativeWithLicenseTokens.apply(this, arguments);
9585
9536
  }
9586
9537
  return mintAndRegisterIpAndMakeDerivativeWithLicenseTokens;
@@ -9594,14 +9545,14 @@ var IPAssetClient = /*#__PURE__*/function () {
9594
9545
  }, {
9595
9546
  key: "registerIpAndMakeDerivativeWithLicenseTokens",
9596
9547
  value: (function () {
9597
- var _registerIpAndMakeDerivativeWithLicenseTokens = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18(request) {
9598
- var _request$txOptions1, tokenId, ipIdAddress, isRegistered, licenseTokenIds, calculatedDeadline, signature, _object4, txHash, receipt, log, _t24;
9599
- return _regenerator().w(function (_context18) {
9600
- 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) {
9601
9552
  case 0:
9602
- _context18.p = 0;
9553
+ _context17.p = 0;
9603
9554
  tokenId = BigInt(request.tokenId);
9604
- _context18.n = 1;
9555
+ _context17.n = 1;
9605
9556
  return getIpIdAddress({
9606
9557
  nftContract: request.nftContract,
9607
9558
  tokenId: tokenId,
@@ -9610,26 +9561,26 @@ var IPAssetClient = /*#__PURE__*/function () {
9610
9561
  chainId: this.chainId
9611
9562
  });
9612
9563
  case 1:
9613
- ipIdAddress = _context18.v;
9614
- _context18.n = 2;
9564
+ ipIdAddress = _context17.v;
9565
+ _context17.n = 2;
9615
9566
  return this.isRegistered(ipIdAddress);
9616
9567
  case 2:
9617
- isRegistered = _context18.v;
9568
+ isRegistered = _context17.v;
9618
9569
  if (!isRegistered) {
9619
- _context18.n = 3;
9570
+ _context17.n = 3;
9620
9571
  break;
9621
9572
  }
9622
9573
  throw new Error("The NFT with id ".concat(tokenId, " is already registered as IP."));
9623
9574
  case 3:
9624
- _context18.n = 4;
9575
+ _context17.n = 4;
9625
9576
  return this.validateLicenseTokenIds(request.licenseTokenIds);
9626
9577
  case 4:
9627
- licenseTokenIds = _context18.v;
9628
- _context18.n = 5;
9578
+ licenseTokenIds = _context17.v;
9579
+ _context17.n = 5;
9629
9580
  return getCalculatedDeadline(this.rpcClient, request.deadline);
9630
9581
  case 5:
9631
- calculatedDeadline = _context18.v;
9632
- _context18.n = 6;
9582
+ calculatedDeadline = _context17.v;
9583
+ _context17.n = 6;
9633
9584
  return generateOperationSignature({
9634
9585
  ipIdAddress: ipIdAddress,
9635
9586
  methodType: SignatureMethodType.REGISTER_IP_AND_MAKE_DERIVATIVE_WITH_LICENSE_TOKENS,
@@ -9638,8 +9589,8 @@ var IPAssetClient = /*#__PURE__*/function () {
9638
9589
  chainId: this.chainId
9639
9590
  });
9640
9591
  case 6:
9641
- signature = _context18.v;
9642
- _object4 = _objectSpread2(_objectSpread2({}, request), {}, {
9592
+ signature = _context17.v;
9593
+ _object3 = _objectSpread2(_objectSpread2({}, request), {}, {
9643
9594
  tokenId: tokenId,
9644
9595
  licenseTokenIds: licenseTokenIds,
9645
9596
  royaltyContext: zeroAddress,
@@ -9649,44 +9600,43 @@ var IPAssetClient = /*#__PURE__*/function () {
9649
9600
  deadline: calculatedDeadline,
9650
9601
  signature: signature
9651
9602
  },
9652
- maxRts: Number(request.maxRts)
9603
+ maxRts: validateMaxRts(request.maxRts)
9653
9604
  });
9654
- validateMaxRts(_object4.maxRts);
9655
- if (!((_request$txOptions1 = request.txOptions) !== null && _request$txOptions1 !== void 0 && _request$txOptions1.encodedTxDataOnly)) {
9656
- _context18.n = 7;
9605
+ if (!((_request$txOptions0 = request.txOptions) !== null && _request$txOptions0 !== void 0 && _request$txOptions0.encodedTxDataOnly)) {
9606
+ _context17.n = 7;
9657
9607
  break;
9658
9608
  }
9659
- return _context18.a(2, {
9660
- encodedTxData: this.derivativeWorkflowsClient.registerIpAndMakeDerivativeWithLicenseTokensEncode(_object4)
9609
+ return _context17.a(2, {
9610
+ encodedTxData: this.derivativeWorkflowsClient.registerIpAndMakeDerivativeWithLicenseTokensEncode(_object3)
9661
9611
  });
9662
9612
  case 7:
9663
- _context18.n = 8;
9664
- return this.derivativeWorkflowsClient.registerIpAndMakeDerivativeWithLicenseTokens(_object4);
9613
+ _context17.n = 8;
9614
+ return this.derivativeWorkflowsClient.registerIpAndMakeDerivativeWithLicenseTokens(_object3);
9665
9615
  case 8:
9666
- txHash = _context18.v;
9667
- _context18.n = 9;
9616
+ txHash = _context17.v;
9617
+ _context17.n = 9;
9668
9618
  return this.rpcClient.waitForTransactionReceipt(_objectSpread2(_objectSpread2({}, request.txOptions), {}, {
9669
9619
  hash: txHash
9670
9620
  }));
9671
9621
  case 9:
9672
- receipt = _context18.v;
9622
+ receipt = _context17.v;
9673
9623
  log = this.getIpIdAndTokenIdsFromEvent(receipt)[0];
9674
- return _context18.a(2, _objectSpread2({
9624
+ return _context17.a(2, _objectSpread2({
9675
9625
  txHash: txHash
9676
9626
  }, log));
9677
9627
  case 10:
9678
- _context18.n = 12;
9628
+ _context17.n = 12;
9679
9629
  break;
9680
9630
  case 11:
9681
- _context18.p = 11;
9682
- _t24 = _context18.v;
9683
- 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"));
9684
9634
  case 12:
9685
- return _context18.a(2);
9635
+ return _context17.a(2);
9686
9636
  }
9687
- }, _callee18, this, [[0, 11]]);
9637
+ }, _callee17, this, [[0, 11]]);
9688
9638
  }));
9689
- function registerIpAndMakeDerivativeWithLicenseTokens(_x16) {
9639
+ function registerIpAndMakeDerivativeWithLicenseTokens(_x15) {
9690
9640
  return _registerIpAndMakeDerivativeWithLicenseTokens.apply(this, arguments);
9691
9641
  }
9692
9642
  return registerIpAndMakeDerivativeWithLicenseTokens;
@@ -9702,23 +9652,23 @@ var IPAssetClient = /*#__PURE__*/function () {
9702
9652
  }, {
9703
9653
  key: "registerIPAndAttachLicenseTermsAndDistributeRoyaltyTokens",
9704
9654
  value: (function () {
9705
- var _registerIPAndAttachLicenseTermsAndDistributeRoyaltyTokens = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19(request) {
9706
- var _getRoyaltyShares, royaltyShares, totalAmount, _yield$validateLicens3, licenseTerms, calculatedDeadline, ipIdAddress, isRegistered, _yield$transformRegis5, _transformRequest4, registerIpAndAttachPilTermsAndDeployRoyaltyVaultTxHash, txReceipt, ipId, licenseTermsIds, ipRoyaltyVault, distributeRoyaltyTokensTxHash, maxLicenseTokensTxHashes, _t25;
9707
- return _regenerator().w(function (_context19) {
9708
- 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) {
9709
9659
  case 0:
9710
- _context19.p = 0;
9660
+ _context18.p = 0;
9711
9661
  _getRoyaltyShares = getRoyaltyShares(request.royaltyShares), royaltyShares = _getRoyaltyShares.royaltyShares, totalAmount = _getRoyaltyShares.totalAmount;
9712
- _context19.n = 1;
9662
+ _context18.n = 1;
9713
9663
  return validateLicenseTermsData(request.licenseTermsData, this.rpcClient, this.chainId);
9714
9664
  case 1:
9715
- _yield$validateLicens3 = _context19.v;
9716
- licenseTerms = _yield$validateLicens3.licenseTerms;
9717
- _context19.n = 2;
9665
+ _yield$validateLicens2 = _context18.v;
9666
+ licenseTerms = _yield$validateLicens2.licenseTerms;
9667
+ _context18.n = 2;
9718
9668
  return getCalculatedDeadline(this.rpcClient, request.deadline);
9719
9669
  case 2:
9720
- calculatedDeadline = _context19.v;
9721
- _context19.n = 3;
9670
+ calculatedDeadline = _context18.v;
9671
+ _context18.n = 3;
9722
9672
  return getIpIdAddress({
9723
9673
  nftContract: validateAddress(request.nftContract),
9724
9674
  tokenId: BigInt(request.tokenId),
@@ -9727,18 +9677,18 @@ var IPAssetClient = /*#__PURE__*/function () {
9727
9677
  chainId: this.chainId
9728
9678
  });
9729
9679
  case 3:
9730
- ipIdAddress = _context19.v;
9731
- _context19.n = 4;
9680
+ ipIdAddress = _context18.v;
9681
+ _context18.n = 4;
9732
9682
  return this.isRegistered(ipIdAddress);
9733
9683
  case 4:
9734
- isRegistered = _context19.v;
9684
+ isRegistered = _context18.v;
9735
9685
  if (!isRegistered) {
9736
- _context19.n = 5;
9686
+ _context18.n = 5;
9737
9687
  break;
9738
9688
  }
9739
9689
  throw new Error("The NFT with id ".concat(request.tokenId, " is already registered as IP."));
9740
9690
  case 5:
9741
- _context19.n = 6;
9691
+ _context18.n = 6;
9742
9692
  return transformRegistrationRequest({
9743
9693
  request: request,
9744
9694
  rpcClient: this.rpcClient,
@@ -9746,25 +9696,25 @@ var IPAssetClient = /*#__PURE__*/function () {
9746
9696
  chainId: this.chainId
9747
9697
  });
9748
9698
  case 6:
9749
- _yield$transformRegis5 = _context19.v;
9699
+ _yield$transformRegis5 = _context18.v;
9750
9700
  _transformRequest4 = _yield$transformRegis5.transformRequest;
9751
- _context19.n = 7;
9701
+ _context18.n = 7;
9752
9702
  return this.royaltyTokenDistributionWorkflowsClient.registerIpAndAttachPilTermsAndDeployRoyaltyVault(_transformRequest4);
9753
9703
  case 7:
9754
- registerIpAndAttachPilTermsAndDeployRoyaltyVaultTxHash = _context19.v;
9755
- _context19.n = 8;
9704
+ registerIpAndAttachPilTermsAndDeployRoyaltyVaultTxHash = _context18.v;
9705
+ _context18.n = 8;
9756
9706
  return this.rpcClient.waitForTransactionReceipt(_objectSpread2(_objectSpread2({}, request.txOptions), {}, {
9757
9707
  hash: registerIpAndAttachPilTermsAndDeployRoyaltyVaultTxHash
9758
9708
  }));
9759
9709
  case 8:
9760
- txReceipt = _context19.v;
9710
+ txReceipt = _context18.v;
9761
9711
  ipId = this.getIpIdAndTokenIdsFromEvent(txReceipt)[0].ipId;
9762
- _context19.n = 9;
9712
+ _context18.n = 9;
9763
9713
  return this.getLicenseTermsId(licenseTerms);
9764
9714
  case 9:
9765
- licenseTermsIds = _context19.v;
9715
+ licenseTermsIds = _context18.v;
9766
9716
  ipRoyaltyVault = this.royaltyModuleEventClient.parseTxIpRoyaltyVaultDeployedEvent(txReceipt)[0].ipRoyaltyVault;
9767
- _context19.n = 10;
9717
+ _context18.n = 10;
9768
9718
  return this.distributeRoyaltyTokens({
9769
9719
  ipId: ipId,
9770
9720
  deadline: calculatedDeadline,
@@ -9774,21 +9724,23 @@ var IPAssetClient = /*#__PURE__*/function () {
9774
9724
  txOptions: request.txOptions
9775
9725
  });
9776
9726
  case 10:
9777
- distributeRoyaltyTokensTxHash = _context19.v;
9778
- _context19.n = 11;
9727
+ distributeRoyaltyTokensTxHash = _context18.v;
9728
+ _context18.n = 11;
9779
9729
  return this.rpcClient.waitForTransactionReceipt(_objectSpread2(_objectSpread2({}, request.txOptions), {}, {
9780
9730
  hash: distributeRoyaltyTokensTxHash
9781
9731
  }));
9782
9732
  case 11:
9783
- _context19.n = 12;
9784
- return this.setMaxLicenseTokens({
9733
+ _context18.n = 12;
9734
+ return setMaxLicenseTokens({
9785
9735
  maxLicenseTokensData: request.licenseTermsData,
9786
9736
  licensorIpId: ipId,
9787
- licenseTermsIds: licenseTermsIds
9737
+ licenseTermsIds: licenseTermsIds,
9738
+ totalLicenseTokenLimitHookClient: this.totalLicenseTokenLimitHookClient,
9739
+ templateAddress: this.licenseTemplateAddress
9788
9740
  });
9789
9741
  case 12:
9790
- maxLicenseTokensTxHashes = _context19.v;
9791
- return _context19.a(2, _objectSpread2({
9742
+ maxLicenseTokensTxHashes = _context18.v;
9743
+ return _context18.a(2, _objectSpread2({
9792
9744
  registerIpAndAttachPilTermsAndDeployRoyaltyVaultTxHash: registerIpAndAttachPilTermsAndDeployRoyaltyVaultTxHash,
9793
9745
  distributeRoyaltyTokensTxHash: distributeRoyaltyTokensTxHash,
9794
9746
  ipId: ipId,
@@ -9798,13 +9750,13 @@ var IPAssetClient = /*#__PURE__*/function () {
9798
9750
  maxLicenseTokensTxHashes: maxLicenseTokensTxHashes
9799
9751
  }));
9800
9752
  case 13:
9801
- _context19.p = 13;
9802
- _t25 = _context19.v;
9803
- 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"));
9804
9756
  }
9805
- }, _callee19, this, [[0, 13]]);
9757
+ }, _callee18, this, [[0, 13]]);
9806
9758
  }));
9807
- function registerIPAndAttachLicenseTermsAndDistributeRoyaltyTokens(_x17) {
9759
+ function registerIPAndAttachLicenseTermsAndDistributeRoyaltyTokens(_x16) {
9808
9760
  return _registerIPAndAttachLicenseTermsAndDistributeRoyaltyTokens.apply(this, arguments);
9809
9761
  }
9810
9762
  return registerIPAndAttachLicenseTermsAndDistributeRoyaltyTokens;
@@ -9819,14 +9771,14 @@ var IPAssetClient = /*#__PURE__*/function () {
9819
9771
  }, {
9820
9772
  key: "registerDerivativeIpAndAttachLicenseTermsAndDistributeRoyaltyTokens",
9821
9773
  value: (function () {
9822
- var _registerDerivativeIpAndAttachLicenseTermsAndDistributeRoyaltyTokens = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee20(request) {
9774
+ var _registerDerivativeIpAndAttachLicenseTermsAndDistributeRoyaltyTokens = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19(request) {
9823
9775
  var _this9 = this;
9824
- var _request$options7, ipIdAddress, _yield$transformRegis6, _transformRequest5, _getRoyaltyShares2, royaltyShares, totalAmount, isRegistered, encodedTxData, contractCall, _yield$this$handleReg, txHash, ipId, tokenId, receipt, ipRoyaltyVault, distributeRoyaltyTokensTxHash, _t26;
9825
- return _regenerator().w(function (_context20) {
9826
- 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) {
9827
9779
  case 0:
9828
- _context20.p = 0;
9829
- _context20.n = 1;
9780
+ _context19.p = 0;
9781
+ _context19.n = 1;
9830
9782
  return getIpIdAddress({
9831
9783
  nftContract: validateAddress(request.nftContract),
9832
9784
  tokenId: BigInt(request.tokenId),
@@ -9835,8 +9787,8 @@ var IPAssetClient = /*#__PURE__*/function () {
9835
9787
  chainId: this.chainId
9836
9788
  });
9837
9789
  case 1:
9838
- ipIdAddress = _context20.v;
9839
- _context20.n = 2;
9790
+ ipIdAddress = _context19.v;
9791
+ _context19.n = 2;
9840
9792
  return transformRegistrationRequest({
9841
9793
  request: request,
9842
9794
  rpcClient: this.rpcClient,
@@ -9844,15 +9796,15 @@ var IPAssetClient = /*#__PURE__*/function () {
9844
9796
  chainId: this.chainId
9845
9797
  });
9846
9798
  case 2:
9847
- _yield$transformRegis6 = _context20.v;
9799
+ _yield$transformRegis6 = _context19.v;
9848
9800
  _transformRequest5 = _yield$transformRegis6.transformRequest;
9849
9801
  _getRoyaltyShares2 = getRoyaltyShares(request.royaltyShares), royaltyShares = _getRoyaltyShares2.royaltyShares, totalAmount = _getRoyaltyShares2.totalAmount;
9850
- _context20.n = 3;
9802
+ _context19.n = 3;
9851
9803
  return this.isRegistered(ipIdAddress);
9852
9804
  case 3:
9853
- isRegistered = _context20.v;
9805
+ isRegistered = _context19.v;
9854
9806
  if (!isRegistered) {
9855
- _context20.n = 4;
9807
+ _context19.n = 4;
9856
9808
  break;
9857
9809
  }
9858
9810
  throw new Error("The NFT with id ".concat(request.tokenId, " is already registered as IP."));
@@ -9861,7 +9813,7 @@ var IPAssetClient = /*#__PURE__*/function () {
9861
9813
  contractCall = function contractCall() {
9862
9814
  return _this9.royaltyTokenDistributionWorkflowsClient.registerIpAndMakeDerivativeAndDeployRoyaltyVault(_transformRequest5);
9863
9815
  };
9864
- _context20.n = 5;
9816
+ _context19.n = 5;
9865
9817
  return this.handleRegistrationWithFees({
9866
9818
  wipOptions: _objectSpread2(_objectSpread2({}, (_request$options7 = request.options) === null || _request$options7 === void 0 ? void 0 : _request$options7.wipOptions), {}, {
9867
9819
  useMulticallWhenPossible: false
@@ -9874,13 +9826,13 @@ var IPAssetClient = /*#__PURE__*/function () {
9874
9826
  txOptions: _objectSpread2({}, request.txOptions)
9875
9827
  });
9876
9828
  case 5:
9877
- _yield$this$handleReg = _context20.v;
9829
+ _yield$this$handleReg = _context19.v;
9878
9830
  txHash = _yield$this$handleReg.txHash;
9879
9831
  ipId = _yield$this$handleReg.ipId;
9880
9832
  tokenId = _yield$this$handleReg.tokenId;
9881
9833
  receipt = _yield$this$handleReg.receipt;
9882
9834
  if (!(tokenId === undefined || !ipId || !receipt)) {
9883
- _context20.n = 6;
9835
+ _context19.n = 6;
9884
9836
  break;
9885
9837
  }
9886
9838
  throw new Error("Failed to register derivative ip and deploy royalty vault.");
@@ -9888,7 +9840,7 @@ var IPAssetClient = /*#__PURE__*/function () {
9888
9840
  ipRoyaltyVault = this.royaltyModuleEventClient.parseTxIpRoyaltyVaultDeployedEvent(receipt).filter(function (item) {
9889
9841
  return item.ipId === ipId;
9890
9842
  })[0].ipRoyaltyVault;
9891
- _context20.n = 7;
9843
+ _context19.n = 7;
9892
9844
  return this.distributeRoyaltyTokens({
9893
9845
  ipId: ipId,
9894
9846
  deadline: request.deadline,
@@ -9898,13 +9850,13 @@ var IPAssetClient = /*#__PURE__*/function () {
9898
9850
  txOptions: request.txOptions
9899
9851
  });
9900
9852
  case 7:
9901
- distributeRoyaltyTokensTxHash = _context20.v;
9902
- _context20.n = 8;
9853
+ distributeRoyaltyTokensTxHash = _context19.v;
9854
+ _context19.n = 8;
9903
9855
  return this.rpcClient.waitForTransactionReceipt(_objectSpread2(_objectSpread2({}, request.txOptions), {}, {
9904
9856
  hash: distributeRoyaltyTokensTxHash
9905
9857
  }));
9906
9858
  case 8:
9907
- return _context20.a(2, {
9859
+ return _context19.a(2, {
9908
9860
  registerDerivativeIpAndAttachLicenseTermsAndDistributeRoyaltyTokensTxHash: txHash,
9909
9861
  distributeRoyaltyTokensTxHash: distributeRoyaltyTokensTxHash,
9910
9862
  ipId: ipId,
@@ -9912,13 +9864,13 @@ var IPAssetClient = /*#__PURE__*/function () {
9912
9864
  ipRoyaltyVault: ipRoyaltyVault
9913
9865
  });
9914
9866
  case 9:
9915
- _context20.p = 9;
9916
- _t26 = _context20.v;
9917
- 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"));
9918
9870
  }
9919
- }, _callee20, this, [[0, 9]]);
9871
+ }, _callee19, this, [[0, 9]]);
9920
9872
  }));
9921
- function registerDerivativeIpAndAttachLicenseTermsAndDistributeRoyaltyTokens(_x18) {
9873
+ function registerDerivativeIpAndAttachLicenseTermsAndDistributeRoyaltyTokens(_x17) {
9922
9874
  return _registerDerivativeIpAndAttachLicenseTermsAndDistributeRoyaltyTokens.apply(this, arguments);
9923
9875
  }
9924
9876
  return registerDerivativeIpAndAttachLicenseTermsAndDistributeRoyaltyTokens;
@@ -9932,19 +9884,19 @@ var IPAssetClient = /*#__PURE__*/function () {
9932
9884
  }, {
9933
9885
  key: "mintAndRegisterIpAndAttachPilTermsAndDistributeRoyaltyTokens",
9934
9886
  value: (function () {
9935
- var _mintAndRegisterIpAndAttachPilTermsAndDistributeRoyaltyTokens = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee21(request) {
9887
+ var _mintAndRegisterIpAndAttachPilTermsAndDistributeRoyaltyTokens = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee20(request) {
9936
9888
  var _this0 = this;
9937
- var _request$options8, _yield$validateLicens4, licenseTerms, _yield$transformRegis7, _transformRequest6, encodedTxData, contractCall, _yield$this$handleReg2, txHash, ipId, tokenId, receipt, licenseTermsIds, ipRoyaltyVault, maxLicenseTokensTxHashes, _t27;
9938
- return _regenerator().w(function (_context21) {
9939
- 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) {
9940
9892
  case 0:
9941
- _context21.p = 0;
9942
- _context21.n = 1;
9893
+ _context20.p = 0;
9894
+ _context20.n = 1;
9943
9895
  return validateLicenseTermsData(request.licenseTermsData, this.rpcClient, this.chainId);
9944
9896
  case 1:
9945
- _yield$validateLicens4 = _context21.v;
9946
- licenseTerms = _yield$validateLicens4.licenseTerms;
9947
- _context21.n = 2;
9897
+ _yield$validateLicens3 = _context20.v;
9898
+ licenseTerms = _yield$validateLicens3.licenseTerms;
9899
+ _context20.n = 2;
9948
9900
  return transformRegistrationRequest({
9949
9901
  request: request,
9950
9902
  rpcClient: this.rpcClient,
@@ -9952,13 +9904,13 @@ var IPAssetClient = /*#__PURE__*/function () {
9952
9904
  chainId: this.chainId
9953
9905
  });
9954
9906
  case 2:
9955
- _yield$transformRegis7 = _context21.v;
9907
+ _yield$transformRegis7 = _context20.v;
9956
9908
  _transformRequest6 = _yield$transformRegis7.transformRequest;
9957
9909
  encodedTxData = this.royaltyTokenDistributionWorkflowsClient.mintAndRegisterIpAndAttachPilTermsAndDistributeRoyaltyTokensEncode(_transformRequest6);
9958
9910
  contractCall = function contractCall() {
9959
9911
  return _this0.royaltyTokenDistributionWorkflowsClient.mintAndRegisterIpAndAttachPilTermsAndDistributeRoyaltyTokens(_transformRequest6);
9960
9912
  };
9961
- _context21.n = 3;
9913
+ _context20.n = 3;
9962
9914
  return this.handleRegistrationWithFees({
9963
9915
  wipOptions: (_request$options8 = request.options) === null || _request$options8 === void 0 ? void 0 : _request$options8.wipOptions,
9964
9916
  sender: this.walletAddress,
@@ -9969,33 +9921,35 @@ var IPAssetClient = /*#__PURE__*/function () {
9969
9921
  txOptions: request.txOptions
9970
9922
  });
9971
9923
  case 3:
9972
- _yield$this$handleReg2 = _context21.v;
9924
+ _yield$this$handleReg2 = _context20.v;
9973
9925
  txHash = _yield$this$handleReg2.txHash;
9974
9926
  ipId = _yield$this$handleReg2.ipId;
9975
9927
  tokenId = _yield$this$handleReg2.tokenId;
9976
9928
  receipt = _yield$this$handleReg2.receipt;
9977
9929
  if (receipt) {
9978
- _context21.n = 4;
9930
+ _context20.n = 4;
9979
9931
  break;
9980
9932
  }
9981
- return _context21.a(2, {
9933
+ return _context20.a(2, {
9982
9934
  txHash: txHash
9983
9935
  });
9984
9936
  case 4:
9985
- _context21.n = 5;
9937
+ _context20.n = 5;
9986
9938
  return this.getLicenseTermsId(licenseTerms);
9987
9939
  case 5:
9988
- licenseTermsIds = _context21.v;
9940
+ licenseTermsIds = _context20.v;
9989
9941
  ipRoyaltyVault = this.royaltyModuleEventClient.parseTxIpRoyaltyVaultDeployedEvent(receipt)[0].ipRoyaltyVault;
9990
- _context21.n = 6;
9991
- return this.setMaxLicenseTokens({
9942
+ _context20.n = 6;
9943
+ return setMaxLicenseTokens({
9992
9944
  maxLicenseTokensData: request.licenseTermsData,
9993
9945
  licensorIpId: ipId,
9994
- licenseTermsIds: licenseTermsIds
9946
+ licenseTermsIds: licenseTermsIds,
9947
+ totalLicenseTokenLimitHookClient: this.totalLicenseTokenLimitHookClient,
9948
+ templateAddress: this.licenseTemplateAddress
9995
9949
  });
9996
9950
  case 6:
9997
- maxLicenseTokensTxHashes = _context21.v;
9998
- return _context21.a(2, _objectSpread2({
9951
+ maxLicenseTokensTxHashes = _context20.v;
9952
+ return _context20.a(2, _objectSpread2({
9999
9953
  txHash: txHash,
10000
9954
  ipId: ipId,
10001
9955
  licenseTermsIds: licenseTermsIds,
@@ -10005,13 +9959,13 @@ var IPAssetClient = /*#__PURE__*/function () {
10005
9959
  maxLicenseTokensTxHashes: maxLicenseTokensTxHashes
10006
9960
  }));
10007
9961
  case 7:
10008
- _context21.p = 7;
10009
- _t27 = _context21.v;
10010
- 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"));
10011
9965
  }
10012
- }, _callee21, this, [[0, 7]]);
9966
+ }, _callee20, this, [[0, 7]]);
10013
9967
  }));
10014
- function mintAndRegisterIpAndAttachPilTermsAndDistributeRoyaltyTokens(_x19) {
9968
+ function mintAndRegisterIpAndAttachPilTermsAndDistributeRoyaltyTokens(_x18) {
10015
9969
  return _mintAndRegisterIpAndAttachPilTermsAndDistributeRoyaltyTokens.apply(this, arguments);
10016
9970
  }
10017
9971
  return mintAndRegisterIpAndAttachPilTermsAndDistributeRoyaltyTokens;
@@ -10025,14 +9979,14 @@ var IPAssetClient = /*#__PURE__*/function () {
10025
9979
  }, {
10026
9980
  key: "mintAndRegisterIpAndMakeDerivativeAndDistributeRoyaltyTokens",
10027
9981
  value: (function () {
10028
- var _mintAndRegisterIpAndMakeDerivativeAndDistributeRoyaltyTokens = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee22(request) {
9982
+ var _mintAndRegisterIpAndMakeDerivativeAndDistributeRoyaltyTokens = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee21(request) {
10029
9983
  var _this1 = this;
10030
- var _request$options9, _yield$transformRegis8, _transformRequest7, encodedTxData, contractCall, _t28;
10031
- return _regenerator().w(function (_context22) {
10032
- 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) {
10033
9987
  case 0:
10034
- _context22.p = 0;
10035
- _context22.n = 1;
9988
+ _context21.p = 0;
9989
+ _context21.n = 1;
10036
9990
  return transformRegistrationRequest({
10037
9991
  request: request,
10038
9992
  rpcClient: this.rpcClient,
@@ -10040,13 +9994,13 @@ var IPAssetClient = /*#__PURE__*/function () {
10040
9994
  chainId: this.chainId
10041
9995
  });
10042
9996
  case 1:
10043
- _yield$transformRegis8 = _context22.v;
9997
+ _yield$transformRegis8 = _context21.v;
10044
9998
  _transformRequest7 = _yield$transformRegis8.transformRequest;
10045
9999
  encodedTxData = this.royaltyTokenDistributionWorkflowsClient.mintAndRegisterIpAndMakeDerivativeAndDistributeRoyaltyTokensEncode(_transformRequest7);
10046
10000
  contractCall = function contractCall() {
10047
10001
  return _this1.royaltyTokenDistributionWorkflowsClient.mintAndRegisterIpAndMakeDerivativeAndDistributeRoyaltyTokens(_transformRequest7);
10048
10002
  };
10049
- _context22.n = 2;
10003
+ _context21.n = 2;
10050
10004
  return this.handleRegistrationWithFees({
10051
10005
  spgNftContract: _transformRequest7.spgNftContract,
10052
10006
  wipOptions: (_request$options9 = request.options) === null || _request$options9 === void 0 ? void 0 : _request$options9.wipOptions,
@@ -10058,15 +10012,15 @@ var IPAssetClient = /*#__PURE__*/function () {
10058
10012
  txOptions: request.txOptions
10059
10013
  });
10060
10014
  case 2:
10061
- return _context22.a(2, _context22.v);
10015
+ return _context21.a(2, _context21.v);
10062
10016
  case 3:
10063
- _context22.p = 3;
10064
- _t28 = _context22.v;
10065
- 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"));
10066
10020
  }
10067
- }, _callee22, this, [[0, 3]]);
10021
+ }, _callee21, this, [[0, 3]]);
10068
10022
  }));
10069
- function mintAndRegisterIpAndMakeDerivativeAndDistributeRoyaltyTokens(_x20) {
10023
+ function mintAndRegisterIpAndMakeDerivativeAndDistributeRoyaltyTokens(_x19) {
10070
10024
  return _mintAndRegisterIpAndMakeDerivativeAndDistributeRoyaltyTokens.apply(this, arguments);
10071
10025
  }
10072
10026
  return mintAndRegisterIpAndMakeDerivativeAndDistributeRoyaltyTokens;
@@ -10074,12 +10028,12 @@ var IPAssetClient = /*#__PURE__*/function () {
10074
10028
  }, {
10075
10029
  key: "distributeRoyaltyTokens",
10076
10030
  value: function () {
10077
- var _distributeRoyaltyTokens = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee23(request) {
10031
+ var _distributeRoyaltyTokens = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee22(request) {
10078
10032
  var _yield$transferDistri, transformRequest, txHash;
10079
- return _regenerator().w(function (_context23) {
10080
- while (1) switch (_context23.n) {
10033
+ return _regenerator().w(function (_context22) {
10034
+ while (1) switch (_context22.n) {
10081
10035
  case 0:
10082
- _context23.n = 1;
10036
+ _context22.n = 1;
10083
10037
  return transferDistributeRoyaltyTokensRequest({
10084
10038
  request: request,
10085
10039
  rpcClient: this.rpcClient,
@@ -10087,22 +10041,22 @@ var IPAssetClient = /*#__PURE__*/function () {
10087
10041
  chainId: this.chainId
10088
10042
  });
10089
10043
  case 1:
10090
- _yield$transferDistri = _context23.v;
10044
+ _yield$transferDistri = _context22.v;
10091
10045
  transformRequest = _yield$transferDistri.transformRequest;
10092
- _context23.n = 2;
10046
+ _context22.n = 2;
10093
10047
  return this.royaltyTokenDistributionWorkflowsClient.distributeRoyaltyTokens(transformRequest);
10094
10048
  case 2:
10095
- txHash = _context23.v;
10096
- _context23.n = 3;
10049
+ txHash = _context22.v;
10050
+ _context22.n = 3;
10097
10051
  return this.rpcClient.waitForTransactionReceipt(_objectSpread2(_objectSpread2({}, request.txOptions), {}, {
10098
10052
  hash: txHash
10099
10053
  }));
10100
10054
  case 3:
10101
- return _context23.a(2, txHash);
10055
+ return _context22.a(2, txHash);
10102
10056
  }
10103
- }, _callee23, this);
10057
+ }, _callee22, this);
10104
10058
  }));
10105
- function distributeRoyaltyTokens(_x21) {
10059
+ function distributeRoyaltyTokens(_x20) {
10106
10060
  return _distributeRoyaltyTokens.apply(this, arguments);
10107
10061
  }
10108
10062
  return distributeRoyaltyTokens;
@@ -10110,20 +10064,20 @@ var IPAssetClient = /*#__PURE__*/function () {
10110
10064
  }, {
10111
10065
  key: "isRegistered",
10112
10066
  value: function () {
10113
- var _isRegistered = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee24(ipId) {
10114
- return _regenerator().w(function (_context24) {
10115
- 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) {
10116
10070
  case 0:
10117
- _context24.n = 1;
10071
+ _context23.n = 1;
10118
10072
  return this.ipAssetRegistryClient.isRegistered({
10119
10073
  id: validateAddress(ipId)
10120
10074
  });
10121
10075
  case 1:
10122
- return _context24.a(2, _context24.v);
10076
+ return _context23.a(2, _context23.v);
10123
10077
  }
10124
- }, _callee24, this);
10078
+ }, _callee23, this);
10125
10079
  }));
10126
- function isRegistered(_x22) {
10080
+ function isRegistered(_x21) {
10127
10081
  return _isRegistered.apply(this, arguments);
10128
10082
  }
10129
10083
  return isRegistered;
@@ -10167,24 +10121,24 @@ var IPAssetClient = /*#__PURE__*/function () {
10167
10121
  }, {
10168
10122
  key: "batchRegisterIpAssetsWithOptimizedWorkflows",
10169
10123
  value: (function () {
10170
- var _batchRegisterIpAssetsWithOptimizedWorkflows = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee25(request) {
10171
- 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;
10172
- return _regenerator().w(function (_context25) {
10173
- 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) {
10174
10128
  case 0:
10175
- _context25.p = 0;
10129
+ _context24.p = 0;
10176
10130
  // Transform requests into workflow format
10177
10131
  transferWorkflowRequests = [];
10178
10132
  _iterator6 = _createForOfIteratorHelper(request.requests);
10179
- _context25.p = 1;
10133
+ _context24.p = 1;
10180
10134
  _iterator6.s();
10181
10135
  case 2:
10182
10136
  if ((_step6 = _iterator6.n()).done) {
10183
- _context25.n = 5;
10137
+ _context24.n = 5;
10184
10138
  break;
10185
10139
  }
10186
10140
  req = _step6.value;
10187
- _context25.n = 3;
10141
+ _context24.n = 3;
10188
10142
  return transformRegistrationRequest({
10189
10143
  request: req,
10190
10144
  rpcClient: this.rpcClient,
@@ -10192,22 +10146,22 @@ var IPAssetClient = /*#__PURE__*/function () {
10192
10146
  chainId: this.chainId
10193
10147
  });
10194
10148
  case 3:
10195
- res = _context25.v;
10149
+ res = _context24.v;
10196
10150
  transferWorkflowRequests.push(res);
10197
10151
  case 4:
10198
- _context25.n = 2;
10152
+ _context24.n = 2;
10199
10153
  break;
10200
10154
  case 5:
10201
- _context25.n = 7;
10155
+ _context24.n = 7;
10202
10156
  break;
10203
10157
  case 6:
10204
- _context25.p = 6;
10205
- _t29 = _context25.v;
10206
- _iterator6.e(_t29);
10158
+ _context24.p = 6;
10159
+ _t28 = _context24.v;
10160
+ _iterator6.e(_t28);
10207
10161
  case 7:
10208
- _context25.p = 7;
10162
+ _context24.p = 7;
10209
10163
  _iterator6.f();
10210
- return _context25.f(7);
10164
+ return _context24.f(7);
10211
10165
  case 8:
10212
10166
  /**
10213
10167
  * Extract royalty distribution requests from workflow responses that contain royalty shares
@@ -10225,7 +10179,7 @@ var IPAssetClient = /*#__PURE__*/function () {
10225
10179
  deadline: res.extraData.deadline
10226
10180
  };
10227
10181
  }); // Process initial registration transactions
10228
- _context25.n = 9;
10182
+ _context24.n = 9;
10229
10183
  return handleMulticall({
10230
10184
  transferWorkflowRequests: transferWorkflowRequests,
10231
10185
  multicall3Address: this.multicall3Client.address,
@@ -10236,23 +10190,23 @@ var IPAssetClient = /*#__PURE__*/function () {
10236
10190
  chainId: this.chainId
10237
10191
  });
10238
10192
  case 9:
10239
- _yield$handleMultical = _context25.v;
10193
+ _yield$handleMultical = _context24.v;
10240
10194
  txResponses = _yield$handleMultical.response;
10241
10195
  aggregateRegistrationRequest = _yield$handleMultical.aggregateRegistrationRequest;
10242
10196
  responses = [];
10243
10197
  royaltyTokensDistributionRequests = []; // Process each transaction response
10244
10198
  _iterator7 = _createForOfIteratorHelper(txResponses);
10245
- _context25.p = 10;
10199
+ _context24.p = 10;
10246
10200
  _iterator7.s();
10247
10201
  case 11:
10248
10202
  if ((_step7 = _iterator7.n()).done) {
10249
- _context25.n = 14;
10203
+ _context24.n = 14;
10250
10204
  break;
10251
10205
  }
10252
10206
  _step7$value = _step7.value, txHash = _step7$value.txHash, receipt = _step7$value.receipt;
10253
10207
  iPRegisteredLog = this.ipAssetRegistryClient.parseTxIpRegisteredEvent(receipt);
10254
10208
  ipRoyaltyVaultEvent = this.royaltyModuleEventClient.parseTxIpRoyaltyVaultDeployedEvent(receipt); // Prepare royalty distribution if needed
10255
- _context25.n = 12;
10209
+ _context24.n = 12;
10256
10210
  return prepareRoyaltyTokensDistributionRequests({
10257
10211
  royaltyDistributionRequests: royaltyDistributionRequests,
10258
10212
  ipRegisteredLog: iPRegisteredLog,
@@ -10262,7 +10216,7 @@ var IPAssetClient = /*#__PURE__*/function () {
10262
10216
  chainId: this.chainId
10263
10217
  });
10264
10218
  case 12:
10265
- response = _context25.v;
10219
+ response = _context24.v;
10266
10220
  royaltyTokensDistributionRequests.push.apply(royaltyTokensDistributionRequests, _toConsumableArray(response));
10267
10221
  responses.push({
10268
10222
  txHash: txHash,
@@ -10275,25 +10229,25 @@ var IPAssetClient = /*#__PURE__*/function () {
10275
10229
  })
10276
10230
  });
10277
10231
  case 13:
10278
- _context25.n = 11;
10232
+ _context24.n = 11;
10279
10233
  break;
10280
10234
  case 14:
10281
- _context25.n = 16;
10235
+ _context24.n = 16;
10282
10236
  break;
10283
10237
  case 15:
10284
- _context25.p = 15;
10285
- _t30 = _context25.v;
10286
- _iterator7.e(_t30);
10238
+ _context24.p = 15;
10239
+ _t29 = _context24.v;
10240
+ _iterator7.e(_t29);
10287
10241
  case 16:
10288
- _context25.p = 16;
10242
+ _context24.p = 16;
10289
10243
  _iterator7.f();
10290
- return _context25.f(16);
10244
+ return _context24.f(16);
10291
10245
  case 17:
10292
10246
  if (!(royaltyTokensDistributionRequests.length > 0)) {
10293
- _context25.n = 19;
10247
+ _context24.n = 19;
10294
10248
  break;
10295
10249
  }
10296
- _context25.n = 18;
10250
+ _context24.n = 18;
10297
10251
  return handleMulticall({
10298
10252
  transferWorkflowRequests: royaltyTokensDistributionRequests,
10299
10253
  multicall3Address: this.multicall3Client.address,
@@ -10304,78 +10258,590 @@ var IPAssetClient = /*#__PURE__*/function () {
10304
10258
  chainId: this.chainId
10305
10259
  });
10306
10260
  case 18:
10307
- _yield$handleMultical2 = _context25.v;
10261
+ _yield$handleMultical2 = _context24.v;
10308
10262
  txResponse = _yield$handleMultical2.response;
10309
10263
  distributeRoyaltyTokensTxHashes = txResponse.map(function (tx) {
10310
10264
  return tx.txHash;
10311
10265
  });
10312
10266
  case 19:
10313
- _context25.n = 20;
10267
+ _context24.n = 20;
10314
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);
10315
10269
  case 20:
10316
- registrationResults = _context25.v;
10317
- return _context25.a(2, _objectSpread2({
10270
+ registrationResults = _context24.v;
10271
+ return _context24.a(2, _objectSpread2({
10318
10272
  registrationResults: registrationResults
10319
10273
  }, distributeRoyaltyTokensTxHashes && {
10320
10274
  distributeRoyaltyTokensTxHashes: distributeRoyaltyTokensTxHashes
10321
10275
  }));
10322
10276
  case 21:
10323
- _context25.p = 21;
10324
- _t31 = _context25.v;
10325
- 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"));
10326
10280
  }
10327
- }, _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]]);
10328
10282
  }));
10329
- function batchRegisterIpAssetsWithOptimizedWorkflows(_x23) {
10283
+ function batchRegisterIpAssetsWithOptimizedWorkflows(_x22) {
10330
10284
  return _batchRegisterIpAssetsWithOptimizedWorkflows.apply(this, arguments);
10331
10285
  }
10332
10286
  return batchRegisterIpAssetsWithOptimizedWorkflows;
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
+ )
10350
+ }, {
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) {
10357
+ case 0:
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;
10362
+ break;
10363
+ }
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);
10374
+ case 3:
10375
+ if (!(nft.type === "mint")) {
10376
+ _context25.n = 5;
10377
+ break;
10378
+ }
10379
+ _context25.n = 4;
10380
+ return this.handleMintNftRegistration(request);
10381
+ case 4:
10382
+ return _context25.a(2, _context25.v);
10383
+ case 5:
10384
+ throw new Error("Invalid NFT type");
10385
+ case 6:
10386
+ _context25.n = 8;
10387
+ break;
10388
+ case 7:
10389
+ _context25.p = 7;
10390
+ _t31 = _context25.v;
10391
+ return _context25.a(2, handleError(_t31, "Failed to register IP Asset"));
10392
+ case 8:
10393
+ return _context25.a(2);
10394
+ }
10395
+ }, _callee25, this, [[0, 7]]);
10396
+ }));
10397
+ function registerIpAsset(_x23) {
10398
+ return _registerIpAsset.apply(this, arguments);
10399
+ }
10400
+ return registerIpAsset;
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
+ )
10463
+ }, {
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) {
10470
+ case 0:
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;
10475
+ break;
10476
+ }
10477
+ throw new Error("derivData must be provided when royaltyShares are provided.");
10478
+ case 1:
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;
10484
+ break;
10485
+ }
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);
10496
+ case 4:
10497
+ if (!(nft.type === "mint")) {
10498
+ _context26.n = 6;
10499
+ break;
10500
+ }
10501
+ _context26.n = 5;
10502
+ return this.handleMintNftDerivativeRegistration(request);
10503
+ case 5:
10504
+ return _context26.a(2, _context26.v);
10505
+ case 6:
10506
+ throw new Error("Invalid NFT type.");
10507
+ case 7:
10508
+ _context26.n = 9;
10509
+ break;
10510
+ case 8:
10511
+ _context26.p = 8;
10512
+ _t32 = _context26.v;
10513
+ return _context26.a(2, handleError(_t32, "Failed to register derivative IP Asset"));
10514
+ case 9:
10515
+ return _context26.a(2);
10516
+ }
10517
+ }, _callee26, this, [[0, 8]]);
10518
+ }));
10519
+ function registerDerivativeIpAsset(_x24) {
10520
+ return _registerDerivativeIpAsset.apply(this, arguments);
10521
+ }
10522
+ return registerDerivativeIpAsset;
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
+ )
10533
+ }, {
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) {
10540
+ case 0:
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;
10552
+ break;
10553
+ }
10554
+ return _context27.a(2, this.registerDerivativeIpAndAttachLicenseTermsAndDistributeRoyaltyTokens(_objectSpread2(_objectSpread2({}, baseParams), {}, {
10555
+ royaltyShares: royaltyShares,
10556
+ derivData: derivData
10557
+ })));
10558
+ case 1:
10559
+ if (!derivData) {
10560
+ _context27.n = 2;
10561
+ break;
10562
+ }
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
+ })));
10571
+ }
10572
+ }, _callee27, this);
10573
+ }));
10574
+ function handleMintedNftDerivativeRegistration(_x25) {
10575
+ return _handleMintedNftDerivativeRegistration.apply(this, arguments);
10576
+ }
10577
+ return handleMintedNftDerivativeRegistration;
10578
+ }()
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) {
10595
+ case 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
+ })));
10613
+ case 1:
10614
+ if (!derivData) {
10615
+ _context28.n = 2;
10616
+ break;
10617
+ }
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;
10675
+ break;
10676
+ }
10677
+ return _context29.a(2, this.registerDerivative(request));
10678
+ case 1:
10679
+ return _context29.a(2, this.registerDerivativeWithLicenseTokens(request));
10680
+ case 2:
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;
10333
10799
  }())
10334
10800
  }, {
10335
10801
  key: "getLicenseTermsId",
10336
10802
  value: function () {
10337
- var _getLicenseTermsId = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee26(licenseTerms) {
10338
- var licenseTermsIds, _iterator8, _step8, licenseTerm, licenseRes, _t32;
10339
- return _regenerator().w(function (_context26) {
10340
- while (1) switch (_context26.p = _context26.n) {
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) {
10341
10807
  case 0:
10342
10808
  licenseTermsIds = [];
10343
10809
  _iterator8 = _createForOfIteratorHelper(licenseTerms);
10344
- _context26.p = 1;
10810
+ _context32.p = 1;
10345
10811
  _iterator8.s();
10346
10812
  case 2:
10347
10813
  if ((_step8 = _iterator8.n()).done) {
10348
- _context26.n = 5;
10814
+ _context32.n = 5;
10349
10815
  break;
10350
10816
  }
10351
10817
  licenseTerm = _step8.value;
10352
- _context26.n = 3;
10818
+ _context32.n = 3;
10353
10819
  return this.licenseTemplateClient.getLicenseTermsId({
10354
10820
  terms: licenseTerm
10355
10821
  });
10356
10822
  case 3:
10357
- licenseRes = _context26.v;
10823
+ licenseRes = _context32.v;
10358
10824
  licenseTermsIds.push(licenseRes.selectedLicenseTermsId);
10359
10825
  case 4:
10360
- _context26.n = 2;
10826
+ _context32.n = 2;
10361
10827
  break;
10362
10828
  case 5:
10363
- _context26.n = 7;
10829
+ _context32.n = 7;
10364
10830
  break;
10365
10831
  case 6:
10366
- _context26.p = 6;
10367
- _t32 = _context26.v;
10368
- _iterator8.e(_t32);
10832
+ _context32.p = 6;
10833
+ _t34 = _context32.v;
10834
+ _iterator8.e(_t34);
10369
10835
  case 7:
10370
- _context26.p = 7;
10836
+ _context32.p = 7;
10371
10837
  _iterator8.f();
10372
- return _context26.f(7);
10838
+ return _context32.f(7);
10373
10839
  case 8:
10374
- return _context26.a(2, licenseTermsIds);
10840
+ return _context32.a(2, licenseTermsIds);
10375
10841
  }
10376
- }, _callee26, this, [[1, 6, 7, 8]]);
10842
+ }, _callee32, this, [[1, 6, 7, 8]]);
10377
10843
  }));
10378
- function getLicenseTermsId(_x24) {
10844
+ function getLicenseTermsId(_x30) {
10379
10845
  return _getLicenseTermsId.apply(this, arguments);
10380
10846
  }
10381
10847
  return getLicenseTermsId;
@@ -10383,13 +10849,13 @@ var IPAssetClient = /*#__PURE__*/function () {
10383
10849
  }, {
10384
10850
  key: "validateLicenseTokenIds",
10385
10851
  value: function () {
10386
- var _validateLicenseTokenIds = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee27(licenseTokenIds) {
10387
- var newLicenseTokenIds, _iterator9, _step9, licenseTokenId, tokenOwnerAddress, _t33;
10388
- return _regenerator().w(function (_context27) {
10389
- while (1) switch (_context27.p = _context27.n) {
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) {
10390
10856
  case 0:
10391
10857
  if (!(licenseTokenIds.length === 0)) {
10392
- _context27.n = 1;
10858
+ _context33.n = 1;
10393
10859
  break;
10394
10860
  }
10395
10861
  throw new Error("License token IDs must be provided.");
@@ -10398,45 +10864,45 @@ var IPAssetClient = /*#__PURE__*/function () {
10398
10864
  return BigInt(id);
10399
10865
  });
10400
10866
  _iterator9 = _createForOfIteratorHelper(newLicenseTokenIds);
10401
- _context27.p = 2;
10867
+ _context33.p = 2;
10402
10868
  _iterator9.s();
10403
10869
  case 3:
10404
10870
  if ((_step9 = _iterator9.n()).done) {
10405
- _context27.n = 6;
10871
+ _context33.n = 6;
10406
10872
  break;
10407
10873
  }
10408
10874
  licenseTokenId = _step9.value;
10409
- _context27.n = 4;
10875
+ _context33.n = 4;
10410
10876
  return this.licenseTokenReadOnlyClient.ownerOf({
10411
10877
  tokenId: licenseTokenId
10412
10878
  });
10413
10879
  case 4:
10414
- tokenOwnerAddress = _context27.v;
10880
+ tokenOwnerAddress = _context33.v;
10415
10881
  if (tokenOwnerAddress) {
10416
- _context27.n = 5;
10882
+ _context33.n = 5;
10417
10883
  break;
10418
10884
  }
10419
10885
  throw new Error("License token id ".concat(licenseTokenId, " must be owned by the caller."));
10420
10886
  case 5:
10421
- _context27.n = 3;
10887
+ _context33.n = 3;
10422
10888
  break;
10423
10889
  case 6:
10424
- _context27.n = 8;
10890
+ _context33.n = 8;
10425
10891
  break;
10426
10892
  case 7:
10427
- _context27.p = 7;
10428
- _t33 = _context27.v;
10429
- _iterator9.e(_t33);
10893
+ _context33.p = 7;
10894
+ _t35 = _context33.v;
10895
+ _iterator9.e(_t35);
10430
10896
  case 8:
10431
- _context27.p = 8;
10897
+ _context33.p = 8;
10432
10898
  _iterator9.f();
10433
- return _context27.f(8);
10899
+ return _context33.f(8);
10434
10900
  case 9:
10435
- return _context27.a(2, newLicenseTokenIds);
10901
+ return _context33.a(2, newLicenseTokenIds);
10436
10902
  }
10437
- }, _callee27, this, [[2, 7, 8, 9]]);
10903
+ }, _callee33, this, [[2, 7, 8, 9]]);
10438
10904
  }));
10439
- function validateLicenseTokenIds(_x25) {
10905
+ function validateLicenseTokenIds(_x31) {
10440
10906
  return _validateLicenseTokenIds.apply(this, arguments);
10441
10907
  }
10442
10908
  return validateLicenseTokenIds;
@@ -10459,28 +10925,28 @@ var IPAssetClient = /*#__PURE__*/function () {
10459
10925
  }, {
10460
10926
  key: "handleRegistrationWithFees",
10461
10927
  value: function () {
10462
- var _handleRegistrationWithFees = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee28(_ref5) {
10928
+ var _handleRegistrationWithFees = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee34(_ref5) {
10463
10929
  var _wipOptions$useMultic, _this$getIpIdAndToken, _event$ipId, _event$tokenId;
10464
10930
  var sender, derivData, spgNftContract, spgSpenderAddress, txOptions, wipOptions, encodedTxs, contractCall, totalFees, wipSpenders, useMulticallWhenPossible, nftMintFee, publicMinting, totalDerivativeMintingFee, _yield$contractCallWi, txHash, receipt, event;
10465
- return _regenerator().w(function (_context28) {
10466
- while (1) switch (_context28.n) {
10931
+ return _regenerator().w(function (_context34) {
10932
+ while (1) switch (_context34.n) {
10467
10933
  case 0:
10468
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;
10469
10935
  totalFees = 0n;
10470
10936
  wipSpenders = [];
10471
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
10472
10938
  if (!spgNftContract) {
10473
- _context28.n = 3;
10939
+ _context34.n = 3;
10474
10940
  break;
10475
10941
  }
10476
- _context28.n = 1;
10942
+ _context34.n = 1;
10477
10943
  return calculateSPGWipMintFee(new SpgnftImplReadOnlyClient(this.rpcClient, spgNftContract));
10478
10944
  case 1:
10479
- nftMintFee = _context28.v;
10480
- _context28.n = 2;
10945
+ nftMintFee = _context34.v;
10946
+ _context34.n = 2;
10481
10947
  return getPublicMinting(spgNftContract, this.rpcClient);
10482
10948
  case 2:
10483
- publicMinting = _context28.v;
10949
+ publicMinting = _context34.v;
10484
10950
  /**
10485
10951
  * If the SPG NFT contract's public minting is disabled, we need to check if the caller has the `minter role`.
10486
10952
  * When public minting is disabled, we can't use multicall because we need to perform additional role checks
@@ -10499,10 +10965,10 @@ var IPAssetClient = /*#__PURE__*/function () {
10499
10965
  });
10500
10966
  case 3:
10501
10967
  if (!derivData) {
10502
- _context28.n = 5;
10968
+ _context34.n = 5;
10503
10969
  break;
10504
10970
  }
10505
- _context28.n = 4;
10971
+ _context34.n = 4;
10506
10972
  return calculateDerivativeMintingFee({
10507
10973
  derivData: derivData,
10508
10974
  rpcClient: this.rpcClient,
@@ -10511,7 +10977,7 @@ var IPAssetClient = /*#__PURE__*/function () {
10511
10977
  sender: sender
10512
10978
  });
10513
10979
  case 4:
10514
- totalDerivativeMintingFee = _context28.v;
10980
+ totalDerivativeMintingFee = _context34.v;
10515
10981
  totalFees += totalDerivativeMintingFee;
10516
10982
  if (totalDerivativeMintingFee > 0) {
10517
10983
  wipSpenders.push({
@@ -10521,12 +10987,12 @@ var IPAssetClient = /*#__PURE__*/function () {
10521
10987
  }
10522
10988
  case 5:
10523
10989
  if (!(totalFees < 0)) {
10524
- _context28.n = 6;
10990
+ _context34.n = 6;
10525
10991
  break;
10526
10992
  }
10527
10993
  throw new Error("Total fees for registering derivative should never be negative: ".concat(totalFees));
10528
10994
  case 6:
10529
- _context28.n = 7;
10995
+ _context34.n = 7;
10530
10996
  return contractCallWithFees({
10531
10997
  totalFees: totalFees,
10532
10998
  options: {
@@ -10544,11 +11010,11 @@ var IPAssetClient = /*#__PURE__*/function () {
10544
11010
  encodedTxs: encodedTxs
10545
11011
  });
10546
11012
  case 7:
10547
- _yield$contractCallWi = _context28.v;
11013
+ _yield$contractCallWi = _context34.v;
10548
11014
  txHash = _yield$contractCallWi.txHash;
10549
11015
  receipt = _yield$contractCallWi.receipt;
10550
11016
  event = (_this$getIpIdAndToken = this.getIpIdAndTokenIdsFromEvent(receipt)) === null || _this$getIpIdAndToken === void 0 ? void 0 : _this$getIpIdAndToken[0];
10551
- return _context28.a(2, _objectSpread2({
11017
+ return _context34.a(2, _objectSpread2({
10552
11018
  txHash: txHash,
10553
11019
  receipt: receipt
10554
11020
  }, event && {
@@ -10556,133 +11022,82 @@ var IPAssetClient = /*#__PURE__*/function () {
10556
11022
  tokenId: (_event$tokenId = event.tokenId) !== null && _event$tokenId !== void 0 ? _event$tokenId : undefined
10557
11023
  }));
10558
11024
  }
10559
- }, _callee28, this);
11025
+ }, _callee34, this);
10560
11026
  }));
10561
- function handleRegistrationWithFees(_x26) {
11027
+ function handleRegistrationWithFees(_x32) {
10562
11028
  return _handleRegistrationWithFees.apply(this, arguments);
10563
11029
  }
10564
11030
  return handleRegistrationWithFees;
10565
11031
  }()
11032
+ /**
11033
+ * Process the `LicenseTermsIds` and `maxLicenseTokensTxHashes` for each IP asset.
11034
+ */
10566
11035
  }, {
10567
- key: "setMaxLicenseTokens",
10568
- value: function () {
10569
- var _setMaxLicenseTokens = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee29(_ref6) {
10570
- var maxLicenseTokensData, licensorIpId, licenseTermsIds, licenseTermsMaxLimitTxHashes, i, maxLicenseTokens, txHash;
10571
- return _regenerator().w(function (_context29) {
10572
- while (1) switch (_context29.n) {
11036
+ key: "processResponses",
11037
+ value: (function () {
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) {
10573
11042
  case 0:
10574
- maxLicenseTokensData = _ref6.maxLicenseTokensData, licensorIpId = _ref6.licensorIpId, licenseTermsIds = _ref6.licenseTermsIds;
10575
- licenseTermsMaxLimitTxHashes = [];
10576
- i = 0;
10577
- case 1:
10578
- if (!(i < maxLicenseTokensData.length)) {
10579
- _context29.n = 5;
10580
- break;
10581
- }
10582
- maxLicenseTokens = maxLicenseTokensData[i].maxLicenseTokens;
10583
- if (!(maxLicenseTokens === undefined || maxLicenseTokens < 0n)) {
10584
- _context29.n = 2;
10585
- break;
10586
- }
10587
- return _context29.a(3, 4);
10588
- case 2:
10589
- _context29.n = 3;
10590
- return this.totalLicenseTokenLimitHookClient.setTotalLicenseTokenLimit({
10591
- licensorIpId: licensorIpId,
10592
- // The contract now directly writes the `licenseTemplate` address internally,
10593
- // so we no longer need to pass it as a parameter
10594
- licenseTemplate: this.licenseTemplateClient.address,
10595
- licenseTermsId: licenseTermsIds[i],
10596
- limit: BigInt(maxLicenseTokens)
10597
- });
10598
- case 3:
10599
- txHash = _context29.v;
10600
- if (txHash) {
10601
- licenseTermsMaxLimitTxHashes.push(txHash);
10602
- }
10603
- case 4:
10604
- i++;
10605
- _context29.n = 1;
10606
- break;
10607
- case 5:
10608
- return _context29.a(2, licenseTermsMaxLimitTxHashes);
10609
- }
10610
- }, _callee29, this);
10611
- }));
10612
- function setMaxLicenseTokens(_x27) {
10613
- return _setMaxLicenseTokens.apply(this, arguments);
10614
- }
10615
- return setMaxLicenseTokens;
10616
- }()
10617
- /**
10618
- * Process the `LicenseTermsIds` and `maxLicenseTokensTxHashes` for each IP asset.
10619
- */
10620
- }, {
10621
- key: "processResponses",
10622
- value: (function () {
10623
- var _processResponses = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee30(responses, aggregateRegistrationRequest, useMulticall) {
10624
- 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;
10625
- return _regenerator().w(function (_context30) {
10626
- while (1) switch (_context30.p = _context30.n) {
10627
- case 0:
10628
- if (!useMulticall) {
10629
- _context30.n = 15;
11043
+ if (!useMulticall) {
11044
+ _context35.n = 15;
10630
11045
  break;
10631
11046
  }
10632
11047
  _iterator0 = _createForOfIteratorHelper(responses.entries());
10633
- _context30.p = 1;
11048
+ _context35.p = 1;
10634
11049
  _iterator0.s();
10635
11050
  case 2:
10636
11051
  if ((_step0 = _iterator0.n()).done) {
10637
- _context30.n = 11;
11052
+ _context35.n = 11;
10638
11053
  break;
10639
11054
  }
10640
11055
  _step0$value = _slicedToArray(_step0.value, 2), responseIndex = _step0$value[0], response = _step0$value[1];
10641
11056
  _iterator1 = _createForOfIteratorHelper(response.ipAssetsWithLicenseTerms.entries());
10642
- _context30.p = 3;
11057
+ _context35.p = 3;
10643
11058
  _iterator1.s();
10644
11059
  case 4:
10645
11060
  if ((_step1 = _iterator1.n()).done) {
10646
- _context30.n = 7;
11061
+ _context35.n = 7;
10647
11062
  break;
10648
11063
  }
10649
11064
  _step1$value = _slicedToArray(_step1.value, 2), assetIndex = _step1$value[0], ipAsset = _step1$value[1];
10650
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];
10651
- _context30.n = 5;
11066
+ _context35.n = 5;
10652
11067
  return this.processIpAssetLicenseTerms(ipAsset, extraData);
10653
11068
  case 5:
10654
- result = _context30.v;
11069
+ result = _context35.v;
10655
11070
  responses[responseIndex].ipAssetsWithLicenseTerms[assetIndex] = result;
10656
11071
  case 6:
10657
- _context30.n = 4;
11072
+ _context35.n = 4;
10658
11073
  break;
10659
11074
  case 7:
10660
- _context30.n = 9;
11075
+ _context35.n = 9;
10661
11076
  break;
10662
11077
  case 8:
10663
- _context30.p = 8;
10664
- _t34 = _context30.v;
10665
- _iterator1.e(_t34);
11078
+ _context35.p = 8;
11079
+ _t36 = _context35.v;
11080
+ _iterator1.e(_t36);
10666
11081
  case 9:
10667
- _context30.p = 9;
11082
+ _context35.p = 9;
10668
11083
  _iterator1.f();
10669
- return _context30.f(9);
11084
+ return _context35.f(9);
10670
11085
  case 10:
10671
- _context30.n = 2;
11086
+ _context35.n = 2;
10672
11087
  break;
10673
11088
  case 11:
10674
- _context30.n = 13;
11089
+ _context35.n = 13;
10675
11090
  break;
10676
11091
  case 12:
10677
- _context30.p = 12;
10678
- _t35 = _context30.v;
10679
- _iterator0.e(_t35);
11092
+ _context35.p = 12;
11093
+ _t37 = _context35.v;
11094
+ _iterator0.e(_t37);
10680
11095
  case 13:
10681
- _context30.p = 13;
11096
+ _context35.p = 13;
10682
11097
  _iterator0.f();
10683
- return _context30.f(13);
11098
+ return _context35.f(13);
10684
11099
  case 14:
10685
- _context30.n = 19;
11100
+ _context35.n = 19;
10686
11101
  break;
10687
11102
  case 15:
10688
11103
  _extraData = [];
@@ -10693,26 +11108,26 @@ var IPAssetClient = /*#__PURE__*/function () {
10693
11108
  i = 0;
10694
11109
  case 16:
10695
11110
  if (!(i < responses.length)) {
10696
- _context30.n = 19;
11111
+ _context35.n = 19;
10697
11112
  break;
10698
11113
  }
10699
11114
  _response = responses[i];
10700
11115
  extraDataItem = _extraData[i];
10701
- _context30.n = 17;
11116
+ _context35.n = 17;
10702
11117
  return this.processIpAssetLicenseTerms(_response.ipAssetsWithLicenseTerms[0], extraDataItem);
10703
11118
  case 17:
10704
- _ipAsset = _context30.v;
11119
+ _ipAsset = _context35.v;
10705
11120
  responses[i].ipAssetsWithLicenseTerms[0] = _ipAsset;
10706
11121
  case 18:
10707
11122
  i++;
10708
- _context30.n = 16;
11123
+ _context35.n = 16;
10709
11124
  break;
10710
11125
  case 19:
10711
- return _context30.a(2, responses);
11126
+ return _context35.a(2, responses);
10712
11127
  }
10713
- }, _callee30, this, [[3, 8, 9, 10], [1, 12, 13, 14]]);
11128
+ }, _callee35, this, [[3, 8, 9, 10], [1, 12, 13, 14]]);
10714
11129
  }));
10715
- function processResponses(_x28, _x29, _x30) {
11130
+ function processResponses(_x33, _x34, _x35) {
10716
11131
  return _processResponses.apply(this, arguments);
10717
11132
  }
10718
11133
  return processResponses;
@@ -10720,31 +11135,31 @@ var IPAssetClient = /*#__PURE__*/function () {
10720
11135
  }, {
10721
11136
  key: "processIpAssetLicenseTerms",
10722
11137
  value: function () {
10723
- var _processIpAssetLicenseTerms = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee31(ipAsset, extraData) {
11138
+ var _processIpAssetLicenseTerms = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee36(ipAsset, extraData) {
10724
11139
  var _extraData$licenseTer;
10725
11140
  var licenseTermsIds, maxLicenseTokens, maxLicenseTokensData, maxLicenseTokensTxHashes;
10726
- return _regenerator().w(function (_context31) {
10727
- while (1) switch (_context31.n) {
11141
+ return _regenerator().w(function (_context36) {
11142
+ while (1) switch (_context36.n) {
10728
11143
  case 0:
10729
11144
  if (extraData !== null && extraData !== void 0 && (_extraData$licenseTer = extraData.licenseTermsData) !== null && _extraData$licenseTer !== void 0 && _extraData$licenseTer.length) {
10730
- _context31.n = 1;
11145
+ _context36.n = 1;
10731
11146
  break;
10732
11147
  }
10733
- return _context31.a(2, ipAsset);
11148
+ return _context36.a(2, ipAsset);
10734
11149
  case 1:
10735
- _context31.n = 2;
11150
+ _context36.n = 2;
10736
11151
  return this.getLicenseTermsId(extraData.licenseTermsData.map(function (item) {
10737
11152
  return item.terms;
10738
11153
  }));
10739
11154
  case 2:
10740
- licenseTermsIds = _context31.v;
11155
+ licenseTermsIds = _context36.v;
10741
11156
  ipAsset.licenseTermsIds = licenseTermsIds;
10742
11157
  maxLicenseTokens = extraData.maxLicenseTokens;
10743
11158
  if (maxLicenseTokens !== null && maxLicenseTokens !== void 0 && maxLicenseTokens.length) {
10744
- _context31.n = 3;
11159
+ _context36.n = 3;
10745
11160
  break;
10746
11161
  }
10747
- return _context31.a(2, ipAsset);
11162
+ return _context36.a(2, ipAsset);
10748
11163
  case 3:
10749
11164
  maxLicenseTokensData = maxLicenseTokens.filter(function (maxLicenseToken) {
10750
11165
  return maxLicenseToken !== undefined;
@@ -10753,22 +11168,24 @@ var IPAssetClient = /*#__PURE__*/function () {
10753
11168
  maxLicenseTokens: maxLicenseToken
10754
11169
  };
10755
11170
  });
10756
- _context31.n = 4;
10757
- return this.setMaxLicenseTokens({
11171
+ _context36.n = 4;
11172
+ return setMaxLicenseTokens({
10758
11173
  maxLicenseTokensData: maxLicenseTokensData,
10759
11174
  licensorIpId: ipAsset.ipId,
10760
- licenseTermsIds: licenseTermsIds
11175
+ licenseTermsIds: licenseTermsIds,
11176
+ totalLicenseTokenLimitHookClient: this.totalLicenseTokenLimitHookClient,
11177
+ templateAddress: this.licenseTemplateAddress
10761
11178
  });
10762
11179
  case 4:
10763
- maxLicenseTokensTxHashes = _context31.v;
11180
+ maxLicenseTokensTxHashes = _context36.v;
10764
11181
  if (maxLicenseTokensTxHashes !== null && maxLicenseTokensTxHashes !== void 0 && maxLicenseTokensTxHashes.length) {
10765
11182
  ipAsset.maxLicenseTokensTxHashes = maxLicenseTokensTxHashes;
10766
11183
  }
10767
- return _context31.a(2, ipAsset);
11184
+ return _context36.a(2, ipAsset);
10768
11185
  }
10769
- }, _callee31, this);
11186
+ }, _callee36, this);
10770
11187
  }));
10771
- function processIpAssetLicenseTerms(_x31, _x32) {
11188
+ function processIpAssetLicenseTerms(_x36, _x37) {
10772
11189
  return _processIpAssetLicenseTerms.apply(this, arguments);
10773
11190
  }
10774
11191
  return processIpAssetLicenseTerms;
@@ -10788,6 +11205,7 @@ var LicenseClient = /*#__PURE__*/function () {
10788
11205
  this.multicall3Client = new Multicall3Client(rpcClient, wallet);
10789
11206
  this.wipClient = new WrappedIpClient(rpcClient, wallet);
10790
11207
  this.totalLicenseTokenLimitHookClient = new TotalLicenseTokenLimitHookClient(rpcClient, wallet);
11208
+ this.licenseAttachmentWorkflowsClient = new LicenseAttachmentWorkflowsClient(rpcClient, wallet);
10791
11209
  this.rpcClient = rpcClient;
10792
11210
  this.wallet = wallet;
10793
11211
  this.chainId = chainId;
@@ -10826,218 +11244,56 @@ var LicenseClient = /*#__PURE__*/function () {
10826
11244
  return registerPILTerms;
10827
11245
  }()
10828
11246
  /**
10829
- * @deprecated Use {@link PILFlavor.nonCommercialSocialRemixing} with {@link LicenseClient.registerPILTerms} instead.
10830
- * The method will be removed in the `v1.4.0`.
10831
- *
10832
- * Convenient function to register a PIL non commercial social remix license to the registry
10833
- *
10834
- * 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}.
10835
- *
10836
- * 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.
11247
+ * Attaches license terms to an IP.
10837
11248
  */
10838
11249
  )
10839
11250
  }, {
10840
- key: "registerNonComSocialRemixingPIL",
11251
+ key: "attachLicenseTerms",
10841
11252
  value: (function () {
10842
- var _registerNonComSocialRemixingPIL = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(request) {
10843
- var licenseTerms, _t2;
11253
+ var _attachLicenseTerms = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(request) {
11254
+ var _request$txOptions, isRegistered, isExisted, isAttachedLicenseTerms, req, txHash, _t2;
10844
11255
  return _regenerator().w(function (_context2) {
10845
11256
  while (1) switch (_context2.p = _context2.n) {
10846
11257
  case 0:
10847
11258
  _context2.p = 0;
10848
- licenseTerms = PILFlavor.nonCommercialSocialRemixing();
10849
- _context2.n = 1;
10850
- return this.registerPILTermsHelper(licenseTerms, request === null || request === void 0 ? void 0 : request.txOptions);
10851
- case 1:
10852
- return _context2.a(2, _context2.v);
10853
- case 2:
10854
- _context2.p = 2;
10855
- _t2 = _context2.v;
10856
- return _context2.a(2, handleError(_t2, "Failed to register non commercial social remixing PIL"));
10857
- }
10858
- }, _callee2, this, [[0, 2]]);
10859
- }));
10860
- function registerNonComSocialRemixingPIL(_x2) {
10861
- return _registerNonComSocialRemixingPIL.apply(this, arguments);
10862
- }
10863
- return registerNonComSocialRemixingPIL;
10864
- }()
10865
- /**
10866
- * @deprecated Use {@link PILFlavor.commercialUse} with {@link LicenseClient.registerPILTerms} instead.
10867
- * The method will be removed in the `v1.4.0`.
10868
- *
10869
- * Convenient function to register a PIL commercial use license to the registry.
10870
- *
10871
- * For more details, see {@link https://docs.story.foundation/concepts/programmable-ip-license/pil-flavors#flavor-%232%3A-commercial-use | Commercial Use}.
10872
- *
10873
- * 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.
10874
- */
10875
- )
10876
- }, {
10877
- key: "registerCommercialUsePIL",
10878
- value: (function () {
10879
- var _registerCommercialUsePIL = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(request) {
10880
- var licenseTerms, _t3;
10881
- return _regenerator().w(function (_context3) {
10882
- while (1) switch (_context3.p = _context3.n) {
10883
- case 0:
10884
- _context3.p = 0;
10885
- licenseTerms = PILFlavor.commercialUse({
10886
- defaultMintingFee: Number(request.defaultMintingFee),
10887
- currency: request.currency,
10888
- royaltyPolicy: request.royaltyPolicyAddress
10889
- });
10890
- _context3.n = 1;
10891
- return this.registerPILTermsHelper(licenseTerms, request.txOptions);
10892
- case 1:
10893
- return _context3.a(2, _context3.v);
10894
- case 2:
10895
- _context3.p = 2;
10896
- _t3 = _context3.v;
10897
- return _context3.a(2, handleError(_t3, "Failed to register commercial use PIL"));
10898
- }
10899
- }, _callee3, this, [[0, 2]]);
10900
- }));
10901
- function registerCommercialUsePIL(_x3) {
10902
- return _registerCommercialUsePIL.apply(this, arguments);
10903
- }
10904
- return registerCommercialUsePIL;
10905
- }()
10906
- /**
10907
- * @deprecated Use {@link PILFlavor.commercialRemix} with {@link LicenseClient.registerPILTerms} instead.
10908
- * The method will be removed in the v1.4.0.
10909
- *
10910
- * Convenient function to register a PIL commercial Remix license to the registry.
10911
- *
10912
- * For more details, see {@link https://docs.story.foundation/concepts/programmable-ip-license/pil-flavors#flavor-%233%3A-commercial-remix | Commercial Remix }.
10913
- *
10914
- * 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.
10915
- */
10916
- )
10917
- }, {
10918
- key: "registerCommercialRemixPIL",
10919
- value: (function () {
10920
- var _registerCommercialRemixPIL = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(_ref) {
10921
- var defaultMintingFee, currency, royaltyPolicyAddress, commercialRevShare, txOptions, licenseTerms, _t4;
10922
- return _regenerator().w(function (_context4) {
10923
- while (1) switch (_context4.p = _context4.n) {
10924
- case 0:
10925
- defaultMintingFee = _ref.defaultMintingFee, currency = _ref.currency, royaltyPolicyAddress = _ref.royaltyPolicyAddress, commercialRevShare = _ref.commercialRevShare, txOptions = _ref.txOptions;
10926
- _context4.p = 1;
10927
- licenseTerms = PILFlavor.commercialRemix({
10928
- defaultMintingFee: Number(defaultMintingFee),
10929
- currency: currency,
10930
- royaltyPolicy: royaltyPolicyAddress,
10931
- commercialRevShare: commercialRevShare
10932
- });
10933
- _context4.n = 2;
10934
- return this.registerPILTermsHelper(licenseTerms, txOptions);
10935
- case 2:
10936
- return _context4.a(2, _context4.v);
10937
- case 3:
10938
- _context4.p = 3;
10939
- _t4 = _context4.v;
10940
- return _context4.a(2, handleError(_t4, "Failed to register commercial remix PIL"));
10941
- }
10942
- }, _callee4, this, [[1, 3]]);
10943
- }));
10944
- function registerCommercialRemixPIL(_x4) {
10945
- return _registerCommercialRemixPIL.apply(this, arguments);
10946
- }
10947
- return registerCommercialRemixPIL;
10948
- }()
10949
- /**
10950
- * @deprecated Use {@link PILFlavor.creativeCommonsAttribution} with {@link LicenseClient.registerPILTerms} instead.
10951
- * The method will be removed in the `v1.4.0`.
10952
- *
10953
- * Convenient function to register a PIL creative commons attribution license to the registry.
10954
- * Creates a Creative Commons Attribution (CC-BY) license terms flavor.
10955
- *
10956
- * For more details, see {@link https://docs.story.foundation/concepts/programmable-ip-license/pil-flavors#flavor-%234%3A-creative-commons-attribution | Creative Commons Attribution}.
10957
- *
10958
- * 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.
10959
- */
10960
- )
10961
- }, {
10962
- key: "registerCreativeCommonsAttributionPIL",
10963
- value: (function () {
10964
- var _registerCreativeCommonsAttributionPIL = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(_ref2) {
10965
- var currency, royaltyPolicyAddress, txOptions, _t5;
10966
- return _regenerator().w(function (_context5) {
10967
- while (1) switch (_context5.p = _context5.n) {
10968
- case 0:
10969
- currency = _ref2.currency, royaltyPolicyAddress = _ref2.royaltyPolicyAddress, txOptions = _ref2.txOptions;
10970
- _context5.p = 1;
10971
- _context5.n = 2;
10972
- return this.registerPILTermsHelper(PILFlavor.creativeCommonsAttribution({
10973
- currency: currency,
10974
- royaltyPolicy: royaltyPolicyAddress
10975
- }), txOptions);
10976
- case 2:
10977
- return _context5.a(2, _context5.v);
10978
- case 3:
10979
- _context5.p = 3;
10980
- _t5 = _context5.v;
10981
- return _context5.a(2, handleError(_t5, "Failed to register creative commons attribution PIL"));
10982
- }
10983
- }, _callee5, this, [[1, 3]]);
10984
- }));
10985
- function registerCreativeCommonsAttributionPIL(_x5) {
10986
- return _registerCreativeCommonsAttributionPIL.apply(this, arguments);
10987
- }
10988
- return registerCreativeCommonsAttributionPIL;
10989
- }()
10990
- /**
10991
- * Attaches license terms to an IP.
10992
- */
10993
- )
10994
- }, {
10995
- key: "attachLicenseTerms",
10996
- value: (function () {
10997
- var _attachLicenseTerms = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(request) {
10998
- var _request$txOptions, isRegistered, isExisted, isAttachedLicenseTerms, req, txHash, _t6;
10999
- return _regenerator().w(function (_context6) {
11000
- while (1) switch (_context6.p = _context6.n) {
11001
- case 0:
11002
- _context6.p = 0;
11003
11259
  request.licenseTermsId = BigInt(request.licenseTermsId);
11004
- _context6.n = 1;
11260
+ _context2.n = 1;
11005
11261
  return this.ipAssetRegistryClient.isRegistered({
11006
11262
  id: validateAddress(request.ipId)
11007
11263
  });
11008
11264
  case 1:
11009
- isRegistered = _context6.v;
11265
+ isRegistered = _context2.v;
11010
11266
  if (isRegistered) {
11011
- _context6.n = 2;
11267
+ _context2.n = 2;
11012
11268
  break;
11013
11269
  }
11014
11270
  throw new Error("The IP with id ".concat(request.ipId, " is not registered."));
11015
11271
  case 2:
11016
- _context6.n = 3;
11272
+ _context2.n = 3;
11017
11273
  return this.piLicenseTemplateReadOnlyClient.exists({
11018
11274
  licenseTermsId: request.licenseTermsId
11019
11275
  });
11020
11276
  case 3:
11021
- isExisted = _context6.v;
11277
+ isExisted = _context2.v;
11022
11278
  if (isExisted) {
11023
- _context6.n = 4;
11279
+ _context2.n = 4;
11024
11280
  break;
11025
11281
  }
11026
11282
  throw new Error("License terms id ".concat(request.licenseTermsId, " do not exist."));
11027
11283
  case 4:
11028
- _context6.n = 5;
11284
+ _context2.n = 5;
11029
11285
  return this.licenseRegistryReadOnlyClient.hasIpAttachedLicenseTerms({
11030
11286
  ipId: request.ipId,
11031
11287
  licenseTemplate: validateAddress(request.licenseTemplate || this.licenseTemplateClient.address),
11032
11288
  licenseTermsId: request.licenseTermsId
11033
11289
  });
11034
11290
  case 5:
11035
- isAttachedLicenseTerms = _context6.v;
11291
+ isAttachedLicenseTerms = _context2.v;
11036
11292
  if (!isAttachedLicenseTerms) {
11037
- _context6.n = 6;
11293
+ _context2.n = 6;
11038
11294
  break;
11039
11295
  }
11040
- return _context6.a(2, {
11296
+ return _context2.a(2, {
11041
11297
  success: false
11042
11298
  });
11043
11299
  case 6:
@@ -11047,39 +11303,39 @@ var LicenseClient = /*#__PURE__*/function () {
11047
11303
  licenseTermsId: request.licenseTermsId
11048
11304
  };
11049
11305
  if (!((_request$txOptions = request.txOptions) !== null && _request$txOptions !== void 0 && _request$txOptions.encodedTxDataOnly)) {
11050
- _context6.n = 7;
11306
+ _context2.n = 7;
11051
11307
  break;
11052
11308
  }
11053
- return _context6.a(2, {
11309
+ return _context2.a(2, {
11054
11310
  encodedTxData: this.licensingModuleClient.attachLicenseTermsEncode(req)
11055
11311
  });
11056
11312
  case 7:
11057
- _context6.n = 8;
11313
+ _context2.n = 8;
11058
11314
  return this.licensingModuleClient.attachLicenseTerms(req);
11059
11315
  case 8:
11060
- txHash = _context6.v;
11061
- _context6.n = 9;
11316
+ txHash = _context2.v;
11317
+ _context2.n = 9;
11062
11318
  return this.rpcClient.waitForTransactionReceipt(_objectSpread2(_objectSpread2({}, request.txOptions), {}, {
11063
11319
  hash: txHash
11064
11320
  }));
11065
11321
  case 9:
11066
- return _context6.a(2, {
11322
+ return _context2.a(2, {
11067
11323
  txHash: txHash,
11068
11324
  success: true
11069
11325
  });
11070
11326
  case 10:
11071
- _context6.n = 12;
11327
+ _context2.n = 12;
11072
11328
  break;
11073
11329
  case 11:
11074
- _context6.p = 11;
11075
- _t6 = _context6.v;
11076
- 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"));
11077
11333
  case 12:
11078
- return _context6.a(2);
11334
+ return _context2.a(2);
11079
11335
  }
11080
- }, _callee6, this, [[0, 11]]);
11336
+ }, _callee2, this, [[0, 11]]);
11081
11337
  }));
11082
- function attachLicenseTerms(_x6) {
11338
+ function attachLicenseTerms(_x2) {
11083
11339
  return _attachLicenseTerms.apply(this, arguments);
11084
11340
  }
11085
11341
  return attachLicenseTerms;
@@ -11103,13 +11359,13 @@ var LicenseClient = /*#__PURE__*/function () {
11103
11359
  }, {
11104
11360
  key: "mintLicenseTokens",
11105
11361
  value: (function () {
11106
- var _mintLicenseTokens = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(request) {
11362
+ var _mintLicenseTokens = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(request) {
11107
11363
  var _this = this;
11108
- var _request$txOptions2, _request$options, receiver, req, isLicenseIpIdRegistered, isExisted, ipAccount, ipOwner, isAttachedLicenseTerms, encodedTxData, licenseMintingFee, wipSpenders, _yield$contractCallWi, txHash, receipt, targetLogs, startLicenseTokenId, licenseTokenIds, i, _t7;
11109
- return _regenerator().w(function (_context7) {
11110
- 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) {
11111
11367
  case 0:
11112
- _context7.p = 0;
11368
+ _context3.p = 0;
11113
11369
  receiver = validateAddress(request.receiver || this.walletAddress);
11114
11370
  req = {
11115
11371
  licensorIpId: validateAddress(request.licensorIpId),
@@ -11118,72 +11374,72 @@ var LicenseClient = /*#__PURE__*/function () {
11118
11374
  amount: BigInt(request.amount === undefined ? 1 : request.amount),
11119
11375
  receiver: receiver,
11120
11376
  royaltyContext: zeroAddress,
11121
- maxMintingFee: BigInt(request.maxMintingFee),
11122
- 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)
11123
11379
  };
11124
11380
  if (!(req.maxMintingFee < 0)) {
11125
- _context7.n = 1;
11381
+ _context3.n = 1;
11126
11382
  break;
11127
11383
  }
11128
11384
  throw new Error("The maxMintingFee must be greater than 0.");
11129
11385
  case 1:
11130
- _context7.n = 2;
11386
+ _context3.n = 2;
11131
11387
  return this.ipAssetRegistryClient.isRegistered({
11132
11388
  id: validateAddress(request.licensorIpId)
11133
11389
  });
11134
11390
  case 2:
11135
- isLicenseIpIdRegistered = _context7.v;
11391
+ isLicenseIpIdRegistered = _context3.v;
11136
11392
  if (isLicenseIpIdRegistered) {
11137
- _context7.n = 3;
11393
+ _context3.n = 3;
11138
11394
  break;
11139
11395
  }
11140
11396
  throw new Error("The licensor IP with id ".concat(request.licensorIpId, " is not registered."));
11141
11397
  case 3:
11142
- _context7.n = 4;
11398
+ _context3.n = 4;
11143
11399
  return this.piLicenseTemplateReadOnlyClient.exists({
11144
11400
  licenseTermsId: req.licenseTermsId
11145
11401
  });
11146
11402
  case 4:
11147
- isExisted = _context7.v;
11403
+ isExisted = _context3.v;
11148
11404
  if (isExisted) {
11149
- _context7.n = 5;
11405
+ _context3.n = 5;
11150
11406
  break;
11151
11407
  }
11152
11408
  throw new Error("License terms id ".concat(request.licenseTermsId, " do not exist."));
11153
11409
  case 5:
11154
11410
  ipAccount = new IpAccountImplClient(this.rpcClient, this.wallet, req.licensorIpId);
11155
- _context7.n = 6;
11411
+ _context3.n = 6;
11156
11412
  return ipAccount.owner();
11157
11413
  case 6:
11158
- ipOwner = _context7.v;
11414
+ ipOwner = _context3.v;
11159
11415
  if (!(ipOwner !== this.walletAddress)) {
11160
- _context7.n = 8;
11416
+ _context3.n = 8;
11161
11417
  break;
11162
11418
  }
11163
- _context7.n = 7;
11419
+ _context3.n = 7;
11164
11420
  return this.licenseRegistryReadOnlyClient.hasIpAttachedLicenseTerms({
11165
11421
  ipId: req.licensorIpId,
11166
11422
  licenseTemplate: req.licenseTemplate,
11167
11423
  licenseTermsId: req.licenseTermsId
11168
11424
  });
11169
11425
  case 7:
11170
- isAttachedLicenseTerms = _context7.v;
11426
+ isAttachedLicenseTerms = _context3.v;
11171
11427
  if (isAttachedLicenseTerms) {
11172
- _context7.n = 8;
11428
+ _context3.n = 8;
11173
11429
  break;
11174
11430
  }
11175
11431
  throw new Error("License terms id ".concat(req.licenseTermsId, " is not attached to the IP with id ").concat(req.licensorIpId, "."));
11176
11432
  case 8:
11177
11433
  encodedTxData = this.licensingModuleClient.mintLicenseTokensEncode(req);
11178
11434
  if (!((_request$txOptions2 = request.txOptions) !== null && _request$txOptions2 !== void 0 && _request$txOptions2.encodedTxDataOnly)) {
11179
- _context7.n = 9;
11435
+ _context3.n = 9;
11180
11436
  break;
11181
11437
  }
11182
- return _context7.a(2, {
11438
+ return _context3.a(2, {
11183
11439
  encodedTxData: encodedTxData
11184
11440
  });
11185
11441
  case 9:
11186
- _context7.n = 10;
11442
+ _context3.n = 10;
11187
11443
  return calculateLicenseWipMintFee({
11188
11444
  predictMintingFeeRequest: req,
11189
11445
  rpcClient: this.rpcClient,
@@ -11191,7 +11447,7 @@ var LicenseClient = /*#__PURE__*/function () {
11191
11447
  walletAddress: this.walletAddress
11192
11448
  });
11193
11449
  case 10:
11194
- licenseMintingFee = _context7.v;
11450
+ licenseMintingFee = _context3.v;
11195
11451
  wipSpenders = [];
11196
11452
  if (licenseMintingFee > 0n) {
11197
11453
  wipSpenders.push({
@@ -11199,7 +11455,7 @@ var LicenseClient = /*#__PURE__*/function () {
11199
11455
  amount: licenseMintingFee
11200
11456
  });
11201
11457
  }
11202
- _context7.n = 11;
11458
+ _context3.n = 11;
11203
11459
  return contractCallWithFees({
11204
11460
  totalFees: licenseMintingFee,
11205
11461
  options: {
@@ -11217,7 +11473,7 @@ var LicenseClient = /*#__PURE__*/function () {
11217
11473
  encodedTxs: [encodedTxData]
11218
11474
  });
11219
11475
  case 11:
11220
- _yield$contractCallWi = _context7.v;
11476
+ _yield$contractCallWi = _context3.v;
11221
11477
  txHash = _yield$contractCallWi.txHash;
11222
11478
  receipt = _yield$contractCallWi.receipt;
11223
11479
  targetLogs = this.licensingModuleClient.parseTxLicenseTokensMintedEvent(receipt);
@@ -11226,19 +11482,19 @@ var LicenseClient = /*#__PURE__*/function () {
11226
11482
  for (i = 0; i < req.amount; i++) {
11227
11483
  licenseTokenIds.push(startLicenseTokenId + BigInt(i));
11228
11484
  }
11229
- return _context7.a(2, {
11485
+ return _context3.a(2, {
11230
11486
  txHash: txHash,
11231
11487
  licenseTokenIds: licenseTokenIds,
11232
11488
  receipt: receipt
11233
11489
  });
11234
11490
  case 12:
11235
- _context7.p = 12;
11236
- _t7 = _context7.v;
11237
- 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"));
11238
11494
  }
11239
- }, _callee7, this, [[0, 12]]);
11495
+ }, _callee3, this, [[0, 12]]);
11240
11496
  }));
11241
- function mintLicenseTokens(_x7) {
11497
+ function mintLicenseTokens(_x3) {
11242
11498
  return _mintLicenseTokens.apply(this, arguments);
11243
11499
  }
11244
11500
  return mintLicenseTokens;
@@ -11250,26 +11506,26 @@ var LicenseClient = /*#__PURE__*/function () {
11250
11506
  }, {
11251
11507
  key: "getLicenseTerms",
11252
11508
  value: (function () {
11253
- var _getLicenseTerms = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(selectedLicenseTermsId) {
11254
- var _t8;
11255
- return _regenerator().w(function (_context8) {
11256
- 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) {
11257
11513
  case 0:
11258
- _context8.p = 0;
11259
- _context8.n = 1;
11514
+ _context4.p = 0;
11515
+ _context4.n = 1;
11260
11516
  return this.piLicenseTemplateReadOnlyClient.getLicenseTerms({
11261
11517
  selectedLicenseTermsId: BigInt(selectedLicenseTermsId)
11262
11518
  });
11263
11519
  case 1:
11264
- return _context8.a(2, _context8.v);
11520
+ return _context4.a(2, _context4.v);
11265
11521
  case 2:
11266
- _context8.p = 2;
11267
- _t8 = _context8.v;
11268
- 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"));
11269
11525
  }
11270
- }, _callee8, this, [[0, 2]]);
11526
+ }, _callee4, this, [[0, 2]]);
11271
11527
  }));
11272
- function getLicenseTerms(_x8) {
11528
+ function getLicenseTerms(_x4) {
11273
11529
  return _getLicenseTerms.apply(this, arguments);
11274
11530
  }
11275
11531
  return getLicenseTerms;
@@ -11281,33 +11537,33 @@ var LicenseClient = /*#__PURE__*/function () {
11281
11537
  }, {
11282
11538
  key: "predictMintingLicenseFee",
11283
11539
  value: (function () {
11284
- var _predictMintingLicenseFee2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(request) {
11285
- var isLicenseIpIdRegistered, licenseTermsId, isExisted, object, _t9;
11286
- return _regenerator().w(function (_context9) {
11287
- 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) {
11288
11544
  case 0:
11289
- _context9.p = 0;
11290
- _context9.n = 1;
11545
+ _context5.p = 0;
11546
+ _context5.n = 1;
11291
11547
  return this.ipAssetRegistryClient.isRegistered({
11292
11548
  id: validateAddress(request.licensorIpId)
11293
11549
  });
11294
11550
  case 1:
11295
- isLicenseIpIdRegistered = _context9.v;
11551
+ isLicenseIpIdRegistered = _context5.v;
11296
11552
  if (isLicenseIpIdRegistered) {
11297
- _context9.n = 2;
11553
+ _context5.n = 2;
11298
11554
  break;
11299
11555
  }
11300
11556
  throw new Error("The licensor IP with id ".concat(request.licensorIpId, " is not registered."));
11301
11557
  case 2:
11302
11558
  licenseTermsId = BigInt(request.licenseTermsId);
11303
- _context9.n = 3;
11559
+ _context5.n = 3;
11304
11560
  return this.piLicenseTemplateReadOnlyClient.exists({
11305
11561
  licenseTermsId: licenseTermsId
11306
11562
  });
11307
11563
  case 3:
11308
- isExisted = _context9.v;
11564
+ isExisted = _context5.v;
11309
11565
  if (isExisted) {
11310
- _context9.n = 4;
11566
+ _context5.n = 4;
11311
11567
  break;
11312
11568
  }
11313
11569
  throw new Error("License terms id ".concat(request.licenseTermsId, " do not exist."));
@@ -11319,7 +11575,7 @@ var LicenseClient = /*#__PURE__*/function () {
11319
11575
  licenseTemplate: validateAddress(request.licenseTemplate || this.licenseTemplateClient.address),
11320
11576
  licenseTermsId: licenseTermsId
11321
11577
  });
11322
- _context9.n = 5;
11578
+ _context5.n = 5;
11323
11579
  return predictMintingLicenseFee({
11324
11580
  predictMintingFeeRequest: object,
11325
11581
  rpcClient: this.rpcClient,
@@ -11327,15 +11583,15 @@ var LicenseClient = /*#__PURE__*/function () {
11327
11583
  walletAddress: this.walletAddress
11328
11584
  });
11329
11585
  case 5:
11330
- return _context9.a(2, _context9.v);
11586
+ return _context5.a(2, _context5.v);
11331
11587
  case 6:
11332
- _context9.p = 6;
11333
- _t9 = _context9.v;
11334
- 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"));
11335
11591
  }
11336
- }, _callee9, this, [[0, 6]]);
11592
+ }, _callee5, this, [[0, 6]]);
11337
11593
  }));
11338
- function predictMintingLicenseFee$1(_x9) {
11594
+ function predictMintingLicenseFee$1(_x5) {
11339
11595
  return _predictMintingLicenseFee2.apply(this, arguments);
11340
11596
  }
11341
11597
  return predictMintingLicenseFee$1;
@@ -11347,12 +11603,12 @@ var LicenseClient = /*#__PURE__*/function () {
11347
11603
  }, {
11348
11604
  key: "setLicensingConfig",
11349
11605
  value: (function () {
11350
- var _setLicensingConfig = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(request) {
11351
- var _request$txOptions3, req, isLicenseIpIdRegistered, isExisted, isRegistered, txHash, _t0;
11352
- return _regenerator().w(function (_context0) {
11353
- 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) {
11354
11610
  case 0:
11355
- _context0.p = 0;
11611
+ _context6.p = 0;
11356
11612
  req = {
11357
11613
  ipId: request.ipId,
11358
11614
  licenseTemplate: validateAddress(request.licenseTemplate || this.licenseTemplateClient.address),
@@ -11360,91 +11616,91 @@ var LicenseClient = /*#__PURE__*/function () {
11360
11616
  licensingConfig: validateLicenseConfig(request.licensingConfig)
11361
11617
  };
11362
11618
  if (!(req.licenseTemplate === zeroAddress && req.licensingConfig.commercialRevShare !== 0)) {
11363
- _context0.n = 1;
11619
+ _context6.n = 1;
11364
11620
  break;
11365
11621
  }
11366
11622
  throw new Error("The license template cannot be zero address if commercial revenue share is not zero.");
11367
11623
  case 1:
11368
- _context0.n = 2;
11624
+ _context6.n = 2;
11369
11625
  return this.ipAssetRegistryClient.isRegistered({
11370
11626
  id: validateAddress(req.ipId)
11371
11627
  });
11372
11628
  case 2:
11373
- isLicenseIpIdRegistered = _context0.v;
11629
+ isLicenseIpIdRegistered = _context6.v;
11374
11630
  if (isLicenseIpIdRegistered) {
11375
- _context0.n = 3;
11631
+ _context6.n = 3;
11376
11632
  break;
11377
11633
  }
11378
11634
  throw new Error("The licensor IP with id ".concat(req.ipId, " is not registered."));
11379
11635
  case 3:
11380
- _context0.n = 4;
11636
+ _context6.n = 4;
11381
11637
  return this.piLicenseTemplateReadOnlyClient.exists({
11382
11638
  licenseTermsId: req.licenseTermsId
11383
11639
  });
11384
11640
  case 4:
11385
- isExisted = _context0.v;
11641
+ isExisted = _context6.v;
11386
11642
  if (isExisted) {
11387
- _context0.n = 5;
11643
+ _context6.n = 5;
11388
11644
  break;
11389
11645
  }
11390
11646
  throw new Error("License terms id ".concat(req.licenseTermsId, " do not exist."));
11391
11647
  case 5:
11392
11648
  if (!(req.licensingConfig.licensingHook !== zeroAddress)) {
11393
- _context0.n = 7;
11649
+ _context6.n = 7;
11394
11650
  break;
11395
11651
  }
11396
- _context0.n = 6;
11652
+ _context6.n = 6;
11397
11653
  return this.moduleRegistryReadOnlyClient.isRegistered({
11398
11654
  moduleAddress: req.licensingConfig.licensingHook
11399
11655
  });
11400
11656
  case 6:
11401
- isRegistered = _context0.v;
11657
+ isRegistered = _context6.v;
11402
11658
  if (isRegistered) {
11403
- _context0.n = 7;
11659
+ _context6.n = 7;
11404
11660
  break;
11405
11661
  }
11406
11662
  throw new Error("The licensing hook is not registered.");
11407
11663
  case 7:
11408
11664
  if (!(req.licenseTemplate === zeroAddress && req.licenseTermsId !== 0n)) {
11409
- _context0.n = 8;
11665
+ _context6.n = 8;
11410
11666
  break;
11411
11667
  }
11412
11668
  throw new Error("The license template is zero address but license terms id is not zero.");
11413
11669
  case 8:
11414
11670
  if (!((_request$txOptions3 = request.txOptions) !== null && _request$txOptions3 !== void 0 && _request$txOptions3.encodedTxDataOnly)) {
11415
- _context0.n = 9;
11671
+ _context6.n = 9;
11416
11672
  break;
11417
11673
  }
11418
- return _context0.a(2, {
11674
+ return _context6.a(2, {
11419
11675
  encodedTxData: this.licensingModuleClient.setLicensingConfigEncode(req)
11420
11676
  });
11421
11677
  case 9:
11422
- _context0.n = 10;
11678
+ _context6.n = 10;
11423
11679
  return this.licensingModuleClient.setLicensingConfig(req);
11424
11680
  case 10:
11425
- txHash = _context0.v;
11426
- _context0.n = 11;
11681
+ txHash = _context6.v;
11682
+ _context6.n = 11;
11427
11683
  return this.rpcClient.waitForTransactionReceipt(_objectSpread2(_objectSpread2({}, request.txOptions), {}, {
11428
11684
  hash: txHash
11429
11685
  }));
11430
11686
  case 11:
11431
- return _context0.a(2, {
11687
+ return _context6.a(2, {
11432
11688
  txHash: txHash,
11433
11689
  success: true
11434
11690
  });
11435
11691
  case 12:
11436
- _context0.n = 14;
11692
+ _context6.n = 14;
11437
11693
  break;
11438
11694
  case 13:
11439
- _context0.p = 13;
11440
- _t0 = _context0.v;
11441
- 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"));
11442
11698
  case 14:
11443
- return _context0.a(2);
11699
+ return _context6.a(2);
11444
11700
  }
11445
- }, _callee0, this, [[0, 13]]);
11701
+ }, _callee6, this, [[0, 13]]);
11446
11702
  }));
11447
- function setLicensingConfig(_x0) {
11703
+ function setLicensingConfig(_x6) {
11448
11704
  return _setLicensingConfig.apply(this, arguments);
11449
11705
  }
11450
11706
  return setLicensingConfig;
@@ -11462,34 +11718,34 @@ var LicenseClient = /*#__PURE__*/function () {
11462
11718
  }, {
11463
11719
  key: "setMaxLicenseTokens",
11464
11720
  value: (function () {
11465
- var _setMaxLicenseTokens = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(_ref3) {
11466
- var ipId, licenseTermsId, maxLicenseTokens, licenseTemplate, txOptions, newLicenseTermsId, newLicenseTemplate, licensingConfig, txHash, _t1;
11467
- return _regenerator().w(function (_context1) {
11468
- 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) {
11469
11725
  case 0:
11470
- ipId = _ref3.ipId, licenseTermsId = _ref3.licenseTermsId, maxLicenseTokens = _ref3.maxLicenseTokens, licenseTemplate = _ref3.licenseTemplate, txOptions = _ref3.txOptions;
11471
- _context1.p = 1;
11726
+ ipId = _ref.ipId, licenseTermsId = _ref.licenseTermsId, maxLicenseTokens = _ref.maxLicenseTokens, licenseTemplate = _ref.licenseTemplate, txOptions = _ref.txOptions;
11727
+ _context7.p = 1;
11472
11728
  if (!(maxLicenseTokens < 0)) {
11473
- _context1.n = 2;
11729
+ _context7.n = 2;
11474
11730
  break;
11475
11731
  }
11476
11732
  throw new Error("The max license tokens must be greater than 0.");
11477
11733
  case 2:
11478
11734
  newLicenseTermsId = BigInt(licenseTermsId);
11479
11735
  newLicenseTemplate = validateAddress(licenseTemplate || this.licenseTemplateClient.address);
11480
- _context1.n = 3;
11736
+ _context7.n = 3;
11481
11737
  return this.getLicensingConfig({
11482
11738
  ipId: ipId,
11483
11739
  licenseTermsId: newLicenseTermsId,
11484
11740
  licenseTemplate: newLicenseTemplate
11485
11741
  });
11486
11742
  case 3:
11487
- licensingConfig = _context1.v;
11743
+ licensingConfig = _context7.v;
11488
11744
  if (!(licensingConfig.licensingHook !== this.totalLicenseTokenLimitHookClient.address)) {
11489
- _context1.n = 4;
11745
+ _context7.n = 4;
11490
11746
  break;
11491
11747
  }
11492
- _context1.n = 4;
11748
+ _context7.n = 4;
11493
11749
  return this.setLicensingConfig({
11494
11750
  ipId: ipId,
11495
11751
  licenseTermsId: newLicenseTermsId,
@@ -11500,7 +11756,7 @@ var LicenseClient = /*#__PURE__*/function () {
11500
11756
  })
11501
11757
  });
11502
11758
  case 4:
11503
- _context1.n = 5;
11759
+ _context7.n = 5;
11504
11760
  return this.totalLicenseTokenLimitHookClient.setTotalLicenseTokenLimit({
11505
11761
  licensorIpId: ipId,
11506
11762
  licenseTemplate: newLicenseTemplate,
@@ -11508,20 +11764,20 @@ var LicenseClient = /*#__PURE__*/function () {
11508
11764
  limit: BigInt(maxLicenseTokens)
11509
11765
  });
11510
11766
  case 5:
11511
- txHash = _context1.v;
11512
- return _context1.a(2, waitForTxReceipt({
11767
+ txHash = _context7.v;
11768
+ return _context7.a(2, waitForTxReceipt({
11513
11769
  txHash: txHash,
11514
11770
  txOptions: txOptions,
11515
11771
  rpcClient: this.rpcClient
11516
11772
  }));
11517
11773
  case 6:
11518
- _context1.p = 6;
11519
- _t1 = _context1.v;
11520
- 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"));
11521
11777
  }
11522
- }, _callee1, this, [[1, 6]]);
11778
+ }, _callee7, this, [[1, 6]]);
11523
11779
  }));
11524
- function setMaxLicenseTokens(_x1) {
11780
+ function setMaxLicenseTokens(_x7) {
11525
11781
  return _setMaxLicenseTokens.apply(this, arguments);
11526
11782
  }
11527
11783
  return setMaxLicenseTokens;
@@ -11529,52 +11785,344 @@ var LicenseClient = /*#__PURE__*/function () {
11529
11785
  }, {
11530
11786
  key: "getLicensingConfig",
11531
11787
  value: function () {
11532
- var _getLicensingConfig = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(request) {
11533
- var licensingConfigParam, _t10;
11534
- return _regenerator().w(function (_context10) {
11535
- 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) {
11536
11792
  case 0:
11537
- _context10.p = 0;
11793
+ _context8.p = 0;
11538
11794
  licensingConfigParam = {
11539
11795
  ipId: validateAddress(request.ipId),
11540
11796
  licenseTemplate: validateAddress(request.licenseTemplate || this.licenseTemplateClient.address),
11541
11797
  licenseTermsId: BigInt(request.licenseTermsId)
11542
11798
  };
11543
- _context10.n = 1;
11799
+ _context8.n = 1;
11544
11800
  return this.licenseRegistryReadOnlyClient.getLicensingConfig(licensingConfigParam);
11545
11801
  case 1:
11546
- return _context10.a(2, _context10.v);
11802
+ return _context8.a(2, _context8.v);
11547
11803
  case 2:
11548
- _context10.p = 2;
11549
- _t10 = _context10.v;
11550
- 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"));
11551
11807
  }
11552
- }, _callee10, this, [[0, 2]]);
11808
+ }, _callee8, this, [[0, 2]]);
11553
11809
  }));
11554
- function getLicensingConfig(_x10) {
11810
+ function getLicensingConfig(_x8) {
11555
11811
  return _getLicensingConfig.apply(this, arguments);
11556
11812
  }
11557
11813
  return getLicensingConfig;
11558
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
+ }())
11559
12107
  }, {
11560
12108
  key: "getLicenseTermsId",
11561
12109
  value: function () {
11562
- var _getLicenseTermsId = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11(request) {
12110
+ var _getLicenseTermsId = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12(licenseTerms) {
11563
12111
  var licenseRes;
11564
- return _regenerator().w(function (_context11) {
11565
- while (1) switch (_context11.n) {
12112
+ return _regenerator().w(function (_context12) {
12113
+ while (1) switch (_context12.n) {
11566
12114
  case 0:
11567
- _context11.n = 1;
12115
+ _context12.n = 1;
11568
12116
  return this.licenseTemplateClient.getLicenseTermsId({
11569
- terms: request
12117
+ terms: licenseTerms
11570
12118
  });
11571
12119
  case 1:
11572
- licenseRes = _context11.v;
11573
- return _context11.a(2, licenseRes.selectedLicenseTermsId);
12120
+ licenseRes = _context12.v;
12121
+ return _context12.a(2, licenseRes.selectedLicenseTermsId);
11574
12122
  }
11575
- }, _callee11, this);
12123
+ }, _callee12, this);
11576
12124
  }));
11577
- function getLicenseTermsId(_x11) {
12125
+ function getLicenseTermsId(_x12) {
11578
12126
  return _getLicenseTermsId.apply(this, arguments);
11579
12127
  }
11580
12128
  return getLicenseTermsId;
@@ -11582,60 +12130,60 @@ var LicenseClient = /*#__PURE__*/function () {
11582
12130
  }, {
11583
12131
  key: "registerPILTermsHelper",
11584
12132
  value: function () {
11585
- var _registerPILTermsHelper = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12(licenseTerms, txOptions) {
12133
+ var _registerPILTermsHelper = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13(licenseTerms, txOptions) {
11586
12134
  var licenseTermsId, txHash, _yield$waitForTxRecei, receipt, targetLogs;
11587
- return _regenerator().w(function (_context12) {
11588
- while (1) switch (_context12.n) {
12135
+ return _regenerator().w(function (_context13) {
12136
+ while (1) switch (_context13.n) {
11589
12137
  case 0:
11590
12138
  licenseTerms.commercialRevShare = getRevenueShare(licenseTerms.commercialRevShare);
11591
12139
  if (!(txOptions !== null && txOptions !== void 0 && txOptions.encodedTxDataOnly)) {
11592
- _context12.n = 1;
12140
+ _context13.n = 1;
11593
12141
  break;
11594
12142
  }
11595
- return _context12.a(2, {
12143
+ return _context13.a(2, {
11596
12144
  encodedTxData: this.licenseTemplateClient.registerLicenseTermsEncode({
11597
12145
  terms: licenseTerms
11598
12146
  })
11599
12147
  });
11600
12148
  case 1:
11601
- _context12.n = 2;
12149
+ _context13.n = 2;
11602
12150
  return this.getLicenseTermsId(licenseTerms);
11603
12151
  case 2:
11604
- licenseTermsId = _context12.v;
12152
+ licenseTermsId = _context13.v;
11605
12153
  if (!(licenseTermsId !== 0n)) {
11606
- _context12.n = 3;
12154
+ _context13.n = 3;
11607
12155
  break;
11608
12156
  }
11609
- return _context12.a(2, {
12157
+ return _context13.a(2, {
11610
12158
  licenseTermsId: licenseTermsId
11611
12159
  });
11612
12160
  case 3:
11613
- _context12.n = 4;
12161
+ _context13.n = 4;
11614
12162
  return this.licenseTemplateClient.registerLicenseTerms({
11615
12163
  terms: licenseTerms
11616
12164
  });
11617
12165
  case 4:
11618
- txHash = _context12.v;
11619
- _context12.n = 5;
12166
+ txHash = _context13.v;
12167
+ _context13.n = 5;
11620
12168
  return waitForTxReceipt({
11621
12169
  txOptions: txOptions,
11622
12170
  rpcClient: this.rpcClient,
11623
12171
  txHash: txHash
11624
12172
  });
11625
12173
  case 5:
11626
- _yield$waitForTxRecei = _context12.v;
12174
+ _yield$waitForTxRecei = _context13.v;
11627
12175
  receipt = _yield$waitForTxRecei.receipt;
11628
12176
  targetLogs = this.licenseTemplateClient.parseTxLicenseTermsRegisteredEvent(receipt);
11629
- return _context12.a(2, {
12177
+ return _context13.a(2, {
11630
12178
  txHash: txHash,
11631
12179
  licenseTermsId: targetLogs[0].licenseTermsId
11632
12180
  });
11633
12181
  case 6:
11634
- return _context12.a(2);
12182
+ return _context13.a(2);
11635
12183
  }
11636
- }, _callee12, this);
12184
+ }, _callee13, this);
11637
12185
  }));
11638
- function registerPILTermsHelper(_x12, _x13) {
12186
+ function registerPILTermsHelper(_x13, _x14) {
11639
12187
  return _registerPILTermsHelper.apply(this, arguments);
11640
12188
  }
11641
12189
  return registerPILTermsHelper;
@@ -11678,7 +12226,7 @@ var NftClient = /*#__PURE__*/function () {
11678
12226
  symbol: request.symbol,
11679
12227
  baseURI: (_request$baseURI = request.baseURI) !== null && _request$baseURI !== void 0 ? _request$baseURI : "",
11680
12228
  maxSupply: (_request$maxSupply = request.maxSupply) !== null && _request$maxSupply !== void 0 ? _request$maxSupply : Number(maxUint32),
11681
- 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),
11682
12230
  mintFeeToken: (_request$mintFeeToken = request.mintFeeToken) !== null && _request$mintFeeToken !== void 0 ? _request$mintFeeToken : zeroAddress,
11683
12231
  owner: validateAddress(request.owner || this.wallet.account.address),
11684
12232
  mintFeeRecipient: validateAddress(request.mintFeeRecipient),