@story-protocol/core-sdk 0.1.0-rc.5 → 0.1.0-rc.7
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +30 -21
- package/dist/declarations/src/abi/generated/CollectModule.d.ts +12 -2
- package/dist/declarations/src/abi/generated/CollectModule.d.ts.map +1 -1
- package/dist/declarations/src/abi/generated/FranchiseRegistry.d.ts +6 -1
- package/dist/declarations/src/abi/generated/FranchiseRegistry.d.ts.map +1 -1
- package/dist/declarations/src/abi/generated/IpAssetRegistry.d.ts.map +1 -1
- package/dist/declarations/src/abi/generated/common.d.ts.map +1 -1
- package/dist/declarations/src/abi/generated/factories/CollectModule__factory.d.ts.map +1 -1
- package/dist/declarations/src/abi/generated/factories/FranchiseRegistry__factory.d.ts.map +1 -1
- package/dist/declarations/src/abi/generated/factories/IpAssetRegistry__factory.d.ts.map +1 -1
- package/dist/declarations/src/abi/generated/factories/index.d.ts +1 -1
- package/dist/declarations/src/abi/generated/factories/index.d.ts.map +1 -1
- package/dist/declarations/src/client.d.ts +40 -13
- package/dist/declarations/src/client.d.ts.map +1 -1
- package/dist/declarations/src/index.d.ts +1 -1
- package/dist/declarations/src/index.d.ts.map +1 -1
- package/dist/declarations/src/resources/collect.d.ts +3 -10
- package/dist/declarations/src/resources/collect.d.ts.map +1 -1
- package/dist/declarations/src/resources/collectReadOnly.d.ts +15 -0
- package/dist/declarations/src/resources/collectReadOnly.d.ts.map +1 -0
- package/dist/declarations/src/resources/franchise.d.ts +3 -18
- package/dist/declarations/src/resources/franchise.d.ts.map +1 -1
- package/dist/declarations/src/resources/franchiseReadOnly.d.ts +27 -0
- package/dist/declarations/src/resources/franchiseReadOnly.d.ts.map +1 -0
- package/dist/declarations/src/resources/ipAsset.d.ts +3 -17
- package/dist/declarations/src/resources/ipAsset.d.ts.map +1 -1
- package/dist/declarations/src/resources/ipAssetReadOnly.d.ts +25 -0
- package/dist/declarations/src/resources/ipAssetReadOnly.d.ts.map +1 -0
- package/dist/declarations/src/resources/license.d.ts +3 -17
- package/dist/declarations/src/resources/license.d.ts.map +1 -1
- package/dist/declarations/src/resources/licenseReadOnly.d.ts +27 -0
- package/dist/declarations/src/resources/licenseReadOnly.d.ts.map +1 -0
- package/dist/declarations/src/resources/relationship.d.ts +2 -3
- package/dist/declarations/src/resources/relationship.d.ts.map +1 -1
- package/dist/declarations/src/resources/relationshipReadOnly.d.ts +16 -0
- package/dist/declarations/src/resources/relationshipReadOnly.d.ts.map +1 -0
- package/dist/declarations/src/resources/transaction.d.ts +2 -17
- package/dist/declarations/src/resources/transaction.d.ts.map +1 -1
- package/dist/declarations/src/resources/transactionReadOnly.d.ts +25 -0
- package/dist/declarations/src/resources/transactionReadOnly.d.ts.map +1 -0
- package/dist/declarations/src/types/client.d.ts +29 -0
- package/dist/declarations/src/types/client.d.ts.map +1 -0
- package/dist/declarations/src/types/config.d.ts +8 -2
- package/dist/declarations/src/types/config.d.ts.map +1 -1
- package/dist/story-protocol-core-sdk.cjs.dev.js +1020 -769
- package/dist/story-protocol-core-sdk.cjs.prod.js +1020 -769
- package/dist/story-protocol-core-sdk.esm.js +1021 -770
- package/package.json +1 -1
@@ -3,8 +3,8 @@
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
5
|
var axios = require('axios');
|
6
|
-
var dotenv = require('dotenv');
|
7
6
|
var ethers = require('ethers');
|
7
|
+
var dotenv = require('dotenv');
|
8
8
|
|
9
9
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
10
10
|
|
@@ -426,6 +426,81 @@ function _asyncToGenerator(fn) {
|
|
426
426
|
};
|
427
427
|
}
|
428
428
|
|
429
|
+
function _setPrototypeOf(o, p) {
|
430
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
431
|
+
o.__proto__ = p;
|
432
|
+
return o;
|
433
|
+
};
|
434
|
+
return _setPrototypeOf(o, p);
|
435
|
+
}
|
436
|
+
|
437
|
+
function _inherits(subClass, superClass) {
|
438
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
439
|
+
throw new TypeError("Super expression must either be null or a function");
|
440
|
+
}
|
441
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
442
|
+
constructor: {
|
443
|
+
value: subClass,
|
444
|
+
writable: true,
|
445
|
+
configurable: true
|
446
|
+
}
|
447
|
+
});
|
448
|
+
Object.defineProperty(subClass, "prototype", {
|
449
|
+
writable: false
|
450
|
+
});
|
451
|
+
if (superClass) _setPrototypeOf(subClass, superClass);
|
452
|
+
}
|
453
|
+
|
454
|
+
function _getPrototypeOf(o) {
|
455
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
456
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
457
|
+
};
|
458
|
+
return _getPrototypeOf(o);
|
459
|
+
}
|
460
|
+
|
461
|
+
function _isNativeReflectConstruct() {
|
462
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
463
|
+
if (Reflect.construct.sham) return false;
|
464
|
+
if (typeof Proxy === "function") return true;
|
465
|
+
try {
|
466
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
467
|
+
return true;
|
468
|
+
} catch (e) {
|
469
|
+
return false;
|
470
|
+
}
|
471
|
+
}
|
472
|
+
|
473
|
+
function _assertThisInitialized(self) {
|
474
|
+
if (self === void 0) {
|
475
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
476
|
+
}
|
477
|
+
return self;
|
478
|
+
}
|
479
|
+
|
480
|
+
function _possibleConstructorReturn(self, call) {
|
481
|
+
if (call && (typeof call === "object" || typeof call === "function")) {
|
482
|
+
return call;
|
483
|
+
} else if (call !== void 0) {
|
484
|
+
throw new TypeError("Derived constructors may only return object or undefined");
|
485
|
+
}
|
486
|
+
return _assertThisInitialized(self);
|
487
|
+
}
|
488
|
+
|
489
|
+
function _createSuper(Derived) {
|
490
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
491
|
+
return function _createSuperInternal() {
|
492
|
+
var Super = _getPrototypeOf(Derived),
|
493
|
+
result;
|
494
|
+
if (hasNativeReflectConstruct) {
|
495
|
+
var NewTarget = _getPrototypeOf(this).constructor;
|
496
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
497
|
+
} else {
|
498
|
+
result = Super.apply(this, arguments);
|
499
|
+
}
|
500
|
+
return _possibleConstructorReturn(this, result);
|
501
|
+
};
|
502
|
+
}
|
503
|
+
|
429
504
|
function handleError(error, msg) {
|
430
505
|
if (error instanceof Error) {
|
431
506
|
throw new Error("".concat(msg, ": ").concat(error.message));
|
@@ -439,12 +514,12 @@ function isIntegerString(s) {
|
|
439
514
|
}
|
440
515
|
|
441
516
|
/**
|
442
|
-
*
|
517
|
+
* FranchiseReadOnlyClient allows you to view, search franchises on
|
443
518
|
* Story Protocol.
|
444
519
|
*/
|
445
|
-
var
|
446
|
-
function
|
447
|
-
_classCallCheck(this,
|
520
|
+
var FranchiseReadOnlyClient = /*#__PURE__*/function () {
|
521
|
+
function FranchiseReadOnlyClient(httpClient, franchiseRegistry, licenseModule) {
|
522
|
+
_classCallCheck(this, FranchiseReadOnlyClient);
|
448
523
|
this.httpClient = httpClient;
|
449
524
|
this.franchiseRegistry = franchiseRegistry;
|
450
525
|
this.licenseModule = licenseModule;
|
@@ -456,7 +531,7 @@ var FranchiseClient = /*#__PURE__*/function () {
|
|
456
531
|
* @param request - the request object for getting the franchise
|
457
532
|
* @returns the response object that contains the fetched franchise object
|
458
533
|
*/
|
459
|
-
_createClass(
|
534
|
+
_createClass(FranchiseReadOnlyClient, [{
|
460
535
|
key: "get",
|
461
536
|
value: function () {
|
462
537
|
var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
|
@@ -525,24 +600,40 @@ var FranchiseClient = /*#__PURE__*/function () {
|
|
525
600
|
}
|
526
601
|
return list;
|
527
602
|
}()
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
603
|
+
}]);
|
604
|
+
return FranchiseReadOnlyClient;
|
605
|
+
}();
|
606
|
+
|
607
|
+
/**
|
608
|
+
* FranchiseClient allows you to create, update, view, search franchises on
|
609
|
+
* Story Protocol.
|
610
|
+
*/
|
611
|
+
var FranchiseClient = /*#__PURE__*/function (_FranchiseReadOnlyCli) {
|
612
|
+
_inherits(FranchiseClient, _FranchiseReadOnlyCli);
|
613
|
+
var _super = _createSuper(FranchiseClient);
|
614
|
+
function FranchiseClient(httpClient, franchiseRegistry, licenseModule) {
|
615
|
+
_classCallCheck(this, FranchiseClient);
|
616
|
+
return _super.call(this, httpClient, franchiseRegistry, licenseModule);
|
617
|
+
}
|
618
|
+
|
619
|
+
/**
|
620
|
+
* Create a franchise on Story Protocol based on the specified input franchise data.
|
621
|
+
*
|
622
|
+
* @param request - the request object that contains all data needed to create a franchise
|
623
|
+
* @returns the response object that contains results from the create franchise action
|
624
|
+
*/
|
625
|
+
_createClass(FranchiseClient, [{
|
535
626
|
key: "create",
|
536
627
|
value: function () {
|
537
|
-
var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
628
|
+
var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
|
538
629
|
var tokenURI, response;
|
539
|
-
return _regeneratorRuntime().wrap(function
|
540
|
-
while (1) switch (
|
630
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
631
|
+
while (1) switch (_context.prev = _context.next) {
|
541
632
|
case 0:
|
542
|
-
|
633
|
+
_context.prev = 0;
|
543
634
|
// hardcoded the URI for now until the backend API for uploading franchise metadata is ready
|
544
635
|
tokenURI = "https://arweave.net/dnFJl1v8kgOx_6Z0gEsBce3D56cMP4-lxAcFqSsL0_w";
|
545
|
-
|
636
|
+
_context.next = 4;
|
546
637
|
return this.franchiseRegistry.registerFranchise({
|
547
638
|
name: request.franchiseName,
|
548
639
|
symbol: request.franchiseSymbol,
|
@@ -550,21 +641,21 @@ var FranchiseClient = /*#__PURE__*/function () {
|
|
550
641
|
tokenURI: tokenURI
|
551
642
|
});
|
552
643
|
case 4:
|
553
|
-
response =
|
554
|
-
return
|
644
|
+
response = _context.sent;
|
645
|
+
return _context.abrupt("return", {
|
555
646
|
txHash: response.hash
|
556
647
|
});
|
557
648
|
case 8:
|
558
|
-
|
559
|
-
|
560
|
-
handleError(
|
649
|
+
_context.prev = 8;
|
650
|
+
_context.t0 = _context["catch"](0);
|
651
|
+
handleError(_context.t0, "Failed to create franchise");
|
561
652
|
case 11:
|
562
653
|
case "end":
|
563
|
-
return
|
654
|
+
return _context.stop();
|
564
655
|
}
|
565
|
-
},
|
656
|
+
}, _callee, this, [[0, 8]]);
|
566
657
|
}));
|
567
|
-
function create(
|
658
|
+
function create(_x) {
|
568
659
|
return _create.apply(this, arguments);
|
569
660
|
}
|
570
661
|
return create;
|
@@ -578,13 +669,13 @@ var FranchiseClient = /*#__PURE__*/function () {
|
|
578
669
|
}, {
|
579
670
|
key: "configure",
|
580
671
|
value: function () {
|
581
|
-
var _configure = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
672
|
+
var _configure = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
|
582
673
|
var response;
|
583
|
-
return _regeneratorRuntime().wrap(function
|
584
|
-
while (1) switch (
|
674
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
675
|
+
while (1) switch (_context2.prev = _context2.next) {
|
585
676
|
case 0:
|
586
|
-
|
587
|
-
|
677
|
+
_context2.prev = 0;
|
678
|
+
_context2.next = 3;
|
588
679
|
return this.licenseModule.configureFranchiseLicensing(request.franchiseId, {
|
589
680
|
nonCommercialConfig: {
|
590
681
|
canSublicense: true,
|
@@ -607,198 +698,427 @@ var FranchiseClient = /*#__PURE__*/function () {
|
|
607
698
|
revoker: "0xF33f05489d9708C2CA97944F2007d4E741D4DEe7"
|
608
699
|
});
|
609
700
|
case 3:
|
610
|
-
response =
|
611
|
-
return
|
701
|
+
response = _context2.sent;
|
702
|
+
return _context2.abrupt("return", {
|
612
703
|
txHash: response.hash
|
613
704
|
});
|
614
705
|
case 7:
|
615
|
-
|
616
|
-
|
617
|
-
handleError(
|
706
|
+
_context2.prev = 7;
|
707
|
+
_context2.t0 = _context2["catch"](0);
|
708
|
+
handleError(_context2.t0, "Failed to configure franchise");
|
618
709
|
case 10:
|
619
710
|
case "end":
|
620
|
-
return
|
711
|
+
return _context2.stop();
|
621
712
|
}
|
622
|
-
},
|
713
|
+
}, _callee2, this, [[0, 7]]);
|
623
714
|
}));
|
624
|
-
function configure(
|
715
|
+
function configure(_x2) {
|
625
716
|
return _configure.apply(this, arguments);
|
626
717
|
}
|
627
718
|
return configure;
|
628
719
|
}()
|
629
720
|
}]);
|
630
721
|
return FranchiseClient;
|
631
|
-
}();
|
722
|
+
}(FranchiseReadOnlyClient);
|
632
723
|
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
type: "uint256"
|
648
|
-
}],
|
649
|
-
internalType: "struct ILicensingModule.IpAssetConfig",
|
650
|
-
name: "nonCommercialConfig",
|
651
|
-
type: "tuple"
|
652
|
-
}, {
|
653
|
-
components: [{
|
654
|
-
internalType: "contract ITermsProcessor",
|
655
|
-
name: "processor",
|
656
|
-
type: "address"
|
657
|
-
}, {
|
658
|
-
internalType: "bytes",
|
659
|
-
name: "data",
|
660
|
-
type: "bytes"
|
661
|
-
}],
|
662
|
-
internalType: "struct IERC5218.TermsProcessorConfig",
|
663
|
-
name: "nonCommercialTerms",
|
664
|
-
type: "tuple"
|
665
|
-
}, {
|
666
|
-
components: [{
|
667
|
-
internalType: "bool",
|
668
|
-
name: "canSublicense",
|
669
|
-
type: "bool"
|
670
|
-
}, {
|
671
|
-
internalType: "uint256",
|
672
|
-
name: "franchiseRootLicenseId",
|
673
|
-
type: "uint256"
|
674
|
-
}],
|
675
|
-
internalType: "struct ILicensingModule.IpAssetConfig",
|
676
|
-
name: "commercialConfig",
|
677
|
-
type: "tuple"
|
678
|
-
}, {
|
679
|
-
components: [{
|
680
|
-
internalType: "contract ITermsProcessor",
|
681
|
-
name: "processor",
|
682
|
-
type: "address"
|
683
|
-
}, {
|
684
|
-
internalType: "bytes",
|
685
|
-
name: "data",
|
686
|
-
type: "bytes"
|
687
|
-
}],
|
688
|
-
internalType: "struct IERC5218.TermsProcessorConfig",
|
689
|
-
name: "commercialTerms",
|
690
|
-
type: "tuple"
|
691
|
-
}, {
|
692
|
-
internalType: "bool",
|
693
|
-
name: "rootIpAssetHasCommercialRights",
|
694
|
-
type: "bool"
|
695
|
-
}, {
|
696
|
-
internalType: "address",
|
697
|
-
name: "revoker",
|
698
|
-
type: "address"
|
699
|
-
}, {
|
700
|
-
internalType: "string",
|
701
|
-
name: "commercialLicenseUri",
|
702
|
-
type: "string"
|
703
|
-
}],
|
704
|
-
internalType: "struct ILicensingModule.FranchiseConfig",
|
705
|
-
name: "config",
|
706
|
-
type: "tuple"
|
707
|
-
}],
|
708
|
-
name: "configureFranchiseLicensing",
|
709
|
-
outputs: [],
|
710
|
-
stateMutability: "nonpayable",
|
711
|
-
type: "function"
|
712
|
-
}];
|
713
|
-
var LicensingModule__factory = /*#__PURE__*/function () {
|
714
|
-
function LicensingModule__factory() {
|
715
|
-
_classCallCheck(this, LicensingModule__factory);
|
716
|
-
}
|
717
|
-
_createClass(LicensingModule__factory, null, [{
|
718
|
-
key: "createInterface",
|
719
|
-
value: function createInterface() {
|
720
|
-
return new ethers.utils.Interface(_abi$4);
|
721
|
-
}
|
722
|
-
}, {
|
723
|
-
key: "connect",
|
724
|
-
value: function connect(address, signerOrProvider) {
|
725
|
-
return new ethers.Contract(address, _abi$4, signerOrProvider);
|
726
|
-
}
|
727
|
-
}]);
|
728
|
-
return LicensingModule__factory;
|
729
|
-
}();
|
730
|
-
_defineProperty(LicensingModule__factory, "abi", _abi$4);
|
724
|
+
/**
|
725
|
+
* Client for managing relationships.
|
726
|
+
*/
|
727
|
+
var RelationshipReadOnlyClient = /*#__PURE__*/_createClass(
|
728
|
+
/**
|
729
|
+
* Creates a new RelationshipClient instance.
|
730
|
+
* @param relationshipModule - The relationship module to interact with.
|
731
|
+
* @param franchiseRegistry - The franchise registry to interact with.
|
732
|
+
*/
|
733
|
+
function RelationshipReadOnlyClient(relationshipModule, franchiseRegistry) {
|
734
|
+
_classCallCheck(this, RelationshipReadOnlyClient);
|
735
|
+
this.relationshipModule = relationshipModule;
|
736
|
+
this.franchiseRegistry = franchiseRegistry;
|
737
|
+
});
|
731
738
|
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
}, {
|
747
|
-
internalType: "string",
|
748
|
-
name: "tokenURI",
|
749
|
-
type: "string"
|
750
|
-
}],
|
751
|
-
internalType: "struct FranchiseRegistry.FranchiseCreationParams",
|
752
|
-
name: "params",
|
753
|
-
type: "tuple"
|
754
|
-
}],
|
755
|
-
name: "registerFranchise",
|
756
|
-
outputs: [{
|
757
|
-
internalType: "uint256",
|
758
|
-
name: "",
|
759
|
-
type: "uint256"
|
760
|
-
}, {
|
761
|
-
internalType: "address",
|
762
|
-
name: "",
|
763
|
-
type: "address"
|
764
|
-
}],
|
765
|
-
stateMutability: "nonpayable",
|
766
|
-
type: "function"
|
767
|
-
}, {
|
768
|
-
inputs: [{
|
769
|
-
internalType: "uint256",
|
770
|
-
name: "franchiseId",
|
771
|
-
type: "uint256"
|
772
|
-
}],
|
773
|
-
name: "ipAssetRegistryForId",
|
774
|
-
outputs: [{
|
775
|
-
internalType: "address",
|
776
|
-
name: "",
|
777
|
-
type: "address"
|
778
|
-
}],
|
779
|
-
stateMutability: "view",
|
780
|
-
type: "function"
|
781
|
-
}];
|
782
|
-
var FranchiseRegistry__factory = /*#__PURE__*/function () {
|
783
|
-
function FranchiseRegistry__factory() {
|
784
|
-
_classCallCheck(this, FranchiseRegistry__factory);
|
739
|
+
/**
|
740
|
+
* Client for managing relationships.
|
741
|
+
*/
|
742
|
+
var RelationshipClient = /*#__PURE__*/function (_RelationshipReadOnly) {
|
743
|
+
_inherits(RelationshipClient, _RelationshipReadOnly);
|
744
|
+
var _super = _createSuper(RelationshipClient);
|
745
|
+
/**
|
746
|
+
* Creates a new RelationshipClient instance.
|
747
|
+
* @param relationshipModule - The relationship module to interact with.
|
748
|
+
* @param franchiseRegistry - The franchise registry to interact with.
|
749
|
+
*/
|
750
|
+
function RelationshipClient(relationshipModule, franchiseRegistry) {
|
751
|
+
_classCallCheck(this, RelationshipClient);
|
752
|
+
return _super.call(this, relationshipModule, franchiseRegistry);
|
785
753
|
}
|
786
|
-
|
787
|
-
|
754
|
+
|
755
|
+
/**
|
756
|
+
* Retrieves the registry addresses for source and destination franchises.
|
757
|
+
* @param sourceFranchiseId - The ID of the source franchise.
|
758
|
+
* @param destFranchiseId - The ID of the destination franchise.
|
759
|
+
* @returns An object containing the source and destination IP registry addresses.
|
760
|
+
*/
|
761
|
+
_createClass(RelationshipClient, [{
|
762
|
+
key: "getRegistryAddresses",
|
763
|
+
value: function () {
|
764
|
+
var _getRegistryAddresses = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(sourceFranchiseId, destFranchiseId) {
|
765
|
+
var sourceIpRegistryAddress, destIpRegistryAddress;
|
766
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
767
|
+
while (1) switch (_context.prev = _context.next) {
|
768
|
+
case 0:
|
769
|
+
_context.prev = 0;
|
770
|
+
_context.next = 3;
|
771
|
+
return this.franchiseRegistry.ipAssetRegistryForId(sourceFranchiseId);
|
772
|
+
case 3:
|
773
|
+
sourceIpRegistryAddress = _context.sent;
|
774
|
+
_context.next = 6;
|
775
|
+
return this.franchiseRegistry.ipAssetRegistryForId(destFranchiseId);
|
776
|
+
case 6:
|
777
|
+
destIpRegistryAddress = _context.sent;
|
778
|
+
return _context.abrupt("return", {
|
779
|
+
sourceIpRegistryAddress: sourceIpRegistryAddress,
|
780
|
+
destIpRegistryAddress: destIpRegistryAddress
|
781
|
+
});
|
782
|
+
case 10:
|
783
|
+
_context.prev = 10;
|
784
|
+
_context.t0 = _context["catch"](0);
|
785
|
+
handleError(_context.t0, "Failed to get registry addresses");
|
786
|
+
case 13:
|
787
|
+
case "end":
|
788
|
+
return _context.stop();
|
789
|
+
}
|
790
|
+
}, _callee, this, [[0, 10]]);
|
791
|
+
}));
|
792
|
+
function getRegistryAddresses(_x, _x2) {
|
793
|
+
return _getRegistryAddresses.apply(this, arguments);
|
794
|
+
}
|
795
|
+
return getRegistryAddresses;
|
796
|
+
}()
|
797
|
+
/**
|
798
|
+
* Establishes a relationship between two IP assets.
|
799
|
+
* @param request - The request for establishing the relationship.
|
800
|
+
* @returns A promise that resolves to the response with the transaction hash.
|
801
|
+
*/
|
802
|
+
}, {
|
803
|
+
key: "relate",
|
804
|
+
value: function () {
|
805
|
+
var _relate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
|
806
|
+
var sourceIPAsset, destIPAsset, mockRelationshipData, _yield$this$getRegist, sourceIpRegistryAddress, destIpRegistryAddress, relationshipId, params, response;
|
807
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
808
|
+
while (1) switch (_context2.prev = _context2.next) {
|
809
|
+
case 0:
|
810
|
+
_context2.prev = 0;
|
811
|
+
sourceIPAsset = request.sourceIPAsset, destIPAsset = request.destIPAsset;
|
812
|
+
mockRelationshipData = ethers.ethers.utils.formatBytes32String(""); // Get IPAssetRegistry Contract Address
|
813
|
+
_context2.next = 5;
|
814
|
+
return this.getRegistryAddresses(sourceIPAsset.franchiseId, destIPAsset.franchiseId);
|
815
|
+
case 5:
|
816
|
+
_yield$this$getRegist = _context2.sent;
|
817
|
+
sourceIpRegistryAddress = _yield$this$getRegist.sourceIpRegistryAddress;
|
818
|
+
destIpRegistryAddress = _yield$this$getRegist.destIpRegistryAddress;
|
819
|
+
_context2.next = 10;
|
820
|
+
return this.relationshipModule.getRelationshipId("APPEARS_IN");
|
821
|
+
case 10:
|
822
|
+
relationshipId = _context2.sent;
|
823
|
+
params = {
|
824
|
+
sourceContract: sourceIpRegistryAddress,
|
825
|
+
sourceId: sourceIPAsset.ipAssetId,
|
826
|
+
destContract: destIpRegistryAddress,
|
827
|
+
destId: destIPAsset.ipAssetId,
|
828
|
+
relationshipId: relationshipId,
|
829
|
+
ttl: "0"
|
830
|
+
};
|
831
|
+
_context2.next = 14;
|
832
|
+
return this.relationshipModule.relate(params, mockRelationshipData);
|
833
|
+
case 14:
|
834
|
+
response = _context2.sent;
|
835
|
+
return _context2.abrupt("return", {
|
836
|
+
txHash: response.hash
|
837
|
+
});
|
838
|
+
case 18:
|
839
|
+
_context2.prev = 18;
|
840
|
+
_context2.t0 = _context2["catch"](0);
|
841
|
+
handleError(_context2.t0, "Failed to create relationship");
|
842
|
+
case 21:
|
843
|
+
case "end":
|
844
|
+
return _context2.stop();
|
845
|
+
}
|
846
|
+
}, _callee2, this, [[0, 18]]);
|
847
|
+
}));
|
848
|
+
function relate(_x3) {
|
849
|
+
return _relate.apply(this, arguments);
|
850
|
+
}
|
851
|
+
return relate;
|
852
|
+
}()
|
853
|
+
/**
|
854
|
+
* Removes a relationship between two IP assets.
|
855
|
+
* @param request - The request for removing the relationship.
|
856
|
+
* @returns A promise that resolves to the response with the transaction hash.
|
857
|
+
*/
|
858
|
+
}, {
|
859
|
+
key: "unrelate",
|
860
|
+
value: function () {
|
861
|
+
var _unrelate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(request) {
|
862
|
+
var sourceIPAsset, destIPAsset, _yield$this$getRegist2, sourceIpRegistryAddress, destIpRegistryAddress, relationshipId, params, response;
|
863
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
864
|
+
while (1) switch (_context3.prev = _context3.next) {
|
865
|
+
case 0:
|
866
|
+
_context3.prev = 0;
|
867
|
+
sourceIPAsset = request.sourceIPAsset, destIPAsset = request.destIPAsset; // Get IPAssetRegistry Contract Address
|
868
|
+
_context3.next = 4;
|
869
|
+
return this.getRegistryAddresses(sourceIPAsset.franchiseId, destIPAsset.franchiseId);
|
870
|
+
case 4:
|
871
|
+
_yield$this$getRegist2 = _context3.sent;
|
872
|
+
sourceIpRegistryAddress = _yield$this$getRegist2.sourceIpRegistryAddress;
|
873
|
+
destIpRegistryAddress = _yield$this$getRegist2.destIpRegistryAddress;
|
874
|
+
_context3.next = 9;
|
875
|
+
return this.relationshipModule.getRelationshipId("APPEARS_IN");
|
876
|
+
case 9:
|
877
|
+
relationshipId = _context3.sent;
|
878
|
+
params = {
|
879
|
+
sourceContract: sourceIpRegistryAddress,
|
880
|
+
sourceId: sourceIPAsset.ipAssetId,
|
881
|
+
destContract: destIpRegistryAddress,
|
882
|
+
destId: destIPAsset.ipAssetId,
|
883
|
+
relationshipId: relationshipId,
|
884
|
+
ttl: "0"
|
885
|
+
};
|
886
|
+
_context3.next = 13;
|
887
|
+
return this.relationshipModule.unrelate(params);
|
888
|
+
case 13:
|
889
|
+
response = _context3.sent;
|
890
|
+
return _context3.abrupt("return", {
|
891
|
+
txHash: response.hash
|
892
|
+
});
|
893
|
+
case 17:
|
894
|
+
_context3.prev = 17;
|
895
|
+
_context3.t0 = _context3["catch"](0);
|
896
|
+
handleError(_context3.t0, "Failed to unrelate relationship");
|
897
|
+
case 20:
|
898
|
+
case "end":
|
899
|
+
return _context3.stop();
|
900
|
+
}
|
901
|
+
}, _callee3, this, [[0, 17]]);
|
902
|
+
}));
|
903
|
+
function unrelate(_x4) {
|
904
|
+
return _unrelate.apply(this, arguments);
|
905
|
+
}
|
906
|
+
return unrelate;
|
907
|
+
}()
|
908
|
+
/**
|
909
|
+
* Checks if a relationship has expired.
|
910
|
+
* @param request - The request for checking the relationship's expiration status.
|
911
|
+
* @returns A promise that resolves to the response indicating whether the relationship has expired.
|
912
|
+
*/
|
913
|
+
}, {
|
914
|
+
key: "isRelationshipExpired",
|
915
|
+
value: function () {
|
916
|
+
var _isRelationshipExpired = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(request) {
|
917
|
+
var sourceIPAsset, destIPAsset, _yield$this$getRegist3, sourceIpRegistryAddress, destIpRegistryAddress, relationshipId, params, response;
|
918
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
919
|
+
while (1) switch (_context4.prev = _context4.next) {
|
920
|
+
case 0:
|
921
|
+
_context4.prev = 0;
|
922
|
+
sourceIPAsset = request.sourceIPAsset, destIPAsset = request.destIPAsset; // Get IPAssetRegistry Contract Address
|
923
|
+
_context4.next = 4;
|
924
|
+
return this.getRegistryAddresses(sourceIPAsset.franchiseId, destIPAsset.franchiseId);
|
925
|
+
case 4:
|
926
|
+
_yield$this$getRegist3 = _context4.sent;
|
927
|
+
sourceIpRegistryAddress = _yield$this$getRegist3.sourceIpRegistryAddress;
|
928
|
+
destIpRegistryAddress = _yield$this$getRegist3.destIpRegistryAddress;
|
929
|
+
_context4.next = 9;
|
930
|
+
return this.relationshipModule.getRelationshipId("APPEARS_IN");
|
931
|
+
case 9:
|
932
|
+
relationshipId = _context4.sent;
|
933
|
+
params = {
|
934
|
+
sourceContract: sourceIpRegistryAddress,
|
935
|
+
sourceId: sourceIPAsset.ipAssetId,
|
936
|
+
destContract: destIpRegistryAddress,
|
937
|
+
destId: destIPAsset.ipAssetId,
|
938
|
+
relationshipId: relationshipId,
|
939
|
+
ttl: "0"
|
940
|
+
};
|
941
|
+
_context4.next = 13;
|
942
|
+
return this.relationshipModule.isRelationshipExpired(params);
|
943
|
+
case 13:
|
944
|
+
response = _context4.sent;
|
945
|
+
return _context4.abrupt("return", {
|
946
|
+
result: response
|
947
|
+
});
|
948
|
+
case 17:
|
949
|
+
_context4.prev = 17;
|
950
|
+
_context4.t0 = _context4["catch"](0);
|
951
|
+
handleError(_context4.t0, "Failed to get isRelationshipExpired");
|
952
|
+
case 20:
|
953
|
+
case "end":
|
954
|
+
return _context4.stop();
|
955
|
+
}
|
956
|
+
}, _callee4, this, [[0, 17]]);
|
957
|
+
}));
|
958
|
+
function isRelationshipExpired(_x5) {
|
959
|
+
return _isRelationshipExpired.apply(this, arguments);
|
960
|
+
}
|
961
|
+
return isRelationshipExpired;
|
962
|
+
}()
|
963
|
+
/**
|
964
|
+
* Checks if two IP assets are related.
|
965
|
+
* @param request - The request for checking the relationship between two IP assets.
|
966
|
+
* @returns A promise that resolves to the response indicating whether the IP assets are related.
|
967
|
+
*/
|
968
|
+
}, {
|
969
|
+
key: "isRelated",
|
970
|
+
value: function () {
|
971
|
+
var _isRelated = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(request) {
|
972
|
+
var sourceIPAsset, destIPAsset, _yield$this$getRegist4, sourceIpRegistryAddress, destIpRegistryAddress, relationshipId, params, response;
|
973
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
974
|
+
while (1) switch (_context5.prev = _context5.next) {
|
975
|
+
case 0:
|
976
|
+
_context5.prev = 0;
|
977
|
+
sourceIPAsset = request.sourceIPAsset, destIPAsset = request.destIPAsset; // Get IPAssetRegistry Contract Address
|
978
|
+
_context5.next = 4;
|
979
|
+
return this.getRegistryAddresses(sourceIPAsset.franchiseId, destIPAsset.franchiseId);
|
980
|
+
case 4:
|
981
|
+
_yield$this$getRegist4 = _context5.sent;
|
982
|
+
sourceIpRegistryAddress = _yield$this$getRegist4.sourceIpRegistryAddress;
|
983
|
+
destIpRegistryAddress = _yield$this$getRegist4.destIpRegistryAddress;
|
984
|
+
_context5.next = 9;
|
985
|
+
return this.relationshipModule.getRelationshipId("APPEARS_IN");
|
986
|
+
case 9:
|
987
|
+
relationshipId = _context5.sent;
|
988
|
+
params = {
|
989
|
+
sourceContract: sourceIpRegistryAddress,
|
990
|
+
sourceId: sourceIPAsset.ipAssetId,
|
991
|
+
destContract: destIpRegistryAddress,
|
992
|
+
destId: destIPAsset.ipAssetId,
|
993
|
+
relationshipId: relationshipId,
|
994
|
+
ttl: "0"
|
995
|
+
};
|
996
|
+
_context5.next = 13;
|
997
|
+
return this.relationshipModule.areTheyRelated(params);
|
998
|
+
case 13:
|
999
|
+
response = _context5.sent;
|
1000
|
+
return _context5.abrupt("return", {
|
1001
|
+
result: response
|
1002
|
+
});
|
1003
|
+
case 17:
|
1004
|
+
_context5.prev = 17;
|
1005
|
+
_context5.t0 = _context5["catch"](0);
|
1006
|
+
handleError(_context5.t0, "Failed to get isRelated");
|
1007
|
+
case 20:
|
1008
|
+
case "end":
|
1009
|
+
return _context5.stop();
|
1010
|
+
}
|
1011
|
+
}, _callee5, this, [[0, 17]]);
|
1012
|
+
}));
|
1013
|
+
function isRelated(_x6) {
|
1014
|
+
return _isRelated.apply(this, arguments);
|
1015
|
+
}
|
1016
|
+
return isRelated;
|
1017
|
+
}()
|
1018
|
+
}]);
|
1019
|
+
return RelationshipClient;
|
1020
|
+
}(RelationshipReadOnlyClient);
|
1021
|
+
|
1022
|
+
var _abi$4 = [{
|
1023
|
+
inputs: [{
|
1024
|
+
internalType: "uint256",
|
1025
|
+
name: "franchiseId",
|
1026
|
+
type: "uint256"
|
1027
|
+
}, {
|
1028
|
+
components: [{
|
1029
|
+
components: [{
|
1030
|
+
internalType: "bool",
|
1031
|
+
name: "canSublicense",
|
1032
|
+
type: "bool"
|
1033
|
+
}, {
|
1034
|
+
internalType: "uint256",
|
1035
|
+
name: "franchiseRootLicenseId",
|
1036
|
+
type: "uint256"
|
1037
|
+
}],
|
1038
|
+
internalType: "struct ILicensingModule.IpAssetConfig",
|
1039
|
+
name: "nonCommercialConfig",
|
1040
|
+
type: "tuple"
|
1041
|
+
}, {
|
1042
|
+
components: [{
|
1043
|
+
internalType: "contract ITermsProcessor",
|
1044
|
+
name: "processor",
|
1045
|
+
type: "address"
|
1046
|
+
}, {
|
1047
|
+
internalType: "bytes",
|
1048
|
+
name: "data",
|
1049
|
+
type: "bytes"
|
1050
|
+
}],
|
1051
|
+
internalType: "struct IERC5218.TermsProcessorConfig",
|
1052
|
+
name: "nonCommercialTerms",
|
1053
|
+
type: "tuple"
|
1054
|
+
}, {
|
1055
|
+
components: [{
|
1056
|
+
internalType: "bool",
|
1057
|
+
name: "canSublicense",
|
1058
|
+
type: "bool"
|
1059
|
+
}, {
|
1060
|
+
internalType: "uint256",
|
1061
|
+
name: "franchiseRootLicenseId",
|
1062
|
+
type: "uint256"
|
1063
|
+
}],
|
1064
|
+
internalType: "struct ILicensingModule.IpAssetConfig",
|
1065
|
+
name: "commercialConfig",
|
1066
|
+
type: "tuple"
|
1067
|
+
}, {
|
1068
|
+
components: [{
|
1069
|
+
internalType: "contract ITermsProcessor",
|
1070
|
+
name: "processor",
|
1071
|
+
type: "address"
|
1072
|
+
}, {
|
1073
|
+
internalType: "bytes",
|
1074
|
+
name: "data",
|
1075
|
+
type: "bytes"
|
1076
|
+
}],
|
1077
|
+
internalType: "struct IERC5218.TermsProcessorConfig",
|
1078
|
+
name: "commercialTerms",
|
1079
|
+
type: "tuple"
|
1080
|
+
}, {
|
1081
|
+
internalType: "bool",
|
1082
|
+
name: "rootIpAssetHasCommercialRights",
|
1083
|
+
type: "bool"
|
1084
|
+
}, {
|
1085
|
+
internalType: "address",
|
1086
|
+
name: "revoker",
|
1087
|
+
type: "address"
|
1088
|
+
}, {
|
1089
|
+
internalType: "string",
|
1090
|
+
name: "commercialLicenseUri",
|
1091
|
+
type: "string"
|
1092
|
+
}],
|
1093
|
+
internalType: "struct ILicensingModule.FranchiseConfig",
|
1094
|
+
name: "config",
|
1095
|
+
type: "tuple"
|
1096
|
+
}],
|
1097
|
+
name: "configureFranchiseLicensing",
|
1098
|
+
outputs: [],
|
1099
|
+
stateMutability: "nonpayable",
|
1100
|
+
type: "function"
|
1101
|
+
}];
|
1102
|
+
var LicensingModule__factory = /*#__PURE__*/function () {
|
1103
|
+
function LicensingModule__factory() {
|
1104
|
+
_classCallCheck(this, LicensingModule__factory);
|
1105
|
+
}
|
1106
|
+
_createClass(LicensingModule__factory, null, [{
|
1107
|
+
key: "createInterface",
|
788
1108
|
value: function createInterface() {
|
789
|
-
return new ethers.utils.Interface(_abi$
|
1109
|
+
return new ethers.utils.Interface(_abi$4);
|
790
1110
|
}
|
791
1111
|
}, {
|
792
1112
|
key: "connect",
|
793
1113
|
value: function connect(address, signerOrProvider) {
|
794
|
-
return new ethers.Contract(address, _abi$
|
1114
|
+
return new ethers.Contract(address, _abi$4, signerOrProvider);
|
795
1115
|
}
|
796
1116
|
}]);
|
797
|
-
return
|
1117
|
+
return LicensingModule__factory;
|
798
1118
|
}();
|
799
|
-
_defineProperty(
|
1119
|
+
_defineProperty(LicensingModule__factory, "abi", _abi$4);
|
800
1120
|
|
801
|
-
var _abi$
|
1121
|
+
var _abi$3 = [{
|
802
1122
|
inputs: [{
|
803
1123
|
components: [{
|
804
1124
|
internalType: "uint256",
|
@@ -847,6 +1167,75 @@ var CollectModule__factory = /*#__PURE__*/function () {
|
|
847
1167
|
_classCallCheck(this, CollectModule__factory);
|
848
1168
|
}
|
849
1169
|
_createClass(CollectModule__factory, null, [{
|
1170
|
+
key: "createInterface",
|
1171
|
+
value: function createInterface() {
|
1172
|
+
return new ethers.utils.Interface(_abi$3);
|
1173
|
+
}
|
1174
|
+
}, {
|
1175
|
+
key: "connect",
|
1176
|
+
value: function connect(address, signerOrProvider) {
|
1177
|
+
return new ethers.Contract(address, _abi$3, signerOrProvider);
|
1178
|
+
}
|
1179
|
+
}]);
|
1180
|
+
return CollectModule__factory;
|
1181
|
+
}();
|
1182
|
+
_defineProperty(CollectModule__factory, "abi", _abi$3);
|
1183
|
+
|
1184
|
+
var _abi$2 = [{
|
1185
|
+
inputs: [{
|
1186
|
+
components: [{
|
1187
|
+
internalType: "string",
|
1188
|
+
name: "name",
|
1189
|
+
type: "string"
|
1190
|
+
}, {
|
1191
|
+
internalType: "string",
|
1192
|
+
name: "symbol",
|
1193
|
+
type: "string"
|
1194
|
+
}, {
|
1195
|
+
internalType: "string",
|
1196
|
+
name: "description",
|
1197
|
+
type: "string"
|
1198
|
+
}, {
|
1199
|
+
internalType: "string",
|
1200
|
+
name: "tokenURI",
|
1201
|
+
type: "string"
|
1202
|
+
}],
|
1203
|
+
internalType: "struct FranchiseRegistry.FranchiseCreationParams",
|
1204
|
+
name: "params",
|
1205
|
+
type: "tuple"
|
1206
|
+
}],
|
1207
|
+
name: "registerFranchise",
|
1208
|
+
outputs: [{
|
1209
|
+
internalType: "uint256",
|
1210
|
+
name: "",
|
1211
|
+
type: "uint256"
|
1212
|
+
}, {
|
1213
|
+
internalType: "address",
|
1214
|
+
name: "",
|
1215
|
+
type: "address"
|
1216
|
+
}],
|
1217
|
+
stateMutability: "nonpayable",
|
1218
|
+
type: "function"
|
1219
|
+
}, {
|
1220
|
+
inputs: [{
|
1221
|
+
internalType: "uint256",
|
1222
|
+
name: "franchiseId",
|
1223
|
+
type: "uint256"
|
1224
|
+
}],
|
1225
|
+
name: "ipAssetRegistryForId",
|
1226
|
+
outputs: [{
|
1227
|
+
internalType: "address",
|
1228
|
+
name: "",
|
1229
|
+
type: "address"
|
1230
|
+
}],
|
1231
|
+
stateMutability: "view",
|
1232
|
+
type: "function"
|
1233
|
+
}];
|
1234
|
+
var FranchiseRegistry__factory = /*#__PURE__*/function () {
|
1235
|
+
function FranchiseRegistry__factory() {
|
1236
|
+
_classCallCheck(this, FranchiseRegistry__factory);
|
1237
|
+
}
|
1238
|
+
_createClass(FranchiseRegistry__factory, null, [{
|
850
1239
|
key: "createInterface",
|
851
1240
|
value: function createInterface() {
|
852
1241
|
return new ethers.utils.Interface(_abi$2);
|
@@ -857,9 +1246,9 @@ var CollectModule__factory = /*#__PURE__*/function () {
|
|
857
1246
|
return new ethers.Contract(address, _abi$2, signerOrProvider);
|
858
1247
|
}
|
859
1248
|
}]);
|
860
|
-
return
|
1249
|
+
return FranchiseRegistry__factory;
|
861
1250
|
}();
|
862
|
-
_defineProperty(
|
1251
|
+
_defineProperty(FranchiseRegistry__factory, "abi", _abi$2);
|
863
1252
|
|
864
1253
|
var _abi$1 = [{
|
865
1254
|
inputs: [{
|
@@ -1171,25 +1560,22 @@ var RelationshipModule__factory = /*#__PURE__*/function () {
|
|
1171
1560
|
_defineProperty(RelationshipModule__factory, "abi", _abi);
|
1172
1561
|
|
1173
1562
|
/**
|
1174
|
-
*
|
1175
|
-
*
|
1176
|
-
* @public
|
1563
|
+
* IpAssetClient allows you to create, view, and list IP Assets on Story Protocol.
|
1177
1564
|
*/
|
1178
|
-
var
|
1179
|
-
function
|
1180
|
-
_classCallCheck(this,
|
1565
|
+
var IPAssetReadOnlyClient = /*#__PURE__*/function () {
|
1566
|
+
function IPAssetReadOnlyClient(httpClient, franchiseRegistry) {
|
1567
|
+
_classCallCheck(this, IPAssetReadOnlyClient);
|
1181
1568
|
this.httpClient = httpClient;
|
1182
|
-
this.signer = signer;
|
1183
1569
|
this.franchiseRegistry = franchiseRegistry;
|
1184
1570
|
}
|
1185
1571
|
|
1186
1572
|
/**
|
1187
|
-
* Get
|
1573
|
+
* Get an IP Asset based on the specified IP asset ID.
|
1188
1574
|
*
|
1189
|
-
* @param
|
1190
|
-
* @returns
|
1575
|
+
* @param request - the request object for getting an IP Asset.
|
1576
|
+
* @returns the response object the contains the fetched IP Asset.
|
1191
1577
|
*/
|
1192
|
-
_createClass(
|
1578
|
+
_createClass(IPAssetReadOnlyClient, [{
|
1193
1579
|
key: "get",
|
1194
1580
|
value: function () {
|
1195
1581
|
var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
|
@@ -1198,21 +1584,21 @@ var LicenseClient = /*#__PURE__*/function () {
|
|
1198
1584
|
while (1) switch (_context.prev = _context.next) {
|
1199
1585
|
case 0:
|
1200
1586
|
_context.prev = 0;
|
1201
|
-
if (isIntegerString(request.
|
1587
|
+
if (isIntegerString(request.ipAssetId)) {
|
1202
1588
|
_context.next = 3;
|
1203
1589
|
break;
|
1204
1590
|
}
|
1205
|
-
throw new Error("Invalid
|
1591
|
+
throw new Error("Invalid IP Asset id. Must be an integer. But get: ".concat(request.ipAssetId));
|
1206
1592
|
case 3:
|
1207
1593
|
_context.next = 5;
|
1208
|
-
return this.httpClient.get("/
|
1594
|
+
return this.httpClient.get("/ipasset/".concat(request.ipAssetId, "?franchiseId=").concat(request.franchiseId));
|
1209
1595
|
case 5:
|
1210
1596
|
response = _context.sent;
|
1211
1597
|
return _context.abrupt("return", response.data);
|
1212
1598
|
case 9:
|
1213
1599
|
_context.prev = 9;
|
1214
1600
|
_context.t0 = _context["catch"](0);
|
1215
|
-
handleError(_context.t0, "Failed to get
|
1601
|
+
handleError(_context.t0, "Failed to get IP Asset");
|
1216
1602
|
case 12:
|
1217
1603
|
case "end":
|
1218
1604
|
return _context.stop();
|
@@ -1225,9 +1611,9 @@ var LicenseClient = /*#__PURE__*/function () {
|
|
1225
1611
|
return get;
|
1226
1612
|
}()
|
1227
1613
|
/**
|
1228
|
-
* List all
|
1614
|
+
* List all IP assets.
|
1229
1615
|
*
|
1230
|
-
* @returns
|
1616
|
+
* @returns the response object that contains results from listing query.
|
1231
1617
|
*/
|
1232
1618
|
}, {
|
1233
1619
|
key: "list",
|
@@ -1239,14 +1625,14 @@ var LicenseClient = /*#__PURE__*/function () {
|
|
1239
1625
|
case 0:
|
1240
1626
|
_context2.prev = 0;
|
1241
1627
|
_context2.next = 3;
|
1242
|
-
return this.httpClient.get("/
|
1628
|
+
return this.httpClient.get("/ipasset?franchiseId=".concat(request.franchiseId));
|
1243
1629
|
case 3:
|
1244
1630
|
response = _context2.sent;
|
1245
1631
|
return _context2.abrupt("return", response.data);
|
1246
1632
|
case 7:
|
1247
1633
|
_context2.prev = 7;
|
1248
1634
|
_context2.t0 = _context2["catch"](0);
|
1249
|
-
handleError(_context2.t0, "Failed to
|
1635
|
+
handleError(_context2.t0, "Failed to list IP Asset.");
|
1250
1636
|
case 10:
|
1251
1637
|
case "end":
|
1252
1638
|
return _context2.stop();
|
@@ -1258,634 +1644,399 @@ var LicenseClient = /*#__PURE__*/function () {
|
|
1258
1644
|
}
|
1259
1645
|
return list;
|
1260
1646
|
}()
|
1261
|
-
/**
|
1262
|
-
* Create a license within the Story Protocol based on the specified input data.
|
1263
|
-
*
|
1264
|
-
* @param request - An object containing the necessary data to create a license.
|
1265
|
-
* @returns A response object containing the result of the create license action, including the transaction hash.
|
1266
|
-
*/
|
1267
|
-
}, {
|
1268
|
-
key: "create",
|
1269
|
-
value: function () {
|
1270
|
-
var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(request) {
|
1271
|
-
var defaults, franchiseId, ipAssetId, licenseURI, options, walletAddress, ipAssetRegistryAddress, ipAssetRegistry, parentLicenseId, createResponse;
|
1272
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
1273
|
-
while (1) switch (_context3.prev = _context3.next) {
|
1274
|
-
case 0:
|
1275
|
-
_context3.prev = 0;
|
1276
|
-
defaults = {
|
1277
|
-
_tokenId: 0,
|
1278
|
-
// Assuming BigNumberish can be initialized with 0
|
1279
|
-
_parentLicenseId: "0",
|
1280
|
-
_licenseHolder: "0x8e3B91c90561523312f32B49DAAc4AD15293De7F",
|
1281
|
-
// An empty string for a default holder address
|
1282
|
-
_uri: "https://example.xyz",
|
1283
|
-
// An empty string for a default URI
|
1284
|
-
_revoker: "0x8e3B91c90561523312f32B49DAAc4AD15293De7F",
|
1285
|
-
// An empty string for a default revoker address
|
1286
|
-
_commercial: false,
|
1287
|
-
// Default to non-commercial
|
1288
|
-
_canSublicense: false,
|
1289
|
-
// Default to not allowing sublicense
|
1290
|
-
_terms: {
|
1291
|
-
processor: ethers.constants.AddressZero,
|
1292
|
-
data: []
|
1293
|
-
},
|
1294
|
-
overrides: {
|
1295
|
-
// Assuming overrides is an object with properties from and gasLimit
|
1296
|
-
// You may need to provide default values for its properties as well
|
1297
|
-
}
|
1298
|
-
};
|
1299
|
-
franchiseId = request.franchiseId, ipAssetId = request.ipAssetId, licenseURI = request.licenseURI, options = request.options; // Get Wallet address from Signer
|
1300
|
-
_context3.next = 5;
|
1301
|
-
return this.signer.getAddress();
|
1302
|
-
case 5:
|
1303
|
-
walletAddress = _context3.sent;
|
1304
|
-
_context3.next = 8;
|
1305
|
-
return this.franchiseRegistry.ipAssetRegistryForId(franchiseId);
|
1306
|
-
case 8:
|
1307
|
-
ipAssetRegistryAddress = _context3.sent;
|
1308
|
-
// Connect to IPAssetRegistry Contract
|
1309
|
-
ipAssetRegistry = IpAssetRegistry__factory.connect(ipAssetRegistryAddress, this.signer); // Get parent license Id
|
1310
|
-
_context3.next = 12;
|
1311
|
-
return ipAssetRegistry.getLicenseIdByTokenId(ipAssetId, (options === null || options === void 0 ? void 0 : options.isCommercial) || defaults._commercial);
|
1312
|
-
case 12:
|
1313
|
-
parentLicenseId = _context3.sent;
|
1314
|
-
_context3.next = 15;
|
1315
|
-
return ipAssetRegistry.createLicense(ipAssetId, parentLicenseId, walletAddress, licenseURI, (options === null || options === void 0 ? void 0 : options.revoker) || defaults._revoker, (options === null || options === void 0 ? void 0 : options.isCommercial) || defaults._commercial, (options === null || options === void 0 ? void 0 : options.isSublicensable) || defaults._canSublicense, (options === null || options === void 0 ? void 0 : options.terms) || defaults._terms);
|
1316
|
-
case 15:
|
1317
|
-
createResponse = _context3.sent;
|
1318
|
-
return _context3.abrupt("return", {
|
1319
|
-
txHash: createResponse.hash
|
1320
|
-
});
|
1321
|
-
case 19:
|
1322
|
-
_context3.prev = 19;
|
1323
|
-
_context3.t0 = _context3["catch"](0);
|
1324
|
-
handleError(_context3.t0, "Failed to create license");
|
1325
|
-
case 22:
|
1326
|
-
case "end":
|
1327
|
-
return _context3.stop();
|
1328
|
-
}
|
1329
|
-
}, _callee3, this, [[0, 19]]);
|
1330
|
-
}));
|
1331
|
-
function create(_x3) {
|
1332
|
-
return _create.apply(this, arguments);
|
1333
|
-
}
|
1334
|
-
return create;
|
1335
|
-
}()
|
1336
1647
|
}]);
|
1337
|
-
return
|
1648
|
+
return IPAssetReadOnlyClient;
|
1338
1649
|
}();
|
1339
1650
|
|
1340
1651
|
/**
|
1341
|
-
*
|
1342
|
-
* Story Protocol.
|
1652
|
+
* IpAssetClient allows you to create, view, and list IP Assets on Story Protocol.
|
1343
1653
|
*/
|
1344
|
-
var
|
1345
|
-
|
1346
|
-
|
1347
|
-
|
1654
|
+
var IPAssetClient = /*#__PURE__*/function (_IPAssetReadOnlyClien) {
|
1655
|
+
_inherits(IPAssetClient, _IPAssetReadOnlyClien);
|
1656
|
+
var _super = _createSuper(IPAssetClient);
|
1657
|
+
function IPAssetClient(httpClient, franchiseRegistry, signer) {
|
1658
|
+
var _this;
|
1659
|
+
_classCallCheck(this, IPAssetClient);
|
1660
|
+
_this = _super.call(this, httpClient, franchiseRegistry);
|
1661
|
+
_this.signer = signer;
|
1662
|
+
return _this;
|
1348
1663
|
}
|
1349
1664
|
|
1350
1665
|
/**
|
1351
|
-
* Get
|
1666
|
+
* Get the ipAssetRegistry associated with a franchiseId.
|
1352
1667
|
*
|
1353
|
-
* @
|
1354
|
-
* @returns the response object that contains the fetched transaction object
|
1668
|
+
* @returns the response object that contains the requested ipAssetRegistry.
|
1355
1669
|
*/
|
1356
|
-
_createClass(
|
1357
|
-
key: "
|
1670
|
+
_createClass(IPAssetClient, [{
|
1671
|
+
key: "getRegistry",
|
1358
1672
|
value: function () {
|
1359
|
-
var
|
1360
|
-
var
|
1673
|
+
var _getRegistry = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(franchiseId) {
|
1674
|
+
var address, ipAssetRegistry;
|
1361
1675
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
1362
1676
|
while (1) switch (_context.prev = _context.next) {
|
1363
1677
|
case 0:
|
1364
1678
|
_context.prev = 0;
|
1365
1679
|
_context.next = 3;
|
1366
|
-
return this.
|
1680
|
+
return this.franchiseRegistry.ipAssetRegistryForId(franchiseId);
|
1367
1681
|
case 3:
|
1368
|
-
|
1369
|
-
|
1370
|
-
|
1371
|
-
|
1682
|
+
address = _context.sent;
|
1683
|
+
ipAssetRegistry = IpAssetRegistry__factory.connect(address, this.signer);
|
1684
|
+
return _context.abrupt("return", ipAssetRegistry);
|
1685
|
+
case 8:
|
1686
|
+
_context.prev = 8;
|
1372
1687
|
_context.t0 = _context["catch"](0);
|
1373
|
-
handleError(_context.t0, "Failed to
|
1374
|
-
case
|
1688
|
+
handleError(_context.t0, "Failed to retrieve IP Asset Registry");
|
1689
|
+
case 11:
|
1375
1690
|
case "end":
|
1376
1691
|
return _context.stop();
|
1377
1692
|
}
|
1378
|
-
}, _callee, this, [[0,
|
1693
|
+
}, _callee, this, [[0, 8]]);
|
1379
1694
|
}));
|
1380
|
-
function
|
1381
|
-
return
|
1695
|
+
function getRegistry(_x) {
|
1696
|
+
return _getRegistry.apply(this, arguments);
|
1382
1697
|
}
|
1383
|
-
return
|
1698
|
+
return getRegistry;
|
1384
1699
|
}()
|
1385
1700
|
/**
|
1386
|
-
*
|
1701
|
+
* Create an IP Asset on Story Protocol based on the specified input asset data.
|
1387
1702
|
*
|
1388
|
-
* @param request - the request object
|
1389
|
-
* @returns the response object that contains the
|
1703
|
+
* @param request - the request object that contains all data needed to create an IP Asset.
|
1704
|
+
* @returns the response object that contains results from the asset creation.
|
1390
1705
|
*/
|
1391
1706
|
}, {
|
1392
|
-
key: "
|
1707
|
+
key: "create",
|
1393
1708
|
value: function () {
|
1394
|
-
var
|
1395
|
-
var response;
|
1709
|
+
var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
|
1710
|
+
var franchiseId, ipAssetRegistry, response;
|
1396
1711
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
1397
1712
|
while (1) switch (_context2.prev = _context2.next) {
|
1398
1713
|
case 0:
|
1399
1714
|
_context2.prev = 0;
|
1400
|
-
|
1401
|
-
|
1402
|
-
|
1403
|
-
|
1404
|
-
|
1405
|
-
|
1406
|
-
|
1407
|
-
_context2.
|
1408
|
-
|
1409
|
-
case 10:
|
1410
|
-
case "end":
|
1411
|
-
return _context2.stop();
|
1412
|
-
}
|
1413
|
-
}, _callee2, this, [[0, 7]]);
|
1414
|
-
}));
|
1415
|
-
function list() {
|
1416
|
-
return _list.apply(this, arguments);
|
1417
|
-
}
|
1418
|
-
return list;
|
1419
|
-
}()
|
1420
|
-
}]);
|
1421
|
-
return TransactionClient;
|
1422
|
-
}();
|
1423
|
-
|
1424
|
-
/**
|
1425
|
-
* Client for managing relationships.
|
1426
|
-
*/
|
1427
|
-
var RelationshipClient = /*#__PURE__*/function () {
|
1428
|
-
/**
|
1429
|
-
* Creates a new RelationshipClient instance.
|
1430
|
-
* @param relationshipModule - The relationship module to interact with.
|
1431
|
-
* @param franchiseRegistry - The franchise registry to interact with.
|
1432
|
-
*/
|
1433
|
-
function RelationshipClient(relationshipModule, franchiseRegistry) {
|
1434
|
-
_classCallCheck(this, RelationshipClient);
|
1435
|
-
this.relationshipModule = relationshipModule;
|
1436
|
-
this.franchiseRegistry = franchiseRegistry;
|
1437
|
-
}
|
1438
|
-
|
1439
|
-
/**
|
1440
|
-
* Retrieves the registry addresses for source and destination franchises.
|
1441
|
-
* @param sourceFranchiseId - The ID of the source franchise.
|
1442
|
-
* @param destFranchiseId - The ID of the destination franchise.
|
1443
|
-
* @returns An object containing the source and destination IP registry addresses.
|
1444
|
-
*/
|
1445
|
-
_createClass(RelationshipClient, [{
|
1446
|
-
key: "getRegistryAddresses",
|
1447
|
-
value: function () {
|
1448
|
-
var _getRegistryAddresses = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(sourceFranchiseId, destFranchiseId) {
|
1449
|
-
var sourceIpRegistryAddress, destIpRegistryAddress;
|
1450
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
1451
|
-
while (1) switch (_context.prev = _context.next) {
|
1452
|
-
case 0:
|
1453
|
-
_context.prev = 0;
|
1454
|
-
_context.next = 3;
|
1455
|
-
return this.franchiseRegistry.ipAssetRegistryForId(sourceFranchiseId);
|
1456
|
-
case 3:
|
1457
|
-
sourceIpRegistryAddress = _context.sent;
|
1458
|
-
_context.next = 6;
|
1459
|
-
return this.franchiseRegistry.ipAssetRegistryForId(destFranchiseId);
|
1715
|
+
franchiseId = request.franchiseId;
|
1716
|
+
if (isIntegerString(franchiseId)) {
|
1717
|
+
_context2.next = 4;
|
1718
|
+
break;
|
1719
|
+
}
|
1720
|
+
throw new Error("Invalid franchise ID for IP asset creation. Must be an integer, but got: ".concat(request.franchiseId));
|
1721
|
+
case 4:
|
1722
|
+
_context2.next = 6;
|
1723
|
+
return this.getRegistry(franchiseId);
|
1460
1724
|
case 6:
|
1461
|
-
|
1462
|
-
|
1463
|
-
|
1464
|
-
|
1465
|
-
});
|
1466
|
-
case 10:
|
1467
|
-
_context.prev = 10;
|
1468
|
-
_context.t0 = _context["catch"](0);
|
1469
|
-
handleError(_context.t0, "Failed to get registry addresses");
|
1470
|
-
case 13:
|
1471
|
-
case "end":
|
1472
|
-
return _context.stop();
|
1473
|
-
}
|
1474
|
-
}, _callee, this, [[0, 10]]);
|
1475
|
-
}));
|
1476
|
-
function getRegistryAddresses(_x, _x2) {
|
1477
|
-
return _getRegistryAddresses.apply(this, arguments);
|
1478
|
-
}
|
1479
|
-
return getRegistryAddresses;
|
1480
|
-
}()
|
1481
|
-
/**
|
1482
|
-
* Establishes a relationship between two IP assets.
|
1483
|
-
* @param request - The request for establishing the relationship.
|
1484
|
-
* @returns A promise that resolves to the response with the transaction hash.
|
1485
|
-
*/
|
1486
|
-
}, {
|
1487
|
-
key: "relate",
|
1488
|
-
value: function () {
|
1489
|
-
var _relate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
|
1490
|
-
var sourceIPAsset, destIPAsset, mockRelationshipData, _yield$this$getRegist, sourceIpRegistryAddress, destIpRegistryAddress, relationshipId, params, response;
|
1491
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
1492
|
-
while (1) switch (_context2.prev = _context2.next) {
|
1493
|
-
case 0:
|
1494
|
-
_context2.prev = 0;
|
1495
|
-
sourceIPAsset = request.sourceIPAsset, destIPAsset = request.destIPAsset;
|
1496
|
-
mockRelationshipData = ethers.ethers.utils.formatBytes32String(""); // Get IPAssetRegistry Contract Address
|
1497
|
-
_context2.next = 5;
|
1498
|
-
return this.getRegistryAddresses(sourceIPAsset.franchiseId, destIPAsset.franchiseId);
|
1499
|
-
case 5:
|
1500
|
-
_yield$this$getRegist = _context2.sent;
|
1501
|
-
sourceIpRegistryAddress = _yield$this$getRegist.sourceIpRegistryAddress;
|
1502
|
-
destIpRegistryAddress = _yield$this$getRegist.destIpRegistryAddress;
|
1503
|
-
_context2.next = 10;
|
1504
|
-
return this.relationshipModule.getRelationshipId("APPEARS_IN");
|
1505
|
-
case 10:
|
1506
|
-
relationshipId = _context2.sent;
|
1507
|
-
params = {
|
1508
|
-
sourceContract: sourceIpRegistryAddress,
|
1509
|
-
sourceId: sourceIPAsset.ipAssetId,
|
1510
|
-
destContract: destIpRegistryAddress,
|
1511
|
-
destId: destIPAsset.ipAssetId,
|
1512
|
-
relationshipId: relationshipId,
|
1513
|
-
ttl: "0"
|
1514
|
-
};
|
1515
|
-
_context2.next = 14;
|
1516
|
-
return this.relationshipModule.relate(params, mockRelationshipData);
|
1517
|
-
case 14:
|
1725
|
+
ipAssetRegistry = _context2.sent;
|
1726
|
+
_context2.next = 9;
|
1727
|
+
return ipAssetRegistry.createIPAsset(request.ipAssetType, request.ipAssetName, request.description, request.mediaUrl, request.to, request.parentIpAssetId);
|
1728
|
+
case 9:
|
1518
1729
|
response = _context2.sent;
|
1519
1730
|
return _context2.abrupt("return", {
|
1520
1731
|
txHash: response.hash
|
1521
1732
|
});
|
1522
|
-
case
|
1523
|
-
_context2.prev =
|
1733
|
+
case 13:
|
1734
|
+
_context2.prev = 13;
|
1524
1735
|
_context2.t0 = _context2["catch"](0);
|
1525
|
-
handleError(_context2.t0, "Failed to create
|
1526
|
-
case
|
1736
|
+
handleError(_context2.t0, "Failed to create IP Asset");
|
1737
|
+
case 16:
|
1527
1738
|
case "end":
|
1528
1739
|
return _context2.stop();
|
1529
1740
|
}
|
1530
|
-
}, _callee2, this, [[0,
|
1741
|
+
}, _callee2, this, [[0, 13]]);
|
1531
1742
|
}));
|
1532
|
-
function
|
1533
|
-
return
|
1743
|
+
function create(_x2) {
|
1744
|
+
return _create.apply(this, arguments);
|
1534
1745
|
}
|
1535
|
-
return
|
1746
|
+
return create;
|
1536
1747
|
}()
|
1537
|
-
|
1538
|
-
|
1539
|
-
|
1540
|
-
|
1541
|
-
|
1542
|
-
|
1543
|
-
|
1748
|
+
}]);
|
1749
|
+
return IPAssetClient;
|
1750
|
+
}(IPAssetReadOnlyClient);
|
1751
|
+
|
1752
|
+
/**
|
1753
|
+
* A class representing License operations.
|
1754
|
+
*
|
1755
|
+
* @public
|
1756
|
+
*/
|
1757
|
+
var LicenseReadOnlyClient = /*#__PURE__*/function () {
|
1758
|
+
function LicenseReadOnlyClient(httpClient, franchiseRegistry) {
|
1759
|
+
_classCallCheck(this, LicenseReadOnlyClient);
|
1760
|
+
this.httpClient = httpClient;
|
1761
|
+
this.franchiseRegistry = franchiseRegistry;
|
1762
|
+
}
|
1763
|
+
|
1764
|
+
/**
|
1765
|
+
* Get a license by its ID.
|
1766
|
+
*
|
1767
|
+
* @param licenseId - The ID of the license to retrieve.
|
1768
|
+
* @returns A Promise that resolves to the GetLicenseResponse.
|
1769
|
+
*/
|
1770
|
+
_createClass(LicenseReadOnlyClient, [{
|
1771
|
+
key: "get",
|
1544
1772
|
value: function () {
|
1545
|
-
var
|
1546
|
-
var
|
1547
|
-
return _regeneratorRuntime().wrap(function
|
1548
|
-
while (1) switch (
|
1773
|
+
var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
|
1774
|
+
var response;
|
1775
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
1776
|
+
while (1) switch (_context.prev = _context.next) {
|
1549
1777
|
case 0:
|
1550
|
-
|
1551
|
-
|
1552
|
-
|
1553
|
-
|
1554
|
-
|
1555
|
-
|
1556
|
-
|
1557
|
-
|
1558
|
-
|
1559
|
-
|
1778
|
+
_context.prev = 0;
|
1779
|
+
if (isIntegerString(request.licenseId)) {
|
1780
|
+
_context.next = 3;
|
1781
|
+
break;
|
1782
|
+
}
|
1783
|
+
throw new Error("Invalid licenseId. Must be an integer. But got: ".concat(request.licenseId));
|
1784
|
+
case 3:
|
1785
|
+
_context.next = 5;
|
1786
|
+
return this.httpClient.get("/license/".concat(request.licenseId));
|
1787
|
+
case 5:
|
1788
|
+
response = _context.sent;
|
1789
|
+
return _context.abrupt("return", response.data);
|
1560
1790
|
case 9:
|
1561
|
-
|
1562
|
-
|
1563
|
-
|
1564
|
-
|
1565
|
-
destContract: destIpRegistryAddress,
|
1566
|
-
destId: destIPAsset.ipAssetId,
|
1567
|
-
relationshipId: relationshipId,
|
1568
|
-
ttl: "0"
|
1569
|
-
};
|
1570
|
-
_context3.next = 13;
|
1571
|
-
return this.relationshipModule.unrelate(params);
|
1572
|
-
case 13:
|
1573
|
-
response = _context3.sent;
|
1574
|
-
return _context3.abrupt("return", {
|
1575
|
-
txHash: response.hash
|
1576
|
-
});
|
1577
|
-
case 17:
|
1578
|
-
_context3.prev = 17;
|
1579
|
-
_context3.t0 = _context3["catch"](0);
|
1580
|
-
handleError(_context3.t0, "Failed to unrelate relationship");
|
1581
|
-
case 20:
|
1791
|
+
_context.prev = 9;
|
1792
|
+
_context.t0 = _context["catch"](0);
|
1793
|
+
handleError(_context.t0, "Failed to get license");
|
1794
|
+
case 12:
|
1582
1795
|
case "end":
|
1583
|
-
return
|
1796
|
+
return _context.stop();
|
1584
1797
|
}
|
1585
|
-
},
|
1798
|
+
}, _callee, this, [[0, 9]]);
|
1586
1799
|
}));
|
1587
|
-
function
|
1588
|
-
return
|
1800
|
+
function get(_x) {
|
1801
|
+
return _get.apply(this, arguments);
|
1589
1802
|
}
|
1590
|
-
return
|
1803
|
+
return get;
|
1591
1804
|
}()
|
1592
1805
|
/**
|
1593
|
-
*
|
1594
|
-
*
|
1595
|
-
* @returns A
|
1806
|
+
* List all licenses.
|
1807
|
+
*
|
1808
|
+
* @returns A Promise that resolves to the ListLicenseResponse.
|
1596
1809
|
*/
|
1597
1810
|
}, {
|
1598
|
-
key: "
|
1811
|
+
key: "list",
|
1599
1812
|
value: function () {
|
1600
|
-
var
|
1601
|
-
var
|
1602
|
-
return _regeneratorRuntime().wrap(function
|
1603
|
-
while (1) switch (
|
1813
|
+
var _list = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
|
1814
|
+
var response;
|
1815
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
1816
|
+
while (1) switch (_context2.prev = _context2.next) {
|
1604
1817
|
case 0:
|
1605
|
-
|
1606
|
-
|
1607
|
-
|
1608
|
-
|
1609
|
-
|
1610
|
-
|
1611
|
-
|
1612
|
-
|
1613
|
-
|
1614
|
-
|
1615
|
-
case
|
1616
|
-
relationshipId = _context4.sent;
|
1617
|
-
params = {
|
1618
|
-
sourceContract: sourceIpRegistryAddress,
|
1619
|
-
sourceId: sourceIPAsset.ipAssetId,
|
1620
|
-
destContract: destIpRegistryAddress,
|
1621
|
-
destId: destIPAsset.ipAssetId,
|
1622
|
-
relationshipId: relationshipId,
|
1623
|
-
ttl: "0"
|
1624
|
-
};
|
1625
|
-
_context4.next = 13;
|
1626
|
-
return this.relationshipModule.isRelationshipExpired(params);
|
1627
|
-
case 13:
|
1628
|
-
response = _context4.sent;
|
1629
|
-
return _context4.abrupt("return", {
|
1630
|
-
result: response
|
1631
|
-
});
|
1632
|
-
case 17:
|
1633
|
-
_context4.prev = 17;
|
1634
|
-
_context4.t0 = _context4["catch"](0);
|
1635
|
-
handleError(_context4.t0, "Failed to get isRelationshipExpired");
|
1636
|
-
case 20:
|
1818
|
+
_context2.prev = 0;
|
1819
|
+
_context2.next = 3;
|
1820
|
+
return this.httpClient.get("/license?franchiseId=".concat(request.franchiseId, "&ipAssetId=").concat(request.ipAssetId));
|
1821
|
+
case 3:
|
1822
|
+
response = _context2.sent;
|
1823
|
+
return _context2.abrupt("return", response.data);
|
1824
|
+
case 7:
|
1825
|
+
_context2.prev = 7;
|
1826
|
+
_context2.t0 = _context2["catch"](0);
|
1827
|
+
handleError(_context2.t0, "Failed to get licenses");
|
1828
|
+
case 10:
|
1637
1829
|
case "end":
|
1638
|
-
return
|
1830
|
+
return _context2.stop();
|
1639
1831
|
}
|
1640
|
-
},
|
1832
|
+
}, _callee2, this, [[0, 7]]);
|
1641
1833
|
}));
|
1642
|
-
function
|
1643
|
-
return
|
1834
|
+
function list(_x2) {
|
1835
|
+
return _list.apply(this, arguments);
|
1644
1836
|
}
|
1645
|
-
return
|
1837
|
+
return list;
|
1646
1838
|
}()
|
1647
|
-
|
1648
|
-
|
1649
|
-
|
1650
|
-
|
1651
|
-
|
1652
|
-
|
1653
|
-
|
1839
|
+
}]);
|
1840
|
+
return LicenseReadOnlyClient;
|
1841
|
+
}();
|
1842
|
+
|
1843
|
+
/**
|
1844
|
+
* A class representing License operations.
|
1845
|
+
*
|
1846
|
+
* @public
|
1847
|
+
*/
|
1848
|
+
var LicenseClient = /*#__PURE__*/function (_LicenseReadOnlyClien) {
|
1849
|
+
_inherits(LicenseClient, _LicenseReadOnlyClien);
|
1850
|
+
var _super = _createSuper(LicenseClient);
|
1851
|
+
function LicenseClient(httpClient, signer, franchiseRegistry) {
|
1852
|
+
var _this;
|
1853
|
+
_classCallCheck(this, LicenseClient);
|
1854
|
+
_this = _super.call(this, httpClient, franchiseRegistry);
|
1855
|
+
_this.signer = signer;
|
1856
|
+
return _this;
|
1857
|
+
}
|
1858
|
+
|
1859
|
+
/**
|
1860
|
+
* Create a license within the Story Protocol based on the specified input data.
|
1861
|
+
*
|
1862
|
+
* @param request - An object containing the necessary data to create a license.
|
1863
|
+
* @returns A response object containing the result of the create license action, including the transaction hash.
|
1864
|
+
*/
|
1865
|
+
_createClass(LicenseClient, [{
|
1866
|
+
key: "create",
|
1654
1867
|
value: function () {
|
1655
|
-
var
|
1656
|
-
var
|
1657
|
-
return _regeneratorRuntime().wrap(function
|
1658
|
-
while (1) switch (
|
1868
|
+
var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
|
1869
|
+
var defaults, franchiseId, ipAssetId, licenseURI, options, walletAddress, ipAssetRegistryAddress, ipAssetRegistry, parentLicenseId, createResponse;
|
1870
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
1871
|
+
while (1) switch (_context.prev = _context.next) {
|
1659
1872
|
case 0:
|
1660
|
-
|
1661
|
-
|
1662
|
-
|
1663
|
-
|
1664
|
-
|
1665
|
-
|
1666
|
-
|
1667
|
-
|
1668
|
-
|
1669
|
-
|
1670
|
-
|
1671
|
-
|
1672
|
-
|
1673
|
-
|
1674
|
-
|
1675
|
-
|
1676
|
-
|
1677
|
-
|
1678
|
-
|
1873
|
+
_context.prev = 0;
|
1874
|
+
defaults = {
|
1875
|
+
_tokenId: 0,
|
1876
|
+
// Assuming BigNumberish can be initialized with 0
|
1877
|
+
_parentLicenseId: "0",
|
1878
|
+
_licenseHolder: "0x8e3B91c90561523312f32B49DAAc4AD15293De7F",
|
1879
|
+
// An empty string for a default holder address
|
1880
|
+
_uri: "https://example.xyz",
|
1881
|
+
// An empty string for a default URI
|
1882
|
+
_revoker: "0x8e3B91c90561523312f32B49DAAc4AD15293De7F",
|
1883
|
+
// An empty string for a default revoker address
|
1884
|
+
_commercial: false,
|
1885
|
+
// Default to non-commercial
|
1886
|
+
_canSublicense: false,
|
1887
|
+
// Default to not allowing sublicense
|
1888
|
+
_terms: {
|
1889
|
+
processor: ethers.constants.AddressZero,
|
1890
|
+
data: []
|
1891
|
+
},
|
1892
|
+
overrides: {
|
1893
|
+
// Assuming overrides is an object with properties from and gasLimit
|
1894
|
+
// You may need to provide default values for its properties as well
|
1895
|
+
}
|
1679
1896
|
};
|
1680
|
-
|
1681
|
-
|
1682
|
-
|
1683
|
-
|
1684
|
-
|
1685
|
-
|
1897
|
+
franchiseId = request.franchiseId, ipAssetId = request.ipAssetId, licenseURI = request.licenseURI, options = request.options; // Get Wallet address from Signer
|
1898
|
+
_context.next = 5;
|
1899
|
+
return this.signer.getAddress();
|
1900
|
+
case 5:
|
1901
|
+
walletAddress = _context.sent;
|
1902
|
+
_context.next = 8;
|
1903
|
+
return this.franchiseRegistry.ipAssetRegistryForId(franchiseId);
|
1904
|
+
case 8:
|
1905
|
+
ipAssetRegistryAddress = _context.sent;
|
1906
|
+
// Connect to IPAssetRegistry Contract
|
1907
|
+
ipAssetRegistry = IpAssetRegistry__factory.connect(ipAssetRegistryAddress, this.signer); // Get parent license Id
|
1908
|
+
_context.next = 12;
|
1909
|
+
return ipAssetRegistry.getLicenseIdByTokenId(ipAssetId, (options === null || options === void 0 ? void 0 : options.isCommercial) || defaults._commercial);
|
1910
|
+
case 12:
|
1911
|
+
parentLicenseId = _context.sent;
|
1912
|
+
_context.next = 15;
|
1913
|
+
return ipAssetRegistry.createLicense(ipAssetId, parentLicenseId, walletAddress, licenseURI, (options === null || options === void 0 ? void 0 : options.revoker) || defaults._revoker, (options === null || options === void 0 ? void 0 : options.isCommercial) || defaults._commercial, (options === null || options === void 0 ? void 0 : options.isSublicensable) || defaults._canSublicense, (options === null || options === void 0 ? void 0 : options.terms) || defaults._terms);
|
1914
|
+
case 15:
|
1915
|
+
createResponse = _context.sent;
|
1916
|
+
return _context.abrupt("return", {
|
1917
|
+
txHash: createResponse.hash
|
1686
1918
|
});
|
1687
|
-
case
|
1688
|
-
|
1689
|
-
|
1690
|
-
handleError(
|
1691
|
-
case
|
1919
|
+
case 19:
|
1920
|
+
_context.prev = 19;
|
1921
|
+
_context.t0 = _context["catch"](0);
|
1922
|
+
handleError(_context.t0, "Failed to create license");
|
1923
|
+
case 22:
|
1692
1924
|
case "end":
|
1693
|
-
return
|
1925
|
+
return _context.stop();
|
1694
1926
|
}
|
1695
|
-
},
|
1927
|
+
}, _callee, this, [[0, 19]]);
|
1696
1928
|
}));
|
1697
|
-
function
|
1698
|
-
return
|
1929
|
+
function create(_x) {
|
1930
|
+
return _create.apply(this, arguments);
|
1699
1931
|
}
|
1700
|
-
return
|
1932
|
+
return create;
|
1701
1933
|
}()
|
1702
1934
|
}]);
|
1703
|
-
return
|
1704
|
-
}();
|
1935
|
+
return LicenseClient;
|
1936
|
+
}(LicenseReadOnlyClient);
|
1705
1937
|
|
1706
1938
|
/**
|
1707
|
-
*
|
1939
|
+
* TransactionClient allows you to view and monitor transactions on
|
1940
|
+
* Story Protocol.
|
1708
1941
|
*/
|
1709
|
-
var
|
1710
|
-
function
|
1711
|
-
_classCallCheck(this,
|
1942
|
+
var TransactionReadOnlyClient = /*#__PURE__*/function () {
|
1943
|
+
function TransactionReadOnlyClient(httpClient) {
|
1944
|
+
_classCallCheck(this, TransactionReadOnlyClient);
|
1712
1945
|
this.httpClient = httpClient;
|
1713
|
-
this.franchiseRegistry = franchiseRegistry;
|
1714
|
-
this.signer = signer;
|
1715
1946
|
}
|
1716
1947
|
|
1717
1948
|
/**
|
1718
|
-
* Get
|
1949
|
+
* Get transaction data based on the specified transaction id.
|
1719
1950
|
*
|
1720
|
-
* @
|
1951
|
+
* @param request - the request object for getting the transaction
|
1952
|
+
* @returns the response object that contains the fetched transaction object
|
1721
1953
|
*/
|
1722
|
-
_createClass(
|
1723
|
-
key: "
|
1954
|
+
_createClass(TransactionReadOnlyClient, [{
|
1955
|
+
key: "get",
|
1724
1956
|
value: function () {
|
1725
|
-
var
|
1726
|
-
var
|
1957
|
+
var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
|
1958
|
+
var response;
|
1727
1959
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
1728
1960
|
while (1) switch (_context.prev = _context.next) {
|
1729
1961
|
case 0:
|
1730
1962
|
_context.prev = 0;
|
1731
1963
|
_context.next = 3;
|
1732
|
-
return this.
|
1964
|
+
return this.httpClient.get("/transaction/".concat(request.txId));
|
1733
1965
|
case 3:
|
1734
|
-
|
1735
|
-
|
1736
|
-
|
1737
|
-
|
1738
|
-
_context.prev = 8;
|
1966
|
+
response = _context.sent;
|
1967
|
+
return _context.abrupt("return", response.data);
|
1968
|
+
case 7:
|
1969
|
+
_context.prev = 7;
|
1739
1970
|
_context.t0 = _context["catch"](0);
|
1740
|
-
handleError(_context.t0, "Failed to
|
1741
|
-
case
|
1971
|
+
handleError(_context.t0, "Failed to get transaction");
|
1972
|
+
case 10:
|
1742
1973
|
case "end":
|
1743
1974
|
return _context.stop();
|
1744
1975
|
}
|
1745
|
-
}, _callee, this, [[0,
|
1976
|
+
}, _callee, this, [[0, 7]]);
|
1746
1977
|
}));
|
1747
|
-
function
|
1748
|
-
return
|
1978
|
+
function get(_x) {
|
1979
|
+
return _get.apply(this, arguments);
|
1749
1980
|
}
|
1750
|
-
return
|
1981
|
+
return get;
|
1751
1982
|
}()
|
1752
1983
|
/**
|
1753
|
-
* Get
|
1984
|
+
* Get transaction data based on the specified transaction id.
|
1754
1985
|
*
|
1755
|
-
* @param request - the request object for getting
|
1756
|
-
* @returns the response object
|
1986
|
+
* @param request - the request object for getting the transactions
|
1987
|
+
* @returns the response object that contains the fetched transaction object
|
1757
1988
|
*/
|
1758
1989
|
}, {
|
1759
|
-
key: "
|
1990
|
+
key: "list",
|
1760
1991
|
value: function () {
|
1761
|
-
var
|
1992
|
+
var _list = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
1762
1993
|
var response;
|
1763
1994
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
1764
1995
|
while (1) switch (_context2.prev = _context2.next) {
|
1765
1996
|
case 0:
|
1766
1997
|
_context2.prev = 0;
|
1767
|
-
|
1768
|
-
|
1769
|
-
break;
|
1770
|
-
}
|
1771
|
-
throw new Error("Invalid IP Asset id. Must be an integer. But get: ".concat(request.ipAssetId));
|
1998
|
+
_context2.next = 3;
|
1999
|
+
return this.httpClient.get("/transaction");
|
1772
2000
|
case 3:
|
1773
|
-
_context2.next = 5;
|
1774
|
-
return this.httpClient.get("/ipasset/".concat(request.ipAssetId, "?franchiseId=").concat(request.franchiseId));
|
1775
|
-
case 5:
|
1776
2001
|
response = _context2.sent;
|
1777
2002
|
return _context2.abrupt("return", response.data);
|
1778
|
-
case 9:
|
1779
|
-
_context2.prev = 9;
|
1780
|
-
_context2.t0 = _context2["catch"](0);
|
1781
|
-
handleError(_context2.t0, "Failed to get IP Asset");
|
1782
|
-
case 12:
|
1783
|
-
case "end":
|
1784
|
-
return _context2.stop();
|
1785
|
-
}
|
1786
|
-
}, _callee2, this, [[0, 9]]);
|
1787
|
-
}));
|
1788
|
-
function get(_x2) {
|
1789
|
-
return _get.apply(this, arguments);
|
1790
|
-
}
|
1791
|
-
return get;
|
1792
|
-
}()
|
1793
|
-
/**
|
1794
|
-
* Create an IP Asset on Story Protocol based on the specified input asset data.
|
1795
|
-
*
|
1796
|
-
* @param request - the request object that contains all data needed to create an IP Asset.
|
1797
|
-
* @returns the response object that contains results from the asset creation.
|
1798
|
-
*/
|
1799
|
-
}, {
|
1800
|
-
key: "create",
|
1801
|
-
value: function () {
|
1802
|
-
var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(request) {
|
1803
|
-
var franchiseId, ipAssetRegistry, response;
|
1804
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
1805
|
-
while (1) switch (_context3.prev = _context3.next) {
|
1806
|
-
case 0:
|
1807
|
-
_context3.prev = 0;
|
1808
|
-
franchiseId = request.franchiseId;
|
1809
|
-
if (isIntegerString(franchiseId)) {
|
1810
|
-
_context3.next = 4;
|
1811
|
-
break;
|
1812
|
-
}
|
1813
|
-
throw new Error("Invalid franchise ID for IP asset creation. Must be an integer, but got: ".concat(request.franchiseId));
|
1814
|
-
case 4:
|
1815
|
-
_context3.next = 6;
|
1816
|
-
return this.getRegistry(franchiseId);
|
1817
|
-
case 6:
|
1818
|
-
ipAssetRegistry = _context3.sent;
|
1819
|
-
_context3.next = 9;
|
1820
|
-
return ipAssetRegistry.createIPAsset(request.ipAssetType, request.ipAssetName, request.description, request.mediaUrl, request.to, request.parentIpAssetId);
|
1821
|
-
case 9:
|
1822
|
-
response = _context3.sent;
|
1823
|
-
return _context3.abrupt("return", {
|
1824
|
-
txHash: response.hash
|
1825
|
-
});
|
1826
|
-
case 13:
|
1827
|
-
_context3.prev = 13;
|
1828
|
-
_context3.t0 = _context3["catch"](0);
|
1829
|
-
handleError(_context3.t0, "Failed to create IP Asset");
|
1830
|
-
case 16:
|
1831
|
-
case "end":
|
1832
|
-
return _context3.stop();
|
1833
|
-
}
|
1834
|
-
}, _callee3, this, [[0, 13]]);
|
1835
|
-
}));
|
1836
|
-
function create(_x3) {
|
1837
|
-
return _create.apply(this, arguments);
|
1838
|
-
}
|
1839
|
-
return create;
|
1840
|
-
}()
|
1841
|
-
/**
|
1842
|
-
* List all IP assets.
|
1843
|
-
*
|
1844
|
-
* @returns the response object that contains results from listing query.
|
1845
|
-
*/
|
1846
|
-
}, {
|
1847
|
-
key: "list",
|
1848
|
-
value: function () {
|
1849
|
-
var _list = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(request) {
|
1850
|
-
var response;
|
1851
|
-
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
1852
|
-
while (1) switch (_context4.prev = _context4.next) {
|
1853
|
-
case 0:
|
1854
|
-
_context4.prev = 0;
|
1855
|
-
_context4.next = 3;
|
1856
|
-
return this.httpClient.get("/ipasset?franchiseId=".concat(request.franchiseId));
|
1857
|
-
case 3:
|
1858
|
-
response = _context4.sent;
|
1859
|
-
return _context4.abrupt("return", response.data);
|
1860
2003
|
case 7:
|
1861
|
-
|
1862
|
-
|
1863
|
-
handleError(
|
2004
|
+
_context2.prev = 7;
|
2005
|
+
_context2.t0 = _context2["catch"](0);
|
2006
|
+
handleError(_context2.t0, "Failed to get transactions");
|
1864
2007
|
case 10:
|
1865
2008
|
case "end":
|
1866
|
-
return
|
2009
|
+
return _context2.stop();
|
1867
2010
|
}
|
1868
|
-
},
|
2011
|
+
}, _callee2, this, [[0, 7]]);
|
1869
2012
|
}));
|
1870
|
-
function list(
|
2013
|
+
function list() {
|
1871
2014
|
return _list.apply(this, arguments);
|
1872
2015
|
}
|
1873
2016
|
return list;
|
1874
2017
|
}()
|
1875
2018
|
}]);
|
1876
|
-
return
|
2019
|
+
return TransactionReadOnlyClient;
|
1877
2020
|
}();
|
1878
2021
|
|
1879
2022
|
/**
|
1880
|
-
*
|
2023
|
+
* TransactionClient allows you to view and monitor transactions on
|
2024
|
+
* Story Protocol.
|
1881
2025
|
*/
|
1882
|
-
var
|
2026
|
+
var TransactionClient = /*#__PURE__*/function (_TransactionReadOnlyC) {
|
2027
|
+
_inherits(TransactionClient, _TransactionReadOnlyC);
|
2028
|
+
var _super = _createSuper(TransactionClient);
|
2029
|
+
function TransactionClient(httpClient) {
|
2030
|
+
_classCallCheck(this, TransactionClient);
|
2031
|
+
return _super.call(this, httpClient);
|
2032
|
+
}
|
2033
|
+
return _createClass(TransactionClient);
|
2034
|
+
}(TransactionReadOnlyClient);
|
1883
2035
|
|
1884
|
-
var
|
1885
|
-
function
|
1886
|
-
_classCallCheck(this,
|
2036
|
+
var CollectReadOnlyClient = /*#__PURE__*/function () {
|
2037
|
+
function CollectReadOnlyClient(httpClient, collectModule) {
|
2038
|
+
_classCallCheck(this, CollectReadOnlyClient);
|
1887
2039
|
this.httpClient = httpClient;
|
1888
|
-
this.signer = signer;
|
1889
2040
|
this.collectModuleContract = collectModule;
|
1890
2041
|
}
|
1891
2042
|
|
@@ -1894,7 +2045,7 @@ var CollectClient = /*#__PURE__*/function () {
|
|
1894
2045
|
*
|
1895
2046
|
* @returns A Promise that resolves to the ListLicenseResponse.
|
1896
2047
|
*/
|
1897
|
-
_createClass(
|
2048
|
+
_createClass(CollectReadOnlyClient, [{
|
1898
2049
|
key: "list",
|
1899
2050
|
value: function () {
|
1900
2051
|
var _list = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
|
@@ -1923,22 +2074,37 @@ var CollectClient = /*#__PURE__*/function () {
|
|
1923
2074
|
}
|
1924
2075
|
return list;
|
1925
2076
|
}()
|
1926
|
-
|
1927
|
-
|
1928
|
-
|
1929
|
-
|
1930
|
-
|
1931
|
-
|
1932
|
-
|
2077
|
+
}]);
|
2078
|
+
return CollectReadOnlyClient;
|
2079
|
+
}();
|
2080
|
+
|
2081
|
+
var CollectClient = /*#__PURE__*/function (_CollectReadOnlyClien) {
|
2082
|
+
_inherits(CollectClient, _CollectReadOnlyClien);
|
2083
|
+
var _super = _createSuper(CollectClient);
|
2084
|
+
function CollectClient(httpClient, signer, collectModule) {
|
2085
|
+
var _this;
|
2086
|
+
_classCallCheck(this, CollectClient);
|
2087
|
+
_this = _super.call(this, httpClient, collectModule);
|
2088
|
+
_this.signer = signer;
|
2089
|
+
return _this;
|
2090
|
+
}
|
2091
|
+
|
2092
|
+
/**
|
2093
|
+
* Collect an IP Asset on Story Protocol based on the specified input collect data.
|
2094
|
+
*
|
2095
|
+
* @param request - the request object that contains all data needed to collect an IP Asset
|
2096
|
+
* @returns the response object that contains results from the create franchise action
|
2097
|
+
*/
|
2098
|
+
_createClass(CollectClient, [{
|
1933
2099
|
key: "collect",
|
1934
2100
|
value: function () {
|
1935
|
-
var _collect = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
2101
|
+
var _collect = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
|
1936
2102
|
var response;
|
1937
|
-
return _regeneratorRuntime().wrap(function
|
1938
|
-
while (1) switch (
|
2103
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
2104
|
+
while (1) switch (_context.prev = _context.next) {
|
1939
2105
|
case 0:
|
1940
|
-
|
1941
|
-
|
2106
|
+
_context.prev = 0;
|
2107
|
+
_context.next = 3;
|
1942
2108
|
return this.collectModuleContract.collect({
|
1943
2109
|
franchiseId: request.franchiseId,
|
1944
2110
|
ipAssetId: request.ipAssetId,
|
@@ -1948,28 +2114,33 @@ var CollectClient = /*#__PURE__*/function () {
|
|
1948
2114
|
collectNFTData: "0x"
|
1949
2115
|
});
|
1950
2116
|
case 3:
|
1951
|
-
response =
|
1952
|
-
return
|
2117
|
+
response = _context.sent;
|
2118
|
+
return _context.abrupt("return", {
|
1953
2119
|
txHash: response.hash
|
1954
2120
|
});
|
1955
2121
|
case 7:
|
1956
|
-
|
1957
|
-
|
1958
|
-
handleError(
|
2122
|
+
_context.prev = 7;
|
2123
|
+
_context.t0 = _context["catch"](0);
|
2124
|
+
handleError(_context.t0, "Failed to collect IP Asset");
|
1959
2125
|
case 10:
|
1960
2126
|
case "end":
|
1961
|
-
return
|
2127
|
+
return _context.stop();
|
1962
2128
|
}
|
1963
|
-
},
|
2129
|
+
}, _callee, this, [[0, 7]]);
|
1964
2130
|
}));
|
1965
|
-
function collect(
|
2131
|
+
function collect(_x) {
|
1966
2132
|
return _collect.apply(this, arguments);
|
1967
2133
|
}
|
1968
2134
|
return collect;
|
1969
2135
|
}()
|
1970
2136
|
}]);
|
1971
2137
|
return CollectClient;
|
1972
|
-
}();
|
2138
|
+
}(CollectReadOnlyClient);
|
2139
|
+
|
2140
|
+
/**
|
2141
|
+
* Default timeout value for http clients.
|
2142
|
+
*/
|
2143
|
+
var HTTP_TIMEOUT = 5000;
|
1973
2144
|
|
1974
2145
|
if (typeof process !== "undefined") {
|
1975
2146
|
dotenv__namespace.config();
|
@@ -1982,17 +2153,21 @@ var StoryClient = /*#__PURE__*/function () {
|
|
1982
2153
|
* @param config - the configuration for the SDK client
|
1983
2154
|
*/
|
1984
2155
|
function StoryClient(config) {
|
2156
|
+
var isReadOnly = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
1985
2157
|
_classCallCheck(this, StoryClient);
|
2158
|
+
_defineProperty(this, "isReadOnly", false);
|
1986
2159
|
_defineProperty(this, "_franchise", null);
|
1987
|
-
_defineProperty(this, "_relationship", null);
|
1988
|
-
_defineProperty(this, "_ipAsset", null);
|
1989
2160
|
_defineProperty(this, "_license", null);
|
1990
2161
|
_defineProperty(this, "_transaction", null);
|
2162
|
+
_defineProperty(this, "_ipAsset", null);
|
1991
2163
|
_defineProperty(this, "_collect", null);
|
2164
|
+
_defineProperty(this, "_relationship", null);
|
1992
2165
|
if (config.environment !== Environment.TEST) {
|
1993
2166
|
throw new Error("Invalid Environment: Only TEST environment is supported");
|
1994
2167
|
}
|
1995
2168
|
this.config = config;
|
2169
|
+
this.isReadOnly = isReadOnly;
|
2170
|
+
this.signerOrProvider = isReadOnly ? this.config.provider || new ethers.ethers.providers.JsonRpcProvider() : this.config.signer;
|
1996
2171
|
this.httpClient = axios__default["default"].create({
|
1997
2172
|
baseURL: process.env.API_BASE_URL || process.env.NEXT_PUBLIC_API_BASE_URL,
|
1998
2173
|
timeout: HTTP_TIMEOUT
|
@@ -2000,20 +2175,90 @@ var StoryClient = /*#__PURE__*/function () {
|
|
2000
2175
|
}
|
2001
2176
|
|
2002
2177
|
/**
|
2003
|
-
*
|
2004
|
-
* this method is called.
|
2178
|
+
* Factory method for creating a read only SDK client.
|
2005
2179
|
*
|
2006
|
-
* @
|
2180
|
+
* @param config - the configuration for a read only SDK client
|
2007
2181
|
*/
|
2008
2182
|
_createClass(StoryClient, [{
|
2183
|
+
key: "initFranchise",
|
2184
|
+
value: function initFranchise() {
|
2185
|
+
var franchiseRegistryContract = process.env.FRANCHISE_REGISTRY_CONTRACT || process.env.NEXT_PUBLIC_FRANCHISE_REGISTRY_CONTRACT;
|
2186
|
+
var licenseModuleContract = process.env.LICENSING_MODULE_CONTRACT || process.env.NEXT_PUBLIC_LICENSING_MODULE_CONTRACT;
|
2187
|
+
var franchiseRegistry = FranchiseRegistry__factory.connect(franchiseRegistryContract, this.signerOrProvider);
|
2188
|
+
var licenseModule = LicensingModule__factory.connect(licenseModuleContract, this.signerOrProvider);
|
2189
|
+
if (this.isReadOnly) {
|
2190
|
+
this._franchise = new FranchiseReadOnlyClient(this.httpClient, franchiseRegistry, licenseModule);
|
2191
|
+
} else {
|
2192
|
+
this._franchise = new FranchiseClient(this.httpClient, franchiseRegistry, licenseModule);
|
2193
|
+
}
|
2194
|
+
}
|
2195
|
+
}, {
|
2196
|
+
key: "initRelationship",
|
2197
|
+
value: function initRelationship() {
|
2198
|
+
var franchiseRegistryContract = process.env.FRANCHISE_REGISTRY_CONTRACT || process.env.NEXT_PUBLIC_FRANCHISE_REGISTRY_CONTRACT;
|
2199
|
+
var relationshipModuleContract = process.env.RELATIONSHIP_MODULE_CONTRACT || process.env.NEXT_PUBLIC_RELATIONSHIP_MODULE_CONTRACT;
|
2200
|
+
var franchiseRegistry = FranchiseRegistry__factory.connect(franchiseRegistryContract, this.signerOrProvider);
|
2201
|
+
var relationshipModule = RelationshipModule__factory.connect(relationshipModuleContract, this.signerOrProvider);
|
2202
|
+
if (this.isReadOnly) {
|
2203
|
+
this._relationship = new RelationshipReadOnlyClient(relationshipModule, franchiseRegistry);
|
2204
|
+
} else {
|
2205
|
+
this._relationship = new RelationshipClient(relationshipModule, franchiseRegistry);
|
2206
|
+
}
|
2207
|
+
}
|
2208
|
+
}, {
|
2209
|
+
key: "initIpAsset",
|
2210
|
+
value: function initIpAsset() {
|
2211
|
+
var franchiseRegistryContract = process.env.FRANCHISE_REGISTRY_CONTRACT || process.env.NEXT_PUBLIC_FRANCHISE_REGISTRY_CONTRACT;
|
2212
|
+
var franchiseRegistry = FranchiseRegistry__factory.connect(franchiseRegistryContract, this.signerOrProvider);
|
2213
|
+
if (this.isReadOnly) {
|
2214
|
+
this._ipAsset = new IPAssetReadOnlyClient(this.httpClient, franchiseRegistry);
|
2215
|
+
} else {
|
2216
|
+
this._ipAsset = new IPAssetClient(this.httpClient, franchiseRegistry, this.signerOrProvider);
|
2217
|
+
}
|
2218
|
+
}
|
2219
|
+
}, {
|
2220
|
+
key: "initLicense",
|
2221
|
+
value: function initLicense() {
|
2222
|
+
var franchiseRegistryContract = process.env.FRANCHISE_REGISTRY_CONTRACT || process.env.NEXT_PUBLIC_FRANCHISE_REGISTRY_CONTRACT;
|
2223
|
+
var franchiseRegistry = FranchiseRegistry__factory.connect(franchiseRegistryContract, this.signerOrProvider);
|
2224
|
+
if (this.isReadOnly) {
|
2225
|
+
this._license = new LicenseReadOnlyClient(this.httpClient, franchiseRegistry);
|
2226
|
+
} else {
|
2227
|
+
this._license = new LicenseClient(this.httpClient, this.signerOrProvider, franchiseRegistry);
|
2228
|
+
}
|
2229
|
+
}
|
2230
|
+
}, {
|
2231
|
+
key: "initTransaction",
|
2232
|
+
value: function initTransaction() {
|
2233
|
+
if (this.isReadOnly) {
|
2234
|
+
this._transaction = new TransactionReadOnlyClient(this.httpClient);
|
2235
|
+
} else {
|
2236
|
+
this._transaction = new TransactionClient(this.httpClient);
|
2237
|
+
}
|
2238
|
+
}
|
2239
|
+
}, {
|
2240
|
+
key: "initCollect",
|
2241
|
+
value: function initCollect() {
|
2242
|
+
var collectModuleContract = process.env.COLLECT_MODULE_CONTRACT || process.env.NEXT_PUBLIC_COLLECT_MODULE_CONTRACT;
|
2243
|
+
var collectModule = CollectModule__factory.connect(collectModuleContract, this.signerOrProvider);
|
2244
|
+
if (this.isReadOnly) {
|
2245
|
+
this._collect = new CollectReadOnlyClient(this.httpClient, collectModule);
|
2246
|
+
} else {
|
2247
|
+
this._collect = new CollectClient(this.httpClient, this.signerOrProvider, collectModule);
|
2248
|
+
}
|
2249
|
+
}
|
2250
|
+
|
2251
|
+
/**
|
2252
|
+
* Getter for the franchise client. The client is lazily created when
|
2253
|
+
* this method is called.
|
2254
|
+
*
|
2255
|
+
* @returns the FranchiseClient or FranchiseReadOnlyClient instance
|
2256
|
+
*/
|
2257
|
+
}, {
|
2009
2258
|
key: "franchise",
|
2010
2259
|
get: function get() {
|
2011
2260
|
if (this._franchise === null) {
|
2012
|
-
|
2013
|
-
var franchiseRegistry = FranchiseRegistry__factory.connect(franchiseRegistryContract, this.config.signer);
|
2014
|
-
var licenseModuleContract = process.env.LICENSING_MODULE_CONTRACT || process.env.NEXT_PUBLIC_LICENSING_MODULE_CONTRACT;
|
2015
|
-
var licenseModule = LicensingModule__factory.connect(licenseModuleContract, this.config.signer);
|
2016
|
-
this._franchise = new FranchiseClient(this.httpClient, franchiseRegistry, licenseModule);
|
2261
|
+
this.initFranchise();
|
2017
2262
|
}
|
2018
2263
|
return this._franchise;
|
2019
2264
|
}
|
@@ -2028,11 +2273,7 @@ var StoryClient = /*#__PURE__*/function () {
|
|
2028
2273
|
key: "relationship",
|
2029
2274
|
get: function get() {
|
2030
2275
|
if (this._relationship === null) {
|
2031
|
-
|
2032
|
-
var franchiseRegistry = FranchiseRegistry__factory.connect(franchiseRegistryContract, this.config.signer);
|
2033
|
-
var relationshipModuleContract = process.env.RELATIONSHIP_MODULE_CONTRACT || process.env.NEXT_PUBLIC_RELATIONSHIP_MODULE_CONTRACT;
|
2034
|
-
var relationshipModule = RelationshipModule__factory.connect(relationshipModuleContract, this.config.signer);
|
2035
|
-
this._relationship = new RelationshipClient(relationshipModule, franchiseRegistry);
|
2276
|
+
this.initRelationship();
|
2036
2277
|
}
|
2037
2278
|
return this._relationship;
|
2038
2279
|
}
|
@@ -2046,10 +2287,8 @@ var StoryClient = /*#__PURE__*/function () {
|
|
2046
2287
|
}, {
|
2047
2288
|
key: "ipAsset",
|
2048
2289
|
get: function get() {
|
2049
|
-
var franchiseRegistryContract = process.env.FRANCHISE_REGISTRY_CONTRACT || process.env.NEXT_PUBLIC_FRANCHISE_REGISTRY_CONTRACT;
|
2050
2290
|
if (this._ipAsset === null) {
|
2051
|
-
|
2052
|
-
this._ipAsset = new IPAssetClient(this.httpClient, franchiseRegistry, this.config.signer);
|
2291
|
+
this.initIpAsset();
|
2053
2292
|
}
|
2054
2293
|
return this._ipAsset;
|
2055
2294
|
}
|
@@ -2064,9 +2303,7 @@ var StoryClient = /*#__PURE__*/function () {
|
|
2064
2303
|
key: "license",
|
2065
2304
|
get: function get() {
|
2066
2305
|
if (this._license === null) {
|
2067
|
-
|
2068
|
-
var franchiseRegistry = FranchiseRegistry__factory.connect(franchiseRegistryContract, this.config.signer);
|
2069
|
-
this._license = new LicenseClient(this.httpClient, this.config.signer, franchiseRegistry);
|
2306
|
+
this.initLicense();
|
2070
2307
|
}
|
2071
2308
|
return this._license;
|
2072
2309
|
}
|
@@ -2081,7 +2318,7 @@ var StoryClient = /*#__PURE__*/function () {
|
|
2081
2318
|
key: "transaction",
|
2082
2319
|
get: function get() {
|
2083
2320
|
if (this._transaction === null) {
|
2084
|
-
this.
|
2321
|
+
this.initTransaction();
|
2085
2322
|
}
|
2086
2323
|
return this._transaction;
|
2087
2324
|
}
|
@@ -2096,12 +2333,26 @@ var StoryClient = /*#__PURE__*/function () {
|
|
2096
2333
|
key: "collect",
|
2097
2334
|
get: function get() {
|
2098
2335
|
if (this._collect === null) {
|
2099
|
-
|
2100
|
-
var collectModule = CollectModule__factory.connect(collectModuleContract, this.config.signer);
|
2101
|
-
this._collect = new CollectClient(this.httpClient, this.config.signer, collectModule);
|
2336
|
+
this.initCollect();
|
2102
2337
|
}
|
2103
2338
|
return this._collect;
|
2104
2339
|
}
|
2340
|
+
}], [{
|
2341
|
+
key: "newReadOnlyClient",
|
2342
|
+
value: function newReadOnlyClient(config) {
|
2343
|
+
return new StoryClient(config, true);
|
2344
|
+
}
|
2345
|
+
|
2346
|
+
/**
|
2347
|
+
* Factory method for creating a SDK client with a signer.
|
2348
|
+
*
|
2349
|
+
* @param config - the configuration for a new read/write SDK client
|
2350
|
+
*/
|
2351
|
+
}, {
|
2352
|
+
key: "newClient",
|
2353
|
+
value: function newClient(config) {
|
2354
|
+
return new StoryClient(config, false);
|
2355
|
+
}
|
2105
2356
|
}]);
|
2106
2357
|
return StoryClient;
|
2107
2358
|
}();
|