wao 0.5.4 → 0.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/ao.js +1 -1
- package/cjs/aoconnect.js +156 -135
- package/cjs/helpers.js +0 -1
- package/cjs/server.js +167 -99
- package/cjs/tar.js +87 -61
- package/esm/ao.js +1 -3
- package/esm/aoconnect.js +6 -1
- package/esm/helpers.js +0 -1
- package/esm/server.js +74 -12
- package/esm/tar.js +11 -4
- package/esm/tgql.js +1 -0
- package/package.json +4 -3
package/cjs/server.js
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
7
|
var _express = _interopRequireDefault(require("express"));
|
|
8
|
+
var _cors = _interopRequireDefault(require("cors"));
|
|
8
9
|
var _base64url = _interopRequireDefault(require("base64url"));
|
|
9
10
|
var _arbundles = require("arbundles");
|
|
10
11
|
var _utils = require("./utils.js");
|
|
@@ -15,11 +16,11 @@ var _graphql = require("graphql");
|
|
|
15
16
|
var _ramda = require("ramda");
|
|
16
17
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
17
18
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
19
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
20
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
18
21
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
19
22
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
20
23
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
21
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
22
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
23
24
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; 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; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; 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); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { 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); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; 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; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
24
25
|
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
25
26
|
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
@@ -152,9 +153,18 @@ var Server = /*#__PURE__*/function () {
|
|
|
152
153
|
value: function ar() {
|
|
153
154
|
var _this = this;
|
|
154
155
|
var app = (0, _express["default"])();
|
|
156
|
+
app.use((0, _cors["default"])());
|
|
155
157
|
app.use(_bodyParser["default"].json({
|
|
156
158
|
limit: "100mb"
|
|
157
159
|
}));
|
|
160
|
+
app.get("/wallet/:id/balance", function (req, res) {
|
|
161
|
+
return res.send("0");
|
|
162
|
+
});
|
|
163
|
+
app.get("/mint/:id/:amount", function (req, res) {
|
|
164
|
+
return res.json({
|
|
165
|
+
id: "0"
|
|
166
|
+
});
|
|
167
|
+
});
|
|
158
168
|
app.get("/tx/:id/offset", /*#__PURE__*/function () {
|
|
159
169
|
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(req, res) {
|
|
160
170
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
@@ -248,7 +258,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
248
258
|
}());
|
|
249
259
|
app.post("/graphql", /*#__PURE__*/function () {
|
|
250
260
|
var _ref10 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(req, res) {
|
|
251
|
-
var _req$body, query, variables, parsedQuery, errors, parsed, tar, fields, args, res2, edges;
|
|
261
|
+
var _req$body, query, variables, parsedQuery, errors, parsed, tar, fields, args, _tags, _iterator, _step, v, res2, edges;
|
|
252
262
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
253
263
|
while (1) switch (_context6.prev = _context6.next) {
|
|
254
264
|
case 0:
|
|
@@ -259,27 +269,42 @@ var Server = /*#__PURE__*/function () {
|
|
|
259
269
|
tar = parsed.rootFieldName;
|
|
260
270
|
fields = parsed.fields[0].edges[0].node;
|
|
261
271
|
args = parsed.args;
|
|
272
|
+
if (args.tags) {
|
|
273
|
+
_tags = {};
|
|
274
|
+
_iterator = _createForOfIteratorHelper(args.tags);
|
|
275
|
+
try {
|
|
276
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
277
|
+
v = _step.value;
|
|
278
|
+
_tags[v.name] = v.values;
|
|
279
|
+
}
|
|
280
|
+
} catch (err) {
|
|
281
|
+
_iterator.e(err);
|
|
282
|
+
} finally {
|
|
283
|
+
_iterator.f();
|
|
284
|
+
}
|
|
285
|
+
args.tags = _tags;
|
|
286
|
+
}
|
|
262
287
|
res2 = null;
|
|
263
288
|
if (!(tar === "transactions")) {
|
|
264
|
-
_context6.next =
|
|
289
|
+
_context6.next = 15;
|
|
265
290
|
break;
|
|
266
291
|
}
|
|
267
|
-
_context6.next =
|
|
292
|
+
_context6.next = 12;
|
|
268
293
|
return _this.gql.txs(_objectSpread({}, args));
|
|
269
|
-
case
|
|
294
|
+
case 12:
|
|
270
295
|
res2 = _context6.sent;
|
|
271
|
-
_context6.next =
|
|
296
|
+
_context6.next = 19;
|
|
272
297
|
break;
|
|
273
|
-
case
|
|
298
|
+
case 15:
|
|
274
299
|
if (!(tar === "blocks")) {
|
|
275
|
-
_context6.next =
|
|
300
|
+
_context6.next = 19;
|
|
276
301
|
break;
|
|
277
302
|
}
|
|
278
|
-
_context6.next =
|
|
303
|
+
_context6.next = 18;
|
|
279
304
|
return _this.gql.blocks();
|
|
280
|
-
case 17:
|
|
281
|
-
res2 = _context6.sent;
|
|
282
305
|
case 18:
|
|
306
|
+
res2 = _context6.sent;
|
|
307
|
+
case 19:
|
|
283
308
|
edges = (0, _ramda.map)(function (v) {
|
|
284
309
|
return {
|
|
285
310
|
node: v,
|
|
@@ -293,7 +318,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
293
318
|
}
|
|
294
319
|
}
|
|
295
320
|
});
|
|
296
|
-
case
|
|
321
|
+
case 21:
|
|
297
322
|
case "end":
|
|
298
323
|
return _context6.stop();
|
|
299
324
|
}
|
|
@@ -366,27 +391,6 @@ var Server = /*#__PURE__*/function () {
|
|
|
366
391
|
return _ref11.apply(this, arguments);
|
|
367
392
|
};
|
|
368
393
|
}());
|
|
369
|
-
app.post("/tx", /*#__PURE__*/function () {
|
|
370
|
-
var _ref12 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(req, res) {
|
|
371
|
-
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
372
|
-
while (1) switch (_context8.prev = _context8.next) {
|
|
373
|
-
case 0:
|
|
374
|
-
_context8.next = 2;
|
|
375
|
-
return _this._ar.postTx(req.body);
|
|
376
|
-
case 2:
|
|
377
|
-
res.json({
|
|
378
|
-
id: req.body.id
|
|
379
|
-
});
|
|
380
|
-
case 3:
|
|
381
|
-
case "end":
|
|
382
|
-
return _context8.stop();
|
|
383
|
-
}
|
|
384
|
-
}, _callee8);
|
|
385
|
-
}));
|
|
386
|
-
return function (_x15, _x16) {
|
|
387
|
-
return _ref12.apply(this, arguments);
|
|
388
|
-
};
|
|
389
|
-
}());
|
|
390
394
|
var server = app.listen(this.ports.ar, function () {
|
|
391
395
|
console.log("AR on port ".concat(_this.ports.ar));
|
|
392
396
|
});
|
|
@@ -397,6 +401,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
397
401
|
value: function mu() {
|
|
398
402
|
var _this2 = this;
|
|
399
403
|
var app = (0, _express["default"])();
|
|
404
|
+
app.use((0, _cors["default"])());
|
|
400
405
|
app.use(_express["default"].raw({
|
|
401
406
|
type: "*/*"
|
|
402
407
|
}));
|
|
@@ -404,11 +409,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
404
409
|
return res.send("ao messenger unit");
|
|
405
410
|
});
|
|
406
411
|
app.post("/monitor/:id", /*#__PURE__*/function () {
|
|
407
|
-
var
|
|
408
|
-
return _regeneratorRuntime().wrap(function
|
|
409
|
-
while (1) switch (
|
|
412
|
+
var _ref12 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(req, res) {
|
|
413
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
414
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
410
415
|
case 0:
|
|
411
|
-
|
|
416
|
+
_context8.next = 2;
|
|
412
417
|
return _this2.monitor({
|
|
413
418
|
process: req.params.id
|
|
414
419
|
});
|
|
@@ -419,20 +424,20 @@ var Server = /*#__PURE__*/function () {
|
|
|
419
424
|
});
|
|
420
425
|
case 3:
|
|
421
426
|
case "end":
|
|
422
|
-
return
|
|
427
|
+
return _context8.stop();
|
|
423
428
|
}
|
|
424
|
-
},
|
|
429
|
+
}, _callee8);
|
|
425
430
|
}));
|
|
426
|
-
return function (
|
|
427
|
-
return
|
|
431
|
+
return function (_x15, _x16) {
|
|
432
|
+
return _ref12.apply(this, arguments);
|
|
428
433
|
};
|
|
429
434
|
}());
|
|
430
435
|
app["delete"]("/monitor/:id", /*#__PURE__*/function () {
|
|
431
|
-
var
|
|
432
|
-
return _regeneratorRuntime().wrap(function
|
|
433
|
-
while (1) switch (
|
|
436
|
+
var _ref13 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(req, res) {
|
|
437
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
438
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
434
439
|
case 0:
|
|
435
|
-
|
|
440
|
+
_context9.next = 2;
|
|
436
441
|
return _this2.unmonitor({
|
|
437
442
|
process: req.params.id
|
|
438
443
|
});
|
|
@@ -443,71 +448,77 @@ var Server = /*#__PURE__*/function () {
|
|
|
443
448
|
});
|
|
444
449
|
case 3:
|
|
445
450
|
case "end":
|
|
446
|
-
return
|
|
451
|
+
return _context9.stop();
|
|
447
452
|
}
|
|
448
|
-
},
|
|
453
|
+
}, _callee9);
|
|
449
454
|
}));
|
|
450
|
-
return function (
|
|
451
|
-
return
|
|
455
|
+
return function (_x17, _x18) {
|
|
456
|
+
return _ref13.apply(this, arguments);
|
|
452
457
|
};
|
|
453
458
|
}());
|
|
454
459
|
app.post("/", /*#__PURE__*/function () {
|
|
455
|
-
var
|
|
460
|
+
var _ref14 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(req, res) {
|
|
456
461
|
var binary, valid, type, item, _tags, err;
|
|
457
|
-
return _regeneratorRuntime().wrap(function
|
|
458
|
-
while (1) switch (
|
|
462
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
463
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
459
464
|
case 0:
|
|
460
465
|
binary = req.body;
|
|
461
|
-
|
|
466
|
+
_context10.next = 3;
|
|
462
467
|
return _arbundles.DataItem.verify(binary);
|
|
463
468
|
case 3:
|
|
464
|
-
valid =
|
|
469
|
+
valid = _context10.sent;
|
|
465
470
|
type = null;
|
|
466
471
|
item = null;
|
|
467
472
|
if (valid) item = new _arbundles.DataItem(binary);
|
|
468
473
|
_tags = (0, _utils.tags)(item.tags);
|
|
469
474
|
err = null;
|
|
470
475
|
if (!(_tags.Type === "Process")) {
|
|
471
|
-
|
|
476
|
+
_context10.next = 14;
|
|
472
477
|
break;
|
|
473
478
|
}
|
|
474
|
-
|
|
479
|
+
_context10.next = 12;
|
|
475
480
|
return _this2.spawn({
|
|
476
481
|
item: item,
|
|
477
482
|
module: _tags.Module,
|
|
478
483
|
scheduler: _tags.Scheduler
|
|
479
484
|
});
|
|
480
485
|
case 12:
|
|
481
|
-
|
|
486
|
+
_context10.next = 20;
|
|
482
487
|
break;
|
|
483
488
|
case 14:
|
|
484
489
|
if (!(_tags.Type === "Message")) {
|
|
485
|
-
|
|
490
|
+
_context10.next = 19;
|
|
486
491
|
break;
|
|
487
492
|
}
|
|
488
|
-
|
|
493
|
+
_context10.next = 17;
|
|
489
494
|
return _this2.message({
|
|
490
495
|
item: item,
|
|
491
496
|
process: item.target
|
|
492
497
|
});
|
|
493
498
|
case 17:
|
|
494
|
-
|
|
499
|
+
_context10.next = 20;
|
|
495
500
|
break;
|
|
496
501
|
case 19:
|
|
497
502
|
err = true;
|
|
498
503
|
case 20:
|
|
499
|
-
if (err)
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
+
if (err) {
|
|
505
|
+
res.status(500);
|
|
506
|
+
res.send({
|
|
507
|
+
err: err
|
|
508
|
+
});
|
|
509
|
+
} else {
|
|
510
|
+
res.send({
|
|
511
|
+
id: item.id
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
case 21:
|
|
504
515
|
case "end":
|
|
505
|
-
return
|
|
516
|
+
return _context10.stop();
|
|
506
517
|
}
|
|
507
|
-
},
|
|
518
|
+
}, _callee10);
|
|
508
519
|
}));
|
|
509
|
-
return function (
|
|
510
|
-
return
|
|
520
|
+
return function (_x19, _x20) {
|
|
521
|
+
return _ref14.apply(this, arguments);
|
|
511
522
|
};
|
|
512
523
|
}());
|
|
513
524
|
var server = app.listen(this.ports.mu, function () {
|
|
@@ -520,10 +531,58 @@ var Server = /*#__PURE__*/function () {
|
|
|
520
531
|
value: function su() {
|
|
521
532
|
var _this3 = this;
|
|
522
533
|
var app = (0, _express["default"])();
|
|
534
|
+
app.use((0, _cors["default"])());
|
|
523
535
|
app.use(_bodyParser["default"].json());
|
|
524
536
|
app.get("/", function (req, res) {
|
|
537
|
+
res.json({
|
|
538
|
+
Unit: "Scheduler",
|
|
539
|
+
Timestamp: Date.now(),
|
|
540
|
+
Address: _test.su.addr,
|
|
541
|
+
Processes: (0, _ramda.keys)(_this3.mem.env)
|
|
542
|
+
});
|
|
543
|
+
});
|
|
544
|
+
app.get("/timestamp", function (req, res) {
|
|
525
545
|
return res.json({
|
|
526
|
-
timestamp: Date.now()
|
|
546
|
+
timestamp: Date.now(),
|
|
547
|
+
block_height: _this3.mem.height
|
|
548
|
+
});
|
|
549
|
+
});
|
|
550
|
+
app.get("/:pid", function (req, res) {
|
|
551
|
+
var pid = req.params.pid;
|
|
552
|
+
var edges = (0, _ramda.map)(function (v) {
|
|
553
|
+
var _mtx$anchor, _tx$anchor;
|
|
554
|
+
var tx = _this3.mem.txs[v.id];
|
|
555
|
+
var _tags = (0, _utils.tags)(v.tags);
|
|
556
|
+
var mid = _tags.Message;
|
|
557
|
+
var mtx = _this3.mem.txs[mid];
|
|
558
|
+
return {
|
|
559
|
+
cursor: v.id,
|
|
560
|
+
node: {
|
|
561
|
+
message: {
|
|
562
|
+
id: mtx.id,
|
|
563
|
+
tags: mtx.tags,
|
|
564
|
+
owner: _this3.mem.addrmap[mtx.owner],
|
|
565
|
+
anchor: (_mtx$anchor = mtx.anchor) !== null && _mtx$anchor !== void 0 ? _mtx$anchor : null,
|
|
566
|
+
target: pid,
|
|
567
|
+
signature: mtx.signature,
|
|
568
|
+
data: tx.data
|
|
569
|
+
},
|
|
570
|
+
assignment: {
|
|
571
|
+
id: tx.id,
|
|
572
|
+
tags: tx.tags,
|
|
573
|
+
owner: _this3.mem.addrmap[tx.owner],
|
|
574
|
+
anchor: (_tx$anchor = tx.anchor) !== null && _tx$anchor !== void 0 ? _tx$anchor : null,
|
|
575
|
+
target: null,
|
|
576
|
+
signature: tx.signature
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
};
|
|
580
|
+
})((0, _ramda.reverse)(_this3.mem.env[pid].txs));
|
|
581
|
+
res.json({
|
|
582
|
+
page_info: {
|
|
583
|
+
has_next_page: false
|
|
584
|
+
},
|
|
585
|
+
edges: edges
|
|
527
586
|
});
|
|
528
587
|
});
|
|
529
588
|
var server = app.listen(this.ports.su, function () {
|
|
@@ -536,45 +595,47 @@ var Server = /*#__PURE__*/function () {
|
|
|
536
595
|
value: function cu() {
|
|
537
596
|
var _this4 = this;
|
|
538
597
|
var app = (0, _express["default"])();
|
|
598
|
+
app.use((0, _cors["default"])());
|
|
539
599
|
app.use(_bodyParser["default"].json());
|
|
540
600
|
app.get("/", function (req, res) {
|
|
541
601
|
return res.json({
|
|
542
|
-
timestamp: Date.now()
|
|
602
|
+
timestamp: Date.now(),
|
|
603
|
+
address: _test.cu.addr
|
|
543
604
|
});
|
|
544
605
|
});
|
|
545
606
|
app.get("/result/:mid", /*#__PURE__*/function () {
|
|
546
|
-
var
|
|
607
|
+
var _ref15 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11(req, res) {
|
|
547
608
|
var res2;
|
|
548
|
-
return _regeneratorRuntime().wrap(function
|
|
549
|
-
while (1) switch (
|
|
609
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
610
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
550
611
|
case 0:
|
|
551
|
-
|
|
612
|
+
_context11.next = 2;
|
|
552
613
|
return _this4.result({
|
|
553
614
|
message: req.params.mid,
|
|
554
615
|
process: req.query["process-id"]
|
|
555
616
|
});
|
|
556
617
|
case 2:
|
|
557
|
-
res2 =
|
|
618
|
+
res2 = _context11.sent;
|
|
558
619
|
res.json(res2);
|
|
559
620
|
case 4:
|
|
560
621
|
case "end":
|
|
561
|
-
return
|
|
622
|
+
return _context11.stop();
|
|
562
623
|
}
|
|
563
|
-
},
|
|
624
|
+
}, _callee11);
|
|
564
625
|
}));
|
|
565
|
-
return function (
|
|
566
|
-
return
|
|
626
|
+
return function (_x21, _x22) {
|
|
627
|
+
return _ref15.apply(this, arguments);
|
|
567
628
|
};
|
|
568
629
|
}());
|
|
569
630
|
app.post("/dry-run", /*#__PURE__*/function () {
|
|
570
|
-
var
|
|
631
|
+
var _ref16 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee12(req, res) {
|
|
571
632
|
var process, _req$body2, id, owner, tags, data, res2;
|
|
572
|
-
return _regeneratorRuntime().wrap(function
|
|
573
|
-
while (1) switch (
|
|
633
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
634
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
574
635
|
case 0:
|
|
575
636
|
process = req.query["process-id"];
|
|
576
637
|
_req$body2 = req.body, id = _req$body2.Id, owner = _req$body2.Owner, tags = _req$body2.Tags, data = _req$body2.Data;
|
|
577
|
-
|
|
638
|
+
_context12.next = 4;
|
|
578
639
|
return _this4.dryrun({
|
|
579
640
|
id: id,
|
|
580
641
|
owner: owner,
|
|
@@ -583,17 +644,24 @@ var Server = /*#__PURE__*/function () {
|
|
|
583
644
|
process: process
|
|
584
645
|
});
|
|
585
646
|
case 4:
|
|
586
|
-
res2 =
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
647
|
+
res2 = _context12.sent;
|
|
648
|
+
if (!res2) {
|
|
649
|
+
res.status(500);
|
|
650
|
+
res.json({
|
|
651
|
+
err: true
|
|
652
|
+
});
|
|
653
|
+
} else {
|
|
654
|
+
delete res2.Memory;
|
|
655
|
+
res.json(res2);
|
|
656
|
+
}
|
|
657
|
+
case 6:
|
|
590
658
|
case "end":
|
|
591
|
-
return
|
|
659
|
+
return _context12.stop();
|
|
592
660
|
}
|
|
593
|
-
},
|
|
661
|
+
}, _callee12);
|
|
594
662
|
}));
|
|
595
|
-
return function (
|
|
596
|
-
return
|
|
663
|
+
return function (_x23, _x24) {
|
|
664
|
+
return _ref16.apply(this, arguments);
|
|
597
665
|
};
|
|
598
666
|
}());
|
|
599
667
|
var server = app.listen(this.ports.cu, function () {
|
|
@@ -607,11 +675,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
607
675
|
var _this5 = this;
|
|
608
676
|
return new Promise(function (res) {
|
|
609
677
|
var count = 0;
|
|
610
|
-
var
|
|
611
|
-
|
|
678
|
+
var _iterator2 = _createForOfIteratorHelper(_this5.servers),
|
|
679
|
+
_step2;
|
|
612
680
|
try {
|
|
613
|
-
for (
|
|
614
|
-
var v =
|
|
681
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
682
|
+
var v = _step2.value;
|
|
615
683
|
v.close(function () {
|
|
616
684
|
count += 1;
|
|
617
685
|
if (count >= 4) {
|
|
@@ -621,9 +689,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
621
689
|
});
|
|
622
690
|
}
|
|
623
691
|
} catch (err) {
|
|
624
|
-
|
|
692
|
+
_iterator2.e(err);
|
|
625
693
|
} finally {
|
|
626
|
-
|
|
694
|
+
_iterator2.f();
|
|
627
695
|
}
|
|
628
696
|
});
|
|
629
697
|
}
|