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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. package/README.md +85 -0
  2. package/dist/declarations/src/client.d.ts +111 -0
  3. package/dist/declarations/src/client.d.ts.map +1 -0
  4. package/dist/declarations/src/enums/ActionType.d.ts +11 -0
  5. package/dist/declarations/src/enums/ActionType.d.ts.map +1 -0
  6. package/dist/declarations/src/enums/Environment.d.ts +8 -0
  7. package/dist/declarations/src/enums/Environment.d.ts.map +1 -0
  8. package/dist/declarations/src/enums/IPAssetType.d.ts +11 -0
  9. package/dist/declarations/src/enums/IPAssetType.d.ts.map +1 -0
  10. package/dist/declarations/src/enums/ResourceType.d.ts +15 -0
  11. package/dist/declarations/src/enums/ResourceType.d.ts.map +1 -0
  12. package/dist/declarations/src/index.d.ts +13 -0
  13. package/dist/declarations/src/index.d.ts.map +1 -0
  14. package/dist/declarations/src/resources/hook.d.ts +12 -0
  15. package/dist/declarations/src/resources/hook.d.ts.map +1 -0
  16. package/dist/declarations/src/resources/hookReadOnly.d.ts +27 -0
  17. package/dist/declarations/src/resources/hookReadOnly.d.ts.map +1 -0
  18. package/dist/declarations/src/resources/ipAsset.d.ts +19 -0
  19. package/dist/declarations/src/resources/ipAsset.d.ts.map +1 -0
  20. package/dist/declarations/src/resources/ipAssetReadOnly.d.ts +25 -0
  21. package/dist/declarations/src/resources/ipAssetReadOnly.d.ts.map +1 -0
  22. package/dist/declarations/src/resources/ipOrg.d.ts +20 -0
  23. package/dist/declarations/src/resources/ipOrg.d.ts.map +1 -0
  24. package/dist/declarations/src/resources/ipOrgReadOnly.d.ts +26 -0
  25. package/dist/declarations/src/resources/ipOrgReadOnly.d.ts.map +1 -0
  26. package/dist/declarations/src/resources/license.d.ts +15 -0
  27. package/dist/declarations/src/resources/license.d.ts.map +1 -0
  28. package/dist/declarations/src/resources/licenseReadOnly.d.ts +27 -0
  29. package/dist/declarations/src/resources/licenseReadOnly.d.ts.map +1 -0
  30. package/dist/declarations/src/resources/module.d.ts +12 -0
  31. package/dist/declarations/src/resources/module.d.ts.map +1 -0
  32. package/dist/declarations/src/resources/moduleReadOnly.d.ts +27 -0
  33. package/dist/declarations/src/resources/moduleReadOnly.d.ts.map +1 -0
  34. package/dist/declarations/src/resources/relationship.d.ts +26 -0
  35. package/dist/declarations/src/resources/relationship.d.ts.map +1 -0
  36. package/dist/declarations/src/resources/relationshipReadOnly.d.ts +25 -0
  37. package/dist/declarations/src/resources/relationshipReadOnly.d.ts.map +1 -0
  38. package/dist/declarations/src/resources/transaction.d.ts +12 -0
  39. package/dist/declarations/src/resources/transaction.d.ts.map +1 -0
  40. package/dist/declarations/src/resources/transactionReadOnly.d.ts +27 -0
  41. package/dist/declarations/src/resources/transactionReadOnly.d.ts.map +1 -0
  42. package/dist/declarations/src/types/client.d.ts +35 -0
  43. package/dist/declarations/src/types/client.d.ts.map +1 -0
  44. package/dist/declarations/src/types/config.d.ts +18 -0
  45. package/dist/declarations/src/types/config.d.ts.map +1 -0
  46. package/dist/declarations/src/types/options.d.ts +10 -0
  47. package/dist/declarations/src/types/options.d.ts.map +1 -0
  48. package/dist/declarations/src/types/resources/IPOrg.d.ts +71 -0
  49. package/dist/declarations/src/types/resources/IPOrg.d.ts.map +1 -0
  50. package/dist/declarations/src/types/resources/hook.d.ts +49 -0
  51. package/dist/declarations/src/types/resources/hook.d.ts.map +1 -0
  52. package/dist/declarations/src/types/resources/ipAsset.d.ts +76 -0
  53. package/dist/declarations/src/types/resources/ipAsset.d.ts.map +1 -0
  54. package/dist/declarations/src/types/resources/license.d.ts +85 -0
  55. package/dist/declarations/src/types/resources/license.d.ts.map +1 -0
  56. package/dist/declarations/src/types/resources/module.d.ts +49 -0
  57. package/dist/declarations/src/types/resources/module.d.ts.map +1 -0
  58. package/dist/declarations/src/types/resources/relationship.d.ts +158 -0
  59. package/dist/declarations/src/types/resources/relationship.d.ts.map +1 -0
  60. package/dist/declarations/src/types/resources/transaction.d.ts +52 -0
  61. package/dist/declarations/src/types/resources/transaction.d.ts.map +1 -0
  62. package/dist/declarations/src/utils/platform.d.ts +17 -0
  63. package/dist/declarations/src/utils/platform.d.ts.map +1 -0
  64. package/dist/story-protocol-core-sdk.cjs.d.ts +2 -0
  65. package/dist/story-protocol-core-sdk.cjs.d.ts.map +1 -0
  66. package/dist/story-protocol-core-sdk.cjs.dev.js +2650 -0
  67. package/dist/story-protocol-core-sdk.cjs.js +7 -0
  68. package/dist/story-protocol-core-sdk.cjs.prod.js +2650 -0
  69. package/dist/story-protocol-core-sdk.esm.js +2620 -0
  70. package/package.json +91 -0
@@ -0,0 +1,2650 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var axios = require('axios');
6
+ var viem = require('viem');
7
+ var chains = require('viem/chains');
8
+ var dotenv = require('dotenv');
9
+ var abitype = require('abitype');
10
+
11
+ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
12
+
13
+ function _interopNamespace(e) {
14
+ if (e && e.__esModule) return e;
15
+ var n = Object.create(null);
16
+ if (e) {
17
+ Object.keys(e).forEach(function (k) {
18
+ if (k !== 'default') {
19
+ var d = Object.getOwnPropertyDescriptor(e, k);
20
+ Object.defineProperty(n, k, d.get ? d : {
21
+ enumerable: true,
22
+ get: function () { return e[k]; }
23
+ });
24
+ }
25
+ });
26
+ }
27
+ n["default"] = e;
28
+ return Object.freeze(n);
29
+ }
30
+
31
+ var axios__default = /*#__PURE__*/_interopDefault(axios);
32
+ var dotenv__namespace = /*#__PURE__*/_interopNamespace(dotenv);
33
+
34
+ function _toPrimitive(input, hint) {
35
+ if (typeof input !== "object" || input === null) return input;
36
+ var prim = input[Symbol.toPrimitive];
37
+ if (prim !== undefined) {
38
+ var res = prim.call(input, hint || "default");
39
+ if (typeof res !== "object") return res;
40
+ throw new TypeError("@@toPrimitive must return a primitive value.");
41
+ }
42
+ return (hint === "string" ? String : Number)(input);
43
+ }
44
+
45
+ function _toPropertyKey(arg) {
46
+ var key = _toPrimitive(arg, "string");
47
+ return typeof key === "symbol" ? key : String(key);
48
+ }
49
+
50
+ function _defineProperty(obj, key, value) {
51
+ key = _toPropertyKey(key);
52
+ if (key in obj) {
53
+ Object.defineProperty(obj, key, {
54
+ value: value,
55
+ enumerable: true,
56
+ configurable: true,
57
+ writable: true
58
+ });
59
+ } else {
60
+ obj[key] = value;
61
+ }
62
+ return obj;
63
+ }
64
+
65
+ function ownKeys(e, r) {
66
+ var t = Object.keys(e);
67
+ if (Object.getOwnPropertySymbols) {
68
+ var o = Object.getOwnPropertySymbols(e);
69
+ r && (o = o.filter(function (r) {
70
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
71
+ })), t.push.apply(t, o);
72
+ }
73
+ return t;
74
+ }
75
+ function _objectSpread2(e) {
76
+ for (var r = 1; r < arguments.length; r++) {
77
+ var t = null != arguments[r] ? arguments[r] : {};
78
+ r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
79
+ _defineProperty(e, r, t[r]);
80
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
81
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
82
+ });
83
+ }
84
+ return e;
85
+ }
86
+
87
+ function _classCallCheck(instance, Constructor) {
88
+ if (!(instance instanceof Constructor)) {
89
+ throw new TypeError("Cannot call a class as a function");
90
+ }
91
+ }
92
+
93
+ function _defineProperties(target, props) {
94
+ for (var i = 0; i < props.length; i++) {
95
+ var descriptor = props[i];
96
+ descriptor.enumerable = descriptor.enumerable || false;
97
+ descriptor.configurable = true;
98
+ if ("value" in descriptor) descriptor.writable = true;
99
+ Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
100
+ }
101
+ }
102
+ function _createClass(Constructor, protoProps, staticProps) {
103
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
104
+ if (staticProps) _defineProperties(Constructor, staticProps);
105
+ Object.defineProperty(Constructor, "prototype", {
106
+ writable: false
107
+ });
108
+ return Constructor;
109
+ }
110
+
111
+ /**
112
+ * @public
113
+ */
114
+ var Environment = /*#__PURE__*/function (Environment) {
115
+ Environment["TEST"] = "TEST";
116
+ Environment["PROD"] = "PROD";
117
+ return Environment;
118
+ }({});
119
+
120
+ function _regeneratorRuntime() {
121
+ _regeneratorRuntime = function () {
122
+ return e;
123
+ };
124
+ var t,
125
+ e = {},
126
+ r = Object.prototype,
127
+ n = r.hasOwnProperty,
128
+ o = Object.defineProperty || function (t, e, r) {
129
+ t[e] = r.value;
130
+ },
131
+ i = "function" == typeof Symbol ? Symbol : {},
132
+ a = i.iterator || "@@iterator",
133
+ c = i.asyncIterator || "@@asyncIterator",
134
+ u = i.toStringTag || "@@toStringTag";
135
+ function define(t, e, r) {
136
+ return Object.defineProperty(t, e, {
137
+ value: r,
138
+ enumerable: !0,
139
+ configurable: !0,
140
+ writable: !0
141
+ }), t[e];
142
+ }
143
+ try {
144
+ define({}, "");
145
+ } catch (t) {
146
+ define = function (t, e, r) {
147
+ return t[e] = r;
148
+ };
149
+ }
150
+ function wrap(t, e, r, n) {
151
+ var i = e && e.prototype instanceof Generator ? e : Generator,
152
+ a = Object.create(i.prototype),
153
+ c = new Context(n || []);
154
+ return o(a, "_invoke", {
155
+ value: makeInvokeMethod(t, r, c)
156
+ }), a;
157
+ }
158
+ function tryCatch(t, e, r) {
159
+ try {
160
+ return {
161
+ type: "normal",
162
+ arg: t.call(e, r)
163
+ };
164
+ } catch (t) {
165
+ return {
166
+ type: "throw",
167
+ arg: t
168
+ };
169
+ }
170
+ }
171
+ e.wrap = wrap;
172
+ var h = "suspendedStart",
173
+ l = "suspendedYield",
174
+ f = "executing",
175
+ s = "completed",
176
+ y = {};
177
+ function Generator() {}
178
+ function GeneratorFunction() {}
179
+ function GeneratorFunctionPrototype() {}
180
+ var p = {};
181
+ define(p, a, function () {
182
+ return this;
183
+ });
184
+ var d = Object.getPrototypeOf,
185
+ v = d && d(d(values([])));
186
+ v && v !== r && n.call(v, a) && (p = v);
187
+ var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
188
+ function defineIteratorMethods(t) {
189
+ ["next", "throw", "return"].forEach(function (e) {
190
+ define(t, e, function (t) {
191
+ return this._invoke(e, t);
192
+ });
193
+ });
194
+ }
195
+ function AsyncIterator(t, e) {
196
+ function invoke(r, o, i, a) {
197
+ var c = tryCatch(t[r], t, o);
198
+ if ("throw" !== c.type) {
199
+ var u = c.arg,
200
+ h = u.value;
201
+ return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
202
+ invoke("next", t, i, a);
203
+ }, function (t) {
204
+ invoke("throw", t, i, a);
205
+ }) : e.resolve(h).then(function (t) {
206
+ u.value = t, i(u);
207
+ }, function (t) {
208
+ return invoke("throw", t, i, a);
209
+ });
210
+ }
211
+ a(c.arg);
212
+ }
213
+ var r;
214
+ o(this, "_invoke", {
215
+ value: function (t, n) {
216
+ function callInvokeWithMethodAndArg() {
217
+ return new e(function (e, r) {
218
+ invoke(t, n, e, r);
219
+ });
220
+ }
221
+ return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
222
+ }
223
+ });
224
+ }
225
+ function makeInvokeMethod(e, r, n) {
226
+ var o = h;
227
+ return function (i, a) {
228
+ if (o === f) throw new Error("Generator is already running");
229
+ if (o === s) {
230
+ if ("throw" === i) throw a;
231
+ return {
232
+ value: t,
233
+ done: !0
234
+ };
235
+ }
236
+ for (n.method = i, n.arg = a;;) {
237
+ var c = n.delegate;
238
+ if (c) {
239
+ var u = maybeInvokeDelegate(c, n);
240
+ if (u) {
241
+ if (u === y) continue;
242
+ return u;
243
+ }
244
+ }
245
+ if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
246
+ if (o === h) throw o = s, n.arg;
247
+ n.dispatchException(n.arg);
248
+ } else "return" === n.method && n.abrupt("return", n.arg);
249
+ o = f;
250
+ var p = tryCatch(e, r, n);
251
+ if ("normal" === p.type) {
252
+ if (o = n.done ? s : l, p.arg === y) continue;
253
+ return {
254
+ value: p.arg,
255
+ done: n.done
256
+ };
257
+ }
258
+ "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
259
+ }
260
+ };
261
+ }
262
+ function maybeInvokeDelegate(e, r) {
263
+ var n = r.method,
264
+ o = e.iterator[n];
265
+ 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;
266
+ var i = tryCatch(o, e.iterator, r.arg);
267
+ if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
268
+ var a = i.arg;
269
+ 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);
270
+ }
271
+ function pushTryEntry(t) {
272
+ var e = {
273
+ tryLoc: t[0]
274
+ };
275
+ 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
276
+ }
277
+ function resetTryEntry(t) {
278
+ var e = t.completion || {};
279
+ e.type = "normal", delete e.arg, t.completion = e;
280
+ }
281
+ function Context(t) {
282
+ this.tryEntries = [{
283
+ tryLoc: "root"
284
+ }], t.forEach(pushTryEntry, this), this.reset(!0);
285
+ }
286
+ function values(e) {
287
+ if (e || "" === e) {
288
+ var r = e[a];
289
+ if (r) return r.call(e);
290
+ if ("function" == typeof e.next) return e;
291
+ if (!isNaN(e.length)) {
292
+ var o = -1,
293
+ i = function next() {
294
+ for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
295
+ return next.value = t, next.done = !0, next;
296
+ };
297
+ return i.next = i;
298
+ }
299
+ }
300
+ throw new TypeError(typeof e + " is not iterable");
301
+ }
302
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
303
+ value: GeneratorFunctionPrototype,
304
+ configurable: !0
305
+ }), o(GeneratorFunctionPrototype, "constructor", {
306
+ value: GeneratorFunction,
307
+ configurable: !0
308
+ }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
309
+ var e = "function" == typeof t && t.constructor;
310
+ return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
311
+ }, e.mark = function (t) {
312
+ return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
313
+ }, e.awrap = function (t) {
314
+ return {
315
+ __await: t
316
+ };
317
+ }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
318
+ return this;
319
+ }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
320
+ void 0 === i && (i = Promise);
321
+ var a = new AsyncIterator(wrap(t, r, n, o), i);
322
+ return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
323
+ return t.done ? t.value : a.next();
324
+ });
325
+ }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
326
+ return this;
327
+ }), define(g, "toString", function () {
328
+ return "[object Generator]";
329
+ }), e.keys = function (t) {
330
+ var e = Object(t),
331
+ r = [];
332
+ for (var n in e) r.push(n);
333
+ return r.reverse(), function next() {
334
+ for (; r.length;) {
335
+ var t = r.pop();
336
+ if (t in e) return next.value = t, next.done = !1, next;
337
+ }
338
+ return next.done = !0, next;
339
+ };
340
+ }, e.values = values, Context.prototype = {
341
+ constructor: Context,
342
+ reset: function (e) {
343
+ 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);
344
+ },
345
+ stop: function () {
346
+ this.done = !0;
347
+ var t = this.tryEntries[0].completion;
348
+ if ("throw" === t.type) throw t.arg;
349
+ return this.rval;
350
+ },
351
+ dispatchException: function (e) {
352
+ if (this.done) throw e;
353
+ var r = this;
354
+ function handle(n, o) {
355
+ return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
356
+ }
357
+ for (var o = this.tryEntries.length - 1; o >= 0; --o) {
358
+ var i = this.tryEntries[o],
359
+ a = i.completion;
360
+ if ("root" === i.tryLoc) return handle("end");
361
+ if (i.tryLoc <= this.prev) {
362
+ var c = n.call(i, "catchLoc"),
363
+ u = n.call(i, "finallyLoc");
364
+ if (c && u) {
365
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
366
+ if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
367
+ } else if (c) {
368
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
369
+ } else {
370
+ if (!u) throw new Error("try statement without catch or finally");
371
+ if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
372
+ }
373
+ }
374
+ }
375
+ },
376
+ abrupt: function (t, e) {
377
+ for (var r = this.tryEntries.length - 1; r >= 0; --r) {
378
+ var o = this.tryEntries[r];
379
+ if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
380
+ var i = o;
381
+ break;
382
+ }
383
+ }
384
+ i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
385
+ var a = i ? i.completion : {};
386
+ return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
387
+ },
388
+ complete: function (t, e) {
389
+ if ("throw" === t.type) throw t.arg;
390
+ 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;
391
+ },
392
+ finish: function (t) {
393
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
394
+ var r = this.tryEntries[e];
395
+ if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
396
+ }
397
+ },
398
+ catch: function (t) {
399
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
400
+ var r = this.tryEntries[e];
401
+ if (r.tryLoc === t) {
402
+ var n = r.completion;
403
+ if ("throw" === n.type) {
404
+ var o = n.arg;
405
+ resetTryEntry(r);
406
+ }
407
+ return o;
408
+ }
409
+ }
410
+ throw new Error("illegal catch attempt");
411
+ },
412
+ delegateYield: function (e, r, n) {
413
+ return this.delegate = {
414
+ iterator: values(e),
415
+ resultName: r,
416
+ nextLoc: n
417
+ }, "next" === this.method && (this.arg = t), y;
418
+ }
419
+ }, e;
420
+ }
421
+
422
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
423
+ try {
424
+ var info = gen[key](arg);
425
+ var value = info.value;
426
+ } catch (error) {
427
+ reject(error);
428
+ return;
429
+ }
430
+ if (info.done) {
431
+ resolve(value);
432
+ } else {
433
+ Promise.resolve(value).then(_next, _throw);
434
+ }
435
+ }
436
+ function _asyncToGenerator(fn) {
437
+ return function () {
438
+ var self = this,
439
+ args = arguments;
440
+ return new Promise(function (resolve, reject) {
441
+ var gen = fn.apply(self, args);
442
+ function _next(value) {
443
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
444
+ }
445
+ function _throw(err) {
446
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
447
+ }
448
+ _next(undefined);
449
+ });
450
+ };
451
+ }
452
+
453
+ function _setPrototypeOf(o, p) {
454
+ _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
455
+ o.__proto__ = p;
456
+ return o;
457
+ };
458
+ return _setPrototypeOf(o, p);
459
+ }
460
+
461
+ function _inherits(subClass, superClass) {
462
+ if (typeof superClass !== "function" && superClass !== null) {
463
+ throw new TypeError("Super expression must either be null or a function");
464
+ }
465
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
466
+ constructor: {
467
+ value: subClass,
468
+ writable: true,
469
+ configurable: true
470
+ }
471
+ });
472
+ Object.defineProperty(subClass, "prototype", {
473
+ writable: false
474
+ });
475
+ if (superClass) _setPrototypeOf(subClass, superClass);
476
+ }
477
+
478
+ function _getPrototypeOf(o) {
479
+ _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
480
+ return o.__proto__ || Object.getPrototypeOf(o);
481
+ };
482
+ return _getPrototypeOf(o);
483
+ }
484
+
485
+ function _isNativeReflectConstruct() {
486
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
487
+ if (Reflect.construct.sham) return false;
488
+ if (typeof Proxy === "function") return true;
489
+ try {
490
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
491
+ return true;
492
+ } catch (e) {
493
+ return false;
494
+ }
495
+ }
496
+
497
+ function _assertThisInitialized(self) {
498
+ if (self === void 0) {
499
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
500
+ }
501
+ return self;
502
+ }
503
+
504
+ function _possibleConstructorReturn(self, call) {
505
+ if (call && (typeof call === "object" || typeof call === "function")) {
506
+ return call;
507
+ } else if (call !== void 0) {
508
+ throw new TypeError("Derived constructors may only return object or undefined");
509
+ }
510
+ return _assertThisInitialized(self);
511
+ }
512
+
513
+ function _createSuper(Derived) {
514
+ var hasNativeReflectConstruct = _isNativeReflectConstruct();
515
+ return function _createSuperInternal() {
516
+ var Super = _getPrototypeOf(Derived),
517
+ result;
518
+ if (hasNativeReflectConstruct) {
519
+ var NewTarget = _getPrototypeOf(this).constructor;
520
+ result = Reflect.construct(Super, arguments, NewTarget);
521
+ } else {
522
+ result = Super.apply(this, arguments);
523
+ }
524
+ return _possibleConstructorReturn(this, result);
525
+ };
526
+ }
527
+
528
+ function handleError(error, msg) {
529
+ if (error instanceof Error) {
530
+ throw new Error("".concat(msg, ": ").concat(error.message));
531
+ }
532
+ throw new Error("".concat(msg, ": Unknown error type"));
533
+ }
534
+
535
+ /**
536
+ * IPOrgReadOnlyClient allows you to view, search IPOrgs on
537
+ * Story Protocol.
538
+ */
539
+ var IPOrgReadOnlyClient = /*#__PURE__*/function () {
540
+ function IPOrgReadOnlyClient(httpClient, rpcClient) {
541
+ _classCallCheck(this, IPOrgReadOnlyClient);
542
+ this.httpClient = httpClient;
543
+ this.rpcClient = rpcClient;
544
+ }
545
+
546
+ /**
547
+ * Get a IPOrg data based on the specified IPOrg id.
548
+ *
549
+ * @param request - the request object for getting the IPOrg
550
+ * @returns the response object that contains the fetched IPOrg object
551
+ */
552
+ _createClass(IPOrgReadOnlyClient, [{
553
+ key: "get",
554
+ value: function () {
555
+ var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
556
+ var response;
557
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
558
+ while (1) switch (_context.prev = _context.next) {
559
+ case 0:
560
+ _context.prev = 0;
561
+ if (viem.isAddress(request.ipOrgId)) {
562
+ _context.next = 3;
563
+ break;
564
+ }
565
+ throw new Error("Invalid IPOrg id. Must be an address. But got: ".concat(request.ipOrgId));
566
+ case 3:
567
+ _context.next = 5;
568
+ return this.httpClient.get("/protocol/iporg/".concat(request.ipOrgId));
569
+ case 5:
570
+ response = _context.sent;
571
+ return _context.abrupt("return", response.data);
572
+ case 9:
573
+ _context.prev = 9;
574
+ _context.t0 = _context["catch"](0);
575
+ handleError(_context.t0, "Failed to get IPOrg");
576
+ case 12:
577
+ case "end":
578
+ return _context.stop();
579
+ }
580
+ }, _callee, this, [[0, 9]]);
581
+ }));
582
+ function get(_x) {
583
+ return _get.apply(this, arguments);
584
+ }
585
+ return get;
586
+ }()
587
+ /**
588
+ * List all IPOrgs.
589
+ *
590
+ * @returns the response object that contains a list of IPOrgs
591
+ */
592
+ }, {
593
+ key: "list",
594
+ value: function () {
595
+ var _list = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
596
+ var response;
597
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
598
+ while (1) switch (_context2.prev = _context2.next) {
599
+ case 0:
600
+ _context2.prev = 0;
601
+ _context2.next = 3;
602
+ return this.httpClient.post("/protocol/iporg", request);
603
+ case 3:
604
+ response = _context2.sent;
605
+ return _context2.abrupt("return", response.data);
606
+ case 7:
607
+ _context2.prev = 7;
608
+ _context2.t0 = _context2["catch"](0);
609
+ handleError(_context2.t0, "Failed to list IPOrgs.");
610
+ case 10:
611
+ case "end":
612
+ return _context2.stop();
613
+ }
614
+ }, _callee2, this, [[0, 7]]);
615
+ }));
616
+ function list(_x2) {
617
+ return _list.apply(this, arguments);
618
+ }
619
+ return list;
620
+ }()
621
+ }]);
622
+ return IPOrgReadOnlyClient;
623
+ }();
624
+
625
+ if (typeof process !== "undefined") {
626
+ dotenv__namespace.config();
627
+ }
628
+ var storyProtocolAbi = [{
629
+ inputs: [{
630
+ internalType: "address",
631
+ name: "owner_",
632
+ type: "address"
633
+ }, {
634
+ internalType: "string",
635
+ name: "name_",
636
+ type: "string"
637
+ }, {
638
+ internalType: "string",
639
+ name: "symbol_",
640
+ type: "string"
641
+ }, {
642
+ internalType: "string[]",
643
+ name: "ipAssetTypes_",
644
+ type: "string[]"
645
+ }],
646
+ name: "registerIpOrg",
647
+ outputs: [{
648
+ internalType: "address",
649
+ name: "ipOrg_",
650
+ type: "address"
651
+ }],
652
+ stateMutability: "nonpayable",
653
+ type: "function"
654
+ }, {
655
+ inputs: [{
656
+ internalType: "address",
657
+ name: "ipOrg_",
658
+ type: "address"
659
+ }, {
660
+ components: [{
661
+ internalType: "bool",
662
+ name: "isCommercial",
663
+ type: "bool"
664
+ }, {
665
+ internalType: "uint256",
666
+ name: "parentLicenseId",
667
+ type: "uint256"
668
+ }],
669
+ internalType: "struct Licensing.LicenseCreation",
670
+ name: "params_",
671
+ type: "tuple"
672
+ }, {
673
+ internalType: "address",
674
+ name: "licensee_",
675
+ type: "address"
676
+ }, {
677
+ internalType: "bytes[]",
678
+ name: "preHooksData_",
679
+ type: "bytes[]"
680
+ }, {
681
+ internalType: "bytes[]",
682
+ name: "postHooksData_",
683
+ type: "bytes[]"
684
+ }],
685
+ name: "createLicenseNft",
686
+ outputs: [{
687
+ internalType: "uint256",
688
+ name: "",
689
+ type: "uint256"
690
+ }],
691
+ stateMutability: "nonpayable",
692
+ type: "function"
693
+ }, {
694
+ inputs: [{
695
+ internalType: "address",
696
+ name: "ipOrg_",
697
+ type: "address"
698
+ }, {
699
+ components: [{
700
+ internalType: "bool",
701
+ name: "isCommercial",
702
+ type: "bool"
703
+ }, {
704
+ internalType: "uint256",
705
+ name: "parentLicenseId",
706
+ type: "uint256"
707
+ }],
708
+ internalType: "struct Licensing.LicenseCreation",
709
+ name: "params_",
710
+ type: "tuple"
711
+ }, {
712
+ internalType: "uint256",
713
+ name: "ipaId_",
714
+ type: "uint256"
715
+ }, {
716
+ internalType: "bytes[]",
717
+ name: "preHooksData_",
718
+ type: "bytes[]"
719
+ }, {
720
+ internalType: "bytes[]",
721
+ name: "postHooksData_",
722
+ type: "bytes[]"
723
+ }],
724
+ name: "createIpaBoundLicense",
725
+ outputs: [{
726
+ internalType: "uint256",
727
+ name: "",
728
+ type: "uint256"
729
+ }],
730
+ stateMutability: "nonpayable",
731
+ type: "function"
732
+ }, {
733
+ inputs: [{
734
+ internalType: "address",
735
+ name: "ipOrg_",
736
+ type: "address"
737
+ }, {
738
+ components: [{
739
+ internalType: "address",
740
+ name: "owner",
741
+ type: "address"
742
+ }, {
743
+ internalType: "string",
744
+ name: "name",
745
+ type: "string"
746
+ }, {
747
+ internalType: "uint64",
748
+ name: "ipAssetType",
749
+ type: "uint64"
750
+ }, {
751
+ internalType: "bytes32",
752
+ name: "hash",
753
+ type: "bytes32"
754
+ }, {
755
+ internalType: "string",
756
+ name: "mediaUrl",
757
+ type: "string"
758
+ }],
759
+ internalType: "struct Registration.RegisterIPAssetParams",
760
+ name: "params_",
761
+ type: "tuple"
762
+ }, {
763
+ internalType: "bytes[]",
764
+ name: "preHooksData_",
765
+ type: "bytes[]"
766
+ }, {
767
+ internalType: "bytes[]",
768
+ name: "postHooksData_",
769
+ type: "bytes[]"
770
+ }],
771
+ name: "registerIPAsset",
772
+ outputs: [{
773
+ internalType: "uint256",
774
+ name: "",
775
+ type: "uint256"
776
+ }, {
777
+ internalType: "uint256",
778
+ name: "",
779
+ type: "uint256"
780
+ }],
781
+ stateMutability: "nonpayable",
782
+ type: "function"
783
+ }, {
784
+ inputs: [{
785
+ components: [{
786
+ internalType: "string",
787
+ name: "relType",
788
+ type: "string"
789
+ }, {
790
+ internalType: "address",
791
+ name: "ipOrg",
792
+ type: "address"
793
+ }, {
794
+ components: [{
795
+ internalType: "enum LibRelationship.Relatables",
796
+ name: "src",
797
+ type: "uint8"
798
+ }, {
799
+ internalType: "enum LibRelationship.Relatables",
800
+ name: "dst",
801
+ type: "uint8"
802
+ }],
803
+ internalType: "struct LibRelationship.RelatedElements",
804
+ name: "allowedElements",
805
+ type: "tuple"
806
+ }, {
807
+ internalType: "uint8[]",
808
+ name: "allowedSrcs",
809
+ type: "uint8[]"
810
+ }, {
811
+ internalType: "uint8[]",
812
+ name: "allowedDsts",
813
+ type: "uint8[]"
814
+ }],
815
+ internalType: "struct LibRelationship.AddRelationshipTypeParams",
816
+ name: "params_",
817
+ type: "tuple"
818
+ }],
819
+ name: "addRelationshipType",
820
+ outputs: [],
821
+ stateMutability: "nonpayable",
822
+ type: "function"
823
+ }, {
824
+ inputs: [{
825
+ internalType: "address",
826
+ name: "ipOrg_",
827
+ type: "address"
828
+ }, {
829
+ components: [{
830
+ internalType: "string",
831
+ name: "relType",
832
+ type: "string"
833
+ }, {
834
+ internalType: "address",
835
+ name: "srcAddress",
836
+ type: "address"
837
+ }, {
838
+ internalType: "uint256",
839
+ name: "srcId",
840
+ type: "uint256"
841
+ }, {
842
+ internalType: "uint8",
843
+ name: "srcType",
844
+ type: "uint8"
845
+ }, {
846
+ internalType: "address",
847
+ name: "dstAddress",
848
+ type: "address"
849
+ }, {
850
+ internalType: "uint256",
851
+ name: "dstId",
852
+ type: "uint256"
853
+ }, {
854
+ internalType: "uint8",
855
+ name: "dstType",
856
+ type: "uint8"
857
+ }],
858
+ internalType: "struct LibRelationship.CreateRelationshipParams",
859
+ name: "params_",
860
+ type: "tuple"
861
+ }, {
862
+ internalType: "bytes[]",
863
+ name: "preHooksData_",
864
+ type: "bytes[]"
865
+ }, {
866
+ internalType: "bytes[]",
867
+ name: "postHooksData_",
868
+ type: "bytes[]"
869
+ }],
870
+ name: "createRelationship",
871
+ outputs: [{
872
+ internalType: "uint256",
873
+ name: "relId",
874
+ type: "uint256"
875
+ }],
876
+ stateMutability: "nonpayable",
877
+ type: "function"
878
+ }, {
879
+ inputs: [{
880
+ internalType: "address",
881
+ name: "ipOrg_",
882
+ type: "address"
883
+ }, {
884
+ internalType: "string",
885
+ name: "relType",
886
+ type: "string"
887
+ }],
888
+ name: "removeRelationshipType",
889
+ outputs: [],
890
+ stateMutability: "nonpayable",
891
+ type: "function"
892
+ }];
893
+ var storyProtocolReadable = abitype.formatAbi(storyProtocolAbi);
894
+ var storyProtocolConfig = {
895
+ abi: viem.parseAbi(storyProtocolReadable),
896
+ address: viem.getAddress(process.env.STORY_PROTOCOL_CONTRACT || process.env.NEXT_PUBLIC_STORY_PROTOCOL_CONTRACT || "")
897
+ };
898
+
899
+ if (typeof process !== "undefined") {
900
+ dotenv__namespace.config();
901
+ }
902
+ var ipOrgControllerAbi = [{
903
+ anonymous: false,
904
+ inputs: [{
905
+ indexed: false,
906
+ internalType: "address",
907
+ name: "owner_",
908
+ type: "address"
909
+ }, {
910
+ indexed: false,
911
+ internalType: "address",
912
+ name: "ipAssetOrg_",
913
+ type: "address"
914
+ }, {
915
+ indexed: false,
916
+ internalType: "string",
917
+ name: "name_",
918
+ type: "string"
919
+ }, {
920
+ indexed: false,
921
+ internalType: "string",
922
+ name: "symbol_",
923
+ type: "string"
924
+ }],
925
+ name: "IPOrgRegistered",
926
+ type: "event"
927
+ }];
928
+ var ipOrgControllerReadable = abitype.formatAbi(ipOrgControllerAbi);
929
+ var ipOrgControllerConfig = {
930
+ abi: viem.parseAbi(ipOrgControllerReadable),
931
+ address: viem.getAddress(process.env.IP_ORG_CONTROLLER_CONTRACT || process.env.NEXT_PUBLIC_IP_ORG_CONTROLLER_CONTRACT || "")
932
+ };
933
+
934
+ function _arrayLikeToArray(arr, len) {
935
+ if (len == null || len > arr.length) len = arr.length;
936
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
937
+ return arr2;
938
+ }
939
+
940
+ function _unsupportedIterableToArray(o, minLen) {
941
+ if (!o) return;
942
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
943
+ var n = Object.prototype.toString.call(o).slice(8, -1);
944
+ if (n === "Object" && o.constructor) n = o.constructor.name;
945
+ if (n === "Map" || n === "Set") return Array.from(o);
946
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
947
+ }
948
+
949
+ function _createForOfIteratorHelper(o, allowArrayLike) {
950
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
951
+ if (!it) {
952
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
953
+ if (it) o = it;
954
+ var i = 0;
955
+ var F = function () {};
956
+ return {
957
+ s: F,
958
+ n: function () {
959
+ if (i >= o.length) return {
960
+ done: true
961
+ };
962
+ return {
963
+ done: false,
964
+ value: o[i++]
965
+ };
966
+ },
967
+ e: function (e) {
968
+ throw e;
969
+ },
970
+ f: F
971
+ };
972
+ }
973
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
974
+ }
975
+ var normalCompletion = true,
976
+ didErr = false,
977
+ err;
978
+ return {
979
+ s: function () {
980
+ it = it.call(o);
981
+ },
982
+ n: function () {
983
+ var step = it.next();
984
+ normalCompletion = step.done;
985
+ return step;
986
+ },
987
+ e: function (e) {
988
+ didErr = true;
989
+ err = e;
990
+ },
991
+ f: function () {
992
+ try {
993
+ if (!normalCompletion && it.return != null) it.return();
994
+ } finally {
995
+ if (didErr) throw err;
996
+ }
997
+ }
998
+ };
999
+ }
1000
+
1001
+ function isIntegerString(s) {
1002
+ var num = Number(s);
1003
+ return !isNaN(num) && parseInt(s, 10) === num;
1004
+ }
1005
+ function parseToBigInt(num) {
1006
+ return BigInt(num);
1007
+ }
1008
+ function fileToBase64(file) {
1009
+ return new Promise(function (resolve, reject) {
1010
+ // convert file to base64
1011
+ if (file instanceof Buffer) {
1012
+ resolve(file.toString("base64"));
1013
+ return;
1014
+ }
1015
+ if (file instanceof File) {
1016
+ var reader = new FileReader();
1017
+ reader.readAsDataURL(file);
1018
+ reader.onload = function () {
1019
+ var _reader$result;
1020
+ var base64 = (_reader$result = reader.result) === null || _reader$result === void 0 ? void 0 : _reader$result.toString().split(",")[1];
1021
+ if (base64) {
1022
+ resolve(base64);
1023
+ } else {
1024
+ reject(new Error("Failed to convert file to base64"));
1025
+ }
1026
+ };
1027
+ reader.onerror = function (error) {
1028
+ return reject(error);
1029
+ };
1030
+ return;
1031
+ }
1032
+ reject(new Error("Invalid file type"));
1033
+ });
1034
+ }
1035
+ function waitTxAndFilterLog(_x, _x2, _x3) {
1036
+ return _waitTxAndFilterLog.apply(this, arguments);
1037
+ }
1038
+ function _waitTxAndFilterLog() {
1039
+ _waitTxAndFilterLog = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(client, txHash, params) {
1040
+ var txReceipt, _iterator, _step, log;
1041
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1042
+ while (1) switch (_context.prev = _context.next) {
1043
+ case 0:
1044
+ _context.next = 2;
1045
+ return client.waitForTransactionReceipt({
1046
+ hash: txHash,
1047
+ confirmations: params.confirmations,
1048
+ pollingInterval: params.pollingInterval,
1049
+ timeout: params.timeout
1050
+ });
1051
+ case 2:
1052
+ txReceipt = _context.sent;
1053
+ _iterator = _createForOfIteratorHelper(txReceipt.logs);
1054
+ _context.prev = 4;
1055
+ _iterator.s();
1056
+ case 6:
1057
+ if ((_step = _iterator.n()).done) {
1058
+ _context.next = 17;
1059
+ break;
1060
+ }
1061
+ log = _step.value;
1062
+ _context.prev = 8;
1063
+ return _context.abrupt("return", viem.decodeEventLog({
1064
+ abi: params.abi,
1065
+ eventName: params.eventName,
1066
+ data: log.data,
1067
+ topics: log.topics
1068
+ }));
1069
+ case 12:
1070
+ _context.prev = 12;
1071
+ _context.t0 = _context["catch"](8);
1072
+ return _context.abrupt("continue", 15);
1073
+ case 15:
1074
+ _context.next = 6;
1075
+ break;
1076
+ case 17:
1077
+ _context.next = 22;
1078
+ break;
1079
+ case 19:
1080
+ _context.prev = 19;
1081
+ _context.t1 = _context["catch"](4);
1082
+ _iterator.e(_context.t1);
1083
+ case 22:
1084
+ _context.prev = 22;
1085
+ _iterator.f();
1086
+ return _context.finish(22);
1087
+ case 25:
1088
+ throw new Error("not found event ".concat(params.eventName, " in target transaction"));
1089
+ case 26:
1090
+ case "end":
1091
+ return _context.stop();
1092
+ }
1093
+ }, _callee, null, [[4, 19, 22, 25], [8, 12]]);
1094
+ }));
1095
+ return _waitTxAndFilterLog.apply(this, arguments);
1096
+ }
1097
+
1098
+ /**
1099
+ * IPOrgClient allows you to create, update, view, search IPOrgs on
1100
+ * Story Protocol.
1101
+ */
1102
+ var IPOrgClient = /*#__PURE__*/function (_IPOrgReadOnlyClient) {
1103
+ _inherits(IPOrgClient, _IPOrgReadOnlyClient);
1104
+ var _super = _createSuper(IPOrgClient);
1105
+ function IPOrgClient(httpClient, rpcClient, wallet) {
1106
+ var _this;
1107
+ _classCallCheck(this, IPOrgClient);
1108
+ _this = _super.call(this, httpClient, rpcClient);
1109
+ _this.wallet = wallet;
1110
+ return _this;
1111
+ }
1112
+
1113
+ /**
1114
+ * Create a IPOrg on Story Protocol based on the specified input IPOrg data.
1115
+ *
1116
+ * @param request - the request object that contains all data needed to create a IPOrg
1117
+ * @returns the response object that contains results from the create IPOrg action
1118
+ */
1119
+ _createClass(IPOrgClient, [{
1120
+ key: "create",
1121
+ value: function () {
1122
+ var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
1123
+ var _request$txOptions, _yield$this$rpcClient, call, txHash, targetLog;
1124
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1125
+ while (1) switch (_context.prev = _context.next) {
1126
+ case 0:
1127
+ _context.prev = 0;
1128
+ _context.next = 3;
1129
+ return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, storyProtocolConfig), {}, {
1130
+ functionName: "registerIpOrg",
1131
+ args: [viem.getAddress(request.owner || viem.zeroAddress), request.name, request.symbol, request.ipAssetTypes],
1132
+ account: this.wallet.account
1133
+ }));
1134
+ case 3:
1135
+ _yield$this$rpcClient = _context.sent;
1136
+ call = _yield$this$rpcClient.request;
1137
+ _context.next = 7;
1138
+ return this.wallet.writeContract(call);
1139
+ case 7:
1140
+ txHash = _context.sent;
1141
+ if (!((_request$txOptions = request.txOptions) !== null && _request$txOptions !== void 0 && _request$txOptions.waitForTransaction)) {
1142
+ _context.next = 15;
1143
+ break;
1144
+ }
1145
+ _context.next = 11;
1146
+ return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, ipOrgControllerConfig), {}, {
1147
+ eventName: "IPOrgRegistered"
1148
+ }));
1149
+ case 11:
1150
+ targetLog = _context.sent;
1151
+ return _context.abrupt("return", {
1152
+ txHash: txHash,
1153
+ ipOrgId: targetLog.args.ipAssetOrg_
1154
+ });
1155
+ case 15:
1156
+ return _context.abrupt("return", {
1157
+ txHash: txHash
1158
+ });
1159
+ case 16:
1160
+ _context.next = 21;
1161
+ break;
1162
+ case 18:
1163
+ _context.prev = 18;
1164
+ _context.t0 = _context["catch"](0);
1165
+ handleError(_context.t0, "Failed to create IPOrg");
1166
+ case 21:
1167
+ case "end":
1168
+ return _context.stop();
1169
+ }
1170
+ }, _callee, this, [[0, 18]]);
1171
+ }));
1172
+ function create(_x) {
1173
+ return _create.apply(this, arguments);
1174
+ }
1175
+ return create;
1176
+ }()
1177
+ }]);
1178
+ return IPOrgClient;
1179
+ }(IPOrgReadOnlyClient);
1180
+
1181
+ /**
1182
+ * Client for managing relationships.
1183
+ */
1184
+ var RelationshipReadOnlyClient = /*#__PURE__*/function () {
1185
+ function RelationshipReadOnlyClient(httpClient, rpcClient) {
1186
+ _classCallCheck(this, RelationshipReadOnlyClient);
1187
+ this.httpClient = httpClient;
1188
+ this.rpcClient = rpcClient;
1189
+ }
1190
+
1191
+ /**
1192
+ * Get a relationship by its ID.
1193
+ *
1194
+ * @param relationshipId - The ID of the relationship to retrieve.
1195
+ * @returns A Promise that resolves to the RelationshipGetResponse.
1196
+ */
1197
+ _createClass(RelationshipReadOnlyClient, [{
1198
+ key: "get",
1199
+ value: function () {
1200
+ var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
1201
+ var response;
1202
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1203
+ while (1) switch (_context.prev = _context.next) {
1204
+ case 0:
1205
+ _context.prev = 0;
1206
+ if (isIntegerString(request.relationshipId)) {
1207
+ _context.next = 3;
1208
+ break;
1209
+ }
1210
+ throw new Error("Invalid relationshipId. Must be an integer. But got: ".concat(request.relationshipId));
1211
+ case 3:
1212
+ _context.next = 5;
1213
+ return this.httpClient.get("/protocol/relationship/".concat(request.relationshipId));
1214
+ case 5:
1215
+ response = _context.sent;
1216
+ return _context.abrupt("return", response.data);
1217
+ case 9:
1218
+ _context.prev = 9;
1219
+ _context.t0 = _context["catch"](0);
1220
+ handleError(_context.t0, "Failed to get relationship");
1221
+ case 12:
1222
+ case "end":
1223
+ return _context.stop();
1224
+ }
1225
+ }, _callee, this, [[0, 9]]);
1226
+ }));
1227
+ function get(_x) {
1228
+ return _get.apply(this, arguments);
1229
+ }
1230
+ return get;
1231
+ }()
1232
+ /**
1233
+ * List all relationships.
1234
+ *
1235
+ * @returns A Promise that resolves to the RelationshipListResponse.
1236
+ */
1237
+ }, {
1238
+ key: "list",
1239
+ value: function () {
1240
+ var _list = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
1241
+ var response;
1242
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1243
+ while (1) switch (_context2.prev = _context2.next) {
1244
+ case 0:
1245
+ _context2.prev = 0;
1246
+ _context2.next = 3;
1247
+ return this.httpClient.post("/protocol/relationship", request, {
1248
+ params: {
1249
+ contract: (request === null || request === void 0 ? void 0 : request.contract) || process.env.IP_ASSET_REGISTRY_CONTRACT || process.env.NEXT_PUBLIC_IP_ASSET_REGISTRY_CONTRACT,
1250
+ tokenId: request === null || request === void 0 ? void 0 : request.tokenId
1251
+ }
1252
+ });
1253
+ case 3:
1254
+ response = _context2.sent;
1255
+ return _context2.abrupt("return", response.data);
1256
+ case 7:
1257
+ _context2.prev = 7;
1258
+ _context2.t0 = _context2["catch"](0);
1259
+ handleError(_context2.t0, "Failed to list relationships");
1260
+ case 10:
1261
+ case "end":
1262
+ return _context2.stop();
1263
+ }
1264
+ }, _callee2, this, [[0, 7]]);
1265
+ }));
1266
+ function list(_x2) {
1267
+ return _list.apply(this, arguments);
1268
+ }
1269
+ return list;
1270
+ }()
1271
+ }]);
1272
+ return RelationshipReadOnlyClient;
1273
+ }();
1274
+
1275
+ /**
1276
+ * IpAssetClient allows you to create, view, and list IP Assets on Story Protocol.
1277
+ */
1278
+ var IPAssetReadOnlyClient = /*#__PURE__*/function () {
1279
+ function IPAssetReadOnlyClient(httpClient, rpcClient) {
1280
+ _classCallCheck(this, IPAssetReadOnlyClient);
1281
+ this.httpClient = httpClient;
1282
+ this.rpcClient = rpcClient;
1283
+ }
1284
+
1285
+ /**
1286
+ * Get an IP Asset based on the specified IP asset ID.
1287
+ *
1288
+ * @param request - the request object for getting an IP Asset.
1289
+ * @returns the response object the contains the fetched IP Asset.
1290
+ */
1291
+ _createClass(IPAssetReadOnlyClient, [{
1292
+ key: "get",
1293
+ value: function () {
1294
+ var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
1295
+ var response;
1296
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1297
+ while (1) switch (_context.prev = _context.next) {
1298
+ case 0:
1299
+ _context.prev = 0;
1300
+ if (isIntegerString(request.ipAssetId)) {
1301
+ _context.next = 3;
1302
+ break;
1303
+ }
1304
+ throw new Error("Invalid IP Asset id. Must be an integer. But get: ".concat(request.ipAssetId));
1305
+ case 3:
1306
+ _context.next = 5;
1307
+ return this.httpClient.get("/protocol/ipasset/".concat(request.ipAssetId));
1308
+ case 5:
1309
+ response = _context.sent;
1310
+ return _context.abrupt("return", response.data);
1311
+ case 9:
1312
+ _context.prev = 9;
1313
+ _context.t0 = _context["catch"](0);
1314
+ handleError(_context.t0, "Failed to get IP Asset");
1315
+ case 12:
1316
+ case "end":
1317
+ return _context.stop();
1318
+ }
1319
+ }, _callee, this, [[0, 9]]);
1320
+ }));
1321
+ function get(_x) {
1322
+ return _get.apply(this, arguments);
1323
+ }
1324
+ return get;
1325
+ }()
1326
+ /**
1327
+ * List all IP assets.
1328
+ *
1329
+ * @returns the response object that contains results from listing query.
1330
+ */
1331
+ }, {
1332
+ key: "list",
1333
+ value: function () {
1334
+ var _list = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
1335
+ var response;
1336
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1337
+ while (1) switch (_context2.prev = _context2.next) {
1338
+ case 0:
1339
+ _context2.prev = 0;
1340
+ _context2.next = 3;
1341
+ return this.httpClient.post("/protocol/ipasset", request);
1342
+ case 3:
1343
+ response = _context2.sent;
1344
+ return _context2.abrupt("return", response.data);
1345
+ case 7:
1346
+ _context2.prev = 7;
1347
+ _context2.t0 = _context2["catch"](0);
1348
+ handleError(_context2.t0, "Failed to list IP Asset.");
1349
+ case 10:
1350
+ case "end":
1351
+ return _context2.stop();
1352
+ }
1353
+ }, _callee2, this, [[0, 7]]);
1354
+ }));
1355
+ function list(_x2) {
1356
+ return _list.apply(this, arguments);
1357
+ }
1358
+ return list;
1359
+ }()
1360
+ }]);
1361
+ return IPAssetReadOnlyClient;
1362
+ }();
1363
+
1364
+ if (typeof process !== "undefined") {
1365
+ dotenv__namespace.config();
1366
+ }
1367
+ var registrationModuleAbi = [{
1368
+ anonymous: false,
1369
+ inputs: [{
1370
+ indexed: false,
1371
+ internalType: "uint256",
1372
+ name: "ipAssetId_",
1373
+ type: "uint256"
1374
+ }, {
1375
+ indexed: true,
1376
+ internalType: "address",
1377
+ name: "ipOrg_",
1378
+ type: "address"
1379
+ }, {
1380
+ indexed: false,
1381
+ internalType: "uint256",
1382
+ name: "ipOrgAssetId_",
1383
+ type: "uint256"
1384
+ }, {
1385
+ indexed: true,
1386
+ internalType: "address",
1387
+ name: "owner_",
1388
+ type: "address"
1389
+ }, {
1390
+ indexed: false,
1391
+ internalType: "string",
1392
+ name: "name_",
1393
+ type: "string"
1394
+ }, {
1395
+ indexed: true,
1396
+ internalType: "uint64",
1397
+ name: "ipAssetType_",
1398
+ type: "uint64"
1399
+ }, {
1400
+ indexed: false,
1401
+ internalType: "bytes32",
1402
+ name: "hash_",
1403
+ type: "bytes32"
1404
+ }, {
1405
+ indexed: false,
1406
+ internalType: "string",
1407
+ name: "mediaUrl_",
1408
+ type: "string"
1409
+ }],
1410
+ name: "IPAssetRegistered",
1411
+ type: "event"
1412
+ }];
1413
+ var registrationModuleReadable = abitype.formatAbi(registrationModuleAbi);
1414
+ var registrationModuleConfig = {
1415
+ abi: viem.parseAbi(registrationModuleReadable),
1416
+ address: viem.getAddress(process.env.REGISTRATION_MODULE_CONTRACT || process.env.NEXT_PUBLIC_REGISTRATION_MODULE_CONTRACT || "")
1417
+ };
1418
+
1419
+ /**
1420
+ * IpAssetClient allows you to create, view, and list IP Assets on Story Protocol.
1421
+ */
1422
+ var IPAssetClient = /*#__PURE__*/function (_IPAssetReadOnlyClien) {
1423
+ _inherits(IPAssetClient, _IPAssetReadOnlyClien);
1424
+ var _super = _createSuper(IPAssetClient);
1425
+ function IPAssetClient(httpClient, rpcClient, wallet) {
1426
+ var _this;
1427
+ _classCallCheck(this, IPAssetClient);
1428
+ _this = _super.call(this, httpClient, rpcClient);
1429
+ _this.wallet = wallet;
1430
+ return _this;
1431
+ }
1432
+
1433
+ /**
1434
+ * Create an IP Asset on Story Protocol based on the specified input asset data.
1435
+ *
1436
+ * @param request - the request object that contains all data needed to create an IP Asset.
1437
+ * @returns the response object that contains results from the asset creation.
1438
+ */
1439
+ _createClass(IPAssetClient, [{
1440
+ key: "create",
1441
+ value: function () {
1442
+ var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
1443
+ var _request$txOptions, _yield$this$rpcClient, call, txHash, targetLog;
1444
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1445
+ while (1) switch (_context.prev = _context.next) {
1446
+ case 0:
1447
+ _context.prev = 0;
1448
+ _context.next = 3;
1449
+ return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, storyProtocolConfig), {}, {
1450
+ functionName: "registerIPAsset",
1451
+ args: [viem.getAddress(request.ipOrgId), {
1452
+ owner: viem.getAddress(request.owner),
1453
+ name: request.name,
1454
+ ipAssetType: parseToBigInt(request.type),
1455
+ hash: viem.toHex(request.contentHash || "", {
1456
+ size: 32
1457
+ }),
1458
+ mediaUrl: request.mediaUrl || ""
1459
+ }, [], []],
1460
+ account: this.wallet.account
1461
+ }));
1462
+ case 3:
1463
+ _yield$this$rpcClient = _context.sent;
1464
+ call = _yield$this$rpcClient.request;
1465
+ _context.next = 7;
1466
+ return this.wallet.writeContract(call);
1467
+ case 7:
1468
+ txHash = _context.sent;
1469
+ if (!((_request$txOptions = request.txOptions) !== null && _request$txOptions !== void 0 && _request$txOptions.waitForTransaction)) {
1470
+ _context.next = 15;
1471
+ break;
1472
+ }
1473
+ _context.next = 11;
1474
+ return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, registrationModuleConfig), {}, {
1475
+ eventName: "IPAssetRegistered"
1476
+ }));
1477
+ case 11:
1478
+ targetLog = _context.sent;
1479
+ return _context.abrupt("return", {
1480
+ txHash: txHash,
1481
+ ipAssetId: targetLog.args.ipAssetId_.toString()
1482
+ });
1483
+ case 15:
1484
+ return _context.abrupt("return", {
1485
+ txHash: txHash
1486
+ });
1487
+ case 16:
1488
+ _context.next = 21;
1489
+ break;
1490
+ case 18:
1491
+ _context.prev = 18;
1492
+ _context.t0 = _context["catch"](0);
1493
+ handleError(_context.t0, "Failed to create IP Asset");
1494
+ case 21:
1495
+ case "end":
1496
+ return _context.stop();
1497
+ }
1498
+ }, _callee, this, [[0, 18]]);
1499
+ }));
1500
+ function create(_x) {
1501
+ return _create.apply(this, arguments);
1502
+ }
1503
+ return create;
1504
+ }()
1505
+ }]);
1506
+ return IPAssetClient;
1507
+ }(IPAssetReadOnlyClient);
1508
+
1509
+ /**
1510
+ * A class representing License operations.
1511
+ *
1512
+ * @public
1513
+ */
1514
+ var LicenseReadOnlyClient = /*#__PURE__*/function () {
1515
+ function LicenseReadOnlyClient(httpClient, rpcClient) {
1516
+ _classCallCheck(this, LicenseReadOnlyClient);
1517
+ this.httpClient = httpClient;
1518
+ this.rpcClient = rpcClient;
1519
+ }
1520
+
1521
+ /**
1522
+ * Get a license by its ID.
1523
+ *
1524
+ * @param licenseId - The ID of the license to retrieve.
1525
+ * @returns A Promise that resolves to the GetLicenseResponse.
1526
+ */
1527
+ _createClass(LicenseReadOnlyClient, [{
1528
+ key: "get",
1529
+ value: function () {
1530
+ var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
1531
+ var response;
1532
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1533
+ while (1) switch (_context.prev = _context.next) {
1534
+ case 0:
1535
+ _context.prev = 0;
1536
+ if (isIntegerString(request.licenseId)) {
1537
+ _context.next = 3;
1538
+ break;
1539
+ }
1540
+ throw new Error("Invalid licenseId. Must be an integer. But got: ".concat(request.licenseId));
1541
+ case 3:
1542
+ _context.next = 5;
1543
+ return this.httpClient.get("/protocol/license/".concat(request.licenseId));
1544
+ case 5:
1545
+ response = _context.sent;
1546
+ return _context.abrupt("return", response.data);
1547
+ case 9:
1548
+ _context.prev = 9;
1549
+ _context.t0 = _context["catch"](0);
1550
+ handleError(_context.t0, "Failed to get license");
1551
+ case 12:
1552
+ case "end":
1553
+ return _context.stop();
1554
+ }
1555
+ }, _callee, this, [[0, 9]]);
1556
+ }));
1557
+ function get(_x) {
1558
+ return _get.apply(this, arguments);
1559
+ }
1560
+ return get;
1561
+ }()
1562
+ /**
1563
+ * List all licenses.
1564
+ *
1565
+ * @returns A Promise that resolves to the ListLicenseResponse.
1566
+ */
1567
+ }, {
1568
+ key: "list",
1569
+ value: function () {
1570
+ var _list = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
1571
+ var response;
1572
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1573
+ while (1) switch (_context2.prev = _context2.next) {
1574
+ case 0:
1575
+ _context2.prev = 0;
1576
+ _context2.next = 3;
1577
+ return this.httpClient.post("/protocol/license", request, {
1578
+ params: {
1579
+ ipOrgId: request === null || request === void 0 ? void 0 : request.ipOrgId,
1580
+ ipAssetId: request === null || request === void 0 ? void 0 : request.ipAssetId,
1581
+ options: request === null || request === void 0 ? void 0 : request.options
1582
+ }
1583
+ });
1584
+ case 3:
1585
+ response = _context2.sent;
1586
+ return _context2.abrupt("return", response.data);
1587
+ case 7:
1588
+ _context2.prev = 7;
1589
+ _context2.t0 = _context2["catch"](0);
1590
+ handleError(_context2.t0, "Failed to get licenses");
1591
+ case 10:
1592
+ case "end":
1593
+ return _context2.stop();
1594
+ }
1595
+ }, _callee2, this, [[0, 7]]);
1596
+ }));
1597
+ function list(_x2) {
1598
+ return _list.apply(this, arguments);
1599
+ }
1600
+ return list;
1601
+ }()
1602
+ }]);
1603
+ return LicenseReadOnlyClient;
1604
+ }();
1605
+
1606
+ /**
1607
+ * TransactionClient allows you to view and monitor transactions on
1608
+ * Story Protocol.
1609
+ */
1610
+ var TransactionReadOnlyClient = /*#__PURE__*/function () {
1611
+ function TransactionReadOnlyClient(httpClient, rpcClient) {
1612
+ _classCallCheck(this, TransactionReadOnlyClient);
1613
+ this.httpClient = httpClient;
1614
+ this.rpcClient = rpcClient;
1615
+ }
1616
+
1617
+ /**
1618
+ * Get transaction data based on the specified transaction id.
1619
+ *
1620
+ * @param request - the request object for getting the transaction
1621
+ * @returns the response object that contains the fetched transaction object
1622
+ */
1623
+ _createClass(TransactionReadOnlyClient, [{
1624
+ key: "get",
1625
+ value: function () {
1626
+ var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
1627
+ var response;
1628
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1629
+ while (1) switch (_context.prev = _context.next) {
1630
+ case 0:
1631
+ _context.prev = 0;
1632
+ _context.next = 3;
1633
+ return this.httpClient.get("/protocol/transaction/".concat(request.transactionId));
1634
+ case 3:
1635
+ response = _context.sent;
1636
+ return _context.abrupt("return", response.data);
1637
+ case 7:
1638
+ _context.prev = 7;
1639
+ _context.t0 = _context["catch"](0);
1640
+ handleError(_context.t0, "Failed to get transaction");
1641
+ case 10:
1642
+ case "end":
1643
+ return _context.stop();
1644
+ }
1645
+ }, _callee, this, [[0, 7]]);
1646
+ }));
1647
+ function get(_x) {
1648
+ return _get.apply(this, arguments);
1649
+ }
1650
+ return get;
1651
+ }()
1652
+ /**
1653
+ * Get transaction data based on the specified transaction id.
1654
+ *
1655
+ * @param request - the request object for getting the transactions
1656
+ * @returns the response object that contains the fetched transaction object
1657
+ */
1658
+ }, {
1659
+ key: "list",
1660
+ value: function () {
1661
+ var _list = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
1662
+ var response;
1663
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1664
+ while (1) switch (_context2.prev = _context2.next) {
1665
+ case 0:
1666
+ _context2.prev = 0;
1667
+ _context2.next = 3;
1668
+ return this.httpClient.post("/protocol/transaction", request);
1669
+ case 3:
1670
+ response = _context2.sent;
1671
+ return _context2.abrupt("return", response.data);
1672
+ case 7:
1673
+ _context2.prev = 7;
1674
+ _context2.t0 = _context2["catch"](0);
1675
+ handleError(_context2.t0, "Failed to get transactions");
1676
+ case 10:
1677
+ case "end":
1678
+ return _context2.stop();
1679
+ }
1680
+ }, _callee2, this, [[0, 7]]);
1681
+ }));
1682
+ function list(_x2) {
1683
+ return _list.apply(this, arguments);
1684
+ }
1685
+ return list;
1686
+ }()
1687
+ }]);
1688
+ return TransactionReadOnlyClient;
1689
+ }();
1690
+
1691
+ /**
1692
+ * TransactionClient allows you to view and monitor transactions on
1693
+ * Story Protocol.
1694
+ */
1695
+ var TransactionClient = /*#__PURE__*/function (_TransactionReadOnlyC) {
1696
+ _inherits(TransactionClient, _TransactionReadOnlyC);
1697
+ var _super = _createSuper(TransactionClient);
1698
+ function TransactionClient(httpClient, rpcClient, wallet) {
1699
+ var _this;
1700
+ _classCallCheck(this, TransactionClient);
1701
+ _this = _super.call(this, httpClient, rpcClient);
1702
+ _this.wallet = wallet;
1703
+ return _this;
1704
+ }
1705
+ return _createClass(TransactionClient);
1706
+ }(TransactionReadOnlyClient);
1707
+
1708
+ /**
1709
+ * Default timeout value for http clients.
1710
+ */
1711
+ var HTTP_TIMEOUT = 5000;
1712
+
1713
+ /**
1714
+ * ModuleClient allows you to view and monitor modules on
1715
+ * Story Protocol.
1716
+ */
1717
+ var ModuleReadOnlyClient = /*#__PURE__*/function () {
1718
+ function ModuleReadOnlyClient(httpClient, rpcClient) {
1719
+ _classCallCheck(this, ModuleReadOnlyClient);
1720
+ this.httpClient = httpClient;
1721
+ this.rpcClient = rpcClient;
1722
+ }
1723
+
1724
+ /**
1725
+ * Get module data based on the specified module id.
1726
+ *
1727
+ * @param request - the request object for getting the module
1728
+ * @returns the response object that contains the fetched module object
1729
+ */
1730
+ _createClass(ModuleReadOnlyClient, [{
1731
+ key: "get",
1732
+ value: function () {
1733
+ var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
1734
+ var response;
1735
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1736
+ while (1) switch (_context.prev = _context.next) {
1737
+ case 0:
1738
+ _context.prev = 0;
1739
+ _context.next = 3;
1740
+ return this.httpClient.get("/protocol/module/".concat(request.moduleId));
1741
+ case 3:
1742
+ response = _context.sent;
1743
+ return _context.abrupt("return", response.data);
1744
+ case 7:
1745
+ _context.prev = 7;
1746
+ _context.t0 = _context["catch"](0);
1747
+ handleError(_context.t0, "Failed to get module");
1748
+ case 10:
1749
+ case "end":
1750
+ return _context.stop();
1751
+ }
1752
+ }, _callee, this, [[0, 7]]);
1753
+ }));
1754
+ function get(_x) {
1755
+ return _get.apply(this, arguments);
1756
+ }
1757
+ return get;
1758
+ }()
1759
+ /**
1760
+ * Get module data based on the specified module id.
1761
+ *
1762
+ * @param request - the request object for getting the modules
1763
+ * @returns the response object that contains the fetched module object
1764
+ */
1765
+ }, {
1766
+ key: "list",
1767
+ value: function () {
1768
+ var _list = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
1769
+ var response;
1770
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1771
+ while (1) switch (_context2.prev = _context2.next) {
1772
+ case 0:
1773
+ _context2.prev = 0;
1774
+ _context2.next = 3;
1775
+ return this.httpClient.post("/protocol/module", request, {
1776
+ params: {
1777
+ ipOrgId: request === null || request === void 0 ? void 0 : request.ipOrgId
1778
+ }
1779
+ });
1780
+ case 3:
1781
+ response = _context2.sent;
1782
+ return _context2.abrupt("return", response.data);
1783
+ case 7:
1784
+ _context2.prev = 7;
1785
+ _context2.t0 = _context2["catch"](0);
1786
+ handleError(_context2.t0, "Failed to get modules");
1787
+ case 10:
1788
+ case "end":
1789
+ return _context2.stop();
1790
+ }
1791
+ }, _callee2, this, [[0, 7]]);
1792
+ }));
1793
+ function list(_x2) {
1794
+ return _list.apply(this, arguments);
1795
+ }
1796
+ return list;
1797
+ }()
1798
+ }]);
1799
+ return ModuleReadOnlyClient;
1800
+ }();
1801
+
1802
+ /**
1803
+ * ModuleClient allows you to view and monitor modules on
1804
+ * Story Protocol.
1805
+ */
1806
+ var ModuleClient = /*#__PURE__*/function (_ModuleReadOnlyClient) {
1807
+ _inherits(ModuleClient, _ModuleReadOnlyClient);
1808
+ var _super = _createSuper(ModuleClient);
1809
+ function ModuleClient(httpClient, rpcClient, wallet) {
1810
+ var _this;
1811
+ _classCallCheck(this, ModuleClient);
1812
+ _this = _super.call(this, httpClient, rpcClient);
1813
+ _this.wallet = wallet;
1814
+ return _this;
1815
+ }
1816
+ return _createClass(ModuleClient);
1817
+ }(ModuleReadOnlyClient);
1818
+
1819
+ /**
1820
+ * HookClient allows you to view and monitor hooks on
1821
+ * Story Protocol.
1822
+ */
1823
+ var HookReadOnlyClient = /*#__PURE__*/function () {
1824
+ function HookReadOnlyClient(httpClient, rpcClient) {
1825
+ _classCallCheck(this, HookReadOnlyClient);
1826
+ this.httpClient = httpClient;
1827
+ this.rpcClient = rpcClient;
1828
+ }
1829
+
1830
+ /**
1831
+ * Get hook data based on the specified hook id.
1832
+ *
1833
+ * @param request - the request object for getting the hook
1834
+ * @returns the response object that contains the fetched hook object
1835
+ */
1836
+ _createClass(HookReadOnlyClient, [{
1837
+ key: "get",
1838
+ value: function () {
1839
+ var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
1840
+ var response;
1841
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1842
+ while (1) switch (_context.prev = _context.next) {
1843
+ case 0:
1844
+ _context.prev = 0;
1845
+ _context.next = 3;
1846
+ return this.httpClient.get("/protocol/hook/".concat(request.hookId));
1847
+ case 3:
1848
+ response = _context.sent;
1849
+ return _context.abrupt("return", response.data);
1850
+ case 7:
1851
+ _context.prev = 7;
1852
+ _context.t0 = _context["catch"](0);
1853
+ handleError(_context.t0, "Failed to get hook");
1854
+ case 10:
1855
+ case "end":
1856
+ return _context.stop();
1857
+ }
1858
+ }, _callee, this, [[0, 7]]);
1859
+ }));
1860
+ function get(_x) {
1861
+ return _get.apply(this, arguments);
1862
+ }
1863
+ return get;
1864
+ }()
1865
+ /**
1866
+ * Get hook data based on the specified hook id.
1867
+ *
1868
+ * @param request - the request object for getting the hooks
1869
+ * @returns the response object that contains the fetched hook object
1870
+ */
1871
+ }, {
1872
+ key: "list",
1873
+ value: function () {
1874
+ var _list = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
1875
+ var response;
1876
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1877
+ while (1) switch (_context2.prev = _context2.next) {
1878
+ case 0:
1879
+ _context2.prev = 0;
1880
+ _context2.next = 3;
1881
+ return this.httpClient.post("/protocol/hook", request, {
1882
+ params: {
1883
+ moduleId: request === null || request === void 0 ? void 0 : request.moduleId
1884
+ }
1885
+ });
1886
+ case 3:
1887
+ response = _context2.sent;
1888
+ return _context2.abrupt("return", response.data);
1889
+ case 7:
1890
+ _context2.prev = 7;
1891
+ _context2.t0 = _context2["catch"](0);
1892
+ handleError(_context2.t0, "Failed to get hooks");
1893
+ case 10:
1894
+ case "end":
1895
+ return _context2.stop();
1896
+ }
1897
+ }, _callee2, this, [[0, 7]]);
1898
+ }));
1899
+ function list(_x2) {
1900
+ return _list.apply(this, arguments);
1901
+ }
1902
+ return list;
1903
+ }()
1904
+ }]);
1905
+ return HookReadOnlyClient;
1906
+ }();
1907
+
1908
+ /**
1909
+ * HookClient allows you to view and monitor hooks on
1910
+ * Story Protocol.
1911
+ */
1912
+ var HookClient = /*#__PURE__*/function (_HookReadOnlyClient) {
1913
+ _inherits(HookClient, _HookReadOnlyClient);
1914
+ var _super = _createSuper(HookClient);
1915
+ function HookClient(httpClient, rpcClient, wallet) {
1916
+ var _this;
1917
+ _classCallCheck(this, HookClient);
1918
+ _this = _super.call(this, httpClient, rpcClient);
1919
+ _this.wallet = wallet;
1920
+ return _this;
1921
+ }
1922
+ return _createClass(HookClient);
1923
+ }(HookReadOnlyClient);
1924
+
1925
+ var PlatformClient = /*#__PURE__*/function () {
1926
+ function PlatformClient(httpClient) {
1927
+ _classCallCheck(this, PlatformClient);
1928
+ this.httpClient = httpClient;
1929
+ }
1930
+
1931
+ /**
1932
+ * Upload a file to Arweave.
1933
+ *
1934
+ * @param file - the file binary data to upload
1935
+ * @param mimeType - the mime type of the file
1936
+ * @returns the response object that contains the uri of the uploaded file
1937
+ */
1938
+ _createClass(PlatformClient, [{
1939
+ key: "uploadFile",
1940
+ value: function () {
1941
+ var _uploadFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(file, mimeType) {
1942
+ var base64, paylod, response;
1943
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1944
+ while (1) switch (_context.prev = _context.next) {
1945
+ case 0:
1946
+ _context.prev = 0;
1947
+ _context.next = 3;
1948
+ return fileToBase64(file);
1949
+ case 3:
1950
+ base64 = _context.sent;
1951
+ paylod = {
1952
+ base64: base64,
1953
+ mimeType: mimeType
1954
+ };
1955
+ _context.next = 7;
1956
+ return this.httpClient.post("/protocol/v2/files/upload", paylod, {
1957
+ headers: {
1958
+ "Content-Type": "application/json"
1959
+ }
1960
+ });
1961
+ case 7:
1962
+ response = _context.sent;
1963
+ return _context.abrupt("return", response.data);
1964
+ case 11:
1965
+ _context.prev = 11;
1966
+ _context.t0 = _context["catch"](0);
1967
+ return _context.abrupt("return", handleError(_context.t0, "Failed to upload file"));
1968
+ case 14:
1969
+ case "end":
1970
+ return _context.stop();
1971
+ }
1972
+ }, _callee, this, [[0, 11]]);
1973
+ }));
1974
+ function uploadFile(_x, _x2) {
1975
+ return _uploadFile.apply(this, arguments);
1976
+ }
1977
+ return uploadFile;
1978
+ }()
1979
+ }]);
1980
+ return PlatformClient;
1981
+ }();
1982
+
1983
+ var licenseRegistryAbi = [{
1984
+ anonymous: false,
1985
+ inputs: [{
1986
+ indexed: true,
1987
+ internalType: "uint256",
1988
+ name: "id",
1989
+ type: "uint256"
1990
+ }],
1991
+ name: "LicenseRegistered",
1992
+ type: "event"
1993
+ }];
1994
+ abitype.formatAbi(licenseRegistryAbi);
1995
+ var licenseRegistryConfig = {
1996
+ abi: licenseRegistryAbi,
1997
+ address: viem.getAddress(process.env.LICENSE_REGISTRY_CONTRACT || process.env.NEXT_PUBLIC_LICENSE_REGISTRY_CONTRACT || "")
1998
+ };
1999
+
2000
+ /**
2001
+ * Client for managing relationships.
2002
+ */
2003
+ var LicenseClient = /*#__PURE__*/function (_LicenseReadOnlyClien) {
2004
+ _inherits(LicenseClient, _LicenseReadOnlyClien);
2005
+ var _super = _createSuper(LicenseClient);
2006
+ function LicenseClient(httpClient, rpcClient, wallet) {
2007
+ var _this;
2008
+ _classCallCheck(this, LicenseClient);
2009
+ _this = _super.call(this, httpClient, rpcClient);
2010
+ _this.wallet = wallet;
2011
+ return _this;
2012
+ }
2013
+ _createClass(LicenseClient, [{
2014
+ key: "create",
2015
+ value: function () {
2016
+ var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
2017
+ var functionName, args, _request$txOptions, _yield$this$rpcClient, call, txHash, _targetLog$args, targetLog;
2018
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
2019
+ while (1) switch (_context.prev = _context.next) {
2020
+ case 0:
2021
+ if (!this.isCreateLicenseNftRequest(request)) {
2022
+ _context.next = 5;
2023
+ break;
2024
+ }
2025
+ functionName = "createLicenseNft";
2026
+ args = [request.ipOrgId, {
2027
+ isCommercial: request.isCommercial,
2028
+ parentLicenseId: request.parentLicenseId || 0
2029
+ }, request.licensee, request.preHooksCalldata, request.postHooksCalldata];
2030
+ _context.next = 11;
2031
+ break;
2032
+ case 5:
2033
+ if (!this.isCreateIpaBoundLicenseRequest(request)) {
2034
+ _context.next = 10;
2035
+ break;
2036
+ }
2037
+ functionName = "createIpaBoundLicense";
2038
+ args = [request.ipOrgId, {
2039
+ isCommercial: request.isCommercial,
2040
+ parentLicenseId: request.parentLicenseId || 0
2041
+ }, request.ipaId, request.preHooksCalldata, request.postHooksCalldata];
2042
+ _context.next = 11;
2043
+ break;
2044
+ case 10:
2045
+ throw new Error("Invalid request type");
2046
+ case 11:
2047
+ _context.prev = 11;
2048
+ _context.next = 14;
2049
+ return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, storyProtocolConfig), {}, {
2050
+ functionName: functionName,
2051
+ args: args,
2052
+ account: this.wallet.account
2053
+ }));
2054
+ case 14:
2055
+ _yield$this$rpcClient = _context.sent;
2056
+ call = _yield$this$rpcClient.request;
2057
+ _context.next = 18;
2058
+ return this.wallet.writeContract(call);
2059
+ case 18:
2060
+ txHash = _context.sent;
2061
+ if (!((_request$txOptions = request.txOptions) !== null && _request$txOptions !== void 0 && _request$txOptions.waitForTransaction)) {
2062
+ _context.next = 26;
2063
+ break;
2064
+ }
2065
+ _context.next = 22;
2066
+ return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, licenseRegistryConfig), {}, {
2067
+ eventName: "LicenseRegistered"
2068
+ }));
2069
+ case 22:
2070
+ targetLog = _context.sent;
2071
+ return _context.abrupt("return", {
2072
+ txHash: txHash,
2073
+ licenseId: targetLog === null || targetLog === void 0 || (_targetLog$args = targetLog.args) === null || _targetLog$args === void 0 ? void 0 : _targetLog$args.id.toString()
2074
+ });
2075
+ case 26:
2076
+ return _context.abrupt("return", {
2077
+ txHash: txHash
2078
+ });
2079
+ case 27:
2080
+ _context.next = 32;
2081
+ break;
2082
+ case 29:
2083
+ _context.prev = 29;
2084
+ _context.t0 = _context["catch"](11);
2085
+ handleError(_context.t0, "Failed to register license");
2086
+ case 32:
2087
+ case "end":
2088
+ return _context.stop();
2089
+ }
2090
+ }, _callee, this, [[11, 29]]);
2091
+ }));
2092
+ function create(_x) {
2093
+ return _create.apply(this, arguments);
2094
+ }
2095
+ return create;
2096
+ }()
2097
+ }, {
2098
+ key: "isCreateLicenseNftRequest",
2099
+ value: function isCreateLicenseNftRequest(request) {
2100
+ return request.licensee !== undefined;
2101
+ }
2102
+ }, {
2103
+ key: "isCreateIpaBoundLicenseRequest",
2104
+ value: function isCreateIpaBoundLicenseRequest(request) {
2105
+ return request.ipaId !== undefined;
2106
+ }
2107
+ }]);
2108
+ return LicenseClient;
2109
+ }(LicenseReadOnlyClient);
2110
+
2111
+ var relationshipModuleAbi = [
2112
+ // EVENTS
2113
+ {
2114
+ anonymous: false,
2115
+ inputs: [{
2116
+ indexed: true,
2117
+ internalType: "uint256",
2118
+ name: "relationshipId",
2119
+ type: "uint256"
2120
+ }, {
2121
+ indexed: true,
2122
+ internalType: "string",
2123
+ name: "relType",
2124
+ type: "string"
2125
+ }, {
2126
+ indexed: false,
2127
+ internalType: "address",
2128
+ name: "srcAddress",
2129
+ type: "address"
2130
+ }, {
2131
+ indexed: false,
2132
+ internalType: "uint256",
2133
+ name: "srcId",
2134
+ type: "uint256"
2135
+ }, {
2136
+ indexed: false,
2137
+ internalType: "address",
2138
+ name: "dstAddress",
2139
+ type: "address"
2140
+ }, {
2141
+ indexed: false,
2142
+ internalType: "uint256",
2143
+ name: "dstId",
2144
+ type: "uint256"
2145
+ }],
2146
+ name: "RelationshipCreated",
2147
+ type: "event"
2148
+ }, {
2149
+ anonymous: false,
2150
+ inputs: [{
2151
+ indexed: true,
2152
+ internalType: "string",
2153
+ name: "relType",
2154
+ type: "string"
2155
+ }, {
2156
+ indexed: true,
2157
+ internalType: "address",
2158
+ name: "ipOrg",
2159
+ type: "address"
2160
+ }, {
2161
+ indexed: false,
2162
+ internalType: "address",
2163
+ name: "src",
2164
+ type: "address"
2165
+ }, {
2166
+ indexed: false,
2167
+ internalType: "enum LibRelationship.Relatables",
2168
+ name: "srcRelatable",
2169
+ type: "uint8"
2170
+ }, {
2171
+ indexed: false,
2172
+ internalType: "uint256",
2173
+ name: "srcSubtypesMask",
2174
+ type: "uint256"
2175
+ }, {
2176
+ indexed: false,
2177
+ internalType: "address",
2178
+ name: "dst",
2179
+ type: "address"
2180
+ }, {
2181
+ indexed: false,
2182
+ internalType: "enum LibRelationship.Relatables",
2183
+ name: "dstRelatable",
2184
+ type: "uint8"
2185
+ }, {
2186
+ indexed: false,
2187
+ internalType: "uint256",
2188
+ name: "dstSubtypesMask",
2189
+ type: "uint256"
2190
+ }],
2191
+ name: "RelationshipTypeSet",
2192
+ type: "event"
2193
+ }];
2194
+ var relationshipModuleConfig = {
2195
+ abi: relationshipModuleAbi,
2196
+ address: viem.getAddress(process.env.RELATIONSHIP_MODULE_CONTRACT || process.env.NEXT_PUBLIC_RELATIONSHIP_MODULE_CONTRACT || "")
2197
+ };
2198
+
2199
+ /**
2200
+ * Client for managing relationships.
2201
+ */
2202
+ var RelationshipClient = /*#__PURE__*/function (_RelationshipReadOnly) {
2203
+ _inherits(RelationshipClient, _RelationshipReadOnly);
2204
+ var _super = _createSuper(RelationshipClient);
2205
+ function RelationshipClient(httpClient, rpcClient, wallet) {
2206
+ var _this;
2207
+ _classCallCheck(this, RelationshipClient);
2208
+ _this = _super.call(this, httpClient, rpcClient);
2209
+ _this.wallet = wallet;
2210
+ return _this;
2211
+ }
2212
+
2213
+ /**
2214
+ * Register a relationship on Story Protocol based on the specified input relationship data.
2215
+ *
2216
+ * @param request - the request object that contains all data needed to register a relationship
2217
+ * @returns the response object that contains results from the register relationship action
2218
+ */
2219
+ _createClass(RelationshipClient, [{
2220
+ key: "register",
2221
+ value: function () {
2222
+ var _register = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
2223
+ var _request$txOptions, _yield$this$rpcClient, call, txHash, _targetLog$args, targetLog;
2224
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
2225
+ while (1) switch (_context.prev = _context.next) {
2226
+ case 0:
2227
+ _context.prev = 0;
2228
+ _context.next = 3;
2229
+ return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, storyProtocolConfig), {}, {
2230
+ functionName: "createRelationship",
2231
+ args: [viem.getAddress(request.ipOrgId), {
2232
+ relType: request.relType,
2233
+ srcAddress: request.srcContract,
2234
+ srcId: request.srcTokenId,
2235
+ srcType: request.srcType || 1,
2236
+ // This represents the n-th bit on the bit mask
2237
+ dstAddress: request.dstContract,
2238
+ dstId: request.dstTokenId,
2239
+ dstType: request.dstType || 1 // This represents the n-th bit on the bit mask,
2240
+ }, [], []],
2241
+ account: this.wallet.account
2242
+ }));
2243
+ case 3:
2244
+ _yield$this$rpcClient = _context.sent;
2245
+ call = _yield$this$rpcClient.request;
2246
+ _context.next = 7;
2247
+ return this.wallet.writeContract(call);
2248
+ case 7:
2249
+ txHash = _context.sent;
2250
+ if (!((_request$txOptions = request.txOptions) !== null && _request$txOptions !== void 0 && _request$txOptions.waitForTransaction)) {
2251
+ _context.next = 15;
2252
+ break;
2253
+ }
2254
+ _context.next = 11;
2255
+ return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, relationshipModuleConfig), {}, {
2256
+ eventName: "RelationshipCreated"
2257
+ }));
2258
+ case 11:
2259
+ targetLog = _context.sent;
2260
+ return _context.abrupt("return", {
2261
+ txHash: txHash,
2262
+ relationshipId: targetLog === null || targetLog === void 0 || (_targetLog$args = targetLog.args) === null || _targetLog$args === void 0 || (_targetLog$args = _targetLog$args.relationshipId) === null || _targetLog$args === void 0 ? void 0 : _targetLog$args.toString()
2263
+ });
2264
+ case 15:
2265
+ return _context.abrupt("return", {
2266
+ txHash: txHash
2267
+ });
2268
+ case 16:
2269
+ _context.next = 21;
2270
+ break;
2271
+ case 18:
2272
+ _context.prev = 18;
2273
+ _context.t0 = _context["catch"](0);
2274
+ handleError(_context.t0, "Failed to register relationship");
2275
+ case 21:
2276
+ case "end":
2277
+ return _context.stop();
2278
+ }
2279
+ }, _callee, this, [[0, 18]]);
2280
+ }));
2281
+ function register(_x) {
2282
+ return _register.apply(this, arguments);
2283
+ }
2284
+ return register;
2285
+ }()
2286
+ /**
2287
+ * Register a relationship type on Story Protocol based on the specified input data.
2288
+ *
2289
+ * @param request - the request object that contains all data needed to register a relationship type
2290
+ * @returns the response object that contains results from the register relationship type action
2291
+ */
2292
+ }, {
2293
+ key: "registerRelationshipType",
2294
+ value: function () {
2295
+ var _registerRelationshipType = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
2296
+ var _request$txOptions2, _yield$this$rpcClient2, call, txHash;
2297
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
2298
+ while (1) switch (_context2.prev = _context2.next) {
2299
+ case 0:
2300
+ _context2.prev = 0;
2301
+ _context2.next = 3;
2302
+ return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, storyProtocolConfig), {}, {
2303
+ functionName: "addRelationshipType",
2304
+ args: [{
2305
+ ipOrg: viem.getAddress(request.ipOrgId),
2306
+ relType: request.relType,
2307
+ allowedElements: {
2308
+ src: request.relatedElements.src,
2309
+ dst: request.relatedElements.dst
2310
+ },
2311
+ allowedSrcs: request.allowedSrcs,
2312
+ allowedDsts: request.allowedDsts
2313
+ }],
2314
+ account: this.wallet.account
2315
+ }));
2316
+ case 3:
2317
+ _yield$this$rpcClient2 = _context2.sent;
2318
+ call = _yield$this$rpcClient2.request;
2319
+ _context2.next = 7;
2320
+ return this.wallet.writeContract(call);
2321
+ case 7:
2322
+ txHash = _context2.sent;
2323
+ if (!((_request$txOptions2 = request.txOptions) !== null && _request$txOptions2 !== void 0 && _request$txOptions2.waitForTransaction)) {
2324
+ _context2.next = 14;
2325
+ break;
2326
+ }
2327
+ _context2.next = 11;
2328
+ return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, relationshipModuleConfig), {}, {
2329
+ eventName: "RelationshipTypeSet"
2330
+ }));
2331
+ case 11:
2332
+ return _context2.abrupt("return", {
2333
+ txHash: txHash,
2334
+ success: true
2335
+ });
2336
+ case 14:
2337
+ return _context2.abrupt("return", {
2338
+ txHash: txHash
2339
+ });
2340
+ case 15:
2341
+ _context2.next = 20;
2342
+ break;
2343
+ case 17:
2344
+ _context2.prev = 17;
2345
+ _context2.t0 = _context2["catch"](0);
2346
+ handleError(_context2.t0, "Failed to register relationship");
2347
+ case 20:
2348
+ case "end":
2349
+ return _context2.stop();
2350
+ }
2351
+ }, _callee2, this, [[0, 17]]);
2352
+ }));
2353
+ function registerRelationshipType(_x2) {
2354
+ return _registerRelationshipType.apply(this, arguments);
2355
+ }
2356
+ return registerRelationshipType;
2357
+ }()
2358
+ }]);
2359
+ return RelationshipClient;
2360
+ }(RelationshipReadOnlyClient);
2361
+
2362
+ if (typeof process !== "undefined") {
2363
+ dotenv__namespace.config();
2364
+ }
2365
+ /**
2366
+ * The StoryClient is the main entry point for the SDK.
2367
+ */
2368
+ var StoryClient = /*#__PURE__*/function () {
2369
+ /**
2370
+ * @param config - the configuration for the SDK client
2371
+ * @param isReadOnly
2372
+ */
2373
+ function StoryClient(config) {
2374
+ var isReadOnly = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
2375
+ _classCallCheck(this, StoryClient);
2376
+ _defineProperty(this, "isReadOnly", false);
2377
+ _defineProperty(this, "_ipOrg", null);
2378
+ _defineProperty(this, "_license", null);
2379
+ _defineProperty(this, "_transaction", null);
2380
+ _defineProperty(this, "_ipAsset", null);
2381
+ _defineProperty(this, "_relationship", null);
2382
+ _defineProperty(this, "_module", null);
2383
+ _defineProperty(this, "_hook", null);
2384
+ _defineProperty(this, "_platform", null);
2385
+ if (config.environment !== Environment.TEST) {
2386
+ throw new Error("Invalid Environment: Only TEST environment is supported");
2387
+ }
2388
+ this.config = config;
2389
+ this.isReadOnly = isReadOnly;
2390
+ var clientConfig = {
2391
+ chain: this.config.chain || chains.sepolia,
2392
+ transport: this.config.transport || viem.http("https://sepolia.gateway.tenderly.co")
2393
+ };
2394
+ this.rpcClient = viem.createPublicClient(clientConfig);
2395
+ if (!isReadOnly) {
2396
+ var account = this.config.account;
2397
+ if (!account) {
2398
+ throw new Error("account is null");
2399
+ }
2400
+ this.wallet = viem.createWalletClient(_objectSpread2(_objectSpread2({}, clientConfig), {}, {
2401
+ account: account
2402
+ }));
2403
+ }
2404
+ this.httpClient = axios__default["default"].create({
2405
+ baseURL: process.env.API_BASE_URL || process.env.NEXT_PUBLIC_API_BASE_URL,
2406
+ timeout: HTTP_TIMEOUT,
2407
+ headers: {
2408
+ version: "v0-alpha"
2409
+ }
2410
+ });
2411
+ }
2412
+
2413
+ /**
2414
+ * Factory method for creating a read only SDK client.
2415
+ *
2416
+ * @param config - the configuration for a read only SDK client
2417
+ */
2418
+ _createClass(StoryClient, [{
2419
+ key: "initIPOrg",
2420
+ value: function initIPOrg() {
2421
+ if (this.isReadOnly) {
2422
+ this._ipOrg = new IPOrgReadOnlyClient(this.httpClient, this.rpcClient);
2423
+ } else {
2424
+ this._ipOrg = new IPOrgClient(this.httpClient, this.rpcClient, this.wallet);
2425
+ }
2426
+ }
2427
+ }, {
2428
+ key: "initRelationship",
2429
+ value: function initRelationship() {
2430
+ if (this.isReadOnly) {
2431
+ this._relationship = new RelationshipReadOnlyClient(this.httpClient, this.rpcClient);
2432
+ } else {
2433
+ this._relationship = new RelationshipClient(this.httpClient, this.rpcClient, this.wallet);
2434
+ }
2435
+ }
2436
+ }, {
2437
+ key: "initIpAsset",
2438
+ value: function initIpAsset() {
2439
+ if (this.isReadOnly) {
2440
+ this._ipAsset = new IPAssetReadOnlyClient(this.httpClient, this.rpcClient);
2441
+ } else {
2442
+ this._ipAsset = new IPAssetClient(this.httpClient, this.rpcClient, this.wallet);
2443
+ }
2444
+ }
2445
+ }, {
2446
+ key: "initLicense",
2447
+ value: function initLicense() {
2448
+ if (this.isReadOnly) {
2449
+ this._license = new LicenseReadOnlyClient(this.httpClient, this.rpcClient);
2450
+ } else {
2451
+ this._license = new LicenseClient(this.httpClient, this.rpcClient, this.wallet);
2452
+ }
2453
+ }
2454
+ }, {
2455
+ key: "initTransaction",
2456
+ value: function initTransaction() {
2457
+ if (this.isReadOnly) {
2458
+ this._transaction = new TransactionReadOnlyClient(this.httpClient, this.rpcClient);
2459
+ } else {
2460
+ this._transaction = new TransactionClient(this.httpClient, this.rpcClient, this.wallet);
2461
+ }
2462
+ }
2463
+ }, {
2464
+ key: "initModule",
2465
+ value: function initModule() {
2466
+ if (this.isReadOnly) {
2467
+ this._module = new ModuleReadOnlyClient(this.httpClient, this.rpcClient);
2468
+ } else {
2469
+ this._module = new ModuleClient(this.httpClient, this.rpcClient, this.wallet);
2470
+ }
2471
+ }
2472
+ }, {
2473
+ key: "initHook",
2474
+ value: function initHook() {
2475
+ if (this.isReadOnly) {
2476
+ this._hook = new HookReadOnlyClient(this.httpClient, this.rpcClient);
2477
+ } else {
2478
+ this._hook = new HookClient(this.httpClient, this.rpcClient, this.wallet);
2479
+ }
2480
+ }
2481
+ }, {
2482
+ key: "initPlatform",
2483
+ value: function initPlatform() {
2484
+ this._platform = new PlatformClient(this.httpClient);
2485
+ }
2486
+
2487
+ /**
2488
+ * Getter for the ipOrg client. The client is lazily created when
2489
+ * this method is called.
2490
+ *
2491
+ * @returns the IPOrgClient or IPOrgReadOnlyClient instance
2492
+ */
2493
+ }, {
2494
+ key: "ipOrg",
2495
+ get: function get() {
2496
+ if (this._ipOrg === null) {
2497
+ this.initIPOrg();
2498
+ }
2499
+ return this._ipOrg;
2500
+ }
2501
+
2502
+ /**
2503
+ * Getter for the relationship client. The client is lazily created when
2504
+ * this method is called.
2505
+ *
2506
+ * @returns the RelationshipClient instance
2507
+ */
2508
+ }, {
2509
+ key: "relationship",
2510
+ get: function get() {
2511
+ if (this._relationship === null) {
2512
+ this.initRelationship();
2513
+ }
2514
+ return this._relationship;
2515
+ }
2516
+
2517
+ /**
2518
+ * Getter for the IP Asset client. The client is lazily created when
2519
+ * this method is called.
2520
+ *
2521
+ * @returns the IpAssetClient instance
2522
+ */
2523
+ }, {
2524
+ key: "ipAsset",
2525
+ get: function get() {
2526
+ if (this._ipAsset === null) {
2527
+ this.initIpAsset();
2528
+ }
2529
+ return this._ipAsset;
2530
+ }
2531
+
2532
+ /**
2533
+ * Getter for the license client. The client is lazily created when
2534
+ * this method is called.
2535
+ *
2536
+ * @returns the License instance
2537
+ */
2538
+ }, {
2539
+ key: "license",
2540
+ get: function get() {
2541
+ if (this._license === null) {
2542
+ this.initLicense();
2543
+ }
2544
+ return this._license;
2545
+ }
2546
+
2547
+ /**
2548
+ * Getter for the transaction client. The client is lazily created when
2549
+ * this method is called.
2550
+ *
2551
+ * @returns the TransactionClient instance
2552
+ */
2553
+ }, {
2554
+ key: "transaction",
2555
+ get: function get() {
2556
+ if (this._transaction === null) {
2557
+ this.initTransaction();
2558
+ }
2559
+ return this._transaction;
2560
+ }
2561
+
2562
+ /**
2563
+ * Getter for the module client. The client is lazily created when
2564
+ * this method is called.
2565
+ *
2566
+ * @returns the ModuleClient instance
2567
+ */
2568
+ }, {
2569
+ key: "module",
2570
+ get: function get() {
2571
+ if (this._module === null) {
2572
+ this.initModule();
2573
+ }
2574
+ return this._module;
2575
+ }
2576
+
2577
+ /**
2578
+ * Getter for the hook client. The client is lazily created when
2579
+ * this method is called.
2580
+ *
2581
+ * @returns the HookClient instance
2582
+ */
2583
+ }, {
2584
+ key: "hook",
2585
+ get: function get() {
2586
+ if (this._hook === null) {
2587
+ this.initHook();
2588
+ }
2589
+ return this._hook;
2590
+ }
2591
+ }, {
2592
+ key: "platform",
2593
+ get: function get() {
2594
+ if (this._platform === null) {
2595
+ this.initPlatform();
2596
+ }
2597
+ return this._platform;
2598
+ }
2599
+ }], [{
2600
+ key: "newReadOnlyClient",
2601
+ value: function newReadOnlyClient(config) {
2602
+ return new StoryClient(config, true);
2603
+ }
2604
+
2605
+ /**
2606
+ * Factory method for creating a SDK client with a signer.
2607
+ *
2608
+ * @param config - the configuration for a new read/write SDK client
2609
+ */
2610
+ }, {
2611
+ key: "newClient",
2612
+ value: function newClient(config) {
2613
+ return new StoryClient(config, false);
2614
+ }
2615
+ }]);
2616
+ return StoryClient;
2617
+ }();
2618
+
2619
+ /**
2620
+ * @public
2621
+ */
2622
+ var IPAssetType = /*#__PURE__*/function (IPAssetType) {
2623
+ IPAssetType[IPAssetType["STORY"] = 1] = "STORY";
2624
+ IPAssetType[IPAssetType["CHARACTER"] = 2] = "CHARACTER";
2625
+ IPAssetType[IPAssetType["ART"] = 3] = "ART";
2626
+ IPAssetType[IPAssetType["LOCATION"] = 5] = "LOCATION";
2627
+ IPAssetType[IPAssetType["ITEM"] = 6] = "ITEM";
2628
+ return IPAssetType;
2629
+ }({});
2630
+
2631
+ /**
2632
+ * @public
2633
+ */
2634
+ var ResourceType = /*#__PURE__*/function (ResourceType) {
2635
+ ResourceType[ResourceType["UNSPECIFIED"] = 0] = "UNSPECIFIED";
2636
+ ResourceType[ResourceType["IP_ORG"] = 1] = "IP_ORG";
2637
+ ResourceType[ResourceType["IP_ASSET"] = 2] = "IP_ASSET";
2638
+ ResourceType[ResourceType["LICENSE"] = 3] = "LICENSE";
2639
+ ResourceType[ResourceType["RELATIONSHIP"] = 4] = "RELATIONSHIP";
2640
+ ResourceType[ResourceType["RELATIONSHIPTYPE"] = 5] = "RELATIONSHIPTYPE";
2641
+ ResourceType[ResourceType["MODULE"] = 6] = "MODULE";
2642
+ ResourceType[ResourceType["HOOK"] = 7] = "HOOK";
2643
+ ResourceType[ResourceType["DISPUTE"] = 8] = "DISPUTE";
2644
+ return ResourceType;
2645
+ }({});
2646
+
2647
+ exports.Environment = Environment;
2648
+ exports.IPAssetType = IPAssetType;
2649
+ exports.ResourceType = ResourceType;
2650
+ exports.StoryClient = StoryClient;