wao 0.5.6 → 0.6.0
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 +145 -50
- package/cjs/aoconnect.js +127 -114
- package/cjs/ar.js +14 -6
- package/cjs/armem.js +2 -1
- package/cjs/gql.js +27 -15
- package/cjs/helpers.js +217 -82
- package/cjs/lua/process.wasm +0 -0
- package/cjs/run.js +3 -1
- package/cjs/server.js +80 -153
- package/cjs/tao.js +13 -11
- package/cjs/tar.js +347 -206
- package/cjs/test.js +6 -0
- package/cjs/tgql.js +23 -8
- package/cjs/utils.js +141 -1
- package/cjs/weavedrive.js +86 -60
- package/esm/ao.js +30 -1
- package/esm/aoconnect.js +24 -15
- package/esm/ar.js +9 -3
- package/esm/armem.js +1 -0
- package/esm/gql.js +15 -6
- package/esm/helpers.js +50 -2
- package/esm/lua/process.wasm +0 -0
- package/esm/run.js +1 -1
- package/esm/server.js +30 -187
- package/esm/tao.js +7 -5
- package/esm/tar.js +125 -85
- package/esm/test.js +2 -1
- package/esm/tgql.js +12 -4
- package/esm/utils.js +227 -0
- package/esm/weavedrive.js +31 -25
- package/package.json +1 -1
package/cjs/server.js
CHANGED
|
@@ -12,109 +12,39 @@ var _utils = require("./utils.js");
|
|
|
12
12
|
var _aoconnect = require("./aoconnect.js");
|
|
13
13
|
var _test = require("./test.js");
|
|
14
14
|
var _bodyParser = _interopRequireDefault(require("body-parser"));
|
|
15
|
-
var _graphql = require("graphql");
|
|
16
15
|
var _ramda = require("ramda");
|
|
17
16
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
18
17
|
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; }
|
|
21
18
|
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; } } }; }
|
|
22
19
|
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; } }
|
|
23
20
|
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
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
24
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; }
|
|
25
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); }
|
|
26
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); }); }; }
|
|
27
27
|
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
28
28
|
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
29
29
|
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
30
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
31
30
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
32
31
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
33
|
-
var schema = (0, _graphql.buildSchema)("\n schema {\n query: Query\n }\n\n type Query {\n transactions(\n ids: [ID!]\n tags: [TagFilter!]\n block: BlockFilter\n after: String\n first: Int\n ): TransactionConnection!\n\n block(id: ID, height: Int): Block\n }\n\n type TransactionConnection {\n edges: [TransactionEdge!]!\n pageInfo: PageInfo!\n }\n\n type TransactionEdge {\n cursor: String!\n node: Transaction!\n }\n\n type Transaction {\n id: ID!\n anchor: String\n signature: String!\n recipient: String\n owner: Owner!\n fee: Quantity!\n quantity: Quantity!\n data: Data!\n tags: [Tag!]!\n block: Block\n parent: Transaction\n }\n\n type Owner {\n address: String!\n key: String!\n }\n\n type Quantity {\n winston: String!\n ar: String!\n }\n\n type Data {\n size: String!\n type: String\n }\n\n type Tag {\n name: String!\n value: String!\n }\n\n type Block {\n id: ID!\n timestamp: Int!\n height: Int!\n previous: String\n transactions: [Transaction!]!\n miner: String!\n reward: String!\n tags: [Tag!]!\n indepHash: String!\n nonce: String!\n }\n\n type PageInfo {\n hasNextPage: Boolean!\n }\n\n input TagFilter {\n name: String!\n values: [String!]!\n }\n\n input BlockFilter {\n min: Int\n max: Int\n }\n");
|
|
34
|
-
var root = {
|
|
35
|
-
transactions: function transactions(_ref) {
|
|
36
|
-
var first = _ref.first;
|
|
37
|
-
return {
|
|
38
|
-
edges: [],
|
|
39
|
-
pageInfo: {
|
|
40
|
-
hasNextPage: false
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
},
|
|
44
|
-
block: function block(_ref2) {
|
|
45
|
-
var id = _ref2.id;
|
|
46
|
-
return {
|
|
47
|
-
id: id,
|
|
48
|
-
timestamp: Date.now(),
|
|
49
|
-
height: 123456,
|
|
50
|
-
previous: "previous-block-id",
|
|
51
|
-
transactions: [],
|
|
52
|
-
miner: "example-miner",
|
|
53
|
-
reward: "1000",
|
|
54
|
-
tags: [],
|
|
55
|
-
indepHash: "example-indep-hash",
|
|
56
|
-
nonce: "000000"
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
var mapParsed = function mapParsed(parsedQuery, variables) {
|
|
61
|
-
var operation = parsedQuery.definitions[0];
|
|
62
|
-
if (operation.operation !== "query") {
|
|
63
|
-
throw new Error("Only 'query' operations are supported.");
|
|
64
|
-
}
|
|
65
|
-
var rootField = operation.selectionSet.selections[0];
|
|
66
|
-
var rootFieldName = rootField.name.value;
|
|
67
|
-
var _parseArgumentValue = function parseArgumentValue(argValue) {
|
|
68
|
-
if (argValue.kind === "Variable") {
|
|
69
|
-
return variables[argValue.name.value];
|
|
70
|
-
}
|
|
71
|
-
if (argValue.kind === "ListValue") {
|
|
72
|
-
return argValue.values.map(function (value) {
|
|
73
|
-
return _parseArgumentValue(value);
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
if (argValue.kind === "ObjectValue") {
|
|
77
|
-
return argValue.fields.reduce(function (obj, field) {
|
|
78
|
-
obj[field.name.value] = _parseArgumentValue(field.value);
|
|
79
|
-
return obj;
|
|
80
|
-
}, {});
|
|
81
|
-
}
|
|
82
|
-
return argValue.value;
|
|
83
|
-
};
|
|
84
|
-
var args = rootField.arguments.reduce(function (acc, arg) {
|
|
85
|
-
acc[arg.name.value] = _parseArgumentValue(arg.value);
|
|
86
|
-
return acc;
|
|
87
|
-
}, {});
|
|
88
|
-
var _extractFields = function extractFields(selectionSet) {
|
|
89
|
-
return selectionSet.selections.map(function (selection) {
|
|
90
|
-
var fieldName = selection.name.value;
|
|
91
|
-
if (selection.selectionSet) {
|
|
92
|
-
return _defineProperty({}, fieldName, _extractFields(selection.selectionSet));
|
|
93
|
-
}
|
|
94
|
-
return fieldName;
|
|
95
|
-
});
|
|
96
|
-
};
|
|
97
|
-
var fields = _extractFields(rootField.selectionSet);
|
|
98
|
-
return {
|
|
99
|
-
rootFieldName: rootFieldName,
|
|
100
|
-
args: args,
|
|
101
|
-
fields: fields
|
|
102
|
-
};
|
|
103
|
-
};
|
|
104
32
|
var Server = /*#__PURE__*/function () {
|
|
105
33
|
function Server() {
|
|
106
|
-
var
|
|
107
|
-
|
|
108
|
-
ar =
|
|
109
|
-
|
|
110
|
-
mu =
|
|
111
|
-
|
|
112
|
-
su =
|
|
113
|
-
|
|
114
|
-
cu =
|
|
115
|
-
aoconnect =
|
|
34
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
35
|
+
_ref$ar = _ref.ar,
|
|
36
|
+
ar = _ref$ar === void 0 ? 4000 : _ref$ar,
|
|
37
|
+
_ref$mu = _ref.mu,
|
|
38
|
+
mu = _ref$mu === void 0 ? 4002 : _ref$mu,
|
|
39
|
+
_ref$su = _ref.su,
|
|
40
|
+
su = _ref$su === void 0 ? 4003 : _ref$su,
|
|
41
|
+
_ref$cu = _ref.cu,
|
|
42
|
+
cu = _ref$cu === void 0 ? 4004 : _ref$cu,
|
|
43
|
+
aoconnect = _ref.aoconnect,
|
|
44
|
+
_ref$log = _ref.log,
|
|
45
|
+
log = _ref$log === void 0 ? false : _ref$log;
|
|
116
46
|
_classCallCheck(this, Server);
|
|
117
|
-
var _connect = (0, _aoconnect.connect)(aoconnect),
|
|
47
|
+
var _connect = (0, _aoconnect.connect)(aoconnect, log),
|
|
118
48
|
_ar = _connect.ar,
|
|
119
49
|
message = _connect.message,
|
|
120
50
|
spawn = _connect.spawn,
|
|
@@ -166,11 +96,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
166
96
|
});
|
|
167
97
|
});
|
|
168
98
|
app.get("/tx/:id/offset", /*#__PURE__*/function () {
|
|
169
|
-
var
|
|
99
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(req, res) {
|
|
170
100
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
171
101
|
while (1) switch (_context.prev = _context.next) {
|
|
172
102
|
case 0:
|
|
173
|
-
res.status(
|
|
103
|
+
res.status(400);
|
|
174
104
|
res.send(null);
|
|
175
105
|
case 2:
|
|
176
106
|
case "end":
|
|
@@ -179,11 +109,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
179
109
|
}, _callee);
|
|
180
110
|
}));
|
|
181
111
|
return function (_x, _x2) {
|
|
182
|
-
return
|
|
112
|
+
return _ref2.apply(this, arguments);
|
|
183
113
|
};
|
|
184
114
|
}());
|
|
185
115
|
app.get("/tx_anchor", /*#__PURE__*/function () {
|
|
186
|
-
var
|
|
116
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(req, res) {
|
|
187
117
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
188
118
|
while (1) switch (_context2.prev = _context2.next) {
|
|
189
119
|
case 0:
|
|
@@ -195,11 +125,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
195
125
|
}, _callee2);
|
|
196
126
|
}));
|
|
197
127
|
return function (_x3, _x4) {
|
|
198
|
-
return
|
|
128
|
+
return _ref3.apply(this, arguments);
|
|
199
129
|
};
|
|
200
130
|
}());
|
|
201
131
|
app.get("/mine", /*#__PURE__*/function () {
|
|
202
|
-
var
|
|
132
|
+
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(req, res) {
|
|
203
133
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
204
134
|
while (1) switch (_context3.prev = _context3.next) {
|
|
205
135
|
case 0:
|
|
@@ -211,11 +141,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
211
141
|
}, _callee3);
|
|
212
142
|
}));
|
|
213
143
|
return function (_x5, _x6) {
|
|
214
|
-
return
|
|
144
|
+
return _ref4.apply(this, arguments);
|
|
215
145
|
};
|
|
216
146
|
}());
|
|
217
147
|
app.get("/:id", /*#__PURE__*/function () {
|
|
218
|
-
var
|
|
148
|
+
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(req, res) {
|
|
219
149
|
var _data;
|
|
220
150
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
221
151
|
while (1) switch (_context4.prev = _context4.next) {
|
|
@@ -237,11 +167,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
237
167
|
}, _callee4);
|
|
238
168
|
}));
|
|
239
169
|
return function (_x7, _x8) {
|
|
240
|
-
return
|
|
170
|
+
return _ref5.apply(this, arguments);
|
|
241
171
|
};
|
|
242
172
|
}());
|
|
243
173
|
app.get("/price/:id", /*#__PURE__*/function () {
|
|
244
|
-
var
|
|
174
|
+
var _ref6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(req, res) {
|
|
245
175
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
246
176
|
while (1) switch (_context5.prev = _context5.next) {
|
|
247
177
|
case 0:
|
|
@@ -253,58 +183,42 @@ var Server = /*#__PURE__*/function () {
|
|
|
253
183
|
}, _callee5);
|
|
254
184
|
}));
|
|
255
185
|
return function (_x9, _x10) {
|
|
256
|
-
return
|
|
186
|
+
return _ref6.apply(this, arguments);
|
|
257
187
|
};
|
|
258
188
|
}());
|
|
259
189
|
app.post("/graphql", /*#__PURE__*/function () {
|
|
260
|
-
var
|
|
261
|
-
var _req$body, query, variables,
|
|
190
|
+
var _ref7 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(req, res) {
|
|
191
|
+
var _req$body, query, variables, _toGraphObj, tar, args, res2, edges;
|
|
262
192
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
263
193
|
while (1) switch (_context6.prev = _context6.next) {
|
|
264
194
|
case 0:
|
|
195
|
+
_context6.prev = 0;
|
|
265
196
|
_req$body = req.body, query = _req$body.query, variables = _req$body.variables;
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
tar =
|
|
270
|
-
fields = parsed.fields[0].edges[0].node;
|
|
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
|
-
}
|
|
197
|
+
_toGraphObj = (0, _utils.toGraphObj)({
|
|
198
|
+
query: query,
|
|
199
|
+
variables: variables
|
|
200
|
+
}), tar = _toGraphObj.tar, args = _toGraphObj.args;
|
|
287
201
|
res2 = null;
|
|
288
202
|
if (!(tar === "transactions")) {
|
|
289
|
-
_context6.next =
|
|
203
|
+
_context6.next = 10;
|
|
290
204
|
break;
|
|
291
205
|
}
|
|
292
|
-
_context6.next =
|
|
206
|
+
_context6.next = 7;
|
|
293
207
|
return _this.gql.txs(_objectSpread({}, args));
|
|
294
|
-
case
|
|
208
|
+
case 7:
|
|
295
209
|
res2 = _context6.sent;
|
|
296
|
-
_context6.next =
|
|
210
|
+
_context6.next = 14;
|
|
297
211
|
break;
|
|
298
|
-
case
|
|
212
|
+
case 10:
|
|
299
213
|
if (!(tar === "blocks")) {
|
|
300
|
-
_context6.next =
|
|
214
|
+
_context6.next = 14;
|
|
301
215
|
break;
|
|
302
216
|
}
|
|
303
|
-
_context6.next =
|
|
304
|
-
return _this.gql.blocks();
|
|
305
|
-
case
|
|
217
|
+
_context6.next = 13;
|
|
218
|
+
return _this.gql.blocks(_objectSpread({}, args));
|
|
219
|
+
case 13:
|
|
306
220
|
res2 = _context6.sent;
|
|
307
|
-
case
|
|
221
|
+
case 14:
|
|
308
222
|
edges = (0, _ramda.map)(function (v) {
|
|
309
223
|
return {
|
|
310
224
|
node: v,
|
|
@@ -314,23 +228,36 @@ var Server = /*#__PURE__*/function () {
|
|
|
314
228
|
res.json({
|
|
315
229
|
data: {
|
|
316
230
|
transactions: {
|
|
231
|
+
pageInfo: {
|
|
232
|
+
hasNextPage: true
|
|
233
|
+
},
|
|
317
234
|
edges: edges
|
|
318
235
|
}
|
|
319
236
|
}
|
|
320
237
|
});
|
|
321
|
-
|
|
238
|
+
_context6.next = 23;
|
|
239
|
+
break;
|
|
240
|
+
case 18:
|
|
241
|
+
_context6.prev = 18;
|
|
242
|
+
_context6.t0 = _context6["catch"](0);
|
|
243
|
+
console.log(_context6.t0);
|
|
244
|
+
res.status(400);
|
|
245
|
+
res.json({
|
|
246
|
+
error: "bad request"
|
|
247
|
+
});
|
|
248
|
+
case 23:
|
|
322
249
|
case "end":
|
|
323
250
|
return _context6.stop();
|
|
324
251
|
}
|
|
325
|
-
}, _callee6);
|
|
252
|
+
}, _callee6, null, [[0, 18]]);
|
|
326
253
|
}));
|
|
327
254
|
return function (_x11, _x12) {
|
|
328
|
-
return
|
|
255
|
+
return _ref7.apply(this, arguments);
|
|
329
256
|
};
|
|
330
257
|
}());
|
|
331
258
|
var data = {};
|
|
332
259
|
app.post("/:id", /*#__PURE__*/function () {
|
|
333
|
-
var
|
|
260
|
+
var _ref8 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(req, res) {
|
|
334
261
|
var buf;
|
|
335
262
|
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
336
263
|
while (1) switch (_context7.prev = _context7.next) {
|
|
@@ -388,7 +315,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
388
315
|
}, _callee7);
|
|
389
316
|
}));
|
|
390
317
|
return function (_x13, _x14) {
|
|
391
|
-
return
|
|
318
|
+
return _ref8.apply(this, arguments);
|
|
392
319
|
};
|
|
393
320
|
}());
|
|
394
321
|
var server = app.listen(this.ports.ar, function () {
|
|
@@ -409,7 +336,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
409
336
|
return res.send("ao messenger unit");
|
|
410
337
|
});
|
|
411
338
|
app.post("/monitor/:id", /*#__PURE__*/function () {
|
|
412
|
-
var
|
|
339
|
+
var _ref9 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(req, res) {
|
|
413
340
|
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
414
341
|
while (1) switch (_context8.prev = _context8.next) {
|
|
415
342
|
case 0:
|
|
@@ -429,11 +356,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
429
356
|
}, _callee8);
|
|
430
357
|
}));
|
|
431
358
|
return function (_x15, _x16) {
|
|
432
|
-
return
|
|
359
|
+
return _ref9.apply(this, arguments);
|
|
433
360
|
};
|
|
434
361
|
}());
|
|
435
362
|
app["delete"]("/monitor/:id", /*#__PURE__*/function () {
|
|
436
|
-
var
|
|
363
|
+
var _ref10 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(req, res) {
|
|
437
364
|
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
438
365
|
while (1) switch (_context9.prev = _context9.next) {
|
|
439
366
|
case 0:
|
|
@@ -453,11 +380,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
453
380
|
}, _callee9);
|
|
454
381
|
}));
|
|
455
382
|
return function (_x17, _x18) {
|
|
456
|
-
return
|
|
383
|
+
return _ref10.apply(this, arguments);
|
|
457
384
|
};
|
|
458
385
|
}());
|
|
459
386
|
app.post("/", /*#__PURE__*/function () {
|
|
460
|
-
var
|
|
387
|
+
var _ref11 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(req, res) {
|
|
461
388
|
var binary, valid, type, item, _tags, err;
|
|
462
389
|
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
463
390
|
while (1) switch (_context10.prev = _context10.next) {
|
|
@@ -502,7 +429,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
502
429
|
err = true;
|
|
503
430
|
case 20:
|
|
504
431
|
if (err) {
|
|
505
|
-
res.status(
|
|
432
|
+
res.status(400);
|
|
506
433
|
res.send({
|
|
507
434
|
err: err
|
|
508
435
|
});
|
|
@@ -518,7 +445,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
518
445
|
}, _callee10);
|
|
519
446
|
}));
|
|
520
447
|
return function (_x19, _x20) {
|
|
521
|
-
return
|
|
448
|
+
return _ref11.apply(this, arguments);
|
|
522
449
|
};
|
|
523
450
|
}());
|
|
524
451
|
var server = app.listen(this.ports.mu, function () {
|
|
@@ -604,7 +531,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
604
531
|
});
|
|
605
532
|
});
|
|
606
533
|
app.get("/result/:mid", /*#__PURE__*/function () {
|
|
607
|
-
var
|
|
534
|
+
var _ref12 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11(req, res) {
|
|
608
535
|
var res2;
|
|
609
536
|
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
610
537
|
while (1) switch (_context11.prev = _context11.next) {
|
|
@@ -624,11 +551,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
624
551
|
}, _callee11);
|
|
625
552
|
}));
|
|
626
553
|
return function (_x21, _x22) {
|
|
627
|
-
return
|
|
554
|
+
return _ref12.apply(this, arguments);
|
|
628
555
|
};
|
|
629
556
|
}());
|
|
630
557
|
app.post("/dry-run", /*#__PURE__*/function () {
|
|
631
|
-
var
|
|
558
|
+
var _ref13 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee12(req, res) {
|
|
632
559
|
var process, _req$body2, id, owner, tags, data, res2;
|
|
633
560
|
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
634
561
|
while (1) switch (_context12.prev = _context12.next) {
|
|
@@ -646,7 +573,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
646
573
|
case 4:
|
|
647
574
|
res2 = _context12.sent;
|
|
648
575
|
if (!res2) {
|
|
649
|
-
res.status(
|
|
576
|
+
res.status(400);
|
|
650
577
|
res.json({
|
|
651
578
|
err: true
|
|
652
579
|
});
|
|
@@ -661,7 +588,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
661
588
|
}, _callee12);
|
|
662
589
|
}));
|
|
663
590
|
return function (_x23, _x24) {
|
|
664
|
-
return
|
|
591
|
+
return _ref13.apply(this, arguments);
|
|
665
592
|
};
|
|
666
593
|
}());
|
|
667
594
|
var server = app.listen(this.ports.cu, function () {
|
|
@@ -675,11 +602,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
675
602
|
var _this5 = this;
|
|
676
603
|
return new Promise(function (res) {
|
|
677
604
|
var count = 0;
|
|
678
|
-
var
|
|
679
|
-
|
|
605
|
+
var _iterator = _createForOfIteratorHelper(_this5.servers),
|
|
606
|
+
_step;
|
|
680
607
|
try {
|
|
681
|
-
for (
|
|
682
|
-
var v =
|
|
608
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
609
|
+
var v = _step.value;
|
|
683
610
|
v.close(function () {
|
|
684
611
|
count += 1;
|
|
685
612
|
if (count >= 4) {
|
|
@@ -689,9 +616,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
689
616
|
});
|
|
690
617
|
}
|
|
691
618
|
} catch (err) {
|
|
692
|
-
|
|
619
|
+
_iterator.e(err);
|
|
693
620
|
} finally {
|
|
694
|
-
|
|
621
|
+
_iterator.f();
|
|
695
622
|
}
|
|
696
623
|
});
|
|
697
624
|
}
|
package/cjs/tao.js
CHANGED
|
@@ -115,8 +115,14 @@ var AO = /*#__PURE__*/function (_MAO) {
|
|
|
115
115
|
return spawn.apply(void 0, _args2);
|
|
116
116
|
case 2:
|
|
117
117
|
res = _context2.sent;
|
|
118
|
+
_context2.next = 5;
|
|
119
|
+
return _this.load({
|
|
120
|
+
data: log,
|
|
121
|
+
pid: res
|
|
122
|
+
});
|
|
123
|
+
case 5:
|
|
118
124
|
return _context2.abrupt("return", res);
|
|
119
|
-
case
|
|
125
|
+
case 6:
|
|
120
126
|
case "end":
|
|
121
127
|
return _context2.stop();
|
|
122
128
|
}
|
|
@@ -176,7 +182,7 @@ var AO = /*#__PURE__*/function (_MAO) {
|
|
|
176
182
|
key: "postModule",
|
|
177
183
|
value: function () {
|
|
178
184
|
var _postModule = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(_ref4) {
|
|
179
|
-
var data, _ref4$tags, tags, jwk, err, _yield$this$ar$checkW, t,
|
|
185
|
+
var data, _ref4$tags, tags, jwk, err, _yield$this$ar$checkW, t, signer, _yield$this$ar$datait, id, owner, item;
|
|
180
186
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
181
187
|
while (1) switch (_context5.prev = _context5.next) {
|
|
182
188
|
case 0:
|
|
@@ -208,24 +214,20 @@ var AO = /*#__PURE__*/function (_MAO) {
|
|
|
208
214
|
"Memory-Limit": "1-gb",
|
|
209
215
|
"Compute-Limit": "9000000000000"
|
|
210
216
|
});
|
|
211
|
-
_tags = (0, _utils.buildTags)(null, t);
|
|
212
217
|
signer = (0, _aoconnect.createDataItemSigner)(jwk);
|
|
213
|
-
_context5.next =
|
|
218
|
+
_context5.next = 13;
|
|
214
219
|
return this.ar.dataitem({
|
|
215
|
-
tags:
|
|
220
|
+
tags: t,
|
|
216
221
|
data: data,
|
|
217
222
|
signer: signer
|
|
218
223
|
});
|
|
219
|
-
case
|
|
224
|
+
case 13:
|
|
220
225
|
_yield$this$ar$datait = _context5.sent;
|
|
221
226
|
id = _yield$this$ar$datait.id;
|
|
222
227
|
owner = _yield$this$ar$datait.owner;
|
|
228
|
+
item = _yield$this$ar$datait.item;
|
|
223
229
|
_context5.next = 19;
|
|
224
|
-
return this.ar.
|
|
225
|
-
data: data,
|
|
226
|
-
tags: t,
|
|
227
|
-
jwk: jwk
|
|
228
|
-
});
|
|
230
|
+
return this.ar.postItems(item, jwk);
|
|
229
231
|
case 19:
|
|
230
232
|
this.mem.wasms[id] = {
|
|
231
233
|
data: data,
|