@story-protocol/core-sdk 0.1.0-rc.1
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +0 -0
- package/dist/declarations/src/abi/generated/CollectModule.d.ts +70 -0
- package/dist/declarations/src/abi/generated/CollectModule.d.ts.map +1 -0
- package/dist/declarations/src/abi/generated/FranchiseRegistry.d.ts +73 -0
- package/dist/declarations/src/abi/generated/FranchiseRegistry.d.ts.map +1 -0
- package/dist/declarations/src/abi/generated/IpAssetRegistry.d.ts +94 -0
- package/dist/declarations/src/abi/generated/IpAssetRegistry.d.ts.map +1 -0
- package/dist/declarations/src/abi/generated/LicensingModule.d.ts +97 -0
- package/dist/declarations/src/abi/generated/LicensingModule.d.ts.map +1 -0
- package/dist/declarations/src/abi/generated/RelationshipModule.d.ts +116 -0
- package/dist/declarations/src/abi/generated/RelationshipModule.d.ts.map +1 -0
- package/dist/declarations/src/abi/generated/common.d.ts +22 -0
- package/dist/declarations/src/abi/generated/common.d.ts.map +1 -0
- package/dist/declarations/src/abi/generated/factories/CollectModule__factory.d.ts +52 -0
- package/dist/declarations/src/abi/generated/factories/CollectModule__factory.d.ts.map +1 -0
- package/dist/declarations/src/abi/generated/factories/FranchiseRegistry__factory.d.ts +58 -0
- package/dist/declarations/src/abi/generated/factories/FranchiseRegistry__factory.d.ts.map +1 -0
- package/dist/declarations/src/abi/generated/factories/IpAssetRegistry__factory.d.ts +112 -0
- package/dist/declarations/src/abi/generated/factories/IpAssetRegistry__factory.d.ts.map +1 -0
- package/dist/declarations/src/abi/generated/factories/LicensingModule__factory.d.ts +88 -0
- package/dist/declarations/src/abi/generated/factories/LicensingModule__factory.d.ts.map +1 -0
- package/dist/declarations/src/abi/generated/factories/RelationshipModule__factory.d.ts +175 -0
- package/dist/declarations/src/abi/generated/factories/RelationshipModule__factory.d.ts.map +1 -0
- package/dist/declarations/src/abi/generated/factories/index.d.ts +6 -0
- package/dist/declarations/src/abi/generated/factories/index.d.ts.map +1 -0
- package/dist/declarations/src/abi/generated/index.d.ts +12 -0
- package/dist/declarations/src/abi/generated/index.d.ts.map +1 -0
- package/dist/declarations/src/client.d.ts +67 -0
- package/dist/declarations/src/client.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 +13 -0
- package/dist/declarations/src/enums/ipAssetType.d.ts.map +1 -0
- package/dist/declarations/src/index.d.ts +5 -0
- package/dist/declarations/src/index.d.ts.map +1 -0
- package/dist/declarations/src/interfaces/config.d.ts +12 -0
- package/dist/declarations/src/interfaces/config.d.ts.map +1 -0
- package/dist/declarations/src/interfaces/resources/collect.d.ts +45 -0
- package/dist/declarations/src/interfaces/resources/collect.d.ts.map +1 -0
- package/dist/declarations/src/interfaces/resources/franchise.d.ts +70 -0
- package/dist/declarations/src/interfaces/resources/franchise.d.ts.map +1 -0
- package/dist/declarations/src/interfaces/resources/ipAsset.d.ts +70 -0
- package/dist/declarations/src/interfaces/resources/ipAsset.d.ts.map +1 -0
- package/dist/declarations/src/interfaces/resources/license.d.ts +78 -0
- package/dist/declarations/src/interfaces/resources/license.d.ts.map +1 -0
- package/dist/declarations/src/interfaces/resources/relationship.d.ts +83 -0
- package/dist/declarations/src/interfaces/resources/relationship.d.ts.map +1 -0
- package/dist/declarations/src/interfaces/resources/transaction.d.ts +46 -0
- package/dist/declarations/src/interfaces/resources/transaction.d.ts.map +1 -0
- package/dist/declarations/src/resources/collect.d.ts +24 -0
- package/dist/declarations/src/resources/collect.d.ts.map +1 -0
- package/dist/declarations/src/resources/franchise.d.ts +41 -0
- package/dist/declarations/src/resources/franchise.d.ts.map +1 -0
- package/dist/declarations/src/resources/ipAsset.d.ts +40 -0
- package/dist/declarations/src/resources/ipAsset.d.ts.map +1 -0
- package/dist/declarations/src/resources/license.d.ts +36 -0
- package/dist/declarations/src/resources/license.d.ts.map +1 -0
- package/dist/declarations/src/resources/relationship.d.ts +48 -0
- package/dist/declarations/src/resources/relationship.d.ts.map +1 -0
- package/dist/declarations/src/resources/transaction.d.ts +25 -0
- package/dist/declarations/src/resources/transaction.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 +2101 -0
- package/dist/story-protocol-core-sdk.cjs.js +7 -0
- package/dist/story-protocol-core-sdk.cjs.prod.js +2101 -0
- package/dist/story-protocol-core-sdk.esm.js +2073 -0
- package/package.json +88 -0
@@ -0,0 +1,2073 @@
|
|
1
|
+
import axios from 'axios';
|
2
|
+
import * as dotenv from 'dotenv';
|
3
|
+
import { constants, utils, Contract, ethers } from 'ethers';
|
4
|
+
|
5
|
+
function _classCallCheck(instance, Constructor) {
|
6
|
+
if (!(instance instanceof Constructor)) {
|
7
|
+
throw new TypeError("Cannot call a class as a function");
|
8
|
+
}
|
9
|
+
}
|
10
|
+
|
11
|
+
function _toPrimitive(input, hint) {
|
12
|
+
if (typeof input !== "object" || input === null) return input;
|
13
|
+
var prim = input[Symbol.toPrimitive];
|
14
|
+
if (prim !== undefined) {
|
15
|
+
var res = prim.call(input, hint || "default");
|
16
|
+
if (typeof res !== "object") return res;
|
17
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
18
|
+
}
|
19
|
+
return (hint === "string" ? String : Number)(input);
|
20
|
+
}
|
21
|
+
|
22
|
+
function _toPropertyKey(arg) {
|
23
|
+
var key = _toPrimitive(arg, "string");
|
24
|
+
return typeof key === "symbol" ? key : String(key);
|
25
|
+
}
|
26
|
+
|
27
|
+
function _defineProperties(target, props) {
|
28
|
+
for (var i = 0; i < props.length; i++) {
|
29
|
+
var descriptor = props[i];
|
30
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
31
|
+
descriptor.configurable = true;
|
32
|
+
if ("value" in descriptor) descriptor.writable = true;
|
33
|
+
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
34
|
+
}
|
35
|
+
}
|
36
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
37
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
38
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
39
|
+
Object.defineProperty(Constructor, "prototype", {
|
40
|
+
writable: false
|
41
|
+
});
|
42
|
+
return Constructor;
|
43
|
+
}
|
44
|
+
|
45
|
+
function _defineProperty(obj, key, value) {
|
46
|
+
key = _toPropertyKey(key);
|
47
|
+
if (key in obj) {
|
48
|
+
Object.defineProperty(obj, key, {
|
49
|
+
value: value,
|
50
|
+
enumerable: true,
|
51
|
+
configurable: true,
|
52
|
+
writable: true
|
53
|
+
});
|
54
|
+
} else {
|
55
|
+
obj[key] = value;
|
56
|
+
}
|
57
|
+
return obj;
|
58
|
+
}
|
59
|
+
|
60
|
+
/**
|
61
|
+
* @public
|
62
|
+
*/
|
63
|
+
var Environment = /*#__PURE__*/function (Environment) {
|
64
|
+
Environment["TEST"] = "TEST";
|
65
|
+
Environment["PROD"] = "PROD";
|
66
|
+
return Environment;
|
67
|
+
}({});
|
68
|
+
|
69
|
+
function _regeneratorRuntime() {
|
70
|
+
_regeneratorRuntime = function () {
|
71
|
+
return e;
|
72
|
+
};
|
73
|
+
var t,
|
74
|
+
e = {},
|
75
|
+
r = Object.prototype,
|
76
|
+
n = r.hasOwnProperty,
|
77
|
+
o = Object.defineProperty || function (t, e, r) {
|
78
|
+
t[e] = r.value;
|
79
|
+
},
|
80
|
+
i = "function" == typeof Symbol ? Symbol : {},
|
81
|
+
a = i.iterator || "@@iterator",
|
82
|
+
c = i.asyncIterator || "@@asyncIterator",
|
83
|
+
u = i.toStringTag || "@@toStringTag";
|
84
|
+
function define(t, e, r) {
|
85
|
+
return Object.defineProperty(t, e, {
|
86
|
+
value: r,
|
87
|
+
enumerable: !0,
|
88
|
+
configurable: !0,
|
89
|
+
writable: !0
|
90
|
+
}), t[e];
|
91
|
+
}
|
92
|
+
try {
|
93
|
+
define({}, "");
|
94
|
+
} catch (t) {
|
95
|
+
define = function (t, e, r) {
|
96
|
+
return t[e] = r;
|
97
|
+
};
|
98
|
+
}
|
99
|
+
function wrap(t, e, r, n) {
|
100
|
+
var i = e && e.prototype instanceof Generator ? e : Generator,
|
101
|
+
a = Object.create(i.prototype),
|
102
|
+
c = new Context(n || []);
|
103
|
+
return o(a, "_invoke", {
|
104
|
+
value: makeInvokeMethod(t, r, c)
|
105
|
+
}), a;
|
106
|
+
}
|
107
|
+
function tryCatch(t, e, r) {
|
108
|
+
try {
|
109
|
+
return {
|
110
|
+
type: "normal",
|
111
|
+
arg: t.call(e, r)
|
112
|
+
};
|
113
|
+
} catch (t) {
|
114
|
+
return {
|
115
|
+
type: "throw",
|
116
|
+
arg: t
|
117
|
+
};
|
118
|
+
}
|
119
|
+
}
|
120
|
+
e.wrap = wrap;
|
121
|
+
var h = "suspendedStart",
|
122
|
+
l = "suspendedYield",
|
123
|
+
f = "executing",
|
124
|
+
s = "completed",
|
125
|
+
y = {};
|
126
|
+
function Generator() {}
|
127
|
+
function GeneratorFunction() {}
|
128
|
+
function GeneratorFunctionPrototype() {}
|
129
|
+
var p = {};
|
130
|
+
define(p, a, function () {
|
131
|
+
return this;
|
132
|
+
});
|
133
|
+
var d = Object.getPrototypeOf,
|
134
|
+
v = d && d(d(values([])));
|
135
|
+
v && v !== r && n.call(v, a) && (p = v);
|
136
|
+
var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
|
137
|
+
function defineIteratorMethods(t) {
|
138
|
+
["next", "throw", "return"].forEach(function (e) {
|
139
|
+
define(t, e, function (t) {
|
140
|
+
return this._invoke(e, t);
|
141
|
+
});
|
142
|
+
});
|
143
|
+
}
|
144
|
+
function AsyncIterator(t, e) {
|
145
|
+
function invoke(r, o, i, a) {
|
146
|
+
var c = tryCatch(t[r], t, o);
|
147
|
+
if ("throw" !== c.type) {
|
148
|
+
var u = c.arg,
|
149
|
+
h = u.value;
|
150
|
+
return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
|
151
|
+
invoke("next", t, i, a);
|
152
|
+
}, function (t) {
|
153
|
+
invoke("throw", t, i, a);
|
154
|
+
}) : e.resolve(h).then(function (t) {
|
155
|
+
u.value = t, i(u);
|
156
|
+
}, function (t) {
|
157
|
+
return invoke("throw", t, i, a);
|
158
|
+
});
|
159
|
+
}
|
160
|
+
a(c.arg);
|
161
|
+
}
|
162
|
+
var r;
|
163
|
+
o(this, "_invoke", {
|
164
|
+
value: function (t, n) {
|
165
|
+
function callInvokeWithMethodAndArg() {
|
166
|
+
return new e(function (e, r) {
|
167
|
+
invoke(t, n, e, r);
|
168
|
+
});
|
169
|
+
}
|
170
|
+
return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
171
|
+
}
|
172
|
+
});
|
173
|
+
}
|
174
|
+
function makeInvokeMethod(e, r, n) {
|
175
|
+
var o = h;
|
176
|
+
return function (i, a) {
|
177
|
+
if (o === f) throw new Error("Generator is already running");
|
178
|
+
if (o === s) {
|
179
|
+
if ("throw" === i) throw a;
|
180
|
+
return {
|
181
|
+
value: t,
|
182
|
+
done: !0
|
183
|
+
};
|
184
|
+
}
|
185
|
+
for (n.method = i, n.arg = a;;) {
|
186
|
+
var c = n.delegate;
|
187
|
+
if (c) {
|
188
|
+
var u = maybeInvokeDelegate(c, n);
|
189
|
+
if (u) {
|
190
|
+
if (u === y) continue;
|
191
|
+
return u;
|
192
|
+
}
|
193
|
+
}
|
194
|
+
if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
|
195
|
+
if (o === h) throw o = s, n.arg;
|
196
|
+
n.dispatchException(n.arg);
|
197
|
+
} else "return" === n.method && n.abrupt("return", n.arg);
|
198
|
+
o = f;
|
199
|
+
var p = tryCatch(e, r, n);
|
200
|
+
if ("normal" === p.type) {
|
201
|
+
if (o = n.done ? s : l, p.arg === y) continue;
|
202
|
+
return {
|
203
|
+
value: p.arg,
|
204
|
+
done: n.done
|
205
|
+
};
|
206
|
+
}
|
207
|
+
"throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
|
208
|
+
}
|
209
|
+
};
|
210
|
+
}
|
211
|
+
function maybeInvokeDelegate(e, r) {
|
212
|
+
var n = r.method,
|
213
|
+
o = e.iterator[n];
|
214
|
+
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;
|
215
|
+
var i = tryCatch(o, e.iterator, r.arg);
|
216
|
+
if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
|
217
|
+
var a = i.arg;
|
218
|
+
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);
|
219
|
+
}
|
220
|
+
function pushTryEntry(t) {
|
221
|
+
var e = {
|
222
|
+
tryLoc: t[0]
|
223
|
+
};
|
224
|
+
1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
|
225
|
+
}
|
226
|
+
function resetTryEntry(t) {
|
227
|
+
var e = t.completion || {};
|
228
|
+
e.type = "normal", delete e.arg, t.completion = e;
|
229
|
+
}
|
230
|
+
function Context(t) {
|
231
|
+
this.tryEntries = [{
|
232
|
+
tryLoc: "root"
|
233
|
+
}], t.forEach(pushTryEntry, this), this.reset(!0);
|
234
|
+
}
|
235
|
+
function values(e) {
|
236
|
+
if (e || "" === e) {
|
237
|
+
var r = e[a];
|
238
|
+
if (r) return r.call(e);
|
239
|
+
if ("function" == typeof e.next) return e;
|
240
|
+
if (!isNaN(e.length)) {
|
241
|
+
var o = -1,
|
242
|
+
i = function next() {
|
243
|
+
for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
|
244
|
+
return next.value = t, next.done = !0, next;
|
245
|
+
};
|
246
|
+
return i.next = i;
|
247
|
+
}
|
248
|
+
}
|
249
|
+
throw new TypeError(typeof e + " is not iterable");
|
250
|
+
}
|
251
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
|
252
|
+
value: GeneratorFunctionPrototype,
|
253
|
+
configurable: !0
|
254
|
+
}), o(GeneratorFunctionPrototype, "constructor", {
|
255
|
+
value: GeneratorFunction,
|
256
|
+
configurable: !0
|
257
|
+
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
|
258
|
+
var e = "function" == typeof t && t.constructor;
|
259
|
+
return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
|
260
|
+
}, e.mark = function (t) {
|
261
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
|
262
|
+
}, e.awrap = function (t) {
|
263
|
+
return {
|
264
|
+
__await: t
|
265
|
+
};
|
266
|
+
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
|
267
|
+
return this;
|
268
|
+
}), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
|
269
|
+
void 0 === i && (i = Promise);
|
270
|
+
var a = new AsyncIterator(wrap(t, r, n, o), i);
|
271
|
+
return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
|
272
|
+
return t.done ? t.value : a.next();
|
273
|
+
});
|
274
|
+
}, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
|
275
|
+
return this;
|
276
|
+
}), define(g, "toString", function () {
|
277
|
+
return "[object Generator]";
|
278
|
+
}), e.keys = function (t) {
|
279
|
+
var e = Object(t),
|
280
|
+
r = [];
|
281
|
+
for (var n in e) r.push(n);
|
282
|
+
return r.reverse(), function next() {
|
283
|
+
for (; r.length;) {
|
284
|
+
var t = r.pop();
|
285
|
+
if (t in e) return next.value = t, next.done = !1, next;
|
286
|
+
}
|
287
|
+
return next.done = !0, next;
|
288
|
+
};
|
289
|
+
}, e.values = values, Context.prototype = {
|
290
|
+
constructor: Context,
|
291
|
+
reset: function (e) {
|
292
|
+
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);
|
293
|
+
},
|
294
|
+
stop: function () {
|
295
|
+
this.done = !0;
|
296
|
+
var t = this.tryEntries[0].completion;
|
297
|
+
if ("throw" === t.type) throw t.arg;
|
298
|
+
return this.rval;
|
299
|
+
},
|
300
|
+
dispatchException: function (e) {
|
301
|
+
if (this.done) throw e;
|
302
|
+
var r = this;
|
303
|
+
function handle(n, o) {
|
304
|
+
return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
|
305
|
+
}
|
306
|
+
for (var o = this.tryEntries.length - 1; o >= 0; --o) {
|
307
|
+
var i = this.tryEntries[o],
|
308
|
+
a = i.completion;
|
309
|
+
if ("root" === i.tryLoc) return handle("end");
|
310
|
+
if (i.tryLoc <= this.prev) {
|
311
|
+
var c = n.call(i, "catchLoc"),
|
312
|
+
u = n.call(i, "finallyLoc");
|
313
|
+
if (c && u) {
|
314
|
+
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
315
|
+
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
316
|
+
} else if (c) {
|
317
|
+
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
318
|
+
} else {
|
319
|
+
if (!u) throw new Error("try statement without catch or finally");
|
320
|
+
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
321
|
+
}
|
322
|
+
}
|
323
|
+
}
|
324
|
+
},
|
325
|
+
abrupt: function (t, e) {
|
326
|
+
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
|
327
|
+
var o = this.tryEntries[r];
|
328
|
+
if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
|
329
|
+
var i = o;
|
330
|
+
break;
|
331
|
+
}
|
332
|
+
}
|
333
|
+
i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
|
334
|
+
var a = i ? i.completion : {};
|
335
|
+
return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
|
336
|
+
},
|
337
|
+
complete: function (t, e) {
|
338
|
+
if ("throw" === t.type) throw t.arg;
|
339
|
+
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;
|
340
|
+
},
|
341
|
+
finish: function (t) {
|
342
|
+
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
343
|
+
var r = this.tryEntries[e];
|
344
|
+
if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
|
345
|
+
}
|
346
|
+
},
|
347
|
+
catch: function (t) {
|
348
|
+
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
349
|
+
var r = this.tryEntries[e];
|
350
|
+
if (r.tryLoc === t) {
|
351
|
+
var n = r.completion;
|
352
|
+
if ("throw" === n.type) {
|
353
|
+
var o = n.arg;
|
354
|
+
resetTryEntry(r);
|
355
|
+
}
|
356
|
+
return o;
|
357
|
+
}
|
358
|
+
}
|
359
|
+
throw new Error("illegal catch attempt");
|
360
|
+
},
|
361
|
+
delegateYield: function (e, r, n) {
|
362
|
+
return this.delegate = {
|
363
|
+
iterator: values(e),
|
364
|
+
resultName: r,
|
365
|
+
nextLoc: n
|
366
|
+
}, "next" === this.method && (this.arg = t), y;
|
367
|
+
}
|
368
|
+
}, e;
|
369
|
+
}
|
370
|
+
|
371
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
372
|
+
try {
|
373
|
+
var info = gen[key](arg);
|
374
|
+
var value = info.value;
|
375
|
+
} catch (error) {
|
376
|
+
reject(error);
|
377
|
+
return;
|
378
|
+
}
|
379
|
+
if (info.done) {
|
380
|
+
resolve(value);
|
381
|
+
} else {
|
382
|
+
Promise.resolve(value).then(_next, _throw);
|
383
|
+
}
|
384
|
+
}
|
385
|
+
function _asyncToGenerator(fn) {
|
386
|
+
return function () {
|
387
|
+
var self = this,
|
388
|
+
args = arguments;
|
389
|
+
return new Promise(function (resolve, reject) {
|
390
|
+
var gen = fn.apply(self, args);
|
391
|
+
function _next(value) {
|
392
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
393
|
+
}
|
394
|
+
function _throw(err) {
|
395
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
396
|
+
}
|
397
|
+
_next(undefined);
|
398
|
+
});
|
399
|
+
};
|
400
|
+
}
|
401
|
+
|
402
|
+
function handleError(error, msg) {
|
403
|
+
if (error instanceof Error) {
|
404
|
+
throw new Error("".concat(msg, ": ").concat(error.message));
|
405
|
+
}
|
406
|
+
throw new Error("".concat(msg, ": Unknown error type"));
|
407
|
+
}
|
408
|
+
|
409
|
+
function isIntegerString(s) {
|
410
|
+
var num = Number(s);
|
411
|
+
return !isNaN(num) && parseInt(s, 10) === num;
|
412
|
+
}
|
413
|
+
|
414
|
+
/**
|
415
|
+
* FranchiseClient allows you to create, update, view, search franchises on
|
416
|
+
* Story Protocol.
|
417
|
+
*/
|
418
|
+
var FranchiseClient = /*#__PURE__*/function () {
|
419
|
+
function FranchiseClient(httpClient, franchiseRegistry, licenseModule) {
|
420
|
+
_classCallCheck(this, FranchiseClient);
|
421
|
+
this.httpClient = httpClient;
|
422
|
+
this.franchiseRegistry = franchiseRegistry;
|
423
|
+
this.licenseModule = licenseModule;
|
424
|
+
}
|
425
|
+
|
426
|
+
/**
|
427
|
+
* Get a franchise data based on the specified franchise id.
|
428
|
+
*
|
429
|
+
* @param request - the request object for getting the franchise
|
430
|
+
* @returns the response object that contains the fetched franchise object
|
431
|
+
*/
|
432
|
+
_createClass(FranchiseClient, [{
|
433
|
+
key: "get",
|
434
|
+
value: function () {
|
435
|
+
var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
|
436
|
+
var response;
|
437
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
438
|
+
while (1) switch (_context.prev = _context.next) {
|
439
|
+
case 0:
|
440
|
+
_context.prev = 0;
|
441
|
+
if (isIntegerString(request.franchiseId)) {
|
442
|
+
_context.next = 3;
|
443
|
+
break;
|
444
|
+
}
|
445
|
+
throw new Error("Invalid franchise id. Must be an integer. But got: ".concat(request.franchiseId));
|
446
|
+
case 3:
|
447
|
+
_context.next = 5;
|
448
|
+
return this.httpClient.get("/franchise/".concat(request.franchiseId));
|
449
|
+
case 5:
|
450
|
+
response = _context.sent;
|
451
|
+
return _context.abrupt("return", response.data);
|
452
|
+
case 9:
|
453
|
+
_context.prev = 9;
|
454
|
+
_context.t0 = _context["catch"](0);
|
455
|
+
handleError(_context.t0, "Failed to get franchise");
|
456
|
+
case 12:
|
457
|
+
case "end":
|
458
|
+
return _context.stop();
|
459
|
+
}
|
460
|
+
}, _callee, this, [[0, 9]]);
|
461
|
+
}));
|
462
|
+
function get(_x) {
|
463
|
+
return _get.apply(this, arguments);
|
464
|
+
}
|
465
|
+
return get;
|
466
|
+
}()
|
467
|
+
/**
|
468
|
+
* List all franchises.
|
469
|
+
*
|
470
|
+
* @returns the response object that contains a list of franchises
|
471
|
+
*/
|
472
|
+
}, {
|
473
|
+
key: "list",
|
474
|
+
value: function () {
|
475
|
+
var _list = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
476
|
+
var response;
|
477
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
478
|
+
while (1) switch (_context2.prev = _context2.next) {
|
479
|
+
case 0:
|
480
|
+
_context2.prev = 0;
|
481
|
+
_context2.next = 3;
|
482
|
+
return this.httpClient.get("/franchise");
|
483
|
+
case 3:
|
484
|
+
response = _context2.sent;
|
485
|
+
return _context2.abrupt("return", response.data);
|
486
|
+
case 7:
|
487
|
+
_context2.prev = 7;
|
488
|
+
_context2.t0 = _context2["catch"](0);
|
489
|
+
handleError(_context2.t0, "Failed to list franchises.");
|
490
|
+
case 10:
|
491
|
+
case "end":
|
492
|
+
return _context2.stop();
|
493
|
+
}
|
494
|
+
}, _callee2, this, [[0, 7]]);
|
495
|
+
}));
|
496
|
+
function list() {
|
497
|
+
return _list.apply(this, arguments);
|
498
|
+
}
|
499
|
+
return list;
|
500
|
+
}()
|
501
|
+
/**
|
502
|
+
* Create a franchise on Story Protocol based on the specified input franchise data.
|
503
|
+
*
|
504
|
+
* @param request - the request object that contains all data needed to create a franchise
|
505
|
+
* @returns the response object that contains results from the create franchise action
|
506
|
+
*/
|
507
|
+
}, {
|
508
|
+
key: "create",
|
509
|
+
value: function () {
|
510
|
+
var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(request) {
|
511
|
+
var tokenURI, response;
|
512
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
513
|
+
while (1) switch (_context3.prev = _context3.next) {
|
514
|
+
case 0:
|
515
|
+
_context3.prev = 0;
|
516
|
+
// hardcoded the URI for now until the backend API for uploading franchise metadata is ready
|
517
|
+
tokenURI = "https://arweave.net/dnFJl1v8kgOx_6Z0gEsBce3D56cMP4-lxAcFqSsL0_w";
|
518
|
+
_context3.next = 4;
|
519
|
+
return this.franchiseRegistry.registerFranchise({
|
520
|
+
name: request.franchiseName,
|
521
|
+
symbol: request.franchiseSymbol,
|
522
|
+
description: request.franchiseDescription,
|
523
|
+
tokenURI: tokenURI
|
524
|
+
});
|
525
|
+
case 4:
|
526
|
+
response = _context3.sent;
|
527
|
+
return _context3.abrupt("return", {
|
528
|
+
txHash: response.hash
|
529
|
+
});
|
530
|
+
case 8:
|
531
|
+
_context3.prev = 8;
|
532
|
+
_context3.t0 = _context3["catch"](0);
|
533
|
+
handleError(_context3.t0, "Failed to create franchise");
|
534
|
+
case 11:
|
535
|
+
case "end":
|
536
|
+
return _context3.stop();
|
537
|
+
}
|
538
|
+
}, _callee3, this, [[0, 8]]);
|
539
|
+
}));
|
540
|
+
function create(_x2) {
|
541
|
+
return _create.apply(this, arguments);
|
542
|
+
}
|
543
|
+
return create;
|
544
|
+
}()
|
545
|
+
/**
|
546
|
+
* Configure a franchise on Story Protocol.
|
547
|
+
*
|
548
|
+
* @param request - the request object that contains all data needed to configure a franchise
|
549
|
+
* @returns the response object that contains results from the configure franchise action
|
550
|
+
*/
|
551
|
+
}, {
|
552
|
+
key: "configure",
|
553
|
+
value: function () {
|
554
|
+
var _configure = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(request) {
|
555
|
+
var response;
|
556
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
557
|
+
while (1) switch (_context4.prev = _context4.next) {
|
558
|
+
case 0:
|
559
|
+
_context4.prev = 0;
|
560
|
+
_context4.next = 3;
|
561
|
+
return this.licenseModule.configureFranchiseLicensing(request.franchiseId, {
|
562
|
+
nonCommercialConfig: {
|
563
|
+
canSublicense: true,
|
564
|
+
franchiseRootLicenseId: 0
|
565
|
+
},
|
566
|
+
nonCommercialTerms: {
|
567
|
+
processor: constants.AddressZero,
|
568
|
+
data: []
|
569
|
+
},
|
570
|
+
commercialConfig: {
|
571
|
+
canSublicense: false,
|
572
|
+
franchiseRootLicenseId: 0
|
573
|
+
},
|
574
|
+
commercialTerms: {
|
575
|
+
processor: constants.AddressZero,
|
576
|
+
data: []
|
577
|
+
},
|
578
|
+
commercialLicenseUri: "aaaa",
|
579
|
+
rootIpAssetHasCommercialRights: false,
|
580
|
+
revoker: "0xF33f05489d9708C2CA97944F2007d4E741D4DEe7"
|
581
|
+
});
|
582
|
+
case 3:
|
583
|
+
response = _context4.sent;
|
584
|
+
return _context4.abrupt("return", {
|
585
|
+
txHash: response.hash
|
586
|
+
});
|
587
|
+
case 7:
|
588
|
+
_context4.prev = 7;
|
589
|
+
_context4.t0 = _context4["catch"](0);
|
590
|
+
handleError(_context4.t0, "Failed to configure franchise");
|
591
|
+
case 10:
|
592
|
+
case "end":
|
593
|
+
return _context4.stop();
|
594
|
+
}
|
595
|
+
}, _callee4, this, [[0, 7]]);
|
596
|
+
}));
|
597
|
+
function configure(_x3) {
|
598
|
+
return _configure.apply(this, arguments);
|
599
|
+
}
|
600
|
+
return configure;
|
601
|
+
}()
|
602
|
+
}]);
|
603
|
+
return FranchiseClient;
|
604
|
+
}();
|
605
|
+
|
606
|
+
var _abi$4 = [{
|
607
|
+
inputs: [{
|
608
|
+
internalType: "uint256",
|
609
|
+
name: "franchiseId",
|
610
|
+
type: "uint256"
|
611
|
+
}, {
|
612
|
+
components: [{
|
613
|
+
components: [{
|
614
|
+
internalType: "bool",
|
615
|
+
name: "canSublicense",
|
616
|
+
type: "bool"
|
617
|
+
}, {
|
618
|
+
internalType: "uint256",
|
619
|
+
name: "franchiseRootLicenseId",
|
620
|
+
type: "uint256"
|
621
|
+
}],
|
622
|
+
internalType: "struct ILicensingModule.IpAssetConfig",
|
623
|
+
name: "nonCommercialConfig",
|
624
|
+
type: "tuple"
|
625
|
+
}, {
|
626
|
+
components: [{
|
627
|
+
internalType: "contract ITermsProcessor",
|
628
|
+
name: "processor",
|
629
|
+
type: "address"
|
630
|
+
}, {
|
631
|
+
internalType: "bytes",
|
632
|
+
name: "data",
|
633
|
+
type: "bytes"
|
634
|
+
}],
|
635
|
+
internalType: "struct IERC5218.TermsProcessorConfig",
|
636
|
+
name: "nonCommercialTerms",
|
637
|
+
type: "tuple"
|
638
|
+
}, {
|
639
|
+
components: [{
|
640
|
+
internalType: "bool",
|
641
|
+
name: "canSublicense",
|
642
|
+
type: "bool"
|
643
|
+
}, {
|
644
|
+
internalType: "uint256",
|
645
|
+
name: "franchiseRootLicenseId",
|
646
|
+
type: "uint256"
|
647
|
+
}],
|
648
|
+
internalType: "struct ILicensingModule.IpAssetConfig",
|
649
|
+
name: "commercialConfig",
|
650
|
+
type: "tuple"
|
651
|
+
}, {
|
652
|
+
components: [{
|
653
|
+
internalType: "contract ITermsProcessor",
|
654
|
+
name: "processor",
|
655
|
+
type: "address"
|
656
|
+
}, {
|
657
|
+
internalType: "bytes",
|
658
|
+
name: "data",
|
659
|
+
type: "bytes"
|
660
|
+
}],
|
661
|
+
internalType: "struct IERC5218.TermsProcessorConfig",
|
662
|
+
name: "commercialTerms",
|
663
|
+
type: "tuple"
|
664
|
+
}, {
|
665
|
+
internalType: "bool",
|
666
|
+
name: "rootIpAssetHasCommercialRights",
|
667
|
+
type: "bool"
|
668
|
+
}, {
|
669
|
+
internalType: "address",
|
670
|
+
name: "revoker",
|
671
|
+
type: "address"
|
672
|
+
}, {
|
673
|
+
internalType: "string",
|
674
|
+
name: "commercialLicenseUri",
|
675
|
+
type: "string"
|
676
|
+
}],
|
677
|
+
internalType: "struct ILicensingModule.FranchiseConfig",
|
678
|
+
name: "config",
|
679
|
+
type: "tuple"
|
680
|
+
}],
|
681
|
+
name: "configureFranchiseLicensing",
|
682
|
+
outputs: [],
|
683
|
+
stateMutability: "nonpayable",
|
684
|
+
type: "function"
|
685
|
+
}];
|
686
|
+
var LicensingModule__factory = /*#__PURE__*/function () {
|
687
|
+
function LicensingModule__factory() {
|
688
|
+
_classCallCheck(this, LicensingModule__factory);
|
689
|
+
}
|
690
|
+
_createClass(LicensingModule__factory, null, [{
|
691
|
+
key: "createInterface",
|
692
|
+
value: function createInterface() {
|
693
|
+
return new utils.Interface(_abi$4);
|
694
|
+
}
|
695
|
+
}, {
|
696
|
+
key: "connect",
|
697
|
+
value: function connect(address, signerOrProvider) {
|
698
|
+
return new Contract(address, _abi$4, signerOrProvider);
|
699
|
+
}
|
700
|
+
}]);
|
701
|
+
return LicensingModule__factory;
|
702
|
+
}();
|
703
|
+
_defineProperty(LicensingModule__factory, "abi", _abi$4);
|
704
|
+
|
705
|
+
var _abi$3 = [{
|
706
|
+
inputs: [{
|
707
|
+
components: [{
|
708
|
+
internalType: "string",
|
709
|
+
name: "name",
|
710
|
+
type: "string"
|
711
|
+
}, {
|
712
|
+
internalType: "string",
|
713
|
+
name: "symbol",
|
714
|
+
type: "string"
|
715
|
+
}, {
|
716
|
+
internalType: "string",
|
717
|
+
name: "description",
|
718
|
+
type: "string"
|
719
|
+
}, {
|
720
|
+
internalType: "string",
|
721
|
+
name: "tokenURI",
|
722
|
+
type: "string"
|
723
|
+
}],
|
724
|
+
internalType: "struct FranchiseRegistry.FranchiseCreationParams",
|
725
|
+
name: "params",
|
726
|
+
type: "tuple"
|
727
|
+
}],
|
728
|
+
name: "registerFranchise",
|
729
|
+
outputs: [{
|
730
|
+
internalType: "uint256",
|
731
|
+
name: "",
|
732
|
+
type: "uint256"
|
733
|
+
}, {
|
734
|
+
internalType: "address",
|
735
|
+
name: "",
|
736
|
+
type: "address"
|
737
|
+
}],
|
738
|
+
stateMutability: "nonpayable",
|
739
|
+
type: "function"
|
740
|
+
}, {
|
741
|
+
inputs: [{
|
742
|
+
internalType: "uint256",
|
743
|
+
name: "franchiseId",
|
744
|
+
type: "uint256"
|
745
|
+
}],
|
746
|
+
name: "ipAssetRegistryForId",
|
747
|
+
outputs: [{
|
748
|
+
internalType: "address",
|
749
|
+
name: "",
|
750
|
+
type: "address"
|
751
|
+
}],
|
752
|
+
stateMutability: "view",
|
753
|
+
type: "function"
|
754
|
+
}];
|
755
|
+
var FranchiseRegistry__factory = /*#__PURE__*/function () {
|
756
|
+
function FranchiseRegistry__factory() {
|
757
|
+
_classCallCheck(this, FranchiseRegistry__factory);
|
758
|
+
}
|
759
|
+
_createClass(FranchiseRegistry__factory, null, [{
|
760
|
+
key: "createInterface",
|
761
|
+
value: function createInterface() {
|
762
|
+
return new utils.Interface(_abi$3);
|
763
|
+
}
|
764
|
+
}, {
|
765
|
+
key: "connect",
|
766
|
+
value: function connect(address, signerOrProvider) {
|
767
|
+
return new Contract(address, _abi$3, signerOrProvider);
|
768
|
+
}
|
769
|
+
}]);
|
770
|
+
return FranchiseRegistry__factory;
|
771
|
+
}();
|
772
|
+
_defineProperty(FranchiseRegistry__factory, "abi", _abi$3);
|
773
|
+
|
774
|
+
var _abi$2 = [{
|
775
|
+
inputs: [{
|
776
|
+
components: [{
|
777
|
+
internalType: "uint256",
|
778
|
+
name: "franchiseId",
|
779
|
+
type: "uint256"
|
780
|
+
}, {
|
781
|
+
internalType: "uint256",
|
782
|
+
name: "ipAssetId",
|
783
|
+
type: "uint256"
|
784
|
+
}, {
|
785
|
+
internalType: "address",
|
786
|
+
name: "collector",
|
787
|
+
type: "address"
|
788
|
+
}, {
|
789
|
+
internalType: "bytes",
|
790
|
+
name: "collectData",
|
791
|
+
type: "bytes"
|
792
|
+
}, {
|
793
|
+
internalType: "bytes",
|
794
|
+
name: "collectNFTInitData",
|
795
|
+
type: "bytes"
|
796
|
+
}, {
|
797
|
+
internalType: "bytes",
|
798
|
+
name: "collectNFTData",
|
799
|
+
type: "bytes"
|
800
|
+
}],
|
801
|
+
internalType: "struct CollectParams",
|
802
|
+
name: "collectParams",
|
803
|
+
type: "tuple"
|
804
|
+
}],
|
805
|
+
name: "collect",
|
806
|
+
outputs: [{
|
807
|
+
internalType: "address",
|
808
|
+
name: "collectNFT",
|
809
|
+
type: "address"
|
810
|
+
}, {
|
811
|
+
internalType: "uint256",
|
812
|
+
name: "collectNFTId",
|
813
|
+
type: "uint256"
|
814
|
+
}],
|
815
|
+
stateMutability: "nonpayable",
|
816
|
+
type: "function"
|
817
|
+
}];
|
818
|
+
var CollectModule__factory = /*#__PURE__*/function () {
|
819
|
+
function CollectModule__factory() {
|
820
|
+
_classCallCheck(this, CollectModule__factory);
|
821
|
+
}
|
822
|
+
_createClass(CollectModule__factory, null, [{
|
823
|
+
key: "createInterface",
|
824
|
+
value: function createInterface() {
|
825
|
+
return new utils.Interface(_abi$2);
|
826
|
+
}
|
827
|
+
}, {
|
828
|
+
key: "connect",
|
829
|
+
value: function connect(address, signerOrProvider) {
|
830
|
+
return new Contract(address, _abi$2, signerOrProvider);
|
831
|
+
}
|
832
|
+
}]);
|
833
|
+
return CollectModule__factory;
|
834
|
+
}();
|
835
|
+
_defineProperty(CollectModule__factory, "abi", _abi$2);
|
836
|
+
|
837
|
+
var _abi$1 = [{
|
838
|
+
inputs: [{
|
839
|
+
internalType: "enum IPAsset",
|
840
|
+
name: "ipAssetType",
|
841
|
+
type: "uint8"
|
842
|
+
}, {
|
843
|
+
internalType: "string",
|
844
|
+
name: "name",
|
845
|
+
type: "string"
|
846
|
+
}, {
|
847
|
+
internalType: "string",
|
848
|
+
name: "_description",
|
849
|
+
type: "string"
|
850
|
+
}, {
|
851
|
+
internalType: "string",
|
852
|
+
name: "mediaUrl",
|
853
|
+
type: "string"
|
854
|
+
}, {
|
855
|
+
internalType: "address",
|
856
|
+
name: "to",
|
857
|
+
type: "address"
|
858
|
+
}, {
|
859
|
+
internalType: "uint256",
|
860
|
+
name: "parentIpAssetId",
|
861
|
+
type: "uint256"
|
862
|
+
}],
|
863
|
+
name: "createIPAsset",
|
864
|
+
outputs: [{
|
865
|
+
internalType: "uint256",
|
866
|
+
name: "",
|
867
|
+
type: "uint256"
|
868
|
+
}],
|
869
|
+
stateMutability: "nonpayable",
|
870
|
+
type: "function"
|
871
|
+
}, {
|
872
|
+
inputs: [{
|
873
|
+
internalType: "uint256",
|
874
|
+
name: "_tokenId",
|
875
|
+
type: "uint256"
|
876
|
+
}, {
|
877
|
+
internalType: "uint256",
|
878
|
+
name: "_parentLicenseId",
|
879
|
+
type: "uint256"
|
880
|
+
}, {
|
881
|
+
internalType: "address",
|
882
|
+
name: "_licenseHolder",
|
883
|
+
type: "address"
|
884
|
+
}, {
|
885
|
+
internalType: "string",
|
886
|
+
name: "_uri",
|
887
|
+
type: "string"
|
888
|
+
}, {
|
889
|
+
internalType: "address",
|
890
|
+
name: "_revoker",
|
891
|
+
type: "address"
|
892
|
+
}, {
|
893
|
+
internalType: "bool",
|
894
|
+
name: "_commercial",
|
895
|
+
type: "bool"
|
896
|
+
}, {
|
897
|
+
internalType: "bool",
|
898
|
+
name: "_canSublicense",
|
899
|
+
type: "bool"
|
900
|
+
}, {
|
901
|
+
components: [{
|
902
|
+
internalType: "contract ITermsProcessor",
|
903
|
+
name: "processor",
|
904
|
+
type: "address"
|
905
|
+
}, {
|
906
|
+
internalType: "bytes",
|
907
|
+
name: "data",
|
908
|
+
type: "bytes"
|
909
|
+
}],
|
910
|
+
internalType: "struct IERC5218.TermsProcessorConfig",
|
911
|
+
name: "_terms",
|
912
|
+
type: "tuple"
|
913
|
+
}],
|
914
|
+
name: "createLicense",
|
915
|
+
outputs: [{
|
916
|
+
internalType: "uint256",
|
917
|
+
name: "",
|
918
|
+
type: "uint256"
|
919
|
+
}],
|
920
|
+
stateMutability: "nonpayable",
|
921
|
+
type: "function"
|
922
|
+
}, {
|
923
|
+
inputs: [{
|
924
|
+
internalType: "uint256",
|
925
|
+
name: "_tokenId",
|
926
|
+
type: "uint256"
|
927
|
+
}, {
|
928
|
+
internalType: "bool",
|
929
|
+
name: "_commercial",
|
930
|
+
type: "bool"
|
931
|
+
}],
|
932
|
+
name: "getLicenseIdByTokenId",
|
933
|
+
outputs: [{
|
934
|
+
internalType: "uint256",
|
935
|
+
name: "",
|
936
|
+
type: "uint256"
|
937
|
+
}],
|
938
|
+
stateMutability: "view",
|
939
|
+
type: "function"
|
940
|
+
}];
|
941
|
+
var IpAssetRegistry__factory = /*#__PURE__*/function () {
|
942
|
+
function IpAssetRegistry__factory() {
|
943
|
+
_classCallCheck(this, IpAssetRegistry__factory);
|
944
|
+
}
|
945
|
+
_createClass(IpAssetRegistry__factory, null, [{
|
946
|
+
key: "createInterface",
|
947
|
+
value: function createInterface() {
|
948
|
+
return new utils.Interface(_abi$1);
|
949
|
+
}
|
950
|
+
}, {
|
951
|
+
key: "connect",
|
952
|
+
value: function connect(address, signerOrProvider) {
|
953
|
+
return new Contract(address, _abi$1, signerOrProvider);
|
954
|
+
}
|
955
|
+
}]);
|
956
|
+
return IpAssetRegistry__factory;
|
957
|
+
}();
|
958
|
+
_defineProperty(IpAssetRegistry__factory, "abi", _abi$1);
|
959
|
+
|
960
|
+
var _abi = [{
|
961
|
+
inputs: [{
|
962
|
+
components: [{
|
963
|
+
internalType: "address",
|
964
|
+
name: "sourceContract",
|
965
|
+
type: "address"
|
966
|
+
}, {
|
967
|
+
internalType: "uint256",
|
968
|
+
name: "sourceId",
|
969
|
+
type: "uint256"
|
970
|
+
}, {
|
971
|
+
internalType: "address",
|
972
|
+
name: "destContract",
|
973
|
+
type: "address"
|
974
|
+
}, {
|
975
|
+
internalType: "uint256",
|
976
|
+
name: "destId",
|
977
|
+
type: "uint256"
|
978
|
+
}, {
|
979
|
+
internalType: "bytes32",
|
980
|
+
name: "relationshipId",
|
981
|
+
type: "bytes32"
|
982
|
+
}, {
|
983
|
+
internalType: "uint256",
|
984
|
+
name: "ttl",
|
985
|
+
type: "uint256"
|
986
|
+
}],
|
987
|
+
internalType: "struct IRelationshipModule.RelationshipParams",
|
988
|
+
name: "params",
|
989
|
+
type: "tuple"
|
990
|
+
}, {
|
991
|
+
internalType: "bytes",
|
992
|
+
name: "data",
|
993
|
+
type: "bytes"
|
994
|
+
}],
|
995
|
+
name: "relate",
|
996
|
+
outputs: [],
|
997
|
+
stateMutability: "nonpayable",
|
998
|
+
type: "function"
|
999
|
+
}, {
|
1000
|
+
inputs: [{
|
1001
|
+
components: [{
|
1002
|
+
internalType: "address",
|
1003
|
+
name: "sourceContract",
|
1004
|
+
type: "address"
|
1005
|
+
}, {
|
1006
|
+
internalType: "uint256",
|
1007
|
+
name: "sourceId",
|
1008
|
+
type: "uint256"
|
1009
|
+
}, {
|
1010
|
+
internalType: "address",
|
1011
|
+
name: "destContract",
|
1012
|
+
type: "address"
|
1013
|
+
}, {
|
1014
|
+
internalType: "uint256",
|
1015
|
+
name: "destId",
|
1016
|
+
type: "uint256"
|
1017
|
+
}, {
|
1018
|
+
internalType: "bytes32",
|
1019
|
+
name: "relationshipId",
|
1020
|
+
type: "bytes32"
|
1021
|
+
}, {
|
1022
|
+
internalType: "uint256",
|
1023
|
+
name: "ttl",
|
1024
|
+
type: "uint256"
|
1025
|
+
}],
|
1026
|
+
internalType: "struct IRelationshipModule.RelationshipParams",
|
1027
|
+
name: "params",
|
1028
|
+
type: "tuple"
|
1029
|
+
}],
|
1030
|
+
name: "unrelate",
|
1031
|
+
outputs: [],
|
1032
|
+
stateMutability: "nonpayable",
|
1033
|
+
type: "function"
|
1034
|
+
}, {
|
1035
|
+
inputs: [{
|
1036
|
+
components: [{
|
1037
|
+
internalType: "address",
|
1038
|
+
name: "sourceContract",
|
1039
|
+
type: "address"
|
1040
|
+
}, {
|
1041
|
+
internalType: "uint256",
|
1042
|
+
name: "sourceId",
|
1043
|
+
type: "uint256"
|
1044
|
+
}, {
|
1045
|
+
internalType: "address",
|
1046
|
+
name: "destContract",
|
1047
|
+
type: "address"
|
1048
|
+
}, {
|
1049
|
+
internalType: "uint256",
|
1050
|
+
name: "destId",
|
1051
|
+
type: "uint256"
|
1052
|
+
}, {
|
1053
|
+
internalType: "bytes32",
|
1054
|
+
name: "relationshipId",
|
1055
|
+
type: "bytes32"
|
1056
|
+
}, {
|
1057
|
+
internalType: "uint256",
|
1058
|
+
name: "ttl",
|
1059
|
+
type: "uint256"
|
1060
|
+
}],
|
1061
|
+
internalType: "struct IRelationshipModule.RelationshipParams",
|
1062
|
+
name: "params",
|
1063
|
+
type: "tuple"
|
1064
|
+
}],
|
1065
|
+
name: "isRelationshipExpired",
|
1066
|
+
outputs: [{
|
1067
|
+
internalType: "bool",
|
1068
|
+
name: "",
|
1069
|
+
type: "bool"
|
1070
|
+
}],
|
1071
|
+
stateMutability: "view",
|
1072
|
+
type: "function"
|
1073
|
+
}, {
|
1074
|
+
inputs: [{
|
1075
|
+
components: [{
|
1076
|
+
internalType: "address",
|
1077
|
+
name: "sourceContract",
|
1078
|
+
type: "address"
|
1079
|
+
}, {
|
1080
|
+
internalType: "uint256",
|
1081
|
+
name: "sourceId",
|
1082
|
+
type: "uint256"
|
1083
|
+
}, {
|
1084
|
+
internalType: "address",
|
1085
|
+
name: "destContract",
|
1086
|
+
type: "address"
|
1087
|
+
}, {
|
1088
|
+
internalType: "uint256",
|
1089
|
+
name: "destId",
|
1090
|
+
type: "uint256"
|
1091
|
+
}, {
|
1092
|
+
internalType: "bytes32",
|
1093
|
+
name: "relationshipId",
|
1094
|
+
type: "bytes32"
|
1095
|
+
}, {
|
1096
|
+
internalType: "uint256",
|
1097
|
+
name: "ttl",
|
1098
|
+
type: "uint256"
|
1099
|
+
}],
|
1100
|
+
internalType: "struct IRelationshipModule.RelationshipParams",
|
1101
|
+
name: "params",
|
1102
|
+
type: "tuple"
|
1103
|
+
}],
|
1104
|
+
name: "areTheyRelated",
|
1105
|
+
outputs: [{
|
1106
|
+
internalType: "bool",
|
1107
|
+
name: "",
|
1108
|
+
type: "bool"
|
1109
|
+
}],
|
1110
|
+
stateMutability: "view",
|
1111
|
+
type: "function"
|
1112
|
+
}, {
|
1113
|
+
inputs: [{
|
1114
|
+
internalType: "string",
|
1115
|
+
name: "name",
|
1116
|
+
type: "string"
|
1117
|
+
}],
|
1118
|
+
name: "getRelationshipId",
|
1119
|
+
outputs: [{
|
1120
|
+
internalType: "bytes32",
|
1121
|
+
name: "",
|
1122
|
+
type: "bytes32"
|
1123
|
+
}],
|
1124
|
+
stateMutability: "pure",
|
1125
|
+
type: "function"
|
1126
|
+
}];
|
1127
|
+
var RelationshipModule__factory = /*#__PURE__*/function () {
|
1128
|
+
function RelationshipModule__factory() {
|
1129
|
+
_classCallCheck(this, RelationshipModule__factory);
|
1130
|
+
}
|
1131
|
+
_createClass(RelationshipModule__factory, null, [{
|
1132
|
+
key: "createInterface",
|
1133
|
+
value: function createInterface() {
|
1134
|
+
return new utils.Interface(_abi);
|
1135
|
+
}
|
1136
|
+
}, {
|
1137
|
+
key: "connect",
|
1138
|
+
value: function connect(address, signerOrProvider) {
|
1139
|
+
return new Contract(address, _abi, signerOrProvider);
|
1140
|
+
}
|
1141
|
+
}]);
|
1142
|
+
return RelationshipModule__factory;
|
1143
|
+
}();
|
1144
|
+
_defineProperty(RelationshipModule__factory, "abi", _abi);
|
1145
|
+
|
1146
|
+
/**
|
1147
|
+
* A class representing License operations.
|
1148
|
+
*
|
1149
|
+
* @public
|
1150
|
+
*/
|
1151
|
+
var LicenseClient = /*#__PURE__*/function () {
|
1152
|
+
function LicenseClient(httpClient, signer, franchiseRegistry) {
|
1153
|
+
_classCallCheck(this, LicenseClient);
|
1154
|
+
this.httpClient = httpClient;
|
1155
|
+
this.signer = signer;
|
1156
|
+
this.franchiseRegistry = franchiseRegistry;
|
1157
|
+
}
|
1158
|
+
|
1159
|
+
/**
|
1160
|
+
* Get a license by its ID.
|
1161
|
+
*
|
1162
|
+
* @param licenseId - The ID of the license to retrieve.
|
1163
|
+
* @returns A Promise that resolves to the GetLicenseResponse.
|
1164
|
+
*/
|
1165
|
+
_createClass(LicenseClient, [{
|
1166
|
+
key: "get",
|
1167
|
+
value: function () {
|
1168
|
+
var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
|
1169
|
+
var response;
|
1170
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
1171
|
+
while (1) switch (_context.prev = _context.next) {
|
1172
|
+
case 0:
|
1173
|
+
_context.prev = 0;
|
1174
|
+
if (isIntegerString(request.licenseId)) {
|
1175
|
+
_context.next = 3;
|
1176
|
+
break;
|
1177
|
+
}
|
1178
|
+
throw new Error("Invalid licenseId. Must be an integer. But got: ".concat(request.licenseId));
|
1179
|
+
case 3:
|
1180
|
+
_context.next = 5;
|
1181
|
+
return this.httpClient.get("/license/".concat(request.licenseId));
|
1182
|
+
case 5:
|
1183
|
+
response = _context.sent;
|
1184
|
+
return _context.abrupt("return", response.data);
|
1185
|
+
case 9:
|
1186
|
+
_context.prev = 9;
|
1187
|
+
_context.t0 = _context["catch"](0);
|
1188
|
+
handleError(_context.t0, "Failed to get license");
|
1189
|
+
case 12:
|
1190
|
+
case "end":
|
1191
|
+
return _context.stop();
|
1192
|
+
}
|
1193
|
+
}, _callee, this, [[0, 9]]);
|
1194
|
+
}));
|
1195
|
+
function get(_x) {
|
1196
|
+
return _get.apply(this, arguments);
|
1197
|
+
}
|
1198
|
+
return get;
|
1199
|
+
}()
|
1200
|
+
/**
|
1201
|
+
* List all licenses.
|
1202
|
+
*
|
1203
|
+
* @returns A Promise that resolves to the ListLicenseResponse.
|
1204
|
+
*/
|
1205
|
+
}, {
|
1206
|
+
key: "list",
|
1207
|
+
value: function () {
|
1208
|
+
var _list = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
|
1209
|
+
var response;
|
1210
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
1211
|
+
while (1) switch (_context2.prev = _context2.next) {
|
1212
|
+
case 0:
|
1213
|
+
_context2.prev = 0;
|
1214
|
+
_context2.next = 3;
|
1215
|
+
return this.httpClient.get("/license?franchiseId=".concat(request.franchiseId, "&ipAssetId=").concat(request.ipAssetId));
|
1216
|
+
case 3:
|
1217
|
+
response = _context2.sent;
|
1218
|
+
return _context2.abrupt("return", response.data);
|
1219
|
+
case 7:
|
1220
|
+
_context2.prev = 7;
|
1221
|
+
_context2.t0 = _context2["catch"](0);
|
1222
|
+
handleError(_context2.t0, "Failed to get licenses");
|
1223
|
+
case 10:
|
1224
|
+
case "end":
|
1225
|
+
return _context2.stop();
|
1226
|
+
}
|
1227
|
+
}, _callee2, this, [[0, 7]]);
|
1228
|
+
}));
|
1229
|
+
function list(_x2) {
|
1230
|
+
return _list.apply(this, arguments);
|
1231
|
+
}
|
1232
|
+
return list;
|
1233
|
+
}()
|
1234
|
+
/**
|
1235
|
+
* Create a license within the Story Protocol based on the specified input data.
|
1236
|
+
*
|
1237
|
+
* @param request - An object containing the necessary data to create a license.
|
1238
|
+
* @returns A response object containing the result of the create license action, including the transaction hash.
|
1239
|
+
*/
|
1240
|
+
}, {
|
1241
|
+
key: "create",
|
1242
|
+
value: function () {
|
1243
|
+
var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(request) {
|
1244
|
+
var defaults, franchiseId, ipAssetId, licenseURI, options, walletAddress, ipAssetRegistryAddress, ipAssetRegistry, parentLicenseId, createResponse;
|
1245
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
1246
|
+
while (1) switch (_context3.prev = _context3.next) {
|
1247
|
+
case 0:
|
1248
|
+
_context3.prev = 0;
|
1249
|
+
defaults = {
|
1250
|
+
_tokenId: 0,
|
1251
|
+
// Assuming BigNumberish can be initialized with 0
|
1252
|
+
_parentLicenseId: "0",
|
1253
|
+
_licenseHolder: "0x8e3B91c90561523312f32B49DAAc4AD15293De7F",
|
1254
|
+
// An empty string for a default holder address
|
1255
|
+
_uri: "https://example.xyz",
|
1256
|
+
// An empty string for a default URI
|
1257
|
+
_revoker: "0x8e3B91c90561523312f32B49DAAc4AD15293De7F",
|
1258
|
+
// An empty string for a default revoker address
|
1259
|
+
_commercial: false,
|
1260
|
+
// Default to non-commercial
|
1261
|
+
_canSublicense: false,
|
1262
|
+
// Default to not allowing sublicense
|
1263
|
+
_terms: {
|
1264
|
+
processor: constants.AddressZero,
|
1265
|
+
data: []
|
1266
|
+
},
|
1267
|
+
overrides: {
|
1268
|
+
// Assuming overrides is an object with properties from and gasLimit
|
1269
|
+
// You may need to provide default values for its properties as well
|
1270
|
+
}
|
1271
|
+
};
|
1272
|
+
franchiseId = request.franchiseId, ipAssetId = request.ipAssetId, licenseURI = request.licenseURI, options = request.options; // Get Wallet address from Signer
|
1273
|
+
_context3.next = 5;
|
1274
|
+
return this.signer.getAddress();
|
1275
|
+
case 5:
|
1276
|
+
walletAddress = _context3.sent;
|
1277
|
+
_context3.next = 8;
|
1278
|
+
return this.franchiseRegistry.ipAssetRegistryForId(franchiseId);
|
1279
|
+
case 8:
|
1280
|
+
ipAssetRegistryAddress = _context3.sent;
|
1281
|
+
// Connect to IPAssetRegistry Contract
|
1282
|
+
ipAssetRegistry = IpAssetRegistry__factory.connect(ipAssetRegistryAddress, this.signer); // Get parent license Id
|
1283
|
+
_context3.next = 12;
|
1284
|
+
return ipAssetRegistry.getLicenseIdByTokenId(ipAssetId, (options === null || options === void 0 ? void 0 : options.isCommercial) || defaults._commercial);
|
1285
|
+
case 12:
|
1286
|
+
parentLicenseId = _context3.sent;
|
1287
|
+
_context3.next = 15;
|
1288
|
+
return ipAssetRegistry.createLicense(ipAssetId, parentLicenseId, walletAddress, licenseURI, (options === null || options === void 0 ? void 0 : options.revoker) || defaults._revoker, (options === null || options === void 0 ? void 0 : options.isCommercial) || defaults._commercial, (options === null || options === void 0 ? void 0 : options.isSublicensable) || defaults._canSublicense, (options === null || options === void 0 ? void 0 : options.terms) || defaults._terms);
|
1289
|
+
case 15:
|
1290
|
+
createResponse = _context3.sent;
|
1291
|
+
return _context3.abrupt("return", {
|
1292
|
+
txHash: createResponse.hash
|
1293
|
+
});
|
1294
|
+
case 19:
|
1295
|
+
_context3.prev = 19;
|
1296
|
+
_context3.t0 = _context3["catch"](0);
|
1297
|
+
handleError(_context3.t0, "Failed to create license");
|
1298
|
+
case 22:
|
1299
|
+
case "end":
|
1300
|
+
return _context3.stop();
|
1301
|
+
}
|
1302
|
+
}, _callee3, this, [[0, 19]]);
|
1303
|
+
}));
|
1304
|
+
function create(_x3) {
|
1305
|
+
return _create.apply(this, arguments);
|
1306
|
+
}
|
1307
|
+
return create;
|
1308
|
+
}()
|
1309
|
+
}]);
|
1310
|
+
return LicenseClient;
|
1311
|
+
}();
|
1312
|
+
|
1313
|
+
/**
|
1314
|
+
* TransactionClient allows you to view and monitor transactions on
|
1315
|
+
* Story Protocol.
|
1316
|
+
*/
|
1317
|
+
var TransactionClient = /*#__PURE__*/function () {
|
1318
|
+
function TransactionClient(httpClient) {
|
1319
|
+
_classCallCheck(this, TransactionClient);
|
1320
|
+
this.httpClient = httpClient;
|
1321
|
+
}
|
1322
|
+
|
1323
|
+
/**
|
1324
|
+
* Get transaction data based on the specified transaction id.
|
1325
|
+
*
|
1326
|
+
* @param request - the request object for getting the transaction
|
1327
|
+
* @returns the response object that contains the fetched transaction object
|
1328
|
+
*/
|
1329
|
+
_createClass(TransactionClient, [{
|
1330
|
+
key: "get",
|
1331
|
+
value: function () {
|
1332
|
+
var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
|
1333
|
+
var response;
|
1334
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
1335
|
+
while (1) switch (_context.prev = _context.next) {
|
1336
|
+
case 0:
|
1337
|
+
_context.prev = 0;
|
1338
|
+
_context.next = 3;
|
1339
|
+
return this.httpClient.get("/transaction/".concat(request.txId));
|
1340
|
+
case 3:
|
1341
|
+
response = _context.sent;
|
1342
|
+
return _context.abrupt("return", response.data);
|
1343
|
+
case 7:
|
1344
|
+
_context.prev = 7;
|
1345
|
+
_context.t0 = _context["catch"](0);
|
1346
|
+
handleError(_context.t0, "Failed to get transaction");
|
1347
|
+
case 10:
|
1348
|
+
case "end":
|
1349
|
+
return _context.stop();
|
1350
|
+
}
|
1351
|
+
}, _callee, this, [[0, 7]]);
|
1352
|
+
}));
|
1353
|
+
function get(_x) {
|
1354
|
+
return _get.apply(this, arguments);
|
1355
|
+
}
|
1356
|
+
return get;
|
1357
|
+
}()
|
1358
|
+
/**
|
1359
|
+
* Get transaction data based on the specified transaction id.
|
1360
|
+
*
|
1361
|
+
* @param request - the request object for getting the transactions
|
1362
|
+
* @returns the response object that contains the fetched transaction object
|
1363
|
+
*/
|
1364
|
+
}, {
|
1365
|
+
key: "list",
|
1366
|
+
value: function () {
|
1367
|
+
var _list = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
1368
|
+
var response;
|
1369
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
1370
|
+
while (1) switch (_context2.prev = _context2.next) {
|
1371
|
+
case 0:
|
1372
|
+
_context2.prev = 0;
|
1373
|
+
_context2.next = 3;
|
1374
|
+
return this.httpClient.get("/transaction");
|
1375
|
+
case 3:
|
1376
|
+
response = _context2.sent;
|
1377
|
+
return _context2.abrupt("return", response.data);
|
1378
|
+
case 7:
|
1379
|
+
_context2.prev = 7;
|
1380
|
+
_context2.t0 = _context2["catch"](0);
|
1381
|
+
handleError(_context2.t0, "Failed to get transactions");
|
1382
|
+
case 10:
|
1383
|
+
case "end":
|
1384
|
+
return _context2.stop();
|
1385
|
+
}
|
1386
|
+
}, _callee2, this, [[0, 7]]);
|
1387
|
+
}));
|
1388
|
+
function list() {
|
1389
|
+
return _list.apply(this, arguments);
|
1390
|
+
}
|
1391
|
+
return list;
|
1392
|
+
}()
|
1393
|
+
}]);
|
1394
|
+
return TransactionClient;
|
1395
|
+
}();
|
1396
|
+
|
1397
|
+
/**
|
1398
|
+
* Client for managing relationships.
|
1399
|
+
*/
|
1400
|
+
var RelationshipClient = /*#__PURE__*/function () {
|
1401
|
+
/**
|
1402
|
+
* Creates a new RelationshipClient instance.
|
1403
|
+
* @param relationshipModule - The relationship module to interact with.
|
1404
|
+
* @param franchiseRegistry - The franchise registry to interact with.
|
1405
|
+
*/
|
1406
|
+
function RelationshipClient(relationshipModule, franchiseRegistry) {
|
1407
|
+
_classCallCheck(this, RelationshipClient);
|
1408
|
+
this.relationshipModule = relationshipModule;
|
1409
|
+
this.franchiseRegistry = franchiseRegistry;
|
1410
|
+
}
|
1411
|
+
|
1412
|
+
/**
|
1413
|
+
* Retrieves the registry addresses for source and destination franchises.
|
1414
|
+
* @param sourceFranchiseId - The ID of the source franchise.
|
1415
|
+
* @param destFranchiseId - The ID of the destination franchise.
|
1416
|
+
* @returns An object containing the source and destination IP registry addresses.
|
1417
|
+
*/
|
1418
|
+
_createClass(RelationshipClient, [{
|
1419
|
+
key: "getRegistryAddresses",
|
1420
|
+
value: function () {
|
1421
|
+
var _getRegistryAddresses = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(sourceFranchiseId, destFranchiseId) {
|
1422
|
+
var sourceIpRegistryAddress, destIpRegistryAddress;
|
1423
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
1424
|
+
while (1) switch (_context.prev = _context.next) {
|
1425
|
+
case 0:
|
1426
|
+
_context.prev = 0;
|
1427
|
+
_context.next = 3;
|
1428
|
+
return this.franchiseRegistry.ipAssetRegistryForId(sourceFranchiseId);
|
1429
|
+
case 3:
|
1430
|
+
sourceIpRegistryAddress = _context.sent;
|
1431
|
+
_context.next = 6;
|
1432
|
+
return this.franchiseRegistry.ipAssetRegistryForId(destFranchiseId);
|
1433
|
+
case 6:
|
1434
|
+
destIpRegistryAddress = _context.sent;
|
1435
|
+
return _context.abrupt("return", {
|
1436
|
+
sourceIpRegistryAddress: sourceIpRegistryAddress,
|
1437
|
+
destIpRegistryAddress: destIpRegistryAddress
|
1438
|
+
});
|
1439
|
+
case 10:
|
1440
|
+
_context.prev = 10;
|
1441
|
+
_context.t0 = _context["catch"](0);
|
1442
|
+
handleError(_context.t0, "Failed to get registry addresses");
|
1443
|
+
case 13:
|
1444
|
+
case "end":
|
1445
|
+
return _context.stop();
|
1446
|
+
}
|
1447
|
+
}, _callee, this, [[0, 10]]);
|
1448
|
+
}));
|
1449
|
+
function getRegistryAddresses(_x, _x2) {
|
1450
|
+
return _getRegistryAddresses.apply(this, arguments);
|
1451
|
+
}
|
1452
|
+
return getRegistryAddresses;
|
1453
|
+
}()
|
1454
|
+
/**
|
1455
|
+
* Establishes a relationship between two IP assets.
|
1456
|
+
* @param request - The request for establishing the relationship.
|
1457
|
+
* @returns A promise that resolves to the response with the transaction hash.
|
1458
|
+
*/
|
1459
|
+
}, {
|
1460
|
+
key: "relate",
|
1461
|
+
value: function () {
|
1462
|
+
var _relate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
|
1463
|
+
var sourceIPAsset, destIPAsset, mockRelationshipData, _yield$this$getRegist, sourceIpRegistryAddress, destIpRegistryAddress, relationshipId, params, response;
|
1464
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
1465
|
+
while (1) switch (_context2.prev = _context2.next) {
|
1466
|
+
case 0:
|
1467
|
+
_context2.prev = 0;
|
1468
|
+
sourceIPAsset = request.sourceIPAsset, destIPAsset = request.destIPAsset;
|
1469
|
+
mockRelationshipData = ethers.utils.formatBytes32String(""); // Get IPAssetRegistry Contract Address
|
1470
|
+
_context2.next = 5;
|
1471
|
+
return this.getRegistryAddresses(sourceIPAsset.franchiseId, destIPAsset.franchiseId);
|
1472
|
+
case 5:
|
1473
|
+
_yield$this$getRegist = _context2.sent;
|
1474
|
+
sourceIpRegistryAddress = _yield$this$getRegist.sourceIpRegistryAddress;
|
1475
|
+
destIpRegistryAddress = _yield$this$getRegist.destIpRegistryAddress;
|
1476
|
+
_context2.next = 10;
|
1477
|
+
return this.relationshipModule.getRelationshipId("APPEARS_IN");
|
1478
|
+
case 10:
|
1479
|
+
relationshipId = _context2.sent;
|
1480
|
+
params = {
|
1481
|
+
sourceContract: sourceIpRegistryAddress,
|
1482
|
+
sourceId: sourceIPAsset.ipAssetId,
|
1483
|
+
destContract: destIpRegistryAddress,
|
1484
|
+
destId: destIPAsset.ipAssetId,
|
1485
|
+
relationshipId: relationshipId,
|
1486
|
+
ttl: "0"
|
1487
|
+
};
|
1488
|
+
_context2.next = 14;
|
1489
|
+
return this.relationshipModule.relate(params, mockRelationshipData);
|
1490
|
+
case 14:
|
1491
|
+
response = _context2.sent;
|
1492
|
+
return _context2.abrupt("return", {
|
1493
|
+
txHash: response.hash
|
1494
|
+
});
|
1495
|
+
case 18:
|
1496
|
+
_context2.prev = 18;
|
1497
|
+
_context2.t0 = _context2["catch"](0);
|
1498
|
+
handleError(_context2.t0, "Failed to create relationship");
|
1499
|
+
case 21:
|
1500
|
+
case "end":
|
1501
|
+
return _context2.stop();
|
1502
|
+
}
|
1503
|
+
}, _callee2, this, [[0, 18]]);
|
1504
|
+
}));
|
1505
|
+
function relate(_x3) {
|
1506
|
+
return _relate.apply(this, arguments);
|
1507
|
+
}
|
1508
|
+
return relate;
|
1509
|
+
}()
|
1510
|
+
/**
|
1511
|
+
* Removes a relationship between two IP assets.
|
1512
|
+
* @param request - The request for removing the relationship.
|
1513
|
+
* @returns A promise that resolves to the response with the transaction hash.
|
1514
|
+
*/
|
1515
|
+
}, {
|
1516
|
+
key: "unrelate",
|
1517
|
+
value: function () {
|
1518
|
+
var _unrelate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(request) {
|
1519
|
+
var sourceIPAsset, destIPAsset, _yield$this$getRegist2, sourceIpRegistryAddress, destIpRegistryAddress, relationshipId, params, response;
|
1520
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
1521
|
+
while (1) switch (_context3.prev = _context3.next) {
|
1522
|
+
case 0:
|
1523
|
+
_context3.prev = 0;
|
1524
|
+
sourceIPAsset = request.sourceIPAsset, destIPAsset = request.destIPAsset; // Get IPAssetRegistry Contract Address
|
1525
|
+
_context3.next = 4;
|
1526
|
+
return this.getRegistryAddresses(sourceIPAsset.franchiseId, destIPAsset.franchiseId);
|
1527
|
+
case 4:
|
1528
|
+
_yield$this$getRegist2 = _context3.sent;
|
1529
|
+
sourceIpRegistryAddress = _yield$this$getRegist2.sourceIpRegistryAddress;
|
1530
|
+
destIpRegistryAddress = _yield$this$getRegist2.destIpRegistryAddress;
|
1531
|
+
_context3.next = 9;
|
1532
|
+
return this.relationshipModule.getRelationshipId("APPEARS_IN");
|
1533
|
+
case 9:
|
1534
|
+
relationshipId = _context3.sent;
|
1535
|
+
params = {
|
1536
|
+
sourceContract: sourceIpRegistryAddress,
|
1537
|
+
sourceId: sourceIPAsset.ipAssetId,
|
1538
|
+
destContract: destIpRegistryAddress,
|
1539
|
+
destId: destIPAsset.ipAssetId,
|
1540
|
+
relationshipId: relationshipId,
|
1541
|
+
ttl: "0"
|
1542
|
+
};
|
1543
|
+
_context3.next = 13;
|
1544
|
+
return this.relationshipModule.unrelate(params);
|
1545
|
+
case 13:
|
1546
|
+
response = _context3.sent;
|
1547
|
+
return _context3.abrupt("return", {
|
1548
|
+
txHash: response.hash
|
1549
|
+
});
|
1550
|
+
case 17:
|
1551
|
+
_context3.prev = 17;
|
1552
|
+
_context3.t0 = _context3["catch"](0);
|
1553
|
+
handleError(_context3.t0, "Failed to unrelate relationship");
|
1554
|
+
case 20:
|
1555
|
+
case "end":
|
1556
|
+
return _context3.stop();
|
1557
|
+
}
|
1558
|
+
}, _callee3, this, [[0, 17]]);
|
1559
|
+
}));
|
1560
|
+
function unrelate(_x4) {
|
1561
|
+
return _unrelate.apply(this, arguments);
|
1562
|
+
}
|
1563
|
+
return unrelate;
|
1564
|
+
}()
|
1565
|
+
/**
|
1566
|
+
* Checks if a relationship has expired.
|
1567
|
+
* @param request - The request for checking the relationship's expiration status.
|
1568
|
+
* @returns A promise that resolves to the response indicating whether the relationship has expired.
|
1569
|
+
*/
|
1570
|
+
}, {
|
1571
|
+
key: "isRelationshipExpired",
|
1572
|
+
value: function () {
|
1573
|
+
var _isRelationshipExpired = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(request) {
|
1574
|
+
var sourceIPAsset, destIPAsset, _yield$this$getRegist3, sourceIpRegistryAddress, destIpRegistryAddress, relationshipId, params, response;
|
1575
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
1576
|
+
while (1) switch (_context4.prev = _context4.next) {
|
1577
|
+
case 0:
|
1578
|
+
_context4.prev = 0;
|
1579
|
+
sourceIPAsset = request.sourceIPAsset, destIPAsset = request.destIPAsset; // Get IPAssetRegistry Contract Address
|
1580
|
+
_context4.next = 4;
|
1581
|
+
return this.getRegistryAddresses(sourceIPAsset.franchiseId, destIPAsset.franchiseId);
|
1582
|
+
case 4:
|
1583
|
+
_yield$this$getRegist3 = _context4.sent;
|
1584
|
+
sourceIpRegistryAddress = _yield$this$getRegist3.sourceIpRegistryAddress;
|
1585
|
+
destIpRegistryAddress = _yield$this$getRegist3.destIpRegistryAddress;
|
1586
|
+
_context4.next = 9;
|
1587
|
+
return this.relationshipModule.getRelationshipId("APPEARS_IN");
|
1588
|
+
case 9:
|
1589
|
+
relationshipId = _context4.sent;
|
1590
|
+
params = {
|
1591
|
+
sourceContract: sourceIpRegistryAddress,
|
1592
|
+
sourceId: sourceIPAsset.ipAssetId,
|
1593
|
+
destContract: destIpRegistryAddress,
|
1594
|
+
destId: destIPAsset.ipAssetId,
|
1595
|
+
relationshipId: relationshipId,
|
1596
|
+
ttl: "0"
|
1597
|
+
};
|
1598
|
+
_context4.next = 13;
|
1599
|
+
return this.relationshipModule.isRelationshipExpired(params);
|
1600
|
+
case 13:
|
1601
|
+
response = _context4.sent;
|
1602
|
+
return _context4.abrupt("return", {
|
1603
|
+
result: response
|
1604
|
+
});
|
1605
|
+
case 17:
|
1606
|
+
_context4.prev = 17;
|
1607
|
+
_context4.t0 = _context4["catch"](0);
|
1608
|
+
handleError(_context4.t0, "Failed to get isRelationshipExpired");
|
1609
|
+
case 20:
|
1610
|
+
case "end":
|
1611
|
+
return _context4.stop();
|
1612
|
+
}
|
1613
|
+
}, _callee4, this, [[0, 17]]);
|
1614
|
+
}));
|
1615
|
+
function isRelationshipExpired(_x5) {
|
1616
|
+
return _isRelationshipExpired.apply(this, arguments);
|
1617
|
+
}
|
1618
|
+
return isRelationshipExpired;
|
1619
|
+
}()
|
1620
|
+
/**
|
1621
|
+
* Checks if two IP assets are related.
|
1622
|
+
* @param request - The request for checking the relationship between two IP assets.
|
1623
|
+
* @returns A promise that resolves to the response indicating whether the IP assets are related.
|
1624
|
+
*/
|
1625
|
+
}, {
|
1626
|
+
key: "isRelated",
|
1627
|
+
value: function () {
|
1628
|
+
var _isRelated = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(request) {
|
1629
|
+
var sourceIPAsset, destIPAsset, _yield$this$getRegist4, sourceIpRegistryAddress, destIpRegistryAddress, relationshipId, params, response;
|
1630
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
1631
|
+
while (1) switch (_context5.prev = _context5.next) {
|
1632
|
+
case 0:
|
1633
|
+
_context5.prev = 0;
|
1634
|
+
sourceIPAsset = request.sourceIPAsset, destIPAsset = request.destIPAsset; // Get IPAssetRegistry Contract Address
|
1635
|
+
_context5.next = 4;
|
1636
|
+
return this.getRegistryAddresses(sourceIPAsset.franchiseId, destIPAsset.franchiseId);
|
1637
|
+
case 4:
|
1638
|
+
_yield$this$getRegist4 = _context5.sent;
|
1639
|
+
sourceIpRegistryAddress = _yield$this$getRegist4.sourceIpRegistryAddress;
|
1640
|
+
destIpRegistryAddress = _yield$this$getRegist4.destIpRegistryAddress;
|
1641
|
+
_context5.next = 9;
|
1642
|
+
return this.relationshipModule.getRelationshipId("APPEARS_IN");
|
1643
|
+
case 9:
|
1644
|
+
relationshipId = _context5.sent;
|
1645
|
+
params = {
|
1646
|
+
sourceContract: sourceIpRegistryAddress,
|
1647
|
+
sourceId: sourceIPAsset.ipAssetId,
|
1648
|
+
destContract: destIpRegistryAddress,
|
1649
|
+
destId: destIPAsset.ipAssetId,
|
1650
|
+
relationshipId: relationshipId,
|
1651
|
+
ttl: "0"
|
1652
|
+
};
|
1653
|
+
_context5.next = 13;
|
1654
|
+
return this.relationshipModule.areTheyRelated(params);
|
1655
|
+
case 13:
|
1656
|
+
response = _context5.sent;
|
1657
|
+
return _context5.abrupt("return", {
|
1658
|
+
result: response
|
1659
|
+
});
|
1660
|
+
case 17:
|
1661
|
+
_context5.prev = 17;
|
1662
|
+
_context5.t0 = _context5["catch"](0);
|
1663
|
+
handleError(_context5.t0, "Failed to get isRelated");
|
1664
|
+
case 20:
|
1665
|
+
case "end":
|
1666
|
+
return _context5.stop();
|
1667
|
+
}
|
1668
|
+
}, _callee5, this, [[0, 17]]);
|
1669
|
+
}));
|
1670
|
+
function isRelated(_x6) {
|
1671
|
+
return _isRelated.apply(this, arguments);
|
1672
|
+
}
|
1673
|
+
return isRelated;
|
1674
|
+
}()
|
1675
|
+
}]);
|
1676
|
+
return RelationshipClient;
|
1677
|
+
}();
|
1678
|
+
|
1679
|
+
/**
|
1680
|
+
* IpAssetClient allows you to create, view, and list IP Assets on Story Protocol.
|
1681
|
+
*/
|
1682
|
+
var IpAssetClient = /*#__PURE__*/function () {
|
1683
|
+
function IpAssetClient(httpClient, franchiseRegistry, signer) {
|
1684
|
+
_classCallCheck(this, IpAssetClient);
|
1685
|
+
this.httpClient = httpClient;
|
1686
|
+
this.franchiseRegistry = franchiseRegistry;
|
1687
|
+
this.signer = signer;
|
1688
|
+
}
|
1689
|
+
|
1690
|
+
/**
|
1691
|
+
* Get the ipAssetRegistry associated with a franchiseId.
|
1692
|
+
*
|
1693
|
+
* @returns the response object that contains the requested ipAssetRegistry.
|
1694
|
+
*/
|
1695
|
+
_createClass(IpAssetClient, [{
|
1696
|
+
key: "getRegistry",
|
1697
|
+
value: function () {
|
1698
|
+
var _getRegistry = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(franchiseId) {
|
1699
|
+
var address, ipAssetRegistry;
|
1700
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
1701
|
+
while (1) switch (_context.prev = _context.next) {
|
1702
|
+
case 0:
|
1703
|
+
_context.prev = 0;
|
1704
|
+
_context.next = 3;
|
1705
|
+
return this.franchiseRegistry.ipAssetRegistryForId(franchiseId);
|
1706
|
+
case 3:
|
1707
|
+
address = _context.sent;
|
1708
|
+
ipAssetRegistry = IpAssetRegistry__factory.connect(address, this.signer);
|
1709
|
+
return _context.abrupt("return", ipAssetRegistry);
|
1710
|
+
case 8:
|
1711
|
+
_context.prev = 8;
|
1712
|
+
_context.t0 = _context["catch"](0);
|
1713
|
+
handleError(_context.t0, "Failed to retrieve IP Asset Registry");
|
1714
|
+
case 11:
|
1715
|
+
case "end":
|
1716
|
+
return _context.stop();
|
1717
|
+
}
|
1718
|
+
}, _callee, this, [[0, 8]]);
|
1719
|
+
}));
|
1720
|
+
function getRegistry(_x) {
|
1721
|
+
return _getRegistry.apply(this, arguments);
|
1722
|
+
}
|
1723
|
+
return getRegistry;
|
1724
|
+
}()
|
1725
|
+
/**
|
1726
|
+
* Get an IP Asset based on the specified IP asset ID.
|
1727
|
+
*
|
1728
|
+
* @param request - the request object for getting an IP Asset.
|
1729
|
+
* @returns the response object the contains the fetched IP Asset.
|
1730
|
+
*/
|
1731
|
+
}, {
|
1732
|
+
key: "get",
|
1733
|
+
value: function () {
|
1734
|
+
var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
|
1735
|
+
var response;
|
1736
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
1737
|
+
while (1) switch (_context2.prev = _context2.next) {
|
1738
|
+
case 0:
|
1739
|
+
_context2.prev = 0;
|
1740
|
+
if (isIntegerString(request.ipAssetId)) {
|
1741
|
+
_context2.next = 3;
|
1742
|
+
break;
|
1743
|
+
}
|
1744
|
+
throw new Error("Invalid IP Asset id. Must be an integer. But get: ".concat(request.ipAssetId));
|
1745
|
+
case 3:
|
1746
|
+
_context2.next = 5;
|
1747
|
+
return this.httpClient.get("/ipasset/".concat(request.ipAssetId, "?franchiseId=").concat(request.franchiseId));
|
1748
|
+
case 5:
|
1749
|
+
response = _context2.sent;
|
1750
|
+
return _context2.abrupt("return", response.data);
|
1751
|
+
case 9:
|
1752
|
+
_context2.prev = 9;
|
1753
|
+
_context2.t0 = _context2["catch"](0);
|
1754
|
+
handleError(_context2.t0, "Failed to get IP Asset");
|
1755
|
+
case 12:
|
1756
|
+
case "end":
|
1757
|
+
return _context2.stop();
|
1758
|
+
}
|
1759
|
+
}, _callee2, this, [[0, 9]]);
|
1760
|
+
}));
|
1761
|
+
function get(_x2) {
|
1762
|
+
return _get.apply(this, arguments);
|
1763
|
+
}
|
1764
|
+
return get;
|
1765
|
+
}()
|
1766
|
+
/**
|
1767
|
+
* Create an IP Asset on Story Protocol based on the specified input asset data.
|
1768
|
+
*
|
1769
|
+
* @param request - the request object that contains all data needed to create an IP Asset.
|
1770
|
+
* @returns the response object that contains results from the asset creation.
|
1771
|
+
*/
|
1772
|
+
}, {
|
1773
|
+
key: "create",
|
1774
|
+
value: function () {
|
1775
|
+
var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(request) {
|
1776
|
+
var franchiseId, ipAssetRegistry, response;
|
1777
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
1778
|
+
while (1) switch (_context3.prev = _context3.next) {
|
1779
|
+
case 0:
|
1780
|
+
_context3.prev = 0;
|
1781
|
+
franchiseId = request.franchiseId;
|
1782
|
+
if (isIntegerString(franchiseId)) {
|
1783
|
+
_context3.next = 4;
|
1784
|
+
break;
|
1785
|
+
}
|
1786
|
+
throw new Error("Invalid franchise ID for IP asset creation. Must be an integer, but got: ".concat(request.franchiseId));
|
1787
|
+
case 4:
|
1788
|
+
_context3.next = 6;
|
1789
|
+
return this.getRegistry(franchiseId);
|
1790
|
+
case 6:
|
1791
|
+
ipAssetRegistry = _context3.sent;
|
1792
|
+
_context3.next = 9;
|
1793
|
+
return ipAssetRegistry.createIPAsset(request.ipAssetType, request.ipAssetName, request.description, request.mediaUrl, request.to, request.parentIpAssetId);
|
1794
|
+
case 9:
|
1795
|
+
response = _context3.sent;
|
1796
|
+
return _context3.abrupt("return", {
|
1797
|
+
txHash: response.hash
|
1798
|
+
});
|
1799
|
+
case 13:
|
1800
|
+
_context3.prev = 13;
|
1801
|
+
_context3.t0 = _context3["catch"](0);
|
1802
|
+
handleError(_context3.t0, "Failed to create IP Asset");
|
1803
|
+
case 16:
|
1804
|
+
case "end":
|
1805
|
+
return _context3.stop();
|
1806
|
+
}
|
1807
|
+
}, _callee3, this, [[0, 13]]);
|
1808
|
+
}));
|
1809
|
+
function create(_x3) {
|
1810
|
+
return _create.apply(this, arguments);
|
1811
|
+
}
|
1812
|
+
return create;
|
1813
|
+
}()
|
1814
|
+
/**
|
1815
|
+
* List all IP assets.
|
1816
|
+
*
|
1817
|
+
* @returns the response object that contains results from listing query.
|
1818
|
+
*/
|
1819
|
+
}, {
|
1820
|
+
key: "list",
|
1821
|
+
value: function () {
|
1822
|
+
var _list = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(request) {
|
1823
|
+
var response;
|
1824
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
1825
|
+
while (1) switch (_context4.prev = _context4.next) {
|
1826
|
+
case 0:
|
1827
|
+
_context4.prev = 0;
|
1828
|
+
_context4.next = 3;
|
1829
|
+
return this.httpClient.get("/ipasset?franchiseId=".concat(request.franchiseId));
|
1830
|
+
case 3:
|
1831
|
+
response = _context4.sent;
|
1832
|
+
return _context4.abrupt("return", response.data);
|
1833
|
+
case 7:
|
1834
|
+
_context4.prev = 7;
|
1835
|
+
_context4.t0 = _context4["catch"](0);
|
1836
|
+
handleError(_context4.t0, "Failed to list IP Asset.");
|
1837
|
+
case 10:
|
1838
|
+
case "end":
|
1839
|
+
return _context4.stop();
|
1840
|
+
}
|
1841
|
+
}, _callee4, this, [[0, 7]]);
|
1842
|
+
}));
|
1843
|
+
function list(_x4) {
|
1844
|
+
return _list.apply(this, arguments);
|
1845
|
+
}
|
1846
|
+
return list;
|
1847
|
+
}()
|
1848
|
+
}]);
|
1849
|
+
return IpAssetClient;
|
1850
|
+
}();
|
1851
|
+
|
1852
|
+
/**
|
1853
|
+
* Default timeout value for http clients.
|
1854
|
+
*/
|
1855
|
+
var HTTP_TIMEOUT = 1000;
|
1856
|
+
|
1857
|
+
var CollectClient = /*#__PURE__*/function () {
|
1858
|
+
function CollectClient(httpClient, signer, collectModule) {
|
1859
|
+
_classCallCheck(this, CollectClient);
|
1860
|
+
this.httpClient = httpClient;
|
1861
|
+
this.signer = signer;
|
1862
|
+
this.collectModuleContract = collectModule;
|
1863
|
+
}
|
1864
|
+
|
1865
|
+
/**
|
1866
|
+
* List all collected IP Assets.
|
1867
|
+
*
|
1868
|
+
* @returns A Promise that resolves to the ListLicenseResponse.
|
1869
|
+
*/
|
1870
|
+
_createClass(CollectClient, [{
|
1871
|
+
key: "list",
|
1872
|
+
value: function () {
|
1873
|
+
var _list = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
|
1874
|
+
var response;
|
1875
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
1876
|
+
while (1) switch (_context.prev = _context.next) {
|
1877
|
+
case 0:
|
1878
|
+
_context.prev = 0;
|
1879
|
+
_context.next = 3;
|
1880
|
+
return this.httpClient.get("/collection?franchiseId=".concat(request.franchiseId));
|
1881
|
+
case 3:
|
1882
|
+
response = _context.sent;
|
1883
|
+
return _context.abrupt("return", response.data);
|
1884
|
+
case 7:
|
1885
|
+
_context.prev = 7;
|
1886
|
+
_context.t0 = _context["catch"](0);
|
1887
|
+
handleError(_context.t0, "Failed to get collections");
|
1888
|
+
case 10:
|
1889
|
+
case "end":
|
1890
|
+
return _context.stop();
|
1891
|
+
}
|
1892
|
+
}, _callee, this, [[0, 7]]);
|
1893
|
+
}));
|
1894
|
+
function list(_x) {
|
1895
|
+
return _list.apply(this, arguments);
|
1896
|
+
}
|
1897
|
+
return list;
|
1898
|
+
}()
|
1899
|
+
/**
|
1900
|
+
* Collect an IP Asset on Story Protocol based on the specified input collect data.
|
1901
|
+
*
|
1902
|
+
* @param request - the request object that contains all data needed to collect an IP Asset
|
1903
|
+
* @returns the response object that contains results from the create franchise action
|
1904
|
+
*/
|
1905
|
+
}, {
|
1906
|
+
key: "collect",
|
1907
|
+
value: function () {
|
1908
|
+
var _collect = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(request) {
|
1909
|
+
var response;
|
1910
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
1911
|
+
while (1) switch (_context2.prev = _context2.next) {
|
1912
|
+
case 0:
|
1913
|
+
_context2.prev = 0;
|
1914
|
+
_context2.next = 3;
|
1915
|
+
return this.collectModuleContract.collect({
|
1916
|
+
franchiseId: request.franchiseId,
|
1917
|
+
ipAssetId: request.ipAssetId,
|
1918
|
+
collector: request.collector,
|
1919
|
+
collectData: "0x",
|
1920
|
+
collectNFTInitData: "0x",
|
1921
|
+
collectNFTData: "0x"
|
1922
|
+
});
|
1923
|
+
case 3:
|
1924
|
+
response = _context2.sent;
|
1925
|
+
return _context2.abrupt("return", {
|
1926
|
+
txHash: response.hash
|
1927
|
+
});
|
1928
|
+
case 7:
|
1929
|
+
_context2.prev = 7;
|
1930
|
+
_context2.t0 = _context2["catch"](0);
|
1931
|
+
handleError(_context2.t0, "Failed to collect IP Asset");
|
1932
|
+
case 10:
|
1933
|
+
case "end":
|
1934
|
+
return _context2.stop();
|
1935
|
+
}
|
1936
|
+
}, _callee2, this, [[0, 7]]);
|
1937
|
+
}));
|
1938
|
+
function collect(_x2) {
|
1939
|
+
return _collect.apply(this, arguments);
|
1940
|
+
}
|
1941
|
+
return collect;
|
1942
|
+
}()
|
1943
|
+
}]);
|
1944
|
+
return CollectClient;
|
1945
|
+
}();
|
1946
|
+
|
1947
|
+
dotenv.config();
|
1948
|
+
/**
|
1949
|
+
* The StoryClient is the main entry point for the SDK.
|
1950
|
+
*/
|
1951
|
+
var StoryClient = /*#__PURE__*/function () {
|
1952
|
+
/**
|
1953
|
+
* @param config - the configuration for the SDK client
|
1954
|
+
*/
|
1955
|
+
function StoryClient(config) {
|
1956
|
+
_classCallCheck(this, StoryClient);
|
1957
|
+
_defineProperty(this, "_franchise", null);
|
1958
|
+
_defineProperty(this, "_relationship", null);
|
1959
|
+
_defineProperty(this, "_ipAsset", null);
|
1960
|
+
_defineProperty(this, "_license", null);
|
1961
|
+
_defineProperty(this, "_transaction", null);
|
1962
|
+
_defineProperty(this, "_collect", null);
|
1963
|
+
if (config.environment !== Environment.TEST) {
|
1964
|
+
throw new Error("Invalid Environment: Only TEST environment is supported");
|
1965
|
+
}
|
1966
|
+
this.config = config;
|
1967
|
+
this.httpClient = axios.create({
|
1968
|
+
baseURL: process.env.API_BASE_URL,
|
1969
|
+
timeout: HTTP_TIMEOUT
|
1970
|
+
});
|
1971
|
+
}
|
1972
|
+
|
1973
|
+
/**
|
1974
|
+
* Getter for the franchise client. The client is lazily created when
|
1975
|
+
* this method is called.
|
1976
|
+
*
|
1977
|
+
* @returns the FranchiseClient instance
|
1978
|
+
*/
|
1979
|
+
_createClass(StoryClient, [{
|
1980
|
+
key: "franchise",
|
1981
|
+
get: function get() {
|
1982
|
+
if (this._franchise === null) {
|
1983
|
+
var franchiseRegistry = FranchiseRegistry__factory.connect(process.env.FRANCHISE_REGISTRY_CONTRACT, this.config.signer);
|
1984
|
+
var licenseModule = LicensingModule__factory.connect(process.env.LICENSING_MODULE_CONTRACT, this.config.signer);
|
1985
|
+
this._franchise = new FranchiseClient(this.httpClient, franchiseRegistry, licenseModule);
|
1986
|
+
}
|
1987
|
+
return this._franchise;
|
1988
|
+
}
|
1989
|
+
|
1990
|
+
/**
|
1991
|
+
* Getter for the relationship client. The client is lazily created when
|
1992
|
+
* this method is called.
|
1993
|
+
*
|
1994
|
+
* @returns the RelationshipClient instance
|
1995
|
+
*/
|
1996
|
+
}, {
|
1997
|
+
key: "relationship",
|
1998
|
+
get: function get() {
|
1999
|
+
if (this._relationship === null) {
|
2000
|
+
var franchiseRegistry = FranchiseRegistry__factory.connect(process.env.FRANCHISE_REGISTRY_CONTRACT, this.config.signer);
|
2001
|
+
var relationshipModule = RelationshipModule__factory.connect(process.env.RELATIONSHIP_MODULE_CONTRACT, this.config.signer);
|
2002
|
+
this._relationship = new RelationshipClient(relationshipModule, franchiseRegistry);
|
2003
|
+
}
|
2004
|
+
return this._relationship;
|
2005
|
+
}
|
2006
|
+
|
2007
|
+
/**
|
2008
|
+
* Getter for the IP Asset client. The client is lazily created when
|
2009
|
+
* this method is called.
|
2010
|
+
*
|
2011
|
+
* @returns the IpAssetClient instance
|
2012
|
+
*/
|
2013
|
+
}, {
|
2014
|
+
key: "ipAsset",
|
2015
|
+
get: function get() {
|
2016
|
+
if (this._ipAsset === null) {
|
2017
|
+
var franchiseRegistry = FranchiseRegistry__factory.connect(process.env.FRANCHISE_REGISTRY_CONTRACT, this.config.signer);
|
2018
|
+
this._ipAsset = new IpAssetClient(this.httpClient, franchiseRegistry, this.config.signer);
|
2019
|
+
}
|
2020
|
+
return this._ipAsset;
|
2021
|
+
}
|
2022
|
+
|
2023
|
+
/**
|
2024
|
+
* Getter for the license client. The client is lazily created when
|
2025
|
+
* this method is called.
|
2026
|
+
*
|
2027
|
+
* @returns the FranchiseClient instance
|
2028
|
+
*/
|
2029
|
+
}, {
|
2030
|
+
key: "license",
|
2031
|
+
get: function get() {
|
2032
|
+
if (this._license === null) {
|
2033
|
+
var franchiseRegistry = FranchiseRegistry__factory.connect(process.env.FRANCHISE_REGISTRY_CONTRACT, this.config.signer);
|
2034
|
+
this._license = new LicenseClient(this.httpClient, this.config.signer, franchiseRegistry);
|
2035
|
+
}
|
2036
|
+
return this._license;
|
2037
|
+
}
|
2038
|
+
|
2039
|
+
/**
|
2040
|
+
* Getter for the transaction client. The client is lazily created when
|
2041
|
+
* this method is called.
|
2042
|
+
*
|
2043
|
+
* @returns the TransactionClient instance
|
2044
|
+
*/
|
2045
|
+
}, {
|
2046
|
+
key: "transaction",
|
2047
|
+
get: function get() {
|
2048
|
+
if (this._transaction === null) {
|
2049
|
+
this._transaction = new TransactionClient(this.httpClient);
|
2050
|
+
}
|
2051
|
+
return this._transaction;
|
2052
|
+
}
|
2053
|
+
|
2054
|
+
/**
|
2055
|
+
* Getter for the collect module client. The client is lazily created when
|
2056
|
+
* this method is called.
|
2057
|
+
*
|
2058
|
+
* @returns the CollectClient instance
|
2059
|
+
*/
|
2060
|
+
}, {
|
2061
|
+
key: "collect",
|
2062
|
+
get: function get() {
|
2063
|
+
if (this._collect === null) {
|
2064
|
+
var collectModule = CollectModule__factory.connect(process.env.COLLECT_MODULE_CONTRACT, this.config.signer);
|
2065
|
+
this._collect = new CollectClient(this.httpClient, this.config.signer, collectModule);
|
2066
|
+
}
|
2067
|
+
return this._collect;
|
2068
|
+
}
|
2069
|
+
}]);
|
2070
|
+
return StoryClient;
|
2071
|
+
}();
|
2072
|
+
|
2073
|
+
export { Environment, StoryClient };
|