@story-protocol/core-sdk 0.0.1-beta-rc.11 → 0.0.1-beta-rc.13

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 (33) hide show
  1. package/dist/declarations/src/client.d.ts +9 -9
  2. package/dist/declarations/src/client.d.ts.map +1 -1
  3. package/dist/declarations/src/clients/storyAPI.d.ts +0 -2
  4. package/dist/declarations/src/clients/storyAPI.d.ts.map +1 -1
  5. package/dist/declarations/src/index.d.ts +3 -4
  6. package/dist/declarations/src/index.d.ts.map +1 -1
  7. package/dist/declarations/src/resources/dispute.d.ts +419 -78
  8. package/dist/declarations/src/resources/dispute.d.ts.map +1 -1
  9. package/dist/declarations/src/resources/ipAccount.d.ts +400 -76
  10. package/dist/declarations/src/resources/ipAccount.d.ts.map +1 -1
  11. package/dist/declarations/src/resources/ipAsset.d.ts +26 -756
  12. package/dist/declarations/src/resources/ipAsset.d.ts.map +1 -1
  13. package/dist/declarations/src/resources/license.d.ts +3411 -650
  14. package/dist/declarations/src/resources/license.d.ts.map +1 -1
  15. package/dist/declarations/src/resources/permission.d.ts +1000 -313
  16. package/dist/declarations/src/resources/permission.d.ts.map +1 -1
  17. package/dist/declarations/src/resources/royalty.d.ts +3103 -0
  18. package/dist/declarations/src/resources/{policy.d.ts.map → royalty.d.ts.map} +1 -1
  19. package/dist/declarations/src/types/config.d.ts +6 -2
  20. package/dist/declarations/src/types/config.d.ts.map +1 -1
  21. package/dist/declarations/src/types/resources/ipAsset.d.ts +5 -21
  22. package/dist/declarations/src/types/resources/ipAsset.d.ts.map +1 -1
  23. package/dist/declarations/src/types/resources/license.d.ts +54 -18
  24. package/dist/declarations/src/types/resources/license.d.ts.map +1 -1
  25. package/dist/declarations/src/types/resources/royalty.d.ts +41 -0
  26. package/dist/declarations/src/types/resources/royalty.d.ts.map +1 -1
  27. package/dist/story-protocol-core-sdk.cjs.dev.js +1580 -1371
  28. package/dist/story-protocol-core-sdk.cjs.prod.js +1580 -1371
  29. package/dist/story-protocol-core-sdk.esm.js +1583 -1373
  30. package/package.json +5 -5
  31. package/dist/declarations/src/resources/policy.d.ts +0 -2436
  32. package/dist/declarations/src/types/resources/policy.d.ts +0 -83
  33. package/dist/declarations/src/types/resources/policy.d.ts.map +0 -1
@@ -440,31 +440,12 @@ function _asyncToGenerator(fn) {
440
440
  };
441
441
  }
442
442
 
443
- function handleError(error, msg) {
444
- if (error instanceof Error) {
445
- throw new Error("".concat(msg, ": ").concat(error.message));
446
- }
447
- throw new Error("".concat(msg, ": Unknown error type"));
448
- }
449
-
450
- var AddressZero = "0x0000000000000000000000000000000000000000";
451
- var HashZero = "0x0000000000000000000000000000000000000000000000000000000000000000";
452
- var SepoliaChainId = "11155111";
453
-
454
443
  function _arrayLikeToArray(arr, len) {
455
444
  if (len == null || len > arr.length) len = arr.length;
456
445
  for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
457
446
  return arr2;
458
447
  }
459
448
 
460
- function _arrayWithoutHoles(arr) {
461
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
462
- }
463
-
464
- function _iterableToArray(iter) {
465
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
466
- }
467
-
468
449
  function _unsupportedIterableToArray(o, minLen) {
469
450
  if (!o) return;
470
451
  if (typeof o === "string") return _arrayLikeToArray(o, minLen);
@@ -474,6 +455,215 @@ function _unsupportedIterableToArray(o, minLen) {
474
455
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
475
456
  }
476
457
 
458
+ function _createForOfIteratorHelper(o, allowArrayLike) {
459
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
460
+ if (!it) {
461
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
462
+ if (it) o = it;
463
+ var i = 0;
464
+ var F = function () {};
465
+ return {
466
+ s: F,
467
+ n: function () {
468
+ if (i >= o.length) return {
469
+ done: true
470
+ };
471
+ return {
472
+ done: false,
473
+ value: o[i++]
474
+ };
475
+ },
476
+ e: function (e) {
477
+ throw e;
478
+ },
479
+ f: F
480
+ };
481
+ }
482
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
483
+ }
484
+ var normalCompletion = true,
485
+ didErr = false,
486
+ err;
487
+ return {
488
+ s: function () {
489
+ it = it.call(o);
490
+ },
491
+ n: function () {
492
+ var step = it.next();
493
+ normalCompletion = step.done;
494
+ return step;
495
+ },
496
+ e: function (e) {
497
+ didErr = true;
498
+ err = e;
499
+ },
500
+ f: function () {
501
+ try {
502
+ if (!normalCompletion && it.return != null) it.return();
503
+ } finally {
504
+ if (didErr) throw err;
505
+ }
506
+ }
507
+ };
508
+ }
509
+
510
+ function parseToBigInt(num) {
511
+ return BigInt(num);
512
+ }
513
+ function waitTxAndFilterLog(_x, _x2, _x3) {
514
+ return _waitTxAndFilterLog.apply(this, arguments);
515
+ }
516
+ function _waitTxAndFilterLog() {
517
+ _waitTxAndFilterLog = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(client, txHash, params) {
518
+ var txReceipt, targetLogs, _iterator, _step, log, currentLog;
519
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
520
+ while (1) switch (_context.prev = _context.next) {
521
+ case 0:
522
+ _context.next = 2;
523
+ return client.waitForTransactionReceipt({
524
+ hash: txHash,
525
+ confirmations: params.confirmations,
526
+ pollingInterval: params.pollingInterval,
527
+ timeout: params.timeout
528
+ });
529
+ case 2:
530
+ txReceipt = _context.sent;
531
+ targetLogs = [];
532
+ _iterator = _createForOfIteratorHelper(txReceipt.logs);
533
+ _context.prev = 5;
534
+ _iterator.s();
535
+ case 7:
536
+ if ((_step = _iterator.n()).done) {
537
+ _context.next = 21;
538
+ break;
539
+ }
540
+ log = _step.value;
541
+ _context.prev = 9;
542
+ if (!(params.from && log.address !== params.from.toLowerCase())) {
543
+ _context.next = 12;
544
+ break;
545
+ }
546
+ return _context.abrupt("continue", 19);
547
+ case 12:
548
+ currentLog = viem.decodeEventLog({
549
+ abi: params.abi,
550
+ eventName: params.eventName,
551
+ data: log.data,
552
+ topics: log.topics
553
+ });
554
+ targetLogs.push(currentLog);
555
+ _context.next = 19;
556
+ break;
557
+ case 16:
558
+ _context.prev = 16;
559
+ _context.t0 = _context["catch"](9);
560
+ return _context.abrupt("continue", 19);
561
+ case 19:
562
+ _context.next = 7;
563
+ break;
564
+ case 21:
565
+ _context.next = 26;
566
+ break;
567
+ case 23:
568
+ _context.prev = 23;
569
+ _context.t1 = _context["catch"](5);
570
+ _iterator.e(_context.t1);
571
+ case 26:
572
+ _context.prev = 26;
573
+ _iterator.f();
574
+ return _context.finish(26);
575
+ case 29:
576
+ if (!(targetLogs.length === 0)) {
577
+ _context.next = 31;
578
+ break;
579
+ }
580
+ throw new Error("not found event ".concat(params.eventName, " in target transaction"));
581
+ case 31:
582
+ return _context.abrupt("return", targetLogs);
583
+ case 32:
584
+ case "end":
585
+ return _context.stop();
586
+ }
587
+ }, _callee, null, [[5, 23, 26, 29], [9, 16]]);
588
+ }));
589
+ return _waitTxAndFilterLog.apply(this, arguments);
590
+ }
591
+ function waitTx(_x4, _x5, _x6) {
592
+ return _waitTx.apply(this, arguments);
593
+ }
594
+ function _waitTx() {
595
+ _waitTx = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(client, txHash, params) {
596
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
597
+ while (1) switch (_context2.prev = _context2.next) {
598
+ case 0:
599
+ _context2.next = 2;
600
+ return client.waitForTransactionReceipt(_objectSpread2({
601
+ hash: txHash
602
+ }, params));
603
+ case 2:
604
+ case "end":
605
+ return _context2.stop();
606
+ }
607
+ }, _callee2);
608
+ }));
609
+ return _waitTx.apply(this, arguments);
610
+ }
611
+ function chainStringToViemChain(chainId) {
612
+ switch (chainId) {
613
+ case "11155111":
614
+ case "sepolia":
615
+ return chains.sepolia;
616
+ case "1513":
617
+ case "storyTestnet":
618
+ return storyTestnet$1;
619
+ default:
620
+ throw new Error("chainId ".concat(chainId, " not supported"));
621
+ }
622
+ }
623
+ var storyTestnet$1 = viem.defineChain({
624
+ id: 1513,
625
+ name: "story-network",
626
+ nativeCurrency: {
627
+ name: "Ether",
628
+ symbol: "SEP",
629
+ decimals: 18
630
+ },
631
+ rpcUrls: {
632
+ "default": {
633
+ http: ["https://story-network.rpc.caldera.xyz/http"],
634
+ webSocket: ["wss://story-network.rpc.caldera.xyz/ws"]
635
+ }
636
+ },
637
+ blockExplorers: {
638
+ "default": {
639
+ name: "Explorer",
640
+ url: "https://story-network.explorer.caldera.xyz"
641
+ }
642
+ },
643
+ //TODO: wait for Ze confirm with config information
644
+ contracts: {
645
+ multicall3: {
646
+ address: "0xcA11bde05977b3631167028862bE2a173976CA11",
647
+ blockCreated: 5882
648
+ }
649
+ },
650
+ testnet: true
651
+ });
652
+ var chain = {
653
+ sepolia: "11155111",
654
+ storyTestnet: "1513",
655
+ 11155111: "11155111",
656
+ 1513: "1513"
657
+ };
658
+
659
+ function _arrayWithoutHoles(arr) {
660
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
661
+ }
662
+
663
+ function _iterableToArray(iter) {
664
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
665
+ }
666
+
477
667
  function _nonIterableSpread() {
478
668
  throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
479
669
  }
@@ -806,19 +996,19 @@ var IPAssetRegistryABI = [{
806
996
  type: "uint256"
807
997
  }, {
808
998
  indexed: false,
809
- internalType: "address",
810
- name: "resolver",
811
- type: "address"
999
+ internalType: "string",
1000
+ name: "name",
1001
+ type: "string"
812
1002
  }, {
813
1003
  indexed: false,
814
- internalType: "address",
815
- name: "provider",
816
- type: "address"
1004
+ internalType: "string",
1005
+ name: "uri",
1006
+ type: "string"
817
1007
  }, {
818
1008
  indexed: false,
819
- internalType: "bytes",
820
- name: "metadata",
821
- type: "bytes"
1009
+ internalType: "uint256",
1010
+ name: "registrationDate",
1011
+ type: "uint256"
822
1012
  }],
823
1013
  name: "IPRegistered",
824
1014
  type: "event"
@@ -858,6 +1048,24 @@ var IPAssetRegistryABI = [{
858
1048
  }],
859
1049
  stateMutability: "view",
860
1050
  type: "function"
1051
+ }, {
1052
+ inputs: [{
1053
+ internalType: "address",
1054
+ name: "tokenContract",
1055
+ type: "address"
1056
+ }, {
1057
+ internalType: "uint256",
1058
+ name: "tokenId",
1059
+ type: "uint256"
1060
+ }],
1061
+ name: "register",
1062
+ outputs: [{
1063
+ internalType: "address",
1064
+ name: "id",
1065
+ type: "address"
1066
+ }],
1067
+ stateMutability: "nonpayable",
1068
+ type: "function"
861
1069
  }];
862
1070
 
863
1071
  var LicensingModuleABI = [{
@@ -874,11 +1082,16 @@ var LicensingModuleABI = [{
874
1082
  type: "address"
875
1083
  }, {
876
1084
  indexed: false,
877
- internalType: "address[]",
878
- name: "parentIpIds",
879
- type: "address[]"
1085
+ internalType: "address",
1086
+ name: "licenseTemplate",
1087
+ type: "address"
1088
+ }, {
1089
+ indexed: false,
1090
+ internalType: "uint256",
1091
+ name: "licenseTermsId",
1092
+ type: "uint256"
880
1093
  }],
881
- name: "IpIdLinkedToParents",
1094
+ name: "LicenseTermsAttached",
882
1095
  type: "event"
883
1096
  }, {
884
1097
  anonymous: false,
@@ -890,154 +1103,67 @@ var LicensingModuleABI = [{
890
1103
  }, {
891
1104
  indexed: true,
892
1105
  internalType: "address",
893
- name: "ipId",
1106
+ name: "licensorIpId",
1107
+ type: "address"
1108
+ }, {
1109
+ indexed: false,
1110
+ internalType: "address",
1111
+ name: "licenseTemplate",
894
1112
  type: "address"
895
1113
  }, {
896
1114
  indexed: true,
897
1115
  internalType: "uint256",
898
- name: "policyId",
1116
+ name: "licenseTermsId",
899
1117
  type: "uint256"
900
1118
  }, {
901
1119
  indexed: false,
902
1120
  internalType: "uint256",
903
- name: "index",
1121
+ name: "amount",
904
1122
  type: "uint256"
905
1123
  }, {
906
1124
  indexed: false,
907
- internalType: "bool",
908
- name: "isInherited",
909
- type: "bool"
1125
+ internalType: "address",
1126
+ name: "receiver",
1127
+ type: "address"
1128
+ }, {
1129
+ indexed: false,
1130
+ internalType: "uint256",
1131
+ name: "startLicenseTokenId",
1132
+ type: "uint256"
910
1133
  }],
911
- name: "PolicyAddedToIpId",
1134
+ name: "LicenseTokensMinted",
912
1135
  type: "event"
913
1136
  }, {
914
- anonymous: false,
915
1137
  inputs: [{
916
- indexed: true,
917
- internalType: "uint256",
918
- name: "policyId",
919
- type: "uint256"
1138
+ internalType: "address",
1139
+ name: "ipId",
1140
+ type: "address"
920
1141
  }, {
921
- indexed: true,
922
1142
  internalType: "address",
923
- name: "policyFrameworkManager",
924
- type: "address"
925
- }, {
926
- indexed: false,
927
- internalType: "bytes",
928
- name: "frameworkData",
929
- type: "bytes"
930
- }, {
931
- indexed: false,
932
- internalType: "address",
933
- name: "royaltyPolicy",
934
- type: "address"
935
- }, {
936
- indexed: false,
937
- internalType: "bytes",
938
- name: "royaltyData",
939
- type: "bytes"
940
- }, {
941
- indexed: false,
942
- internalType: "uint256",
943
- name: "mintingFee",
944
- type: "uint256"
945
- }, {
946
- indexed: false,
947
- internalType: "address",
948
- name: "mintingFeeToken",
949
- type: "address"
950
- }],
951
- name: "PolicyRegistered",
952
- type: "event"
953
- }, {
954
- inputs: [{
955
- internalType: "address",
956
- name: "ipId",
1143
+ name: "licenseTemplate",
957
1144
  type: "address"
958
1145
  }, {
959
1146
  internalType: "uint256",
960
- name: "polId",
961
- type: "uint256"
962
- }],
963
- name: "addPolicyToIp",
964
- outputs: [{
965
- internalType: "uint256",
966
- name: "indexOnIpId",
1147
+ name: "licenseTermsId",
967
1148
  type: "uint256"
968
1149
  }],
1150
+ name: "attachLicenseTerms",
1151
+ outputs: [],
969
1152
  stateMutability: "nonpayable",
970
1153
  type: "function"
971
1154
  }, {
972
1155
  inputs: [{
973
- components: [{
974
- internalType: "bool",
975
- name: "isLicenseTransferable",
976
- type: "bool"
977
- }, {
978
- internalType: "address",
979
- name: "policyFramework",
980
- type: "address"
981
- }, {
982
- internalType: "bytes",
983
- name: "frameworkData",
984
- type: "bytes"
985
- }, {
986
- internalType: "address",
987
- name: "royaltyPolicy",
988
- type: "address"
989
- }, {
990
- internalType: "bytes",
991
- name: "royaltyData",
992
- type: "bytes"
993
- }, {
994
- internalType: "uint256",
995
- name: "mintingFee",
996
- type: "uint256"
997
- }, {
998
- internalType: "address",
999
- name: "mintingFeeToken",
1000
- type: "address"
1001
- }],
1002
- internalType: "struct Licensing.Policy",
1003
- name: "pol",
1004
- type: "tuple"
1005
- }],
1006
- name: "getPolicyId",
1007
- outputs: [{
1008
- internalType: "uint256",
1009
- name: "policyId",
1010
- type: "uint256"
1011
- }],
1012
- stateMutability: "view",
1013
- type: "function"
1014
- }, {
1015
- inputs: [{
1016
- internalType: "uint256[]",
1017
- name: "licenseIds",
1018
- type: "uint256[]"
1156
+ internalType: "address",
1157
+ name: "licensorIpId",
1158
+ type: "address"
1019
1159
  }, {
1020
1160
  internalType: "address",
1021
- name: "childIpId",
1161
+ name: "licenseTemplate",
1022
1162
  type: "address"
1023
1163
  }, {
1024
- internalType: "bytes",
1025
- name: "royaltyContext",
1026
- type: "bytes"
1027
- }],
1028
- name: "linkIpToParents",
1029
- outputs: [],
1030
- stateMutability: "nonpayable",
1031
- type: "function"
1032
- }, {
1033
- inputs: [{
1034
1164
  internalType: "uint256",
1035
- name: "policyId",
1165
+ name: "licenseTermsId",
1036
1166
  type: "uint256"
1037
- }, {
1038
- internalType: "address",
1039
- name: "licensorIpId",
1040
- type: "address"
1041
1167
  }, {
1042
1168
  internalType: "uint256",
1043
1169
  name: "amount",
@@ -1051,60 +1177,116 @@ var LicensingModuleABI = [{
1051
1177
  name: "royaltyContext",
1052
1178
  type: "bytes"
1053
1179
  }],
1054
- name: "mintLicense",
1180
+ name: "mintLicenseTokens",
1055
1181
  outputs: [{
1056
1182
  internalType: "uint256",
1057
- name: "licenseId",
1183
+ name: "startLicenseTokenId",
1058
1184
  type: "uint256"
1059
1185
  }],
1060
1186
  stateMutability: "nonpayable",
1061
1187
  type: "function"
1188
+ }];
1189
+
1190
+ var PILicenseTemplateABI = [{
1191
+ anonymous: false,
1192
+ inputs: [{
1193
+ indexed: true,
1194
+ internalType: "uint256",
1195
+ name: "licenseTermsId",
1196
+ type: "uint256"
1197
+ }, {
1198
+ indexed: true,
1199
+ internalType: "address",
1200
+ name: "licenseTemplate",
1201
+ type: "address"
1202
+ }, {
1203
+ indexed: false,
1204
+ internalType: "bytes",
1205
+ name: "licenseTerms",
1206
+ type: "bytes"
1207
+ }],
1208
+ name: "LicenseTermsRegistered",
1209
+ type: "event"
1062
1210
  }, {
1063
1211
  inputs: [{
1064
1212
  components: [{
1065
1213
  internalType: "bool",
1066
- name: "isLicenseTransferable",
1214
+ name: "transferable",
1067
1215
  type: "bool"
1068
1216
  }, {
1069
1217
  internalType: "address",
1070
- name: "policyFramework",
1218
+ name: "royaltyPolicy",
1071
1219
  type: "address"
1072
1220
  }, {
1073
- internalType: "bytes",
1074
- name: "frameworkData",
1075
- type: "bytes"
1221
+ internalType: "uint256",
1222
+ name: "mintingFee",
1223
+ type: "uint256"
1224
+ }, {
1225
+ internalType: "uint256",
1226
+ name: "expiration",
1227
+ type: "uint256"
1228
+ }, {
1229
+ internalType: "bool",
1230
+ name: "commercialUse",
1231
+ type: "bool"
1232
+ }, {
1233
+ internalType: "bool",
1234
+ name: "commercialAttribution",
1235
+ type: "bool"
1076
1236
  }, {
1077
1237
  internalType: "address",
1078
- name: "royaltyPolicy",
1238
+ name: "commercializerChecker",
1079
1239
  type: "address"
1080
1240
  }, {
1081
1241
  internalType: "bytes",
1082
- name: "royaltyData",
1242
+ name: "commercializerCheckerData",
1083
1243
  type: "bytes"
1244
+ }, {
1245
+ internalType: "uint32",
1246
+ name: "commercialRevShare",
1247
+ type: "uint32"
1084
1248
  }, {
1085
1249
  internalType: "uint256",
1086
- name: "mintingFee",
1250
+ name: "commercialRevCelling",
1251
+ type: "uint256"
1252
+ }, {
1253
+ internalType: "bool",
1254
+ name: "derivativesAllowed",
1255
+ type: "bool"
1256
+ }, {
1257
+ internalType: "bool",
1258
+ name: "derivativesAttribution",
1259
+ type: "bool"
1260
+ }, {
1261
+ internalType: "bool",
1262
+ name: "derivativesApproval",
1263
+ type: "bool"
1264
+ }, {
1265
+ internalType: "bool",
1266
+ name: "derivativesReciprocal",
1267
+ type: "bool"
1268
+ }, {
1269
+ internalType: "uint256",
1270
+ name: "derivativeRevCelling",
1087
1271
  type: "uint256"
1088
1272
  }, {
1089
1273
  internalType: "address",
1090
- name: "mintingFeeToken",
1274
+ name: "currency",
1091
1275
  type: "address"
1092
1276
  }],
1093
- internalType: "struct Licensing.Policy",
1094
- name: "pol",
1277
+ internalType: "struct PILTerms",
1278
+ name: "terms",
1095
1279
  type: "tuple"
1096
1280
  }],
1097
- name: "registerPolicy",
1281
+ name: "getLicenseTermsId",
1098
1282
  outputs: [{
1099
1283
  internalType: "uint256",
1100
- name: "policyId",
1284
+ name: "selectedLicenseTermsId",
1101
1285
  type: "uint256"
1102
1286
  }],
1103
- stateMutability: "nonpayable",
1287
+ stateMutability: "view",
1104
1288
  type: "function"
1105
- }];
1106
-
1107
- var PILPolicyFrameworkManagerABI = [{
1289
+ }, {
1108
1290
  inputs: [{
1109
1291
  components: [{
1110
1292
  internalType: "bool",
@@ -1118,148 +1300,219 @@ var PILPolicyFrameworkManagerABI = [{
1118
1300
  internalType: "uint256",
1119
1301
  name: "mintingFee",
1120
1302
  type: "uint256"
1303
+ }, {
1304
+ internalType: "uint256",
1305
+ name: "expiration",
1306
+ type: "uint256"
1307
+ }, {
1308
+ internalType: "bool",
1309
+ name: "commercialUse",
1310
+ type: "bool"
1311
+ }, {
1312
+ internalType: "bool",
1313
+ name: "commercialAttribution",
1314
+ type: "bool"
1121
1315
  }, {
1122
1316
  internalType: "address",
1123
- name: "mintingFeeToken",
1317
+ name: "commercializerChecker",
1124
1318
  type: "address"
1125
1319
  }, {
1126
- components: [{
1127
- internalType: "bool",
1128
- name: "attribution",
1129
- type: "bool"
1130
- }, {
1131
- internalType: "bool",
1132
- name: "commercialUse",
1133
- type: "bool"
1134
- }, {
1135
- internalType: "bool",
1136
- name: "commercialAttribution",
1137
- type: "bool"
1138
- }, {
1139
- internalType: "address",
1140
- name: "commercializerChecker",
1141
- type: "address"
1142
- }, {
1143
- internalType: "bytes",
1144
- name: "commercializerCheckerData",
1145
- type: "bytes"
1146
- }, {
1147
- internalType: "uint32",
1148
- name: "commercialRevShare",
1149
- type: "uint32"
1150
- }, {
1151
- internalType: "bool",
1152
- name: "derivativesAllowed",
1153
- type: "bool"
1154
- }, {
1155
- internalType: "bool",
1156
- name: "derivativesAttribution",
1157
- type: "bool"
1158
- }, {
1159
- internalType: "bool",
1160
- name: "derivativesApproval",
1161
- type: "bool"
1162
- }, {
1163
- internalType: "bool",
1164
- name: "derivativesReciprocal",
1165
- type: "bool"
1166
- }, {
1167
- internalType: "string[]",
1168
- name: "territories",
1169
- type: "string[]"
1170
- }, {
1171
- internalType: "string[]",
1172
- name: "distributionChannels",
1173
- type: "string[]"
1174
- }, {
1175
- internalType: "string[]",
1176
- name: "contentRestrictions",
1177
- type: "string[]"
1178
- }],
1179
- internalType: "struct PILPolicy",
1180
- name: "policy",
1181
- type: "tuple"
1320
+ internalType: "bytes",
1321
+ name: "commercializerCheckerData",
1322
+ type: "bytes"
1323
+ }, {
1324
+ internalType: "uint32",
1325
+ name: "commercialRevShare",
1326
+ type: "uint32"
1327
+ }, {
1328
+ internalType: "uint256",
1329
+ name: "commercialRevCelling",
1330
+ type: "uint256"
1331
+ }, {
1332
+ internalType: "bool",
1333
+ name: "derivativesAllowed",
1334
+ type: "bool"
1335
+ }, {
1336
+ internalType: "bool",
1337
+ name: "derivativesAttribution",
1338
+ type: "bool"
1339
+ }, {
1340
+ internalType: "bool",
1341
+ name: "derivativesApproval",
1342
+ type: "bool"
1343
+ }, {
1344
+ internalType: "bool",
1345
+ name: "derivativesReciprocal",
1346
+ type: "bool"
1347
+ }, {
1348
+ internalType: "uint256",
1349
+ name: "derivativeRevCelling",
1350
+ type: "uint256"
1351
+ }, {
1352
+ internalType: "address",
1353
+ name: "currency",
1354
+ type: "address"
1182
1355
  }],
1183
- internalType: "struct RegisterPILPolicyParams",
1184
- name: "params",
1356
+ internalType: "struct PILTerms",
1357
+ name: "terms",
1185
1358
  type: "tuple"
1186
1359
  }],
1187
- name: "registerPolicy",
1360
+ name: "registerLicenseTerms",
1188
1361
  outputs: [{
1189
1362
  internalType: "uint256",
1190
- name: "policyId",
1363
+ name: "selectedLicenseTermsId",
1191
1364
  type: "uint256"
1192
1365
  }],
1193
1366
  stateMutability: "nonpayable",
1194
1367
  type: "function"
1195
1368
  }];
1196
1369
 
1197
- var RegistrationModuleABI = [{
1370
+ var IRoyaltyPolicyLAPABI = [{
1198
1371
  inputs: [{
1199
- internalType: "uint256[]",
1200
- name: "licenseIds",
1201
- type: "uint256[]"
1372
+ internalType: "address",
1373
+ name: "ipId",
1374
+ type: "address"
1375
+ }],
1376
+ name: "getRoyaltyData",
1377
+ outputs: [{
1378
+ internalType: "bool",
1379
+ name: "",
1380
+ type: "bool"
1202
1381
  }, {
1203
1382
  internalType: "address",
1204
- name: "tokenContract",
1383
+ name: "",
1205
1384
  type: "address"
1206
1385
  }, {
1207
- internalType: "uint256",
1208
- name: "tokenId",
1209
- type: "uint256"
1386
+ internalType: "uint32",
1387
+ name: "",
1388
+ type: "uint32"
1210
1389
  }, {
1211
- internalType: "string",
1212
- name: "ipName",
1213
- type: "string"
1390
+ internalType: "address[]",
1391
+ name: "",
1392
+ type: "address[]"
1214
1393
  }, {
1215
- internalType: "bytes32",
1216
- name: "contentHash",
1217
- type: "bytes32"
1394
+ internalType: "uint32[]",
1395
+ name: "",
1396
+ type: "uint32[]"
1397
+ }],
1398
+ stateMutability: "view",
1399
+ type: "function"
1400
+ }, {
1401
+ inputs: [{
1402
+ internalType: "address",
1403
+ name: "caller",
1404
+ type: "address"
1218
1405
  }, {
1219
- internalType: "string",
1220
- name: "externalURL",
1221
- type: "string"
1406
+ internalType: "address",
1407
+ name: "ipId",
1408
+ type: "address"
1222
1409
  }, {
1223
- internalType: "bytes",
1224
- name: "royaltyContext",
1225
- type: "bytes"
1410
+ internalType: "address",
1411
+ name: "token",
1412
+ type: "address"
1413
+ }, {
1414
+ internalType: "uint256",
1415
+ name: "amount",
1416
+ type: "uint256"
1226
1417
  }],
1227
- name: "registerDerivativeIp",
1418
+ name: "onRoyaltyPayment",
1419
+ outputs: [],
1420
+ stateMutability: "nonpayable",
1421
+ type: "function"
1422
+ }];
1423
+
1424
+ var IpRoyaltyVaultABI = [{
1425
+ inputs: [{
1426
+ internalType: "uint256[]",
1427
+ name: "snapshotIds",
1428
+ type: "uint256[]"
1429
+ }, {
1430
+ internalType: "address",
1431
+ name: "token",
1432
+ type: "address"
1433
+ }],
1434
+ name: "claimRevenueBySnapshotBatch",
1228
1435
  outputs: [],
1229
1436
  stateMutability: "nonpayable",
1230
1437
  type: "function"
1231
1438
  }, {
1232
1439
  inputs: [{
1233
1440
  internalType: "uint256",
1234
- name: "policyId",
1441
+ name: "snapshotId",
1235
1442
  type: "uint256"
1236
1443
  }, {
1444
+ internalType: "address[]",
1445
+ name: "tokens",
1446
+ type: "address[]"
1447
+ }],
1448
+ name: "claimRevenueByTokenBatch",
1449
+ outputs: [],
1450
+ stateMutability: "nonpayable",
1451
+ type: "function"
1452
+ }, {
1453
+ inputs: [{
1237
1454
  internalType: "address",
1238
- name: "tokenContract",
1455
+ name: "account",
1239
1456
  type: "address"
1240
1457
  }, {
1241
1458
  internalType: "uint256",
1242
- name: "tokenId",
1459
+ name: "snapshotId",
1243
1460
  type: "uint256"
1244
1461
  }, {
1245
- internalType: "string",
1246
- name: "ipName",
1247
- type: "string"
1248
- }, {
1249
- internalType: "bytes32",
1250
- name: "contentHash",
1251
- type: "bytes32"
1252
- }, {
1253
- internalType: "string",
1254
- name: "externalURL",
1255
- type: "string"
1462
+ internalType: "address",
1463
+ name: "token",
1464
+ type: "address"
1256
1465
  }],
1257
- name: "registerRootIp",
1466
+ name: "claimableRevenue",
1467
+ outputs: [{
1468
+ internalType: "uint256",
1469
+ name: "",
1470
+ type: "uint256"
1471
+ }],
1472
+ stateMutability: "view",
1473
+ type: "function"
1474
+ }, {
1475
+ inputs: [{
1476
+ internalType: "address",
1477
+ name: "ancestorIpId",
1478
+ type: "address"
1479
+ }],
1480
+ name: "collectRoyaltyTokens",
1481
+ outputs: [],
1482
+ stateMutability: "nonpayable",
1483
+ type: "function"
1484
+ }, {
1485
+ inputs: [],
1486
+ name: "ipId",
1258
1487
  outputs: [{
1259
1488
  internalType: "address",
1260
1489
  name: "",
1261
1490
  type: "address"
1262
1491
  }],
1492
+ stateMutability: "view",
1493
+ type: "function"
1494
+ }];
1495
+
1496
+ var IRoyaltyModuleABI = [{
1497
+ inputs: [{
1498
+ internalType: "address",
1499
+ name: "receiverIpId",
1500
+ type: "address"
1501
+ }, {
1502
+ internalType: "address",
1503
+ name: "payerIpId",
1504
+ type: "address"
1505
+ }, {
1506
+ internalType: "address",
1507
+ name: "token",
1508
+ type: "address"
1509
+ }, {
1510
+ internalType: "uint256",
1511
+ name: "amount",
1512
+ type: "uint256"
1513
+ }],
1514
+ name: "payRoyaltyOnBehalf",
1515
+ outputs: [],
1263
1516
  stateMutability: "nonpayable",
1264
1517
  type: "function"
1265
1518
  }];
@@ -1284,6 +1537,18 @@ var ErrorsABI = [{
1284
1537
  inputs: [],
1285
1538
  name: "AccessControlled__ZeroAddress",
1286
1539
  type: "error"
1540
+ }, {
1541
+ inputs: [{
1542
+ internalType: "address",
1543
+ name: "signer",
1544
+ type: "address"
1545
+ }, {
1546
+ internalType: "address",
1547
+ name: "to",
1548
+ type: "address"
1549
+ }],
1550
+ name: "AccessController__BothCallerAndRecipientAreNotRegisteredModule",
1551
+ type: "error"
1287
1552
  }, {
1288
1553
  inputs: [],
1289
1554
  name: "AccessController__CallerIsNotIPAccount",
@@ -1324,241 +1589,485 @@ var ErrorsABI = [{
1324
1589
  inputs: [],
1325
1590
  name: "AccessController__PermissionIsNotValid",
1326
1591
  type: "error"
1592
+ }, {
1593
+ inputs: [],
1594
+ name: "AccessController__SignerIsZeroAddress",
1595
+ type: "error"
1596
+ }, {
1597
+ inputs: [],
1598
+ name: "ArbitrationPolicySP__NotDisputeModule",
1599
+ type: "error"
1600
+ }, {
1601
+ inputs: [],
1602
+ name: "ArbitrationPolicySP__ZeroDisputeModule",
1603
+ type: "error"
1604
+ }, {
1605
+ inputs: [],
1606
+ name: "ArbitrationPolicySP__ZeroPaymentToken",
1607
+ type: "error"
1608
+ }, {
1609
+ inputs: [],
1610
+ name: "BasePolicyFrameworkManager__CallerNotLicensingModule",
1611
+ type: "error"
1612
+ }, {
1613
+ inputs: [],
1614
+ name: "CoreMetadataModule__MetadataAlreadyFrozen",
1615
+ type: "error"
1616
+ }, {
1617
+ inputs: [],
1618
+ name: "DisputeModule__NotAbleToResolve",
1619
+ type: "error"
1620
+ }, {
1621
+ inputs: [],
1622
+ name: "DisputeModule__NotDisputeInitiator",
1623
+ type: "error"
1624
+ }, {
1625
+ inputs: [],
1626
+ name: "DisputeModule__NotInDisputeState",
1627
+ type: "error"
1628
+ }, {
1629
+ inputs: [],
1630
+ name: "DisputeModule__NotRegisteredIpId",
1631
+ type: "error"
1632
+ }, {
1633
+ inputs: [],
1634
+ name: "DisputeModule__NotWhitelistedArbitrationPolicy",
1635
+ type: "error"
1636
+ }, {
1637
+ inputs: [],
1638
+ name: "DisputeModule__NotWhitelistedArbitrationRelayer",
1639
+ type: "error"
1640
+ }, {
1641
+ inputs: [],
1642
+ name: "DisputeModule__NotWhitelistedDisputeTag",
1643
+ type: "error"
1644
+ }, {
1645
+ inputs: [],
1646
+ name: "DisputeModule__ZeroArbitrationPolicy",
1647
+ type: "error"
1648
+ }, {
1649
+ inputs: [],
1650
+ name: "DisputeModule__ZeroArbitrationRelayer",
1651
+ type: "error"
1652
+ }, {
1653
+ inputs: [],
1654
+ name: "DisputeModule__ZeroDisputeTag",
1655
+ type: "error"
1656
+ }, {
1657
+ inputs: [],
1658
+ name: "DisputeModule__ZeroLinkToDisputeEvidence",
1659
+ type: "error"
1660
+ }, {
1661
+ inputs: [],
1662
+ name: "Governance__InconsistentState",
1663
+ type: "error"
1664
+ }, {
1665
+ inputs: [],
1666
+ name: "Governance__NewStateIsTheSameWithOldState",
1667
+ type: "error"
1668
+ }, {
1669
+ inputs: [],
1670
+ name: "Governance__OnlyProtocolAdmin",
1671
+ type: "error"
1672
+ }, {
1673
+ inputs: [],
1674
+ name: "Governance__ProtocolPaused",
1675
+ type: "error"
1327
1676
  }, {
1328
1677
  inputs: [{
1329
- internalType: "address",
1330
- name: "to",
1331
- type: "address"
1678
+ internalType: "string",
1679
+ name: "interfaceName",
1680
+ type: "string"
1332
1681
  }],
1333
- name: "AccessController__RecipientIsNotRegisteredModule",
1682
+ name: "Governance__UnsupportedInterface",
1334
1683
  type: "error"
1335
1684
  }, {
1336
1685
  inputs: [],
1337
- name: "AccessController__SignerIsZeroAddress",
1686
+ name: "Governance__ZeroAddress",
1338
1687
  type: "error"
1339
1688
  }, {
1340
1689
  inputs: [],
1341
- name: "AncestorsVaultLAP__AlreadyClaimed",
1690
+ name: "IPAccountRegistry_InvalidIpAccountImpl",
1342
1691
  type: "error"
1343
1692
  }, {
1344
1693
  inputs: [],
1345
- name: "AncestorsVaultLAP__ClaimerNotAnAncestor",
1694
+ name: "IPAccount__ExpiredSignature",
1346
1695
  type: "error"
1347
1696
  }, {
1348
1697
  inputs: [],
1349
- name: "AncestorsVaultLAP__ERC20BalanceNotZero",
1698
+ name: "IPAccount__InvalidAccessController",
1350
1699
  type: "error"
1351
1700
  }, {
1352
1701
  inputs: [],
1353
- name: "AncestorsVaultLAP__ETHBalanceNotZero",
1702
+ name: "IPAccount__InvalidCalldata",
1354
1703
  type: "error"
1355
1704
  }, {
1356
1705
  inputs: [],
1357
- name: "AncestorsVaultLAP__InvalidAncestorsHash",
1706
+ name: "IPAccount__InvalidSignature",
1358
1707
  type: "error"
1359
1708
  }, {
1360
1709
  inputs: [],
1361
- name: "AncestorsVaultLAP__InvalidClaimer",
1710
+ name: "IPAccount__InvalidSigner",
1362
1711
  type: "error"
1363
1712
  }, {
1364
1713
  inputs: [],
1365
- name: "AncestorsVaultLAP__TransferFailed",
1714
+ name: "IPAssetRegistry__AlreadyRegistered",
1366
1715
  type: "error"
1367
1716
  }, {
1368
1717
  inputs: [],
1369
- name: "AncestorsVaultLAP__ZeroRoyaltyPolicyLAP",
1718
+ name: "IPAssetRegistry__IPAccountAlreadyCreated",
1370
1719
  type: "error"
1371
1720
  }, {
1372
1721
  inputs: [],
1373
- name: "ArbitrationPolicySP__NotDisputeModule",
1722
+ name: "IPAssetRegistry__InvalidAccount",
1723
+ type: "error"
1724
+ }, {
1725
+ inputs: [],
1726
+ name: "IPAssetRegistry__InvalidMetadataProvider",
1727
+ type: "error"
1728
+ }, {
1729
+ inputs: [{
1730
+ internalType: "address",
1731
+ name: "contractAddress",
1732
+ type: "address"
1733
+ }, {
1734
+ internalType: "uint256",
1735
+ name: "tokenId",
1736
+ type: "uint256"
1737
+ }],
1738
+ name: "IPAssetRegistry__InvalidToken",
1739
+ type: "error"
1740
+ }, {
1741
+ inputs: [],
1742
+ name: "IPAssetRegistry__NotYetRegistered",
1743
+ type: "error"
1744
+ }, {
1745
+ inputs: [],
1746
+ name: "IPAssetRegistry__RegistrantUnauthorized",
1747
+ type: "error"
1748
+ }, {
1749
+ inputs: [],
1750
+ name: "IPAssetRegistry__ResolverInvalid",
1751
+ type: "error"
1752
+ }, {
1753
+ inputs: [],
1754
+ name: "IPAssetRegistry__Unauthorized",
1374
1755
  type: "error"
1375
1756
  }, {
1376
- inputs: [],
1377
- name: "ArbitrationPolicySP__ZeroDisputeModule",
1757
+ inputs: [{
1758
+ internalType: "address",
1759
+ name: "contractAddress",
1760
+ type: "address"
1761
+ }],
1762
+ name: "IPAssetRegistry__UnsupportedIERC721",
1378
1763
  type: "error"
1379
1764
  }, {
1380
- inputs: [],
1381
- name: "ArbitrationPolicySP__ZeroPaymentToken",
1765
+ inputs: [{
1766
+ internalType: "address",
1767
+ name: "contractAddress",
1768
+ type: "address"
1769
+ }],
1770
+ name: "IPAssetRegistry__UnsupportedIERC721Metadata",
1382
1771
  type: "error"
1383
1772
  }, {
1384
1773
  inputs: [],
1385
- name: "DisputeModule__NotAbleToResolve",
1774
+ name: "IPResolver_InvalidIP",
1386
1775
  type: "error"
1387
1776
  }, {
1388
1777
  inputs: [],
1389
- name: "DisputeModule__NotDisputeInitiator",
1778
+ name: "IPResolver_Unauthorized",
1390
1779
  type: "error"
1391
1780
  }, {
1392
1781
  inputs: [],
1393
- name: "DisputeModule__NotInDisputeState",
1782
+ name: "IpRoyaltyVault__AlreadyClaimed",
1394
1783
  type: "error"
1395
1784
  }, {
1396
1785
  inputs: [],
1397
- name: "DisputeModule__NotRegisteredIpId",
1786
+ name: "IpRoyaltyVault__ClaimerNotAnAncestor",
1398
1787
  type: "error"
1399
1788
  }, {
1400
1789
  inputs: [],
1401
- name: "DisputeModule__NotWhitelistedArbitrationPolicy",
1790
+ name: "IpRoyaltyVault__IpTagged",
1402
1791
  type: "error"
1403
1792
  }, {
1404
1793
  inputs: [],
1405
- name: "DisputeModule__NotWhitelistedArbitrationRelayer",
1794
+ name: "IpRoyaltyVault__NotRoyaltyPolicyLAP",
1406
1795
  type: "error"
1407
1796
  }, {
1408
1797
  inputs: [],
1409
- name: "DisputeModule__NotWhitelistedDisputeTag",
1798
+ name: "IpRoyaltyVault__SnapshotIntervalTooShort",
1410
1799
  type: "error"
1411
1800
  }, {
1412
1801
  inputs: [],
1413
- name: "DisputeModule__UnauthorizedAccess",
1802
+ name: "IpRoyaltyVault__ZeroDisputeModule",
1414
1803
  type: "error"
1415
1804
  }, {
1416
1805
  inputs: [],
1417
- name: "DisputeModule__ZeroArbitrationPolicy",
1806
+ name: "IpRoyaltyVault__ZeroIpId",
1418
1807
  type: "error"
1419
1808
  }, {
1420
1809
  inputs: [],
1421
- name: "DisputeModule__ZeroArbitrationRelayer",
1810
+ name: "IpRoyaltyVault__ZeroRoyaltyPolicyLAP",
1422
1811
  type: "error"
1423
1812
  }, {
1424
1813
  inputs: [],
1425
- name: "DisputeModule__ZeroDisputeTag",
1814
+ name: "LicenseRegistry__CallerNotLicensingModule",
1426
1815
  type: "error"
1427
1816
  }, {
1428
- inputs: [],
1429
- name: "DisputeModule__ZeroLinkToDisputeEvidence",
1817
+ inputs: [{
1818
+ internalType: "address",
1819
+ name: "childIpId",
1820
+ type: "address"
1821
+ }],
1822
+ name: "LicenseRegistry__DerivativeAlreadyRegistered",
1430
1823
  type: "error"
1431
1824
  }, {
1432
- inputs: [],
1433
- name: "Governance__InconsistentState",
1825
+ inputs: [{
1826
+ internalType: "address",
1827
+ name: "childIpId",
1828
+ type: "address"
1829
+ }],
1830
+ name: "LicenseRegistry__DerivativeIpAlreadyHasLicense",
1434
1831
  type: "error"
1435
1832
  }, {
1436
- inputs: [],
1437
- name: "Governance__NewStateIsTheSameWithOldState",
1833
+ inputs: [{
1834
+ internalType: "address",
1835
+ name: "ipId",
1836
+ type: "address"
1837
+ }],
1838
+ name: "LicenseRegistry__DerivativeIsParent",
1438
1839
  type: "error"
1439
1840
  }, {
1440
- inputs: [],
1441
- name: "Governance__OnlyProtocolAdmin",
1841
+ inputs: [{
1842
+ internalType: "address",
1843
+ name: "ipId",
1844
+ type: "address"
1845
+ }, {
1846
+ internalType: "uint256",
1847
+ name: "index",
1848
+ type: "uint256"
1849
+ }, {
1850
+ internalType: "uint256",
1851
+ name: "length",
1852
+ type: "uint256"
1853
+ }],
1854
+ name: "LicenseRegistry__IndexOutOfBounds",
1442
1855
  type: "error"
1443
1856
  }, {
1444
- inputs: [],
1445
- name: "Governance__ProtocolPaused",
1857
+ inputs: [{
1858
+ internalType: "address",
1859
+ name: "ipId",
1860
+ type: "address"
1861
+ }],
1862
+ name: "LicenseRegistry__IpExpired",
1446
1863
  type: "error"
1447
1864
  }, {
1448
1865
  inputs: [{
1449
- internalType: "string",
1450
- name: "interfaceName",
1451
- type: "string"
1866
+ internalType: "address",
1867
+ name: "licenseTemplate",
1868
+ type: "address"
1869
+ }, {
1870
+ internalType: "uint256",
1871
+ name: "licenseTermsId",
1872
+ type: "uint256"
1452
1873
  }],
1453
- name: "Governance__UnsupportedInterface",
1874
+ name: "LicenseRegistry__LicenseTermsNotExists",
1454
1875
  type: "error"
1455
1876
  }, {
1456
1877
  inputs: [],
1457
- name: "Governance__ZeroAddress",
1878
+ name: "LicenseRegistry__NoParentIp",
1458
1879
  type: "error"
1459
1880
  }, {
1460
- inputs: [],
1461
- name: "IPAccountRegistry_InvalidIpAccountImpl",
1881
+ inputs: [{
1882
+ internalType: "address",
1883
+ name: "licenseTemplate",
1884
+ type: "address"
1885
+ }],
1886
+ name: "LicenseRegistry__NotLicenseTemplate",
1462
1887
  type: "error"
1463
1888
  }, {
1464
1889
  inputs: [],
1465
- name: "IPAccount__ExpiredSignature",
1890
+ name: "LicenseRegistry__NotTransferable",
1466
1891
  type: "error"
1467
1892
  }, {
1468
- inputs: [],
1469
- name: "IPAccount__InvalidAccessController",
1893
+ inputs: [{
1894
+ internalType: "address",
1895
+ name: "ipId",
1896
+ type: "address"
1897
+ }],
1898
+ name: "LicenseRegistry__ParentIpExpired",
1470
1899
  type: "error"
1471
1900
  }, {
1472
- inputs: [],
1473
- name: "IPAccount__InvalidCalldata",
1901
+ inputs: [{
1902
+ internalType: "address",
1903
+ name: "ipId",
1904
+ type: "address"
1905
+ }, {
1906
+ internalType: "uint256",
1907
+ name: "licenseTermsId",
1908
+ type: "uint256"
1909
+ }],
1910
+ name: "LicenseRegistry__ParentIpHasNoLicenseTerms",
1474
1911
  type: "error"
1475
1912
  }, {
1476
- inputs: [],
1477
- name: "IPAccount__InvalidSignature",
1913
+ inputs: [{
1914
+ internalType: "address",
1915
+ name: "ipId",
1916
+ type: "address"
1917
+ }],
1918
+ name: "LicenseRegistry__ParentIpTagged",
1478
1919
  type: "error"
1479
1920
  }, {
1480
- inputs: [],
1481
- name: "IPAccount__InvalidSigner",
1921
+ inputs: [{
1922
+ internalType: "address",
1923
+ name: "ipId",
1924
+ type: "address"
1925
+ }, {
1926
+ internalType: "address",
1927
+ name: "licenseTemplate",
1928
+ type: "address"
1929
+ }],
1930
+ name: "LicenseRegistry__ParentIpUnmachedLicenseTemplate",
1482
1931
  type: "error"
1483
1932
  }, {
1484
- inputs: [],
1485
- name: "IPAssetRegistry__AlreadyRegistered",
1933
+ inputs: [{
1934
+ internalType: "address",
1935
+ name: "licenseTemplate",
1936
+ type: "address"
1937
+ }],
1938
+ name: "LicenseRegistry__UnregisteredLicenseTemplate",
1486
1939
  type: "error"
1487
1940
  }, {
1488
1941
  inputs: [],
1489
- name: "IPAssetRegistry__IPAccountAlreadyCreated",
1942
+ name: "LicenseRegistry__ZeroDisputeModule",
1490
1943
  type: "error"
1491
1944
  }, {
1492
1945
  inputs: [],
1493
- name: "IPAssetRegistry__InvalidAccount",
1946
+ name: "LicenseRegistry__ZeroLicensingModule",
1494
1947
  type: "error"
1495
1948
  }, {
1496
- inputs: [],
1497
- name: "IPAssetRegistry__InvalidMetadataProvider",
1949
+ inputs: [{
1950
+ internalType: "address",
1951
+ name: "licenseTemplate",
1952
+ type: "address"
1953
+ }, {
1954
+ internalType: "address",
1955
+ name: "anotherLicenseTemplate",
1956
+ type: "address"
1957
+ }],
1958
+ name: "LicenseToken__AllLicenseTokensMustFromSameLicenseTemplate",
1498
1959
  type: "error"
1499
1960
  }, {
1500
1961
  inputs: [],
1501
- name: "IPAssetRegistry__NotYetRegistered",
1962
+ name: "LicenseToken__CallerNotLicensingModule",
1502
1963
  type: "error"
1503
1964
  }, {
1504
- inputs: [],
1505
- name: "IPAssetRegistry__RegistrantUnauthorized",
1965
+ inputs: [{
1966
+ internalType: "uint256",
1967
+ name: "tokenId",
1968
+ type: "uint256"
1969
+ }, {
1970
+ internalType: "uint256",
1971
+ name: "expiredAt",
1972
+ type: "uint256"
1973
+ }, {
1974
+ internalType: "uint256",
1975
+ name: "currentTimestamp",
1976
+ type: "uint256"
1977
+ }],
1978
+ name: "LicenseToken__LicenseTokenExpired",
1506
1979
  type: "error"
1507
1980
  }, {
1508
- inputs: [],
1509
- name: "IPAssetRegistry__ResolverInvalid",
1981
+ inputs: [{
1982
+ internalType: "uint256",
1983
+ name: "tokenId",
1984
+ type: "uint256"
1985
+ }, {
1986
+ internalType: "address",
1987
+ name: "iPowner",
1988
+ type: "address"
1989
+ }, {
1990
+ internalType: "address",
1991
+ name: "tokenOwner",
1992
+ type: "address"
1993
+ }],
1994
+ name: "LicenseToken__NotLicenseTokenOwner",
1510
1995
  type: "error"
1511
1996
  }, {
1512
1997
  inputs: [],
1513
- name: "IPAssetRegistry__Unauthorized",
1998
+ name: "LicenseToken__NotTransferable",
1514
1999
  type: "error"
1515
2000
  }, {
1516
- inputs: [],
1517
- name: "IPResolver_InvalidIP",
2001
+ inputs: [{
2002
+ internalType: "uint256",
2003
+ name: "tokenId",
2004
+ type: "uint256"
2005
+ }],
2006
+ name: "LicenseToken__RevokedLicense",
1518
2007
  type: "error"
1519
2008
  }, {
1520
2009
  inputs: [],
1521
- name: "IPResolver_Unauthorized",
2010
+ name: "LicenseToken__ZeroDisputeModule",
1522
2011
  type: "error"
1523
2012
  }, {
1524
2013
  inputs: [],
1525
- name: "LicenseRegistry__CallerNotLicensingModule",
2014
+ name: "LicenseToken__ZeroLicensingModule",
1526
2015
  type: "error"
1527
2016
  }, {
1528
2017
  inputs: [],
1529
- name: "LicenseRegistry__NotTransferable",
2018
+ name: "LicensingModule__CallerNotLicenseRegistry",
1530
2019
  type: "error"
1531
2020
  }, {
1532
- inputs: [],
1533
- name: "LicenseRegistry__RevokedLicense",
2021
+ inputs: [{
2022
+ internalType: "address",
2023
+ name: "caller",
2024
+ type: "address"
2025
+ }, {
2026
+ internalType: "address",
2027
+ name: "licensorIpId",
2028
+ type: "address"
2029
+ }, {
2030
+ internalType: "address",
2031
+ name: "licenseTemplate",
2032
+ type: "address"
2033
+ }, {
2034
+ internalType: "uint256",
2035
+ name: "licenseTermsId",
2036
+ type: "uint256"
2037
+ }],
2038
+ name: "LicensingModule__CallerNotLicensorAndIpHasNotAttachedLicenseTerms",
1534
2039
  type: "error"
1535
2040
  }, {
1536
2041
  inputs: [],
1537
- name: "LicenseRegistry__ZeroDisputeModule",
2042
+ name: "LicensingModule__CallerNotLicensorAndPolicyNotSet",
1538
2043
  type: "error"
1539
2044
  }, {
1540
2045
  inputs: [],
1541
- name: "LicenseRegistry__ZeroLicensingModule",
2046
+ name: "LicensingModule__CommercialTermInNonCommercialPolicy",
1542
2047
  type: "error"
1543
2048
  }, {
1544
- inputs: [],
1545
- name: "LicensingModuleAware__CallerNotLicensingModule",
2049
+ inputs: [{
2050
+ internalType: "address",
2051
+ name: "ipId",
2052
+ type: "address"
2053
+ }],
2054
+ name: "LicensingModule__DerivativeAlreadyHasLicenseTerms",
1546
2055
  type: "error"
1547
2056
  }, {
1548
2057
  inputs: [],
1549
- name: "LicensingModule__CallerNotLicenseRegistry",
2058
+ name: "LicensingModule__DerivativeAlreadyRegistered",
1550
2059
  type: "error"
1551
2060
  }, {
1552
2061
  inputs: [],
1553
- name: "LicensingModule__CallerNotLicensorAndPolicyNotSet",
2062
+ name: "LicensingModule__DerivativeIsParent",
1554
2063
  type: "error"
1555
2064
  }, {
1556
2065
  inputs: [],
1557
- name: "LicensingModule__CommercialTermInNonCommercialPolicy",
2066
+ name: "LicensingModule__DerivativeRevShareSumExceedsMaxRNFTSupply",
1558
2067
  type: "error"
1559
2068
  }, {
1560
2069
  inputs: [],
1561
- name: "LicensingModule__DerivativeRevShareSumExceedsMaxRNFTSupply",
2070
+ name: "LicensingModule__DerivativesCannotAddLicenseTerms",
1562
2071
  type: "error"
1563
2072
  }, {
1564
2073
  inputs: [],
@@ -1582,11 +2091,19 @@ var ErrorsABI = [{
1582
2091
  type: "error"
1583
2092
  }, {
1584
2093
  inputs: [],
1585
- name: "LicensingModule__IncompatibleLicensorCommercialPolicy",
2094
+ name: "LicensingModule__IncompatibleLicensorRoyaltyDerivativeRevShare",
1586
2095
  type: "error"
1587
2096
  }, {
1588
- inputs: [],
1589
- name: "LicensingModule__IncompatibleLicensorRoyaltyDerivativeRevShare",
2097
+ inputs: [{
2098
+ internalType: "address",
2099
+ name: "royaltyPolicy",
2100
+ type: "address"
2101
+ }, {
2102
+ internalType: "address",
2103
+ name: "anotherRoyaltyPolicy",
2104
+ type: "address"
2105
+ }],
2106
+ name: "LicensingModule__IncompatibleRoyaltyPolicy",
1590
2107
  type: "error"
1591
2108
  }, {
1592
2109
  inputs: [],
@@ -1604,6 +2121,54 @@ var ErrorsABI = [{
1604
2121
  inputs: [],
1605
2122
  name: "LicensingModule__InvalidPolicyFramework",
1606
2123
  type: "error"
2124
+ }, {
2125
+ inputs: [],
2126
+ name: "LicensingModule__IpAlreadyLinked",
2127
+ type: "error"
2128
+ }, {
2129
+ inputs: [{
2130
+ internalType: "address",
2131
+ name: "childIpId",
2132
+ type: "address"
2133
+ }],
2134
+ name: "LicensingModule__LicenseNotCompatibleForDerivative",
2135
+ type: "error"
2136
+ }, {
2137
+ inputs: [{
2138
+ internalType: "uint256",
2139
+ name: "ipLength",
2140
+ type: "uint256"
2141
+ }, {
2142
+ internalType: "uint256",
2143
+ name: "licenseTermsLength",
2144
+ type: "uint256"
2145
+ }],
2146
+ name: "LicensingModule__LicenseTermsLengthMismatch",
2147
+ type: "error"
2148
+ }, {
2149
+ inputs: [{
2150
+ internalType: "address",
2151
+ name: "licenseTemplate",
2152
+ type: "address"
2153
+ }, {
2154
+ internalType: "uint256",
2155
+ name: "licenseTermsId",
2156
+ type: "uint256"
2157
+ }],
2158
+ name: "LicensingModule__LicenseTermsNotFound",
2159
+ type: "error"
2160
+ }, {
2161
+ inputs: [{
2162
+ internalType: "address",
2163
+ name: "childIpId",
2164
+ type: "address"
2165
+ }, {
2166
+ internalType: "uint256[]",
2167
+ name: "licenseTokenIds",
2168
+ type: "uint256[]"
2169
+ }],
2170
+ name: "LicensingModule__LicenseTokenNotCompatibleForDerivative",
2171
+ type: "error"
1607
2172
  }, {
1608
2173
  inputs: [],
1609
2174
  name: "LicensingModule__LicensorDoesntHaveThisPolicy",
@@ -1620,6 +2185,10 @@ var ErrorsABI = [{
1620
2185
  inputs: [],
1621
2186
  name: "LicensingModule__LinkingRevokedLicense",
1622
2187
  type: "error"
2188
+ }, {
2189
+ inputs: [],
2190
+ name: "LicensingModule__MintAmountZero",
2191
+ type: "error"
1623
2192
  }, {
1624
2193
  inputs: [],
1625
2194
  name: "LicensingModule__MintLicenseParamFailed",
@@ -1632,6 +2201,14 @@ var ErrorsABI = [{
1632
2201
  inputs: [],
1633
2202
  name: "LicensingModule__MismatchBetweenRoyaltyPolicy",
1634
2203
  type: "error"
2204
+ }, {
2205
+ inputs: [],
2206
+ name: "LicensingModule__NoLicenseToken",
2207
+ type: "error"
2208
+ }, {
2209
+ inputs: [],
2210
+ name: "LicensingModule__NoParentIp",
2211
+ type: "error"
1635
2212
  }, {
1636
2213
  inputs: [],
1637
2214
  name: "LicensingModule__NotLicensee",
@@ -1648,6 +2225,14 @@ var ErrorsABI = [{
1648
2225
  inputs: [],
1649
2226
  name: "LicensingModule__ParentIdEqualThanChild",
1650
2227
  type: "error"
2228
+ }, {
2229
+ inputs: [{
2230
+ internalType: "address",
2231
+ name: "ipId",
2232
+ type: "address"
2233
+ }],
2234
+ name: "LicensingModule__ParentIpHasNoLicenseTerms",
2235
+ type: "error"
1651
2236
  }, {
1652
2237
  inputs: [],
1653
2238
  name: "LicensingModule__PolicyAlreadySetForIpId",
@@ -1656,6 +2241,18 @@ var ErrorsABI = [{
1656
2241
  inputs: [],
1657
2242
  name: "LicensingModule__PolicyNotFound",
1658
2243
  type: "error"
2244
+ }, {
2245
+ inputs: [{
2246
+ internalType: "address",
2247
+ name: "receiver",
2248
+ type: "address"
2249
+ }],
2250
+ name: "LicensingModule__ReceiverCheckFailed",
2251
+ type: "error"
2252
+ }, {
2253
+ inputs: [],
2254
+ name: "LicensingModule__ReceiverZeroAddress",
2255
+ type: "error"
1659
2256
  }, {
1660
2257
  inputs: [],
1661
2258
  name: "LicensingModule__RegisterPolicyFrameworkMismatch",
@@ -1786,15 +2383,15 @@ var ErrorsABI = [{
1786
2383
  type: "error"
1787
2384
  }, {
1788
2385
  inputs: [],
1789
- name: "RegistrationModule__InvalidOwner",
2386
+ name: "RoyaltyModule__CanOnlyMintSelectedPolicy",
1790
2387
  type: "error"
1791
2388
  }, {
1792
2389
  inputs: [],
1793
- name: "RoyaltyModule__CanOnlyMintSelectedPolicy",
2390
+ name: "RoyaltyModule__IncompatibleRoyaltyPolicy",
1794
2391
  type: "error"
1795
2392
  }, {
1796
2393
  inputs: [],
1797
- name: "RoyaltyModule__IncompatibleRoyaltyPolicy",
2394
+ name: "RoyaltyModule__IpIsTagged",
1798
2395
  type: "error"
1799
2396
  }, {
1800
2397
  inputs: [],
@@ -1810,15 +2407,15 @@ var ErrorsABI = [{
1810
2407
  type: "error"
1811
2408
  }, {
1812
2409
  inputs: [],
1813
- name: "RoyaltyModule__NotRegisteredIpId",
2410
+ name: "RoyaltyModule__NotWhitelistedRoyaltyPolicy",
1814
2411
  type: "error"
1815
2412
  }, {
1816
2413
  inputs: [],
1817
- name: "RoyaltyModule__NotWhitelistedRoyaltyPolicy",
2414
+ name: "RoyaltyModule__NotWhitelistedRoyaltyToken",
1818
2415
  type: "error"
1819
2416
  }, {
1820
2417
  inputs: [],
1821
- name: "RoyaltyModule__NotWhitelistedRoyaltyToken",
2418
+ name: "RoyaltyModule__ZeroDisputeModule",
1822
2419
  type: "error"
1823
2420
  }, {
1824
2421
  inputs: [],
@@ -1848,30 +2445,10 @@ var ErrorsABI = [{
1848
2445
  inputs: [],
1849
2446
  name: "RoyaltyPolicyLAP__ImplementationAlreadySet",
1850
2447
  type: "error"
1851
- }, {
1852
- inputs: [],
1853
- name: "RoyaltyPolicyLAP__InvalidAncestors",
1854
- type: "error"
1855
- }, {
1856
- inputs: [],
1857
- name: "RoyaltyPolicyLAP__InvalidAncestorsHash",
1858
- type: "error"
1859
- }, {
1860
- inputs: [],
1861
- name: "RoyaltyPolicyLAP__InvalidAncestorsLength",
1862
- type: "error"
1863
- }, {
1864
- inputs: [],
1865
- name: "RoyaltyPolicyLAP__InvalidAncestorsRoyalty",
1866
- type: "error"
1867
2448
  }, {
1868
2449
  inputs: [],
1869
2450
  name: "RoyaltyPolicyLAP__InvalidParentRoyaltiesLength",
1870
2451
  type: "error"
1871
- }, {
1872
- inputs: [],
1873
- name: "RoyaltyPolicyLAP__InvalidRoyaltyAmountLength",
1874
- type: "error"
1875
2452
  }, {
1876
2453
  inputs: [],
1877
2454
  name: "RoyaltyPolicyLAP__LastPositionNotAbleToMintLicense",
@@ -1886,15 +2463,15 @@ var ErrorsABI = [{
1886
2463
  type: "error"
1887
2464
  }, {
1888
2465
  inputs: [],
1889
- name: "RoyaltyPolicyLAP__TransferFailed",
2466
+ name: "RoyaltyPolicyLAP__UnlinkableToParents",
1890
2467
  type: "error"
1891
2468
  }, {
1892
2469
  inputs: [],
1893
- name: "RoyaltyPolicyLAP__UnlinkableToParents",
2470
+ name: "RoyaltyPolicyLAP__ZeroAncestorsVaultImpl",
1894
2471
  type: "error"
1895
2472
  }, {
1896
2473
  inputs: [],
1897
- name: "RoyaltyPolicyLAP__ZeroAncestorsVaultImpl",
2474
+ name: "RoyaltyPolicyLAP__ZeroIpRoyaltyVaultBeacon",
1898
2475
  type: "error"
1899
2476
  }, {
1900
2477
  inputs: [],
@@ -1932,544 +2509,238 @@ var sepolia = {
1932
2509
  MockERC721: "0x16d50f333B264b153B7BF1DD9fe65A2707B3281b",
1933
2510
  MockTokenGatedHook: "0x28C32a4B5B3E186d7f658C051d3Bb4a95243209a",
1934
2511
  ModuleRegistry: "0x5Aac3177F496F503Ac724A0D0A697f6ba9dA2C27",
1935
- PILPolicyFrameworkManager: "0xeAABf2b80B7e069EE449B5629590A1cc0F9bC9C2",
2512
+ PILicenseTemplate: "0xeAABf2b80B7e069EE449B5629590A1cc0F9bC9C2",
1936
2513
  RegistrationModule: "0x613128e88b568768764824f898C8135efED97fA6",
1937
2514
  RoyaltyModule: "0xA6bEf9CC650A16939566c1da5d5088f3F028a865",
1938
2515
  RoyaltyPolicyLAP: "0x16eF58e959522727588921A92e9084d36E5d3855",
1939
2516
  TokenWithdrawalModule: "0x66738a5722e9Cd91B694bA39146CFEcE95457F04"
1940
2517
  };
1941
-
1942
- var IPAccountABI = [].concat(_toConsumableArray(IPAccountImplABI), _toConsumableArray(ErrorsABI));
1943
- var IPAssetRegistryConfig = {
1944
- abi: IPAssetRegistryABI,
1945
- address: viem.getAddress(sepolia.IPAssetRegistry)
2518
+ var storyTestnet = {
2519
+ AccessController: "0x7e253Df9b0fC872746877Fa362b2cAf32712d770",
2520
+ ArbitrationPolicySP: "0xA25bc70932282b35407e0DC08cc9C91f6b00CEf0",
2521
+ CoreMetadataModule: "0x8A8FBAaEB6A0B7736ebde31c6F49CccD808232bA",
2522
+ CoreMetadataViewModule: "0x8A8FBAaEB6A0B7736ebde31c6F49CccD808232bA",
2523
+ DisputeModule: "0x6d54456Ae5DCbDC0C9E2713cC8E650fE4f445c7C",
2524
+ Governance: "0x63F4A670A8b518ef5eb291559BdAbea4b31c1AC4",
2525
+ IPAccountImpl: "0x38cAfD16502B1d61c6399A18d6Fa1Ea8CEca3678",
2526
+ IPAccountRegistry: "0x8448d0F77D7e67e0814f83D988aB3344D46bb1E4",
2527
+ IPAssetRegistry: "0x862de97662a1231FFc14038eC1BE93aB129D2169",
2528
+ IpRoyaltyVaultBeacon: "0xE92Cdf428f07D92248b6b15ce59a9d5597428F21",
2529
+ IpRoyaltyVaultImpl: "0x8Be22cc2D13ADF496a417D9C616dA4a253c68Af8",
2530
+ LicenseRegistry: "0x0c3D467537FAd845a78728CEdc3D9447338c5422",
2531
+ LicenseToken: "0xD40b7bCA204f96a346021e31c9ad54FF495226e7",
2532
+ LicensingModule: "0xEeDDE5529122b621105798860F235c28FD3aBA40",
2533
+ MockERC20: "0xA36F2A4A02f5C215d1b3630f71A4Ff55B5492AAE",
2534
+ MockERC721: "0x83DD606d14CcEb629dE9Bf8Aad7aE63767dB476f",
2535
+ MockTokenGatedHook: "0x80519d82FBE474AB9E863A066AC32E3eeAFc8F11",
2536
+ ModuleRegistry: "0xf2965E3B6251905Dd1E8671077760D07b0408cf2",
2537
+ PILicenseTemplate: "0xd0Be223ae9719bBD93447ecf5289319CCf8cA227",
2538
+ RoyaltyModule: "0x551AD8CD7893003cE00500aC2aCF1E327763D9f6",
2539
+ RoyaltyPolicyLAP: "0x2EcdB5bD12a037dCb9De0Ab7957f35FEeF758eA6",
2540
+ TokenWithdrawalModule: "0xC573E5c36B8FA5108b78f7357947972D030699d5"
1946
2541
  };
1947
- var AccessControllerConfig = {
1948
- abi: [].concat(_toConsumableArray(AccessControllerABI), _toConsumableArray(ErrorsABI)),
1949
- address: viem.getAddress(sepolia.AccessController)
2542
+ var contractAddress = {
2543
+ sepolia: sepolia,
2544
+ 11155111: sepolia,
2545
+ storyTestnet: storyTestnet,
2546
+ 1513: storyTestnet
1950
2547
  };
1951
- var DisputeModuleConfig = {
1952
- abi: [].concat(_toConsumableArray(DisputeModuleABI), _toConsumableArray(ErrorsABI)),
1953
- address: viem.getAddress(sepolia.DisputeModule)
2548
+
2549
+ var IPAccountABI = [].concat(_toConsumableArray(IPAccountImplABI), _toConsumableArray(ErrorsABI));
2550
+ var getIPAssetRegistryConfig = function getIPAssetRegistryConfig(chain) {
2551
+ return {
2552
+ abi: IPAssetRegistryABI,
2553
+ address: viem.getAddress(contractAddress[chain].IPAssetRegistry)
2554
+ };
1954
2555
  };
1955
- var LicenseRegistryConfig = {
1956
- abi: IERC1155ABI,
1957
- address: viem.getAddress(sepolia.LicenseRegistry)
2556
+ var getAccessControllerConfig = function getAccessControllerConfig(chain) {
2557
+ return {
2558
+ abi: [].concat(_toConsumableArray(AccessControllerABI), _toConsumableArray(ErrorsABI)),
2559
+ address: viem.getAddress(contractAddress[chain].AccessController)
2560
+ };
1958
2561
  };
1959
- var LicensingModuleConfig = {
1960
- abi: [].concat(_toConsumableArray(LicensingModuleABI), _toConsumableArray(ErrorsABI)),
1961
- address: viem.getAddress(sepolia.LicensingModule)
2562
+ var getDisputeModuleConfig = function getDisputeModuleConfig(chain) {
2563
+ return {
2564
+ abi: [].concat(_toConsumableArray(DisputeModuleABI), _toConsumableArray(ErrorsABI)),
2565
+ address: viem.getAddress(contractAddress[chain].DisputeModule)
2566
+ };
1962
2567
  };
1963
- var RegistrationModuleConfig = {
1964
- abi: [].concat(_toConsumableArray(RegistrationModuleABI), _toConsumableArray(ErrorsABI)),
1965
- address: viem.getAddress(sepolia.RegistrationModule)
2568
+ var getLicenseRegistryConfig = function getLicenseRegistryConfig(chain) {
2569
+ return {
2570
+ abi: IERC1155ABI,
2571
+ address: viem.getAddress(contractAddress[chain].LicenseRegistry)
2572
+ };
1966
2573
  };
1967
- var PILPolicyFrameworkManagerConfig = {
1968
- abi: [].concat(_toConsumableArray(PILPolicyFrameworkManagerABI), _toConsumableArray(ErrorsABI)),
1969
- address: viem.getAddress(sepolia.PILPolicyFrameworkManager)
2574
+ var getLicensingModuleConfig = function getLicensingModuleConfig(chain) {
2575
+ return {
2576
+ abi: [].concat(_toConsumableArray(LicensingModuleABI), _toConsumableArray(ErrorsABI)),
2577
+ address: viem.getAddress(contractAddress[chain].LicensingModule)
2578
+ };
1970
2579
  };
1971
- var RoyaltyPolicyLAPConfig = {
1972
- address: viem.getAddress(sepolia.RoyaltyPolicyLAP)
2580
+ var getRoyaltyPolicyLAPConfig = function getRoyaltyPolicyLAPConfig(chain) {
2581
+ return {
2582
+ abi: [].concat(_toConsumableArray(IRoyaltyPolicyLAPABI), _toConsumableArray(ErrorsABI)),
2583
+ address: viem.getAddress(contractAddress[chain].RoyaltyPolicyLAP)
2584
+ };
1973
2585
  };
1974
-
1975
- function _createForOfIteratorHelper(o, allowArrayLike) {
1976
- var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
1977
- if (!it) {
1978
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
1979
- if (it) o = it;
1980
- var i = 0;
1981
- var F = function () {};
1982
- return {
1983
- s: F,
1984
- n: function () {
1985
- if (i >= o.length) return {
1986
- done: true
1987
- };
1988
- return {
1989
- done: false,
1990
- value: o[i++]
1991
- };
1992
- },
1993
- e: function (e) {
1994
- throw e;
1995
- },
1996
- f: F
1997
- };
1998
- }
1999
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2000
- }
2001
- var normalCompletion = true,
2002
- didErr = false,
2003
- err;
2586
+ var getRoyaltyVaultImplConfig = function getRoyaltyVaultImplConfig(chain) {
2004
2587
  return {
2005
- s: function () {
2006
- it = it.call(o);
2007
- },
2008
- n: function () {
2009
- var step = it.next();
2010
- normalCompletion = step.done;
2011
- return step;
2012
- },
2013
- e: function (e) {
2014
- didErr = true;
2015
- err = e;
2016
- },
2017
- f: function () {
2018
- try {
2019
- if (!normalCompletion && it.return != null) it.return();
2020
- } finally {
2021
- if (didErr) throw err;
2022
- }
2023
- }
2588
+ abi: [].concat(_toConsumableArray(IpRoyaltyVaultABI), _toConsumableArray(ErrorsABI)),
2589
+ address: viem.getAddress(contractAddress[chain].IpRoyaltyVaultImpl)
2024
2590
  };
2025
- }
2026
-
2027
- function parseToBigInt(num) {
2028
- return BigInt(num);
2029
- }
2030
- function waitTxAndFilterLog(_x, _x2, _x3) {
2031
- return _waitTxAndFilterLog.apply(this, arguments);
2032
- }
2033
- function _waitTxAndFilterLog() {
2034
- _waitTxAndFilterLog = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(client, txHash, params) {
2035
- var txReceipt, targetLogs, _iterator, _step, log, currentLog;
2036
- return _regeneratorRuntime().wrap(function _callee$(_context) {
2037
- while (1) switch (_context.prev = _context.next) {
2038
- case 0:
2039
- _context.next = 2;
2040
- return client.waitForTransactionReceipt({
2041
- hash: txHash,
2042
- confirmations: params.confirmations,
2043
- pollingInterval: params.pollingInterval,
2044
- timeout: params.timeout
2045
- });
2046
- case 2:
2047
- txReceipt = _context.sent;
2048
- targetLogs = [];
2049
- _iterator = _createForOfIteratorHelper(txReceipt.logs);
2050
- _context.prev = 5;
2051
- _iterator.s();
2052
- case 7:
2053
- if ((_step = _iterator.n()).done) {
2054
- _context.next = 21;
2055
- break;
2056
- }
2057
- log = _step.value;
2058
- _context.prev = 9;
2059
- if (!(params.from && log.address !== params.from.toLowerCase())) {
2060
- _context.next = 12;
2061
- break;
2062
- }
2063
- return _context.abrupt("continue", 19);
2064
- case 12:
2065
- currentLog = viem.decodeEventLog({
2066
- abi: params.abi,
2067
- eventName: params.eventName,
2068
- data: log.data,
2069
- topics: log.topics
2070
- });
2071
- targetLogs.push(currentLog);
2072
- _context.next = 19;
2073
- break;
2074
- case 16:
2075
- _context.prev = 16;
2076
- _context.t0 = _context["catch"](9);
2077
- return _context.abrupt("continue", 19);
2078
- case 19:
2079
- _context.next = 7;
2080
- break;
2081
- case 21:
2082
- _context.next = 26;
2083
- break;
2084
- case 23:
2085
- _context.prev = 23;
2086
- _context.t1 = _context["catch"](5);
2087
- _iterator.e(_context.t1);
2088
- case 26:
2089
- _context.prev = 26;
2090
- _iterator.f();
2091
- return _context.finish(26);
2092
- case 29:
2093
- if (!(targetLogs.length === 0)) {
2094
- _context.next = 31;
2095
- break;
2096
- }
2097
- throw new Error("not found event ".concat(params.eventName, " in target transaction"));
2098
- case 31:
2099
- return _context.abrupt("return", targetLogs);
2100
- case 32:
2101
- case "end":
2102
- return _context.stop();
2103
- }
2104
- }, _callee, null, [[5, 23, 26, 29], [9, 16]]);
2105
- }));
2106
- return _waitTxAndFilterLog.apply(this, arguments);
2107
- }
2108
- function waitTx(_x4, _x5, _x6) {
2109
- return _waitTx.apply(this, arguments);
2110
- }
2111
- function _waitTx() {
2112
- _waitTx = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(client, txHash, params) {
2113
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
2114
- while (1) switch (_context2.prev = _context2.next) {
2115
- case 0:
2116
- _context2.next = 2;
2117
- return client.waitForTransactionReceipt(_objectSpread2({
2118
- hash: txHash
2119
- }, params));
2120
- case 2:
2121
- case "end":
2122
- return _context2.stop();
2123
- }
2124
- }, _callee2);
2125
- }));
2126
- return _waitTx.apply(this, arguments);
2127
- }
2128
- function typedDataToBytes(typedData) {
2129
- return viem.encodeAbiParameters(viem.parseAbiParameters(typedData["interface"]), typedData.data);
2130
- }
2131
- function chainStringToViemChain(chainId) {
2132
- switch (chainId) {
2133
- case "1":
2134
- case "mainnet":
2135
- return chains.mainnet;
2136
- case "11155111":
2137
- case "sepolia":
2138
- return chains.sepolia;
2139
- case "80001":
2140
- case "mumbai":
2141
- case "polygonMumbai":
2142
- return chains.polygonMumbai;
2143
- default:
2144
- throw new Error("chainId ".concat(chainId, " not supported"));
2145
- }
2146
- }
2147
-
2148
- function computeRoyaltyContext(_x, _x2) {
2149
- return _computeRoyaltyContext.apply(this, arguments);
2150
- }
2151
- function _computeRoyaltyContext() {
2152
- _computeRoyaltyContext = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(licenseIds, storyClient) {
2153
- var royaltyContext, i, licenseData, royaltyPolicy, policy, targetRoyaltyAmount;
2154
- return _regeneratorRuntime().wrap(function _callee$(_context) {
2155
- while (1) switch (_context.prev = _context.next) {
2156
- case 0:
2157
- royaltyContext = {
2158
- targetAncestors: [],
2159
- targetRoyaltyAmount: [],
2160
- parentAncestors1: [],
2161
- parentAncestors2: [],
2162
- parentAncestorsRoyalties1: [],
2163
- parentAncestorsRoyalties2: []
2164
- };
2165
- i = 0;
2166
- case 2:
2167
- if (!(i < licenseIds.length)) {
2168
- _context.next = 16;
2169
- break;
2170
- }
2171
- _context.next = 5;
2172
- return storyClient.getLicense(licenseIds[i]);
2173
- case 5:
2174
- licenseData = _context.sent;
2175
- _context.next = 8;
2176
- return storyClient.getRoyaltyPolicy(licenseData.licensorIpId);
2177
- case 8:
2178
- royaltyPolicy = _context.sent;
2179
- _context.next = 11;
2180
- return storyClient.getPolicy(licenseData.policyId);
2181
- case 11:
2182
- policy = _context.sent;
2183
- if (royaltyPolicy) {
2184
- targetRoyaltyAmount = royaltyPolicy.targetRoyaltyAmount.map(function (e) {
2185
- return parseInt(e);
2186
- });
2187
- if (i === 0) {
2188
- royaltyContext.parentAncestors1 = royaltyPolicy.targetAncestors;
2189
- royaltyContext.parentAncestorsRoyalties1 = targetRoyaltyAmount;
2190
- } else {
2191
- royaltyContext.parentAncestors2 = royaltyPolicy.targetAncestors;
2192
- royaltyContext.parentAncestorsRoyalties2 = targetRoyaltyAmount;
2193
- }
2194
- updateRoyaltyContext(royaltyContext, [licenseData.licensorIpId], [parseInt(policy.pil.commercialRevShare)]);
2195
- updateRoyaltyContext(royaltyContext, royaltyPolicy.targetAncestors, targetRoyaltyAmount);
2196
- }
2197
- case 13:
2198
- i++;
2199
- _context.next = 2;
2200
- break;
2201
- case 16:
2202
- return _context.abrupt("return", royaltyContext);
2203
- case 17:
2204
- case "end":
2205
- return _context.stop();
2206
- }
2207
- }, _callee);
2208
- }));
2209
- return _computeRoyaltyContext.apply(this, arguments);
2210
- }
2211
- function encodeRoyaltyContext(royaltyContext) {
2212
- return typedDataToBytes({
2213
- "interface": "(address[], uint32[], address[], address[], uint32[], uint32[])",
2214
- data: [[royaltyContext.targetAncestors, royaltyContext.targetRoyaltyAmount, royaltyContext.parentAncestors1, royaltyContext.parentAncestors2, royaltyContext.parentAncestorsRoyalties1, royaltyContext.parentAncestorsRoyalties2]]
2215
- });
2216
- }
2217
- function updateRoyaltyContext(royaltyContext, targetAncestors, targetRoyaltyAccounts) {
2218
- for (var i = 0; i < targetAncestors.length; i++) {
2219
- var index = royaltyContext.targetAncestors.indexOf(targetAncestors[i]);
2220
- if (index === -1) {
2221
- royaltyContext.targetAncestors.push(targetAncestors[i]);
2222
- royaltyContext.targetRoyaltyAmount.push(targetRoyaltyAccounts[i]);
2223
- } else {
2224
- royaltyContext.targetRoyaltyAmount[index] += targetRoyaltyAccounts[i];
2225
- }
2591
+ };
2592
+ var getRoyaltyModuleConfig = function getRoyaltyModuleConfig(chain) {
2593
+ return {
2594
+ abi: [].concat(_toConsumableArray(IRoyaltyModuleABI), _toConsumableArray(ErrorsABI)),
2595
+ address: viem.getAddress(contractAddress[chain].RoyaltyModule)
2596
+ };
2597
+ };
2598
+ var getLicenseTemplateConfig = function getLicenseTemplateConfig(chain) {
2599
+ return {
2600
+ abi: [].concat(_toConsumableArray(PILicenseTemplateABI), _toConsumableArray(ErrorsABI)),
2601
+ address: viem.getAddress(contractAddress[chain].PILicenseTemplate)
2602
+ };
2603
+ };
2604
+
2605
+ function handleError(error, msg) {
2606
+ if (error instanceof Error) {
2607
+ throw new Error("".concat(msg, ": ").concat(error.message));
2226
2608
  }
2609
+ throw new Error("".concat(msg, ": Unknown error type"));
2227
2610
  }
2228
2611
 
2229
2612
  var IPAssetClient = /*#__PURE__*/function () {
2230
- function IPAssetClient(rpcClient, wallet, storyClient) {
2613
+ function IPAssetClient(rpcClient, wallet, chainId) {
2231
2614
  _classCallCheck(this, IPAssetClient);
2232
- _defineProperty(this, "ipAssetRegistryConfig", IPAssetRegistryConfig);
2233
- _defineProperty(this, "registrationModuleConfig", RegistrationModuleConfig);
2234
2615
  this.wallet = wallet;
2235
2616
  this.rpcClient = rpcClient;
2236
- this.storyClient = storyClient;
2617
+ this.chainId = chainId;
2618
+ this.ipAssetRegistryConfig = getIPAssetRegistryConfig(chainId);
2237
2619
  }
2238
-
2239
- /**
2240
- * Registers a root-level IP into the protocol. Root-level IPs can be thought of as organizational hubs
2241
- * for encapsulating policies that actual IPs can use to register through. As such, a root-level IP is not an
2242
- * actual IP, but a container for IP policy management for their child IP assets.
2243
- * @param request The request object that contains all data needed to register a root IP.
2244
- * @param request.policyId The policy that identifies the licensing terms of the IP.
2245
- * @param request.tokenContract The address of the NFT bound to the root-level IP.
2246
- * @param request.tokenId The token id of the NFT bound to the root-level IP.
2247
- * @param request.ipName [Optional] The name assigned to the new IP.
2248
- * @param request.contentHash [Optional] The content hash of the IP being registered.
2249
- * @param request.uri [Optional] An external URI to link to the IP.
2250
- * @param request.txOptions [Optional] The transaction options.
2251
- * @returns A Promise that resolves to an object containing the transaction hash and optional IP ID if waitForTxn is set to true.
2252
- * @emits RootIPRegistered (msg.sender, ipId, policyId)
2253
- */
2254
2620
  return _createClass(IPAssetClient, [{
2255
- key: "registerRootIp",
2256
- value: (function () {
2257
- var _registerRootIp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
2258
- var _request$txOptions, ipId, _yield$this$rpcClient, call, txHash, targetLogs;
2621
+ key: "isNFTRegistered",
2622
+ value: function () {
2623
+ var _isNFTRegistered = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(tokenAddress, tokenId) {
2624
+ var ipId, isRegistered;
2259
2625
  return _regeneratorRuntime().wrap(function _callee$(_context) {
2260
2626
  while (1) switch (_context.prev = _context.next) {
2261
2627
  case 0:
2262
- _context.prev = 0;
2263
- _context.next = 3;
2264
- return this.isNFTRegistered(SepoliaChainId, request.tokenContractAddress, request.tokenId);
2265
- case 3:
2266
- ipId = _context.sent;
2267
- if (!(ipId !== "0x")) {
2268
- _context.next = 6;
2269
- break;
2270
- }
2271
- return _context.abrupt("return", {
2272
- ipId: ipId
2273
- });
2274
- case 6:
2275
- _context.next = 8;
2276
- return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.registrationModuleConfig), {}, {
2277
- functionName: "registerRootIp",
2278
- args: [parseToBigInt(request.policyId || "0"), viem.getAddress(request.tokenContractAddress),
2279
- // 0x Address
2280
- parseToBigInt(request.tokenId), request.ipName || "", request.contentHash || HashZero, request.uri || ""],
2281
- account: this.wallet.account
2628
+ _context.next = 2;
2629
+ return this.rpcClient.readContract(_objectSpread2(_objectSpread2({}, this.ipAssetRegistryConfig), {}, {
2630
+ functionName: "ipId",
2631
+ args: [parseToBigInt(chain[this.chainId]), tokenAddress, tokenId]
2282
2632
  }));
2283
- case 8:
2284
- _yield$this$rpcClient = _context.sent;
2285
- call = _yield$this$rpcClient.request;
2286
- _context.next = 12;
2287
- return this.wallet.writeContract(call);
2288
- case 12:
2289
- txHash = _context.sent;
2290
- if (!((_request$txOptions = request.txOptions) !== null && _request$txOptions !== void 0 && _request$txOptions.waitForTransaction)) {
2291
- _context.next = 20;
2292
- break;
2293
- }
2294
- _context.next = 16;
2295
- return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, this.ipAssetRegistryConfig), {}, {
2296
- eventName: "IPRegistered"
2633
+ case 2:
2634
+ ipId = _context.sent;
2635
+ _context.next = 5;
2636
+ return this.rpcClient.readContract(_objectSpread2(_objectSpread2({}, this.ipAssetRegistryConfig), {}, {
2637
+ functionName: "isRegistered",
2638
+ args: [ipId]
2297
2639
  }));
2298
- case 16:
2299
- targetLogs = _context.sent;
2300
- return _context.abrupt("return", {
2301
- txHash: txHash,
2302
- ipId: targetLogs[0].args.ipId
2303
- });
2304
- case 20:
2305
- return _context.abrupt("return", {
2306
- txHash: txHash
2307
- });
2308
- case 21:
2309
- _context.next = 26;
2310
- break;
2311
- case 23:
2312
- _context.prev = 23;
2313
- _context.t0 = _context["catch"](0);
2314
- handleError(_context.t0, "Failed to register root IP");
2315
- case 26:
2640
+ case 5:
2641
+ isRegistered = _context.sent;
2642
+ return _context.abrupt("return", isRegistered ? ipId : "0x");
2643
+ case 7:
2316
2644
  case "end":
2317
2645
  return _context.stop();
2318
2646
  }
2319
- }, _callee, this, [[0, 23]]);
2647
+ }, _callee, this);
2320
2648
  }));
2321
- function registerRootIp(_x) {
2322
- return _registerRootIp.apply(this, arguments);
2649
+ function isNFTRegistered(_x, _x2) {
2650
+ return _isNFTRegistered.apply(this, arguments);
2323
2651
  }
2324
- return registerRootIp;
2652
+ return isNFTRegistered;
2325
2653
  }()
2326
2654
  /**
2327
- * Registers derivative IPs into the protocol. Derivative IPs are IP assets that inherit policies from
2328
- * parent IPs by burning acquired license NFTs.
2329
- * @param request The request object that contains all data needed to register a root IP.
2330
- * @param request.licenseIds The policy that identifies the licensing terms of the IP.
2331
- * @param request.tokenContract The address of the NFT bound to the derivative IP.
2332
- * @param request.tokenId The token id of the NFT bound to the derivative IP.
2333
- * @param request.ipName [Optional] The name assigned to the new IP.
2334
- * @param request.contentHash [Optional] The content hash of the IP being registered.
2335
- * @param request.uri [Optional] An external URI to link to the IP.
2336
- * @param request.txOptions [Optional] The transaction options.
2655
+ * Registers an NFT as IP, creating a corresponding IP record.
2656
+ * @param request The request object that contains all data needed to register IP.
2657
+ * @param request.tokenContract The address of the NFT.
2658
+ * @param request.tokenId The token identifier of the NFT.
2659
+ * @param request.txOptions [Optional] The transaction options.
2337
2660
  * @returns A Promise that resolves to an object containing the transaction hash and optional IP ID if waitForTxn is set to true.
2338
- * @emits RootIPRegistered (msg.sender, ipId, policyId)
2661
+ * @emits IPRegistered (ipId, chainId, tokenContract, tokenId, resolverAddr, metadataProviderAddress, metadata)
2339
2662
  */
2340
- )
2341
2663
  }, {
2342
- key: "registerDerivativeIp",
2664
+ key: "register",
2343
2665
  value: (function () {
2344
- var _registerDerivativeIp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
2345
- var _request$txOptions2, ipId, licenseIds, royaltyContext, _yield$this$rpcClient2, call, txHash, targetLogs;
2666
+ var _register = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
2667
+ var tokenId, _request$txOptions, ipId, _yield$this$rpcClient, call, txHash, targetLogs;
2346
2668
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
2347
2669
  while (1) switch (_context2.prev = _context2.next) {
2348
2670
  case 0:
2349
- _context2.prev = 0;
2350
- _context2.next = 3;
2351
- return this.isNFTRegistered(SepoliaChainId, request.tokenContractAddress, request.tokenId);
2352
- case 3:
2671
+ tokenId = parseToBigInt(request.tokenId);
2672
+ _context2.prev = 1;
2673
+ _context2.next = 4;
2674
+ return this.isNFTRegistered(request.tokenContract, tokenId);
2675
+ case 4:
2353
2676
  ipId = _context2.sent;
2354
2677
  if (!(ipId !== "0x")) {
2355
- _context2.next = 6;
2678
+ _context2.next = 7;
2356
2679
  break;
2357
2680
  }
2358
2681
  return _context2.abrupt("return", {
2359
2682
  ipId: ipId
2360
2683
  });
2361
- case 6:
2362
- licenseIds = [];
2363
- request.licenseIds.forEach(function (licenseId) {
2364
- licenseIds.push(parseToBigInt(licenseId));
2365
- });
2366
- _context2.next = 10;
2367
- return computeRoyaltyContext(request.licenseIds, this.storyClient);
2368
- case 10:
2369
- royaltyContext = _context2.sent;
2370
- _context2.next = 13;
2371
- return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.registrationModuleConfig), {}, {
2372
- functionName: "registerDerivativeIp",
2373
- args: [licenseIds, viem.getAddress(request.tokenContractAddress),
2374
- // 0x Address
2375
- parseToBigInt(request.tokenId), request.ipName || "", request.contentHash || HashZero, request.uri || "", encodeRoyaltyContext(royaltyContext)],
2684
+ case 7:
2685
+ _context2.next = 9;
2686
+ return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.ipAssetRegistryConfig), {}, {
2687
+ functionName: "register",
2688
+ args: [viem.getAddress(request.tokenContract), tokenId],
2376
2689
  account: this.wallet.account
2377
2690
  }));
2378
- case 13:
2379
- _yield$this$rpcClient2 = _context2.sent;
2380
- call = _yield$this$rpcClient2.request;
2381
- _context2.next = 17;
2691
+ case 9:
2692
+ _yield$this$rpcClient = _context2.sent;
2693
+ call = _yield$this$rpcClient.request;
2694
+ _context2.next = 13;
2382
2695
  return this.wallet.writeContract(call);
2383
- case 17:
2696
+ case 13:
2384
2697
  txHash = _context2.sent;
2385
- if (!((_request$txOptions2 = request.txOptions) !== null && _request$txOptions2 !== void 0 && _request$txOptions2.waitForTransaction)) {
2386
- _context2.next = 25;
2698
+ if (!((_request$txOptions = request.txOptions) !== null && _request$txOptions !== void 0 && _request$txOptions.waitForTransaction)) {
2699
+ _context2.next = 21;
2387
2700
  break;
2388
2701
  }
2389
- _context2.next = 21;
2702
+ _context2.next = 17;
2390
2703
  return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, this.ipAssetRegistryConfig), {}, {
2391
2704
  eventName: "IPRegistered"
2392
2705
  }));
2393
- case 21:
2706
+ case 17:
2394
2707
  targetLogs = _context2.sent;
2395
2708
  return _context2.abrupt("return", {
2396
2709
  txHash: txHash,
2397
2710
  ipId: targetLogs[0].args.ipId
2398
2711
  });
2399
- case 25:
2712
+ case 21:
2400
2713
  return _context2.abrupt("return", {
2401
2714
  txHash: txHash
2402
2715
  });
2403
- case 26:
2404
- _context2.next = 31;
2716
+ case 22:
2717
+ _context2.next = 27;
2405
2718
  break;
2406
- case 28:
2407
- _context2.prev = 28;
2408
- _context2.t0 = _context2["catch"](0);
2409
- handleError(_context2.t0, "Failed to register derivative IP");
2410
- case 31:
2719
+ case 24:
2720
+ _context2.prev = 24;
2721
+ _context2.t0 = _context2["catch"](1);
2722
+ handleError(_context2.t0, "Failed to register IP");
2723
+ case 27:
2411
2724
  case "end":
2412
2725
  return _context2.stop();
2413
2726
  }
2414
- }, _callee2, this, [[0, 28]]);
2415
- }));
2416
- function registerDerivativeIp(_x2) {
2417
- return _registerDerivativeIp.apply(this, arguments);
2418
- }
2419
- return registerDerivativeIp;
2420
- }()
2421
- /**
2422
- * Checks if an NFT is already registered in the protocol.
2423
- * @param chainId The chain ID of the NFT.
2424
- * @param tokenAddress The address of the NFT.
2425
- * @param tokenId The token ID of the NFT.
2426
- * @returns A Promise that resolves to the IP ID if the NFT is already registered, otherwise it resolves to 0x.
2427
- */
2428
- )
2429
- }, {
2430
- key: "isNFTRegistered",
2431
- value: (function () {
2432
- var _isNFTRegistered = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(chainId, tokenAddress, tokenId) {
2433
- var ipId, isRegistered;
2434
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
2435
- while (1) switch (_context3.prev = _context3.next) {
2436
- case 0:
2437
- _context3.next = 2;
2438
- return this.rpcClient.readContract(_objectSpread2(_objectSpread2({}, this.ipAssetRegistryConfig), {}, {
2439
- functionName: "ipId",
2440
- args: [parseToBigInt(chainId), tokenAddress, parseToBigInt(tokenId)]
2441
- }));
2442
- case 2:
2443
- ipId = _context3.sent;
2444
- _context3.next = 5;
2445
- return this.rpcClient.readContract(_objectSpread2(_objectSpread2({}, this.ipAssetRegistryConfig), {}, {
2446
- functionName: "isRegistered",
2447
- args: [ipId]
2448
- }));
2449
- case 5:
2450
- isRegistered = _context3.sent;
2451
- return _context3.abrupt("return", isRegistered ? ipId : "0x");
2452
- case 7:
2453
- case "end":
2454
- return _context3.stop();
2455
- }
2456
- }, _callee3, this);
2727
+ }, _callee2, this, [[1, 24]]);
2457
2728
  }));
2458
- function isNFTRegistered(_x3, _x4, _x5) {
2459
- return _isNFTRegistered.apply(this, arguments);
2729
+ function register(_x3) {
2730
+ return _register.apply(this, arguments);
2460
2731
  }
2461
- return isNFTRegistered;
2732
+ return register;
2462
2733
  }())
2463
2734
  }]);
2464
2735
  }();
2465
2736
 
2466
2737
  var PermissionClient = /*#__PURE__*/function () {
2467
- function PermissionClient(rpcClient, wallet) {
2738
+ function PermissionClient(rpcClient, wallet, chainId) {
2468
2739
  _classCallCheck(this, PermissionClient);
2469
2740
  _defineProperty(this, "ipAccountABI", IPAccountABI);
2470
- _defineProperty(this, "accessControllerConfig", AccessControllerConfig);
2471
2741
  this.rpcClient = rpcClient;
2472
2742
  this.wallet = wallet;
2743
+ this.accessControllerConfig = getAccessControllerConfig(chainId);
2473
2744
  }
2474
2745
 
2475
2746
  /**
@@ -2569,417 +2840,116 @@ var PermissionClient = /*#__PURE__*/function () {
2569
2840
  }();
2570
2841
 
2571
2842
  var LicenseClient = /*#__PURE__*/function () {
2572
- function LicenseClient(rpcClient, wallet, storyClient) {
2843
+ function LicenseClient(rpcClient, wallet, storyClient, chainId) {
2573
2844
  _classCallCheck(this, LicenseClient);
2574
2845
  _defineProperty(this, "ipAccountABI", IPAccountABI);
2575
- _defineProperty(this, "licenseRegistryConfig", LicenseRegistryConfig);
2576
- _defineProperty(this, "licensingModuleConfig", LicensingModuleConfig);
2577
2846
  this.wallet = wallet;
2578
2847
  this.rpcClient = rpcClient;
2579
2848
  this.storyClient = storyClient;
2849
+ this.licenseRegistryConfig = getLicenseRegistryConfig(chainId);
2850
+ this.licensingModuleConfig = getLicensingModuleConfig(chainId);
2851
+ this.licenseTemplateConfig = getLicenseTemplateConfig(chainId);
2852
+ this.royaltyPolicyLAPConfig = getRoyaltyPolicyLAPConfig(chainId);
2580
2853
  }
2581
-
2582
- /**
2583
- * Mints license NFTs representing a policy granted by a set of ipIds (licensors). This NFT needs to be
2584
- * burned in order to link a derivative IP with its parents. If this is the first combination of policy and
2585
- * licensors, a new licenseId will be created. If not, the license is fungible and an id will be reused.
2586
- * @dev Only callable by the licensing module.
2587
- * @param request The request object containing necessary data to mint a license.
2588
- * @param request.policyId The ID of the policy to be minted
2589
- * @param request.licensorIpId_ The ID of the IP granting the license (ie. licensor)
2590
- * @param request.mintAmount Number of licenses to mint. License NFT is fungible for same policy and same licensors
2591
- * @param request.receiver Receiver address of the minted license NFT(s).
2592
- * @returns licenseId The ID of the minted license NFT(s).
2593
- */
2594
2854
  return _createClass(LicenseClient, [{
2595
- key: "mintLicense",
2596
- value: (function () {
2597
- var _mintLicense = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
2598
- var _request$txOptions, royaltyContext, royaltyPolicy, _royaltyContext$targe, _royaltyContext$targe2, targetRoyaltyAmount, _yield$this$rpcClient, call, txHash, targetLogs;
2599
- return _regeneratorRuntime().wrap(function _callee$(_context) {
2600
- while (1) switch (_context.prev = _context.next) {
2601
- case 0:
2602
- _context.prev = 0;
2603
- royaltyContext = {
2604
- targetAncestors: [],
2605
- targetRoyaltyAmount: [],
2606
- parentAncestors1: [],
2607
- parentAncestors2: [],
2608
- parentAncestorsRoyalties1: [],
2609
- parentAncestorsRoyalties2: []
2610
- };
2611
- _context.next = 4;
2612
- return this.storyClient.getRoyaltyPolicy(request.licensorIpId);
2613
- case 4:
2614
- royaltyPolicy = _context.sent;
2615
- if (royaltyPolicy) {
2616
- (_royaltyContext$targe = royaltyContext.targetAncestors).push.apply(_royaltyContext$targe, _toConsumableArray(royaltyPolicy.targetAncestors));
2617
- targetRoyaltyAmount = royaltyPolicy.targetRoyaltyAmount.map(function (e) {
2618
- return parseInt(e);
2619
- });
2620
- (_royaltyContext$targe2 = royaltyContext.targetRoyaltyAmount).push.apply(_royaltyContext$targe2, _toConsumableArray(targetRoyaltyAmount));
2621
- }
2622
- _context.next = 8;
2623
- return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.licensingModuleConfig), {}, {
2624
- functionName: "mintLicense",
2625
- args: [parseToBigInt(request.policyId), request.licensorIpId, parseToBigInt(request.mintAmount), viem.getAddress(request.receiverAddress), encodeRoyaltyContext(royaltyContext)],
2626
- account: this.wallet.account
2627
- }));
2628
- case 8:
2629
- _yield$this$rpcClient = _context.sent;
2630
- call = _yield$this$rpcClient.request;
2631
- _context.next = 12;
2632
- return this.wallet.writeContract(call);
2633
- case 12:
2634
- txHash = _context.sent;
2635
- if (!((_request$txOptions = request.txOptions) !== null && _request$txOptions !== void 0 && _request$txOptions.waitForTransaction)) {
2636
- _context.next = 20;
2637
- break;
2638
- }
2639
- _context.next = 16;
2640
- return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, this.licenseRegistryConfig), {}, {
2641
- eventName: "TransferSingle",
2642
- from: this.licenseRegistryConfig.address
2643
- }));
2644
- case 16:
2645
- targetLogs = _context.sent;
2646
- return _context.abrupt("return", {
2647
- txHash: txHash,
2648
- licenseId: targetLogs[0].args.id.toString()
2649
- });
2650
- case 20:
2651
- return _context.abrupt("return", {
2652
- txHash: txHash
2653
- });
2654
- case 21:
2655
- _context.next = 26;
2656
- break;
2657
- case 23:
2658
- _context.prev = 23;
2659
- _context.t0 = _context["catch"](0);
2660
- handleError(_context.t0, "Failed to mint license");
2661
- case 26:
2662
- case "end":
2663
- return _context.stop();
2664
- }
2665
- }, _callee, this, [[0, 23]]);
2666
- }));
2667
- function mintLicense(_x) {
2668
- return _mintLicense.apply(this, arguments);
2669
- }
2670
- return mintLicense;
2671
- }())
2672
- }, {
2673
- key: "linkIpToParent",
2855
+ key: "getLicenseTermsId",
2674
2856
  value: function () {
2675
- var _linkIpToParent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
2676
- var _request$txOptions2, IPAccountConfig, licenseIds, royaltyContext, _yield$this$rpcClient2, call, txHash;
2677
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
2678
- while (1) switch (_context2.prev = _context2.next) {
2679
- case 0:
2680
- _context2.prev = 0;
2681
- IPAccountConfig = {
2682
- abi: this.ipAccountABI,
2683
- address: viem.getAddress(request.childIpId)
2684
- };
2685
- licenseIds = [];
2686
- request.licenseIds.forEach(function (licenseId) {
2687
- licenseIds.push(parseToBigInt(licenseId));
2688
- });
2689
- _context2.next = 6;
2690
- return computeRoyaltyContext(request.licenseIds, this.storyClient);
2691
- case 6:
2692
- royaltyContext = _context2.sent;
2693
- _context2.next = 9;
2694
- return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, IPAccountConfig), {}, {
2695
- functionName: "execute",
2696
- args: [this.licensingModuleConfig.address, parseToBigInt(0), viem.encodeFunctionData({
2697
- abi: this.licensingModuleConfig.abi,
2698
- functionName: "linkIpToParents",
2699
- args: [licenseIds, viem.getAddress(request.childIpId), encodeRoyaltyContext(royaltyContext)]
2700
- })],
2701
- account: this.wallet.account
2702
- }));
2703
- case 9:
2704
- _yield$this$rpcClient2 = _context2.sent;
2705
- call = _yield$this$rpcClient2.request;
2706
- _context2.next = 13;
2707
- return this.wallet.writeContract(call);
2708
- case 13:
2709
- txHash = _context2.sent;
2710
- if (!((_request$txOptions2 = request.txOptions) !== null && _request$txOptions2 !== void 0 && _request$txOptions2.waitForTransaction)) {
2711
- _context2.next = 20;
2712
- break;
2713
- }
2714
- _context2.next = 17;
2715
- return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, LicenseRegistryConfig), {}, {
2716
- eventName: "TransferBatch"
2717
- }));
2718
- case 17:
2719
- return _context2.abrupt("return", {
2720
- txHash: txHash,
2721
- success: true
2722
- });
2723
- case 20:
2724
- return _context2.abrupt("return", {
2725
- txHash: txHash
2726
- });
2727
- case 21:
2728
- _context2.next = 26;
2729
- break;
2730
- case 23:
2731
- _context2.prev = 23;
2732
- _context2.t0 = _context2["catch"](0);
2733
- handleError(_context2.t0, "Failed to link IP to parents");
2734
- case 26:
2735
- case "end":
2736
- return _context2.stop();
2737
- }
2738
- }, _callee2, this, [[0, 23]]);
2739
- }));
2740
- function linkIpToParent(_x2) {
2741
- return _linkIpToParent.apply(this, arguments);
2742
- }
2743
- return linkIpToParent;
2744
- }()
2745
- }]);
2746
- }();
2747
-
2748
- var PolicyClient = /*#__PURE__*/function () {
2749
- function PolicyClient(rpcClient, wallet) {
2750
- _classCallCheck(this, PolicyClient);
2751
- _defineProperty(this, "ipAccountABI", IPAccountABI);
2752
- _defineProperty(this, "licensingModuleConfig", LicensingModuleConfig);
2753
- _defineProperty(this, "pilPolicyFrameworkManagerConfig", PILPolicyFrameworkManagerConfig);
2754
- _defineProperty(this, "royaltyPolicyLAPConfig", RoyaltyPolicyLAPConfig);
2755
- this.wallet = wallet;
2756
- this.rpcClient = rpcClient;
2757
- }
2758
-
2759
- /**
2760
- * Registers a PIL policy to the registry
2761
- * Internally, this function must generate a Licensing.Policy struct and call registerPolicy.
2762
- * @param request - the licensing parameters for the Programmable IP License v1 (PIL) standard.
2763
- * @param request.transferable Whether or not the license is transferable
2764
- * @param request.attribution Whether or not attribution is required when reproducing the work
2765
- * @param request.commercialUse Whether or not the work can be used commercially
2766
- * @param request.commercialAttribution Whether or not attribution is required when reproducing the work commercially
2767
- * @param request.commercializerChecker commericializers that are allowed to commercially exploit the work. If zero address, then no restrictions is enforced.
2768
- * @param request.commercialRevShare Percentage of revenue that must be shared with the licensor
2769
- * @param request.derivativesAllowed Whether or not the licensee can create derivatives of his work
2770
- * @param request.derivativesAttribution Whether or not attribution is required for derivatives of the work
2771
- * @param request.derivativesApproval Whether or not the licensor must approve derivatives of the work before they can be linked to the licensor IP ID
2772
- * @param request.derivativesReciprocal Whether or not the licensee must license derivatives of the work under the same terms.
2773
- * @param request.territories List of territories where the license is valid. If empty, global.
2774
- * @param request.distributionChannels List of distribution channels where the license is valid. Empty if no restrictions.
2775
- * @param request.royaltyPolicy Address of a royalty policy contract (e.g. RoyaltyPolicyLS) that will handle royalty payments
2776
- * @returns the transaction hash and the policy ID if the txOptions.waitForTransaction is set to true
2777
- */
2778
- return _createClass(PolicyClient, [{
2779
- key: "registerPILPolicy",
2780
- value: (function () {
2781
- var _registerPILPolicy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
2782
- var _request$txOptions, frameworkData, policyId, _yield$this$rpcClient, call, txHash, targetLogs;
2857
+ var _getLicenseTermsId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
2858
+ var selectedLicenseTermsId;
2783
2859
  return _regeneratorRuntime().wrap(function _callee$(_context) {
2784
2860
  while (1) switch (_context.prev = _context.next) {
2785
2861
  case 0:
2786
- _context.prev = 0;
2787
- // First check if the policy exists
2788
- frameworkData = {
2789
- attribution: request.attribution || false,
2790
- commercialUse: request.commercialUse || false,
2791
- commercialAttribution: request.commercialAttribution || false,
2792
- commercializerChecker: request.commercializerChecker || viem.zeroAddress,
2793
- commercializerCheckerData: request.commercializerCheckerData || "0x",
2794
- commercialRevShare: request.commercialRevShare || 0,
2795
- derivativesAllowed: request.derivativesAllowed || false,
2796
- derivativesAttribution: request.derivativesAttribution || false,
2797
- derivativesApproval: request.derivativesApproval || false,
2798
- derivativesReciprocal: request.derivativesReciprocal || false,
2799
- territories: request.territories || [],
2800
- distributionChannels: request.distributionChannels || [],
2801
- contentRestrictions: request.contentRestrictions || []
2802
- };
2803
- _context.next = 4;
2804
- return this.getPolicyId(request.transferable, this.encodeFrameworkData(frameworkData), typedDataToBytes({
2805
- "interface": "uint32",
2806
- data: [request.commercialRevShare || 0]
2807
- }), request.mintingFee || "0", request.mintingFeeToken || viem.zeroAddress, request.royaltyPolicy || viem.zeroAddress);
2808
- case 4:
2809
- policyId = _context.sent;
2810
- if (!(policyId !== 0)) {
2811
- _context.next = 7;
2812
- break;
2813
- }
2814
- return _context.abrupt("return", {
2815
- policyId: policyId.toString()
2816
- });
2817
- case 7:
2818
- _context.next = 9;
2819
- return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.pilPolicyFrameworkManagerConfig), {}, {
2820
- functionName: "registerPolicy",
2821
- args: [{
2822
- transferable: request.transferable,
2823
- royaltyPolicy: request.royaltyPolicy || viem.zeroAddress,
2824
- mintingFee: parseToBigInt(request.mintingFee || "0"),
2825
- mintingFeeToken: request.mintingFeeToken || viem.zeroAddress,
2826
- policy: {
2827
- attribution: request.attribution || false,
2828
- commercialUse: request.commercialUse || false,
2829
- commercialAttribution: request.commercialAttribution || false,
2830
- commercialRevShare: request.commercialRevShare || 0,
2831
- derivativesAllowed: request.derivativesAllowed || false,
2832
- derivativesAttribution: request.derivativesAttribution || false,
2833
- derivativesApproval: request.derivativesApproval || false,
2834
- derivativesReciprocal: request.derivativesReciprocal || false,
2835
- commercializerChecker: request.commercializerChecker || viem.zeroAddress,
2836
- commercializerCheckerData: request.commercializerCheckerData || "0x",
2837
- territories: request.territories || [],
2838
- distributionChannels: request.distributionChannels || [],
2839
- contentRestrictions: request.contentRestrictions || []
2840
- }
2841
- }],
2842
- account: this.wallet.account
2843
- }));
2844
- case 9:
2845
- _yield$this$rpcClient = _context.sent;
2846
- call = _yield$this$rpcClient.request;
2847
- _context.next = 13;
2848
- return this.wallet.writeContract(call);
2849
- case 13:
2850
- txHash = _context.sent;
2851
- if (!((_request$txOptions = request.txOptions) !== null && _request$txOptions !== void 0 && _request$txOptions.waitForTransaction)) {
2852
- _context.next = 21;
2853
- break;
2854
- }
2855
- _context.next = 17;
2856
- return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, this.licensingModuleConfig), {}, {
2857
- eventName: "PolicyRegistered"
2862
+ _context.next = 2;
2863
+ return this.rpcClient.readContract(_objectSpread2(_objectSpread2({}, this.licenseTemplateConfig), {}, {
2864
+ functionName: "getLicenseTermsId",
2865
+ args: [request]
2858
2866
  }));
2859
- case 17:
2860
- targetLogs = _context.sent;
2861
- return _context.abrupt("return", {
2862
- txHash: txHash,
2863
- policyId: targetLogs[0].args.policyId.toString()
2864
- });
2865
- case 21:
2866
- return _context.abrupt("return", {
2867
- txHash: txHash
2868
- });
2869
- case 22:
2870
- _context.next = 27;
2871
- break;
2872
- case 24:
2873
- _context.prev = 24;
2874
- _context.t0 = _context["catch"](0);
2875
- handleError(_context.t0, "Failed to register policy");
2876
- case 27:
2867
+ case 2:
2868
+ selectedLicenseTermsId = _context.sent;
2869
+ return _context.abrupt("return", Number(selectedLicenseTermsId));
2870
+ case 4:
2877
2871
  case "end":
2878
2872
  return _context.stop();
2879
2873
  }
2880
- }, _callee, this, [[0, 24]]);
2874
+ }, _callee, this);
2881
2875
  }));
2882
- function registerPILPolicy(_x) {
2883
- return _registerPILPolicy.apply(this, arguments);
2876
+ function getLicenseTermsId(_x) {
2877
+ return _getLicenseTermsId.apply(this, arguments);
2884
2878
  }
2885
- return registerPILPolicy;
2879
+ return getLicenseTermsId;
2886
2880
  }()
2887
2881
  /**
2888
- * Convenient function to register a PIL social remix policy to the registry
2889
- * Internally, this function must generate a Licensing.Policy struct and call registerPolicy.
2890
- * @param request - the licensing parameters for the Programmable IP License v1 (PIL) standard.
2891
- * @param request.territories List of territories where the license is valid. If empty, global.
2892
- * @param request.distributionChannels List of distribution channels where the license is valid. Empty if no restrictions.
2893
- * @param request.contentRestrictions List of content restrictions where the license is valid. Empty if no restrictions.
2894
- * @returns the transaction hash and the policy ID if the txOptions.waitForTransaction is set to true
2882
+ * Convenient function to register a PIL non commercial social remix license to the registry
2883
+ * @param request The request object that contains all data needed to register a PIL non commercial social remix license.
2884
+ * @param request.txOptions [Optional] The transaction options.
2885
+ * @returns A Promise that resolves to an object containing the optional transaction hash and optional license ID.
2886
+ * @emits LicenseTermsRegistered (licenseTermsId, licenseTemplate, licenseTerms);
2895
2887
  */
2896
- )
2897
2888
  }, {
2898
- key: "registerPILSocialRemixPolicy",
2889
+ key: "registerNonComSocialRemixingPIL",
2899
2890
  value: (function () {
2900
- var _registerPILSocialRemixPolicy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
2901
- var _request$txOptions2, frameworkData, policyId, _yield$this$rpcClient2, call, txHash, targetLog;
2891
+ var _registerNonComSocialRemixingPIL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
2892
+ var _request$txOptions, licenseTerms, licenseTermsId, _yield$this$rpcClient, call, txHash, targetLogs;
2902
2893
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
2903
2894
  while (1) switch (_context2.prev = _context2.next) {
2904
2895
  case 0:
2905
2896
  _context2.prev = 0;
2906
- // First check if the policy exists
2907
- frameworkData = {
2908
- attribution: true,
2897
+ licenseTerms = {
2898
+ transferable: true,
2899
+ royaltyPolicy: viem.zeroAddress,
2900
+ mintingFee: BigInt(0),
2901
+ expiration: BigInt(0),
2909
2902
  commercialUse: false,
2910
2903
  commercialAttribution: false,
2911
2904
  commercializerChecker: viem.zeroAddress,
2912
- commercializerCheckerData: "0x",
2905
+ commercializerCheckerData: viem.zeroAddress,
2913
2906
  commercialRevShare: 0,
2907
+ commercialRevCelling: BigInt(0),
2914
2908
  derivativesAllowed: true,
2915
2909
  derivativesAttribution: true,
2916
2910
  derivativesApproval: false,
2917
2911
  derivativesReciprocal: true,
2918
- territories: request.territories || [],
2919
- distributionChannels: request.distributionChannels || [],
2920
- contentRestrictions: request.contentRestrictions || []
2912
+ derivativeRevCelling: BigInt(0),
2913
+ currency: viem.zeroAddress
2921
2914
  };
2922
2915
  _context2.next = 4;
2923
- return this.getPolicyId(true, this.encodeFrameworkData(frameworkData), typedDataToBytes({
2924
- "interface": "uint32",
2925
- data: [0]
2926
- }), "0", viem.zeroAddress, viem.zeroAddress);
2916
+ return this.getLicenseTermsId(licenseTerms);
2927
2917
  case 4:
2928
- policyId = _context2.sent;
2929
- if (!(policyId !== 0)) {
2918
+ licenseTermsId = _context2.sent;
2919
+ if (!(licenseTermsId !== 0)) {
2930
2920
  _context2.next = 7;
2931
2921
  break;
2932
2922
  }
2933
2923
  return _context2.abrupt("return", {
2934
- policyId: policyId.toString()
2924
+ licenseId: licenseTermsId.toString()
2935
2925
  });
2936
2926
  case 7:
2937
2927
  _context2.next = 9;
2938
- return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.pilPolicyFrameworkManagerConfig), {}, {
2939
- functionName: "registerPolicy",
2940
- args: [{
2941
- transferable: true,
2942
- royaltyPolicy: viem.zeroAddress,
2943
- mintingFee: parseToBigInt(0),
2944
- mintingFeeToken: viem.zeroAddress,
2945
- policy: {
2946
- attribution: true,
2947
- commercialUse: false,
2948
- commercialAttribution: false,
2949
- commercialRevShare: 0,
2950
- derivativesAllowed: true,
2951
- derivativesAttribution: true,
2952
- derivativesApproval: false,
2953
- derivativesReciprocal: true,
2954
- commercializerChecker: viem.zeroAddress,
2955
- commercializerCheckerData: "0x",
2956
- territories: request.territories || [],
2957
- distributionChannels: request.distributionChannels || [],
2958
- contentRestrictions: request.contentRestrictions || []
2959
- }
2960
- }],
2928
+ return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.licenseTemplateConfig), {}, {
2929
+ functionName: "registerLicenseTerms",
2930
+ args: [licenseTerms],
2961
2931
  account: this.wallet.account
2962
2932
  }));
2963
2933
  case 9:
2964
- _yield$this$rpcClient2 = _context2.sent;
2965
- call = _yield$this$rpcClient2.request;
2934
+ _yield$this$rpcClient = _context2.sent;
2935
+ call = _yield$this$rpcClient.request;
2966
2936
  _context2.next = 13;
2967
2937
  return this.wallet.writeContract(call);
2968
2938
  case 13:
2969
2939
  txHash = _context2.sent;
2970
- if (!((_request$txOptions2 = request.txOptions) !== null && _request$txOptions2 !== void 0 && _request$txOptions2.waitForTransaction)) {
2940
+ if (!((_request$txOptions = request.txOptions) !== null && _request$txOptions !== void 0 && _request$txOptions.waitForTransaction)) {
2971
2941
  _context2.next = 21;
2972
2942
  break;
2973
2943
  }
2974
2944
  _context2.next = 17;
2975
- return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, this.licensingModuleConfig), {}, {
2976
- eventName: "PolicyRegistered"
2945
+ return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, this.licenseTemplateConfig), {}, {
2946
+ eventName: "LicenseTermsRegistered"
2977
2947
  }));
2978
2948
  case 17:
2979
- targetLog = _context2.sent;
2949
+ targetLogs = _context2.sent;
2980
2950
  return _context2.abrupt("return", {
2981
2951
  txHash: txHash,
2982
- policyId: targetLog[0].args.policyId.toString()
2952
+ licenseId: targetLogs[0].args.licenseTermsId.toString()
2983
2953
  });
2984
2954
  case 21:
2985
2955
  return _context2.abrupt("return", {
@@ -2991,117 +2961,95 @@ var PolicyClient = /*#__PURE__*/function () {
2991
2961
  case 24:
2992
2962
  _context2.prev = 24;
2993
2963
  _context2.t0 = _context2["catch"](0);
2994
- handleError(_context2.t0, "Failed to register social remix policy");
2964
+ handleError(_context2.t0, "Failed to register non commercial social remixing PIL");
2995
2965
  case 27:
2996
2966
  case "end":
2997
2967
  return _context2.stop();
2998
2968
  }
2999
2969
  }, _callee2, this, [[0, 24]]);
3000
2970
  }));
3001
- function registerPILSocialRemixPolicy(_x2) {
3002
- return _registerPILSocialRemixPolicy.apply(this, arguments);
2971
+ function registerNonComSocialRemixingPIL(_x2) {
2972
+ return _registerNonComSocialRemixingPIL.apply(this, arguments);
3003
2973
  }
3004
- return registerPILSocialRemixPolicy;
2974
+ return registerNonComSocialRemixingPIL;
3005
2975
  }()
3006
2976
  /**
3007
- * Convenient function to register a PIL social remix policy to the registry
3008
- * Internally, this function must generate a Licensing.Policy struct and call registerPolicy.
3009
- * @param request - the licensing parameters for the Programmable IP License v1 (PIL) standard.
3010
- * @param request.commercialRevShare Percentage of revenue that must be shared with the licensor
3011
- * @param mintingFee Fee to be paid when minting a license
3012
- * @param mintingFeeToken Token to be used to pay the minting fee
3013
- * @param request.territories List of territories where the license is valid. If empty, global.
3014
- * @param request.distributionChannels List of distribution channels where the license is valid. Empty if no restrictions.
3015
- * @param request.contentRestrictions List of content restrictions where the license is valid. Empty if no restrictions.
3016
- * @returns the transaction hash and the policy ID if the txOptions.waitForTransaction is set to true
2977
+ * Convenient function to register a PIL commercial use license to the registry.
2978
+ * @param request The request object that contains all data needed to register a PIL commercial use license.
2979
+ * @param request.mintingFee The fee to be paid when minting a license.
2980
+ * @param request.currency The ERC20 token to be used to pay the minting fee.
2981
+ * the token must be registered in story protocol.
2982
+ * @param request.royaltyPolicy The address of the royalty policy contract which required to StoryProtocol in advance.
2983
+ * @param request.txOptions [Optional] The transaction options.
2984
+ * @returns A Promise that resolves to an object containing the optional transaction hash and optional license ID.
2985
+ * @emits LicenseTermsRegistered (licenseTermsId, licenseTemplate, licenseTerms);
3017
2986
  */
3018
2987
  )
3019
2988
  }, {
3020
- key: "registerPILCommercialUsePolicy",
2989
+ key: "registerCommercialUsePIL",
3021
2990
  value: (function () {
3022
- var _registerPILCommercialUsePolicy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(request) {
3023
- var _request$txOptions3, frameworkData, policyId, _yield$this$rpcClient3, call, txHash, targetLogs;
2991
+ var _registerCommercialUsePIL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(request) {
2992
+ var _request$txOptions2, licenseTerms, licenseTermsId, _yield$this$rpcClient2, call, txHash, targetLogs;
3024
2993
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
3025
2994
  while (1) switch (_context3.prev = _context3.next) {
3026
2995
  case 0:
3027
2996
  _context3.prev = 0;
3028
- // First check if the policy exists
3029
- frameworkData = {
3030
- attribution: true,
2997
+ licenseTerms = {
2998
+ transferable: true,
2999
+ royaltyPolicy: this.royaltyPolicyLAPConfig.address,
3000
+ mintingFee: BigInt(request.mintingFee),
3001
+ expiration: BigInt(0),
3031
3002
  commercialUse: true,
3032
3003
  commercialAttribution: true,
3033
3004
  commercializerChecker: viem.zeroAddress,
3034
- commercializerCheckerData: "0x",
3035
- commercialRevShare: request.commercialRevShare,
3005
+ commercializerCheckerData: viem.zeroAddress,
3006
+ commercialRevShare: 0,
3007
+ commercialRevCelling: BigInt(0),
3036
3008
  derivativesAllowed: true,
3037
3009
  derivativesAttribution: true,
3038
3010
  derivativesApproval: false,
3039
- derivativesReciprocal: true,
3040
- territories: request.territories || [],
3041
- distributionChannels: request.distributionChannels || [],
3042
- contentRestrictions: request.contentRestrictions || []
3011
+ derivativesReciprocal: false,
3012
+ derivativeRevCelling: BigInt(0),
3013
+ currency: request.currency
3043
3014
  };
3044
3015
  _context3.next = 4;
3045
- return this.getPolicyId(true, this.encodeFrameworkData(frameworkData), typedDataToBytes({
3046
- "interface": "uint32",
3047
- data: [request.commercialRevShare]
3048
- }), request.mintingFee || "0", request.mintingFeeToken || viem.zeroAddress, this.royaltyPolicyLAPConfig.address);
3016
+ return this.getLicenseTermsId(licenseTerms);
3049
3017
  case 4:
3050
- policyId = _context3.sent;
3051
- if (!(policyId !== 0)) {
3018
+ licenseTermsId = _context3.sent;
3019
+ if (!(licenseTermsId !== 0)) {
3052
3020
  _context3.next = 7;
3053
3021
  break;
3054
3022
  }
3055
3023
  return _context3.abrupt("return", {
3056
- policyId: policyId.toString()
3024
+ licenseId: licenseTermsId.toString()
3057
3025
  });
3058
3026
  case 7:
3059
3027
  _context3.next = 9;
3060
- return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.pilPolicyFrameworkManagerConfig), {}, {
3061
- functionName: "registerPolicy",
3062
- args: [{
3063
- transferable: true,
3064
- royaltyPolicy: this.royaltyPolicyLAPConfig.address,
3065
- mintingFee: parseToBigInt(request.mintingFee || "0"),
3066
- mintingFeeToken: request.mintingFeeToken || viem.zeroAddress,
3067
- policy: {
3068
- attribution: true,
3069
- commercialUse: true,
3070
- commercialAttribution: true,
3071
- commercialRevShare: request.commercialRevShare,
3072
- derivativesAllowed: true,
3073
- derivativesAttribution: true,
3074
- derivativesApproval: false,
3075
- derivativesReciprocal: true,
3076
- commercializerChecker: viem.zeroAddress,
3077
- commercializerCheckerData: "0x",
3078
- territories: request.territories || [],
3079
- distributionChannels: request.distributionChannels || [],
3080
- contentRestrictions: request.contentRestrictions || []
3081
- }
3082
- }],
3028
+ return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.licenseTemplateConfig), {}, {
3029
+ functionName: "registerLicenseTerms",
3030
+ args: [licenseTerms],
3083
3031
  account: this.wallet.account
3084
3032
  }));
3085
3033
  case 9:
3086
- _yield$this$rpcClient3 = _context3.sent;
3087
- call = _yield$this$rpcClient3.request;
3034
+ _yield$this$rpcClient2 = _context3.sent;
3035
+ call = _yield$this$rpcClient2.request;
3088
3036
  _context3.next = 13;
3089
3037
  return this.wallet.writeContract(call);
3090
3038
  case 13:
3091
3039
  txHash = _context3.sent;
3092
- if (!((_request$txOptions3 = request.txOptions) !== null && _request$txOptions3 !== void 0 && _request$txOptions3.waitForTransaction)) {
3040
+ if (!((_request$txOptions2 = request.txOptions) !== null && _request$txOptions2 !== void 0 && _request$txOptions2.waitForTransaction)) {
3093
3041
  _context3.next = 21;
3094
3042
  break;
3095
3043
  }
3096
3044
  _context3.next = 17;
3097
- return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, this.licensingModuleConfig), {}, {
3098
- eventName: "PolicyRegistered"
3045
+ return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, this.licenseTemplateConfig), {}, {
3046
+ eventName: "LicenseTermsRegistered"
3099
3047
  }));
3100
3048
  case 17:
3101
3049
  targetLogs = _context3.sent;
3102
3050
  return _context3.abrupt("return", {
3103
3051
  txHash: txHash,
3104
- policyId: targetLogs[0].args.policyId.toString()
3052
+ licenseId: targetLogs[0].args.licenseTermsId.toString()
3105
3053
  });
3106
3054
  case 21:
3107
3055
  return _context3.abrupt("return", {
@@ -3113,144 +3061,266 @@ var PolicyClient = /*#__PURE__*/function () {
3113
3061
  case 24:
3114
3062
  _context3.prev = 24;
3115
3063
  _context3.t0 = _context3["catch"](0);
3116
- handleError(_context3.t0, "Failed to register commercial use policy");
3064
+ handleError(_context3.t0, "Failed to register commercial use PIL");
3117
3065
  case 27:
3118
3066
  case "end":
3119
3067
  return _context3.stop();
3120
3068
  }
3121
3069
  }, _callee3, this, [[0, 24]]);
3122
3070
  }));
3123
- function registerPILCommercialUsePolicy(_x3) {
3124
- return _registerPILCommercialUsePolicy.apply(this, arguments);
3071
+ function registerCommercialUsePIL(_x3) {
3072
+ return _registerCommercialUsePIL.apply(this, arguments);
3125
3073
  }
3126
- return registerPILCommercialUsePolicy;
3127
- }())
3074
+ return registerCommercialUsePIL;
3075
+ }()
3076
+ /**
3077
+ * Convenient function to register a PIL commercial Remix license to the registry.
3078
+ * @param request The request object that contains all data needed to register license.
3079
+ * @param request.mintingFee The fee to be paid when minting a license.
3080
+ * @param request.commercialRevShare Percentage of revenue that must be shared with the licensor.
3081
+ * @param request.currency The ERC20 token to be used to pay the minting fee. the token must be registered in story protocol.
3082
+ * @param request.royaltyPolicy The address of the royalty policy contract which required to StoryProtocol in advance.
3083
+ * @param request.txOptions [Optional] The transaction options.
3084
+ * @returns A Promise that resolves to an object containing the optional transaction hash and optional license ID.
3085
+ * @emits LicenseTermsRegistered (licenseTermsId, licenseTemplate, licenseTerms);
3086
+ */
3087
+ )
3128
3088
  }, {
3129
- key: "getPolicyId",
3130
- value: function () {
3131
- var _getPolicyId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(transferable, frameworkData, royaltyData, mintingFee, mintingFeeToken, royaltyPolicy, policyFramework) {
3132
- var data;
3089
+ key: "registerCommercialRemixPIL",
3090
+ value: (function () {
3091
+ var _registerCommercialRemixPIL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(request) {
3092
+ var _request$txOptions3, licenseTerms, licenseTermsId, _yield$this$rpcClient3, call, txHash, targetLogs;
3133
3093
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
3134
3094
  while (1) switch (_context4.prev = _context4.next) {
3135
3095
  case 0:
3136
- _context4.next = 2;
3137
- return this.rpcClient.readContract(_objectSpread2(_objectSpread2({}, this.licensingModuleConfig), {}, {
3138
- functionName: "getPolicyId",
3139
- args: [{
3140
- isLicenseTransferable: transferable,
3141
- policyFramework: policyFramework || this.pilPolicyFrameworkManagerConfig.address,
3142
- frameworkData: frameworkData,
3143
- royaltyPolicy: royaltyPolicy,
3144
- royaltyData: royaltyData,
3145
- mintingFee: parseToBigInt(mintingFee),
3146
- mintingFeeToken: mintingFeeToken
3147
- }]
3148
- }));
3149
- case 2:
3150
- data = _context4.sent;
3151
- return _context4.abrupt("return", Number(data));
3096
+ _context4.prev = 0;
3097
+ licenseTerms = {
3098
+ transferable: true,
3099
+ royaltyPolicy: this.royaltyPolicyLAPConfig.address,
3100
+ mintingFee: BigInt(request.mintingFee),
3101
+ expiration: BigInt(0),
3102
+ commercialUse: true,
3103
+ commercialAttribution: true,
3104
+ commercializerChecker: viem.zeroAddress,
3105
+ commercializerCheckerData: viem.zeroAddress,
3106
+ commercialRevShare: request.commercialRevShare,
3107
+ commercialRevCelling: BigInt(0),
3108
+ derivativesAllowed: true,
3109
+ derivativesAttribution: true,
3110
+ derivativesApproval: false,
3111
+ derivativesReciprocal: true,
3112
+ derivativeRevCelling: BigInt(0),
3113
+ currency: request.currency
3114
+ };
3115
+ _context4.next = 4;
3116
+ return this.getLicenseTermsId(licenseTerms);
3152
3117
  case 4:
3118
+ licenseTermsId = _context4.sent;
3119
+ if (!(licenseTermsId !== 0)) {
3120
+ _context4.next = 7;
3121
+ break;
3122
+ }
3123
+ return _context4.abrupt("return", {
3124
+ licenseId: licenseTermsId.toString()
3125
+ });
3126
+ case 7:
3127
+ _context4.next = 9;
3128
+ return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.licenseTemplateConfig), {}, {
3129
+ functionName: "registerLicenseTerms",
3130
+ args: [licenseTerms],
3131
+ account: this.wallet.account
3132
+ }));
3133
+ case 9:
3134
+ _yield$this$rpcClient3 = _context4.sent;
3135
+ call = _yield$this$rpcClient3.request;
3136
+ _context4.next = 13;
3137
+ return this.wallet.writeContract(call);
3138
+ case 13:
3139
+ txHash = _context4.sent;
3140
+ if (!((_request$txOptions3 = request.txOptions) !== null && _request$txOptions3 !== void 0 && _request$txOptions3.waitForTransaction)) {
3141
+ _context4.next = 21;
3142
+ break;
3143
+ }
3144
+ _context4.next = 17;
3145
+ return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, this.licenseTemplateConfig), {}, {
3146
+ eventName: "LicenseTermsRegistered"
3147
+ }));
3148
+ case 17:
3149
+ targetLogs = _context4.sent;
3150
+ return _context4.abrupt("return", {
3151
+ txHash: txHash,
3152
+ licenseId: targetLogs[0].args.licenseTermsId.toString()
3153
+ });
3154
+ case 21:
3155
+ return _context4.abrupt("return", {
3156
+ txHash: txHash
3157
+ });
3158
+ case 22:
3159
+ _context4.next = 27;
3160
+ break;
3161
+ case 24:
3162
+ _context4.prev = 24;
3163
+ _context4.t0 = _context4["catch"](0);
3164
+ handleError(_context4.t0, "Failed to register commercial remix PIL");
3165
+ case 27:
3153
3166
  case "end":
3154
3167
  return _context4.stop();
3155
3168
  }
3156
- }, _callee4, this);
3169
+ }, _callee4, this, [[0, 24]]);
3157
3170
  }));
3158
- function getPolicyId(_x4, _x5, _x6, _x7, _x8, _x9, _x10) {
3159
- return _getPolicyId.apply(this, arguments);
3171
+ function registerCommercialRemixPIL(_x4) {
3172
+ return _registerCommercialRemixPIL.apply(this, arguments);
3160
3173
  }
3161
- return getPolicyId;
3174
+ return registerCommercialRemixPIL;
3162
3175
  }()
3163
- }, {
3164
- key: "encodeFrameworkData",
3165
- value: function encodeFrameworkData(data) {
3166
- return typedDataToBytes({
3167
- "interface": "(bool, bool, bool, address, bytes, uint32, bool, bool, bool, bool, string[], string[], string[])",
3168
- data: [[data.attribution, data.commercialUse, data.commercialAttribution, data.commercializerChecker, data.commercializerCheckerData, data.commercialRevShare, data.derivativesAllowed, data.derivativesAttribution, data.derivativesApproval, data.derivativesReciprocal, data.territories, data.distributionChannels, data.contentRestrictions]]
3169
- });
3170
- }
3171
-
3172
3176
  /**
3173
- * Adds a policy to the set of policies of an IP
3174
- * @param request The request object containing details to add a policy to an IP
3175
- * @param request.ipId The id of the IP
3176
- * @param request.polId The id of the policy
3177
- * @return the transaction hash and the index of the policy in the IP's policy set if the txOptions.waitForTransaction is set to true
3177
+ * Attaches license terms to an IP, and the function must be called by the IP owner or an authorized operator.
3178
+ * @param request The request object that contains all data needed to attach license terms.
3179
+ @param request.ipId The IP ID.
3180
+ @param request.tokenAddress The address of the NFT.
3181
+ @param request.licenseTemplate The address of the license template.
3182
+ @param request.licenseTermsId The ID of the license terms.
3183
+ * @param request.txOptions [Optional] The transaction options.
3184
+ * @returns A Promise that resolves to an object containing the transaction hash.
3178
3185
  */
3186
+ )
3179
3187
  }, {
3180
- key: "addPolicyToIp",
3188
+ key: "attachLicenseTerms",
3181
3189
  value: (function () {
3182
- var _addPolicyToIp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(request) {
3183
- var _request$txOptions4, IPAccountConfig, _yield$this$rpcClient4, call, txHash, targetLogs;
3190
+ var _attachLicenseTerms = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(request) {
3191
+ var _request$txOptions4;
3192
+ var _yield$this$rpcClient4, call, txHash;
3184
3193
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
3185
3194
  while (1) switch (_context5.prev = _context5.next) {
3186
3195
  case 0:
3187
- _context5.prev = 0;
3188
- IPAccountConfig = {
3189
- abi: this.ipAccountABI,
3190
- address: viem.getAddress(request.ipId)
3191
- };
3192
- _context5.next = 4;
3193
- return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, IPAccountConfig), {}, {
3194
- functionName: "execute",
3195
- args: [this.licensingModuleConfig.address, parseToBigInt(0), viem.encodeFunctionData({
3196
- abi: this.licensingModuleConfig.abi,
3197
- functionName: "addPolicyToIp",
3198
- args: [viem.getAddress(request.ipId), parseToBigInt(request.policyId)]
3199
- })],
3196
+ _context5.next = 2;
3197
+ return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.licensingModuleConfig), {}, {
3198
+ functionName: "attachLicenseTerms",
3199
+ args: [request.ipId, request.licenseTemplate || this.licenseTemplateConfig.address, BigInt(request.licenseTermsId)],
3200
3200
  account: this.wallet.account
3201
3201
  }));
3202
- case 4:
3202
+ case 2:
3203
3203
  _yield$this$rpcClient4 = _context5.sent;
3204
3204
  call = _yield$this$rpcClient4.request;
3205
- _context5.next = 8;
3205
+ _context5.next = 6;
3206
3206
  return this.wallet.writeContract(call);
3207
- case 8:
3207
+ case 6:
3208
3208
  txHash = _context5.sent;
3209
3209
  if (!((_request$txOptions4 = request.txOptions) !== null && _request$txOptions4 !== void 0 && _request$txOptions4.waitForTransaction)) {
3210
- _context5.next = 16;
3210
+ _context5.next = 13;
3211
+ break;
3212
+ }
3213
+ _context5.next = 10;
3214
+ return waitTx(this.rpcClient, txHash);
3215
+ case 10:
3216
+ return _context5.abrupt("return", {
3217
+ txHash: txHash
3218
+ });
3219
+ case 13:
3220
+ return _context5.abrupt("return", {
3221
+ txHash: txHash
3222
+ });
3223
+ case 14:
3224
+ case "end":
3225
+ return _context5.stop();
3226
+ }
3227
+ }, _callee5, this);
3228
+ }));
3229
+ function attachLicenseTerms(_x5) {
3230
+ return _attachLicenseTerms.apply(this, arguments);
3231
+ }
3232
+ return attachLicenseTerms;
3233
+ }()
3234
+ /**
3235
+ * Mints license tokens for the license terms attached to an IP.
3236
+ * The license tokens are minted to the receiver.
3237
+ * The license terms must be attached to the IP before calling this function.
3238
+ * But it can mint license token of default license terms without attaching the default license terms,
3239
+ * since it is attached to all IPs by default.
3240
+ * IP owners can mint license tokens for their IPs for arbitrary license terms
3241
+ * without attaching the license terms to IP.
3242
+ * It might require the caller pay the minting fee, depending on the license terms or configured by the iP owner.
3243
+ * The minting fee is paid in the minting fee token specified in the license terms or configured by the IP owner.
3244
+ * IP owners can configure the minting fee of their IPs or
3245
+ * configure the minting fee module to determine the minting fee.
3246
+ * @param request The request object that contains all data needed to mint license tokens.
3247
+ * @param request.licensorIpId The licensor IP ID.
3248
+ * @param request.licenseTemplate The address of the license template.
3249
+ * @param request.licenseTermsId The ID of the license terms within the license template.
3250
+ * @param request.amount The amount of license tokens to mint.
3251
+ * @param request.receiver The address of the receiver.
3252
+ * @param request.txOptions [Optional] The transaction options.
3253
+ * @returns A Promise that resolves to an object containing the transaction hash and optional license token ID if waitForTxn is set to true.
3254
+ * @emits LicenseTokensMinted (msg.sender, licensorIpId, licenseTemplate, licenseTermsId, amount, receiver, startLicenseTokenId);
3255
+ */
3256
+ )
3257
+ }, {
3258
+ key: "mintLicenseTokens",
3259
+ value: (function () {
3260
+ var _mintLicenseTokens = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(request) {
3261
+ var _request$txOptions5, _yield$this$rpcClient5, call, txHash, targetLogs;
3262
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
3263
+ while (1) switch (_context6.prev = _context6.next) {
3264
+ case 0:
3265
+ _context6.prev = 0;
3266
+ _context6.next = 3;
3267
+ return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.licensingModuleConfig), {}, {
3268
+ functionName: "mintLicenseTokens",
3269
+ args: [request.licensorIpId, request.licenseTemplate || this.licenseTemplateConfig.address, BigInt(request.licenseTermsId), BigInt(request.amount || 1), request.receiver || this.wallet.account.address, viem.zeroAddress],
3270
+ account: this.wallet.account
3271
+ }));
3272
+ case 3:
3273
+ _yield$this$rpcClient5 = _context6.sent;
3274
+ call = _yield$this$rpcClient5.request;
3275
+ _context6.next = 7;
3276
+ return this.wallet.writeContract(call);
3277
+ case 7:
3278
+ txHash = _context6.sent;
3279
+ if (!((_request$txOptions5 = request.txOptions) !== null && _request$txOptions5 !== void 0 && _request$txOptions5.waitForTransaction)) {
3280
+ _context6.next = 15;
3211
3281
  break;
3212
3282
  }
3213
- _context5.next = 12;
3283
+ _context6.next = 11;
3214
3284
  return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, this.licensingModuleConfig), {}, {
3215
- eventName: "PolicyAddedToIpId"
3285
+ eventName: "LicenseTokensMinted"
3216
3286
  }));
3217
- case 12:
3218
- targetLogs = _context5.sent;
3219
- return _context5.abrupt("return", {
3287
+ case 11:
3288
+ targetLogs = _context6.sent;
3289
+ return _context6.abrupt("return", {
3220
3290
  txHash: txHash,
3221
- index: targetLogs[0].args.index.toString()
3291
+ licenseTokenId: targetLogs[0].args.startLicenseTokenId.toString()
3222
3292
  });
3223
- case 16:
3224
- return _context5.abrupt("return", {
3293
+ case 15:
3294
+ return _context6.abrupt("return", {
3225
3295
  txHash: txHash
3226
3296
  });
3227
- case 17:
3228
- _context5.next = 22;
3297
+ case 16:
3298
+ _context6.next = 21;
3229
3299
  break;
3230
- case 19:
3231
- _context5.prev = 19;
3232
- _context5.t0 = _context5["catch"](0);
3233
- handleError(_context5.t0, "Failed to add policy to IP");
3234
- case 22:
3300
+ case 18:
3301
+ _context6.prev = 18;
3302
+ _context6.t0 = _context6["catch"](0);
3303
+ handleError(_context6.t0, "Failed to mint license tokens");
3304
+ case 21:
3235
3305
  case "end":
3236
- return _context5.stop();
3306
+ return _context6.stop();
3237
3307
  }
3238
- }, _callee5, this, [[0, 19]]);
3308
+ }, _callee6, this, [[0, 18]]);
3239
3309
  }));
3240
- function addPolicyToIp(_x11) {
3241
- return _addPolicyToIp.apply(this, arguments);
3310
+ function mintLicenseTokens(_x6) {
3311
+ return _mintLicenseTokens.apply(this, arguments);
3242
3312
  }
3243
- return addPolicyToIp;
3313
+ return mintLicenseTokens;
3244
3314
  }())
3245
3315
  }]);
3246
3316
  }();
3247
3317
 
3248
3318
  var DisputeClient = /*#__PURE__*/function () {
3249
- function DisputeClient(rpcClient, wallet) {
3319
+ function DisputeClient(rpcClient, wallet, chainId) {
3250
3320
  _classCallCheck(this, DisputeClient);
3251
- _defineProperty(this, "disputeModuleConfig", DisputeModuleConfig);
3252
3321
  this.rpcClient = rpcClient;
3253
3322
  this.wallet = wallet;
3323
+ this.disputeModuleConfig = getDisputeModuleConfig(chainId);
3254
3324
  }
3255
3325
 
3256
3326
  /**
@@ -3636,30 +3706,166 @@ var StoryAPIClient = /*#__PURE__*/function () {
3636
3706
  }
3637
3707
  return getLicense;
3638
3708
  }()
3709
+ }]);
3710
+ }();
3711
+
3712
+ var RoyaltyClient = /*#__PURE__*/function () {
3713
+ function RoyaltyClient(rpcClient, wallet, chainId) {
3714
+ _classCallCheck(this, RoyaltyClient);
3715
+ this.rpcClient = rpcClient;
3716
+ this.wallet = wallet;
3717
+ this.royaltyVaultImplConfig = getRoyaltyVaultImplConfig(chainId);
3718
+ this.royaltyPolicyLAPConfig = getRoyaltyPolicyLAPConfig(chainId);
3719
+ this.royaltyModuleConfig = getRoyaltyModuleConfig(chainId);
3720
+ }
3721
+ /**
3722
+ * Allows ancestors to claim the royalty tokens and any accrued revenue tokens
3723
+ * @param request - the licensing parameters for the Programmable IP License v1 (PIL) standard.
3724
+ * @param request.ancestorIpId The ip id of the ancestor to whom the royalty tokens belong to.
3725
+ * @param request.txOptions [Optional] The transaction options.
3726
+ * @returns Tx hash for the transaction.
3727
+ * @emits RoyaltyTokensCollected (ancestorIpId, ancestorsRoyalty)
3728
+ */
3729
+ return _createClass(RoyaltyClient, [{
3730
+ key: "collectRoyaltyTokens",
3731
+ value: (function () {
3732
+ var _collectRoyaltyTokens = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
3733
+ var proxyAddress, _yield$this$rpcClient, call, txHash;
3734
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
3735
+ while (1) switch (_context.prev = _context.next) {
3736
+ case 0:
3737
+ _context.prev = 0;
3738
+ _context.next = 3;
3739
+ return this.getProxyAddress(request.derivativeId);
3740
+ case 3:
3741
+ proxyAddress = _context.sent;
3742
+ if (proxyAddress) {
3743
+ _context.next = 6;
3744
+ break;
3745
+ }
3746
+ throw new Error("Proxy address not found");
3747
+ case 6:
3748
+ _context.next = 8;
3749
+ return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.royaltyVaultImplConfig), {}, {
3750
+ address: proxyAddress,
3751
+ functionName: "collectRoyaltyTokens",
3752
+ args: [request.ancestorIpId],
3753
+ account: this.wallet.account
3754
+ }));
3755
+ case 8:
3756
+ _yield$this$rpcClient = _context.sent;
3757
+ call = _yield$this$rpcClient.request;
3758
+ _context.next = 12;
3759
+ return this.wallet.writeContract(call);
3760
+ case 12:
3761
+ txHash = _context.sent;
3762
+ return _context.abrupt("return", {
3763
+ txHash: txHash
3764
+ });
3765
+ case 16:
3766
+ _context.prev = 16;
3767
+ _context.t0 = _context["catch"](0);
3768
+ handleError(_context.t0, "Failed to collect royalty tokens");
3769
+ case 19:
3770
+ case "end":
3771
+ return _context.stop();
3772
+ }
3773
+ }, _callee, this, [[0, 16]]);
3774
+ }));
3775
+ function collectRoyaltyTokens(_x) {
3776
+ return _collectRoyaltyTokens.apply(this, arguments);
3777
+ }
3778
+ return collectRoyaltyTokens;
3779
+ }())
3639
3780
  }, {
3640
- key: "getPolicy",
3781
+ key: "getProxyAddress",
3641
3782
  value: function () {
3642
- var _getPolicy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(policyId) {
3643
- var policyResp;
3783
+ var _getProxyAddress = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(derivativeID) {
3784
+ var data;
3785
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
3786
+ while (1) switch (_context2.prev = _context2.next) {
3787
+ case 0:
3788
+ _context2.next = 2;
3789
+ return this.rpcClient.readContract(_objectSpread2(_objectSpread2({}, this.royaltyPolicyLAPConfig), {}, {
3790
+ functionName: "getRoyaltyData",
3791
+ args: [derivativeID]
3792
+ }));
3793
+ case 2:
3794
+ data = _context2.sent;
3795
+ if (!(Array.isArray(data) && data[1])) {
3796
+ _context2.next = 5;
3797
+ break;
3798
+ }
3799
+ return _context2.abrupt("return", data[1]);
3800
+ case 5:
3801
+ case "end":
3802
+ return _context2.stop();
3803
+ }
3804
+ }, _callee2, this);
3805
+ }));
3806
+ function getProxyAddress(_x2) {
3807
+ return _getProxyAddress.apply(this, arguments);
3808
+ }
3809
+ return getProxyAddress;
3810
+ }()
3811
+ /**
3812
+ * Allows the function caller to pay royalties to the receiver IP asset on behalf of the payer IP asset.
3813
+ * @param request - The request object that contains all data needed to pay royalty on behalf.
3814
+ * @param request.receiverIpId The ipId that receives the royalties.
3815
+ * @param request.payerIpId The ID of the IP asset that pays the royalties.
3816
+ * @param request.token The token to use to pay the royalties.
3817
+ * @param request.amount The amount to pay.
3818
+ * @param request.txOptions [Optional] The transaction options.
3819
+ * @returns A Promise that resolves to an object containing the transaction hash.
3820
+ * @emits RoyaltyPaid (receiverIpId, payerIpId, msg.sender, token, amount)
3821
+ */
3822
+ }, {
3823
+ key: "payRoyaltyOnBehalf",
3824
+ value: (function () {
3825
+ var _payRoyaltyOnBehalf = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(request) {
3826
+ var _request$txOptions, _yield$this$rpcClient2, call, txHash;
3644
3827
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
3645
3828
  while (1) switch (_context3.prev = _context3.next) {
3646
3829
  case 0:
3647
- _context3.next = 2;
3648
- return this.httpClient.get("/api/v1/policies/".concat(policyId));
3649
- case 2:
3650
- policyResp = _context3.sent;
3651
- return _context3.abrupt("return", policyResp.data.data);
3652
- case 4:
3830
+ _context3.prev = 0;
3831
+ _context3.next = 3;
3832
+ return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.royaltyModuleConfig), {}, {
3833
+ functionName: "payRoyaltyOnBehalf",
3834
+ args: [request.receiverIpId, request.payerIpId, request.token, request.amount],
3835
+ account: this.wallet.account
3836
+ }));
3837
+ case 3:
3838
+ _yield$this$rpcClient2 = _context3.sent;
3839
+ call = _yield$this$rpcClient2.request;
3840
+ _context3.next = 7;
3841
+ return this.wallet.writeContract(call);
3842
+ case 7:
3843
+ txHash = _context3.sent;
3844
+ if (!((_request$txOptions = request.txOptions) !== null && _request$txOptions !== void 0 && _request$txOptions.waitForTransaction)) {
3845
+ _context3.next = 11;
3846
+ break;
3847
+ }
3848
+ _context3.next = 11;
3849
+ return waitTx(this.rpcClient, txHash);
3850
+ case 11:
3851
+ return _context3.abrupt("return", {
3852
+ txHash: txHash
3853
+ });
3854
+ case 14:
3855
+ _context3.prev = 14;
3856
+ _context3.t0 = _context3["catch"](0);
3857
+ handleError(_context3.t0, "Failed to pay royalty on behalf");
3858
+ case 17:
3653
3859
  case "end":
3654
3860
  return _context3.stop();
3655
3861
  }
3656
- }, _callee3, this);
3862
+ }, _callee3, this, [[0, 14]]);
3657
3863
  }));
3658
- function getPolicy(_x3) {
3659
- return _getPolicy.apply(this, arguments);
3864
+ function payRoyaltyOnBehalf(_x3) {
3865
+ return _payRoyaltyOnBehalf.apply(this, arguments);
3660
3866
  }
3661
- return getPolicy;
3662
- }()
3867
+ return payRoyaltyOnBehalf;
3868
+ }())
3663
3869
  }]);
3664
3870
  }();
3665
3871
 
@@ -3678,15 +3884,17 @@ var StoryClient = /*#__PURE__*/function () {
3678
3884
  _defineProperty(this, "_ipAsset", null);
3679
3885
  _defineProperty(this, "_permission", null);
3680
3886
  _defineProperty(this, "_license", null);
3681
- _defineProperty(this, "_policy", null);
3682
3887
  _defineProperty(this, "_dispute", null);
3683
3888
  _defineProperty(this, "_ipAccount", null);
3684
- this.config = config;
3889
+ _defineProperty(this, "_royalty", null);
3890
+ this.config = _objectSpread2(_objectSpread2({}, config), {}, {
3891
+ chainId: config.chainId || "sepolia"
3892
+ });
3685
3893
  if (!this.config.transport) {
3686
3894
  throw new Error("transport is null, please pass in a valid RPC Provider URL as the transport.");
3687
3895
  }
3688
3896
  var clientConfig = {
3689
- chain: chainStringToViemChain(this.config.chainId || "sepolia"),
3897
+ chain: chainStringToViemChain(this.config.chainId),
3690
3898
  transport: this.config.transport
3691
3899
  };
3692
3900
  this.rpcClient = viem.createPublicClient(clientConfig);
@@ -3695,7 +3903,7 @@ var StoryClient = /*#__PURE__*/function () {
3695
3903
  if (!account) {
3696
3904
  throw new Error("account is null");
3697
3905
  }
3698
- this.wallet = viem.createWalletClient(_objectSpread2(_objectSpread2({}, clientConfig), {}, {
3906
+ this.wallet = config.wallet || viem.createWalletClient(_objectSpread2(_objectSpread2({}, clientConfig), {}, {
3699
3907
  account: account
3700
3908
  }));
3701
3909
  }
@@ -3716,7 +3924,7 @@ var StoryClient = /*#__PURE__*/function () {
3716
3924
  */
3717
3925
  function get() {
3718
3926
  if (this._ipAsset === null) {
3719
- this._ipAsset = new IPAssetClient(this.rpcClient, this.wallet, this.storyClient);
3927
+ this._ipAsset = new IPAssetClient(this.rpcClient, this.wallet, this.config.chainId);
3720
3928
  }
3721
3929
  return this._ipAsset;
3722
3930
  }
@@ -3731,7 +3939,7 @@ var StoryClient = /*#__PURE__*/function () {
3731
3939
  key: "permission",
3732
3940
  get: function get() {
3733
3941
  if (this._permission === null) {
3734
- this._permission = new PermissionClient(this.rpcClient, this.wallet);
3942
+ this._permission = new PermissionClient(this.rpcClient, this.wallet, this.config.chainId);
3735
3943
  }
3736
3944
  return this._permission;
3737
3945
  }
@@ -3746,26 +3954,11 @@ var StoryClient = /*#__PURE__*/function () {
3746
3954
  key: "license",
3747
3955
  get: function get() {
3748
3956
  if (this._license === null) {
3749
- this._license = new LicenseClient(this.rpcClient, this.wallet, this.storyClient);
3957
+ this._license = new LicenseClient(this.rpcClient, this.wallet, this.storyClient, this.config.chainId);
3750
3958
  }
3751
3959
  return this._license;
3752
3960
  }
3753
3961
 
3754
- /**
3755
- * Getter for the policy client. The client is lazily created when
3756
- * this method is called.
3757
- *
3758
- * @returns the PolicyClient instance
3759
- */
3760
- }, {
3761
- key: "policy",
3762
- get: function get() {
3763
- if (this._policy === null) {
3764
- this._policy = new PolicyClient(this.rpcClient, this.wallet);
3765
- }
3766
- return this._policy;
3767
- }
3768
-
3769
3962
  /**
3770
3963
  * Getter for the dispute client. The client is lazily created when
3771
3964
  * this method is called.
@@ -3776,7 +3969,7 @@ var StoryClient = /*#__PURE__*/function () {
3776
3969
  key: "dispute",
3777
3970
  get: function get() {
3778
3971
  if (this._dispute === null) {
3779
- this._dispute = new DisputeClient(this.rpcClient, this.wallet);
3972
+ this._dispute = new DisputeClient(this.rpcClient, this.wallet, this.config.chainId);
3780
3973
  }
3781
3974
  return this._dispute;
3782
3975
  }
@@ -3795,6 +3988,20 @@ var StoryClient = /*#__PURE__*/function () {
3795
3988
  }
3796
3989
  return this._ipAccount;
3797
3990
  }
3991
+ /**
3992
+ * Getter for the royalty client. The client is lazily created when
3993
+ * this method is called.
3994
+ *
3995
+ * @returns the RoyaltyClient instance
3996
+ */
3997
+ }, {
3998
+ key: "royalty",
3999
+ get: function get() {
4000
+ if (this._royalty === null) {
4001
+ this._royalty = new RoyaltyClient(this.rpcClient, this.wallet, this.config.chainId);
4002
+ }
4003
+ return this._royalty;
4004
+ }
3798
4005
  }], [{
3799
4006
  key: "newClient",
3800
4007
  value: function newClient(config) {
@@ -3803,11 +4010,13 @@ var StoryClient = /*#__PURE__*/function () {
3803
4010
  }]);
3804
4011
  }();
3805
4012
 
4013
+ var AddressZero = "0x0000000000000000000000000000000000000000";
4014
+ var HashZero = "0x0000000000000000000000000000000000000000000000000000000000000000";
4015
+
3806
4016
  exports.AddressZero = AddressZero;
3807
4017
  exports.DisputeClient = DisputeClient;
3808
4018
  exports.HashZero = HashZero;
3809
4019
  exports.IPAssetClient = IPAssetClient;
3810
4020
  exports.LicenseClient = LicenseClient;
3811
4021
  exports.PermissionClient = PermissionClient;
3812
- exports.PolicyClient = PolicyClient;
3813
4022
  exports.StoryClient = StoryClient;