@story-protocol/core-sdk 0.1.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/README.md +0 -0
  2. package/dist/declarations/src/abi/generated/CollectModule.d.ts +70 -0
  3. package/dist/declarations/src/abi/generated/CollectModule.d.ts.map +1 -0
  4. package/dist/declarations/src/abi/generated/FranchiseRegistry.d.ts +73 -0
  5. package/dist/declarations/src/abi/generated/FranchiseRegistry.d.ts.map +1 -0
  6. package/dist/declarations/src/abi/generated/IpAssetRegistry.d.ts +94 -0
  7. package/dist/declarations/src/abi/generated/IpAssetRegistry.d.ts.map +1 -0
  8. package/dist/declarations/src/abi/generated/LicensingModule.d.ts +97 -0
  9. package/dist/declarations/src/abi/generated/LicensingModule.d.ts.map +1 -0
  10. package/dist/declarations/src/abi/generated/RelationshipModule.d.ts +116 -0
  11. package/dist/declarations/src/abi/generated/RelationshipModule.d.ts.map +1 -0
  12. package/dist/declarations/src/abi/generated/common.d.ts +22 -0
  13. package/dist/declarations/src/abi/generated/common.d.ts.map +1 -0
  14. package/dist/declarations/src/abi/generated/factories/CollectModule__factory.d.ts +52 -0
  15. package/dist/declarations/src/abi/generated/factories/CollectModule__factory.d.ts.map +1 -0
  16. package/dist/declarations/src/abi/generated/factories/FranchiseRegistry__factory.d.ts +58 -0
  17. package/dist/declarations/src/abi/generated/factories/FranchiseRegistry__factory.d.ts.map +1 -0
  18. package/dist/declarations/src/abi/generated/factories/IpAssetRegistry__factory.d.ts +112 -0
  19. package/dist/declarations/src/abi/generated/factories/IpAssetRegistry__factory.d.ts.map +1 -0
  20. package/dist/declarations/src/abi/generated/factories/LicensingModule__factory.d.ts +88 -0
  21. package/dist/declarations/src/abi/generated/factories/LicensingModule__factory.d.ts.map +1 -0
  22. package/dist/declarations/src/abi/generated/factories/RelationshipModule__factory.d.ts +175 -0
  23. package/dist/declarations/src/abi/generated/factories/RelationshipModule__factory.d.ts.map +1 -0
  24. package/dist/declarations/src/abi/generated/factories/index.d.ts +6 -0
  25. package/dist/declarations/src/abi/generated/factories/index.d.ts.map +1 -0
  26. package/dist/declarations/src/abi/generated/index.d.ts +12 -0
  27. package/dist/declarations/src/abi/generated/index.d.ts.map +1 -0
  28. package/dist/declarations/src/client.d.ts +67 -0
  29. package/dist/declarations/src/client.d.ts.map +1 -0
  30. package/dist/declarations/src/enums/environment.d.ts +8 -0
  31. package/dist/declarations/src/enums/environment.d.ts.map +1 -0
  32. package/dist/declarations/src/enums/ipAssetType.d.ts +13 -0
  33. package/dist/declarations/src/enums/ipAssetType.d.ts.map +1 -0
  34. package/dist/declarations/src/index.d.ts +5 -0
  35. package/dist/declarations/src/index.d.ts.map +1 -0
  36. package/dist/declarations/src/interfaces/config.d.ts +12 -0
  37. package/dist/declarations/src/interfaces/config.d.ts.map +1 -0
  38. package/dist/declarations/src/interfaces/resources/collect.d.ts +45 -0
  39. package/dist/declarations/src/interfaces/resources/collect.d.ts.map +1 -0
  40. package/dist/declarations/src/interfaces/resources/franchise.d.ts +70 -0
  41. package/dist/declarations/src/interfaces/resources/franchise.d.ts.map +1 -0
  42. package/dist/declarations/src/interfaces/resources/ipAsset.d.ts +70 -0
  43. package/dist/declarations/src/interfaces/resources/ipAsset.d.ts.map +1 -0
  44. package/dist/declarations/src/interfaces/resources/license.d.ts +78 -0
  45. package/dist/declarations/src/interfaces/resources/license.d.ts.map +1 -0
  46. package/dist/declarations/src/interfaces/resources/relationship.d.ts +83 -0
  47. package/dist/declarations/src/interfaces/resources/relationship.d.ts.map +1 -0
  48. package/dist/declarations/src/interfaces/resources/transaction.d.ts +46 -0
  49. package/dist/declarations/src/interfaces/resources/transaction.d.ts.map +1 -0
  50. package/dist/declarations/src/resources/collect.d.ts +24 -0
  51. package/dist/declarations/src/resources/collect.d.ts.map +1 -0
  52. package/dist/declarations/src/resources/franchise.d.ts +41 -0
  53. package/dist/declarations/src/resources/franchise.d.ts.map +1 -0
  54. package/dist/declarations/src/resources/ipAsset.d.ts +40 -0
  55. package/dist/declarations/src/resources/ipAsset.d.ts.map +1 -0
  56. package/dist/declarations/src/resources/license.d.ts +36 -0
  57. package/dist/declarations/src/resources/license.d.ts.map +1 -0
  58. package/dist/declarations/src/resources/relationship.d.ts +48 -0
  59. package/dist/declarations/src/resources/relationship.d.ts.map +1 -0
  60. package/dist/declarations/src/resources/transaction.d.ts +25 -0
  61. package/dist/declarations/src/resources/transaction.d.ts.map +1 -0
  62. package/dist/story-protocol-core-sdk.cjs.d.ts +2 -0
  63. package/dist/story-protocol-core-sdk.cjs.d.ts.map +1 -0
  64. package/dist/story-protocol-core-sdk.cjs.dev.js +2101 -0
  65. package/dist/story-protocol-core-sdk.cjs.js +7 -0
  66. package/dist/story-protocol-core-sdk.cjs.prod.js +2101 -0
  67. package/dist/story-protocol-core-sdk.esm.js +2073 -0
  68. package/package.json +88 -0
@@ -0,0 +1,2101 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var axios = require('axios');
6
+ var dotenv = require('dotenv');
7
+ var ethers = require('ethers');
8
+
9
+ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
10
+
11
+ function _interopNamespace(e) {
12
+ if (e && e.__esModule) return e;
13
+ var n = Object.create(null);
14
+ if (e) {
15
+ Object.keys(e).forEach(function (k) {
16
+ if (k !== 'default') {
17
+ var d = Object.getOwnPropertyDescriptor(e, k);
18
+ Object.defineProperty(n, k, d.get ? d : {
19
+ enumerable: true,
20
+ get: function () { return e[k]; }
21
+ });
22
+ }
23
+ });
24
+ }
25
+ n["default"] = e;
26
+ return Object.freeze(n);
27
+ }
28
+
29
+ var axios__default = /*#__PURE__*/_interopDefault(axios);
30
+ var dotenv__namespace = /*#__PURE__*/_interopNamespace(dotenv);
31
+
32
+ function _classCallCheck(instance, Constructor) {
33
+ if (!(instance instanceof Constructor)) {
34
+ throw new TypeError("Cannot call a class as a function");
35
+ }
36
+ }
37
+
38
+ function _toPrimitive(input, hint) {
39
+ if (typeof input !== "object" || input === null) return input;
40
+ var prim = input[Symbol.toPrimitive];
41
+ if (prim !== undefined) {
42
+ var res = prim.call(input, hint || "default");
43
+ if (typeof res !== "object") return res;
44
+ throw new TypeError("@@toPrimitive must return a primitive value.");
45
+ }
46
+ return (hint === "string" ? String : Number)(input);
47
+ }
48
+
49
+ function _toPropertyKey(arg) {
50
+ var key = _toPrimitive(arg, "string");
51
+ return typeof key === "symbol" ? key : String(key);
52
+ }
53
+
54
+ function _defineProperties(target, props) {
55
+ for (var i = 0; i < props.length; i++) {
56
+ var descriptor = props[i];
57
+ descriptor.enumerable = descriptor.enumerable || false;
58
+ descriptor.configurable = true;
59
+ if ("value" in descriptor) descriptor.writable = true;
60
+ Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
61
+ }
62
+ }
63
+ function _createClass(Constructor, protoProps, staticProps) {
64
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
65
+ if (staticProps) _defineProperties(Constructor, staticProps);
66
+ Object.defineProperty(Constructor, "prototype", {
67
+ writable: false
68
+ });
69
+ return Constructor;
70
+ }
71
+
72
+ function _defineProperty(obj, key, value) {
73
+ key = _toPropertyKey(key);
74
+ if (key in obj) {
75
+ Object.defineProperty(obj, key, {
76
+ value: value,
77
+ enumerable: true,
78
+ configurable: true,
79
+ writable: true
80
+ });
81
+ } else {
82
+ obj[key] = value;
83
+ }
84
+ return obj;
85
+ }
86
+
87
+ /**
88
+ * @public
89
+ */
90
+ var Environment = /*#__PURE__*/function (Environment) {
91
+ Environment["TEST"] = "TEST";
92
+ Environment["PROD"] = "PROD";
93
+ return Environment;
94
+ }({});
95
+
96
+ function _regeneratorRuntime() {
97
+ _regeneratorRuntime = function () {
98
+ return e;
99
+ };
100
+ var t,
101
+ e = {},
102
+ r = Object.prototype,
103
+ n = r.hasOwnProperty,
104
+ o = Object.defineProperty || function (t, e, r) {
105
+ t[e] = r.value;
106
+ },
107
+ i = "function" == typeof Symbol ? Symbol : {},
108
+ a = i.iterator || "@@iterator",
109
+ c = i.asyncIterator || "@@asyncIterator",
110
+ u = i.toStringTag || "@@toStringTag";
111
+ function define(t, e, r) {
112
+ return Object.defineProperty(t, e, {
113
+ value: r,
114
+ enumerable: !0,
115
+ configurable: !0,
116
+ writable: !0
117
+ }), t[e];
118
+ }
119
+ try {
120
+ define({}, "");
121
+ } catch (t) {
122
+ define = function (t, e, r) {
123
+ return t[e] = r;
124
+ };
125
+ }
126
+ function wrap(t, e, r, n) {
127
+ var i = e && e.prototype instanceof Generator ? e : Generator,
128
+ a = Object.create(i.prototype),
129
+ c = new Context(n || []);
130
+ return o(a, "_invoke", {
131
+ value: makeInvokeMethod(t, r, c)
132
+ }), a;
133
+ }
134
+ function tryCatch(t, e, r) {
135
+ try {
136
+ return {
137
+ type: "normal",
138
+ arg: t.call(e, r)
139
+ };
140
+ } catch (t) {
141
+ return {
142
+ type: "throw",
143
+ arg: t
144
+ };
145
+ }
146
+ }
147
+ e.wrap = wrap;
148
+ var h = "suspendedStart",
149
+ l = "suspendedYield",
150
+ f = "executing",
151
+ s = "completed",
152
+ y = {};
153
+ function Generator() {}
154
+ function GeneratorFunction() {}
155
+ function GeneratorFunctionPrototype() {}
156
+ var p = {};
157
+ define(p, a, function () {
158
+ return this;
159
+ });
160
+ var d = Object.getPrototypeOf,
161
+ v = d && d(d(values([])));
162
+ v && v !== r && n.call(v, a) && (p = v);
163
+ var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
164
+ function defineIteratorMethods(t) {
165
+ ["next", "throw", "return"].forEach(function (e) {
166
+ define(t, e, function (t) {
167
+ return this._invoke(e, t);
168
+ });
169
+ });
170
+ }
171
+ function AsyncIterator(t, e) {
172
+ function invoke(r, o, i, a) {
173
+ var c = tryCatch(t[r], t, o);
174
+ if ("throw" !== c.type) {
175
+ var u = c.arg,
176
+ h = u.value;
177
+ return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
178
+ invoke("next", t, i, a);
179
+ }, function (t) {
180
+ invoke("throw", t, i, a);
181
+ }) : e.resolve(h).then(function (t) {
182
+ u.value = t, i(u);
183
+ }, function (t) {
184
+ return invoke("throw", t, i, a);
185
+ });
186
+ }
187
+ a(c.arg);
188
+ }
189
+ var r;
190
+ o(this, "_invoke", {
191
+ value: function (t, n) {
192
+ function callInvokeWithMethodAndArg() {
193
+ return new e(function (e, r) {
194
+ invoke(t, n, e, r);
195
+ });
196
+ }
197
+ return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
198
+ }
199
+ });
200
+ }
201
+ function makeInvokeMethod(e, r, n) {
202
+ var o = h;
203
+ return function (i, a) {
204
+ if (o === f) throw new Error("Generator is already running");
205
+ if (o === s) {
206
+ if ("throw" === i) throw a;
207
+ return {
208
+ value: t,
209
+ done: !0
210
+ };
211
+ }
212
+ for (n.method = i, n.arg = a;;) {
213
+ var c = n.delegate;
214
+ if (c) {
215
+ var u = maybeInvokeDelegate(c, n);
216
+ if (u) {
217
+ if (u === y) continue;
218
+ return u;
219
+ }
220
+ }
221
+ if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
222
+ if (o === h) throw o = s, n.arg;
223
+ n.dispatchException(n.arg);
224
+ } else "return" === n.method && n.abrupt("return", n.arg);
225
+ o = f;
226
+ var p = tryCatch(e, r, n);
227
+ if ("normal" === p.type) {
228
+ if (o = n.done ? s : l, p.arg === y) continue;
229
+ return {
230
+ value: p.arg,
231
+ done: n.done
232
+ };
233
+ }
234
+ "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
235
+ }
236
+ };
237
+ }
238
+ function maybeInvokeDelegate(e, r) {
239
+ var n = r.method,
240
+ o = e.iterator[n];
241
+ if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
242
+ var i = tryCatch(o, e.iterator, r.arg);
243
+ if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
244
+ var a = i.arg;
245
+ return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
246
+ }
247
+ function pushTryEntry(t) {
248
+ var e = {
249
+ tryLoc: t[0]
250
+ };
251
+ 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
252
+ }
253
+ function resetTryEntry(t) {
254
+ var e = t.completion || {};
255
+ e.type = "normal", delete e.arg, t.completion = e;
256
+ }
257
+ function Context(t) {
258
+ this.tryEntries = [{
259
+ tryLoc: "root"
260
+ }], t.forEach(pushTryEntry, this), this.reset(!0);
261
+ }
262
+ function values(e) {
263
+ if (e || "" === e) {
264
+ var r = e[a];
265
+ if (r) return r.call(e);
266
+ if ("function" == typeof e.next) return e;
267
+ if (!isNaN(e.length)) {
268
+ var o = -1,
269
+ i = function next() {
270
+ for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
271
+ return next.value = t, next.done = !0, next;
272
+ };
273
+ return i.next = i;
274
+ }
275
+ }
276
+ throw new TypeError(typeof e + " is not iterable");
277
+ }
278
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
279
+ value: GeneratorFunctionPrototype,
280
+ configurable: !0
281
+ }), o(GeneratorFunctionPrototype, "constructor", {
282
+ value: GeneratorFunction,
283
+ configurable: !0
284
+ }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
285
+ var e = "function" == typeof t && t.constructor;
286
+ return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
287
+ }, e.mark = function (t) {
288
+ return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
289
+ }, e.awrap = function (t) {
290
+ return {
291
+ __await: t
292
+ };
293
+ }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
294
+ return this;
295
+ }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
296
+ void 0 === i && (i = Promise);
297
+ var a = new AsyncIterator(wrap(t, r, n, o), i);
298
+ return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
299
+ return t.done ? t.value : a.next();
300
+ });
301
+ }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
302
+ return this;
303
+ }), define(g, "toString", function () {
304
+ return "[object Generator]";
305
+ }), e.keys = function (t) {
306
+ var e = Object(t),
307
+ r = [];
308
+ for (var n in e) r.push(n);
309
+ return r.reverse(), function next() {
310
+ for (; r.length;) {
311
+ var t = r.pop();
312
+ if (t in e) return next.value = t, next.done = !1, next;
313
+ }
314
+ return next.done = !0, next;
315
+ };
316
+ }, e.values = values, Context.prototype = {
317
+ constructor: Context,
318
+ reset: function (e) {
319
+ if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
320
+ },
321
+ stop: function () {
322
+ this.done = !0;
323
+ var t = this.tryEntries[0].completion;
324
+ if ("throw" === t.type) throw t.arg;
325
+ return this.rval;
326
+ },
327
+ dispatchException: function (e) {
328
+ if (this.done) throw e;
329
+ var r = this;
330
+ function handle(n, o) {
331
+ return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
332
+ }
333
+ for (var o = this.tryEntries.length - 1; o >= 0; --o) {
334
+ var i = this.tryEntries[o],
335
+ a = i.completion;
336
+ if ("root" === i.tryLoc) return handle("end");
337
+ if (i.tryLoc <= this.prev) {
338
+ var c = n.call(i, "catchLoc"),
339
+ u = n.call(i, "finallyLoc");
340
+ if (c && u) {
341
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
342
+ if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
343
+ } else if (c) {
344
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
345
+ } else {
346
+ if (!u) throw new Error("try statement without catch or finally");
347
+ if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
348
+ }
349
+ }
350
+ }
351
+ },
352
+ abrupt: function (t, e) {
353
+ for (var r = this.tryEntries.length - 1; r >= 0; --r) {
354
+ var o = this.tryEntries[r];
355
+ if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
356
+ var i = o;
357
+ break;
358
+ }
359
+ }
360
+ i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
361
+ var a = i ? i.completion : {};
362
+ return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
363
+ },
364
+ complete: function (t, e) {
365
+ if ("throw" === t.type) throw t.arg;
366
+ return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
367
+ },
368
+ finish: function (t) {
369
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
370
+ var r = this.tryEntries[e];
371
+ if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
372
+ }
373
+ },
374
+ catch: function (t) {
375
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
376
+ var r = this.tryEntries[e];
377
+ if (r.tryLoc === t) {
378
+ var n = r.completion;
379
+ if ("throw" === n.type) {
380
+ var o = n.arg;
381
+ resetTryEntry(r);
382
+ }
383
+ return o;
384
+ }
385
+ }
386
+ throw new Error("illegal catch attempt");
387
+ },
388
+ delegateYield: function (e, r, n) {
389
+ return this.delegate = {
390
+ iterator: values(e),
391
+ resultName: r,
392
+ nextLoc: n
393
+ }, "next" === this.method && (this.arg = t), y;
394
+ }
395
+ }, e;
396
+ }
397
+
398
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
399
+ try {
400
+ var info = gen[key](arg);
401
+ var value = info.value;
402
+ } catch (error) {
403
+ reject(error);
404
+ return;
405
+ }
406
+ if (info.done) {
407
+ resolve(value);
408
+ } else {
409
+ Promise.resolve(value).then(_next, _throw);
410
+ }
411
+ }
412
+ function _asyncToGenerator(fn) {
413
+ return function () {
414
+ var self = this,
415
+ args = arguments;
416
+ return new Promise(function (resolve, reject) {
417
+ var gen = fn.apply(self, args);
418
+ function _next(value) {
419
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
420
+ }
421
+ function _throw(err) {
422
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
423
+ }
424
+ _next(undefined);
425
+ });
426
+ };
427
+ }
428
+
429
+ function handleError(error, msg) {
430
+ if (error instanceof Error) {
431
+ throw new Error("".concat(msg, ": ").concat(error.message));
432
+ }
433
+ throw new Error("".concat(msg, ": Unknown error type"));
434
+ }
435
+
436
+ function isIntegerString(s) {
437
+ var num = Number(s);
438
+ return !isNaN(num) && parseInt(s, 10) === num;
439
+ }
440
+
441
+ /**
442
+ * FranchiseClient allows you to create, update, view, search franchises on
443
+ * Story Protocol.
444
+ */
445
+ var FranchiseClient = /*#__PURE__*/function () {
446
+ function FranchiseClient(httpClient, franchiseRegistry, licenseModule) {
447
+ _classCallCheck(this, FranchiseClient);
448
+ this.httpClient = httpClient;
449
+ this.franchiseRegistry = franchiseRegistry;
450
+ this.licenseModule = licenseModule;
451
+ }
452
+
453
+ /**
454
+ * Get a franchise data based on the specified franchise id.
455
+ *
456
+ * @param request - the request object for getting the franchise
457
+ * @returns the response object that contains the fetched franchise object
458
+ */
459
+ _createClass(FranchiseClient, [{
460
+ key: "get",
461
+ value: function () {
462
+ var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
463
+ var response;
464
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
465
+ while (1) switch (_context.prev = _context.next) {
466
+ case 0:
467
+ _context.prev = 0;
468
+ if (isIntegerString(request.franchiseId)) {
469
+ _context.next = 3;
470
+ break;
471
+ }
472
+ throw new Error("Invalid franchise id. Must be an integer. But got: ".concat(request.franchiseId));
473
+ case 3:
474
+ _context.next = 5;
475
+ return this.httpClient.get("/franchise/".concat(request.franchiseId));
476
+ case 5:
477
+ response = _context.sent;
478
+ return _context.abrupt("return", response.data);
479
+ case 9:
480
+ _context.prev = 9;
481
+ _context.t0 = _context["catch"](0);
482
+ handleError(_context.t0, "Failed to get franchise");
483
+ case 12:
484
+ case "end":
485
+ return _context.stop();
486
+ }
487
+ }, _callee, this, [[0, 9]]);
488
+ }));
489
+ function get(_x) {
490
+ return _get.apply(this, arguments);
491
+ }
492
+ return get;
493
+ }()
494
+ /**
495
+ * List all franchises.
496
+ *
497
+ * @returns the response object that contains a list of franchises
498
+ */
499
+ }, {
500
+ key: "list",
501
+ value: function () {
502
+ var _list = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
503
+ var response;
504
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
505
+ while (1) switch (_context2.prev = _context2.next) {
506
+ case 0:
507
+ _context2.prev = 0;
508
+ _context2.next = 3;
509
+ return this.httpClient.get("/franchise");
510
+ case 3:
511
+ response = _context2.sent;
512
+ return _context2.abrupt("return", response.data);
513
+ case 7:
514
+ _context2.prev = 7;
515
+ _context2.t0 = _context2["catch"](0);
516
+ handleError(_context2.t0, "Failed to list franchises.");
517
+ case 10:
518
+ case "end":
519
+ return _context2.stop();
520
+ }
521
+ }, _callee2, this, [[0, 7]]);
522
+ }));
523
+ function list() {
524
+ return _list.apply(this, arguments);
525
+ }
526
+ return list;
527
+ }()
528
+ /**
529
+ * Create a franchise on Story Protocol based on the specified input franchise data.
530
+ *
531
+ * @param request - the request object that contains all data needed to create a franchise
532
+ * @returns the response object that contains results from the create franchise action
533
+ */
534
+ }, {
535
+ key: "create",
536
+ value: function () {
537
+ var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(request) {
538
+ var tokenURI, response;
539
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
540
+ while (1) switch (_context3.prev = _context3.next) {
541
+ case 0:
542
+ _context3.prev = 0;
543
+ // hardcoded the URI for now until the backend API for uploading franchise metadata is ready
544
+ tokenURI = "https://arweave.net/dnFJl1v8kgOx_6Z0gEsBce3D56cMP4-lxAcFqSsL0_w";
545
+ _context3.next = 4;
546
+ return this.franchiseRegistry.registerFranchise({
547
+ name: request.franchiseName,
548
+ symbol: request.franchiseSymbol,
549
+ description: request.franchiseDescription,
550
+ tokenURI: tokenURI
551
+ });
552
+ case 4:
553
+ response = _context3.sent;
554
+ return _context3.abrupt("return", {
555
+ txHash: response.hash
556
+ });
557
+ case 8:
558
+ _context3.prev = 8;
559
+ _context3.t0 = _context3["catch"](0);
560
+ handleError(_context3.t0, "Failed to create franchise");
561
+ case 11:
562
+ case "end":
563
+ return _context3.stop();
564
+ }
565
+ }, _callee3, this, [[0, 8]]);
566
+ }));
567
+ function create(_x2) {
568
+ return _create.apply(this, arguments);
569
+ }
570
+ return create;
571
+ }()
572
+ /**
573
+ * Configure a franchise on Story Protocol.
574
+ *
575
+ * @param request - the request object that contains all data needed to configure a franchise
576
+ * @returns the response object that contains results from the configure franchise action
577
+ */
578
+ }, {
579
+ key: "configure",
580
+ value: function () {
581
+ var _configure = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(request) {
582
+ var response;
583
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
584
+ while (1) switch (_context4.prev = _context4.next) {
585
+ case 0:
586
+ _context4.prev = 0;
587
+ _context4.next = 3;
588
+ return this.licenseModule.configureFranchiseLicensing(request.franchiseId, {
589
+ nonCommercialConfig: {
590
+ canSublicense: true,
591
+ franchiseRootLicenseId: 0
592
+ },
593
+ nonCommercialTerms: {
594
+ processor: ethers.constants.AddressZero,
595
+ data: []
596
+ },
597
+ commercialConfig: {
598
+ canSublicense: false,
599
+ franchiseRootLicenseId: 0
600
+ },
601
+ commercialTerms: {
602
+ processor: ethers.constants.AddressZero,
603
+ data: []
604
+ },
605
+ commercialLicenseUri: "aaaa",
606
+ rootIpAssetHasCommercialRights: false,
607
+ revoker: "0xF33f05489d9708C2CA97944F2007d4E741D4DEe7"
608
+ });
609
+ case 3:
610
+ response = _context4.sent;
611
+ return _context4.abrupt("return", {
612
+ txHash: response.hash
613
+ });
614
+ case 7:
615
+ _context4.prev = 7;
616
+ _context4.t0 = _context4["catch"](0);
617
+ handleError(_context4.t0, "Failed to configure franchise");
618
+ case 10:
619
+ case "end":
620
+ return _context4.stop();
621
+ }
622
+ }, _callee4, this, [[0, 7]]);
623
+ }));
624
+ function configure(_x3) {
625
+ return _configure.apply(this, arguments);
626
+ }
627
+ return configure;
628
+ }()
629
+ }]);
630
+ return FranchiseClient;
631
+ }();
632
+
633
+ var _abi$4 = [{
634
+ inputs: [{
635
+ internalType: "uint256",
636
+ name: "franchiseId",
637
+ type: "uint256"
638
+ }, {
639
+ components: [{
640
+ components: [{
641
+ internalType: "bool",
642
+ name: "canSublicense",
643
+ type: "bool"
644
+ }, {
645
+ internalType: "uint256",
646
+ name: "franchiseRootLicenseId",
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);
731
+
732
+ var _abi$3 = [{
733
+ inputs: [{
734
+ components: [{
735
+ internalType: "string",
736
+ name: "name",
737
+ type: "string"
738
+ }, {
739
+ internalType: "string",
740
+ name: "symbol",
741
+ type: "string"
742
+ }, {
743
+ internalType: "string",
744
+ name: "description",
745
+ type: "string"
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);
785
+ }
786
+ _createClass(FranchiseRegistry__factory, null, [{
787
+ key: "createInterface",
788
+ value: function createInterface() {
789
+ return new ethers.utils.Interface(_abi$3);
790
+ }
791
+ }, {
792
+ key: "connect",
793
+ value: function connect(address, signerOrProvider) {
794
+ return new ethers.Contract(address, _abi$3, signerOrProvider);
795
+ }
796
+ }]);
797
+ return FranchiseRegistry__factory;
798
+ }();
799
+ _defineProperty(FranchiseRegistry__factory, "abi", _abi$3);
800
+
801
+ var _abi$2 = [{
802
+ inputs: [{
803
+ components: [{
804
+ internalType: "uint256",
805
+ name: "franchiseId",
806
+ type: "uint256"
807
+ }, {
808
+ internalType: "uint256",
809
+ name: "ipAssetId",
810
+ type: "uint256"
811
+ }, {
812
+ internalType: "address",
813
+ name: "collector",
814
+ type: "address"
815
+ }, {
816
+ internalType: "bytes",
817
+ name: "collectData",
818
+ type: "bytes"
819
+ }, {
820
+ internalType: "bytes",
821
+ name: "collectNFTInitData",
822
+ type: "bytes"
823
+ }, {
824
+ internalType: "bytes",
825
+ name: "collectNFTData",
826
+ type: "bytes"
827
+ }],
828
+ internalType: "struct CollectParams",
829
+ name: "collectParams",
830
+ type: "tuple"
831
+ }],
832
+ name: "collect",
833
+ outputs: [{
834
+ internalType: "address",
835
+ name: "collectNFT",
836
+ type: "address"
837
+ }, {
838
+ internalType: "uint256",
839
+ name: "collectNFTId",
840
+ type: "uint256"
841
+ }],
842
+ stateMutability: "nonpayable",
843
+ type: "function"
844
+ }];
845
+ var CollectModule__factory = /*#__PURE__*/function () {
846
+ function CollectModule__factory() {
847
+ _classCallCheck(this, CollectModule__factory);
848
+ }
849
+ _createClass(CollectModule__factory, null, [{
850
+ key: "createInterface",
851
+ value: function createInterface() {
852
+ return new ethers.utils.Interface(_abi$2);
853
+ }
854
+ }, {
855
+ key: "connect",
856
+ value: function connect(address, signerOrProvider) {
857
+ return new ethers.Contract(address, _abi$2, signerOrProvider);
858
+ }
859
+ }]);
860
+ return CollectModule__factory;
861
+ }();
862
+ _defineProperty(CollectModule__factory, "abi", _abi$2);
863
+
864
+ var _abi$1 = [{
865
+ inputs: [{
866
+ internalType: "enum IPAsset",
867
+ name: "ipAssetType",
868
+ type: "uint8"
869
+ }, {
870
+ internalType: "string",
871
+ name: "name",
872
+ type: "string"
873
+ }, {
874
+ internalType: "string",
875
+ name: "_description",
876
+ type: "string"
877
+ }, {
878
+ internalType: "string",
879
+ name: "mediaUrl",
880
+ type: "string"
881
+ }, {
882
+ internalType: "address",
883
+ name: "to",
884
+ type: "address"
885
+ }, {
886
+ internalType: "uint256",
887
+ name: "parentIpAssetId",
888
+ type: "uint256"
889
+ }],
890
+ name: "createIPAsset",
891
+ outputs: [{
892
+ internalType: "uint256",
893
+ name: "",
894
+ type: "uint256"
895
+ }],
896
+ stateMutability: "nonpayable",
897
+ type: "function"
898
+ }, {
899
+ inputs: [{
900
+ internalType: "uint256",
901
+ name: "_tokenId",
902
+ type: "uint256"
903
+ }, {
904
+ internalType: "uint256",
905
+ name: "_parentLicenseId",
906
+ type: "uint256"
907
+ }, {
908
+ internalType: "address",
909
+ name: "_licenseHolder",
910
+ type: "address"
911
+ }, {
912
+ internalType: "string",
913
+ name: "_uri",
914
+ type: "string"
915
+ }, {
916
+ internalType: "address",
917
+ name: "_revoker",
918
+ type: "address"
919
+ }, {
920
+ internalType: "bool",
921
+ name: "_commercial",
922
+ type: "bool"
923
+ }, {
924
+ internalType: "bool",
925
+ name: "_canSublicense",
926
+ type: "bool"
927
+ }, {
928
+ components: [{
929
+ internalType: "contract ITermsProcessor",
930
+ name: "processor",
931
+ type: "address"
932
+ }, {
933
+ internalType: "bytes",
934
+ name: "data",
935
+ type: "bytes"
936
+ }],
937
+ internalType: "struct IERC5218.TermsProcessorConfig",
938
+ name: "_terms",
939
+ type: "tuple"
940
+ }],
941
+ name: "createLicense",
942
+ outputs: [{
943
+ internalType: "uint256",
944
+ name: "",
945
+ type: "uint256"
946
+ }],
947
+ stateMutability: "nonpayable",
948
+ type: "function"
949
+ }, {
950
+ inputs: [{
951
+ internalType: "uint256",
952
+ name: "_tokenId",
953
+ type: "uint256"
954
+ }, {
955
+ internalType: "bool",
956
+ name: "_commercial",
957
+ type: "bool"
958
+ }],
959
+ name: "getLicenseIdByTokenId",
960
+ outputs: [{
961
+ internalType: "uint256",
962
+ name: "",
963
+ type: "uint256"
964
+ }],
965
+ stateMutability: "view",
966
+ type: "function"
967
+ }];
968
+ var IpAssetRegistry__factory = /*#__PURE__*/function () {
969
+ function IpAssetRegistry__factory() {
970
+ _classCallCheck(this, IpAssetRegistry__factory);
971
+ }
972
+ _createClass(IpAssetRegistry__factory, null, [{
973
+ key: "createInterface",
974
+ value: function createInterface() {
975
+ return new ethers.utils.Interface(_abi$1);
976
+ }
977
+ }, {
978
+ key: "connect",
979
+ value: function connect(address, signerOrProvider) {
980
+ return new ethers.Contract(address, _abi$1, signerOrProvider);
981
+ }
982
+ }]);
983
+ return IpAssetRegistry__factory;
984
+ }();
985
+ _defineProperty(IpAssetRegistry__factory, "abi", _abi$1);
986
+
987
+ var _abi = [{
988
+ inputs: [{
989
+ components: [{
990
+ internalType: "address",
991
+ name: "sourceContract",
992
+ type: "address"
993
+ }, {
994
+ internalType: "uint256",
995
+ name: "sourceId",
996
+ type: "uint256"
997
+ }, {
998
+ internalType: "address",
999
+ name: "destContract",
1000
+ type: "address"
1001
+ }, {
1002
+ internalType: "uint256",
1003
+ name: "destId",
1004
+ type: "uint256"
1005
+ }, {
1006
+ internalType: "bytes32",
1007
+ name: "relationshipId",
1008
+ type: "bytes32"
1009
+ }, {
1010
+ internalType: "uint256",
1011
+ name: "ttl",
1012
+ type: "uint256"
1013
+ }],
1014
+ internalType: "struct IRelationshipModule.RelationshipParams",
1015
+ name: "params",
1016
+ type: "tuple"
1017
+ }, {
1018
+ internalType: "bytes",
1019
+ name: "data",
1020
+ type: "bytes"
1021
+ }],
1022
+ name: "relate",
1023
+ outputs: [],
1024
+ stateMutability: "nonpayable",
1025
+ type: "function"
1026
+ }, {
1027
+ inputs: [{
1028
+ components: [{
1029
+ internalType: "address",
1030
+ name: "sourceContract",
1031
+ type: "address"
1032
+ }, {
1033
+ internalType: "uint256",
1034
+ name: "sourceId",
1035
+ type: "uint256"
1036
+ }, {
1037
+ internalType: "address",
1038
+ name: "destContract",
1039
+ type: "address"
1040
+ }, {
1041
+ internalType: "uint256",
1042
+ name: "destId",
1043
+ type: "uint256"
1044
+ }, {
1045
+ internalType: "bytes32",
1046
+ name: "relationshipId",
1047
+ type: "bytes32"
1048
+ }, {
1049
+ internalType: "uint256",
1050
+ name: "ttl",
1051
+ type: "uint256"
1052
+ }],
1053
+ internalType: "struct IRelationshipModule.RelationshipParams",
1054
+ name: "params",
1055
+ type: "tuple"
1056
+ }],
1057
+ name: "unrelate",
1058
+ outputs: [],
1059
+ stateMutability: "nonpayable",
1060
+ type: "function"
1061
+ }, {
1062
+ inputs: [{
1063
+ components: [{
1064
+ internalType: "address",
1065
+ name: "sourceContract",
1066
+ type: "address"
1067
+ }, {
1068
+ internalType: "uint256",
1069
+ name: "sourceId",
1070
+ type: "uint256"
1071
+ }, {
1072
+ internalType: "address",
1073
+ name: "destContract",
1074
+ type: "address"
1075
+ }, {
1076
+ internalType: "uint256",
1077
+ name: "destId",
1078
+ type: "uint256"
1079
+ }, {
1080
+ internalType: "bytes32",
1081
+ name: "relationshipId",
1082
+ type: "bytes32"
1083
+ }, {
1084
+ internalType: "uint256",
1085
+ name: "ttl",
1086
+ type: "uint256"
1087
+ }],
1088
+ internalType: "struct IRelationshipModule.RelationshipParams",
1089
+ name: "params",
1090
+ type: "tuple"
1091
+ }],
1092
+ name: "isRelationshipExpired",
1093
+ outputs: [{
1094
+ internalType: "bool",
1095
+ name: "",
1096
+ type: "bool"
1097
+ }],
1098
+ stateMutability: "view",
1099
+ type: "function"
1100
+ }, {
1101
+ inputs: [{
1102
+ components: [{
1103
+ internalType: "address",
1104
+ name: "sourceContract",
1105
+ type: "address"
1106
+ }, {
1107
+ internalType: "uint256",
1108
+ name: "sourceId",
1109
+ type: "uint256"
1110
+ }, {
1111
+ internalType: "address",
1112
+ name: "destContract",
1113
+ type: "address"
1114
+ }, {
1115
+ internalType: "uint256",
1116
+ name: "destId",
1117
+ type: "uint256"
1118
+ }, {
1119
+ internalType: "bytes32",
1120
+ name: "relationshipId",
1121
+ type: "bytes32"
1122
+ }, {
1123
+ internalType: "uint256",
1124
+ name: "ttl",
1125
+ type: "uint256"
1126
+ }],
1127
+ internalType: "struct IRelationshipModule.RelationshipParams",
1128
+ name: "params",
1129
+ type: "tuple"
1130
+ }],
1131
+ name: "areTheyRelated",
1132
+ outputs: [{
1133
+ internalType: "bool",
1134
+ name: "",
1135
+ type: "bool"
1136
+ }],
1137
+ stateMutability: "view",
1138
+ type: "function"
1139
+ }, {
1140
+ inputs: [{
1141
+ internalType: "string",
1142
+ name: "name",
1143
+ type: "string"
1144
+ }],
1145
+ name: "getRelationshipId",
1146
+ outputs: [{
1147
+ internalType: "bytes32",
1148
+ name: "",
1149
+ type: "bytes32"
1150
+ }],
1151
+ stateMutability: "pure",
1152
+ type: "function"
1153
+ }];
1154
+ var RelationshipModule__factory = /*#__PURE__*/function () {
1155
+ function RelationshipModule__factory() {
1156
+ _classCallCheck(this, RelationshipModule__factory);
1157
+ }
1158
+ _createClass(RelationshipModule__factory, null, [{
1159
+ key: "createInterface",
1160
+ value: function createInterface() {
1161
+ return new ethers.utils.Interface(_abi);
1162
+ }
1163
+ }, {
1164
+ key: "connect",
1165
+ value: function connect(address, signerOrProvider) {
1166
+ return new ethers.Contract(address, _abi, signerOrProvider);
1167
+ }
1168
+ }]);
1169
+ return RelationshipModule__factory;
1170
+ }();
1171
+ _defineProperty(RelationshipModule__factory, "abi", _abi);
1172
+
1173
+ /**
1174
+ * A class representing License operations.
1175
+ *
1176
+ * @public
1177
+ */
1178
+ var LicenseClient = /*#__PURE__*/function () {
1179
+ function LicenseClient(httpClient, signer, franchiseRegistry) {
1180
+ _classCallCheck(this, LicenseClient);
1181
+ this.httpClient = httpClient;
1182
+ this.signer = signer;
1183
+ this.franchiseRegistry = franchiseRegistry;
1184
+ }
1185
+
1186
+ /**
1187
+ * Get a license by its ID.
1188
+ *
1189
+ * @param licenseId - The ID of the license to retrieve.
1190
+ * @returns A Promise that resolves to the GetLicenseResponse.
1191
+ */
1192
+ _createClass(LicenseClient, [{
1193
+ key: "get",
1194
+ value: function () {
1195
+ var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
1196
+ var response;
1197
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1198
+ while (1) switch (_context.prev = _context.next) {
1199
+ case 0:
1200
+ _context.prev = 0;
1201
+ if (isIntegerString(request.licenseId)) {
1202
+ _context.next = 3;
1203
+ break;
1204
+ }
1205
+ throw new Error("Invalid licenseId. Must be an integer. But got: ".concat(request.licenseId));
1206
+ case 3:
1207
+ _context.next = 5;
1208
+ return this.httpClient.get("/license/".concat(request.licenseId));
1209
+ case 5:
1210
+ response = _context.sent;
1211
+ return _context.abrupt("return", response.data);
1212
+ case 9:
1213
+ _context.prev = 9;
1214
+ _context.t0 = _context["catch"](0);
1215
+ handleError(_context.t0, "Failed to get license");
1216
+ case 12:
1217
+ case "end":
1218
+ return _context.stop();
1219
+ }
1220
+ }, _callee, this, [[0, 9]]);
1221
+ }));
1222
+ function get(_x) {
1223
+ return _get.apply(this, arguments);
1224
+ }
1225
+ return get;
1226
+ }()
1227
+ /**
1228
+ * List all licenses.
1229
+ *
1230
+ * @returns A Promise that resolves to the ListLicenseResponse.
1231
+ */
1232
+ }, {
1233
+ key: "list",
1234
+ value: function () {
1235
+ var _list = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
1236
+ var response;
1237
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1238
+ while (1) switch (_context2.prev = _context2.next) {
1239
+ case 0:
1240
+ _context2.prev = 0;
1241
+ _context2.next = 3;
1242
+ return this.httpClient.get("/license?franchiseId=".concat(request.franchiseId, "&ipAssetId=").concat(request.ipAssetId));
1243
+ case 3:
1244
+ response = _context2.sent;
1245
+ return _context2.abrupt("return", response.data);
1246
+ case 7:
1247
+ _context2.prev = 7;
1248
+ _context2.t0 = _context2["catch"](0);
1249
+ handleError(_context2.t0, "Failed to get licenses");
1250
+ case 10:
1251
+ case "end":
1252
+ return _context2.stop();
1253
+ }
1254
+ }, _callee2, this, [[0, 7]]);
1255
+ }));
1256
+ function list(_x2) {
1257
+ return _list.apply(this, arguments);
1258
+ }
1259
+ return list;
1260
+ }()
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
+ }]);
1337
+ return LicenseClient;
1338
+ }();
1339
+
1340
+ /**
1341
+ * TransactionClient allows you to view and monitor transactions on
1342
+ * Story Protocol.
1343
+ */
1344
+ var TransactionClient = /*#__PURE__*/function () {
1345
+ function TransactionClient(httpClient) {
1346
+ _classCallCheck(this, TransactionClient);
1347
+ this.httpClient = httpClient;
1348
+ }
1349
+
1350
+ /**
1351
+ * Get transaction data based on the specified transaction id.
1352
+ *
1353
+ * @param request - the request object for getting the transaction
1354
+ * @returns the response object that contains the fetched transaction object
1355
+ */
1356
+ _createClass(TransactionClient, [{
1357
+ key: "get",
1358
+ value: function () {
1359
+ var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
1360
+ var response;
1361
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1362
+ while (1) switch (_context.prev = _context.next) {
1363
+ case 0:
1364
+ _context.prev = 0;
1365
+ _context.next = 3;
1366
+ return this.httpClient.get("/transaction/".concat(request.txId));
1367
+ case 3:
1368
+ response = _context.sent;
1369
+ return _context.abrupt("return", response.data);
1370
+ case 7:
1371
+ _context.prev = 7;
1372
+ _context.t0 = _context["catch"](0);
1373
+ handleError(_context.t0, "Failed to get transaction");
1374
+ case 10:
1375
+ case "end":
1376
+ return _context.stop();
1377
+ }
1378
+ }, _callee, this, [[0, 7]]);
1379
+ }));
1380
+ function get(_x) {
1381
+ return _get.apply(this, arguments);
1382
+ }
1383
+ return get;
1384
+ }()
1385
+ /**
1386
+ * Get transaction data based on the specified transaction id.
1387
+ *
1388
+ * @param request - the request object for getting the transactions
1389
+ * @returns the response object that contains the fetched transaction object
1390
+ */
1391
+ }, {
1392
+ key: "list",
1393
+ value: function () {
1394
+ var _list = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
1395
+ var response;
1396
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1397
+ while (1) switch (_context2.prev = _context2.next) {
1398
+ case 0:
1399
+ _context2.prev = 0;
1400
+ _context2.next = 3;
1401
+ return this.httpClient.get("/transaction");
1402
+ case 3:
1403
+ response = _context2.sent;
1404
+ return _context2.abrupt("return", response.data);
1405
+ case 7:
1406
+ _context2.prev = 7;
1407
+ _context2.t0 = _context2["catch"](0);
1408
+ handleError(_context2.t0, "Failed to get transactions");
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);
1460
+ case 6:
1461
+ destIpRegistryAddress = _context.sent;
1462
+ return _context.abrupt("return", {
1463
+ sourceIpRegistryAddress: sourceIpRegistryAddress,
1464
+ destIpRegistryAddress: destIpRegistryAddress
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:
1518
+ response = _context2.sent;
1519
+ return _context2.abrupt("return", {
1520
+ txHash: response.hash
1521
+ });
1522
+ case 18:
1523
+ _context2.prev = 18;
1524
+ _context2.t0 = _context2["catch"](0);
1525
+ handleError(_context2.t0, "Failed to create relationship");
1526
+ case 21:
1527
+ case "end":
1528
+ return _context2.stop();
1529
+ }
1530
+ }, _callee2, this, [[0, 18]]);
1531
+ }));
1532
+ function relate(_x3) {
1533
+ return _relate.apply(this, arguments);
1534
+ }
1535
+ return relate;
1536
+ }()
1537
+ /**
1538
+ * Removes a relationship between two IP assets.
1539
+ * @param request - The request for removing the relationship.
1540
+ * @returns A promise that resolves to the response with the transaction hash.
1541
+ */
1542
+ }, {
1543
+ key: "unrelate",
1544
+ value: function () {
1545
+ var _unrelate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(request) {
1546
+ var sourceIPAsset, destIPAsset, _yield$this$getRegist2, sourceIpRegistryAddress, destIpRegistryAddress, relationshipId, params, response;
1547
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
1548
+ while (1) switch (_context3.prev = _context3.next) {
1549
+ case 0:
1550
+ _context3.prev = 0;
1551
+ sourceIPAsset = request.sourceIPAsset, destIPAsset = request.destIPAsset; // Get IPAssetRegistry Contract Address
1552
+ _context3.next = 4;
1553
+ return this.getRegistryAddresses(sourceIPAsset.franchiseId, destIPAsset.franchiseId);
1554
+ case 4:
1555
+ _yield$this$getRegist2 = _context3.sent;
1556
+ sourceIpRegistryAddress = _yield$this$getRegist2.sourceIpRegistryAddress;
1557
+ destIpRegistryAddress = _yield$this$getRegist2.destIpRegistryAddress;
1558
+ _context3.next = 9;
1559
+ return this.relationshipModule.getRelationshipId("APPEARS_IN");
1560
+ case 9:
1561
+ relationshipId = _context3.sent;
1562
+ params = {
1563
+ sourceContract: sourceIpRegistryAddress,
1564
+ sourceId: sourceIPAsset.ipAssetId,
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:
1582
+ case "end":
1583
+ return _context3.stop();
1584
+ }
1585
+ }, _callee3, this, [[0, 17]]);
1586
+ }));
1587
+ function unrelate(_x4) {
1588
+ return _unrelate.apply(this, arguments);
1589
+ }
1590
+ return unrelate;
1591
+ }()
1592
+ /**
1593
+ * Checks if a relationship has expired.
1594
+ * @param request - The request for checking the relationship's expiration status.
1595
+ * @returns A promise that resolves to the response indicating whether the relationship has expired.
1596
+ */
1597
+ }, {
1598
+ key: "isRelationshipExpired",
1599
+ value: function () {
1600
+ var _isRelationshipExpired = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(request) {
1601
+ var sourceIPAsset, destIPAsset, _yield$this$getRegist3, sourceIpRegistryAddress, destIpRegistryAddress, relationshipId, params, response;
1602
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
1603
+ while (1) switch (_context4.prev = _context4.next) {
1604
+ case 0:
1605
+ _context4.prev = 0;
1606
+ sourceIPAsset = request.sourceIPAsset, destIPAsset = request.destIPAsset; // Get IPAssetRegistry Contract Address
1607
+ _context4.next = 4;
1608
+ return this.getRegistryAddresses(sourceIPAsset.franchiseId, destIPAsset.franchiseId);
1609
+ case 4:
1610
+ _yield$this$getRegist3 = _context4.sent;
1611
+ sourceIpRegistryAddress = _yield$this$getRegist3.sourceIpRegistryAddress;
1612
+ destIpRegistryAddress = _yield$this$getRegist3.destIpRegistryAddress;
1613
+ _context4.next = 9;
1614
+ return this.relationshipModule.getRelationshipId("APPEARS_IN");
1615
+ case 9:
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:
1637
+ case "end":
1638
+ return _context4.stop();
1639
+ }
1640
+ }, _callee4, this, [[0, 17]]);
1641
+ }));
1642
+ function isRelationshipExpired(_x5) {
1643
+ return _isRelationshipExpired.apply(this, arguments);
1644
+ }
1645
+ return isRelationshipExpired;
1646
+ }()
1647
+ /**
1648
+ * Checks if two IP assets are related.
1649
+ * @param request - The request for checking the relationship between two IP assets.
1650
+ * @returns A promise that resolves to the response indicating whether the IP assets are related.
1651
+ */
1652
+ }, {
1653
+ key: "isRelated",
1654
+ value: function () {
1655
+ var _isRelated = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(request) {
1656
+ var sourceIPAsset, destIPAsset, _yield$this$getRegist4, sourceIpRegistryAddress, destIpRegistryAddress, relationshipId, params, response;
1657
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
1658
+ while (1) switch (_context5.prev = _context5.next) {
1659
+ case 0:
1660
+ _context5.prev = 0;
1661
+ sourceIPAsset = request.sourceIPAsset, destIPAsset = request.destIPAsset; // Get IPAssetRegistry Contract Address
1662
+ _context5.next = 4;
1663
+ return this.getRegistryAddresses(sourceIPAsset.franchiseId, destIPAsset.franchiseId);
1664
+ case 4:
1665
+ _yield$this$getRegist4 = _context5.sent;
1666
+ sourceIpRegistryAddress = _yield$this$getRegist4.sourceIpRegistryAddress;
1667
+ destIpRegistryAddress = _yield$this$getRegist4.destIpRegistryAddress;
1668
+ _context5.next = 9;
1669
+ return this.relationshipModule.getRelationshipId("APPEARS_IN");
1670
+ case 9:
1671
+ relationshipId = _context5.sent;
1672
+ params = {
1673
+ sourceContract: sourceIpRegistryAddress,
1674
+ sourceId: sourceIPAsset.ipAssetId,
1675
+ destContract: destIpRegistryAddress,
1676
+ destId: destIPAsset.ipAssetId,
1677
+ relationshipId: relationshipId,
1678
+ ttl: "0"
1679
+ };
1680
+ _context5.next = 13;
1681
+ return this.relationshipModule.areTheyRelated(params);
1682
+ case 13:
1683
+ response = _context5.sent;
1684
+ return _context5.abrupt("return", {
1685
+ result: response
1686
+ });
1687
+ case 17:
1688
+ _context5.prev = 17;
1689
+ _context5.t0 = _context5["catch"](0);
1690
+ handleError(_context5.t0, "Failed to get isRelated");
1691
+ case 20:
1692
+ case "end":
1693
+ return _context5.stop();
1694
+ }
1695
+ }, _callee5, this, [[0, 17]]);
1696
+ }));
1697
+ function isRelated(_x6) {
1698
+ return _isRelated.apply(this, arguments);
1699
+ }
1700
+ return isRelated;
1701
+ }()
1702
+ }]);
1703
+ return RelationshipClient;
1704
+ }();
1705
+
1706
+ /**
1707
+ * IpAssetClient allows you to create, view, and list IP Assets on Story Protocol.
1708
+ */
1709
+ var IpAssetClient = /*#__PURE__*/function () {
1710
+ function IpAssetClient(httpClient, franchiseRegistry, signer) {
1711
+ _classCallCheck(this, IpAssetClient);
1712
+ this.httpClient = httpClient;
1713
+ this.franchiseRegistry = franchiseRegistry;
1714
+ this.signer = signer;
1715
+ }
1716
+
1717
+ /**
1718
+ * Get the ipAssetRegistry associated with a franchiseId.
1719
+ *
1720
+ * @returns the response object that contains the requested ipAssetRegistry.
1721
+ */
1722
+ _createClass(IpAssetClient, [{
1723
+ key: "getRegistry",
1724
+ value: function () {
1725
+ var _getRegistry = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(franchiseId) {
1726
+ var address, ipAssetRegistry;
1727
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1728
+ while (1) switch (_context.prev = _context.next) {
1729
+ case 0:
1730
+ _context.prev = 0;
1731
+ _context.next = 3;
1732
+ return this.franchiseRegistry.ipAssetRegistryForId(franchiseId);
1733
+ case 3:
1734
+ address = _context.sent;
1735
+ ipAssetRegistry = IpAssetRegistry__factory.connect(address, this.signer);
1736
+ return _context.abrupt("return", ipAssetRegistry);
1737
+ case 8:
1738
+ _context.prev = 8;
1739
+ _context.t0 = _context["catch"](0);
1740
+ handleError(_context.t0, "Failed to retrieve IP Asset Registry");
1741
+ case 11:
1742
+ case "end":
1743
+ return _context.stop();
1744
+ }
1745
+ }, _callee, this, [[0, 8]]);
1746
+ }));
1747
+ function getRegistry(_x) {
1748
+ return _getRegistry.apply(this, arguments);
1749
+ }
1750
+ return getRegistry;
1751
+ }()
1752
+ /**
1753
+ * Get an IP Asset based on the specified IP asset ID.
1754
+ *
1755
+ * @param request - the request object for getting an IP Asset.
1756
+ * @returns the response object the contains the fetched IP Asset.
1757
+ */
1758
+ }, {
1759
+ key: "get",
1760
+ value: function () {
1761
+ var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
1762
+ var response;
1763
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1764
+ while (1) switch (_context2.prev = _context2.next) {
1765
+ case 0:
1766
+ _context2.prev = 0;
1767
+ if (isIntegerString(request.ipAssetId)) {
1768
+ _context2.next = 3;
1769
+ break;
1770
+ }
1771
+ throw new Error("Invalid IP Asset id. Must be an integer. But get: ".concat(request.ipAssetId));
1772
+ case 3:
1773
+ _context2.next = 5;
1774
+ return this.httpClient.get("/ipasset/".concat(request.ipAssetId, "?franchiseId=").concat(request.franchiseId));
1775
+ case 5:
1776
+ response = _context2.sent;
1777
+ 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
+ case 7:
1861
+ _context4.prev = 7;
1862
+ _context4.t0 = _context4["catch"](0);
1863
+ handleError(_context4.t0, "Failed to list IP Asset.");
1864
+ case 10:
1865
+ case "end":
1866
+ return _context4.stop();
1867
+ }
1868
+ }, _callee4, this, [[0, 7]]);
1869
+ }));
1870
+ function list(_x4) {
1871
+ return _list.apply(this, arguments);
1872
+ }
1873
+ return list;
1874
+ }()
1875
+ }]);
1876
+ return IpAssetClient;
1877
+ }();
1878
+
1879
+ /**
1880
+ * Default timeout value for http clients.
1881
+ */
1882
+ var HTTP_TIMEOUT = 1000;
1883
+
1884
+ var CollectClient = /*#__PURE__*/function () {
1885
+ function CollectClient(httpClient, signer, collectModule) {
1886
+ _classCallCheck(this, CollectClient);
1887
+ this.httpClient = httpClient;
1888
+ this.signer = signer;
1889
+ this.collectModuleContract = collectModule;
1890
+ }
1891
+
1892
+ /**
1893
+ * List all collected IP Assets.
1894
+ *
1895
+ * @returns A Promise that resolves to the ListLicenseResponse.
1896
+ */
1897
+ _createClass(CollectClient, [{
1898
+ key: "list",
1899
+ value: function () {
1900
+ var _list = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
1901
+ var response;
1902
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1903
+ while (1) switch (_context.prev = _context.next) {
1904
+ case 0:
1905
+ _context.prev = 0;
1906
+ _context.next = 3;
1907
+ return this.httpClient.get("/collection?franchiseId=".concat(request.franchiseId));
1908
+ case 3:
1909
+ response = _context.sent;
1910
+ return _context.abrupt("return", response.data);
1911
+ case 7:
1912
+ _context.prev = 7;
1913
+ _context.t0 = _context["catch"](0);
1914
+ handleError(_context.t0, "Failed to get collections");
1915
+ case 10:
1916
+ case "end":
1917
+ return _context.stop();
1918
+ }
1919
+ }, _callee, this, [[0, 7]]);
1920
+ }));
1921
+ function list(_x) {
1922
+ return _list.apply(this, arguments);
1923
+ }
1924
+ return list;
1925
+ }()
1926
+ /**
1927
+ * Collect an IP Asset on Story Protocol based on the specified input collect data.
1928
+ *
1929
+ * @param request - the request object that contains all data needed to collect an IP Asset
1930
+ * @returns the response object that contains results from the create franchise action
1931
+ */
1932
+ }, {
1933
+ key: "collect",
1934
+ value: function () {
1935
+ var _collect = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
1936
+ var response;
1937
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1938
+ while (1) switch (_context2.prev = _context2.next) {
1939
+ case 0:
1940
+ _context2.prev = 0;
1941
+ _context2.next = 3;
1942
+ return this.collectModuleContract.collect({
1943
+ franchiseId: request.franchiseId,
1944
+ ipAssetId: request.ipAssetId,
1945
+ collector: request.collector,
1946
+ collectData: "0x",
1947
+ collectNFTInitData: "0x",
1948
+ collectNFTData: "0x"
1949
+ });
1950
+ case 3:
1951
+ response = _context2.sent;
1952
+ return _context2.abrupt("return", {
1953
+ txHash: response.hash
1954
+ });
1955
+ case 7:
1956
+ _context2.prev = 7;
1957
+ _context2.t0 = _context2["catch"](0);
1958
+ handleError(_context2.t0, "Failed to collect IP Asset");
1959
+ case 10:
1960
+ case "end":
1961
+ return _context2.stop();
1962
+ }
1963
+ }, _callee2, this, [[0, 7]]);
1964
+ }));
1965
+ function collect(_x2) {
1966
+ return _collect.apply(this, arguments);
1967
+ }
1968
+ return collect;
1969
+ }()
1970
+ }]);
1971
+ return CollectClient;
1972
+ }();
1973
+
1974
+ dotenv__namespace.config();
1975
+ /**
1976
+ * The StoryClient is the main entry point for the SDK.
1977
+ */
1978
+ var StoryClient = /*#__PURE__*/function () {
1979
+ /**
1980
+ * @param config - the configuration for the SDK client
1981
+ */
1982
+ function StoryClient(config) {
1983
+ _classCallCheck(this, StoryClient);
1984
+ _defineProperty(this, "_franchise", null);
1985
+ _defineProperty(this, "_relationship", null);
1986
+ _defineProperty(this, "_ipAsset", null);
1987
+ _defineProperty(this, "_license", null);
1988
+ _defineProperty(this, "_transaction", null);
1989
+ _defineProperty(this, "_collect", null);
1990
+ if (config.environment !== Environment.TEST) {
1991
+ throw new Error("Invalid Environment: Only TEST environment is supported");
1992
+ }
1993
+ this.config = config;
1994
+ this.httpClient = axios__default["default"].create({
1995
+ baseURL: process.env.API_BASE_URL,
1996
+ timeout: HTTP_TIMEOUT
1997
+ });
1998
+ }
1999
+
2000
+ /**
2001
+ * Getter for the franchise client. The client is lazily created when
2002
+ * this method is called.
2003
+ *
2004
+ * @returns the FranchiseClient instance
2005
+ */
2006
+ _createClass(StoryClient, [{
2007
+ key: "franchise",
2008
+ get: function get() {
2009
+ if (this._franchise === null) {
2010
+ var franchiseRegistry = FranchiseRegistry__factory.connect(process.env.FRANCHISE_REGISTRY_CONTRACT, this.config.signer);
2011
+ var licenseModule = LicensingModule__factory.connect(process.env.LICENSING_MODULE_CONTRACT, this.config.signer);
2012
+ this._franchise = new FranchiseClient(this.httpClient, franchiseRegistry, licenseModule);
2013
+ }
2014
+ return this._franchise;
2015
+ }
2016
+
2017
+ /**
2018
+ * Getter for the relationship client. The client is lazily created when
2019
+ * this method is called.
2020
+ *
2021
+ * @returns the RelationshipClient instance
2022
+ */
2023
+ }, {
2024
+ key: "relationship",
2025
+ get: function get() {
2026
+ if (this._relationship === null) {
2027
+ var franchiseRegistry = FranchiseRegistry__factory.connect(process.env.FRANCHISE_REGISTRY_CONTRACT, this.config.signer);
2028
+ var relationshipModule = RelationshipModule__factory.connect(process.env.RELATIONSHIP_MODULE_CONTRACT, this.config.signer);
2029
+ this._relationship = new RelationshipClient(relationshipModule, franchiseRegistry);
2030
+ }
2031
+ return this._relationship;
2032
+ }
2033
+
2034
+ /**
2035
+ * Getter for the IP Asset client. The client is lazily created when
2036
+ * this method is called.
2037
+ *
2038
+ * @returns the IpAssetClient instance
2039
+ */
2040
+ }, {
2041
+ key: "ipAsset",
2042
+ get: function get() {
2043
+ if (this._ipAsset === null) {
2044
+ var franchiseRegistry = FranchiseRegistry__factory.connect(process.env.FRANCHISE_REGISTRY_CONTRACT, this.config.signer);
2045
+ this._ipAsset = new IpAssetClient(this.httpClient, franchiseRegistry, this.config.signer);
2046
+ }
2047
+ return this._ipAsset;
2048
+ }
2049
+
2050
+ /**
2051
+ * Getter for the license client. The client is lazily created when
2052
+ * this method is called.
2053
+ *
2054
+ * @returns the FranchiseClient instance
2055
+ */
2056
+ }, {
2057
+ key: "license",
2058
+ get: function get() {
2059
+ if (this._license === null) {
2060
+ var franchiseRegistry = FranchiseRegistry__factory.connect(process.env.FRANCHISE_REGISTRY_CONTRACT, this.config.signer);
2061
+ this._license = new LicenseClient(this.httpClient, this.config.signer, franchiseRegistry);
2062
+ }
2063
+ return this._license;
2064
+ }
2065
+
2066
+ /**
2067
+ * Getter for the transaction client. The client is lazily created when
2068
+ * this method is called.
2069
+ *
2070
+ * @returns the TransactionClient instance
2071
+ */
2072
+ }, {
2073
+ key: "transaction",
2074
+ get: function get() {
2075
+ if (this._transaction === null) {
2076
+ this._transaction = new TransactionClient(this.httpClient);
2077
+ }
2078
+ return this._transaction;
2079
+ }
2080
+
2081
+ /**
2082
+ * Getter for the collect module client. The client is lazily created when
2083
+ * this method is called.
2084
+ *
2085
+ * @returns the CollectClient instance
2086
+ */
2087
+ }, {
2088
+ key: "collect",
2089
+ get: function get() {
2090
+ if (this._collect === null) {
2091
+ var collectModule = CollectModule__factory.connect(process.env.COLLECT_MODULE_CONTRACT, this.config.signer);
2092
+ this._collect = new CollectClient(this.httpClient, this.config.signer, collectModule);
2093
+ }
2094
+ return this._collect;
2095
+ }
2096
+ }]);
2097
+ return StoryClient;
2098
+ }();
2099
+
2100
+ exports.Environment = Environment;
2101
+ exports.StoryClient = StoryClient;