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

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 (28) hide show
  1. package/dist/declarations/src/client.d.ts +9 -0
  2. package/dist/declarations/src/client.d.ts.map +1 -1
  3. package/dist/declarations/src/index.d.ts +2 -1
  4. package/dist/declarations/src/index.d.ts.map +1 -1
  5. package/dist/declarations/src/resources/dispute.d.ts +103 -78
  6. package/dist/declarations/src/resources/dispute.d.ts.map +1 -1
  7. package/dist/declarations/src/resources/ipAccount.d.ts +84 -76
  8. package/dist/declarations/src/resources/ipAccount.d.ts.map +1 -1
  9. package/dist/declarations/src/resources/ipAsset.d.ts +26 -756
  10. package/dist/declarations/src/resources/ipAsset.d.ts.map +1 -1
  11. package/dist/declarations/src/resources/license.d.ts +875 -858
  12. package/dist/declarations/src/resources/license.d.ts.map +1 -1
  13. package/dist/declarations/src/resources/permission.d.ts +271 -216
  14. package/dist/declarations/src/resources/permission.d.ts.map +1 -1
  15. package/dist/declarations/src/resources/policy.d.ts +1094 -277
  16. package/dist/declarations/src/resources/policy.d.ts.map +1 -1
  17. package/dist/declarations/src/resources/royalty.d.ts +2155 -0
  18. package/dist/declarations/src/resources/royalty.d.ts.map +1 -0
  19. package/dist/declarations/src/types/config.d.ts +4 -1
  20. package/dist/declarations/src/types/config.d.ts.map +1 -1
  21. package/dist/declarations/src/types/resources/ipAsset.d.ts +4 -20
  22. package/dist/declarations/src/types/resources/ipAsset.d.ts.map +1 -1
  23. package/dist/declarations/src/types/resources/royalty.d.ts +41 -0
  24. package/dist/declarations/src/types/resources/royalty.d.ts.map +1 -1
  25. package/dist/story-protocol-core-sdk.cjs.dev.js +864 -613
  26. package/dist/story-protocol-core-sdk.cjs.prod.js +864 -613
  27. package/dist/story-protocol-core-sdk.esm.js +866 -615
  28. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
- import { getAddress, encodeAbiParameters, parseAbiParameters, decodeEventLog, encodeFunctionData, zeroAddress, stringToHex, createPublicClient, createWalletClient } from 'viem';
1
+ import { encodeAbiParameters, parseAbiParameters, defineChain, decodeEventLog, getAddress, encodeFunctionData, zeroAddress, stringToHex, createPublicClient, createWalletClient } from 'viem';
2
2
  import * as dotenv from 'dotenv';
3
- import { polygonMumbai, sepolia as sepolia$1, mainnet } from 'viem/chains';
3
+ import { sepolia as sepolia$1 } from 'viem/chains';
4
4
  import axios from 'axios';
5
5
 
6
6
  function toPrimitive(t, r) {
@@ -413,31 +413,12 @@ function _asyncToGenerator(fn) {
413
413
  };
414
414
  }
415
415
 
416
- function handleError(error, msg) {
417
- if (error instanceof Error) {
418
- throw new Error("".concat(msg, ": ").concat(error.message));
419
- }
420
- throw new Error("".concat(msg, ": Unknown error type"));
421
- }
422
-
423
- var AddressZero = "0x0000000000000000000000000000000000000000";
424
- var HashZero = "0x0000000000000000000000000000000000000000000000000000000000000000";
425
- var SepoliaChainId = "11155111";
426
-
427
416
  function _arrayLikeToArray(arr, len) {
428
417
  if (len == null || len > arr.length) len = arr.length;
429
418
  for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
430
419
  return arr2;
431
420
  }
432
421
 
433
- function _arrayWithoutHoles(arr) {
434
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
435
- }
436
-
437
- function _iterableToArray(iter) {
438
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
439
- }
440
-
441
422
  function _unsupportedIterableToArray(o, minLen) {
442
423
  if (!o) return;
443
424
  if (typeof o === "string") return _arrayLikeToArray(o, minLen);
@@ -447,6 +428,218 @@ function _unsupportedIterableToArray(o, minLen) {
447
428
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
448
429
  }
449
430
 
431
+ function _createForOfIteratorHelper(o, allowArrayLike) {
432
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
433
+ if (!it) {
434
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
435
+ if (it) o = it;
436
+ var i = 0;
437
+ var F = function () {};
438
+ return {
439
+ s: F,
440
+ n: function () {
441
+ if (i >= o.length) return {
442
+ done: true
443
+ };
444
+ return {
445
+ done: false,
446
+ value: o[i++]
447
+ };
448
+ },
449
+ e: function (e) {
450
+ throw e;
451
+ },
452
+ f: F
453
+ };
454
+ }
455
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
456
+ }
457
+ var normalCompletion = true,
458
+ didErr = false,
459
+ err;
460
+ return {
461
+ s: function () {
462
+ it = it.call(o);
463
+ },
464
+ n: function () {
465
+ var step = it.next();
466
+ normalCompletion = step.done;
467
+ return step;
468
+ },
469
+ e: function (e) {
470
+ didErr = true;
471
+ err = e;
472
+ },
473
+ f: function () {
474
+ try {
475
+ if (!normalCompletion && it.return != null) it.return();
476
+ } finally {
477
+ if (didErr) throw err;
478
+ }
479
+ }
480
+ };
481
+ }
482
+
483
+ function parseToBigInt(num) {
484
+ return BigInt(num);
485
+ }
486
+ function waitTxAndFilterLog(_x, _x2, _x3) {
487
+ return _waitTxAndFilterLog.apply(this, arguments);
488
+ }
489
+ function _waitTxAndFilterLog() {
490
+ _waitTxAndFilterLog = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(client, txHash, params) {
491
+ var txReceipt, targetLogs, _iterator, _step, log, currentLog;
492
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
493
+ while (1) switch (_context.prev = _context.next) {
494
+ case 0:
495
+ _context.next = 2;
496
+ return client.waitForTransactionReceipt({
497
+ hash: txHash,
498
+ confirmations: params.confirmations,
499
+ pollingInterval: params.pollingInterval,
500
+ timeout: params.timeout
501
+ });
502
+ case 2:
503
+ txReceipt = _context.sent;
504
+ targetLogs = [];
505
+ _iterator = _createForOfIteratorHelper(txReceipt.logs);
506
+ _context.prev = 5;
507
+ _iterator.s();
508
+ case 7:
509
+ if ((_step = _iterator.n()).done) {
510
+ _context.next = 21;
511
+ break;
512
+ }
513
+ log = _step.value;
514
+ _context.prev = 9;
515
+ if (!(params.from && log.address !== params.from.toLowerCase())) {
516
+ _context.next = 12;
517
+ break;
518
+ }
519
+ return _context.abrupt("continue", 19);
520
+ case 12:
521
+ currentLog = decodeEventLog({
522
+ abi: params.abi,
523
+ eventName: params.eventName,
524
+ data: log.data,
525
+ topics: log.topics
526
+ });
527
+ targetLogs.push(currentLog);
528
+ _context.next = 19;
529
+ break;
530
+ case 16:
531
+ _context.prev = 16;
532
+ _context.t0 = _context["catch"](9);
533
+ return _context.abrupt("continue", 19);
534
+ case 19:
535
+ _context.next = 7;
536
+ break;
537
+ case 21:
538
+ _context.next = 26;
539
+ break;
540
+ case 23:
541
+ _context.prev = 23;
542
+ _context.t1 = _context["catch"](5);
543
+ _iterator.e(_context.t1);
544
+ case 26:
545
+ _context.prev = 26;
546
+ _iterator.f();
547
+ return _context.finish(26);
548
+ case 29:
549
+ if (!(targetLogs.length === 0)) {
550
+ _context.next = 31;
551
+ break;
552
+ }
553
+ throw new Error("not found event ".concat(params.eventName, " in target transaction"));
554
+ case 31:
555
+ return _context.abrupt("return", targetLogs);
556
+ case 32:
557
+ case "end":
558
+ return _context.stop();
559
+ }
560
+ }, _callee, null, [[5, 23, 26, 29], [9, 16]]);
561
+ }));
562
+ return _waitTxAndFilterLog.apply(this, arguments);
563
+ }
564
+ function waitTx(_x4, _x5, _x6) {
565
+ return _waitTx.apply(this, arguments);
566
+ }
567
+ function _waitTx() {
568
+ _waitTx = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(client, txHash, params) {
569
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
570
+ while (1) switch (_context2.prev = _context2.next) {
571
+ case 0:
572
+ _context2.next = 2;
573
+ return client.waitForTransactionReceipt(_objectSpread2({
574
+ hash: txHash
575
+ }, params));
576
+ case 2:
577
+ case "end":
578
+ return _context2.stop();
579
+ }
580
+ }, _callee2);
581
+ }));
582
+ return _waitTx.apply(this, arguments);
583
+ }
584
+ function typedDataToBytes(typedData) {
585
+ return encodeAbiParameters(parseAbiParameters(typedData["interface"]), typedData.data);
586
+ }
587
+ function chainStringToViemChain(chainId) {
588
+ switch (chainId) {
589
+ case "11155111":
590
+ case "sepolia":
591
+ return sepolia$1;
592
+ case "1513":
593
+ case "storyTestnet":
594
+ return storyTestnet$1;
595
+ default:
596
+ throw new Error("chainId ".concat(chainId, " not supported"));
597
+ }
598
+ }
599
+ var storyTestnet$1 = defineChain({
600
+ id: 1513,
601
+ name: "story-network",
602
+ nativeCurrency: {
603
+ name: "Ether",
604
+ symbol: "SEP",
605
+ decimals: 18
606
+ },
607
+ rpcUrls: {
608
+ "default": {
609
+ http: ["https://story-network.rpc.caldera.xyz/http"],
610
+ webSocket: ["wss://story-network.rpc.caldera.xyz/ws"]
611
+ }
612
+ },
613
+ blockExplorers: {
614
+ "default": {
615
+ name: "Explorer",
616
+ url: "https://story-network.explorer.caldera.xyz"
617
+ }
618
+ },
619
+ //TODO: wait for Ze confirm with config information
620
+ contracts: {
621
+ multicall3: {
622
+ address: "0xcA11bde05977b3631167028862bE2a173976CA11",
623
+ blockCreated: 5882
624
+ }
625
+ },
626
+ testnet: true
627
+ });
628
+ var chain = {
629
+ sepolia: "11155111",
630
+ storyTestnet: "1513",
631
+ 11155111: "11155111",
632
+ 1513: "1513"
633
+ };
634
+
635
+ function _arrayWithoutHoles(arr) {
636
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
637
+ }
638
+
639
+ function _iterableToArray(iter) {
640
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
641
+ }
642
+
450
643
  function _nonIterableSpread() {
451
644
  throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
452
645
  }
@@ -779,19 +972,19 @@ var IPAssetRegistryABI = [{
779
972
  type: "uint256"
780
973
  }, {
781
974
  indexed: false,
782
- internalType: "address",
783
- name: "resolver",
784
- type: "address"
975
+ internalType: "string",
976
+ name: "name",
977
+ type: "string"
785
978
  }, {
786
979
  indexed: false,
787
- internalType: "address",
788
- name: "provider",
789
- type: "address"
980
+ internalType: "string",
981
+ name: "uri",
982
+ type: "string"
790
983
  }, {
791
984
  indexed: false,
792
- internalType: "bytes",
793
- name: "metadata",
794
- type: "bytes"
985
+ internalType: "uint256",
986
+ name: "registrationDate",
987
+ type: "uint256"
795
988
  }],
796
989
  name: "IPRegistered",
797
990
  type: "event"
@@ -831,6 +1024,24 @@ var IPAssetRegistryABI = [{
831
1024
  }],
832
1025
  stateMutability: "view",
833
1026
  type: "function"
1027
+ }, {
1028
+ inputs: [{
1029
+ internalType: "address",
1030
+ name: "tokenContract",
1031
+ type: "address"
1032
+ }, {
1033
+ internalType: "uint256",
1034
+ name: "tokenId",
1035
+ type: "uint256"
1036
+ }],
1037
+ name: "register",
1038
+ outputs: [{
1039
+ internalType: "address",
1040
+ name: "id",
1041
+ type: "address"
1042
+ }],
1043
+ stateMutability: "nonpayable",
1044
+ type: "function"
834
1045
  }];
835
1046
 
836
1047
  var LicensingModuleABI = [{
@@ -1167,72 +1378,152 @@ var PILPolicyFrameworkManagerABI = [{
1167
1378
  type: "function"
1168
1379
  }];
1169
1380
 
1170
- var RegistrationModuleABI = [{
1381
+ var IRoyaltyPolicyLAPABI = [{
1171
1382
  inputs: [{
1172
- internalType: "uint256[]",
1173
- name: "licenseIds",
1174
- type: "uint256[]"
1175
- }, {
1176
1383
  internalType: "address",
1177
- name: "tokenContract",
1384
+ name: "ipId",
1178
1385
  type: "address"
1386
+ }],
1387
+ name: "getRoyaltyData",
1388
+ outputs: [{
1389
+ internalType: "bool",
1390
+ name: "",
1391
+ type: "bool"
1179
1392
  }, {
1180
- internalType: "uint256",
1181
- name: "tokenId",
1182
- type: "uint256"
1183
- }, {
1184
- internalType: "string",
1185
- name: "ipName",
1186
- type: "string"
1393
+ internalType: "address",
1394
+ name: "",
1395
+ type: "address"
1187
1396
  }, {
1188
- internalType: "bytes32",
1189
- name: "contentHash",
1190
- type: "bytes32"
1397
+ internalType: "uint32",
1398
+ name: "",
1399
+ type: "uint32"
1191
1400
  }, {
1192
- internalType: "string",
1193
- name: "externalURL",
1194
- type: "string"
1401
+ internalType: "address[]",
1402
+ name: "",
1403
+ type: "address[]"
1195
1404
  }, {
1196
- internalType: "bytes",
1197
- name: "royaltyContext",
1198
- type: "bytes"
1405
+ internalType: "uint32[]",
1406
+ name: "",
1407
+ type: "uint32[]"
1408
+ }],
1409
+ stateMutability: "view",
1410
+ type: "function"
1411
+ }, {
1412
+ inputs: [{
1413
+ internalType: "address",
1414
+ name: "caller",
1415
+ type: "address"
1416
+ }, {
1417
+ internalType: "address",
1418
+ name: "ipId",
1419
+ type: "address"
1420
+ }, {
1421
+ internalType: "address",
1422
+ name: "token",
1423
+ type: "address"
1424
+ }, {
1425
+ internalType: "uint256",
1426
+ name: "amount",
1427
+ type: "uint256"
1428
+ }],
1429
+ name: "onRoyaltyPayment",
1430
+ outputs: [],
1431
+ stateMutability: "nonpayable",
1432
+ type: "function"
1433
+ }];
1434
+
1435
+ var IpRoyaltyVaultABI = [{
1436
+ inputs: [{
1437
+ internalType: "uint256[]",
1438
+ name: "snapshotIds",
1439
+ type: "uint256[]"
1440
+ }, {
1441
+ internalType: "address",
1442
+ name: "token",
1443
+ type: "address"
1199
1444
  }],
1200
- name: "registerDerivativeIp",
1445
+ name: "claimRevenueBySnapshotBatch",
1201
1446
  outputs: [],
1202
1447
  stateMutability: "nonpayable",
1203
1448
  type: "function"
1204
1449
  }, {
1205
1450
  inputs: [{
1206
1451
  internalType: "uint256",
1207
- name: "policyId",
1452
+ name: "snapshotId",
1208
1453
  type: "uint256"
1209
1454
  }, {
1455
+ internalType: "address[]",
1456
+ name: "tokens",
1457
+ type: "address[]"
1458
+ }],
1459
+ name: "claimRevenueByTokenBatch",
1460
+ outputs: [],
1461
+ stateMutability: "nonpayable",
1462
+ type: "function"
1463
+ }, {
1464
+ inputs: [{
1210
1465
  internalType: "address",
1211
- name: "tokenContract",
1466
+ name: "account",
1212
1467
  type: "address"
1213
1468
  }, {
1214
1469
  internalType: "uint256",
1215
- name: "tokenId",
1470
+ name: "snapshotId",
1216
1471
  type: "uint256"
1217
1472
  }, {
1218
- internalType: "string",
1219
- name: "ipName",
1220
- type: "string"
1221
- }, {
1222
- internalType: "bytes32",
1223
- name: "contentHash",
1224
- type: "bytes32"
1225
- }, {
1226
- internalType: "string",
1227
- name: "externalURL",
1228
- type: "string"
1473
+ internalType: "address",
1474
+ name: "token",
1475
+ type: "address"
1476
+ }],
1477
+ name: "claimableRevenue",
1478
+ outputs: [{
1479
+ internalType: "uint256",
1480
+ name: "",
1481
+ type: "uint256"
1482
+ }],
1483
+ stateMutability: "view",
1484
+ type: "function"
1485
+ }, {
1486
+ inputs: [{
1487
+ internalType: "address",
1488
+ name: "ancestorIpId",
1489
+ type: "address"
1229
1490
  }],
1230
- name: "registerRootIp",
1491
+ name: "collectRoyaltyTokens",
1492
+ outputs: [],
1493
+ stateMutability: "nonpayable",
1494
+ type: "function"
1495
+ }, {
1496
+ inputs: [],
1497
+ name: "ipId",
1231
1498
  outputs: [{
1232
1499
  internalType: "address",
1233
1500
  name: "",
1234
1501
  type: "address"
1235
1502
  }],
1503
+ stateMutability: "view",
1504
+ type: "function"
1505
+ }];
1506
+
1507
+ var IRoyaltyModuleABI = [{
1508
+ inputs: [{
1509
+ internalType: "address",
1510
+ name: "receiverIpId",
1511
+ type: "address"
1512
+ }, {
1513
+ internalType: "address",
1514
+ name: "payerIpId",
1515
+ type: "address"
1516
+ }, {
1517
+ internalType: "address",
1518
+ name: "token",
1519
+ type: "address"
1520
+ }, {
1521
+ internalType: "uint256",
1522
+ name: "amount",
1523
+ type: "uint256"
1524
+ }],
1525
+ name: "payRoyaltyOnBehalf",
1526
+ outputs: [],
1236
1527
  stateMutability: "nonpayable",
1237
1528
  type: "function"
1238
1529
  }];
@@ -1257,6 +1548,18 @@ var ErrorsABI = [{
1257
1548
  inputs: [],
1258
1549
  name: "AccessControlled__ZeroAddress",
1259
1550
  type: "error"
1551
+ }, {
1552
+ inputs: [{
1553
+ internalType: "address",
1554
+ name: "signer",
1555
+ type: "address"
1556
+ }, {
1557
+ internalType: "address",
1558
+ name: "to",
1559
+ type: "address"
1560
+ }],
1561
+ name: "AccessController__BothCallerAndRecipientAreNotRegisteredModule",
1562
+ type: "error"
1260
1563
  }, {
1261
1564
  inputs: [],
1262
1565
  name: "AccessController__CallerIsNotIPAccount",
@@ -1297,61 +1600,29 @@ var ErrorsABI = [{
1297
1600
  inputs: [],
1298
1601
  name: "AccessController__PermissionIsNotValid",
1299
1602
  type: "error"
1300
- }, {
1301
- inputs: [{
1302
- internalType: "address",
1303
- name: "to",
1304
- type: "address"
1305
- }],
1306
- name: "AccessController__RecipientIsNotRegisteredModule",
1307
- type: "error"
1308
1603
  }, {
1309
1604
  inputs: [],
1310
1605
  name: "AccessController__SignerIsZeroAddress",
1311
1606
  type: "error"
1312
1607
  }, {
1313
1608
  inputs: [],
1314
- name: "AncestorsVaultLAP__AlreadyClaimed",
1315
- type: "error"
1316
- }, {
1317
- inputs: [],
1318
- name: "AncestorsVaultLAP__ClaimerNotAnAncestor",
1319
- type: "error"
1320
- }, {
1321
- inputs: [],
1322
- name: "AncestorsVaultLAP__ERC20BalanceNotZero",
1323
- type: "error"
1324
- }, {
1325
- inputs: [],
1326
- name: "AncestorsVaultLAP__ETHBalanceNotZero",
1327
- type: "error"
1328
- }, {
1329
- inputs: [],
1330
- name: "AncestorsVaultLAP__InvalidAncestorsHash",
1331
- type: "error"
1332
- }, {
1333
- inputs: [],
1334
- name: "AncestorsVaultLAP__InvalidClaimer",
1335
- type: "error"
1336
- }, {
1337
- inputs: [],
1338
- name: "AncestorsVaultLAP__TransferFailed",
1609
+ name: "ArbitrationPolicySP__NotDisputeModule",
1339
1610
  type: "error"
1340
1611
  }, {
1341
1612
  inputs: [],
1342
- name: "AncestorsVaultLAP__ZeroRoyaltyPolicyLAP",
1613
+ name: "ArbitrationPolicySP__ZeroDisputeModule",
1343
1614
  type: "error"
1344
1615
  }, {
1345
1616
  inputs: [],
1346
- name: "ArbitrationPolicySP__NotDisputeModule",
1617
+ name: "ArbitrationPolicySP__ZeroPaymentToken",
1347
1618
  type: "error"
1348
1619
  }, {
1349
1620
  inputs: [],
1350
- name: "ArbitrationPolicySP__ZeroDisputeModule",
1621
+ name: "BasePolicyFrameworkManager__CallerNotLicensingModule",
1351
1622
  type: "error"
1352
1623
  }, {
1353
1624
  inputs: [],
1354
- name: "ArbitrationPolicySP__ZeroPaymentToken",
1625
+ name: "CoreMetadataModule__MetadataAlreadyFrozen",
1355
1626
  type: "error"
1356
1627
  }, {
1357
1628
  inputs: [],
@@ -1381,10 +1652,6 @@ var ErrorsABI = [{
1381
1652
  inputs: [],
1382
1653
  name: "DisputeModule__NotWhitelistedDisputeTag",
1383
1654
  type: "error"
1384
- }, {
1385
- inputs: [],
1386
- name: "DisputeModule__UnauthorizedAccess",
1387
- type: "error"
1388
1655
  }, {
1389
1656
  inputs: [],
1390
1657
  name: "DisputeModule__ZeroArbitrationPolicy",
@@ -1469,6 +1736,18 @@ var ErrorsABI = [{
1469
1736
  inputs: [],
1470
1737
  name: "IPAssetRegistry__InvalidMetadataProvider",
1471
1738
  type: "error"
1739
+ }, {
1740
+ inputs: [{
1741
+ internalType: "address",
1742
+ name: "contractAddress",
1743
+ type: "address"
1744
+ }, {
1745
+ internalType: "uint256",
1746
+ name: "tokenId",
1747
+ type: "uint256"
1748
+ }],
1749
+ name: "IPAssetRegistry__InvalidToken",
1750
+ type: "error"
1472
1751
  }, {
1473
1752
  inputs: [],
1474
1753
  name: "IPAssetRegistry__NotYetRegistered",
@@ -1485,6 +1764,22 @@ var ErrorsABI = [{
1485
1764
  inputs: [],
1486
1765
  name: "IPAssetRegistry__Unauthorized",
1487
1766
  type: "error"
1767
+ }, {
1768
+ inputs: [{
1769
+ internalType: "address",
1770
+ name: "contractAddress",
1771
+ type: "address"
1772
+ }],
1773
+ name: "IPAssetRegistry__UnsupportedIERC721",
1774
+ type: "error"
1775
+ }, {
1776
+ inputs: [{
1777
+ internalType: "address",
1778
+ name: "contractAddress",
1779
+ type: "address"
1780
+ }],
1781
+ name: "IPAssetRegistry__UnsupportedIERC721Metadata",
1782
+ type: "error"
1488
1783
  }, {
1489
1784
  inputs: [],
1490
1785
  name: "IPResolver_InvalidIP",
@@ -1493,6 +1788,30 @@ var ErrorsABI = [{
1493
1788
  inputs: [],
1494
1789
  name: "IPResolver_Unauthorized",
1495
1790
  type: "error"
1791
+ }, {
1792
+ inputs: [],
1793
+ name: "IpRoyaltyVault__AlreadyClaimed",
1794
+ type: "error"
1795
+ }, {
1796
+ inputs: [],
1797
+ name: "IpRoyaltyVault__ClaimerNotAnAncestor",
1798
+ type: "error"
1799
+ }, {
1800
+ inputs: [],
1801
+ name: "IpRoyaltyVault__NotRoyaltyPolicyLAP",
1802
+ type: "error"
1803
+ }, {
1804
+ inputs: [],
1805
+ name: "IpRoyaltyVault__SnapshotIntervalTooShort",
1806
+ type: "error"
1807
+ }, {
1808
+ inputs: [],
1809
+ name: "IpRoyaltyVault__ZeroIpId",
1810
+ type: "error"
1811
+ }, {
1812
+ inputs: [],
1813
+ name: "IpRoyaltyVault__ZeroRoyaltyPolicyLAP",
1814
+ type: "error"
1496
1815
  }, {
1497
1816
  inputs: [],
1498
1817
  name: "LicenseRegistry__CallerNotLicensingModule",
@@ -1513,10 +1832,6 @@ var ErrorsABI = [{
1513
1832
  inputs: [],
1514
1833
  name: "LicenseRegistry__ZeroLicensingModule",
1515
1834
  type: "error"
1516
- }, {
1517
- inputs: [],
1518
- name: "LicensingModuleAware__CallerNotLicensingModule",
1519
- type: "error"
1520
1835
  }, {
1521
1836
  inputs: [],
1522
1837
  name: "LicensingModule__CallerNotLicenseRegistry",
@@ -1577,6 +1892,10 @@ var ErrorsABI = [{
1577
1892
  inputs: [],
1578
1893
  name: "LicensingModule__InvalidPolicyFramework",
1579
1894
  type: "error"
1895
+ }, {
1896
+ inputs: [],
1897
+ name: "LicensingModule__IpAlreadyLinked",
1898
+ type: "error"
1580
1899
  }, {
1581
1900
  inputs: [],
1582
1901
  name: "LicensingModule__LicensorDoesntHaveThisPolicy",
@@ -1593,6 +1912,10 @@ var ErrorsABI = [{
1593
1912
  inputs: [],
1594
1913
  name: "LicensingModule__LinkingRevokedLicense",
1595
1914
  type: "error"
1915
+ }, {
1916
+ inputs: [],
1917
+ name: "LicensingModule__MintAmountZero",
1918
+ type: "error"
1596
1919
  }, {
1597
1920
  inputs: [],
1598
1921
  name: "LicensingModule__MintLicenseParamFailed",
@@ -1629,6 +1952,10 @@ var ErrorsABI = [{
1629
1952
  inputs: [],
1630
1953
  name: "LicensingModule__PolicyNotFound",
1631
1954
  type: "error"
1955
+ }, {
1956
+ inputs: [],
1957
+ name: "LicensingModule__ReceiverZeroAddress",
1958
+ type: "error"
1632
1959
  }, {
1633
1960
  inputs: [],
1634
1961
  name: "LicensingModule__RegisterPolicyFrameworkMismatch",
@@ -1757,10 +2084,6 @@ var ErrorsABI = [{
1757
2084
  inputs: [],
1758
2085
  name: "PolicyFrameworkManager__GettingPolicyWrongFramework",
1759
2086
  type: "error"
1760
- }, {
1761
- inputs: [],
1762
- name: "RegistrationModule__InvalidOwner",
1763
- type: "error"
1764
2087
  }, {
1765
2088
  inputs: [],
1766
2089
  name: "RoyaltyModule__CanOnlyMintSelectedPolicy",
@@ -1781,10 +2104,6 @@ var ErrorsABI = [{
1781
2104
  inputs: [],
1782
2105
  name: "RoyaltyModule__NotAllowedCaller",
1783
2106
  type: "error"
1784
- }, {
1785
- inputs: [],
1786
- name: "RoyaltyModule__NotRegisteredIpId",
1787
- type: "error"
1788
2107
  }, {
1789
2108
  inputs: [],
1790
2109
  name: "RoyaltyModule__NotWhitelistedRoyaltyPolicy",
@@ -1821,30 +2140,10 @@ var ErrorsABI = [{
1821
2140
  inputs: [],
1822
2141
  name: "RoyaltyPolicyLAP__ImplementationAlreadySet",
1823
2142
  type: "error"
1824
- }, {
1825
- inputs: [],
1826
- name: "RoyaltyPolicyLAP__InvalidAncestors",
1827
- type: "error"
1828
- }, {
1829
- inputs: [],
1830
- name: "RoyaltyPolicyLAP__InvalidAncestorsHash",
1831
- type: "error"
1832
- }, {
1833
- inputs: [],
1834
- name: "RoyaltyPolicyLAP__InvalidAncestorsLength",
1835
- type: "error"
1836
- }, {
1837
- inputs: [],
1838
- name: "RoyaltyPolicyLAP__InvalidAncestorsRoyalty",
1839
- type: "error"
1840
2143
  }, {
1841
2144
  inputs: [],
1842
2145
  name: "RoyaltyPolicyLAP__InvalidParentRoyaltiesLength",
1843
2146
  type: "error"
1844
- }, {
1845
- inputs: [],
1846
- name: "RoyaltyPolicyLAP__InvalidRoyaltyAmountLength",
1847
- type: "error"
1848
2147
  }, {
1849
2148
  inputs: [],
1850
2149
  name: "RoyaltyPolicyLAP__LastPositionNotAbleToMintLicense",
@@ -1859,15 +2158,15 @@ var ErrorsABI = [{
1859
2158
  type: "error"
1860
2159
  }, {
1861
2160
  inputs: [],
1862
- name: "RoyaltyPolicyLAP__TransferFailed",
2161
+ name: "RoyaltyPolicyLAP__UnlinkableToParents",
1863
2162
  type: "error"
1864
2163
  }, {
1865
2164
  inputs: [],
1866
- name: "RoyaltyPolicyLAP__UnlinkableToParents",
2165
+ name: "RoyaltyPolicyLAP__ZeroAncestorsVaultImpl",
1867
2166
  type: "error"
1868
2167
  }, {
1869
2168
  inputs: [],
1870
- name: "RoyaltyPolicyLAP__ZeroAncestorsVaultImpl",
2169
+ name: "RoyaltyPolicyLAP__ZeroIpRoyaltyVaultBeacon",
1871
2170
  type: "error"
1872
2171
  }, {
1873
2172
  inputs: [],
@@ -1911,538 +2210,229 @@ var sepolia = {
1911
2210
  RoyaltyPolicyLAP: "0x16eF58e959522727588921A92e9084d36E5d3855",
1912
2211
  TokenWithdrawalModule: "0x66738a5722e9Cd91B694bA39146CFEcE95457F04"
1913
2212
  };
2213
+ 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"
2233
+ };
2234
+ var contractAddress = {
2235
+ sepolia: sepolia,
2236
+ 11155111: sepolia,
2237
+ storyTestnet: storyTestnet,
2238
+ 1513: storyTestnet
2239
+ };
1914
2240
 
1915
2241
  var IPAccountABI = [].concat(_toConsumableArray(IPAccountImplABI), _toConsumableArray(ErrorsABI));
1916
- var IPAssetRegistryConfig = {
1917
- abi: IPAssetRegistryABI,
1918
- address: getAddress(sepolia.IPAssetRegistry)
2242
+ var getIPAssetRegistryConfig = function getIPAssetRegistryConfig(chain) {
2243
+ return {
2244
+ abi: IPAssetRegistryABI,
2245
+ address: getAddress(contractAddress[chain].IPAssetRegistry)
2246
+ };
1919
2247
  };
1920
- var AccessControllerConfig = {
1921
- abi: [].concat(_toConsumableArray(AccessControllerABI), _toConsumableArray(ErrorsABI)),
1922
- address: getAddress(sepolia.AccessController)
2248
+ var getAccessControllerConfig = function getAccessControllerConfig(chain) {
2249
+ return {
2250
+ abi: [].concat(_toConsumableArray(AccessControllerABI), _toConsumableArray(ErrorsABI)),
2251
+ address: getAddress(contractAddress[chain].AccessController)
2252
+ };
2253
+ };
2254
+ var getDisputeModuleConfig = function getDisputeModuleConfig(chain) {
2255
+ return {
2256
+ abi: [].concat(_toConsumableArray(DisputeModuleABI), _toConsumableArray(ErrorsABI)),
2257
+ address: getAddress(contractAddress[chain].DisputeModule)
2258
+ };
1923
2259
  };
1924
- var DisputeModuleConfig = {
1925
- abi: [].concat(_toConsumableArray(DisputeModuleABI), _toConsumableArray(ErrorsABI)),
1926
- address: getAddress(sepolia.DisputeModule)
2260
+ var getLicenseRegistryConfig = function getLicenseRegistryConfig(chain) {
2261
+ return {
2262
+ abi: IERC1155ABI,
2263
+ address: getAddress(contractAddress[chain].LicenseRegistry)
2264
+ };
1927
2265
  };
1928
- var LicenseRegistryConfig = {
1929
- abi: IERC1155ABI,
1930
- address: getAddress(sepolia.LicenseRegistry)
2266
+ var getLicensingModuleConfig = function getLicensingModuleConfig(chain) {
2267
+ return {
2268
+ abi: [].concat(_toConsumableArray(LicensingModuleABI), _toConsumableArray(ErrorsABI)),
2269
+ address: getAddress(contractAddress[chain].LicensingModule)
2270
+ };
1931
2271
  };
1932
- var LicensingModuleConfig = {
1933
- abi: [].concat(_toConsumableArray(LicensingModuleABI), _toConsumableArray(ErrorsABI)),
1934
- address: getAddress(sepolia.LicensingModule)
2272
+ var getPILPolicyFrameworkManagerConfig = function getPILPolicyFrameworkManagerConfig(chain) {
2273
+ return {
2274
+ abi: [].concat(_toConsumableArray(PILPolicyFrameworkManagerABI), _toConsumableArray(ErrorsABI)),
2275
+ address: getAddress(contractAddress[chain].PILPolicyFrameworkManager)
2276
+ };
1935
2277
  };
1936
- var RegistrationModuleConfig = {
1937
- abi: [].concat(_toConsumableArray(RegistrationModuleABI), _toConsumableArray(ErrorsABI)),
1938
- address: getAddress(sepolia.RegistrationModule)
2278
+ var getRoyaltyPolicyLAPConfig = function getRoyaltyPolicyLAPConfig(chain) {
2279
+ return {
2280
+ abi: [].concat(_toConsumableArray(IRoyaltyPolicyLAPABI), _toConsumableArray(ErrorsABI)),
2281
+ address: getAddress(contractAddress[chain].RoyaltyPolicyLAP)
2282
+ };
1939
2283
  };
1940
- var PILPolicyFrameworkManagerConfig = {
1941
- abi: [].concat(_toConsumableArray(PILPolicyFrameworkManagerABI), _toConsumableArray(ErrorsABI)),
1942
- address: getAddress(sepolia.PILPolicyFrameworkManager)
2284
+ var getRoyaltyVaultImplConfig = function getRoyaltyVaultImplConfig(chain) {
2285
+ return {
2286
+ abi: [].concat(_toConsumableArray(IpRoyaltyVaultABI), _toConsumableArray(ErrorsABI)),
2287
+ address: getAddress(contractAddress[chain].IpRoyaltyVaultImpl)
2288
+ };
1943
2289
  };
1944
- var RoyaltyPolicyLAPConfig = {
1945
- address: getAddress(sepolia.RoyaltyPolicyLAP)
2290
+ var getRoyaltyModuleConfig = function getRoyaltyModuleConfig(chain) {
2291
+ return {
2292
+ abi: [].concat(_toConsumableArray(IRoyaltyModuleABI), _toConsumableArray(ErrorsABI)),
2293
+ address: getAddress(contractAddress[chain].RoyaltyModule)
2294
+ };
1946
2295
  };
1947
2296
 
1948
- function _createForOfIteratorHelper(o, allowArrayLike) {
1949
- var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
1950
- if (!it) {
1951
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
1952
- if (it) o = it;
1953
- var i = 0;
1954
- var F = function () {};
1955
- return {
1956
- s: F,
1957
- n: function () {
1958
- if (i >= o.length) return {
1959
- done: true
1960
- };
1961
- return {
1962
- done: false,
1963
- value: o[i++]
1964
- };
1965
- },
1966
- e: function (e) {
1967
- throw e;
1968
- },
1969
- f: F
1970
- };
1971
- }
1972
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1973
- }
1974
- var normalCompletion = true,
1975
- didErr = false,
1976
- err;
1977
- return {
1978
- s: function () {
1979
- it = it.call(o);
1980
- },
1981
- n: function () {
1982
- var step = it.next();
1983
- normalCompletion = step.done;
1984
- return step;
1985
- },
1986
- e: function (e) {
1987
- didErr = true;
1988
- err = e;
1989
- },
1990
- f: function () {
1991
- try {
1992
- if (!normalCompletion && it.return != null) it.return();
1993
- } finally {
1994
- if (didErr) throw err;
1995
- }
1996
- }
1997
- };
1998
- }
1999
-
2000
- function parseToBigInt(num) {
2001
- return BigInt(num);
2002
- }
2003
- function waitTxAndFilterLog(_x, _x2, _x3) {
2004
- return _waitTxAndFilterLog.apply(this, arguments);
2005
- }
2006
- function _waitTxAndFilterLog() {
2007
- _waitTxAndFilterLog = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(client, txHash, params) {
2008
- var txReceipt, targetLogs, _iterator, _step, log, currentLog;
2009
- return _regeneratorRuntime().wrap(function _callee$(_context) {
2010
- while (1) switch (_context.prev = _context.next) {
2011
- case 0:
2012
- _context.next = 2;
2013
- return client.waitForTransactionReceipt({
2014
- hash: txHash,
2015
- confirmations: params.confirmations,
2016
- pollingInterval: params.pollingInterval,
2017
- timeout: params.timeout
2018
- });
2019
- case 2:
2020
- txReceipt = _context.sent;
2021
- targetLogs = [];
2022
- _iterator = _createForOfIteratorHelper(txReceipt.logs);
2023
- _context.prev = 5;
2024
- _iterator.s();
2025
- case 7:
2026
- if ((_step = _iterator.n()).done) {
2027
- _context.next = 21;
2028
- break;
2029
- }
2030
- log = _step.value;
2031
- _context.prev = 9;
2032
- if (!(params.from && log.address !== params.from.toLowerCase())) {
2033
- _context.next = 12;
2034
- break;
2035
- }
2036
- return _context.abrupt("continue", 19);
2037
- case 12:
2038
- currentLog = decodeEventLog({
2039
- abi: params.abi,
2040
- eventName: params.eventName,
2041
- data: log.data,
2042
- topics: log.topics
2043
- });
2044
- targetLogs.push(currentLog);
2045
- _context.next = 19;
2046
- break;
2047
- case 16:
2048
- _context.prev = 16;
2049
- _context.t0 = _context["catch"](9);
2050
- return _context.abrupt("continue", 19);
2051
- case 19:
2052
- _context.next = 7;
2053
- break;
2054
- case 21:
2055
- _context.next = 26;
2056
- break;
2057
- case 23:
2058
- _context.prev = 23;
2059
- _context.t1 = _context["catch"](5);
2060
- _iterator.e(_context.t1);
2061
- case 26:
2062
- _context.prev = 26;
2063
- _iterator.f();
2064
- return _context.finish(26);
2065
- case 29:
2066
- if (!(targetLogs.length === 0)) {
2067
- _context.next = 31;
2068
- break;
2069
- }
2070
- throw new Error("not found event ".concat(params.eventName, " in target transaction"));
2071
- case 31:
2072
- return _context.abrupt("return", targetLogs);
2073
- case 32:
2074
- case "end":
2075
- return _context.stop();
2076
- }
2077
- }, _callee, null, [[5, 23, 26, 29], [9, 16]]);
2078
- }));
2079
- return _waitTxAndFilterLog.apply(this, arguments);
2080
- }
2081
- function waitTx(_x4, _x5, _x6) {
2082
- return _waitTx.apply(this, arguments);
2083
- }
2084
- function _waitTx() {
2085
- _waitTx = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(client, txHash, params) {
2086
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
2087
- while (1) switch (_context2.prev = _context2.next) {
2088
- case 0:
2089
- _context2.next = 2;
2090
- return client.waitForTransactionReceipt(_objectSpread2({
2091
- hash: txHash
2092
- }, params));
2093
- case 2:
2094
- case "end":
2095
- return _context2.stop();
2096
- }
2097
- }, _callee2);
2098
- }));
2099
- return _waitTx.apply(this, arguments);
2100
- }
2101
- function typedDataToBytes(typedData) {
2102
- return encodeAbiParameters(parseAbiParameters(typedData["interface"]), typedData.data);
2103
- }
2104
- function chainStringToViemChain(chainId) {
2105
- switch (chainId) {
2106
- case "1":
2107
- case "mainnet":
2108
- return mainnet;
2109
- case "11155111":
2110
- case "sepolia":
2111
- return sepolia$1;
2112
- case "80001":
2113
- case "mumbai":
2114
- case "polygonMumbai":
2115
- return polygonMumbai;
2116
- default:
2117
- throw new Error("chainId ".concat(chainId, " not supported"));
2118
- }
2119
- }
2120
-
2121
- function computeRoyaltyContext(_x, _x2) {
2122
- return _computeRoyaltyContext.apply(this, arguments);
2123
- }
2124
- function _computeRoyaltyContext() {
2125
- _computeRoyaltyContext = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(licenseIds, storyClient) {
2126
- var royaltyContext, i, licenseData, royaltyPolicy, policy, targetRoyaltyAmount;
2127
- return _regeneratorRuntime().wrap(function _callee$(_context) {
2128
- while (1) switch (_context.prev = _context.next) {
2129
- case 0:
2130
- royaltyContext = {
2131
- targetAncestors: [],
2132
- targetRoyaltyAmount: [],
2133
- parentAncestors1: [],
2134
- parentAncestors2: [],
2135
- parentAncestorsRoyalties1: [],
2136
- parentAncestorsRoyalties2: []
2137
- };
2138
- i = 0;
2139
- case 2:
2140
- if (!(i < licenseIds.length)) {
2141
- _context.next = 16;
2142
- break;
2143
- }
2144
- _context.next = 5;
2145
- return storyClient.getLicense(licenseIds[i]);
2146
- case 5:
2147
- licenseData = _context.sent;
2148
- _context.next = 8;
2149
- return storyClient.getRoyaltyPolicy(licenseData.licensorIpId);
2150
- case 8:
2151
- royaltyPolicy = _context.sent;
2152
- _context.next = 11;
2153
- return storyClient.getPolicy(licenseData.policyId);
2154
- case 11:
2155
- policy = _context.sent;
2156
- if (royaltyPolicy) {
2157
- targetRoyaltyAmount = royaltyPolicy.targetRoyaltyAmount.map(function (e) {
2158
- return parseInt(e);
2159
- });
2160
- if (i === 0) {
2161
- royaltyContext.parentAncestors1 = royaltyPolicy.targetAncestors;
2162
- royaltyContext.parentAncestorsRoyalties1 = targetRoyaltyAmount;
2163
- } else {
2164
- royaltyContext.parentAncestors2 = royaltyPolicy.targetAncestors;
2165
- royaltyContext.parentAncestorsRoyalties2 = targetRoyaltyAmount;
2166
- }
2167
- updateRoyaltyContext(royaltyContext, [licenseData.licensorIpId], [parseInt(policy.pil.commercialRevShare)]);
2168
- updateRoyaltyContext(royaltyContext, royaltyPolicy.targetAncestors, targetRoyaltyAmount);
2169
- }
2170
- case 13:
2171
- i++;
2172
- _context.next = 2;
2173
- break;
2174
- case 16:
2175
- return _context.abrupt("return", royaltyContext);
2176
- case 17:
2177
- case "end":
2178
- return _context.stop();
2179
- }
2180
- }, _callee);
2181
- }));
2182
- return _computeRoyaltyContext.apply(this, arguments);
2183
- }
2184
- function encodeRoyaltyContext(royaltyContext) {
2185
- return typedDataToBytes({
2186
- "interface": "(address[], uint32[], address[], address[], uint32[], uint32[])",
2187
- data: [[royaltyContext.targetAncestors, royaltyContext.targetRoyaltyAmount, royaltyContext.parentAncestors1, royaltyContext.parentAncestors2, royaltyContext.parentAncestorsRoyalties1, royaltyContext.parentAncestorsRoyalties2]]
2188
- });
2189
- }
2190
- function updateRoyaltyContext(royaltyContext, targetAncestors, targetRoyaltyAccounts) {
2191
- for (var i = 0; i < targetAncestors.length; i++) {
2192
- var index = royaltyContext.targetAncestors.indexOf(targetAncestors[i]);
2193
- if (index === -1) {
2194
- royaltyContext.targetAncestors.push(targetAncestors[i]);
2195
- royaltyContext.targetRoyaltyAmount.push(targetRoyaltyAccounts[i]);
2196
- } else {
2197
- royaltyContext.targetRoyaltyAmount[index] += targetRoyaltyAccounts[i];
2198
- }
2297
+ function handleError(error, msg) {
2298
+ if (error instanceof Error) {
2299
+ throw new Error("".concat(msg, ": ").concat(error.message));
2199
2300
  }
2301
+ throw new Error("".concat(msg, ": Unknown error type"));
2200
2302
  }
2201
2303
 
2202
2304
  var IPAssetClient = /*#__PURE__*/function () {
2203
- function IPAssetClient(rpcClient, wallet, storyClient) {
2305
+ function IPAssetClient(rpcClient, wallet, chainId) {
2204
2306
  _classCallCheck(this, IPAssetClient);
2205
- _defineProperty(this, "ipAssetRegistryConfig", IPAssetRegistryConfig);
2206
- _defineProperty(this, "registrationModuleConfig", RegistrationModuleConfig);
2207
2307
  this.wallet = wallet;
2208
2308
  this.rpcClient = rpcClient;
2209
- this.storyClient = storyClient;
2309
+ this.chainId = chainId;
2310
+ this.ipAssetRegistryConfig = getIPAssetRegistryConfig(chainId);
2210
2311
  }
2211
-
2212
- /**
2213
- * Registers a root-level IP into the protocol. Root-level IPs can be thought of as organizational hubs
2214
- * for encapsulating policies that actual IPs can use to register through. As such, a root-level IP is not an
2215
- * actual IP, but a container for IP policy management for their child IP assets.
2216
- * @param request The request object that contains all data needed to register a root IP.
2217
- * @param request.policyId The policy that identifies the licensing terms of the IP.
2218
- * @param request.tokenContract The address of the NFT bound to the root-level IP.
2219
- * @param request.tokenId The token id of the NFT bound to the root-level IP.
2220
- * @param request.ipName [Optional] The name assigned to the new IP.
2221
- * @param request.contentHash [Optional] The content hash of the IP being registered.
2222
- * @param request.uri [Optional] An external URI to link to the IP.
2223
- * @param request.txOptions [Optional] The transaction options.
2224
- * @returns A Promise that resolves to an object containing the transaction hash and optional IP ID if waitForTxn is set to true.
2225
- * @emits RootIPRegistered (msg.sender, ipId, policyId)
2226
- */
2227
2312
  return _createClass(IPAssetClient, [{
2228
- key: "registerRootIp",
2229
- value: (function () {
2230
- var _registerRootIp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
2231
- var _request$txOptions, ipId, _yield$this$rpcClient, call, txHash, targetLogs;
2313
+ key: "isNFTRegistered",
2314
+ value: function () {
2315
+ var _isNFTRegistered = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(tokenAddress, tokenId) {
2316
+ var ipId, isRegistered;
2232
2317
  return _regeneratorRuntime().wrap(function _callee$(_context) {
2233
2318
  while (1) switch (_context.prev = _context.next) {
2234
2319
  case 0:
2235
- _context.prev = 0;
2236
- _context.next = 3;
2237
- return this.isNFTRegistered(SepoliaChainId, request.tokenContractAddress, request.tokenId);
2238
- case 3:
2239
- ipId = _context.sent;
2240
- if (!(ipId !== "0x")) {
2241
- _context.next = 6;
2242
- break;
2243
- }
2244
- return _context.abrupt("return", {
2245
- ipId: ipId
2246
- });
2247
- case 6:
2248
- _context.next = 8;
2249
- return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.registrationModuleConfig), {}, {
2250
- functionName: "registerRootIp",
2251
- args: [parseToBigInt(request.policyId || "0"), getAddress(request.tokenContractAddress),
2252
- // 0x Address
2253
- parseToBigInt(request.tokenId), request.ipName || "", request.contentHash || HashZero, request.uri || ""],
2254
- account: this.wallet.account
2320
+ _context.next = 2;
2321
+ return this.rpcClient.readContract(_objectSpread2(_objectSpread2({}, this.ipAssetRegistryConfig), {}, {
2322
+ functionName: "ipId",
2323
+ args: [parseToBigInt(chain[this.chainId]), tokenAddress, tokenId]
2255
2324
  }));
2256
- case 8:
2257
- _yield$this$rpcClient = _context.sent;
2258
- call = _yield$this$rpcClient.request;
2259
- _context.next = 12;
2260
- return this.wallet.writeContract(call);
2261
- case 12:
2262
- txHash = _context.sent;
2263
- if (!((_request$txOptions = request.txOptions) !== null && _request$txOptions !== void 0 && _request$txOptions.waitForTransaction)) {
2264
- _context.next = 20;
2265
- break;
2266
- }
2267
- _context.next = 16;
2268
- return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, this.ipAssetRegistryConfig), {}, {
2269
- eventName: "IPRegistered"
2325
+ case 2:
2326
+ ipId = _context.sent;
2327
+ _context.next = 5;
2328
+ return this.rpcClient.readContract(_objectSpread2(_objectSpread2({}, this.ipAssetRegistryConfig), {}, {
2329
+ functionName: "isRegistered",
2330
+ args: [ipId]
2270
2331
  }));
2271
- case 16:
2272
- targetLogs = _context.sent;
2273
- return _context.abrupt("return", {
2274
- txHash: txHash,
2275
- ipId: targetLogs[0].args.ipId
2276
- });
2277
- case 20:
2278
- return _context.abrupt("return", {
2279
- txHash: txHash
2280
- });
2281
- case 21:
2282
- _context.next = 26;
2283
- break;
2284
- case 23:
2285
- _context.prev = 23;
2286
- _context.t0 = _context["catch"](0);
2287
- handleError(_context.t0, "Failed to register root IP");
2288
- case 26:
2332
+ case 5:
2333
+ isRegistered = _context.sent;
2334
+ return _context.abrupt("return", isRegistered ? ipId : "0x");
2335
+ case 7:
2289
2336
  case "end":
2290
2337
  return _context.stop();
2291
2338
  }
2292
- }, _callee, this, [[0, 23]]);
2339
+ }, _callee, this);
2293
2340
  }));
2294
- function registerRootIp(_x) {
2295
- return _registerRootIp.apply(this, arguments);
2341
+ function isNFTRegistered(_x, _x2) {
2342
+ return _isNFTRegistered.apply(this, arguments);
2296
2343
  }
2297
- return registerRootIp;
2344
+ return isNFTRegistered;
2298
2345
  }()
2299
2346
  /**
2300
- * Registers derivative IPs into the protocol. Derivative IPs are IP assets that inherit policies from
2301
- * parent IPs by burning acquired license NFTs.
2302
- * @param request The request object that contains all data needed to register a root IP.
2303
- * @param request.licenseIds The policy that identifies the licensing terms of the IP.
2304
- * @param request.tokenContract The address of the NFT bound to the derivative IP.
2305
- * @param request.tokenId The token id of the NFT bound to the derivative IP.
2306
- * @param request.ipName [Optional] The name assigned to the new IP.
2307
- * @param request.contentHash [Optional] The content hash of the IP being registered.
2308
- * @param request.uri [Optional] An external URI to link to the IP.
2309
- * @param request.txOptions [Optional] The transaction options.
2347
+ * Registers an NFT as IP, creating a corresponding IP record.
2348
+ * @param request The request object that contains all data needed to register IP.
2349
+ * @param request.tokenContract The address of the NFT.
2350
+ * @param request.tokenId The token identifier of the NFT.
2351
+ * @param request.txOptions [Optional] The transaction options.
2310
2352
  * @returns A Promise that resolves to an object containing the transaction hash and optional IP ID if waitForTxn is set to true.
2311
- * @emits RootIPRegistered (msg.sender, ipId, policyId)
2353
+ * @emits IPRegistered (ipId, chainId, tokenContract, tokenId, resolverAddr, metadataProviderAddress, metadata)
2312
2354
  */
2313
- )
2314
2355
  }, {
2315
- key: "registerDerivativeIp",
2356
+ key: "register",
2316
2357
  value: (function () {
2317
- var _registerDerivativeIp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
2318
- var _request$txOptions2, ipId, licenseIds, royaltyContext, _yield$this$rpcClient2, call, txHash, targetLogs;
2358
+ var _register = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
2359
+ var tokenId, _request$txOptions, ipId, _yield$this$rpcClient, call, txHash, targetLogs;
2319
2360
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
2320
2361
  while (1) switch (_context2.prev = _context2.next) {
2321
2362
  case 0:
2322
- _context2.prev = 0;
2323
- _context2.next = 3;
2324
- return this.isNFTRegistered(SepoliaChainId, request.tokenContractAddress, request.tokenId);
2325
- case 3:
2363
+ tokenId = parseToBigInt(request.tokenId);
2364
+ _context2.prev = 1;
2365
+ _context2.next = 4;
2366
+ return this.isNFTRegistered(request.tokenContract, tokenId);
2367
+ case 4:
2326
2368
  ipId = _context2.sent;
2327
2369
  if (!(ipId !== "0x")) {
2328
- _context2.next = 6;
2370
+ _context2.next = 7;
2329
2371
  break;
2330
2372
  }
2331
2373
  return _context2.abrupt("return", {
2332
2374
  ipId: ipId
2333
2375
  });
2334
- case 6:
2335
- licenseIds = [];
2336
- request.licenseIds.forEach(function (licenseId) {
2337
- licenseIds.push(parseToBigInt(licenseId));
2338
- });
2339
- _context2.next = 10;
2340
- return computeRoyaltyContext(request.licenseIds, this.storyClient);
2341
- case 10:
2342
- royaltyContext = _context2.sent;
2343
- _context2.next = 13;
2344
- return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.registrationModuleConfig), {}, {
2345
- functionName: "registerDerivativeIp",
2346
- args: [licenseIds, getAddress(request.tokenContractAddress),
2347
- // 0x Address
2348
- parseToBigInt(request.tokenId), request.ipName || "", request.contentHash || HashZero, request.uri || "", encodeRoyaltyContext(royaltyContext)],
2376
+ case 7:
2377
+ _context2.next = 9;
2378
+ return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.ipAssetRegistryConfig), {}, {
2379
+ functionName: "register",
2380
+ args: [getAddress(request.tokenContract), tokenId],
2349
2381
  account: this.wallet.account
2350
2382
  }));
2351
- case 13:
2352
- _yield$this$rpcClient2 = _context2.sent;
2353
- call = _yield$this$rpcClient2.request;
2354
- _context2.next = 17;
2383
+ case 9:
2384
+ _yield$this$rpcClient = _context2.sent;
2385
+ call = _yield$this$rpcClient.request;
2386
+ _context2.next = 13;
2355
2387
  return this.wallet.writeContract(call);
2356
- case 17:
2388
+ case 13:
2357
2389
  txHash = _context2.sent;
2358
- if (!((_request$txOptions2 = request.txOptions) !== null && _request$txOptions2 !== void 0 && _request$txOptions2.waitForTransaction)) {
2359
- _context2.next = 25;
2390
+ if (!((_request$txOptions = request.txOptions) !== null && _request$txOptions !== void 0 && _request$txOptions.waitForTransaction)) {
2391
+ _context2.next = 21;
2360
2392
  break;
2361
2393
  }
2362
- _context2.next = 21;
2394
+ _context2.next = 17;
2363
2395
  return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, this.ipAssetRegistryConfig), {}, {
2364
2396
  eventName: "IPRegistered"
2365
2397
  }));
2366
- case 21:
2398
+ case 17:
2367
2399
  targetLogs = _context2.sent;
2368
2400
  return _context2.abrupt("return", {
2369
2401
  txHash: txHash,
2370
2402
  ipId: targetLogs[0].args.ipId
2371
2403
  });
2372
- case 25:
2404
+ case 21:
2373
2405
  return _context2.abrupt("return", {
2374
2406
  txHash: txHash
2375
2407
  });
2376
- case 26:
2377
- _context2.next = 31;
2408
+ case 22:
2409
+ _context2.next = 27;
2378
2410
  break;
2379
- case 28:
2380
- _context2.prev = 28;
2381
- _context2.t0 = _context2["catch"](0);
2382
- handleError(_context2.t0, "Failed to register derivative IP");
2383
- case 31:
2411
+ case 24:
2412
+ _context2.prev = 24;
2413
+ _context2.t0 = _context2["catch"](1);
2414
+ handleError(_context2.t0, "Failed to register IP");
2415
+ case 27:
2384
2416
  case "end":
2385
2417
  return _context2.stop();
2386
2418
  }
2387
- }, _callee2, this, [[0, 28]]);
2388
- }));
2389
- function registerDerivativeIp(_x2) {
2390
- return _registerDerivativeIp.apply(this, arguments);
2391
- }
2392
- return registerDerivativeIp;
2393
- }()
2394
- /**
2395
- * Checks if an NFT is already registered in the protocol.
2396
- * @param chainId The chain ID of the NFT.
2397
- * @param tokenAddress The address of the NFT.
2398
- * @param tokenId The token ID of the NFT.
2399
- * @returns A Promise that resolves to the IP ID if the NFT is already registered, otherwise it resolves to 0x.
2400
- */
2401
- )
2402
- }, {
2403
- key: "isNFTRegistered",
2404
- value: (function () {
2405
- var _isNFTRegistered = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(chainId, tokenAddress, tokenId) {
2406
- var ipId, isRegistered;
2407
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
2408
- while (1) switch (_context3.prev = _context3.next) {
2409
- case 0:
2410
- _context3.next = 2;
2411
- return this.rpcClient.readContract(_objectSpread2(_objectSpread2({}, this.ipAssetRegistryConfig), {}, {
2412
- functionName: "ipId",
2413
- args: [parseToBigInt(chainId), tokenAddress, parseToBigInt(tokenId)]
2414
- }));
2415
- case 2:
2416
- ipId = _context3.sent;
2417
- _context3.next = 5;
2418
- return this.rpcClient.readContract(_objectSpread2(_objectSpread2({}, this.ipAssetRegistryConfig), {}, {
2419
- functionName: "isRegistered",
2420
- args: [ipId]
2421
- }));
2422
- case 5:
2423
- isRegistered = _context3.sent;
2424
- return _context3.abrupt("return", isRegistered ? ipId : "0x");
2425
- case 7:
2426
- case "end":
2427
- return _context3.stop();
2428
- }
2429
- }, _callee3, this);
2419
+ }, _callee2, this, [[1, 24]]);
2430
2420
  }));
2431
- function isNFTRegistered(_x3, _x4, _x5) {
2432
- return _isNFTRegistered.apply(this, arguments);
2421
+ function register(_x3) {
2422
+ return _register.apply(this, arguments);
2433
2423
  }
2434
- return isNFTRegistered;
2424
+ return register;
2435
2425
  }())
2436
2426
  }]);
2437
2427
  }();
2438
2428
 
2439
2429
  var PermissionClient = /*#__PURE__*/function () {
2440
- function PermissionClient(rpcClient, wallet) {
2430
+ function PermissionClient(rpcClient, wallet, chainId) {
2441
2431
  _classCallCheck(this, PermissionClient);
2442
2432
  _defineProperty(this, "ipAccountABI", IPAccountABI);
2443
- _defineProperty(this, "accessControllerConfig", AccessControllerConfig);
2444
2433
  this.rpcClient = rpcClient;
2445
2434
  this.wallet = wallet;
2435
+ this.accessControllerConfig = getAccessControllerConfig(chainId);
2446
2436
  }
2447
2437
 
2448
2438
  /**
@@ -2541,15 +2531,96 @@ var PermissionClient = /*#__PURE__*/function () {
2541
2531
  }]);
2542
2532
  }();
2543
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
+
2544
2615
  var LicenseClient = /*#__PURE__*/function () {
2545
- function LicenseClient(rpcClient, wallet, storyClient) {
2616
+ function LicenseClient(rpcClient, wallet, storyClient, chainId) {
2546
2617
  _classCallCheck(this, LicenseClient);
2547
2618
  _defineProperty(this, "ipAccountABI", IPAccountABI);
2548
- _defineProperty(this, "licenseRegistryConfig", LicenseRegistryConfig);
2549
- _defineProperty(this, "licensingModuleConfig", LicensingModuleConfig);
2550
2619
  this.wallet = wallet;
2551
2620
  this.rpcClient = rpcClient;
2552
2621
  this.storyClient = storyClient;
2622
+ this.licenseRegistryConfig = getLicenseRegistryConfig(chainId);
2623
+ this.licensingModuleConfig = getLicensingModuleConfig(chainId);
2553
2624
  }
2554
2625
 
2555
2626
  /**
@@ -2685,7 +2756,7 @@ var LicenseClient = /*#__PURE__*/function () {
2685
2756
  break;
2686
2757
  }
2687
2758
  _context2.next = 17;
2688
- return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, LicenseRegistryConfig), {}, {
2759
+ return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, this.licenseRegistryConfig), {}, {
2689
2760
  eventName: "TransferBatch"
2690
2761
  }));
2691
2762
  case 17:
@@ -2719,14 +2790,14 @@ var LicenseClient = /*#__PURE__*/function () {
2719
2790
  }();
2720
2791
 
2721
2792
  var PolicyClient = /*#__PURE__*/function () {
2722
- function PolicyClient(rpcClient, wallet) {
2793
+ function PolicyClient(rpcClient, wallet, chainId) {
2723
2794
  _classCallCheck(this, PolicyClient);
2724
2795
  _defineProperty(this, "ipAccountABI", IPAccountABI);
2725
- _defineProperty(this, "licensingModuleConfig", LicensingModuleConfig);
2726
- _defineProperty(this, "pilPolicyFrameworkManagerConfig", PILPolicyFrameworkManagerConfig);
2727
- _defineProperty(this, "royaltyPolicyLAPConfig", RoyaltyPolicyLAPConfig);
2728
2796
  this.wallet = wallet;
2729
2797
  this.rpcClient = rpcClient;
2798
+ this.licensingModuleConfig = getLicensingModuleConfig(chainId);
2799
+ this.pilPolicyFrameworkManagerConfig = getPILPolicyFrameworkManagerConfig(chainId);
2800
+ this.royaltyPolicyLAPConfig = getRoyaltyPolicyLAPConfig(chainId);
2730
2801
  }
2731
2802
 
2732
2803
  /**
@@ -3219,11 +3290,11 @@ var PolicyClient = /*#__PURE__*/function () {
3219
3290
  }();
3220
3291
 
3221
3292
  var DisputeClient = /*#__PURE__*/function () {
3222
- function DisputeClient(rpcClient, wallet) {
3293
+ function DisputeClient(rpcClient, wallet, chainId) {
3223
3294
  _classCallCheck(this, DisputeClient);
3224
- _defineProperty(this, "disputeModuleConfig", DisputeModuleConfig);
3225
3295
  this.rpcClient = rpcClient;
3226
3296
  this.wallet = wallet;
3297
+ this.disputeModuleConfig = getDisputeModuleConfig(chainId);
3227
3298
  }
3228
3299
 
3229
3300
  /**
@@ -3636,6 +3707,166 @@ var StoryAPIClient = /*#__PURE__*/function () {
3636
3707
  }]);
3637
3708
  }();
3638
3709
 
3710
+ var RoyaltyClient = /*#__PURE__*/function () {
3711
+ function RoyaltyClient(rpcClient, wallet, chainId) {
3712
+ _classCallCheck(this, RoyaltyClient);
3713
+ this.rpcClient = rpcClient;
3714
+ this.wallet = wallet;
3715
+ this.royaltyVaultImplConfig = getRoyaltyVaultImplConfig(chainId);
3716
+ this.royaltyPolicyLAPConfig = getRoyaltyPolicyLAPConfig(chainId);
3717
+ this.royaltyModuleConfig = getRoyaltyModuleConfig(chainId);
3718
+ }
3719
+ /**
3720
+ * Allows ancestors to claim the royalty tokens and any accrued revenue tokens
3721
+ * @param request - the licensing parameters for the Programmable IP License v1 (PIL) standard.
3722
+ * @param request.ancestorIpId The ip id of the ancestor to whom the royalty tokens belong to.
3723
+ * @param request.txOptions [Optional] The transaction options.
3724
+ * @returns Tx hash for the transaction.
3725
+ * @emits RoyaltyTokensCollected (ancestorIpId, ancestorsRoyalty)
3726
+ */
3727
+ return _createClass(RoyaltyClient, [{
3728
+ key: "collectRoyaltyTokens",
3729
+ value: (function () {
3730
+ var _collectRoyaltyTokens = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
3731
+ var proxyAddress, _yield$this$rpcClient, call, txHash;
3732
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
3733
+ while (1) switch (_context.prev = _context.next) {
3734
+ case 0:
3735
+ _context.prev = 0;
3736
+ _context.next = 3;
3737
+ return this.getProxyAddress(request.derivativeId);
3738
+ case 3:
3739
+ proxyAddress = _context.sent;
3740
+ if (proxyAddress) {
3741
+ _context.next = 6;
3742
+ break;
3743
+ }
3744
+ throw new Error("Proxy address not found");
3745
+ case 6:
3746
+ _context.next = 8;
3747
+ return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.royaltyVaultImplConfig), {}, {
3748
+ address: proxyAddress,
3749
+ functionName: "collectRoyaltyTokens",
3750
+ args: [request.ancestorIpId],
3751
+ account: this.wallet.account
3752
+ }));
3753
+ case 8:
3754
+ _yield$this$rpcClient = _context.sent;
3755
+ call = _yield$this$rpcClient.request;
3756
+ _context.next = 12;
3757
+ return this.wallet.writeContract(call);
3758
+ case 12:
3759
+ txHash = _context.sent;
3760
+ return _context.abrupt("return", {
3761
+ txHash: txHash
3762
+ });
3763
+ case 16:
3764
+ _context.prev = 16;
3765
+ _context.t0 = _context["catch"](0);
3766
+ handleError(_context.t0, "Failed to collect royalty tokens");
3767
+ case 19:
3768
+ case "end":
3769
+ return _context.stop();
3770
+ }
3771
+ }, _callee, this, [[0, 16]]);
3772
+ }));
3773
+ function collectRoyaltyTokens(_x) {
3774
+ return _collectRoyaltyTokens.apply(this, arguments);
3775
+ }
3776
+ return collectRoyaltyTokens;
3777
+ }())
3778
+ }, {
3779
+ key: "getProxyAddress",
3780
+ value: function () {
3781
+ var _getProxyAddress = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(derivativeID) {
3782
+ var data;
3783
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
3784
+ while (1) switch (_context2.prev = _context2.next) {
3785
+ case 0:
3786
+ _context2.next = 2;
3787
+ return this.rpcClient.readContract(_objectSpread2(_objectSpread2({}, this.royaltyPolicyLAPConfig), {}, {
3788
+ functionName: "getRoyaltyData",
3789
+ args: [derivativeID]
3790
+ }));
3791
+ case 2:
3792
+ data = _context2.sent;
3793
+ if (!(Array.isArray(data) && data[1])) {
3794
+ _context2.next = 5;
3795
+ break;
3796
+ }
3797
+ return _context2.abrupt("return", data[1]);
3798
+ case 5:
3799
+ case "end":
3800
+ return _context2.stop();
3801
+ }
3802
+ }, _callee2, this);
3803
+ }));
3804
+ function getProxyAddress(_x2) {
3805
+ return _getProxyAddress.apply(this, arguments);
3806
+ }
3807
+ return getProxyAddress;
3808
+ }()
3809
+ /**
3810
+ * Allows the function caller to pay royalties to the receiver IP asset on behalf of the payer IP asset.
3811
+ * @param request - The request object that contains all data needed to pay royalty on behalf.
3812
+ * @param request.receiverIpId The ipId that receives the royalties.
3813
+ * @param request.payerIpId The ID of the IP asset that pays the royalties.
3814
+ * @param request.token The token to use to pay the royalties.
3815
+ * @param request.amount The amount to pay.
3816
+ * @param request.txOptions [Optional] The transaction options.
3817
+ * @returns A Promise that resolves to an object containing the transaction hash.
3818
+ * @emits RoyaltyPaid (receiverIpId, payerIpId, msg.sender, token, amount)
3819
+ */
3820
+ }, {
3821
+ key: "payRoyaltyOnBehalf",
3822
+ value: (function () {
3823
+ var _payRoyaltyOnBehalf = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(request) {
3824
+ var _request$txOptions, _yield$this$rpcClient2, call, txHash;
3825
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
3826
+ while (1) switch (_context3.prev = _context3.next) {
3827
+ case 0:
3828
+ _context3.prev = 0;
3829
+ _context3.next = 3;
3830
+ return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, this.royaltyModuleConfig), {}, {
3831
+ functionName: "payRoyaltyOnBehalf",
3832
+ args: [request.receiverIpId, request.payerIpId, request.token, request.amount],
3833
+ account: this.wallet.account
3834
+ }));
3835
+ case 3:
3836
+ _yield$this$rpcClient2 = _context3.sent;
3837
+ call = _yield$this$rpcClient2.request;
3838
+ _context3.next = 7;
3839
+ return this.wallet.writeContract(call);
3840
+ case 7:
3841
+ txHash = _context3.sent;
3842
+ if (!((_request$txOptions = request.txOptions) !== null && _request$txOptions !== void 0 && _request$txOptions.waitForTransaction)) {
3843
+ _context3.next = 11;
3844
+ break;
3845
+ }
3846
+ _context3.next = 11;
3847
+ return waitTx(this.rpcClient, txHash);
3848
+ case 11:
3849
+ return _context3.abrupt("return", {
3850
+ txHash: txHash
3851
+ });
3852
+ case 14:
3853
+ _context3.prev = 14;
3854
+ _context3.t0 = _context3["catch"](0);
3855
+ handleError(_context3.t0, "Failed to pay royalty on behalf");
3856
+ case 17:
3857
+ case "end":
3858
+ return _context3.stop();
3859
+ }
3860
+ }, _callee3, this, [[0, 14]]);
3861
+ }));
3862
+ function payRoyaltyOnBehalf(_x3) {
3863
+ return _payRoyaltyOnBehalf.apply(this, arguments);
3864
+ }
3865
+ return payRoyaltyOnBehalf;
3866
+ }())
3867
+ }]);
3868
+ }();
3869
+
3639
3870
  if (typeof process !== "undefined") {
3640
3871
  dotenv.config();
3641
3872
  }
@@ -3654,12 +3885,15 @@ var StoryClient = /*#__PURE__*/function () {
3654
3885
  _defineProperty(this, "_policy", null);
3655
3886
  _defineProperty(this, "_dispute", null);
3656
3887
  _defineProperty(this, "_ipAccount", null);
3657
- this.config = config;
3888
+ _defineProperty(this, "_royalty", null);
3889
+ this.config = _objectSpread2(_objectSpread2({}, config), {}, {
3890
+ chainId: config.chainId || "sepolia"
3891
+ });
3658
3892
  if (!this.config.transport) {
3659
3893
  throw new Error("transport is null, please pass in a valid RPC Provider URL as the transport.");
3660
3894
  }
3661
3895
  var clientConfig = {
3662
- chain: chainStringToViemChain(this.config.chainId || "sepolia"),
3896
+ chain: chainStringToViemChain(this.config.chainId),
3663
3897
  transport: this.config.transport
3664
3898
  };
3665
3899
  this.rpcClient = createPublicClient(clientConfig);
@@ -3689,7 +3923,7 @@ var StoryClient = /*#__PURE__*/function () {
3689
3923
  */
3690
3924
  function get() {
3691
3925
  if (this._ipAsset === null) {
3692
- this._ipAsset = new IPAssetClient(this.rpcClient, this.wallet, this.storyClient);
3926
+ this._ipAsset = new IPAssetClient(this.rpcClient, this.wallet, this.config.chainId);
3693
3927
  }
3694
3928
  return this._ipAsset;
3695
3929
  }
@@ -3704,7 +3938,7 @@ var StoryClient = /*#__PURE__*/function () {
3704
3938
  key: "permission",
3705
3939
  get: function get() {
3706
3940
  if (this._permission === null) {
3707
- this._permission = new PermissionClient(this.rpcClient, this.wallet);
3941
+ this._permission = new PermissionClient(this.rpcClient, this.wallet, this.config.chainId);
3708
3942
  }
3709
3943
  return this._permission;
3710
3944
  }
@@ -3719,7 +3953,7 @@ var StoryClient = /*#__PURE__*/function () {
3719
3953
  key: "license",
3720
3954
  get: function get() {
3721
3955
  if (this._license === null) {
3722
- this._license = new LicenseClient(this.rpcClient, this.wallet, this.storyClient);
3956
+ this._license = new LicenseClient(this.rpcClient, this.wallet, this.storyClient, this.config.chainId);
3723
3957
  }
3724
3958
  return this._license;
3725
3959
  }
@@ -3734,7 +3968,7 @@ var StoryClient = /*#__PURE__*/function () {
3734
3968
  key: "policy",
3735
3969
  get: function get() {
3736
3970
  if (this._policy === null) {
3737
- this._policy = new PolicyClient(this.rpcClient, this.wallet);
3971
+ this._policy = new PolicyClient(this.rpcClient, this.wallet, this.config.chainId);
3738
3972
  }
3739
3973
  return this._policy;
3740
3974
  }
@@ -3749,7 +3983,7 @@ var StoryClient = /*#__PURE__*/function () {
3749
3983
  key: "dispute",
3750
3984
  get: function get() {
3751
3985
  if (this._dispute === null) {
3752
- this._dispute = new DisputeClient(this.rpcClient, this.wallet);
3986
+ this._dispute = new DisputeClient(this.rpcClient, this.wallet, this.config.chainId);
3753
3987
  }
3754
3988
  return this._dispute;
3755
3989
  }
@@ -3768,6 +4002,20 @@ var StoryClient = /*#__PURE__*/function () {
3768
4002
  }
3769
4003
  return this._ipAccount;
3770
4004
  }
4005
+ /**
4006
+ * Getter for the royalty client. The client is lazily created when
4007
+ * this method is called.
4008
+ *
4009
+ * @returns the RoyaltyClient instance
4010
+ */
4011
+ }, {
4012
+ key: "royalty",
4013
+ get: function get() {
4014
+ if (this._royalty === null) {
4015
+ this._royalty = new RoyaltyClient(this.rpcClient, this.wallet, this.config.chainId);
4016
+ }
4017
+ return this._royalty;
4018
+ }
3771
4019
  }], [{
3772
4020
  key: "newClient",
3773
4021
  value: function newClient(config) {
@@ -3776,4 +4024,7 @@ var StoryClient = /*#__PURE__*/function () {
3776
4024
  }]);
3777
4025
  }();
3778
4026
 
4027
+ var AddressZero = "0x0000000000000000000000000000000000000000";
4028
+ var HashZero = "0x0000000000000000000000000000000000000000000000000000000000000000";
4029
+
3779
4030
  export { AddressZero, DisputeClient, HashZero, IPAssetClient, LicenseClient, PermissionClient, PolicyClient, StoryClient };