@story-protocol/core-sdk 0.0.1-beta-rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. package/README.md +85 -0
  2. package/dist/declarations/src/client.d.ts +76 -0
  3. package/dist/declarations/src/client.d.ts.map +1 -0
  4. package/dist/declarations/src/constants/common.d.ts +3 -0
  5. package/dist/declarations/src/constants/common.d.ts.map +1 -0
  6. package/dist/declarations/src/enums/ActionType.d.ts +11 -0
  7. package/dist/declarations/src/enums/ActionType.d.ts.map +1 -0
  8. package/dist/declarations/src/enums/ResourceType.d.ts +15 -0
  9. package/dist/declarations/src/enums/ResourceType.d.ts.map +1 -0
  10. package/dist/declarations/src/index.d.ts +19 -0
  11. package/dist/declarations/src/index.d.ts.map +1 -0
  12. package/dist/declarations/src/resources/ipAsset.d.ts +23 -0
  13. package/dist/declarations/src/resources/ipAsset.d.ts.map +1 -0
  14. package/dist/declarations/src/resources/ipAssetReadOnly.d.ts +26 -0
  15. package/dist/declarations/src/resources/ipAssetReadOnly.d.ts.map +1 -0
  16. package/dist/declarations/src/resources/moduleReadOnly.d.ts +25 -0
  17. package/dist/declarations/src/resources/moduleReadOnly.d.ts.map +1 -0
  18. package/dist/declarations/src/resources/permission.d.ts +16 -0
  19. package/dist/declarations/src/resources/permission.d.ts.map +1 -0
  20. package/dist/declarations/src/resources/permissionReadOnly.d.ts +25 -0
  21. package/dist/declarations/src/resources/permissionReadOnly.d.ts.map +1 -0
  22. package/dist/declarations/src/resources/tagging.d.ts +11 -0
  23. package/dist/declarations/src/resources/tagging.d.ts.map +1 -0
  24. package/dist/declarations/src/resources/taggingReadOnly.d.ts +24 -0
  25. package/dist/declarations/src/resources/taggingReadOnly.d.ts.map +1 -0
  26. package/dist/declarations/src/resources/transaction.d.ts +11 -0
  27. package/dist/declarations/src/resources/transaction.d.ts.map +1 -0
  28. package/dist/declarations/src/resources/transactionReadOnly.d.ts +25 -0
  29. package/dist/declarations/src/resources/transactionReadOnly.d.ts.map +1 -0
  30. package/dist/declarations/src/types/client.d.ts +23 -0
  31. package/dist/declarations/src/types/client.d.ts.map +1 -0
  32. package/dist/declarations/src/types/common.d.ts +6 -0
  33. package/dist/declarations/src/types/common.d.ts.map +1 -0
  34. package/dist/declarations/src/types/config.d.ts +19 -0
  35. package/dist/declarations/src/types/config.d.ts.map +1 -0
  36. package/dist/declarations/src/types/options.d.ts +12 -0
  37. package/dist/declarations/src/types/options.d.ts.map +1 -0
  38. package/dist/declarations/src/types/resources/ipAsset.d.ts +144 -0
  39. package/dist/declarations/src/types/resources/ipAsset.d.ts.map +1 -0
  40. package/dist/declarations/src/types/resources/module.d.ts +43 -0
  41. package/dist/declarations/src/types/resources/module.d.ts.map +1 -0
  42. package/dist/declarations/src/types/resources/permission.d.ts +35 -0
  43. package/dist/declarations/src/types/resources/permission.d.ts.map +1 -0
  44. package/dist/declarations/src/types/resources/tagging.d.ts +35 -0
  45. package/dist/declarations/src/types/resources/tagging.d.ts.map +1 -0
  46. package/dist/declarations/src/types/resources/transaction.d.ts +52 -0
  47. package/dist/declarations/src/types/resources/transaction.d.ts.map +1 -0
  48. package/dist/declarations/src/utils/platform.d.ts +17 -0
  49. package/dist/declarations/src/utils/platform.d.ts.map +1 -0
  50. package/dist/story-protocol-core-sdk.cjs.d.ts +2 -0
  51. package/dist/story-protocol-core-sdk.cjs.d.ts.map +1 -0
  52. package/dist/story-protocol-core-sdk.cjs.dev.js +2367 -0
  53. package/dist/story-protocol-core-sdk.cjs.js +7 -0
  54. package/dist/story-protocol-core-sdk.cjs.prod.js +2367 -0
  55. package/dist/story-protocol-core-sdk.esm.js +2328 -0
  56. package/package.json +91 -0
@@ -0,0 +1,2328 @@
1
+ import axios from 'axios';
2
+ import { getAddress, isAddress, decodeEventLog, encodeFunctionData, http, createPublicClient, createWalletClient } from 'viem';
3
+ import { sepolia } from 'viem/chains';
4
+ import * as dotenv from 'dotenv';
5
+ import { formatAbi } from 'abitype';
6
+
7
+ function _toPrimitive(input, hint) {
8
+ if (typeof input !== "object" || input === null) return input;
9
+ var prim = input[Symbol.toPrimitive];
10
+ if (prim !== undefined) {
11
+ var res = prim.call(input, hint || "default");
12
+ if (typeof res !== "object") return res;
13
+ throw new TypeError("@@toPrimitive must return a primitive value.");
14
+ }
15
+ return (hint === "string" ? String : Number)(input);
16
+ }
17
+
18
+ function _toPropertyKey(arg) {
19
+ var key = _toPrimitive(arg, "string");
20
+ return typeof key === "symbol" ? key : String(key);
21
+ }
22
+
23
+ function _defineProperty(obj, key, value) {
24
+ key = _toPropertyKey(key);
25
+ if (key in obj) {
26
+ Object.defineProperty(obj, key, {
27
+ value: value,
28
+ enumerable: true,
29
+ configurable: true,
30
+ writable: true
31
+ });
32
+ } else {
33
+ obj[key] = value;
34
+ }
35
+ return obj;
36
+ }
37
+
38
+ function ownKeys(e, r) {
39
+ var t = Object.keys(e);
40
+ if (Object.getOwnPropertySymbols) {
41
+ var o = Object.getOwnPropertySymbols(e);
42
+ r && (o = o.filter(function (r) {
43
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
44
+ })), t.push.apply(t, o);
45
+ }
46
+ return t;
47
+ }
48
+ function _objectSpread2(e) {
49
+ for (var r = 1; r < arguments.length; r++) {
50
+ var t = null != arguments[r] ? arguments[r] : {};
51
+ r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
52
+ _defineProperty(e, r, t[r]);
53
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
54
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
55
+ });
56
+ }
57
+ return e;
58
+ }
59
+
60
+ function _classCallCheck(instance, Constructor) {
61
+ if (!(instance instanceof Constructor)) {
62
+ throw new TypeError("Cannot call a class as a function");
63
+ }
64
+ }
65
+
66
+ function _defineProperties(target, props) {
67
+ for (var i = 0; i < props.length; i++) {
68
+ var descriptor = props[i];
69
+ descriptor.enumerable = descriptor.enumerable || false;
70
+ descriptor.configurable = true;
71
+ if ("value" in descriptor) descriptor.writable = true;
72
+ Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
73
+ }
74
+ }
75
+ function _createClass(Constructor, protoProps, staticProps) {
76
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
77
+ if (staticProps) _defineProperties(Constructor, staticProps);
78
+ Object.defineProperty(Constructor, "prototype", {
79
+ writable: false
80
+ });
81
+ return Constructor;
82
+ }
83
+
84
+ function _setPrototypeOf(o, p) {
85
+ _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
86
+ o.__proto__ = p;
87
+ return o;
88
+ };
89
+ return _setPrototypeOf(o, p);
90
+ }
91
+
92
+ function _inherits(subClass, superClass) {
93
+ if (typeof superClass !== "function" && superClass !== null) {
94
+ throw new TypeError("Super expression must either be null or a function");
95
+ }
96
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
97
+ constructor: {
98
+ value: subClass,
99
+ writable: true,
100
+ configurable: true
101
+ }
102
+ });
103
+ Object.defineProperty(subClass, "prototype", {
104
+ writable: false
105
+ });
106
+ if (superClass) _setPrototypeOf(subClass, superClass);
107
+ }
108
+
109
+ function _getPrototypeOf(o) {
110
+ _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
111
+ return o.__proto__ || Object.getPrototypeOf(o);
112
+ };
113
+ return _getPrototypeOf(o);
114
+ }
115
+
116
+ function _isNativeReflectConstruct() {
117
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
118
+ if (Reflect.construct.sham) return false;
119
+ if (typeof Proxy === "function") return true;
120
+ try {
121
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
122
+ return true;
123
+ } catch (e) {
124
+ return false;
125
+ }
126
+ }
127
+
128
+ function _assertThisInitialized(self) {
129
+ if (self === void 0) {
130
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
131
+ }
132
+ return self;
133
+ }
134
+
135
+ function _possibleConstructorReturn(self, call) {
136
+ if (call && (typeof call === "object" || typeof call === "function")) {
137
+ return call;
138
+ } else if (call !== void 0) {
139
+ throw new TypeError("Derived constructors may only return object or undefined");
140
+ }
141
+ return _assertThisInitialized(self);
142
+ }
143
+
144
+ function _createSuper(Derived) {
145
+ var hasNativeReflectConstruct = _isNativeReflectConstruct();
146
+ return function _createSuperInternal() {
147
+ var Super = _getPrototypeOf(Derived),
148
+ result;
149
+ if (hasNativeReflectConstruct) {
150
+ var NewTarget = _getPrototypeOf(this).constructor;
151
+ result = Reflect.construct(Super, arguments, NewTarget);
152
+ } else {
153
+ result = Super.apply(this, arguments);
154
+ }
155
+ return _possibleConstructorReturn(this, result);
156
+ };
157
+ }
158
+
159
+ function _regeneratorRuntime() {
160
+ _regeneratorRuntime = function () {
161
+ return e;
162
+ };
163
+ var t,
164
+ e = {},
165
+ r = Object.prototype,
166
+ n = r.hasOwnProperty,
167
+ o = Object.defineProperty || function (t, e, r) {
168
+ t[e] = r.value;
169
+ },
170
+ i = "function" == typeof Symbol ? Symbol : {},
171
+ a = i.iterator || "@@iterator",
172
+ c = i.asyncIterator || "@@asyncIterator",
173
+ u = i.toStringTag || "@@toStringTag";
174
+ function define(t, e, r) {
175
+ return Object.defineProperty(t, e, {
176
+ value: r,
177
+ enumerable: !0,
178
+ configurable: !0,
179
+ writable: !0
180
+ }), t[e];
181
+ }
182
+ try {
183
+ define({}, "");
184
+ } catch (t) {
185
+ define = function (t, e, r) {
186
+ return t[e] = r;
187
+ };
188
+ }
189
+ function wrap(t, e, r, n) {
190
+ var i = e && e.prototype instanceof Generator ? e : Generator,
191
+ a = Object.create(i.prototype),
192
+ c = new Context(n || []);
193
+ return o(a, "_invoke", {
194
+ value: makeInvokeMethod(t, r, c)
195
+ }), a;
196
+ }
197
+ function tryCatch(t, e, r) {
198
+ try {
199
+ return {
200
+ type: "normal",
201
+ arg: t.call(e, r)
202
+ };
203
+ } catch (t) {
204
+ return {
205
+ type: "throw",
206
+ arg: t
207
+ };
208
+ }
209
+ }
210
+ e.wrap = wrap;
211
+ var h = "suspendedStart",
212
+ l = "suspendedYield",
213
+ f = "executing",
214
+ s = "completed",
215
+ y = {};
216
+ function Generator() {}
217
+ function GeneratorFunction() {}
218
+ function GeneratorFunctionPrototype() {}
219
+ var p = {};
220
+ define(p, a, function () {
221
+ return this;
222
+ });
223
+ var d = Object.getPrototypeOf,
224
+ v = d && d(d(values([])));
225
+ v && v !== r && n.call(v, a) && (p = v);
226
+ var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
227
+ function defineIteratorMethods(t) {
228
+ ["next", "throw", "return"].forEach(function (e) {
229
+ define(t, e, function (t) {
230
+ return this._invoke(e, t);
231
+ });
232
+ });
233
+ }
234
+ function AsyncIterator(t, e) {
235
+ function invoke(r, o, i, a) {
236
+ var c = tryCatch(t[r], t, o);
237
+ if ("throw" !== c.type) {
238
+ var u = c.arg,
239
+ h = u.value;
240
+ return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
241
+ invoke("next", t, i, a);
242
+ }, function (t) {
243
+ invoke("throw", t, i, a);
244
+ }) : e.resolve(h).then(function (t) {
245
+ u.value = t, i(u);
246
+ }, function (t) {
247
+ return invoke("throw", t, i, a);
248
+ });
249
+ }
250
+ a(c.arg);
251
+ }
252
+ var r;
253
+ o(this, "_invoke", {
254
+ value: function (t, n) {
255
+ function callInvokeWithMethodAndArg() {
256
+ return new e(function (e, r) {
257
+ invoke(t, n, e, r);
258
+ });
259
+ }
260
+ return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
261
+ }
262
+ });
263
+ }
264
+ function makeInvokeMethod(e, r, n) {
265
+ var o = h;
266
+ return function (i, a) {
267
+ if (o === f) throw new Error("Generator is already running");
268
+ if (o === s) {
269
+ if ("throw" === i) throw a;
270
+ return {
271
+ value: t,
272
+ done: !0
273
+ };
274
+ }
275
+ for (n.method = i, n.arg = a;;) {
276
+ var c = n.delegate;
277
+ if (c) {
278
+ var u = maybeInvokeDelegate(c, n);
279
+ if (u) {
280
+ if (u === y) continue;
281
+ return u;
282
+ }
283
+ }
284
+ if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
285
+ if (o === h) throw o = s, n.arg;
286
+ n.dispatchException(n.arg);
287
+ } else "return" === n.method && n.abrupt("return", n.arg);
288
+ o = f;
289
+ var p = tryCatch(e, r, n);
290
+ if ("normal" === p.type) {
291
+ if (o = n.done ? s : l, p.arg === y) continue;
292
+ return {
293
+ value: p.arg,
294
+ done: n.done
295
+ };
296
+ }
297
+ "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
298
+ }
299
+ };
300
+ }
301
+ function maybeInvokeDelegate(e, r) {
302
+ var n = r.method,
303
+ o = e.iterator[n];
304
+ 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;
305
+ var i = tryCatch(o, e.iterator, r.arg);
306
+ if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
307
+ var a = i.arg;
308
+ 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);
309
+ }
310
+ function pushTryEntry(t) {
311
+ var e = {
312
+ tryLoc: t[0]
313
+ };
314
+ 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
315
+ }
316
+ function resetTryEntry(t) {
317
+ var e = t.completion || {};
318
+ e.type = "normal", delete e.arg, t.completion = e;
319
+ }
320
+ function Context(t) {
321
+ this.tryEntries = [{
322
+ tryLoc: "root"
323
+ }], t.forEach(pushTryEntry, this), this.reset(!0);
324
+ }
325
+ function values(e) {
326
+ if (e || "" === e) {
327
+ var r = e[a];
328
+ if (r) return r.call(e);
329
+ if ("function" == typeof e.next) return e;
330
+ if (!isNaN(e.length)) {
331
+ var o = -1,
332
+ i = function next() {
333
+ for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
334
+ return next.value = t, next.done = !0, next;
335
+ };
336
+ return i.next = i;
337
+ }
338
+ }
339
+ throw new TypeError(typeof e + " is not iterable");
340
+ }
341
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
342
+ value: GeneratorFunctionPrototype,
343
+ configurable: !0
344
+ }), o(GeneratorFunctionPrototype, "constructor", {
345
+ value: GeneratorFunction,
346
+ configurable: !0
347
+ }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
348
+ var e = "function" == typeof t && t.constructor;
349
+ return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
350
+ }, e.mark = function (t) {
351
+ return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
352
+ }, e.awrap = function (t) {
353
+ return {
354
+ __await: t
355
+ };
356
+ }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
357
+ return this;
358
+ }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
359
+ void 0 === i && (i = Promise);
360
+ var a = new AsyncIterator(wrap(t, r, n, o), i);
361
+ return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
362
+ return t.done ? t.value : a.next();
363
+ });
364
+ }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
365
+ return this;
366
+ }), define(g, "toString", function () {
367
+ return "[object Generator]";
368
+ }), e.keys = function (t) {
369
+ var e = Object(t),
370
+ r = [];
371
+ for (var n in e) r.push(n);
372
+ return r.reverse(), function next() {
373
+ for (; r.length;) {
374
+ var t = r.pop();
375
+ if (t in e) return next.value = t, next.done = !1, next;
376
+ }
377
+ return next.done = !0, next;
378
+ };
379
+ }, e.values = values, Context.prototype = {
380
+ constructor: Context,
381
+ reset: function (e) {
382
+ 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);
383
+ },
384
+ stop: function () {
385
+ this.done = !0;
386
+ var t = this.tryEntries[0].completion;
387
+ if ("throw" === t.type) throw t.arg;
388
+ return this.rval;
389
+ },
390
+ dispatchException: function (e) {
391
+ if (this.done) throw e;
392
+ var r = this;
393
+ function handle(n, o) {
394
+ return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
395
+ }
396
+ for (var o = this.tryEntries.length - 1; o >= 0; --o) {
397
+ var i = this.tryEntries[o],
398
+ a = i.completion;
399
+ if ("root" === i.tryLoc) return handle("end");
400
+ if (i.tryLoc <= this.prev) {
401
+ var c = n.call(i, "catchLoc"),
402
+ u = n.call(i, "finallyLoc");
403
+ if (c && u) {
404
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
405
+ if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
406
+ } else if (c) {
407
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
408
+ } else {
409
+ if (!u) throw new Error("try statement without catch or finally");
410
+ if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
411
+ }
412
+ }
413
+ }
414
+ },
415
+ abrupt: function (t, e) {
416
+ for (var r = this.tryEntries.length - 1; r >= 0; --r) {
417
+ var o = this.tryEntries[r];
418
+ if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
419
+ var i = o;
420
+ break;
421
+ }
422
+ }
423
+ i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
424
+ var a = i ? i.completion : {};
425
+ return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
426
+ },
427
+ complete: function (t, e) {
428
+ if ("throw" === t.type) throw t.arg;
429
+ 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;
430
+ },
431
+ finish: function (t) {
432
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
433
+ var r = this.tryEntries[e];
434
+ if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
435
+ }
436
+ },
437
+ catch: function (t) {
438
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
439
+ var r = this.tryEntries[e];
440
+ if (r.tryLoc === t) {
441
+ var n = r.completion;
442
+ if ("throw" === n.type) {
443
+ var o = n.arg;
444
+ resetTryEntry(r);
445
+ }
446
+ return o;
447
+ }
448
+ }
449
+ throw new Error("illegal catch attempt");
450
+ },
451
+ delegateYield: function (e, r, n) {
452
+ return this.delegate = {
453
+ iterator: values(e),
454
+ resultName: r,
455
+ nextLoc: n
456
+ }, "next" === this.method && (this.arg = t), y;
457
+ }
458
+ }, e;
459
+ }
460
+
461
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
462
+ try {
463
+ var info = gen[key](arg);
464
+ var value = info.value;
465
+ } catch (error) {
466
+ reject(error);
467
+ return;
468
+ }
469
+ if (info.done) {
470
+ resolve(value);
471
+ } else {
472
+ Promise.resolve(value).then(_next, _throw);
473
+ }
474
+ }
475
+ function _asyncToGenerator(fn) {
476
+ return function () {
477
+ var self = this,
478
+ args = arguments;
479
+ return new Promise(function (resolve, reject) {
480
+ var gen = fn.apply(self, args);
481
+ function _next(value) {
482
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
483
+ }
484
+ function _throw(err) {
485
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
486
+ }
487
+ _next(undefined);
488
+ });
489
+ };
490
+ }
491
+
492
+ function handleError(error, msg) {
493
+ if (error instanceof Error) {
494
+ throw new Error("".concat(msg, ": ").concat(error.message));
495
+ }
496
+ throw new Error("".concat(msg, ": Unknown error type"));
497
+ }
498
+
499
+ /**
500
+ * TransactionClient allows you to view and monitor transactions on Story Protocol.
501
+ */
502
+ var TransactionReadOnlyClient = /*#__PURE__*/function () {
503
+ function TransactionReadOnlyClient(httpClient, rpcClient) {
504
+ _classCallCheck(this, TransactionReadOnlyClient);
505
+ this.httpClient = httpClient;
506
+ this.rpcClient = rpcClient;
507
+ }
508
+
509
+ /**
510
+ * Get transaction data based on the specified transaction id.
511
+ *
512
+ * @param request - the request object for getting the transaction
513
+ * @returns the response object that contains the fetched transaction object
514
+ */
515
+ _createClass(TransactionReadOnlyClient, [{
516
+ key: "get",
517
+ value: function () {
518
+ var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
519
+ var response;
520
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
521
+ while (1) switch (_context.prev = _context.next) {
522
+ case 0:
523
+ _context.prev = 0;
524
+ _context.next = 3;
525
+ return this.httpClient.get("/protocol/transaction/".concat(request.transactionId));
526
+ case 3:
527
+ response = _context.sent;
528
+ return _context.abrupt("return", response.data);
529
+ case 7:
530
+ _context.prev = 7;
531
+ _context.t0 = _context["catch"](0);
532
+ handleError(_context.t0, "Failed to get transaction");
533
+ case 10:
534
+ case "end":
535
+ return _context.stop();
536
+ }
537
+ }, _callee, this, [[0, 7]]);
538
+ }));
539
+ function get(_x) {
540
+ return _get.apply(this, arguments);
541
+ }
542
+ return get;
543
+ }()
544
+ /**
545
+ * List Transactions.
546
+ *
547
+ * @returns the response object that contains a list of transactions
548
+ */
549
+ }, {
550
+ key: "list",
551
+ value: function () {
552
+ var _list = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
553
+ var response;
554
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
555
+ while (1) switch (_context2.prev = _context2.next) {
556
+ case 0:
557
+ _context2.prev = 0;
558
+ _context2.next = 3;
559
+ return this.httpClient.post("/protocol/transaction", request || {});
560
+ case 3:
561
+ response = _context2.sent;
562
+ return _context2.abrupt("return", response.data);
563
+ case 7:
564
+ _context2.prev = 7;
565
+ _context2.t0 = _context2["catch"](0);
566
+ handleError(_context2.t0, "Failed to list transactions");
567
+ case 10:
568
+ case "end":
569
+ return _context2.stop();
570
+ }
571
+ }, _callee2, this, [[0, 7]]);
572
+ }));
573
+ function list(_x2) {
574
+ return _list.apply(this, arguments);
575
+ }
576
+ return list;
577
+ }()
578
+ }]);
579
+ return TransactionReadOnlyClient;
580
+ }();
581
+
582
+ /**
583
+ * TransactionClient allows you to view and monitor transactions on Story Protocol.
584
+ */
585
+ var TransactionClient = /*#__PURE__*/function (_TransactionReadOnlyC) {
586
+ _inherits(TransactionClient, _TransactionReadOnlyC);
587
+ var _super = _createSuper(TransactionClient);
588
+ function TransactionClient(httpClient, rpcClient, wallet) {
589
+ var _this;
590
+ _classCallCheck(this, TransactionClient);
591
+ _this = _super.call(this, httpClient, rpcClient);
592
+ _this.wallet = wallet;
593
+ return _this;
594
+ }
595
+ return _createClass(TransactionClient);
596
+ }(TransactionReadOnlyClient);
597
+
598
+ /**
599
+ * Default timeout value for http clients.
600
+ */
601
+ var HTTP_TIMEOUT = 5000;
602
+
603
+ var PlatformClient = /*#__PURE__*/function () {
604
+ function PlatformClient(httpClient) {
605
+ _classCallCheck(this, PlatformClient);
606
+ this.httpClient = httpClient;
607
+ }
608
+
609
+ /**
610
+ * Upload a file to Arweave.
611
+ *
612
+ * @param file - the file binary data to upload
613
+ * @param mimeType - the mime type of the file
614
+ * @returns the response object that contains the uri of the uploaded file
615
+ */
616
+ _createClass(PlatformClient, [{
617
+ key: "uploadFile",
618
+ value: function () {
619
+ var _uploadFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(file, mimeType) {
620
+ var preSignUrlResp, data, uploadResp, confirmResp;
621
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
622
+ while (1) switch (_context.prev = _context.next) {
623
+ case 0:
624
+ _context.prev = 0;
625
+ _context.next = 3;
626
+ return this.httpClient.post("/platform/file-upload/request");
627
+ case 3:
628
+ preSignUrlResp = _context.sent;
629
+ data = preSignUrlResp.data; // upload the file to s3
630
+ _context.next = 7;
631
+ return this.httpClient.put(data.url, file, {
632
+ timeout: 0,
633
+ headers: {
634
+ "Content-Type": mimeType
635
+ }
636
+ });
637
+ case 7:
638
+ uploadResp = _context.sent;
639
+ if (!(uploadResp.status !== 200)) {
640
+ _context.next = 10;
641
+ break;
642
+ }
643
+ throw new Error("Failed to upload file to s3. Status: ".concat(uploadResp.status));
644
+ case 10:
645
+ _context.next = 12;
646
+ return this.httpClient.post("/platform/file-upload/confirm", {
647
+ key: data.key
648
+ });
649
+ case 12:
650
+ confirmResp = _context.sent;
651
+ return _context.abrupt("return", confirmResp.data);
652
+ case 16:
653
+ _context.prev = 16;
654
+ _context.t0 = _context["catch"](0);
655
+ return _context.abrupt("return", handleError(_context.t0, "Failed to upload file"));
656
+ case 19:
657
+ case "end":
658
+ return _context.stop();
659
+ }
660
+ }, _callee, this, [[0, 16]]);
661
+ }));
662
+ function uploadFile(_x, _x2) {
663
+ return _uploadFile.apply(this, arguments);
664
+ }
665
+ return uploadFile;
666
+ }()
667
+ }]);
668
+ return PlatformClient;
669
+ }();
670
+
671
+ /**
672
+ * ModuleReadOnlyClient allows you to view and search modules on Story Protocol.
673
+ */
674
+ var ModuleReadOnlyClient = /*#__PURE__*/function () {
675
+ function ModuleReadOnlyClient(httpClient, rpcClient) {
676
+ _classCallCheck(this, ModuleReadOnlyClient);
677
+ this.httpClient = httpClient;
678
+ this.rpcClient = rpcClient;
679
+ }
680
+
681
+ /**
682
+ * Get an module based on the module name.
683
+ *
684
+ * @param request - the request object for getting a module.
685
+ * @returns the response object the contains the fetched module.
686
+ */
687
+ _createClass(ModuleReadOnlyClient, [{
688
+ key: "get",
689
+ value: function () {
690
+ var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
691
+ var response;
692
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
693
+ while (1) switch (_context.prev = _context.next) {
694
+ case 0:
695
+ _context.prev = 0;
696
+ _context.next = 3;
697
+ return this.httpClient.get("/modules/".concat(request.name));
698
+ case 3:
699
+ response = _context.sent;
700
+ return _context.abrupt("return", response.data);
701
+ case 7:
702
+ _context.prev = 7;
703
+ _context.t0 = _context["catch"](0);
704
+ handleError(_context.t0, "Failed to get module");
705
+ case 10:
706
+ case "end":
707
+ return _context.stop();
708
+ }
709
+ }, _callee, this, [[0, 7]]);
710
+ }));
711
+ function get(_x) {
712
+ return _get.apply(this, arguments);
713
+ }
714
+ return get;
715
+ }()
716
+ /**
717
+ * List modules.
718
+ *
719
+ * @returns the response object that contains results from listing query.
720
+ */
721
+ }, {
722
+ key: "list",
723
+ value: function () {
724
+ var _list = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
725
+ var response;
726
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
727
+ while (1) switch (_context2.prev = _context2.next) {
728
+ case 0:
729
+ _context2.prev = 0;
730
+ _context2.next = 3;
731
+ return this.httpClient.post("/modules", request || {});
732
+ case 3:
733
+ response = _context2.sent;
734
+ return _context2.abrupt("return", response.data);
735
+ case 7:
736
+ _context2.prev = 7;
737
+ _context2.t0 = _context2["catch"](0);
738
+ handleError(_context2.t0, "Failed to list modules.");
739
+ case 10:
740
+ case "end":
741
+ return _context2.stop();
742
+ }
743
+ }, _callee2, this, [[0, 7]]);
744
+ }));
745
+ function list(_x2) {
746
+ return _list.apply(this, arguments);
747
+ }
748
+ return list;
749
+ }()
750
+ }]);
751
+ return ModuleReadOnlyClient;
752
+ }();
753
+
754
+ var TaggingModuleABI = [{
755
+ inputs: [{
756
+ internalType: "string",
757
+ name: "tag",
758
+ type: "string"
759
+ }, {
760
+ internalType: "address",
761
+ name: "ipId",
762
+ type: "address"
763
+ }],
764
+ name: "removeTag",
765
+ outputs: [{
766
+ internalType: "bool",
767
+ name: "removed",
768
+ type: "bool"
769
+ }],
770
+ stateMutability: "nonpayable",
771
+ type: "function"
772
+ }, {
773
+ inputs: [{
774
+ internalType: "string",
775
+ name: "tag",
776
+ type: "string"
777
+ }, {
778
+ internalType: "address",
779
+ name: "ipId",
780
+ type: "address"
781
+ }],
782
+ name: "setTag",
783
+ outputs: [{
784
+ internalType: "bool",
785
+ name: "added",
786
+ type: "bool"
787
+ }],
788
+ stateMutability: "nonpayable",
789
+ type: "function"
790
+ }];
791
+
792
+ var TaggingModuleRaw = TaggingModuleABI;
793
+ formatAbi(TaggingModuleRaw);
794
+ var TaggingModuleConfig = {
795
+ abi: TaggingModuleRaw,
796
+ address: getAddress(process.env.TAGGING_MODULE || process.env.NEXT_PUBLIC_TAGGING_MODULE || "")
797
+ };
798
+
799
+ /**
800
+ * TaggingReadOnlyClient allows you to view and search IP Assets on Story Protocol.
801
+ */
802
+ var TaggingReadOnlyClient = /*#__PURE__*/function () {
803
+ function TaggingReadOnlyClient(httpClient, rpcClient) {
804
+ _classCallCheck(this, TaggingReadOnlyClient);
805
+ this.httpClient = httpClient;
806
+ this.rpcClient = rpcClient;
807
+ }
808
+
809
+ /**
810
+ * Get tags.
811
+ *
812
+ * @returns the response object that contains results from get tag query.
813
+ */
814
+ _createClass(TaggingReadOnlyClient, [{
815
+ key: "get",
816
+ value: function () {
817
+ var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
818
+ var response;
819
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
820
+ while (1) switch (_context.prev = _context.next) {
821
+ case 0:
822
+ _context.prev = 0;
823
+ _context.next = 3;
824
+ return this.httpClient.get("/tags/".concat(request.id));
825
+ case 3:
826
+ response = _context.sent;
827
+ return _context.abrupt("return", response.data);
828
+ case 7:
829
+ _context.prev = 7;
830
+ _context.t0 = _context["catch"](0);
831
+ handleError(_context.t0, "Failed to get tags.");
832
+ case 10:
833
+ case "end":
834
+ return _context.stop();
835
+ }
836
+ }, _callee, this, [[0, 7]]);
837
+ }));
838
+ function get(_x) {
839
+ return _get.apply(this, arguments);
840
+ }
841
+ return get;
842
+ }()
843
+ /**
844
+ * List tags.
845
+ *
846
+ * @returns the response object that contains results from list tags query.
847
+ */
848
+ }, {
849
+ key: "list",
850
+ value: function () {
851
+ var _list = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
852
+ var response;
853
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
854
+ while (1) switch (_context2.prev = _context2.next) {
855
+ case 0:
856
+ _context2.prev = 0;
857
+ _context2.next = 3;
858
+ return this.httpClient.post("/tags", request || {});
859
+ case 3:
860
+ response = _context2.sent;
861
+ return _context2.abrupt("return", response.data);
862
+ case 7:
863
+ _context2.prev = 7;
864
+ _context2.t0 = _context2["catch"](0);
865
+ handleError(_context2.t0, "Failed to list tags.");
866
+ case 10:
867
+ case "end":
868
+ return _context2.stop();
869
+ }
870
+ }, _callee2, this, [[0, 7]]);
871
+ }));
872
+ function list(_x2) {
873
+ return _list.apply(this, arguments);
874
+ }
875
+ return list;
876
+ }()
877
+ }]);
878
+ return TaggingReadOnlyClient;
879
+ }();
880
+
881
+ var TaggingClient = /*#__PURE__*/function (_TaggingReadOnlyClien) {
882
+ _inherits(TaggingClient, _TaggingReadOnlyClien);
883
+ var _super = _createSuper(TaggingClient);
884
+ function TaggingClient(httpClient, rpcClient, wallet) {
885
+ var _this;
886
+ _classCallCheck(this, TaggingClient);
887
+ _this = _super.call(this, httpClient, rpcClient);
888
+ _this.wallet = wallet;
889
+ return _this;
890
+ }
891
+ _createClass(TaggingClient, [{
892
+ key: "setTag",
893
+ value: function () {
894
+ var _setTag = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
895
+ var _yield$this$rpcClient, call, txHash;
896
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
897
+ while (1) switch (_context.prev = _context.next) {
898
+ case 0:
899
+ _context.prev = 0;
900
+ _context.next = 3;
901
+ return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, TaggingModuleConfig), {}, {
902
+ functionName: "setTag",
903
+ args: [request.tag, request.ipId]
904
+ }));
905
+ case 3:
906
+ _yield$this$rpcClient = _context.sent;
907
+ call = _yield$this$rpcClient.request;
908
+ _context.next = 7;
909
+ return this.wallet.writeContract(call);
910
+ case 7:
911
+ txHash = _context.sent;
912
+ return _context.abrupt("return", {
913
+ txHash: txHash
914
+ });
915
+ case 11:
916
+ _context.prev = 11;
917
+ _context.t0 = _context["catch"](0);
918
+ handleError(_context.t0, "Failed to set tag");
919
+ case 14:
920
+ case "end":
921
+ return _context.stop();
922
+ }
923
+ }, _callee, this, [[0, 11]]);
924
+ }));
925
+ function setTag(_x) {
926
+ return _setTag.apply(this, arguments);
927
+ }
928
+ return setTag;
929
+ }()
930
+ }, {
931
+ key: "removeTag",
932
+ value: function () {
933
+ var _removeTag = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
934
+ var _yield$this$rpcClient2, call, txHash;
935
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
936
+ while (1) switch (_context2.prev = _context2.next) {
937
+ case 0:
938
+ _context2.prev = 0;
939
+ _context2.next = 3;
940
+ return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, TaggingModuleConfig), {}, {
941
+ functionName: "removeTag",
942
+ args: [request.tag, request.ipId]
943
+ }));
944
+ case 3:
945
+ _yield$this$rpcClient2 = _context2.sent;
946
+ call = _yield$this$rpcClient2.request;
947
+ _context2.next = 7;
948
+ return this.wallet.writeContract(call);
949
+ case 7:
950
+ txHash = _context2.sent;
951
+ return _context2.abrupt("return", {
952
+ txHash: txHash
953
+ });
954
+ case 11:
955
+ _context2.prev = 11;
956
+ _context2.t0 = _context2["catch"](0);
957
+ handleError(_context2.t0, "Failed to remove tag");
958
+ case 14:
959
+ case "end":
960
+ return _context2.stop();
961
+ }
962
+ }, _callee2, this, [[0, 11]]);
963
+ }));
964
+ function removeTag(_x2) {
965
+ return _removeTag.apply(this, arguments);
966
+ }
967
+ return removeTag;
968
+ }()
969
+ }]);
970
+ return TaggingClient;
971
+ }(TaggingReadOnlyClient);
972
+
973
+ /**
974
+ * IPAssetReadOnlyClient allows you to view and search IP Assets on Story Protocol.
975
+ */
976
+ var IPAssetReadOnlyClient = /*#__PURE__*/function () {
977
+ function IPAssetReadOnlyClient(httpClient, rpcClient) {
978
+ _classCallCheck(this, IPAssetReadOnlyClient);
979
+ this.httpClient = httpClient;
980
+ this.rpcClient = rpcClient;
981
+ }
982
+
983
+ /**
984
+ * Get an IP Asset based on the specified IP asset ID.
985
+ *
986
+ * @param request - the request object for getting an IP Asset.
987
+ * @returns the response object the contains the fetched IP Asset.
988
+ */
989
+ _createClass(IPAssetReadOnlyClient, [{
990
+ key: "get",
991
+ value: function () {
992
+ var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
993
+ var response;
994
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
995
+ while (1) switch (_context.prev = _context.next) {
996
+ case 0:
997
+ _context.prev = 0;
998
+ if (isAddress(request.ipId)) {
999
+ _context.next = 3;
1000
+ break;
1001
+ }
1002
+ throw new Error("Invalid ip id. Must be an address. But get: ".concat(request.ipId));
1003
+ case 3:
1004
+ _context.next = 5;
1005
+ return this.httpClient.get("/accounts/".concat(request.ipId));
1006
+ case 5:
1007
+ response = _context.sent;
1008
+ return _context.abrupt("return", response.data);
1009
+ case 9:
1010
+ _context.prev = 9;
1011
+ _context.t0 = _context["catch"](0);
1012
+ handleError(_context.t0, "Failed to get IP account");
1013
+ case 12:
1014
+ case "end":
1015
+ return _context.stop();
1016
+ }
1017
+ }, _callee, this, [[0, 9]]);
1018
+ }));
1019
+ function get(_x) {
1020
+ return _get.apply(this, arguments);
1021
+ }
1022
+ return get;
1023
+ }()
1024
+ /**
1025
+ * List IP accounts.
1026
+ *
1027
+ * @returns the response object that contains results from listing query.
1028
+ */
1029
+ }, {
1030
+ key: "list",
1031
+ value: function () {
1032
+ var _list = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
1033
+ var response;
1034
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1035
+ while (1) switch (_context2.prev = _context2.next) {
1036
+ case 0:
1037
+ _context2.prev = 0;
1038
+ _context2.next = 3;
1039
+ return this.httpClient.post("/accounts", request || {});
1040
+ case 3:
1041
+ response = _context2.sent;
1042
+ return _context2.abrupt("return", response.data);
1043
+ case 7:
1044
+ _context2.prev = 7;
1045
+ _context2.t0 = _context2["catch"](0);
1046
+ handleError(_context2.t0, "Failed to list IP Asset.");
1047
+ case 10:
1048
+ case "end":
1049
+ return _context2.stop();
1050
+ }
1051
+ }, _callee2, this, [[0, 7]]);
1052
+ }));
1053
+ function list(_x2) {
1054
+ return _list.apply(this, arguments);
1055
+ }
1056
+ return list;
1057
+ }()
1058
+ }, {
1059
+ key: "getIpId",
1060
+ value: function () {
1061
+ var _getIpId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
1062
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
1063
+ while (1) switch (_context3.prev = _context3.next) {
1064
+ case 0:
1065
+ case "end":
1066
+ return _context3.stop();
1067
+ }
1068
+ }, _callee3);
1069
+ }));
1070
+ function getIpId() {
1071
+ return _getIpId.apply(this, arguments);
1072
+ }
1073
+ return getIpId;
1074
+ }()
1075
+ }]);
1076
+ return IPAssetReadOnlyClient;
1077
+ }();
1078
+
1079
+ var IPAccountRegistryABI = [{
1080
+ inputs: [{
1081
+ internalType: "uint256",
1082
+ name: "chainId_",
1083
+ type: "uint256"
1084
+ }, {
1085
+ internalType: "address",
1086
+ name: "tokenContract_",
1087
+ type: "address"
1088
+ }, {
1089
+ internalType: "uint256",
1090
+ name: "tokenId_",
1091
+ type: "uint256"
1092
+ }],
1093
+ name: "ipAsset",
1094
+ outputs: [{
1095
+ internalType: "address",
1096
+ name: "",
1097
+ type: "address"
1098
+ }],
1099
+ stateMutability: "view",
1100
+ type: "function"
1101
+ }, {
1102
+ anonymous: false,
1103
+ inputs: [{
1104
+ indexed: true,
1105
+ internalType: "address",
1106
+ name: "account",
1107
+ type: "address"
1108
+ }, {
1109
+ indexed: true,
1110
+ internalType: "address",
1111
+ name: "implementation",
1112
+ type: "address"
1113
+ }, {
1114
+ indexed: true,
1115
+ internalType: "uint256",
1116
+ name: "chainId",
1117
+ type: "uint256"
1118
+ }, {
1119
+ indexed: false,
1120
+ internalType: "address",
1121
+ name: "tokenContract",
1122
+ type: "address"
1123
+ }, {
1124
+ indexed: false,
1125
+ internalType: "uint256",
1126
+ name: "tokenId",
1127
+ type: "uint256"
1128
+ }],
1129
+ name: "IPAccountRegistered",
1130
+ type: "event"
1131
+ }];
1132
+
1133
+ if (typeof process !== "undefined") {
1134
+ dotenv.config();
1135
+ }
1136
+ var IPAccountRegistryRaw = IPAccountRegistryABI;
1137
+ formatAbi(IPAccountRegistryRaw);
1138
+ var IPAccountRegistryConfig = {
1139
+ abi: IPAccountRegistryRaw,
1140
+ address: getAddress(process.env.IP_ACCOUNT_REGISTRY || process.env.NEXT_PUBLIC_IP_ACCOUNT_REGISTRY || "")
1141
+ };
1142
+
1143
+ function _arrayLikeToArray(arr, len) {
1144
+ if (len == null || len > arr.length) len = arr.length;
1145
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
1146
+ return arr2;
1147
+ }
1148
+
1149
+ function _unsupportedIterableToArray(o, minLen) {
1150
+ if (!o) return;
1151
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
1152
+ var n = Object.prototype.toString.call(o).slice(8, -1);
1153
+ if (n === "Object" && o.constructor) n = o.constructor.name;
1154
+ if (n === "Map" || n === "Set") return Array.from(o);
1155
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
1156
+ }
1157
+
1158
+ function _createForOfIteratorHelper(o, allowArrayLike) {
1159
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
1160
+ if (!it) {
1161
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
1162
+ if (it) o = it;
1163
+ var i = 0;
1164
+ var F = function () {};
1165
+ return {
1166
+ s: F,
1167
+ n: function () {
1168
+ if (i >= o.length) return {
1169
+ done: true
1170
+ };
1171
+ return {
1172
+ done: false,
1173
+ value: o[i++]
1174
+ };
1175
+ },
1176
+ e: function (e) {
1177
+ throw e;
1178
+ },
1179
+ f: F
1180
+ };
1181
+ }
1182
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1183
+ }
1184
+ var normalCompletion = true,
1185
+ didErr = false,
1186
+ err;
1187
+ return {
1188
+ s: function () {
1189
+ it = it.call(o);
1190
+ },
1191
+ n: function () {
1192
+ var step = it.next();
1193
+ normalCompletion = step.done;
1194
+ return step;
1195
+ },
1196
+ e: function (e) {
1197
+ didErr = true;
1198
+ err = e;
1199
+ },
1200
+ f: function () {
1201
+ try {
1202
+ if (!normalCompletion && it.return != null) it.return();
1203
+ } finally {
1204
+ if (didErr) throw err;
1205
+ }
1206
+ }
1207
+ };
1208
+ }
1209
+
1210
+ function parseToBigInt(num) {
1211
+ return BigInt(num);
1212
+ }
1213
+ function waitTxAndFilterLog(_x, _x2, _x3) {
1214
+ return _waitTxAndFilterLog.apply(this, arguments);
1215
+ }
1216
+ function _waitTxAndFilterLog() {
1217
+ _waitTxAndFilterLog = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(client, txHash, params) {
1218
+ var txReceipt, _iterator, _step, log;
1219
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1220
+ while (1) switch (_context.prev = _context.next) {
1221
+ case 0:
1222
+ _context.next = 2;
1223
+ return client.waitForTransactionReceipt({
1224
+ hash: txHash,
1225
+ confirmations: params.confirmations,
1226
+ pollingInterval: params.pollingInterval,
1227
+ timeout: params.timeout
1228
+ });
1229
+ case 2:
1230
+ txReceipt = _context.sent;
1231
+ _iterator = _createForOfIteratorHelper(txReceipt.logs);
1232
+ _context.prev = 4;
1233
+ _iterator.s();
1234
+ case 6:
1235
+ if ((_step = _iterator.n()).done) {
1236
+ _context.next = 17;
1237
+ break;
1238
+ }
1239
+ log = _step.value;
1240
+ _context.prev = 8;
1241
+ return _context.abrupt("return", decodeEventLog({
1242
+ abi: params.abi,
1243
+ eventName: params.eventName,
1244
+ data: log.data,
1245
+ topics: log.topics
1246
+ }));
1247
+ case 12:
1248
+ _context.prev = 12;
1249
+ _context.t0 = _context["catch"](8);
1250
+ return _context.abrupt("continue", 15);
1251
+ case 15:
1252
+ _context.next = 6;
1253
+ break;
1254
+ case 17:
1255
+ _context.next = 22;
1256
+ break;
1257
+ case 19:
1258
+ _context.prev = 19;
1259
+ _context.t1 = _context["catch"](4);
1260
+ _iterator.e(_context.t1);
1261
+ case 22:
1262
+ _context.prev = 22;
1263
+ _iterator.f();
1264
+ return _context.finish(22);
1265
+ case 25:
1266
+ throw new Error("not found event ".concat(params.eventName, " in target transaction"));
1267
+ case 26:
1268
+ case "end":
1269
+ return _context.stop();
1270
+ }
1271
+ }, _callee, null, [[4, 19, 22, 25], [8, 12]]);
1272
+ }));
1273
+ return _waitTxAndFilterLog.apply(this, arguments);
1274
+ }
1275
+
1276
+ function _arrayWithoutHoles(arr) {
1277
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
1278
+ }
1279
+
1280
+ function _iterableToArray(iter) {
1281
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
1282
+ }
1283
+
1284
+ function _nonIterableSpread() {
1285
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1286
+ }
1287
+
1288
+ function _toConsumableArray(arr) {
1289
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
1290
+ }
1291
+
1292
+ var RegistrationModuleABI = [{
1293
+ inputs: [{
1294
+ internalType: "uint256",
1295
+ name: "licenseId",
1296
+ type: "uint256"
1297
+ }, {
1298
+ internalType: "address",
1299
+ name: "tokenContract",
1300
+ type: "address"
1301
+ }, {
1302
+ internalType: "uint256",
1303
+ name: "tokenId",
1304
+ type: "uint256"
1305
+ }, {
1306
+ internalType: "string",
1307
+ name: "ipName",
1308
+ type: "string"
1309
+ }, {
1310
+ internalType: "string",
1311
+ name: "ipDescription",
1312
+ type: "string"
1313
+ }, {
1314
+ internalType: "bytes32",
1315
+ name: "contentHash",
1316
+ type: "bytes32"
1317
+ }],
1318
+ name: "registerDerivativeIp",
1319
+ outputs: [],
1320
+ stateMutability: "nonpayable",
1321
+ type: "function"
1322
+ }, {
1323
+ inputs: [{
1324
+ internalType: "uint256",
1325
+ name: "policyId",
1326
+ type: "uint256"
1327
+ }, {
1328
+ internalType: "address",
1329
+ name: "tokenContract",
1330
+ type: "address"
1331
+ }, {
1332
+ internalType: "uint256",
1333
+ name: "tokenId",
1334
+ type: "uint256"
1335
+ }],
1336
+ name: "registerRootIp",
1337
+ outputs: [{
1338
+ internalType: "address",
1339
+ name: "",
1340
+ type: "address"
1341
+ }],
1342
+ stateMutability: "nonpayable",
1343
+ type: "function"
1344
+ }];
1345
+
1346
+ var errorsJson = [
1347
+ {
1348
+ inputs: [
1349
+ ],
1350
+ name: "AccessController__CallerIsNotIPAccount",
1351
+ type: "error"
1352
+ },
1353
+ {
1354
+ inputs: [
1355
+ ],
1356
+ name: "AccessController__IPAccountIsNotValid",
1357
+ type: "error"
1358
+ },
1359
+ {
1360
+ inputs: [
1361
+ ],
1362
+ name: "AccessController__IPAccountIsZeroAddress",
1363
+ type: "error"
1364
+ },
1365
+ {
1366
+ inputs: [
1367
+ ],
1368
+ name: "AccessController__PermissionIsNotValid",
1369
+ type: "error"
1370
+ },
1371
+ {
1372
+ inputs: [
1373
+ ],
1374
+ name: "AccessController__SignerIsZeroAddress",
1375
+ type: "error"
1376
+ },
1377
+ {
1378
+ inputs: [
1379
+ ],
1380
+ name: "ArbitrationPolicySP__NotDisputeModule",
1381
+ type: "error"
1382
+ },
1383
+ {
1384
+ inputs: [
1385
+ ],
1386
+ name: "ArbitrationPolicySP__ZeroDisputeModule",
1387
+ type: "error"
1388
+ },
1389
+ {
1390
+ inputs: [
1391
+ ],
1392
+ name: "ArbitrationPolicySP__ZeroPaymentToken",
1393
+ type: "error"
1394
+ },
1395
+ {
1396
+ inputs: [
1397
+ ],
1398
+ name: "DisputeModule__NotDisputeInitiator",
1399
+ type: "error"
1400
+ },
1401
+ {
1402
+ inputs: [
1403
+ ],
1404
+ name: "DisputeModule__NotWhitelistedArbitrationPolicy",
1405
+ type: "error"
1406
+ },
1407
+ {
1408
+ inputs: [
1409
+ ],
1410
+ name: "DisputeModule__NotWhitelistedArbitrationRelayer",
1411
+ type: "error"
1412
+ },
1413
+ {
1414
+ inputs: [
1415
+ ],
1416
+ name: "DisputeModule__NotWhitelistedDisputeTag",
1417
+ type: "error"
1418
+ },
1419
+ {
1420
+ inputs: [
1421
+ ],
1422
+ name: "DisputeModule__ZeroArbitrationPolicy",
1423
+ type: "error"
1424
+ },
1425
+ {
1426
+ inputs: [
1427
+ ],
1428
+ name: "DisputeModule__ZeroArbitrationRelayer",
1429
+ type: "error"
1430
+ },
1431
+ {
1432
+ inputs: [
1433
+ ],
1434
+ name: "DisputeModule__ZeroDisputeTag",
1435
+ type: "error"
1436
+ },
1437
+ {
1438
+ inputs: [
1439
+ ],
1440
+ name: "DisputeModule__ZeroLinkToDisputeSummary",
1441
+ type: "error"
1442
+ },
1443
+ {
1444
+ inputs: [
1445
+ ],
1446
+ name: "IPRecordRegistry_AlreadyRegistered",
1447
+ type: "error"
1448
+ },
1449
+ {
1450
+ inputs: [
1451
+ ],
1452
+ name: "IPRecordRegistry_IPAccountAlreadyCreated",
1453
+ type: "error"
1454
+ },
1455
+ {
1456
+ inputs: [
1457
+ ],
1458
+ name: "IPRecordRegistry_NotYetRegistered",
1459
+ type: "error"
1460
+ },
1461
+ {
1462
+ inputs: [
1463
+ ],
1464
+ name: "IPRecordRegistry_ResolverInvalid",
1465
+ type: "error"
1466
+ },
1467
+ {
1468
+ inputs: [
1469
+ ],
1470
+ name: "IPRecordRegistry_Unauthorized",
1471
+ type: "error"
1472
+ },
1473
+ {
1474
+ inputs: [
1475
+ ],
1476
+ name: "IPResolver_InvalidIP",
1477
+ type: "error"
1478
+ },
1479
+ {
1480
+ inputs: [
1481
+ ],
1482
+ name: "IPResolver_Unauthorized",
1483
+ type: "error"
1484
+ },
1485
+ {
1486
+ inputs: [
1487
+ ],
1488
+ name: "LicenseRegistry__EmptyLicenseUrl",
1489
+ type: "error"
1490
+ },
1491
+ {
1492
+ inputs: [
1493
+ ],
1494
+ name: "LicenseRegistry__FrameworkNotFound",
1495
+ type: "error"
1496
+ },
1497
+ {
1498
+ inputs: [
1499
+ ],
1500
+ name: "LicenseRegistry__InvalidParamVerifierType",
1501
+ type: "error"
1502
+ },
1503
+ {
1504
+ inputs: [
1505
+ ],
1506
+ name: "LicenseRegistry__LicensorDoesntHaveThisPolicy",
1507
+ type: "error"
1508
+ },
1509
+ {
1510
+ inputs: [
1511
+ ],
1512
+ name: "LicenseRegistry__LinkParentParamFailed",
1513
+ type: "error"
1514
+ },
1515
+ {
1516
+ inputs: [
1517
+ ],
1518
+ name: "LicenseRegistry__MintParamFailed",
1519
+ type: "error"
1520
+ },
1521
+ {
1522
+ inputs: [
1523
+ ],
1524
+ name: "LicenseRegistry__NotLicensee",
1525
+ type: "error"
1526
+ },
1527
+ {
1528
+ inputs: [
1529
+ ],
1530
+ name: "LicenseRegistry__ParamVerifierLengthMismatch",
1531
+ type: "error"
1532
+ },
1533
+ {
1534
+ inputs: [
1535
+ ],
1536
+ name: "LicenseRegistry__ParentIdEqualThanChild",
1537
+ type: "error"
1538
+ },
1539
+ {
1540
+ inputs: [
1541
+ ],
1542
+ name: "LicenseRegistry__PolicyAlreadySetForIpId",
1543
+ type: "error"
1544
+ },
1545
+ {
1546
+ inputs: [
1547
+ ],
1548
+ name: "LicenseRegistry__PolicyNotFound",
1549
+ type: "error"
1550
+ },
1551
+ {
1552
+ inputs: [
1553
+ ],
1554
+ name: "ModuleRegistry__ModuleAddressNotContract",
1555
+ type: "error"
1556
+ },
1557
+ {
1558
+ inputs: [
1559
+ ],
1560
+ name: "ModuleRegistry__ModuleAddressZeroAddress",
1561
+ type: "error"
1562
+ },
1563
+ {
1564
+ inputs: [
1565
+ ],
1566
+ name: "ModuleRegistry__ModuleAlreadyRegistered",
1567
+ type: "error"
1568
+ },
1569
+ {
1570
+ inputs: [
1571
+ ],
1572
+ name: "ModuleRegistry__ModuleNotRegistered",
1573
+ type: "error"
1574
+ },
1575
+ {
1576
+ inputs: [
1577
+ ],
1578
+ name: "ModuleRegistry__NameAlreadyRegistered",
1579
+ type: "error"
1580
+ },
1581
+ {
1582
+ inputs: [
1583
+ ],
1584
+ name: "ModuleRegistry__NameDoesNotMatch",
1585
+ type: "error"
1586
+ },
1587
+ {
1588
+ inputs: [
1589
+ ],
1590
+ name: "ModuleRegistry__NameEmptyString",
1591
+ type: "error"
1592
+ },
1593
+ {
1594
+ inputs: [
1595
+ ],
1596
+ name: "Module_Unauthorized",
1597
+ type: "error"
1598
+ },
1599
+ {
1600
+ inputs: [
1601
+ ],
1602
+ name: "RegistrationModule__InvalidOwner",
1603
+ type: "error"
1604
+ },
1605
+ {
1606
+ inputs: [
1607
+ ],
1608
+ name: "RoyaltyModule__AlreadySetRoyaltyPolicy",
1609
+ type: "error"
1610
+ },
1611
+ {
1612
+ inputs: [
1613
+ ],
1614
+ name: "RoyaltyModule__NotWhitelistedRoyaltyPolicy",
1615
+ type: "error"
1616
+ },
1617
+ {
1618
+ inputs: [
1619
+ ],
1620
+ name: "RoyaltyModule__ZeroRoyaltyPolicy",
1621
+ type: "error"
1622
+ },
1623
+ {
1624
+ inputs: [
1625
+ ],
1626
+ name: "RoyaltyPolicyLS__NotRoyaltyModule",
1627
+ type: "error"
1628
+ },
1629
+ {
1630
+ inputs: [
1631
+ ],
1632
+ name: "RoyaltyPolicyLS__TransferFailed",
1633
+ type: "error"
1634
+ },
1635
+ {
1636
+ inputs: [
1637
+ ],
1638
+ name: "RoyaltyPolicyLS__ZeroLiquidSplitFactory",
1639
+ type: "error"
1640
+ },
1641
+ {
1642
+ inputs: [
1643
+ ],
1644
+ name: "RoyaltyPolicyLS__ZeroLiquidSplitMain",
1645
+ type: "error"
1646
+ },
1647
+ {
1648
+ inputs: [
1649
+ ],
1650
+ name: "RoyaltyPolicyLS__ZeroRoyaltyModule",
1651
+ type: "error"
1652
+ },
1653
+ {
1654
+ inputs: [
1655
+ ],
1656
+ name: "TaggingModule__DstIpIdDoesNotHaveDstTag",
1657
+ type: "error"
1658
+ },
1659
+ {
1660
+ inputs: [
1661
+ ],
1662
+ name: "TaggingModule__InvalidRelationTypeName",
1663
+ type: "error"
1664
+ },
1665
+ {
1666
+ inputs: [
1667
+ ],
1668
+ name: "TaggingModule__RelationTypeAlreadyExists",
1669
+ type: "error"
1670
+ },
1671
+ {
1672
+ inputs: [
1673
+ ],
1674
+ name: "TaggingModule__RelationTypeDoesNotExist",
1675
+ type: "error"
1676
+ },
1677
+ {
1678
+ inputs: [
1679
+ ],
1680
+ name: "TaggingModule__SrcIpIdDoesNotHaveSrcTag",
1681
+ type: "error"
1682
+ }
1683
+ ];
1684
+
1685
+ var ErrorsAbi$2 = errorsJson;
1686
+ var storyProtocolMerged = [].concat(_toConsumableArray(RegistrationModuleABI), _toConsumableArray(ErrorsAbi$2));
1687
+ var RegistrationModuleConfig = {
1688
+ abi: storyProtocolMerged,
1689
+ address: getAddress(process.env.REGISTRATION_MODULE || process.env.NEXT_PUBLIC_REGISTRATION_MODULE || "")
1690
+ };
1691
+
1692
+ var IPAssetClient = /*#__PURE__*/function (_IPAssetReadOnlyClien) {
1693
+ _inherits(IPAssetClient, _IPAssetReadOnlyClien);
1694
+ var _super = _createSuper(IPAssetClient);
1695
+ function IPAssetClient(httpClient, rpcClient, wallet) {
1696
+ var _this;
1697
+ _classCallCheck(this, IPAssetClient);
1698
+ _this = _super.call(this, httpClient, rpcClient);
1699
+ _this.wallet = wallet;
1700
+ return _this;
1701
+ }
1702
+
1703
+ /**
1704
+ * Register a root IP on Story Protocol based on the specified input asset data.
1705
+ *
1706
+ * @param request - the request object that contains all data needed to register a root IP.
1707
+ * @returns the response object that contains results from the IP creation.
1708
+ */
1709
+ _createClass(IPAssetClient, [{
1710
+ key: "registerRootIp",
1711
+ value: function () {
1712
+ var _registerRootIp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
1713
+ var _request$txOptions, _yield$this$rpcClient, call, txHash, targetLog;
1714
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1715
+ while (1) switch (_context.prev = _context.next) {
1716
+ case 0:
1717
+ _context.prev = 0;
1718
+ _context.next = 3;
1719
+ return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, RegistrationModuleConfig), {}, {
1720
+ functionName: "registerRootIp",
1721
+ args: [parseToBigInt(request.policyId), getAddress(request.tokenContractAddress),
1722
+ // 0x Address
1723
+ parseToBigInt(request.tokenId)],
1724
+ account: this.wallet.account
1725
+ }));
1726
+ case 3:
1727
+ _yield$this$rpcClient = _context.sent;
1728
+ call = _yield$this$rpcClient.request;
1729
+ _context.next = 7;
1730
+ return this.wallet.writeContract(call);
1731
+ case 7:
1732
+ txHash = _context.sent;
1733
+ if (!((_request$txOptions = request.txOptions) !== null && _request$txOptions !== void 0 && _request$txOptions.waitForTransaction)) {
1734
+ _context.next = 15;
1735
+ break;
1736
+ }
1737
+ _context.next = 11;
1738
+ return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, IPAccountRegistryConfig), {}, {
1739
+ eventName: "IPAccountRegistered"
1740
+ }));
1741
+ case 11:
1742
+ targetLog = _context.sent;
1743
+ return _context.abrupt("return", {
1744
+ txHash: txHash,
1745
+ ipAccountId: targetLog === null || targetLog === void 0 ? void 0 : targetLog.args.account.toString()
1746
+ });
1747
+ case 15:
1748
+ return _context.abrupt("return", {
1749
+ txHash: txHash
1750
+ });
1751
+ case 16:
1752
+ _context.next = 21;
1753
+ break;
1754
+ case 18:
1755
+ _context.prev = 18;
1756
+ _context.t0 = _context["catch"](0);
1757
+ handleError(_context.t0, "Failed to register root IP");
1758
+ case 21:
1759
+ case "end":
1760
+ return _context.stop();
1761
+ }
1762
+ }, _callee, this, [[0, 18]]);
1763
+ }));
1764
+ function registerRootIp(_x) {
1765
+ return _registerRootIp.apply(this, arguments);
1766
+ }
1767
+ return registerRootIp;
1768
+ }()
1769
+ /**
1770
+ * Register a derivative IP on Story Protocol based on the specified input asset data.
1771
+ *
1772
+ * @param request - the request object that contains all data needed to register a derivative IP.
1773
+ * @returns the response object that contains results from the IP creation.
1774
+ */
1775
+ }, {
1776
+ key: "registerDerivativeIp",
1777
+ value: function () {
1778
+ var _registerDerivativeIp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
1779
+ var _request$txOptions2, _yield$this$rpcClient2, call, txHash, targetLog;
1780
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1781
+ while (1) switch (_context2.prev = _context2.next) {
1782
+ case 0:
1783
+ _context2.prev = 0;
1784
+ _context2.next = 3;
1785
+ return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, RegistrationModuleConfig), {}, {
1786
+ functionName: "registerDerivativeIp",
1787
+ args: [parseToBigInt(request.licenseId), getAddress(request.tokenContractAddress),
1788
+ // 0x Address
1789
+ parseToBigInt(request.tokenId), request.ipName, request.ipDescription, getAddress(request.hash) // Byte32
1790
+ ]
1791
+ }));
1792
+ case 3:
1793
+ _yield$this$rpcClient2 = _context2.sent;
1794
+ call = _yield$this$rpcClient2.request;
1795
+ _context2.next = 7;
1796
+ return this.wallet.writeContract(call);
1797
+ case 7:
1798
+ txHash = _context2.sent;
1799
+ if (!((_request$txOptions2 = request.txOptions) !== null && _request$txOptions2 !== void 0 && _request$txOptions2.waitForTransaction)) {
1800
+ _context2.next = 15;
1801
+ break;
1802
+ }
1803
+ _context2.next = 11;
1804
+ return waitTxAndFilterLog(this.rpcClient, txHash, _objectSpread2(_objectSpread2({}, IPAccountRegistryConfig), {}, {
1805
+ eventName: "IPAccountRegistered"
1806
+ }));
1807
+ case 11:
1808
+ targetLog = _context2.sent;
1809
+ return _context2.abrupt("return", {
1810
+ txHash: txHash,
1811
+ ipAccountId: targetLog === null || targetLog === void 0 ? void 0 : targetLog.args.account.toString()
1812
+ });
1813
+ case 15:
1814
+ return _context2.abrupt("return", {
1815
+ txHash: txHash
1816
+ });
1817
+ case 16:
1818
+ _context2.next = 21;
1819
+ break;
1820
+ case 18:
1821
+ _context2.prev = 18;
1822
+ _context2.t0 = _context2["catch"](0);
1823
+ handleError(_context2.t0, "Failed to register derivative IP");
1824
+ case 21:
1825
+ case "end":
1826
+ return _context2.stop();
1827
+ }
1828
+ }, _callee2, this, [[0, 18]]);
1829
+ }));
1830
+ function registerDerivativeIp(_x2) {
1831
+ return _registerDerivativeIp.apply(this, arguments);
1832
+ }
1833
+ return registerDerivativeIp;
1834
+ }() // TODO: move to License resource
1835
+ // public async createPolicy(request: addPolicyRequest): Promise<addPolicyResponse> {
1836
+ // try {
1837
+ // const { request: call } = await this.rpcClient.simulateContract({
1838
+ // ...LicenseRegistryConfig,
1839
+ // functionName: "addPolicy",
1840
+ // args: [
1841
+ // {
1842
+ // frameworkId: parseToBigInt(request.frameworkId),
1843
+ // mintingParamValues: request.mintingParamValues.map((add) => getAddress(add)),
1844
+ // activationParamValues: request.activationParamValues.map((add) => getAddress(add)),
1845
+ // needsActivation: request.needsActivation,
1846
+ // linkParentParamValues: request.linkParentParamValues.map((add) => getAddress(add)),
1847
+ // },
1848
+ // ], // TODO: add args
1849
+ // });
1850
+ // const txHash = await this.wallet.writeContract(call);
1851
+ // // TODO: need an emitted event
1852
+ // // if (request.txOptions?.waitForTransaction) {
1853
+ // // const targetLog = await waitTxAndFilterLog(this.rpcClient, txHash, {
1854
+ // // ...IPAccountRegistryConfig,
1855
+ // // eventName: "IPAccountRegistered",
1856
+ // // });
1857
+ // // return { txHash: txHash, policyId: targetLog?.args.account.toString() };
1858
+ // // } else {
1859
+ // return { txHash: txHash };
1860
+ // // }
1861
+ // } catch (error) {
1862
+ // handleError(error, "Failed to register derivative IP");
1863
+ // }
1864
+ // }
1865
+ // TODO: move to License resource
1866
+ // public async addPolicyToIp(request: addPolicyToIpRequest): Promise<addPolicyToIpResponse> {
1867
+ // TODO: use getIpAccount to get the ipId
1868
+ // }
1869
+ }]);
1870
+ return IPAssetClient;
1871
+ }(IPAssetReadOnlyClient);
1872
+
1873
+ // import { isIntegerString } from "../utils/utils";
1874
+
1875
+ /**
1876
+ * IPAssetReadOnlyClient allows you to view and search IP Assets on Story Protocol.
1877
+ */
1878
+ var PermissionReadOnlyClient = /*#__PURE__*/function () {
1879
+ function PermissionReadOnlyClient(httpClient, rpcClient) {
1880
+ _classCallCheck(this, PermissionReadOnlyClient);
1881
+ this.httpClient = httpClient;
1882
+ this.rpcClient = rpcClient;
1883
+ }
1884
+
1885
+ /**
1886
+ * Get permission based on based on the specified IP id.
1887
+ *
1888
+ * @param request - the request object for getting an IP Asset.
1889
+ * @returns the response object the contains the fetched IP Asset.
1890
+ */
1891
+ _createClass(PermissionReadOnlyClient, [{
1892
+ key: "get",
1893
+ value: function () {
1894
+ var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
1895
+ var response;
1896
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1897
+ while (1) switch (_context.prev = _context.next) {
1898
+ case 0:
1899
+ _context.prev = 0;
1900
+ _context.next = 3;
1901
+ return this.httpClient.get("/permissions/".concat(request.permissionId));
1902
+ case 3:
1903
+ response = _context.sent;
1904
+ return _context.abrupt("return", response.data);
1905
+ case 7:
1906
+ _context.prev = 7;
1907
+ _context.t0 = _context["catch"](0);
1908
+ handleError(_context.t0, "Failed to get IP account");
1909
+ case 10:
1910
+ case "end":
1911
+ return _context.stop();
1912
+ }
1913
+ }, _callee, this, [[0, 7]]);
1914
+ }));
1915
+ function get(_x) {
1916
+ return _get.apply(this, arguments);
1917
+ }
1918
+ return get;
1919
+ }()
1920
+ /**
1921
+ * List IP accounts.
1922
+ *
1923
+ * @returns the response object that contains results from listing query.
1924
+ */
1925
+ }, {
1926
+ key: "list",
1927
+ value: function () {
1928
+ var _list = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
1929
+ var response;
1930
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1931
+ while (1) switch (_context2.prev = _context2.next) {
1932
+ case 0:
1933
+ _context2.prev = 0;
1934
+ _context2.next = 3;
1935
+ return this.httpClient.post("/permissions", request || {});
1936
+ case 3:
1937
+ response = _context2.sent;
1938
+ return _context2.abrupt("return", response.data);
1939
+ case 7:
1940
+ _context2.prev = 7;
1941
+ _context2.t0 = _context2["catch"](0);
1942
+ handleError(_context2.t0, "Failed to list IP Asset.");
1943
+ case 10:
1944
+ case "end":
1945
+ return _context2.stop();
1946
+ }
1947
+ }, _callee2, this, [[0, 7]]);
1948
+ }));
1949
+ function list(_x2) {
1950
+ return _list.apply(this, arguments);
1951
+ }
1952
+ return list;
1953
+ }()
1954
+ }]);
1955
+ return PermissionReadOnlyClient;
1956
+ }();
1957
+
1958
+ var IPAccountImplABI = [{
1959
+ inputs: [{
1960
+ internalType: "address",
1961
+ name: "to_",
1962
+ type: "address"
1963
+ }, {
1964
+ internalType: "uint256",
1965
+ name: "value_",
1966
+ type: "uint256"
1967
+ }, {
1968
+ internalType: "bytes",
1969
+ name: "data_",
1970
+ type: "bytes"
1971
+ }],
1972
+ name: "execute",
1973
+ outputs: [{
1974
+ internalType: "bytes",
1975
+ name: "result",
1976
+ type: "bytes"
1977
+ }],
1978
+ stateMutability: "payable",
1979
+ type: "function"
1980
+ }, {
1981
+ inputs: [{
1982
+ internalType: "address",
1983
+ name: "signer_",
1984
+ type: "address"
1985
+ }, {
1986
+ internalType: "bytes",
1987
+ name: "data_",
1988
+ type: "bytes"
1989
+ }],
1990
+ name: "isValidSigner",
1991
+ outputs: [{
1992
+ internalType: "bytes4",
1993
+ name: "",
1994
+ type: "bytes4"
1995
+ }],
1996
+ stateMutability: "view",
1997
+ type: "function"
1998
+ }];
1999
+
2000
+ var ErrorsAbi$1 = errorsJson;
2001
+ var IPAccountImplMerged = [].concat(_toConsumableArray(IPAccountImplABI), _toConsumableArray(ErrorsAbi$1));
2002
+
2003
+ var AccessControllerABI = [{
2004
+ inputs: [{
2005
+ internalType: "address",
2006
+ name: "ipAccount_",
2007
+ type: "address"
2008
+ }, {
2009
+ internalType: "address",
2010
+ name: "signer_",
2011
+ type: "address"
2012
+ }, {
2013
+ internalType: "address",
2014
+ name: "to_",
2015
+ type: "address"
2016
+ }, {
2017
+ internalType: "bytes4",
2018
+ name: "func_",
2019
+ type: "bytes4"
2020
+ }, {
2021
+ internalType: "uint8",
2022
+ name: "permission_",
2023
+ type: "uint8"
2024
+ }],
2025
+ name: "setPermission",
2026
+ outputs: [],
2027
+ stateMutability: "nonpayable",
2028
+ type: "function"
2029
+ }, {
2030
+ anonymous: false,
2031
+ inputs: [{
2032
+ indexed: true,
2033
+ internalType: "address",
2034
+ name: "ipAccount",
2035
+ type: "address"
2036
+ }, {
2037
+ indexed: true,
2038
+ internalType: "address",
2039
+ name: "signer",
2040
+ type: "address"
2041
+ }, {
2042
+ indexed: true,
2043
+ internalType: "address",
2044
+ name: "to",
2045
+ type: "address"
2046
+ }, {
2047
+ indexed: false,
2048
+ internalType: "bytes4",
2049
+ name: "func",
2050
+ type: "bytes4"
2051
+ }, {
2052
+ indexed: false,
2053
+ internalType: "uint8",
2054
+ name: "permission",
2055
+ type: "uint8"
2056
+ }],
2057
+ name: "PermissionSet",
2058
+ type: "event"
2059
+ }];
2060
+
2061
+ var ErrorsAbi = errorsJson;
2062
+ var AccessControllerABImerged = [].concat(_toConsumableArray(AccessControllerABI), _toConsumableArray(ErrorsAbi));
2063
+ ({
2064
+ abi: AccessControllerABImerged,
2065
+ address: getAddress(process.env.ACCESS_CONTROLLER || process.env.NEXT_PUBLIC_ACCESS_CONTROLLER || "")
2066
+ });
2067
+
2068
+ // import { HashZero } from "../constants/common";
2069
+
2070
+ var PermissionClient = /*#__PURE__*/function (_PermissionReadOnlyCl) {
2071
+ _inherits(PermissionClient, _PermissionReadOnlyCl);
2072
+ var _super = _createSuper(PermissionClient);
2073
+ function PermissionClient(httpClient, rpcClient, wallet) {
2074
+ var _this;
2075
+ _classCallCheck(this, PermissionClient);
2076
+ _this = _super.call(this, httpClient, rpcClient);
2077
+ _this.wallet = wallet;
2078
+ return _this;
2079
+ }
2080
+
2081
+ /**
2082
+ * Set Permission based on the specified input
2083
+ *
2084
+ * @param request - the request object that contains all data needed to set permission.
2085
+ * @returns the response object that contains results from the set permission.
2086
+ */
2087
+ _createClass(PermissionClient, [{
2088
+ key: "setPermission",
2089
+ value: function () {
2090
+ var _setPermission = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
2091
+ var IPAccountConfig, accessController, _yield$this$rpcClient, call, txHash;
2092
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
2093
+ while (1) switch (_context.prev = _context.next) {
2094
+ case 0:
2095
+ _context.prev = 0;
2096
+ IPAccountConfig = {
2097
+ abi: IPAccountImplMerged,
2098
+ address: getAddress(request.ipAsset)
2099
+ };
2100
+ accessController = getAddress(process.env.ACCESS_CONTROLLER || process.env.NEXT_PUBLIC_ACCESS_CONTROLLER || ""); //to
2101
+ _context.next = 5;
2102
+ return this.rpcClient.simulateContract(_objectSpread2(_objectSpread2({}, IPAccountConfig), {}, {
2103
+ functionName: "execute",
2104
+ args: [accessController, 0, encodeFunctionData({
2105
+ abi: AccessControllerABImerged,
2106
+ functionName: "setPermission",
2107
+ args: [getAddress(request.ipAsset),
2108
+ // 0x Address
2109
+ getAddress(request.signer),
2110
+ // 0x Address
2111
+ getAddress(request.to),
2112
+ // 0x Address
2113
+ request.func,
2114
+ // bytes4
2115
+ request.permission // uint8
2116
+ ]
2117
+ })],
2118
+
2119
+ account: this.wallet.account
2120
+ }));
2121
+ case 5:
2122
+ _yield$this$rpcClient = _context.sent;
2123
+ call = _yield$this$rpcClient.request;
2124
+ _context.next = 9;
2125
+ return this.wallet.writeContract(call);
2126
+ case 9:
2127
+ txHash = _context.sent;
2128
+ return _context.abrupt("return", {
2129
+ txHash: txHash
2130
+ });
2131
+ case 13:
2132
+ _context.prev = 13;
2133
+ _context.t0 = _context["catch"](0);
2134
+ handleError(_context.t0, "Failed to set permissions");
2135
+ case 16:
2136
+ case "end":
2137
+ return _context.stop();
2138
+ }
2139
+ }, _callee, this, [[0, 13]]);
2140
+ }));
2141
+ function setPermission(_x) {
2142
+ return _setPermission.apply(this, arguments);
2143
+ }
2144
+ return setPermission;
2145
+ }()
2146
+ }]);
2147
+ return PermissionClient;
2148
+ }(PermissionReadOnlyClient);
2149
+
2150
+ if (typeof process !== "undefined") {
2151
+ dotenv.config();
2152
+ }
2153
+ /**
2154
+ * The StoryClient is the main entry point for the SDK.
2155
+ */
2156
+ var StoryClient = /*#__PURE__*/function () {
2157
+ /**
2158
+ * @param config - the configuration for the SDK client
2159
+ * @param isReadOnly
2160
+ */
2161
+ function StoryClient(config) {
2162
+ var isReadOnly = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
2163
+ _classCallCheck(this, StoryClient);
2164
+ _defineProperty(this, "isReadOnly", false);
2165
+ _defineProperty(this, "_ipAccount", null);
2166
+ _defineProperty(this, "_permission", null);
2167
+ _defineProperty(this, "_transaction", null);
2168
+ _defineProperty(this, "_platform", null);
2169
+ _defineProperty(this, "_module", null);
2170
+ _defineProperty(this, "_tagging", null);
2171
+ this.config = config;
2172
+ this.isReadOnly = isReadOnly;
2173
+ var clientConfig = {
2174
+ chain: this.config.chain || sepolia,
2175
+ transport: this.config.transport || http(process.env.RPC_PROVIDER_URL)
2176
+ };
2177
+ this.rpcClient = createPublicClient(clientConfig);
2178
+ if (!isReadOnly) {
2179
+ var account = this.config.account;
2180
+ if (!account) {
2181
+ throw new Error("account is null");
2182
+ }
2183
+ this.wallet = createWalletClient(_objectSpread2(_objectSpread2({}, clientConfig), {}, {
2184
+ account: account
2185
+ }));
2186
+ }
2187
+ this.httpClient = axios.create({
2188
+ baseURL: process.env.API_BASE_URL || process.env.NEXT_PUBLIC_API_BASE_URL,
2189
+ timeout: HTTP_TIMEOUT,
2190
+ headers: {
2191
+ version: "v0-alpha"
2192
+ }
2193
+ });
2194
+ }
2195
+
2196
+ /**
2197
+ * Factory method for creating a read only SDK client.
2198
+ *
2199
+ * @param config - the configuration for a read only SDK client
2200
+ */
2201
+ _createClass(StoryClient, [{
2202
+ key: "ipAsset",
2203
+ get: function get() {
2204
+ if (this._ipAccount === null) {
2205
+ this._ipAccount = this.isReadOnly ? new IPAssetReadOnlyClient(this.httpClient, this.rpcClient) : new IPAssetClient(this.httpClient, this.rpcClient, this.wallet);
2206
+ }
2207
+ return this._ipAccount;
2208
+ }
2209
+ }, {
2210
+ key: "permission",
2211
+ get: function get() {
2212
+ if (this._permission === null) {
2213
+ this._permission = this.isReadOnly ? new PermissionReadOnlyClient(this.httpClient, this.rpcClient) : new PermissionClient(this.httpClient, this.rpcClient, this.wallet);
2214
+ }
2215
+ return this._permission;
2216
+ }
2217
+
2218
+ /**
2219
+ * Getter for the transaction client. The client is lazily created when
2220
+ * this method is called.
2221
+ *
2222
+ * @returns the TransactionReadOnlyClient or TransactionClient instance
2223
+ */
2224
+ }, {
2225
+ key: "transaction",
2226
+ get: function get() {
2227
+ if (this._transaction === null) {
2228
+ this._transaction = this.isReadOnly ? new TransactionReadOnlyClient(this.httpClient, this.rpcClient) : new TransactionClient(this.httpClient, this.rpcClient, this.wallet);
2229
+ }
2230
+ return this._transaction;
2231
+ }
2232
+
2233
+ /**
2234
+ * Getter for the tagging client. The client is lazily created when
2235
+ * this method is called.
2236
+ *
2237
+ * @returns the TaggingReadOnlyClient or TaggingClient instance
2238
+ */
2239
+ }, {
2240
+ key: "tagging",
2241
+ get: function get() {
2242
+ if (this._tagging === null) {
2243
+ this._tagging = this.isReadOnly ? new TaggingReadOnlyClient(this.httpClient, this.rpcClient) : new TaggingClient(this.httpClient, this.rpcClient, this.wallet);
2244
+ }
2245
+ return this._tagging;
2246
+ }
2247
+
2248
+ /**
2249
+ * Getter for the platform client. The client is lazily created when
2250
+ * this method is called.
2251
+ *
2252
+ * @returns the PlatformClient instance
2253
+ */
2254
+ }, {
2255
+ key: "platform",
2256
+ get: function get() {
2257
+ if (this._platform === null) {
2258
+ this._platform = new PlatformClient(this.httpClient);
2259
+ }
2260
+ return this._platform;
2261
+ }
2262
+
2263
+ /**
2264
+ * Getter for the module client. The client is lazily created when
2265
+ * this method is called.
2266
+ *
2267
+ * @returns the Module instance
2268
+ */
2269
+ }, {
2270
+ key: "module",
2271
+ get: function get() {
2272
+ if (this._module === null) {
2273
+ this._module = new ModuleReadOnlyClient(this.httpClient, this.rpcClient);
2274
+ }
2275
+ return this._module;
2276
+ }
2277
+ }], [{
2278
+ key: "newReadOnlyClient",
2279
+ value: function newReadOnlyClient(config) {
2280
+ return new StoryClient(config, true);
2281
+ }
2282
+
2283
+ /**
2284
+ * Factory method for creating a SDK client with a signer.
2285
+ *
2286
+ * @param config - the configuration for a new read/write SDK client
2287
+ */
2288
+ }, {
2289
+ key: "newClient",
2290
+ value: function newClient(config) {
2291
+ return new StoryClient(config, false);
2292
+ }
2293
+ }]);
2294
+ return StoryClient;
2295
+ }();
2296
+
2297
+ /**
2298
+ * @public
2299
+ */
2300
+ var ResourceType = /*#__PURE__*/function (ResourceType) {
2301
+ ResourceType["Unspecified"] = "Unspecified";
2302
+ ResourceType["IPOrg"] = "IPOrg";
2303
+ ResourceType["IPAsset"] = "IPAsset";
2304
+ ResourceType["License"] = "License";
2305
+ ResourceType["Relationship"] = "Relationship";
2306
+ ResourceType["RelationshipType"] = "RelationshipType";
2307
+ ResourceType["Module"] = "Module";
2308
+ ResourceType["Hook"] = "Hook";
2309
+ ResourceType["Dispute"] = "Dispute";
2310
+ return ResourceType;
2311
+ }({});
2312
+
2313
+ /**
2314
+ * @public
2315
+ */
2316
+ var ActionType = /*#__PURE__*/function (ActionType) {
2317
+ ActionType["Unspecified"] = "Unspecified";
2318
+ ActionType["Register"] = "Register";
2319
+ ActionType["Unregister"] = "Unregister";
2320
+ ActionType["Configure"] = "Configure";
2321
+ ActionType["Create"] = "Create";
2322
+ return ActionType;
2323
+ }({});
2324
+
2325
+ var AddressZero = "0x0000000000000000000000000000000000000000";
2326
+ var HashZero = "0x0000000000000000000000000000000000000000000000000000000000000000";
2327
+
2328
+ export { ActionType, AddressZero, HashZero, IPAssetClient, IPAssetReadOnlyClient, ModuleReadOnlyClient, PermissionClient, PermissionReadOnlyClient, PlatformClient, ResourceType, StoryClient, TaggingReadOnlyClient, TransactionClient };