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