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