@story-protocol/core-sdk 0.0.1-beta-rc.12 → 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 (30) hide show
  1. package/dist/declarations/src/client.d.ts +0 -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 +1 -3
  6. package/dist/declarations/src/index.d.ts.map +1 -1
  7. package/dist/declarations/src/resources/dispute.d.ts +321 -5
  8. package/dist/declarations/src/resources/dispute.d.ts.map +1 -1
  9. package/dist/declarations/src/resources/ipAccount.d.ts +321 -5
  10. package/dist/declarations/src/resources/ipAccount.d.ts.map +1 -1
  11. package/dist/declarations/src/resources/license.d.ts +2955 -211
  12. package/dist/declarations/src/resources/license.d.ts.map +1 -1
  13. package/dist/declarations/src/resources/permission.d.ts +642 -10
  14. package/dist/declarations/src/resources/permission.d.ts.map +1 -1
  15. package/dist/declarations/src/resources/royalty.d.ts +963 -15
  16. package/dist/declarations/src/resources/royalty.d.ts.map +1 -1
  17. package/dist/declarations/src/types/config.d.ts +2 -1
  18. package/dist/declarations/src/types/config.d.ts.map +1 -1
  19. package/dist/declarations/src/types/resources/ipAsset.d.ts +1 -1
  20. package/dist/declarations/src/types/resources/ipAsset.d.ts.map +1 -1
  21. package/dist/declarations/src/types/resources/license.d.ts +54 -18
  22. package/dist/declarations/src/types/resources/license.d.ts.map +1 -1
  23. package/dist/story-protocol-core-sdk.cjs.dev.js +863 -905
  24. package/dist/story-protocol-core-sdk.cjs.prod.js +863 -905
  25. package/dist/story-protocol-core-sdk.esm.js +865 -906
  26. package/package.json +5 -5
  27. package/dist/declarations/src/resources/policy.d.ts +0 -3253
  28. package/dist/declarations/src/resources/policy.d.ts.map +0 -1
  29. package/dist/declarations/src/types/resources/policy.d.ts +0 -83
  30. package/dist/declarations/src/types/resources/policy.d.ts.map +0 -1
@@ -1,4 +1,4 @@
1
- import { encodeAbiParameters, parseAbiParameters, defineChain, decodeEventLog, getAddress, encodeFunctionData, zeroAddress, stringToHex, createPublicClient, createWalletClient } from 'viem';
1
+ import { defineChain, decodeEventLog, getAddress, encodeFunctionData, zeroAddress, stringToHex, createPublicClient, createWalletClient } from 'viem';
2
2
  import * as dotenv from 'dotenv';
3
3
  import { sepolia as sepolia$1 } from 'viem/chains';
4
4
  import axios from 'axios';
@@ -581,9 +581,6 @@ function _waitTx() {
581
581
  }));
582
582
  return _waitTx.apply(this, arguments);
583
583
  }
584
- function typedDataToBytes(typedData) {
585
- return encodeAbiParameters(parseAbiParameters(typedData["interface"]), typedData.data);
586
- }
587
584
  function chainStringToViemChain(chainId) {
588
585
  switch (chainId) {
589
586
  case "11155111":
@@ -1058,170 +1055,88 @@ var LicensingModuleABI = [{
1058
1055
  type: "address"
1059
1056
  }, {
1060
1057
  indexed: false,
1061
- internalType: "address[]",
1062
- name: "parentIpIds",
1063
- type: "address[]"
1064
- }],
1065
- name: "IpIdLinkedToParents",
1066
- type: "event"
1067
- }, {
1068
- anonymous: false,
1069
- inputs: [{
1070
- indexed: true,
1071
- internalType: "address",
1072
- name: "caller",
1073
- type: "address"
1074
- }, {
1075
- indexed: true,
1076
1058
  internalType: "address",
1077
- name: "ipId",
1059
+ name: "licenseTemplate",
1078
1060
  type: "address"
1079
- }, {
1080
- indexed: true,
1081
- internalType: "uint256",
1082
- name: "policyId",
1083
- type: "uint256"
1084
1061
  }, {
1085
1062
  indexed: false,
1086
1063
  internalType: "uint256",
1087
- name: "index",
1064
+ name: "licenseTermsId",
1088
1065
  type: "uint256"
1089
- }, {
1090
- indexed: false,
1091
- internalType: "bool",
1092
- name: "isInherited",
1093
- type: "bool"
1094
1066
  }],
1095
- name: "PolicyAddedToIpId",
1067
+ name: "LicenseTermsAttached",
1096
1068
  type: "event"
1097
1069
  }, {
1098
1070
  anonymous: false,
1099
1071
  inputs: [{
1100
1072
  indexed: true,
1101
- internalType: "uint256",
1102
- name: "policyId",
1103
- type: "uint256"
1073
+ internalType: "address",
1074
+ name: "caller",
1075
+ type: "address"
1104
1076
  }, {
1105
1077
  indexed: true,
1106
1078
  internalType: "address",
1107
- name: "policyFrameworkManager",
1079
+ name: "licensorIpId",
1108
1080
  type: "address"
1109
- }, {
1110
- indexed: false,
1111
- internalType: "bytes",
1112
- name: "frameworkData",
1113
- type: "bytes"
1114
1081
  }, {
1115
1082
  indexed: false,
1116
1083
  internalType: "address",
1117
- name: "royaltyPolicy",
1084
+ name: "licenseTemplate",
1118
1085
  type: "address"
1119
1086
  }, {
1120
- indexed: false,
1121
- internalType: "bytes",
1122
- name: "royaltyData",
1123
- type: "bytes"
1087
+ indexed: true,
1088
+ internalType: "uint256",
1089
+ name: "licenseTermsId",
1090
+ type: "uint256"
1124
1091
  }, {
1125
1092
  indexed: false,
1126
1093
  internalType: "uint256",
1127
- name: "mintingFee",
1094
+ name: "amount",
1128
1095
  type: "uint256"
1129
1096
  }, {
1130
1097
  indexed: false,
1131
1098
  internalType: "address",
1132
- name: "mintingFeeToken",
1099
+ name: "receiver",
1133
1100
  type: "address"
1101
+ }, {
1102
+ indexed: false,
1103
+ internalType: "uint256",
1104
+ name: "startLicenseTokenId",
1105
+ type: "uint256"
1134
1106
  }],
1135
- name: "PolicyRegistered",
1107
+ name: "LicenseTokensMinted",
1136
1108
  type: "event"
1137
1109
  }, {
1138
1110
  inputs: [{
1139
1111
  internalType: "address",
1140
1112
  name: "ipId",
1141
1113
  type: "address"
1114
+ }, {
1115
+ internalType: "address",
1116
+ name: "licenseTemplate",
1117
+ type: "address"
1142
1118
  }, {
1143
1119
  internalType: "uint256",
1144
- name: "polId",
1145
- type: "uint256"
1146
- }],
1147
- name: "addPolicyToIp",
1148
- outputs: [{
1149
- internalType: "uint256",
1150
- name: "indexOnIpId",
1120
+ name: "licenseTermsId",
1151
1121
  type: "uint256"
1152
1122
  }],
1123
+ name: "attachLicenseTerms",
1124
+ outputs: [],
1153
1125
  stateMutability: "nonpayable",
1154
1126
  type: "function"
1155
1127
  }, {
1156
1128
  inputs: [{
1157
- components: [{
1158
- internalType: "bool",
1159
- name: "isLicenseTransferable",
1160
- type: "bool"
1161
- }, {
1162
- internalType: "address",
1163
- name: "policyFramework",
1164
- type: "address"
1165
- }, {
1166
- internalType: "bytes",
1167
- name: "frameworkData",
1168
- type: "bytes"
1169
- }, {
1170
- internalType: "address",
1171
- name: "royaltyPolicy",
1172
- type: "address"
1173
- }, {
1174
- internalType: "bytes",
1175
- name: "royaltyData",
1176
- type: "bytes"
1177
- }, {
1178
- internalType: "uint256",
1179
- name: "mintingFee",
1180
- type: "uint256"
1181
- }, {
1182
- internalType: "address",
1183
- name: "mintingFeeToken",
1184
- type: "address"
1185
- }],
1186
- internalType: "struct Licensing.Policy",
1187
- name: "pol",
1188
- type: "tuple"
1189
- }],
1190
- name: "getPolicyId",
1191
- outputs: [{
1192
- internalType: "uint256",
1193
- name: "policyId",
1194
- type: "uint256"
1195
- }],
1196
- stateMutability: "view",
1197
- type: "function"
1198
- }, {
1199
- inputs: [{
1200
- internalType: "uint256[]",
1201
- name: "licenseIds",
1202
- type: "uint256[]"
1129
+ internalType: "address",
1130
+ name: "licensorIpId",
1131
+ type: "address"
1203
1132
  }, {
1204
1133
  internalType: "address",
1205
- name: "childIpId",
1134
+ name: "licenseTemplate",
1206
1135
  type: "address"
1207
1136
  }, {
1208
- internalType: "bytes",
1209
- name: "royaltyContext",
1210
- type: "bytes"
1211
- }],
1212
- name: "linkIpToParents",
1213
- outputs: [],
1214
- stateMutability: "nonpayable",
1215
- type: "function"
1216
- }, {
1217
- inputs: [{
1218
1137
  internalType: "uint256",
1219
- name: "policyId",
1138
+ name: "licenseTermsId",
1220
1139
  type: "uint256"
1221
- }, {
1222
- internalType: "address",
1223
- name: "licensorIpId",
1224
- type: "address"
1225
1140
  }, {
1226
1141
  internalType: "uint256",
1227
1142
  name: "amount",
@@ -1235,60 +1150,116 @@ var LicensingModuleABI = [{
1235
1150
  name: "royaltyContext",
1236
1151
  type: "bytes"
1237
1152
  }],
1238
- name: "mintLicense",
1153
+ name: "mintLicenseTokens",
1239
1154
  outputs: [{
1240
1155
  internalType: "uint256",
1241
- name: "licenseId",
1156
+ name: "startLicenseTokenId",
1242
1157
  type: "uint256"
1243
1158
  }],
1244
1159
  stateMutability: "nonpayable",
1245
1160
  type: "function"
1161
+ }];
1162
+
1163
+ var PILicenseTemplateABI = [{
1164
+ anonymous: false,
1165
+ inputs: [{
1166
+ indexed: true,
1167
+ internalType: "uint256",
1168
+ name: "licenseTermsId",
1169
+ type: "uint256"
1170
+ }, {
1171
+ indexed: true,
1172
+ internalType: "address",
1173
+ name: "licenseTemplate",
1174
+ type: "address"
1175
+ }, {
1176
+ indexed: false,
1177
+ internalType: "bytes",
1178
+ name: "licenseTerms",
1179
+ type: "bytes"
1180
+ }],
1181
+ name: "LicenseTermsRegistered",
1182
+ type: "event"
1246
1183
  }, {
1247
1184
  inputs: [{
1248
1185
  components: [{
1249
1186
  internalType: "bool",
1250
- name: "isLicenseTransferable",
1187
+ name: "transferable",
1251
1188
  type: "bool"
1252
1189
  }, {
1253
1190
  internalType: "address",
1254
- name: "policyFramework",
1191
+ name: "royaltyPolicy",
1255
1192
  type: "address"
1256
1193
  }, {
1257
- internalType: "bytes",
1258
- name: "frameworkData",
1259
- type: "bytes"
1194
+ internalType: "uint256",
1195
+ name: "mintingFee",
1196
+ type: "uint256"
1197
+ }, {
1198
+ internalType: "uint256",
1199
+ name: "expiration",
1200
+ type: "uint256"
1201
+ }, {
1202
+ internalType: "bool",
1203
+ name: "commercialUse",
1204
+ type: "bool"
1205
+ }, {
1206
+ internalType: "bool",
1207
+ name: "commercialAttribution",
1208
+ type: "bool"
1260
1209
  }, {
1261
1210
  internalType: "address",
1262
- name: "royaltyPolicy",
1211
+ name: "commercializerChecker",
1263
1212
  type: "address"
1264
1213
  }, {
1265
1214
  internalType: "bytes",
1266
- name: "royaltyData",
1215
+ name: "commercializerCheckerData",
1267
1216
  type: "bytes"
1217
+ }, {
1218
+ internalType: "uint32",
1219
+ name: "commercialRevShare",
1220
+ type: "uint32"
1268
1221
  }, {
1269
1222
  internalType: "uint256",
1270
- name: "mintingFee",
1223
+ name: "commercialRevCelling",
1224
+ type: "uint256"
1225
+ }, {
1226
+ internalType: "bool",
1227
+ name: "derivativesAllowed",
1228
+ type: "bool"
1229
+ }, {
1230
+ internalType: "bool",
1231
+ name: "derivativesAttribution",
1232
+ type: "bool"
1233
+ }, {
1234
+ internalType: "bool",
1235
+ name: "derivativesApproval",
1236
+ type: "bool"
1237
+ }, {
1238
+ internalType: "bool",
1239
+ name: "derivativesReciprocal",
1240
+ type: "bool"
1241
+ }, {
1242
+ internalType: "uint256",
1243
+ name: "derivativeRevCelling",
1271
1244
  type: "uint256"
1272
1245
  }, {
1273
1246
  internalType: "address",
1274
- name: "mintingFeeToken",
1247
+ name: "currency",
1275
1248
  type: "address"
1276
1249
  }],
1277
- internalType: "struct Licensing.Policy",
1278
- name: "pol",
1250
+ internalType: "struct PILTerms",
1251
+ name: "terms",
1279
1252
  type: "tuple"
1280
1253
  }],
1281
- name: "registerPolicy",
1254
+ name: "getLicenseTermsId",
1282
1255
  outputs: [{
1283
1256
  internalType: "uint256",
1284
- name: "policyId",
1257
+ name: "selectedLicenseTermsId",
1285
1258
  type: "uint256"
1286
1259
  }],
1287
- stateMutability: "nonpayable",
1260
+ stateMutability: "view",
1288
1261
  type: "function"
1289
- }];
1290
-
1291
- var PILPolicyFrameworkManagerABI = [{
1262
+ }, {
1292
1263
  inputs: [{
1293
1264
  components: [{
1294
1265
  internalType: "bool",
@@ -1302,76 +1273,67 @@ var PILPolicyFrameworkManagerABI = [{
1302
1273
  internalType: "uint256",
1303
1274
  name: "mintingFee",
1304
1275
  type: "uint256"
1276
+ }, {
1277
+ internalType: "uint256",
1278
+ name: "expiration",
1279
+ type: "uint256"
1280
+ }, {
1281
+ internalType: "bool",
1282
+ name: "commercialUse",
1283
+ type: "bool"
1284
+ }, {
1285
+ internalType: "bool",
1286
+ name: "commercialAttribution",
1287
+ type: "bool"
1305
1288
  }, {
1306
1289
  internalType: "address",
1307
- name: "mintingFeeToken",
1290
+ name: "commercializerChecker",
1308
1291
  type: "address"
1309
1292
  }, {
1310
- components: [{
1311
- internalType: "bool",
1312
- name: "attribution",
1313
- type: "bool"
1314
- }, {
1315
- internalType: "bool",
1316
- name: "commercialUse",
1317
- type: "bool"
1318
- }, {
1319
- internalType: "bool",
1320
- name: "commercialAttribution",
1321
- type: "bool"
1322
- }, {
1323
- internalType: "address",
1324
- name: "commercializerChecker",
1325
- type: "address"
1326
- }, {
1327
- internalType: "bytes",
1328
- name: "commercializerCheckerData",
1329
- type: "bytes"
1330
- }, {
1331
- internalType: "uint32",
1332
- name: "commercialRevShare",
1333
- type: "uint32"
1334
- }, {
1335
- internalType: "bool",
1336
- name: "derivativesAllowed",
1337
- type: "bool"
1338
- }, {
1339
- internalType: "bool",
1340
- name: "derivativesAttribution",
1341
- type: "bool"
1342
- }, {
1343
- internalType: "bool",
1344
- name: "derivativesApproval",
1345
- type: "bool"
1346
- }, {
1347
- internalType: "bool",
1348
- name: "derivativesReciprocal",
1349
- type: "bool"
1350
- }, {
1351
- internalType: "string[]",
1352
- name: "territories",
1353
- type: "string[]"
1354
- }, {
1355
- internalType: "string[]",
1356
- name: "distributionChannels",
1357
- type: "string[]"
1358
- }, {
1359
- internalType: "string[]",
1360
- name: "contentRestrictions",
1361
- type: "string[]"
1362
- }],
1363
- internalType: "struct PILPolicy",
1364
- name: "policy",
1365
- type: "tuple"
1293
+ internalType: "bytes",
1294
+ name: "commercializerCheckerData",
1295
+ type: "bytes"
1296
+ }, {
1297
+ internalType: "uint32",
1298
+ name: "commercialRevShare",
1299
+ type: "uint32"
1300
+ }, {
1301
+ internalType: "uint256",
1302
+ name: "commercialRevCelling",
1303
+ type: "uint256"
1304
+ }, {
1305
+ internalType: "bool",
1306
+ name: "derivativesAllowed",
1307
+ type: "bool"
1308
+ }, {
1309
+ internalType: "bool",
1310
+ name: "derivativesAttribution",
1311
+ type: "bool"
1312
+ }, {
1313
+ internalType: "bool",
1314
+ name: "derivativesApproval",
1315
+ type: "bool"
1316
+ }, {
1317
+ internalType: "bool",
1318
+ name: "derivativesReciprocal",
1319
+ type: "bool"
1320
+ }, {
1321
+ internalType: "uint256",
1322
+ name: "derivativeRevCelling",
1323
+ type: "uint256"
1324
+ }, {
1325
+ internalType: "address",
1326
+ name: "currency",
1327
+ type: "address"
1366
1328
  }],
1367
- internalType: "struct RegisterPILPolicyParams",
1368
- name: "params",
1329
+ internalType: "struct PILTerms",
1330
+ name: "terms",
1369
1331
  type: "tuple"
1370
1332
  }],
1371
- name: "registerPolicy",
1333
+ name: "registerLicenseTerms",
1372
1334
  outputs: [{
1373
1335
  internalType: "uint256",
1374
- name: "policyId",
1336
+ name: "selectedLicenseTermsId",
1375
1337
  type: "uint256"
1376
1338
  }],
1377
1339
  stateMutability: "nonpayable",
@@ -1796,6 +1758,10 @@ var ErrorsABI = [{
1796
1758
  inputs: [],
1797
1759
  name: "IpRoyaltyVault__ClaimerNotAnAncestor",
1798
1760
  type: "error"
1761
+ }, {
1762
+ inputs: [],
1763
+ name: "IpRoyaltyVault__IpTagged",
1764
+ type: "error"
1799
1765
  }, {
1800
1766
  inputs: [],
1801
1767
  name: "IpRoyaltyVault__NotRoyaltyPolicyLAP",
@@ -1804,6 +1770,10 @@ var ErrorsABI = [{
1804
1770
  inputs: [],
1805
1771
  name: "IpRoyaltyVault__SnapshotIntervalTooShort",
1806
1772
  type: "error"
1773
+ }, {
1774
+ inputs: [],
1775
+ name: "IpRoyaltyVault__ZeroDisputeModule",
1776
+ type: "error"
1807
1777
  }, {
1808
1778
  inputs: [],
1809
1779
  name: "IpRoyaltyVault__ZeroIpId",
@@ -1817,36 +1787,260 @@ var ErrorsABI = [{
1817
1787
  name: "LicenseRegistry__CallerNotLicensingModule",
1818
1788
  type: "error"
1819
1789
  }, {
1820
- inputs: [],
1821
- name: "LicenseRegistry__NotTransferable",
1790
+ inputs: [{
1791
+ internalType: "address",
1792
+ name: "childIpId",
1793
+ type: "address"
1794
+ }],
1795
+ name: "LicenseRegistry__DerivativeAlreadyRegistered",
1822
1796
  type: "error"
1823
1797
  }, {
1824
- inputs: [],
1825
- name: "LicenseRegistry__RevokedLicense",
1798
+ inputs: [{
1799
+ internalType: "address",
1800
+ name: "childIpId",
1801
+ type: "address"
1802
+ }],
1803
+ name: "LicenseRegistry__DerivativeIpAlreadyHasLicense",
1826
1804
  type: "error"
1827
1805
  }, {
1828
- inputs: [],
1829
- name: "LicenseRegistry__ZeroDisputeModule",
1806
+ inputs: [{
1807
+ internalType: "address",
1808
+ name: "ipId",
1809
+ type: "address"
1810
+ }],
1811
+ name: "LicenseRegistry__DerivativeIsParent",
1830
1812
  type: "error"
1831
1813
  }, {
1832
- inputs: [],
1833
- name: "LicenseRegistry__ZeroLicensingModule",
1814
+ inputs: [{
1815
+ internalType: "address",
1816
+ name: "ipId",
1817
+ type: "address"
1818
+ }, {
1819
+ internalType: "uint256",
1820
+ name: "index",
1821
+ type: "uint256"
1822
+ }, {
1823
+ internalType: "uint256",
1824
+ name: "length",
1825
+ type: "uint256"
1826
+ }],
1827
+ name: "LicenseRegistry__IndexOutOfBounds",
1834
1828
  type: "error"
1835
1829
  }, {
1836
- inputs: [],
1837
- name: "LicensingModule__CallerNotLicenseRegistry",
1830
+ inputs: [{
1831
+ internalType: "address",
1832
+ name: "ipId",
1833
+ type: "address"
1834
+ }],
1835
+ name: "LicenseRegistry__IpExpired",
1838
1836
  type: "error"
1839
1837
  }, {
1840
- inputs: [],
1841
- name: "LicensingModule__CallerNotLicensorAndPolicyNotSet",
1838
+ inputs: [{
1839
+ internalType: "address",
1840
+ name: "licenseTemplate",
1841
+ type: "address"
1842
+ }, {
1843
+ internalType: "uint256",
1844
+ name: "licenseTermsId",
1845
+ type: "uint256"
1846
+ }],
1847
+ name: "LicenseRegistry__LicenseTermsNotExists",
1842
1848
  type: "error"
1843
1849
  }, {
1844
1850
  inputs: [],
1845
- name: "LicensingModule__CommercialTermInNonCommercialPolicy",
1851
+ name: "LicenseRegistry__NoParentIp",
1846
1852
  type: "error"
1847
1853
  }, {
1848
- inputs: [],
1849
- name: "LicensingModule__DerivativeRevShareSumExceedsMaxRNFTSupply",
1854
+ inputs: [{
1855
+ internalType: "address",
1856
+ name: "licenseTemplate",
1857
+ type: "address"
1858
+ }],
1859
+ name: "LicenseRegistry__NotLicenseTemplate",
1860
+ type: "error"
1861
+ }, {
1862
+ inputs: [],
1863
+ name: "LicenseRegistry__NotTransferable",
1864
+ type: "error"
1865
+ }, {
1866
+ inputs: [{
1867
+ internalType: "address",
1868
+ name: "ipId",
1869
+ type: "address"
1870
+ }],
1871
+ name: "LicenseRegistry__ParentIpExpired",
1872
+ type: "error"
1873
+ }, {
1874
+ inputs: [{
1875
+ internalType: "address",
1876
+ name: "ipId",
1877
+ type: "address"
1878
+ }, {
1879
+ internalType: "uint256",
1880
+ name: "licenseTermsId",
1881
+ type: "uint256"
1882
+ }],
1883
+ name: "LicenseRegistry__ParentIpHasNoLicenseTerms",
1884
+ type: "error"
1885
+ }, {
1886
+ inputs: [{
1887
+ internalType: "address",
1888
+ name: "ipId",
1889
+ type: "address"
1890
+ }],
1891
+ name: "LicenseRegistry__ParentIpTagged",
1892
+ type: "error"
1893
+ }, {
1894
+ inputs: [{
1895
+ internalType: "address",
1896
+ name: "ipId",
1897
+ type: "address"
1898
+ }, {
1899
+ internalType: "address",
1900
+ name: "licenseTemplate",
1901
+ type: "address"
1902
+ }],
1903
+ name: "LicenseRegistry__ParentIpUnmachedLicenseTemplate",
1904
+ type: "error"
1905
+ }, {
1906
+ inputs: [{
1907
+ internalType: "address",
1908
+ name: "licenseTemplate",
1909
+ type: "address"
1910
+ }],
1911
+ name: "LicenseRegistry__UnregisteredLicenseTemplate",
1912
+ type: "error"
1913
+ }, {
1914
+ inputs: [],
1915
+ name: "LicenseRegistry__ZeroDisputeModule",
1916
+ type: "error"
1917
+ }, {
1918
+ inputs: [],
1919
+ name: "LicenseRegistry__ZeroLicensingModule",
1920
+ type: "error"
1921
+ }, {
1922
+ inputs: [{
1923
+ internalType: "address",
1924
+ name: "licenseTemplate",
1925
+ type: "address"
1926
+ }, {
1927
+ internalType: "address",
1928
+ name: "anotherLicenseTemplate",
1929
+ type: "address"
1930
+ }],
1931
+ name: "LicenseToken__AllLicenseTokensMustFromSameLicenseTemplate",
1932
+ type: "error"
1933
+ }, {
1934
+ inputs: [],
1935
+ name: "LicenseToken__CallerNotLicensingModule",
1936
+ type: "error"
1937
+ }, {
1938
+ inputs: [{
1939
+ internalType: "uint256",
1940
+ name: "tokenId",
1941
+ type: "uint256"
1942
+ }, {
1943
+ internalType: "uint256",
1944
+ name: "expiredAt",
1945
+ type: "uint256"
1946
+ }, {
1947
+ internalType: "uint256",
1948
+ name: "currentTimestamp",
1949
+ type: "uint256"
1950
+ }],
1951
+ name: "LicenseToken__LicenseTokenExpired",
1952
+ type: "error"
1953
+ }, {
1954
+ inputs: [{
1955
+ internalType: "uint256",
1956
+ name: "tokenId",
1957
+ type: "uint256"
1958
+ }, {
1959
+ internalType: "address",
1960
+ name: "iPowner",
1961
+ type: "address"
1962
+ }, {
1963
+ internalType: "address",
1964
+ name: "tokenOwner",
1965
+ type: "address"
1966
+ }],
1967
+ name: "LicenseToken__NotLicenseTokenOwner",
1968
+ type: "error"
1969
+ }, {
1970
+ inputs: [],
1971
+ name: "LicenseToken__NotTransferable",
1972
+ type: "error"
1973
+ }, {
1974
+ inputs: [{
1975
+ internalType: "uint256",
1976
+ name: "tokenId",
1977
+ type: "uint256"
1978
+ }],
1979
+ name: "LicenseToken__RevokedLicense",
1980
+ type: "error"
1981
+ }, {
1982
+ inputs: [],
1983
+ name: "LicenseToken__ZeroDisputeModule",
1984
+ type: "error"
1985
+ }, {
1986
+ inputs: [],
1987
+ name: "LicenseToken__ZeroLicensingModule",
1988
+ type: "error"
1989
+ }, {
1990
+ inputs: [],
1991
+ name: "LicensingModule__CallerNotLicenseRegistry",
1992
+ type: "error"
1993
+ }, {
1994
+ inputs: [{
1995
+ internalType: "address",
1996
+ name: "caller",
1997
+ type: "address"
1998
+ }, {
1999
+ internalType: "address",
2000
+ name: "licensorIpId",
2001
+ type: "address"
2002
+ }, {
2003
+ internalType: "address",
2004
+ name: "licenseTemplate",
2005
+ type: "address"
2006
+ }, {
2007
+ internalType: "uint256",
2008
+ name: "licenseTermsId",
2009
+ type: "uint256"
2010
+ }],
2011
+ name: "LicensingModule__CallerNotLicensorAndIpHasNotAttachedLicenseTerms",
2012
+ type: "error"
2013
+ }, {
2014
+ inputs: [],
2015
+ name: "LicensingModule__CallerNotLicensorAndPolicyNotSet",
2016
+ type: "error"
2017
+ }, {
2018
+ inputs: [],
2019
+ name: "LicensingModule__CommercialTermInNonCommercialPolicy",
2020
+ type: "error"
2021
+ }, {
2022
+ inputs: [{
2023
+ internalType: "address",
2024
+ name: "ipId",
2025
+ type: "address"
2026
+ }],
2027
+ name: "LicensingModule__DerivativeAlreadyHasLicenseTerms",
2028
+ type: "error"
2029
+ }, {
2030
+ inputs: [],
2031
+ name: "LicensingModule__DerivativeAlreadyRegistered",
2032
+ type: "error"
2033
+ }, {
2034
+ inputs: [],
2035
+ name: "LicensingModule__DerivativeIsParent",
2036
+ type: "error"
2037
+ }, {
2038
+ inputs: [],
2039
+ name: "LicensingModule__DerivativeRevShareSumExceedsMaxRNFTSupply",
2040
+ type: "error"
2041
+ }, {
2042
+ inputs: [],
2043
+ name: "LicensingModule__DerivativesCannotAddLicenseTerms",
1850
2044
  type: "error"
1851
2045
  }, {
1852
2046
  inputs: [],
@@ -1870,11 +2064,19 @@ var ErrorsABI = [{
1870
2064
  type: "error"
1871
2065
  }, {
1872
2066
  inputs: [],
1873
- name: "LicensingModule__IncompatibleLicensorCommercialPolicy",
2067
+ name: "LicensingModule__IncompatibleLicensorRoyaltyDerivativeRevShare",
1874
2068
  type: "error"
1875
2069
  }, {
1876
- inputs: [],
1877
- name: "LicensingModule__IncompatibleLicensorRoyaltyDerivativeRevShare",
2070
+ inputs: [{
2071
+ internalType: "address",
2072
+ name: "royaltyPolicy",
2073
+ type: "address"
2074
+ }, {
2075
+ internalType: "address",
2076
+ name: "anotherRoyaltyPolicy",
2077
+ type: "address"
2078
+ }],
2079
+ name: "LicensingModule__IncompatibleRoyaltyPolicy",
1878
2080
  type: "error"
1879
2081
  }, {
1880
2082
  inputs: [],
@@ -1896,6 +2098,50 @@ var ErrorsABI = [{
1896
2098
  inputs: [],
1897
2099
  name: "LicensingModule__IpAlreadyLinked",
1898
2100
  type: "error"
2101
+ }, {
2102
+ inputs: [{
2103
+ internalType: "address",
2104
+ name: "childIpId",
2105
+ type: "address"
2106
+ }],
2107
+ name: "LicensingModule__LicenseNotCompatibleForDerivative",
2108
+ type: "error"
2109
+ }, {
2110
+ inputs: [{
2111
+ internalType: "uint256",
2112
+ name: "ipLength",
2113
+ type: "uint256"
2114
+ }, {
2115
+ internalType: "uint256",
2116
+ name: "licenseTermsLength",
2117
+ type: "uint256"
2118
+ }],
2119
+ name: "LicensingModule__LicenseTermsLengthMismatch",
2120
+ type: "error"
2121
+ }, {
2122
+ inputs: [{
2123
+ internalType: "address",
2124
+ name: "licenseTemplate",
2125
+ type: "address"
2126
+ }, {
2127
+ internalType: "uint256",
2128
+ name: "licenseTermsId",
2129
+ type: "uint256"
2130
+ }],
2131
+ name: "LicensingModule__LicenseTermsNotFound",
2132
+ type: "error"
2133
+ }, {
2134
+ inputs: [{
2135
+ internalType: "address",
2136
+ name: "childIpId",
2137
+ type: "address"
2138
+ }, {
2139
+ internalType: "uint256[]",
2140
+ name: "licenseTokenIds",
2141
+ type: "uint256[]"
2142
+ }],
2143
+ name: "LicensingModule__LicenseTokenNotCompatibleForDerivative",
2144
+ type: "error"
1899
2145
  }, {
1900
2146
  inputs: [],
1901
2147
  name: "LicensingModule__LicensorDoesntHaveThisPolicy",
@@ -1928,6 +2174,14 @@ var ErrorsABI = [{
1928
2174
  inputs: [],
1929
2175
  name: "LicensingModule__MismatchBetweenRoyaltyPolicy",
1930
2176
  type: "error"
2177
+ }, {
2178
+ inputs: [],
2179
+ name: "LicensingModule__NoLicenseToken",
2180
+ type: "error"
2181
+ }, {
2182
+ inputs: [],
2183
+ name: "LicensingModule__NoParentIp",
2184
+ type: "error"
1931
2185
  }, {
1932
2186
  inputs: [],
1933
2187
  name: "LicensingModule__NotLicensee",
@@ -1944,6 +2198,14 @@ var ErrorsABI = [{
1944
2198
  inputs: [],
1945
2199
  name: "LicensingModule__ParentIdEqualThanChild",
1946
2200
  type: "error"
2201
+ }, {
2202
+ inputs: [{
2203
+ internalType: "address",
2204
+ name: "ipId",
2205
+ type: "address"
2206
+ }],
2207
+ name: "LicensingModule__ParentIpHasNoLicenseTerms",
2208
+ type: "error"
1947
2209
  }, {
1948
2210
  inputs: [],
1949
2211
  name: "LicensingModule__PolicyAlreadySetForIpId",
@@ -1952,6 +2214,14 @@ var ErrorsABI = [{
1952
2214
  inputs: [],
1953
2215
  name: "LicensingModule__PolicyNotFound",
1954
2216
  type: "error"
2217
+ }, {
2218
+ inputs: [{
2219
+ internalType: "address",
2220
+ name: "receiver",
2221
+ type: "address"
2222
+ }],
2223
+ name: "LicensingModule__ReceiverCheckFailed",
2224
+ type: "error"
1955
2225
  }, {
1956
2226
  inputs: [],
1957
2227
  name: "LicensingModule__ReceiverZeroAddress",
@@ -2092,6 +2362,10 @@ var ErrorsABI = [{
2092
2362
  inputs: [],
2093
2363
  name: "RoyaltyModule__IncompatibleRoyaltyPolicy",
2094
2364
  type: "error"
2365
+ }, {
2366
+ inputs: [],
2367
+ name: "RoyaltyModule__IpIsTagged",
2368
+ type: "error"
2095
2369
  }, {
2096
2370
  inputs: [],
2097
2371
  name: "RoyaltyModule__NoParentsOnLinking",
@@ -2112,6 +2386,10 @@ var ErrorsABI = [{
2112
2386
  inputs: [],
2113
2387
  name: "RoyaltyModule__NotWhitelistedRoyaltyToken",
2114
2388
  type: "error"
2389
+ }, {
2390
+ inputs: [],
2391
+ name: "RoyaltyModule__ZeroDisputeModule",
2392
+ type: "error"
2115
2393
  }, {
2116
2394
  inputs: [],
2117
2395
  name: "RoyaltyModule__ZeroLicensingModule",
@@ -2204,32 +2482,35 @@ var sepolia = {
2204
2482
  MockERC721: "0x16d50f333B264b153B7BF1DD9fe65A2707B3281b",
2205
2483
  MockTokenGatedHook: "0x28C32a4B5B3E186d7f658C051d3Bb4a95243209a",
2206
2484
  ModuleRegistry: "0x5Aac3177F496F503Ac724A0D0A697f6ba9dA2C27",
2207
- PILPolicyFrameworkManager: "0xeAABf2b80B7e069EE449B5629590A1cc0F9bC9C2",
2485
+ PILicenseTemplate: "0xeAABf2b80B7e069EE449B5629590A1cc0F9bC9C2",
2208
2486
  RegistrationModule: "0x613128e88b568768764824f898C8135efED97fA6",
2209
2487
  RoyaltyModule: "0xA6bEf9CC650A16939566c1da5d5088f3F028a865",
2210
2488
  RoyaltyPolicyLAP: "0x16eF58e959522727588921A92e9084d36E5d3855",
2211
2489
  TokenWithdrawalModule: "0x66738a5722e9Cd91B694bA39146CFEcE95457F04"
2212
2490
  };
2213
2491
  var storyTestnet = {
2214
- AccessController: "0x6fB5BA9A8747E897109044a1cd1192898AA384a9",
2215
- ArbitrationPolicySP: "0x114aE96d362b802Ed92758A21992e429e9E83565",
2216
- DisputeModule: "0x837d095F9A11178545DF4114C44fb526dcf74168",
2217
- Governance: "0x0Fee5B61cF0976f3F59138146a9180a107738db9",
2218
- IPAccountImpl: "0x6d1398e1ceE174a3e41d6eB50F00Fe43132f9C8A",
2219
- IPAccountRegistry: "0x0CCc0CD388477ED0D7531d2aD6e68c9E24B8392d",
2220
- IPAssetRegistry: "0x30C89bCB41277f09b18DF0375b9438909e193bf0",
2221
- IpRoyaltyVaultBeacon: "0x8C7664Befc382A282F8aA821A2d337960e410E77",
2222
- IpRoyaltyVaultImpl: "0x0dB6AAb7525F03Bf94A1fC08A9aACCc2Ad25eD12",
2223
- LicenseRegistry: "0x790717fBa06Aa219Fc3A502ce360d8dEAF273Eb5",
2224
- LicensingModule: "0xB7a83a5f3C8b512A6DfE294ad4811F1b4AA10E96",
2225
- MockERC20: "0xCc97e835157daf88820cbDE105ADFF5d7981A382",
2226
- MockERC721: "0x7c0004C6D352bC0a0531AaD46d33A03D9d51ab1D",
2227
- MockTokenGatedHook: "0xD3Aa4F5B77509907FF3d7a90cEadE19bab2b6Fdb",
2228
- ModuleRegistry: "0xab0bf9846eCE1299AaA1cB3FF5EfbBA328968771",
2229
- PILPolicyFrameworkManager: "0x251bce81DF5957123869E43269C4E29308A062c4",
2230
- RoyaltyModule: "0xF77b0933F6aaC2dCE2eAa0d79f6Bfd6b9347a5E7",
2231
- RoyaltyPolicyLAP: "0x31f263D48df5FA5956E2Ba614b150e2A0fE1aDd3",
2232
- TokenWithdrawalModule: "0x446B734C3Fc13c53b4E32FEFCaaED97e0100552D"
2492
+ AccessController: "0x7e253Df9b0fC872746877Fa362b2cAf32712d770",
2493
+ ArbitrationPolicySP: "0xA25bc70932282b35407e0DC08cc9C91f6b00CEf0",
2494
+ CoreMetadataModule: "0x8A8FBAaEB6A0B7736ebde31c6F49CccD808232bA",
2495
+ CoreMetadataViewModule: "0x8A8FBAaEB6A0B7736ebde31c6F49CccD808232bA",
2496
+ DisputeModule: "0x6d54456Ae5DCbDC0C9E2713cC8E650fE4f445c7C",
2497
+ Governance: "0x63F4A670A8b518ef5eb291559BdAbea4b31c1AC4",
2498
+ IPAccountImpl: "0x38cAfD16502B1d61c6399A18d6Fa1Ea8CEca3678",
2499
+ IPAccountRegistry: "0x8448d0F77D7e67e0814f83D988aB3344D46bb1E4",
2500
+ IPAssetRegistry: "0x862de97662a1231FFc14038eC1BE93aB129D2169",
2501
+ IpRoyaltyVaultBeacon: "0xE92Cdf428f07D92248b6b15ce59a9d5597428F21",
2502
+ IpRoyaltyVaultImpl: "0x8Be22cc2D13ADF496a417D9C616dA4a253c68Af8",
2503
+ LicenseRegistry: "0x0c3D467537FAd845a78728CEdc3D9447338c5422",
2504
+ LicenseToken: "0xD40b7bCA204f96a346021e31c9ad54FF495226e7",
2505
+ LicensingModule: "0xEeDDE5529122b621105798860F235c28FD3aBA40",
2506
+ MockERC20: "0xA36F2A4A02f5C215d1b3630f71A4Ff55B5492AAE",
2507
+ MockERC721: "0x83DD606d14CcEb629dE9Bf8Aad7aE63767dB476f",
2508
+ MockTokenGatedHook: "0x80519d82FBE474AB9E863A066AC32E3eeAFc8F11",
2509
+ ModuleRegistry: "0xf2965E3B6251905Dd1E8671077760D07b0408cf2",
2510
+ PILicenseTemplate: "0xd0Be223ae9719bBD93447ecf5289319CCf8cA227",
2511
+ RoyaltyModule: "0x551AD8CD7893003cE00500aC2aCF1E327763D9f6",
2512
+ RoyaltyPolicyLAP: "0x2EcdB5bD12a037dCb9De0Ab7957f35FEeF758eA6",
2513
+ TokenWithdrawalModule: "0xC573E5c36B8FA5108b78f7357947972D030699d5"
2233
2514
  };
2234
2515
  var contractAddress = {
2235
2516
  sepolia: sepolia,
@@ -2269,12 +2550,6 @@ var getLicensingModuleConfig = function getLicensingModuleConfig(chain) {
2269
2550
  address: getAddress(contractAddress[chain].LicensingModule)
2270
2551
  };
2271
2552
  };
2272
- var getPILPolicyFrameworkManagerConfig = function getPILPolicyFrameworkManagerConfig(chain) {
2273
- return {
2274
- abi: [].concat(_toConsumableArray(PILPolicyFrameworkManagerABI), _toConsumableArray(ErrorsABI)),
2275
- address: getAddress(contractAddress[chain].PILPolicyFrameworkManager)
2276
- };
2277
- };
2278
2553
  var getRoyaltyPolicyLAPConfig = function getRoyaltyPolicyLAPConfig(chain) {
2279
2554
  return {
2280
2555
  abi: [].concat(_toConsumableArray(IRoyaltyPolicyLAPABI), _toConsumableArray(ErrorsABI)),
@@ -2293,6 +2568,12 @@ var getRoyaltyModuleConfig = function getRoyaltyModuleConfig(chain) {
2293
2568
  address: getAddress(contractAddress[chain].RoyaltyModule)
2294
2569
  };
2295
2570
  };
2571
+ var getLicenseTemplateConfig = function getLicenseTemplateConfig(chain) {
2572
+ return {
2573
+ abi: [].concat(_toConsumableArray(PILicenseTemplateABI), _toConsumableArray(ErrorsABI)),
2574
+ address: getAddress(contractAddress[chain].PILicenseTemplate)
2575
+ };
2576
+ };
2296
2577
 
2297
2578
  function handleError(error, msg) {
2298
2579
  if (error instanceof Error) {
@@ -2470,560 +2751,178 @@ var PermissionClient = /*#__PURE__*/function () {
2470
2751
  _context.next = 4;
2471
2752
  return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, IPAccountConfig), {}, {
2472
2753
  functionName: "execute",
2473
- args: [this.accessControllerConfig.address, parseToBigInt(0), encodeFunctionData({
2474
- abi: this.accessControllerConfig.abi,
2475
- functionName: "setPermission",
2476
- args: [getAddress(request.ipId),
2477
- // 0x Address
2478
- getAddress(request.signer),
2479
- // 0x Address
2480
- getAddress(request.to),
2481
- // 0x Address
2482
- request.func || "0x00000000",
2483
- // bytes4
2484
- request.permission // uint8
2485
- ]
2486
- })],
2487
- account: this.wallet.account
2488
- }));
2489
- case 4:
2490
- _yield$this$rpcClient = _context.sent;
2491
- call = _yield$this$rpcClient.request;
2492
- _context.next = 8;
2493
- return this.wallet.writeContract(call);
2494
- case 8:
2495
- txHash = _context.sent;
2496
- if (!((_request$txOptions = request.txOptions) !== null && _request$txOptions !== void 0 && _request$txOptions.waitForTransaction)) {
2497
- _context.next = 15;
2498
- break;
2499
- }
2500
- _context.next = 12;
2501
- return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, this.accessControllerConfig), {}, {
2502
- eventName: "PermissionSet"
2503
- }));
2504
- case 12:
2505
- return _context.abrupt("return", {
2506
- txHash: txHash,
2507
- success: true
2508
- });
2509
- case 15:
2510
- return _context.abrupt("return", {
2511
- txHash: txHash
2512
- });
2513
- case 16:
2514
- _context.next = 21;
2515
- break;
2516
- case 18:
2517
- _context.prev = 18;
2518
- _context.t0 = _context["catch"](0);
2519
- handleError(_context.t0, "Failed to set permissions");
2520
- case 21:
2521
- case "end":
2522
- return _context.stop();
2523
- }
2524
- }, _callee, this, [[0, 18]]);
2525
- }));
2526
- function setPermission(_x) {
2527
- return _setPermission.apply(this, arguments);
2528
- }
2529
- return setPermission;
2530
- }())
2531
- }]);
2532
- }();
2533
-
2534
- function computeRoyaltyContext(_x, _x2) {
2535
- return _computeRoyaltyContext.apply(this, arguments);
2536
- }
2537
- function _computeRoyaltyContext() {
2538
- _computeRoyaltyContext = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(licenseIds, storyClient) {
2539
- var royaltyContext, i, licenseData, royaltyPolicy, policy, targetRoyaltyAmount;
2540
- return _regeneratorRuntime().wrap(function _callee$(_context) {
2541
- while (1) switch (_context.prev = _context.next) {
2542
- case 0:
2543
- royaltyContext = {
2544
- targetAncestors: [],
2545
- targetRoyaltyAmount: [],
2546
- parentAncestors1: [],
2547
- parentAncestors2: [],
2548
- parentAncestorsRoyalties1: [],
2549
- parentAncestorsRoyalties2: []
2550
- };
2551
- i = 0;
2552
- case 2:
2553
- if (!(i < licenseIds.length)) {
2554
- _context.next = 16;
2555
- break;
2556
- }
2557
- _context.next = 5;
2558
- return storyClient.getLicense(licenseIds[i]);
2559
- case 5:
2560
- licenseData = _context.sent;
2561
- _context.next = 8;
2562
- return storyClient.getRoyaltyPolicy(licenseData.licensorIpId);
2563
- case 8:
2564
- royaltyPolicy = _context.sent;
2565
- _context.next = 11;
2566
- return storyClient.getPolicy(licenseData.policyId);
2567
- case 11:
2568
- policy = _context.sent;
2569
- if (royaltyPolicy) {
2570
- targetRoyaltyAmount = royaltyPolicy.targetRoyaltyAmount.map(function (e) {
2571
- return parseInt(e);
2572
- });
2573
- if (i === 0) {
2574
- royaltyContext.parentAncestors1 = royaltyPolicy.targetAncestors;
2575
- royaltyContext.parentAncestorsRoyalties1 = targetRoyaltyAmount;
2576
- } else {
2577
- royaltyContext.parentAncestors2 = royaltyPolicy.targetAncestors;
2578
- royaltyContext.parentAncestorsRoyalties2 = targetRoyaltyAmount;
2579
- }
2580
- updateRoyaltyContext(royaltyContext, [licenseData.licensorIpId], [parseInt(policy.pil.commercialRevShare)]);
2581
- updateRoyaltyContext(royaltyContext, royaltyPolicy.targetAncestors, targetRoyaltyAmount);
2582
- }
2583
- case 13:
2584
- i++;
2585
- _context.next = 2;
2586
- break;
2587
- case 16:
2588
- return _context.abrupt("return", royaltyContext);
2589
- case 17:
2590
- case "end":
2591
- return _context.stop();
2592
- }
2593
- }, _callee);
2594
- }));
2595
- return _computeRoyaltyContext.apply(this, arguments);
2596
- }
2597
- function encodeRoyaltyContext(royaltyContext) {
2598
- return typedDataToBytes({
2599
- "interface": "(address[], uint32[], address[], address[], uint32[], uint32[])",
2600
- data: [[royaltyContext.targetAncestors, royaltyContext.targetRoyaltyAmount, royaltyContext.parentAncestors1, royaltyContext.parentAncestors2, royaltyContext.parentAncestorsRoyalties1, royaltyContext.parentAncestorsRoyalties2]]
2601
- });
2602
- }
2603
- function updateRoyaltyContext(royaltyContext, targetAncestors, targetRoyaltyAccounts) {
2604
- for (var i = 0; i < targetAncestors.length; i++) {
2605
- var index = royaltyContext.targetAncestors.indexOf(targetAncestors[i]);
2606
- if (index === -1) {
2607
- royaltyContext.targetAncestors.push(targetAncestors[i]);
2608
- royaltyContext.targetRoyaltyAmount.push(targetRoyaltyAccounts[i]);
2609
- } else {
2610
- royaltyContext.targetRoyaltyAmount[index] += targetRoyaltyAccounts[i];
2611
- }
2612
- }
2613
- }
2614
-
2615
- var LicenseClient = /*#__PURE__*/function () {
2616
- function LicenseClient(rpcClient, wallet, storyClient, chainId) {
2617
- _classCallCheck(this, LicenseClient);
2618
- _defineProperty(this, "ipAccountABI", IPAccountABI);
2619
- this.wallet = wallet;
2620
- this.rpcClient = rpcClient;
2621
- this.storyClient = storyClient;
2622
- this.licenseRegistryConfig = getLicenseRegistryConfig(chainId);
2623
- this.licensingModuleConfig = getLicensingModuleConfig(chainId);
2624
- }
2625
-
2626
- /**
2627
- * Mints license NFTs representing a policy granted by a set of ipIds (licensors). This NFT needs to be
2628
- * burned in order to link a derivative IP with its parents. If this is the first combination of policy and
2629
- * licensors, a new licenseId will be created. If not, the license is fungible and an id will be reused.
2630
- * @dev Only callable by the licensing module.
2631
- * @param request The request object containing necessary data to mint a license.
2632
- * @param request.policyId The ID of the policy to be minted
2633
- * @param request.licensorIpId_ The ID of the IP granting the license (ie. licensor)
2634
- * @param request.mintAmount Number of licenses to mint. License NFT is fungible for same policy and same licensors
2635
- * @param request.receiver Receiver address of the minted license NFT(s).
2636
- * @returns licenseId The ID of the minted license NFT(s).
2637
- */
2638
- return _createClass(LicenseClient, [{
2639
- key: "mintLicense",
2640
- value: (function () {
2641
- var _mintLicense = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
2642
- var _request$txOptions, royaltyContext, royaltyPolicy, _royaltyContext$targe, _royaltyContext$targe2, targetRoyaltyAmount, _yield$this$rpcClient, call, txHash, targetLogs;
2643
- return _regeneratorRuntime().wrap(function _callee$(_context) {
2644
- while (1) switch (_context.prev = _context.next) {
2645
- case 0:
2646
- _context.prev = 0;
2647
- royaltyContext = {
2648
- targetAncestors: [],
2649
- targetRoyaltyAmount: [],
2650
- parentAncestors1: [],
2651
- parentAncestors2: [],
2652
- parentAncestorsRoyalties1: [],
2653
- parentAncestorsRoyalties2: []
2654
- };
2655
- _context.next = 4;
2656
- return this.storyClient.getRoyaltyPolicy(request.licensorIpId);
2657
- case 4:
2658
- royaltyPolicy = _context.sent;
2659
- if (royaltyPolicy) {
2660
- (_royaltyContext$targe = royaltyContext.targetAncestors).push.apply(_royaltyContext$targe, _toConsumableArray(royaltyPolicy.targetAncestors));
2661
- targetRoyaltyAmount = royaltyPolicy.targetRoyaltyAmount.map(function (e) {
2662
- return parseInt(e);
2663
- });
2664
- (_royaltyContext$targe2 = royaltyContext.targetRoyaltyAmount).push.apply(_royaltyContext$targe2, _toConsumableArray(targetRoyaltyAmount));
2665
- }
2666
- _context.next = 8;
2667
- return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.licensingModuleConfig), {}, {
2668
- functionName: "mintLicense",
2669
- args: [parseToBigInt(request.policyId), request.licensorIpId, parseToBigInt(request.mintAmount), getAddress(request.receiverAddress), encodeRoyaltyContext(royaltyContext)],
2670
- account: this.wallet.account
2671
- }));
2672
- case 8:
2673
- _yield$this$rpcClient = _context.sent;
2674
- call = _yield$this$rpcClient.request;
2675
- _context.next = 12;
2676
- return this.wallet.writeContract(call);
2677
- case 12:
2678
- txHash = _context.sent;
2679
- if (!((_request$txOptions = request.txOptions) !== null && _request$txOptions !== void 0 && _request$txOptions.waitForTransaction)) {
2680
- _context.next = 20;
2681
- break;
2682
- }
2683
- _context.next = 16;
2684
- return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, this.licenseRegistryConfig), {}, {
2685
- eventName: "TransferSingle",
2686
- from: this.licenseRegistryConfig.address
2687
- }));
2688
- case 16:
2689
- targetLogs = _context.sent;
2690
- return _context.abrupt("return", {
2691
- txHash: txHash,
2692
- licenseId: targetLogs[0].args.id.toString()
2693
- });
2694
- case 20:
2695
- return _context.abrupt("return", {
2696
- txHash: txHash
2697
- });
2698
- case 21:
2699
- _context.next = 26;
2700
- break;
2701
- case 23:
2702
- _context.prev = 23;
2703
- _context.t0 = _context["catch"](0);
2704
- handleError(_context.t0, "Failed to mint license");
2705
- case 26:
2706
- case "end":
2707
- return _context.stop();
2708
- }
2709
- }, _callee, this, [[0, 23]]);
2710
- }));
2711
- function mintLicense(_x) {
2712
- return _mintLicense.apply(this, arguments);
2713
- }
2714
- return mintLicense;
2715
- }())
2716
- }, {
2717
- key: "linkIpToParent",
2718
- value: function () {
2719
- var _linkIpToParent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
2720
- var _request$txOptions2, IPAccountConfig, licenseIds, royaltyContext, _yield$this$rpcClient2, call, txHash;
2721
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
2722
- while (1) switch (_context2.prev = _context2.next) {
2723
- case 0:
2724
- _context2.prev = 0;
2725
- IPAccountConfig = {
2726
- abi: this.ipAccountABI,
2727
- address: getAddress(request.childIpId)
2728
- };
2729
- licenseIds = [];
2730
- request.licenseIds.forEach(function (licenseId) {
2731
- licenseIds.push(parseToBigInt(licenseId));
2732
- });
2733
- _context2.next = 6;
2734
- return computeRoyaltyContext(request.licenseIds, this.storyClient);
2735
- case 6:
2736
- royaltyContext = _context2.sent;
2737
- _context2.next = 9;
2738
- return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, IPAccountConfig), {}, {
2739
- functionName: "execute",
2740
- args: [this.licensingModuleConfig.address, parseToBigInt(0), encodeFunctionData({
2741
- abi: this.licensingModuleConfig.abi,
2742
- functionName: "linkIpToParents",
2743
- args: [licenseIds, getAddress(request.childIpId), encodeRoyaltyContext(royaltyContext)]
2754
+ args: [this.accessControllerConfig.address, parseToBigInt(0), encodeFunctionData({
2755
+ abi: this.accessControllerConfig.abi,
2756
+ functionName: "setPermission",
2757
+ args: [getAddress(request.ipId),
2758
+ // 0x Address
2759
+ getAddress(request.signer),
2760
+ // 0x Address
2761
+ getAddress(request.to),
2762
+ // 0x Address
2763
+ request.func || "0x00000000",
2764
+ // bytes4
2765
+ request.permission // uint8
2766
+ ]
2744
2767
  })],
2745
2768
  account: this.wallet.account
2746
2769
  }));
2747
- case 9:
2748
- _yield$this$rpcClient2 = _context2.sent;
2749
- call = _yield$this$rpcClient2.request;
2750
- _context2.next = 13;
2770
+ case 4:
2771
+ _yield$this$rpcClient = _context.sent;
2772
+ call = _yield$this$rpcClient.request;
2773
+ _context.next = 8;
2751
2774
  return this.wallet.writeContract(call);
2752
- case 13:
2753
- txHash = _context2.sent;
2754
- if (!((_request$txOptions2 = request.txOptions) !== null && _request$txOptions2 !== void 0 && _request$txOptions2.waitForTransaction)) {
2755
- _context2.next = 20;
2775
+ case 8:
2776
+ txHash = _context.sent;
2777
+ if (!((_request$txOptions = request.txOptions) !== null && _request$txOptions !== void 0 && _request$txOptions.waitForTransaction)) {
2778
+ _context.next = 15;
2756
2779
  break;
2757
2780
  }
2758
- _context2.next = 17;
2759
- return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, this.licenseRegistryConfig), {}, {
2760
- eventName: "TransferBatch"
2781
+ _context.next = 12;
2782
+ return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, this.accessControllerConfig), {}, {
2783
+ eventName: "PermissionSet"
2761
2784
  }));
2762
- case 17:
2763
- return _context2.abrupt("return", {
2785
+ case 12:
2786
+ return _context.abrupt("return", {
2764
2787
  txHash: txHash,
2765
2788
  success: true
2766
2789
  });
2767
- case 20:
2768
- return _context2.abrupt("return", {
2790
+ case 15:
2791
+ return _context.abrupt("return", {
2769
2792
  txHash: txHash
2770
2793
  });
2771
- case 21:
2772
- _context2.next = 26;
2794
+ case 16:
2795
+ _context.next = 21;
2773
2796
  break;
2774
- case 23:
2775
- _context2.prev = 23;
2776
- _context2.t0 = _context2["catch"](0);
2777
- handleError(_context2.t0, "Failed to link IP to parents");
2778
- case 26:
2797
+ case 18:
2798
+ _context.prev = 18;
2799
+ _context.t0 = _context["catch"](0);
2800
+ handleError(_context.t0, "Failed to set permissions");
2801
+ case 21:
2779
2802
  case "end":
2780
- return _context2.stop();
2803
+ return _context.stop();
2781
2804
  }
2782
- }, _callee2, this, [[0, 23]]);
2805
+ }, _callee, this, [[0, 18]]);
2783
2806
  }));
2784
- function linkIpToParent(_x2) {
2785
- return _linkIpToParent.apply(this, arguments);
2807
+ function setPermission(_x) {
2808
+ return _setPermission.apply(this, arguments);
2786
2809
  }
2787
- return linkIpToParent;
2788
- }()
2810
+ return setPermission;
2811
+ }())
2789
2812
  }]);
2790
2813
  }();
2791
2814
 
2792
- var PolicyClient = /*#__PURE__*/function () {
2793
- function PolicyClient(rpcClient, wallet, chainId) {
2794
- _classCallCheck(this, PolicyClient);
2815
+ var LicenseClient = /*#__PURE__*/function () {
2816
+ function LicenseClient(rpcClient, wallet, storyClient, chainId) {
2817
+ _classCallCheck(this, LicenseClient);
2795
2818
  _defineProperty(this, "ipAccountABI", IPAccountABI);
2796
2819
  this.wallet = wallet;
2797
2820
  this.rpcClient = rpcClient;
2821
+ this.storyClient = storyClient;
2822
+ this.licenseRegistryConfig = getLicenseRegistryConfig(chainId);
2798
2823
  this.licensingModuleConfig = getLicensingModuleConfig(chainId);
2799
- this.pilPolicyFrameworkManagerConfig = getPILPolicyFrameworkManagerConfig(chainId);
2824
+ this.licenseTemplateConfig = getLicenseTemplateConfig(chainId);
2800
2825
  this.royaltyPolicyLAPConfig = getRoyaltyPolicyLAPConfig(chainId);
2801
2826
  }
2802
-
2803
- /**
2804
- * Registers a PIL policy to the registry
2805
- * Internally, this function must generate a Licensing.Policy struct and call registerPolicy.
2806
- * @param request - the licensing parameters for the Programmable IP License v1 (PIL) standard.
2807
- * @param request.transferable Whether or not the license is transferable
2808
- * @param request.attribution Whether or not attribution is required when reproducing the work
2809
- * @param request.commercialUse Whether or not the work can be used commercially
2810
- * @param request.commercialAttribution Whether or not attribution is required when reproducing the work commercially
2811
- * @param request.commercializerChecker commericializers that are allowed to commercially exploit the work. If zero address, then no restrictions is enforced.
2812
- * @param request.commercialRevShare Percentage of revenue that must be shared with the licensor
2813
- * @param request.derivativesAllowed Whether or not the licensee can create derivatives of his work
2814
- * @param request.derivativesAttribution Whether or not attribution is required for derivatives of the work
2815
- * @param request.derivativesApproval Whether or not the licensor must approve derivatives of the work before they can be linked to the licensor IP ID
2816
- * @param request.derivativesReciprocal Whether or not the licensee must license derivatives of the work under the same terms.
2817
- * @param request.territories List of territories where the license is valid. If empty, global.
2818
- * @param request.distributionChannels List of distribution channels where the license is valid. Empty if no restrictions.
2819
- * @param request.royaltyPolicy Address of a royalty policy contract (e.g. RoyaltyPolicyLS) that will handle royalty payments
2820
- * @returns the transaction hash and the policy ID if the txOptions.waitForTransaction is set to true
2821
- */
2822
- return _createClass(PolicyClient, [{
2823
- key: "registerPILPolicy",
2824
- value: (function () {
2825
- var _registerPILPolicy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
2826
- var _request$txOptions, frameworkData, policyId, _yield$this$rpcClient, call, txHash, targetLogs;
2827
+ return _createClass(LicenseClient, [{
2828
+ key: "getLicenseTermsId",
2829
+ value: function () {
2830
+ var _getLicenseTermsId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
2831
+ var selectedLicenseTermsId;
2827
2832
  return _regeneratorRuntime().wrap(function _callee$(_context) {
2828
2833
  while (1) switch (_context.prev = _context.next) {
2829
2834
  case 0:
2830
- _context.prev = 0;
2831
- // First check if the policy exists
2832
- frameworkData = {
2833
- attribution: request.attribution || false,
2834
- commercialUse: request.commercialUse || false,
2835
- commercialAttribution: request.commercialAttribution || false,
2836
- commercializerChecker: request.commercializerChecker || zeroAddress,
2837
- commercializerCheckerData: request.commercializerCheckerData || "0x",
2838
- commercialRevShare: request.commercialRevShare || 0,
2839
- derivativesAllowed: request.derivativesAllowed || false,
2840
- derivativesAttribution: request.derivativesAttribution || false,
2841
- derivativesApproval: request.derivativesApproval || false,
2842
- derivativesReciprocal: request.derivativesReciprocal || false,
2843
- territories: request.territories || [],
2844
- distributionChannels: request.distributionChannels || [],
2845
- contentRestrictions: request.contentRestrictions || []
2846
- };
2847
- _context.next = 4;
2848
- return this.getPolicyId(request.transferable, this.encodeFrameworkData(frameworkData), typedDataToBytes({
2849
- "interface": "uint32",
2850
- data: [request.commercialRevShare || 0]
2851
- }), request.mintingFee || "0", request.mintingFeeToken || zeroAddress, request.royaltyPolicy || zeroAddress);
2852
- case 4:
2853
- policyId = _context.sent;
2854
- if (!(policyId !== 0)) {
2855
- _context.next = 7;
2856
- break;
2857
- }
2858
- return _context.abrupt("return", {
2859
- policyId: policyId.toString()
2860
- });
2861
- case 7:
2862
- _context.next = 9;
2863
- return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.pilPolicyFrameworkManagerConfig), {}, {
2864
- functionName: "registerPolicy",
2865
- args: [{
2866
- transferable: request.transferable,
2867
- royaltyPolicy: request.royaltyPolicy || zeroAddress,
2868
- mintingFee: parseToBigInt(request.mintingFee || "0"),
2869
- mintingFeeToken: request.mintingFeeToken || zeroAddress,
2870
- policy: {
2871
- attribution: request.attribution || false,
2872
- commercialUse: request.commercialUse || false,
2873
- commercialAttribution: request.commercialAttribution || false,
2874
- commercialRevShare: request.commercialRevShare || 0,
2875
- derivativesAllowed: request.derivativesAllowed || false,
2876
- derivativesAttribution: request.derivativesAttribution || false,
2877
- derivativesApproval: request.derivativesApproval || false,
2878
- derivativesReciprocal: request.derivativesReciprocal || false,
2879
- commercializerChecker: request.commercializerChecker || zeroAddress,
2880
- commercializerCheckerData: request.commercializerCheckerData || "0x",
2881
- territories: request.territories || [],
2882
- distributionChannels: request.distributionChannels || [],
2883
- contentRestrictions: request.contentRestrictions || []
2884
- }
2885
- }],
2886
- account: this.wallet.account
2887
- }));
2888
- case 9:
2889
- _yield$this$rpcClient = _context.sent;
2890
- call = _yield$this$rpcClient.request;
2891
- _context.next = 13;
2892
- return this.wallet.writeContract(call);
2893
- case 13:
2894
- txHash = _context.sent;
2895
- if (!((_request$txOptions = request.txOptions) !== null && _request$txOptions !== void 0 && _request$txOptions.waitForTransaction)) {
2896
- _context.next = 21;
2897
- break;
2898
- }
2899
- _context.next = 17;
2900
- return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, this.licensingModuleConfig), {}, {
2901
- eventName: "PolicyRegistered"
2835
+ _context.next = 2;
2836
+ return this.rpcClient.readContract(_objectSpread2(_objectSpread2({}, this.licenseTemplateConfig), {}, {
2837
+ functionName: "getLicenseTermsId",
2838
+ args: [request]
2902
2839
  }));
2903
- case 17:
2904
- targetLogs = _context.sent;
2905
- return _context.abrupt("return", {
2906
- txHash: txHash,
2907
- policyId: targetLogs[0].args.policyId.toString()
2908
- });
2909
- case 21:
2910
- return _context.abrupt("return", {
2911
- txHash: txHash
2912
- });
2913
- case 22:
2914
- _context.next = 27;
2915
- break;
2916
- case 24:
2917
- _context.prev = 24;
2918
- _context.t0 = _context["catch"](0);
2919
- handleError(_context.t0, "Failed to register policy");
2920
- case 27:
2840
+ case 2:
2841
+ selectedLicenseTermsId = _context.sent;
2842
+ return _context.abrupt("return", Number(selectedLicenseTermsId));
2843
+ case 4:
2921
2844
  case "end":
2922
2845
  return _context.stop();
2923
2846
  }
2924
- }, _callee, this, [[0, 24]]);
2847
+ }, _callee, this);
2925
2848
  }));
2926
- function registerPILPolicy(_x) {
2927
- return _registerPILPolicy.apply(this, arguments);
2849
+ function getLicenseTermsId(_x) {
2850
+ return _getLicenseTermsId.apply(this, arguments);
2928
2851
  }
2929
- return registerPILPolicy;
2852
+ return getLicenseTermsId;
2930
2853
  }()
2931
2854
  /**
2932
- * Convenient function to register a PIL social remix policy to the registry
2933
- * Internally, this function must generate a Licensing.Policy struct and call registerPolicy.
2934
- * @param request - the licensing parameters for the Programmable IP License v1 (PIL) standard.
2935
- * @param request.territories List of territories where the license is valid. If empty, global.
2936
- * @param request.distributionChannels List of distribution channels where the license is valid. Empty if no restrictions.
2937
- * @param request.contentRestrictions List of content restrictions where the license is valid. Empty if no restrictions.
2938
- * @returns the transaction hash and the policy ID if the txOptions.waitForTransaction is set to true
2855
+ * Convenient function to register a PIL non commercial social remix license to the registry
2856
+ * @param request The request object that contains all data needed to register a PIL non commercial social remix license.
2857
+ * @param request.txOptions [Optional] The transaction options.
2858
+ * @returns A Promise that resolves to an object containing the optional transaction hash and optional license ID.
2859
+ * @emits LicenseTermsRegistered (licenseTermsId, licenseTemplate, licenseTerms);
2939
2860
  */
2940
- )
2941
2861
  }, {
2942
- key: "registerPILSocialRemixPolicy",
2862
+ key: "registerNonComSocialRemixingPIL",
2943
2863
  value: (function () {
2944
- var _registerPILSocialRemixPolicy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
2945
- var _request$txOptions2, frameworkData, policyId, _yield$this$rpcClient2, call, txHash, targetLog;
2864
+ var _registerNonComSocialRemixingPIL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
2865
+ var _request$txOptions, licenseTerms, licenseTermsId, _yield$this$rpcClient, call, txHash, targetLogs;
2946
2866
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
2947
2867
  while (1) switch (_context2.prev = _context2.next) {
2948
2868
  case 0:
2949
2869
  _context2.prev = 0;
2950
- // First check if the policy exists
2951
- frameworkData = {
2952
- attribution: true,
2870
+ licenseTerms = {
2871
+ transferable: true,
2872
+ royaltyPolicy: zeroAddress,
2873
+ mintingFee: BigInt(0),
2874
+ expiration: BigInt(0),
2953
2875
  commercialUse: false,
2954
2876
  commercialAttribution: false,
2955
2877
  commercializerChecker: zeroAddress,
2956
- commercializerCheckerData: "0x",
2878
+ commercializerCheckerData: zeroAddress,
2957
2879
  commercialRevShare: 0,
2880
+ commercialRevCelling: BigInt(0),
2958
2881
  derivativesAllowed: true,
2959
2882
  derivativesAttribution: true,
2960
2883
  derivativesApproval: false,
2961
2884
  derivativesReciprocal: true,
2962
- territories: request.territories || [],
2963
- distributionChannels: request.distributionChannels || [],
2964
- contentRestrictions: request.contentRestrictions || []
2885
+ derivativeRevCelling: BigInt(0),
2886
+ currency: zeroAddress
2965
2887
  };
2966
2888
  _context2.next = 4;
2967
- return this.getPolicyId(true, this.encodeFrameworkData(frameworkData), typedDataToBytes({
2968
- "interface": "uint32",
2969
- data: [0]
2970
- }), "0", zeroAddress, zeroAddress);
2889
+ return this.getLicenseTermsId(licenseTerms);
2971
2890
  case 4:
2972
- policyId = _context2.sent;
2973
- if (!(policyId !== 0)) {
2891
+ licenseTermsId = _context2.sent;
2892
+ if (!(licenseTermsId !== 0)) {
2974
2893
  _context2.next = 7;
2975
2894
  break;
2976
2895
  }
2977
2896
  return _context2.abrupt("return", {
2978
- policyId: policyId.toString()
2897
+ licenseId: licenseTermsId.toString()
2979
2898
  });
2980
2899
  case 7:
2981
2900
  _context2.next = 9;
2982
- return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.pilPolicyFrameworkManagerConfig), {}, {
2983
- functionName: "registerPolicy",
2984
- args: [{
2985
- transferable: true,
2986
- royaltyPolicy: zeroAddress,
2987
- mintingFee: parseToBigInt(0),
2988
- mintingFeeToken: zeroAddress,
2989
- policy: {
2990
- attribution: true,
2991
- commercialUse: false,
2992
- commercialAttribution: false,
2993
- commercialRevShare: 0,
2994
- derivativesAllowed: true,
2995
- derivativesAttribution: true,
2996
- derivativesApproval: false,
2997
- derivativesReciprocal: true,
2998
- commercializerChecker: zeroAddress,
2999
- commercializerCheckerData: "0x",
3000
- territories: request.territories || [],
3001
- distributionChannels: request.distributionChannels || [],
3002
- contentRestrictions: request.contentRestrictions || []
3003
- }
3004
- }],
2901
+ return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.licenseTemplateConfig), {}, {
2902
+ functionName: "registerLicenseTerms",
2903
+ args: [licenseTerms],
3005
2904
  account: this.wallet.account
3006
2905
  }));
3007
2906
  case 9:
3008
- _yield$this$rpcClient2 = _context2.sent;
3009
- call = _yield$this$rpcClient2.request;
2907
+ _yield$this$rpcClient = _context2.sent;
2908
+ call = _yield$this$rpcClient.request;
3010
2909
  _context2.next = 13;
3011
2910
  return this.wallet.writeContract(call);
3012
2911
  case 13:
3013
2912
  txHash = _context2.sent;
3014
- if (!((_request$txOptions2 = request.txOptions) !== null && _request$txOptions2 !== void 0 && _request$txOptions2.waitForTransaction)) {
2913
+ if (!((_request$txOptions = request.txOptions) !== null && _request$txOptions !== void 0 && _request$txOptions.waitForTransaction)) {
3015
2914
  _context2.next = 21;
3016
2915
  break;
3017
2916
  }
3018
2917
  _context2.next = 17;
3019
- return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, this.licensingModuleConfig), {}, {
3020
- eventName: "PolicyRegistered"
2918
+ return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, this.licenseTemplateConfig), {}, {
2919
+ eventName: "LicenseTermsRegistered"
3021
2920
  }));
3022
2921
  case 17:
3023
- targetLog = _context2.sent;
2922
+ targetLogs = _context2.sent;
3024
2923
  return _context2.abrupt("return", {
3025
2924
  txHash: txHash,
3026
- policyId: targetLog[0].args.policyId.toString()
2925
+ licenseId: targetLogs[0].args.licenseTermsId.toString()
3027
2926
  });
3028
2927
  case 21:
3029
2928
  return _context2.abrupt("return", {
@@ -3035,117 +2934,95 @@ var PolicyClient = /*#__PURE__*/function () {
3035
2934
  case 24:
3036
2935
  _context2.prev = 24;
3037
2936
  _context2.t0 = _context2["catch"](0);
3038
- handleError(_context2.t0, "Failed to register social remix policy");
2937
+ handleError(_context2.t0, "Failed to register non commercial social remixing PIL");
3039
2938
  case 27:
3040
2939
  case "end":
3041
2940
  return _context2.stop();
3042
2941
  }
3043
2942
  }, _callee2, this, [[0, 24]]);
3044
2943
  }));
3045
- function registerPILSocialRemixPolicy(_x2) {
3046
- return _registerPILSocialRemixPolicy.apply(this, arguments);
2944
+ function registerNonComSocialRemixingPIL(_x2) {
2945
+ return _registerNonComSocialRemixingPIL.apply(this, arguments);
3047
2946
  }
3048
- return registerPILSocialRemixPolicy;
2947
+ return registerNonComSocialRemixingPIL;
3049
2948
  }()
3050
2949
  /**
3051
- * Convenient function to register a PIL social remix policy to the registry
3052
- * Internally, this function must generate a Licensing.Policy struct and call registerPolicy.
3053
- * @param request - the licensing parameters for the Programmable IP License v1 (PIL) standard.
3054
- * @param request.commercialRevShare Percentage of revenue that must be shared with the licensor
3055
- * @param mintingFee Fee to be paid when minting a license
3056
- * @param mintingFeeToken Token to be used to pay the minting fee
3057
- * @param request.territories List of territories where the license is valid. If empty, global.
3058
- * @param request.distributionChannels List of distribution channels where the license is valid. Empty if no restrictions.
3059
- * @param request.contentRestrictions List of content restrictions where the license is valid. Empty if no restrictions.
3060
- * @returns the transaction hash and the policy ID if the txOptions.waitForTransaction is set to true
2950
+ * Convenient function to register a PIL commercial use license to the registry.
2951
+ * @param request The request object that contains all data needed to register a PIL commercial use license.
2952
+ * @param request.mintingFee The fee to be paid when minting a license.
2953
+ * @param request.currency The ERC20 token to be used to pay the minting fee.
2954
+ * the token must be registered in story protocol.
2955
+ * @param request.royaltyPolicy The address of the royalty policy contract which required to StoryProtocol in advance.
2956
+ * @param request.txOptions [Optional] The transaction options.
2957
+ * @returns A Promise that resolves to an object containing the optional transaction hash and optional license ID.
2958
+ * @emits LicenseTermsRegistered (licenseTermsId, licenseTemplate, licenseTerms);
3061
2959
  */
3062
2960
  )
3063
2961
  }, {
3064
- key: "registerPILCommercialUsePolicy",
2962
+ key: "registerCommercialUsePIL",
3065
2963
  value: (function () {
3066
- var _registerPILCommercialUsePolicy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(request) {
3067
- var _request$txOptions3, frameworkData, policyId, _yield$this$rpcClient3, call, txHash, targetLogs;
2964
+ var _registerCommercialUsePIL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(request) {
2965
+ var _request$txOptions2, licenseTerms, licenseTermsId, _yield$this$rpcClient2, call, txHash, targetLogs;
3068
2966
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
3069
2967
  while (1) switch (_context3.prev = _context3.next) {
3070
2968
  case 0:
3071
2969
  _context3.prev = 0;
3072
- // First check if the policy exists
3073
- frameworkData = {
3074
- attribution: true,
2970
+ licenseTerms = {
2971
+ transferable: true,
2972
+ royaltyPolicy: this.royaltyPolicyLAPConfig.address,
2973
+ mintingFee: BigInt(request.mintingFee),
2974
+ expiration: BigInt(0),
3075
2975
  commercialUse: true,
3076
2976
  commercialAttribution: true,
3077
2977
  commercializerChecker: zeroAddress,
3078
- commercializerCheckerData: "0x",
3079
- commercialRevShare: request.commercialRevShare,
2978
+ commercializerCheckerData: zeroAddress,
2979
+ commercialRevShare: 0,
2980
+ commercialRevCelling: BigInt(0),
3080
2981
  derivativesAllowed: true,
3081
2982
  derivativesAttribution: true,
3082
2983
  derivativesApproval: false,
3083
- derivativesReciprocal: true,
3084
- territories: request.territories || [],
3085
- distributionChannels: request.distributionChannels || [],
3086
- contentRestrictions: request.contentRestrictions || []
2984
+ derivativesReciprocal: false,
2985
+ derivativeRevCelling: BigInt(0),
2986
+ currency: request.currency
3087
2987
  };
3088
2988
  _context3.next = 4;
3089
- return this.getPolicyId(true, this.encodeFrameworkData(frameworkData), typedDataToBytes({
3090
- "interface": "uint32",
3091
- data: [request.commercialRevShare]
3092
- }), request.mintingFee || "0", request.mintingFeeToken || zeroAddress, this.royaltyPolicyLAPConfig.address);
2989
+ return this.getLicenseTermsId(licenseTerms);
3093
2990
  case 4:
3094
- policyId = _context3.sent;
3095
- if (!(policyId !== 0)) {
2991
+ licenseTermsId = _context3.sent;
2992
+ if (!(licenseTermsId !== 0)) {
3096
2993
  _context3.next = 7;
3097
2994
  break;
3098
2995
  }
3099
2996
  return _context3.abrupt("return", {
3100
- policyId: policyId.toString()
2997
+ licenseId: licenseTermsId.toString()
3101
2998
  });
3102
2999
  case 7:
3103
3000
  _context3.next = 9;
3104
- return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.pilPolicyFrameworkManagerConfig), {}, {
3105
- functionName: "registerPolicy",
3106
- args: [{
3107
- transferable: true,
3108
- royaltyPolicy: this.royaltyPolicyLAPConfig.address,
3109
- mintingFee: parseToBigInt(request.mintingFee || "0"),
3110
- mintingFeeToken: request.mintingFeeToken || zeroAddress,
3111
- policy: {
3112
- attribution: true,
3113
- commercialUse: true,
3114
- commercialAttribution: true,
3115
- commercialRevShare: request.commercialRevShare,
3116
- derivativesAllowed: true,
3117
- derivativesAttribution: true,
3118
- derivativesApproval: false,
3119
- derivativesReciprocal: true,
3120
- commercializerChecker: zeroAddress,
3121
- commercializerCheckerData: "0x",
3122
- territories: request.territories || [],
3123
- distributionChannels: request.distributionChannels || [],
3124
- contentRestrictions: request.contentRestrictions || []
3125
- }
3126
- }],
3001
+ return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.licenseTemplateConfig), {}, {
3002
+ functionName: "registerLicenseTerms",
3003
+ args: [licenseTerms],
3127
3004
  account: this.wallet.account
3128
3005
  }));
3129
3006
  case 9:
3130
- _yield$this$rpcClient3 = _context3.sent;
3131
- call = _yield$this$rpcClient3.request;
3007
+ _yield$this$rpcClient2 = _context3.sent;
3008
+ call = _yield$this$rpcClient2.request;
3132
3009
  _context3.next = 13;
3133
3010
  return this.wallet.writeContract(call);
3134
3011
  case 13:
3135
3012
  txHash = _context3.sent;
3136
- if (!((_request$txOptions3 = request.txOptions) !== null && _request$txOptions3 !== void 0 && _request$txOptions3.waitForTransaction)) {
3013
+ if (!((_request$txOptions2 = request.txOptions) !== null && _request$txOptions2 !== void 0 && _request$txOptions2.waitForTransaction)) {
3137
3014
  _context3.next = 21;
3138
3015
  break;
3139
3016
  }
3140
3017
  _context3.next = 17;
3141
- return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, this.licensingModuleConfig), {}, {
3142
- eventName: "PolicyRegistered"
3018
+ return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, this.licenseTemplateConfig), {}, {
3019
+ eventName: "LicenseTermsRegistered"
3143
3020
  }));
3144
3021
  case 17:
3145
3022
  targetLogs = _context3.sent;
3146
3023
  return _context3.abrupt("return", {
3147
3024
  txHash: txHash,
3148
- policyId: targetLogs[0].args.policyId.toString()
3025
+ licenseId: targetLogs[0].args.licenseTermsId.toString()
3149
3026
  });
3150
3027
  case 21:
3151
3028
  return _context3.abrupt("return", {
@@ -3157,134 +3034,256 @@ var PolicyClient = /*#__PURE__*/function () {
3157
3034
  case 24:
3158
3035
  _context3.prev = 24;
3159
3036
  _context3.t0 = _context3["catch"](0);
3160
- handleError(_context3.t0, "Failed to register commercial use policy");
3037
+ handleError(_context3.t0, "Failed to register commercial use PIL");
3161
3038
  case 27:
3162
3039
  case "end":
3163
3040
  return _context3.stop();
3164
3041
  }
3165
3042
  }, _callee3, this, [[0, 24]]);
3166
3043
  }));
3167
- function registerPILCommercialUsePolicy(_x3) {
3168
- return _registerPILCommercialUsePolicy.apply(this, arguments);
3044
+ function registerCommercialUsePIL(_x3) {
3045
+ return _registerCommercialUsePIL.apply(this, arguments);
3169
3046
  }
3170
- return registerPILCommercialUsePolicy;
3171
- }())
3047
+ return registerCommercialUsePIL;
3048
+ }()
3049
+ /**
3050
+ * Convenient function to register a PIL commercial Remix license to the registry.
3051
+ * @param request The request object that contains all data needed to register license.
3052
+ * @param request.mintingFee The fee to be paid when minting a license.
3053
+ * @param request.commercialRevShare Percentage of revenue that must be shared with the licensor.
3054
+ * @param request.currency The ERC20 token to be used to pay the minting fee. the token must be registered in story protocol.
3055
+ * @param request.royaltyPolicy The address of the royalty policy contract which required to StoryProtocol in advance.
3056
+ * @param request.txOptions [Optional] The transaction options.
3057
+ * @returns A Promise that resolves to an object containing the optional transaction hash and optional license ID.
3058
+ * @emits LicenseTermsRegistered (licenseTermsId, licenseTemplate, licenseTerms);
3059
+ */
3060
+ )
3172
3061
  }, {
3173
- key: "getPolicyId",
3174
- value: function () {
3175
- var _getPolicyId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(transferable, frameworkData, royaltyData, mintingFee, mintingFeeToken, royaltyPolicy, policyFramework) {
3176
- var data;
3062
+ key: "registerCommercialRemixPIL",
3063
+ value: (function () {
3064
+ var _registerCommercialRemixPIL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(request) {
3065
+ var _request$txOptions3, licenseTerms, licenseTermsId, _yield$this$rpcClient3, call, txHash, targetLogs;
3177
3066
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
3178
3067
  while (1) switch (_context4.prev = _context4.next) {
3179
3068
  case 0:
3180
- _context4.next = 2;
3181
- return this.rpcClient.readContract(_objectSpread2(_objectSpread2({}, this.licensingModuleConfig), {}, {
3182
- functionName: "getPolicyId",
3183
- args: [{
3184
- isLicenseTransferable: transferable,
3185
- policyFramework: policyFramework || this.pilPolicyFrameworkManagerConfig.address,
3186
- frameworkData: frameworkData,
3187
- royaltyPolicy: royaltyPolicy,
3188
- royaltyData: royaltyData,
3189
- mintingFee: parseToBigInt(mintingFee),
3190
- mintingFeeToken: mintingFeeToken
3191
- }]
3192
- }));
3193
- case 2:
3194
- data = _context4.sent;
3195
- return _context4.abrupt("return", Number(data));
3069
+ _context4.prev = 0;
3070
+ licenseTerms = {
3071
+ transferable: true,
3072
+ royaltyPolicy: this.royaltyPolicyLAPConfig.address,
3073
+ mintingFee: BigInt(request.mintingFee),
3074
+ expiration: BigInt(0),
3075
+ commercialUse: true,
3076
+ commercialAttribution: true,
3077
+ commercializerChecker: zeroAddress,
3078
+ commercializerCheckerData: zeroAddress,
3079
+ commercialRevShare: request.commercialRevShare,
3080
+ commercialRevCelling: BigInt(0),
3081
+ derivativesAllowed: true,
3082
+ derivativesAttribution: true,
3083
+ derivativesApproval: false,
3084
+ derivativesReciprocal: true,
3085
+ derivativeRevCelling: BigInt(0),
3086
+ currency: request.currency
3087
+ };
3088
+ _context4.next = 4;
3089
+ return this.getLicenseTermsId(licenseTerms);
3196
3090
  case 4:
3091
+ licenseTermsId = _context4.sent;
3092
+ if (!(licenseTermsId !== 0)) {
3093
+ _context4.next = 7;
3094
+ break;
3095
+ }
3096
+ return _context4.abrupt("return", {
3097
+ licenseId: licenseTermsId.toString()
3098
+ });
3099
+ case 7:
3100
+ _context4.next = 9;
3101
+ return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.licenseTemplateConfig), {}, {
3102
+ functionName: "registerLicenseTerms",
3103
+ args: [licenseTerms],
3104
+ account: this.wallet.account
3105
+ }));
3106
+ case 9:
3107
+ _yield$this$rpcClient3 = _context4.sent;
3108
+ call = _yield$this$rpcClient3.request;
3109
+ _context4.next = 13;
3110
+ return this.wallet.writeContract(call);
3111
+ case 13:
3112
+ txHash = _context4.sent;
3113
+ if (!((_request$txOptions3 = request.txOptions) !== null && _request$txOptions3 !== void 0 && _request$txOptions3.waitForTransaction)) {
3114
+ _context4.next = 21;
3115
+ break;
3116
+ }
3117
+ _context4.next = 17;
3118
+ return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, this.licenseTemplateConfig), {}, {
3119
+ eventName: "LicenseTermsRegistered"
3120
+ }));
3121
+ case 17:
3122
+ targetLogs = _context4.sent;
3123
+ return _context4.abrupt("return", {
3124
+ txHash: txHash,
3125
+ licenseId: targetLogs[0].args.licenseTermsId.toString()
3126
+ });
3127
+ case 21:
3128
+ return _context4.abrupt("return", {
3129
+ txHash: txHash
3130
+ });
3131
+ case 22:
3132
+ _context4.next = 27;
3133
+ break;
3134
+ case 24:
3135
+ _context4.prev = 24;
3136
+ _context4.t0 = _context4["catch"](0);
3137
+ handleError(_context4.t0, "Failed to register commercial remix PIL");
3138
+ case 27:
3197
3139
  case "end":
3198
3140
  return _context4.stop();
3199
3141
  }
3200
- }, _callee4, this);
3142
+ }, _callee4, this, [[0, 24]]);
3201
3143
  }));
3202
- function getPolicyId(_x4, _x5, _x6, _x7, _x8, _x9, _x10) {
3203
- return _getPolicyId.apply(this, arguments);
3144
+ function registerCommercialRemixPIL(_x4) {
3145
+ return _registerCommercialRemixPIL.apply(this, arguments);
3204
3146
  }
3205
- return getPolicyId;
3147
+ return registerCommercialRemixPIL;
3206
3148
  }()
3207
- }, {
3208
- key: "encodeFrameworkData",
3209
- value: function encodeFrameworkData(data) {
3210
- return typedDataToBytes({
3211
- "interface": "(bool, bool, bool, address, bytes, uint32, bool, bool, bool, bool, string[], string[], string[])",
3212
- 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]]
3213
- });
3214
- }
3215
-
3216
3149
  /**
3217
- * Adds a policy to the set of policies of an IP
3218
- * @param request The request object containing details to add a policy to an IP
3219
- * @param request.ipId The id of the IP
3220
- * @param request.polId The id of the policy
3221
- * @return the transaction hash and the index of the policy in the IP's policy set if the txOptions.waitForTransaction is set to true
3150
+ * Attaches license terms to an IP, and the function must be called by the IP owner or an authorized operator.
3151
+ * @param request The request object that contains all data needed to attach license terms.
3152
+ @param request.ipId The IP ID.
3153
+ @param request.tokenAddress The address of the NFT.
3154
+ @param request.licenseTemplate The address of the license template.
3155
+ @param request.licenseTermsId The ID of the license terms.
3156
+ * @param request.txOptions [Optional] The transaction options.
3157
+ * @returns A Promise that resolves to an object containing the transaction hash.
3222
3158
  */
3159
+ )
3223
3160
  }, {
3224
- key: "addPolicyToIp",
3161
+ key: "attachLicenseTerms",
3225
3162
  value: (function () {
3226
- var _addPolicyToIp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(request) {
3227
- var _request$txOptions4, IPAccountConfig, _yield$this$rpcClient4, call, txHash, targetLogs;
3163
+ var _attachLicenseTerms = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(request) {
3164
+ var _request$txOptions4;
3165
+ var _yield$this$rpcClient4, call, txHash;
3228
3166
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
3229
3167
  while (1) switch (_context5.prev = _context5.next) {
3230
3168
  case 0:
3231
- _context5.prev = 0;
3232
- IPAccountConfig = {
3233
- abi: this.ipAccountABI,
3234
- address: getAddress(request.ipId)
3235
- };
3236
- _context5.next = 4;
3237
- return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, IPAccountConfig), {}, {
3238
- functionName: "execute",
3239
- args: [this.licensingModuleConfig.address, parseToBigInt(0), encodeFunctionData({
3240
- abi: this.licensingModuleConfig.abi,
3241
- functionName: "addPolicyToIp",
3242
- args: [getAddress(request.ipId), parseToBigInt(request.policyId)]
3243
- })],
3169
+ _context5.next = 2;
3170
+ return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.licensingModuleConfig), {}, {
3171
+ functionName: "attachLicenseTerms",
3172
+ args: [request.ipId, request.licenseTemplate || this.licenseTemplateConfig.address, BigInt(request.licenseTermsId)],
3244
3173
  account: this.wallet.account
3245
3174
  }));
3246
- case 4:
3175
+ case 2:
3247
3176
  _yield$this$rpcClient4 = _context5.sent;
3248
3177
  call = _yield$this$rpcClient4.request;
3249
- _context5.next = 8;
3178
+ _context5.next = 6;
3250
3179
  return this.wallet.writeContract(call);
3251
- case 8:
3180
+ case 6:
3252
3181
  txHash = _context5.sent;
3253
3182
  if (!((_request$txOptions4 = request.txOptions) !== null && _request$txOptions4 !== void 0 && _request$txOptions4.waitForTransaction)) {
3254
- _context5.next = 16;
3183
+ _context5.next = 13;
3184
+ break;
3185
+ }
3186
+ _context5.next = 10;
3187
+ return waitTx(this.rpcClient, txHash);
3188
+ case 10:
3189
+ return _context5.abrupt("return", {
3190
+ txHash: txHash
3191
+ });
3192
+ case 13:
3193
+ return _context5.abrupt("return", {
3194
+ txHash: txHash
3195
+ });
3196
+ case 14:
3197
+ case "end":
3198
+ return _context5.stop();
3199
+ }
3200
+ }, _callee5, this);
3201
+ }));
3202
+ function attachLicenseTerms(_x5) {
3203
+ return _attachLicenseTerms.apply(this, arguments);
3204
+ }
3205
+ return attachLicenseTerms;
3206
+ }()
3207
+ /**
3208
+ * Mints license tokens for the license terms attached to an IP.
3209
+ * The license tokens are minted to the receiver.
3210
+ * The license terms must be attached to the IP before calling this function.
3211
+ * But it can mint license token of default license terms without attaching the default license terms,
3212
+ * since it is attached to all IPs by default.
3213
+ * IP owners can mint license tokens for their IPs for arbitrary license terms
3214
+ * without attaching the license terms to IP.
3215
+ * It might require the caller pay the minting fee, depending on the license terms or configured by the iP owner.
3216
+ * The minting fee is paid in the minting fee token specified in the license terms or configured by the IP owner.
3217
+ * IP owners can configure the minting fee of their IPs or
3218
+ * configure the minting fee module to determine the minting fee.
3219
+ * @param request The request object that contains all data needed to mint license tokens.
3220
+ * @param request.licensorIpId The licensor IP ID.
3221
+ * @param request.licenseTemplate The address of the license template.
3222
+ * @param request.licenseTermsId The ID of the license terms within the license template.
3223
+ * @param request.amount The amount of license tokens to mint.
3224
+ * @param request.receiver The address of the receiver.
3225
+ * @param request.txOptions [Optional] The transaction options.
3226
+ * @returns A Promise that resolves to an object containing the transaction hash and optional license token ID if waitForTxn is set to true.
3227
+ * @emits LicenseTokensMinted (msg.sender, licensorIpId, licenseTemplate, licenseTermsId, amount, receiver, startLicenseTokenId);
3228
+ */
3229
+ )
3230
+ }, {
3231
+ key: "mintLicenseTokens",
3232
+ value: (function () {
3233
+ var _mintLicenseTokens = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(request) {
3234
+ var _request$txOptions5, _yield$this$rpcClient5, call, txHash, targetLogs;
3235
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
3236
+ while (1) switch (_context6.prev = _context6.next) {
3237
+ case 0:
3238
+ _context6.prev = 0;
3239
+ _context6.next = 3;
3240
+ return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.licensingModuleConfig), {}, {
3241
+ functionName: "mintLicenseTokens",
3242
+ args: [request.licensorIpId, request.licenseTemplate || this.licenseTemplateConfig.address, BigInt(request.licenseTermsId), BigInt(request.amount || 1), request.receiver || this.wallet.account.address, zeroAddress],
3243
+ account: this.wallet.account
3244
+ }));
3245
+ case 3:
3246
+ _yield$this$rpcClient5 = _context6.sent;
3247
+ call = _yield$this$rpcClient5.request;
3248
+ _context6.next = 7;
3249
+ return this.wallet.writeContract(call);
3250
+ case 7:
3251
+ txHash = _context6.sent;
3252
+ if (!((_request$txOptions5 = request.txOptions) !== null && _request$txOptions5 !== void 0 && _request$txOptions5.waitForTransaction)) {
3253
+ _context6.next = 15;
3255
3254
  break;
3256
3255
  }
3257
- _context5.next = 12;
3256
+ _context6.next = 11;
3258
3257
  return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, this.licensingModuleConfig), {}, {
3259
- eventName: "PolicyAddedToIpId"
3258
+ eventName: "LicenseTokensMinted"
3260
3259
  }));
3261
- case 12:
3262
- targetLogs = _context5.sent;
3263
- return _context5.abrupt("return", {
3260
+ case 11:
3261
+ targetLogs = _context6.sent;
3262
+ return _context6.abrupt("return", {
3264
3263
  txHash: txHash,
3265
- index: targetLogs[0].args.index.toString()
3264
+ licenseTokenId: targetLogs[0].args.startLicenseTokenId.toString()
3266
3265
  });
3267
- case 16:
3268
- return _context5.abrupt("return", {
3266
+ case 15:
3267
+ return _context6.abrupt("return", {
3269
3268
  txHash: txHash
3270
3269
  });
3271
- case 17:
3272
- _context5.next = 22;
3270
+ case 16:
3271
+ _context6.next = 21;
3273
3272
  break;
3274
- case 19:
3275
- _context5.prev = 19;
3276
- _context5.t0 = _context5["catch"](0);
3277
- handleError(_context5.t0, "Failed to add policy to IP");
3278
- case 22:
3273
+ case 18:
3274
+ _context6.prev = 18;
3275
+ _context6.t0 = _context6["catch"](0);
3276
+ handleError(_context6.t0, "Failed to mint license tokens");
3277
+ case 21:
3279
3278
  case "end":
3280
- return _context5.stop();
3279
+ return _context6.stop();
3281
3280
  }
3282
- }, _callee5, this, [[0, 19]]);
3281
+ }, _callee6, this, [[0, 18]]);
3283
3282
  }));
3284
- function addPolicyToIp(_x11) {
3285
- return _addPolicyToIp.apply(this, arguments);
3283
+ function mintLicenseTokens(_x6) {
3284
+ return _mintLicenseTokens.apply(this, arguments);
3286
3285
  }
3287
- return addPolicyToIp;
3286
+ return mintLicenseTokens;
3288
3287
  }())
3289
3288
  }]);
3290
3289
  }();
@@ -3680,30 +3679,6 @@ var StoryAPIClient = /*#__PURE__*/function () {
3680
3679
  }
3681
3680
  return getLicense;
3682
3681
  }()
3683
- }, {
3684
- key: "getPolicy",
3685
- value: function () {
3686
- var _getPolicy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(policyId) {
3687
- var policyResp;
3688
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
3689
- while (1) switch (_context3.prev = _context3.next) {
3690
- case 0:
3691
- _context3.next = 2;
3692
- return this.httpClient.get("/api/v1/policies/".concat(policyId));
3693
- case 2:
3694
- policyResp = _context3.sent;
3695
- return _context3.abrupt("return", policyResp.data.data);
3696
- case 4:
3697
- case "end":
3698
- return _context3.stop();
3699
- }
3700
- }, _callee3, this);
3701
- }));
3702
- function getPolicy(_x3) {
3703
- return _getPolicy.apply(this, arguments);
3704
- }
3705
- return getPolicy;
3706
- }()
3707
3682
  }]);
3708
3683
  }();
3709
3684
 
@@ -3882,7 +3857,6 @@ var StoryClient = /*#__PURE__*/function () {
3882
3857
  _defineProperty(this, "_ipAsset", null);
3883
3858
  _defineProperty(this, "_permission", null);
3884
3859
  _defineProperty(this, "_license", null);
3885
- _defineProperty(this, "_policy", null);
3886
3860
  _defineProperty(this, "_dispute", null);
3887
3861
  _defineProperty(this, "_ipAccount", null);
3888
3862
  _defineProperty(this, "_royalty", null);
@@ -3902,7 +3876,7 @@ var StoryClient = /*#__PURE__*/function () {
3902
3876
  if (!account) {
3903
3877
  throw new Error("account is null");
3904
3878
  }
3905
- this.wallet = createWalletClient(_objectSpread2(_objectSpread2({}, clientConfig), {}, {
3879
+ this.wallet = config.wallet || createWalletClient(_objectSpread2(_objectSpread2({}, clientConfig), {}, {
3906
3880
  account: account
3907
3881
  }));
3908
3882
  }
@@ -3958,21 +3932,6 @@ var StoryClient = /*#__PURE__*/function () {
3958
3932
  return this._license;
3959
3933
  }
3960
3934
 
3961
- /**
3962
- * Getter for the policy client. The client is lazily created when
3963
- * this method is called.
3964
- *
3965
- * @returns the PolicyClient instance
3966
- */
3967
- }, {
3968
- key: "policy",
3969
- get: function get() {
3970
- if (this._policy === null) {
3971
- this._policy = new PolicyClient(this.rpcClient, this.wallet, this.config.chainId);
3972
- }
3973
- return this._policy;
3974
- }
3975
-
3976
3935
  /**
3977
3936
  * Getter for the dispute client. The client is lazily created when
3978
3937
  * this method is called.
@@ -4027,4 +3986,4 @@ var StoryClient = /*#__PURE__*/function () {
4027
3986
  var AddressZero = "0x0000000000000000000000000000000000000000";
4028
3987
  var HashZero = "0x0000000000000000000000000000000000000000000000000000000000000000";
4029
3988
 
4030
- export { AddressZero, DisputeClient, HashZero, IPAssetClient, LicenseClient, PermissionClient, PolicyClient, StoryClient };
3989
+ export { AddressZero, DisputeClient, HashZero, IPAssetClient, LicenseClient, PermissionClient, StoryClient };