wao 0.6.3 → 0.7.1
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/aoconnect.js +50 -34
- package/cjs/run.js +5 -1
- package/cjs/server.js +37 -17
- package/cjs/tao.js +1 -5
- package/cjs/tar.js +31 -18
- package/cjs/weavedrive.js +2 -4
- package/esm/.db/885449/data/ppl/bob.json +1 -0
- package/esm/.db/929039/data/ppl/bob.json +1 -0
- package/esm/aoconnect.js +12 -9
- package/esm/run.js +3 -1
- package/esm/server.js +21 -2
- package/esm/tao.js +0 -1
- package/esm/tar.js +15 -5
- package/esm/weavedrive.js +2 -6
- package/package.json +1 -1
package/cjs/aoconnect.js
CHANGED
|
@@ -38,9 +38,10 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
38
38
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
39
39
|
var pkg = (_WarpArBundles$defaul = WarpArBundles["default"]) !== null && _WarpArBundles$defaul !== void 0 ? _WarpArBundles$defaul : WarpArBundles;
|
|
40
40
|
var DataItem = pkg.DataItem;
|
|
41
|
-
var connect = exports.connect = function connect(mem
|
|
41
|
+
var connect = exports.connect = function connect(mem) {
|
|
42
42
|
var _mem;
|
|
43
|
-
var _ref
|
|
43
|
+
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
44
|
+
_ref$log = _ref.log,
|
|
44
45
|
log = _ref$log === void 0 ? false : _ref$log,
|
|
45
46
|
_ref$extensions = _ref.extensions,
|
|
46
47
|
extensions = _ref$extensions === void 0 ? {} : _ref$extensions;
|
|
@@ -167,6 +168,7 @@ var connect = exports.connect = function connect(mem, _ref) {
|
|
|
167
168
|
__tags,
|
|
168
169
|
now,
|
|
169
170
|
t,
|
|
171
|
+
wdrive,
|
|
170
172
|
handle,
|
|
171
173
|
_tags,
|
|
172
174
|
res,
|
|
@@ -275,16 +277,30 @@ var connect = exports.connect = function connect(mem, _ref) {
|
|
|
275
277
|
case 33:
|
|
276
278
|
now = Date.now;
|
|
277
279
|
t = (0, _utils.tags)(opt.tags);
|
|
278
|
-
|
|
280
|
+
wdrive = extensions[t.Extension || "WeaveDrive"];
|
|
281
|
+
handle = null;
|
|
282
|
+
_context.prev = 37;
|
|
283
|
+
_context.next = 40;
|
|
279
284
|
return (0, _aoLoader["default"])(wasm, {
|
|
280
285
|
format: format,
|
|
281
|
-
WeaveDrive:
|
|
286
|
+
WeaveDrive: wdrive,
|
|
282
287
|
spawn: item,
|
|
283
|
-
module: mem.txs[mod]
|
|
284
|
-
blockHeight: "100"
|
|
288
|
+
module: mem.txs[mod]
|
|
285
289
|
});
|
|
286
|
-
case
|
|
290
|
+
case 40:
|
|
287
291
|
handle = _context.sent;
|
|
292
|
+
_context.next = 45;
|
|
293
|
+
break;
|
|
294
|
+
case 43:
|
|
295
|
+
_context.prev = 43;
|
|
296
|
+
_context.t0 = _context["catch"](37);
|
|
297
|
+
case 45:
|
|
298
|
+
if (handle) {
|
|
299
|
+
_context.next = 47;
|
|
300
|
+
break;
|
|
301
|
+
}
|
|
302
|
+
return _context.abrupt("return", null);
|
|
303
|
+
case 47:
|
|
288
304
|
_module = {
|
|
289
305
|
handle: handle,
|
|
290
306
|
id: mod
|
|
@@ -308,7 +324,7 @@ var connect = exports.connect = function connect(mem, _ref) {
|
|
|
308
324
|
opt: opt
|
|
309
325
|
};
|
|
310
326
|
if (!(_tags["On-Boot"] || true)) {
|
|
311
|
-
_context.next =
|
|
327
|
+
_context.next = 67;
|
|
312
328
|
break;
|
|
313
329
|
}
|
|
314
330
|
data = "";
|
|
@@ -321,51 +337,51 @@ var connect = exports.connect = function connect(mem, _ref) {
|
|
|
321
337
|
auth: _test.mu.addr
|
|
322
338
|
});
|
|
323
339
|
_t = (0, _utils.tags)(msg.Tags);
|
|
324
|
-
_context.next =
|
|
340
|
+
_context.next = 61;
|
|
325
341
|
return _module.handle(null, msg, _env);
|
|
326
|
-
case
|
|
342
|
+
case 61:
|
|
327
343
|
res = _context.sent;
|
|
328
344
|
p.memory = res.Memory;
|
|
329
345
|
delete res.Memory;
|
|
330
346
|
p.res[id] = res;
|
|
331
|
-
_context.next =
|
|
347
|
+
_context.next = 68;
|
|
332
348
|
break;
|
|
333
|
-
case
|
|
349
|
+
case 67:
|
|
334
350
|
p.height += 1;
|
|
335
|
-
case
|
|
351
|
+
case 68:
|
|
336
352
|
mem.msgs[id] = opt;
|
|
337
353
|
mem.env[id] = p;
|
|
338
354
|
if (!_tags["Cron-Interval"]) {
|
|
339
|
-
_context.next =
|
|
355
|
+
_context.next = 94;
|
|
340
356
|
break;
|
|
341
357
|
}
|
|
342
358
|
_tags$CronInterval$s = _tags["Cron-Interval"].split("-"), _tags$CronInterval$s2 = _slicedToArray(_tags$CronInterval$s, 2), num = _tags$CronInterval$s2[0], unit = _tags$CronInterval$s2[1];
|
|
343
359
|
_int = 0;
|
|
344
|
-
_context.
|
|
345
|
-
_context.next = _context.
|
|
360
|
+
_context.t1 = unit.replace(/s$/, "");
|
|
361
|
+
_context.next = _context.t1 === "millisecond" ? 76 : _context.t1 === "second" ? 78 : _context.t1 === "minute" ? 80 : _context.t1 === "hour" ? 82 : _context.t1 === "day" ? 84 : _context.t1 === "month" ? 86 : _context.t1 === "year" ? 88 : 90;
|
|
346
362
|
break;
|
|
347
|
-
case
|
|
363
|
+
case 76:
|
|
348
364
|
_int = num;
|
|
349
|
-
return _context.abrupt("break",
|
|
350
|
-
case
|
|
365
|
+
return _context.abrupt("break", 90);
|
|
366
|
+
case 78:
|
|
351
367
|
_int = num * 1000;
|
|
352
|
-
return _context.abrupt("break",
|
|
353
|
-
case
|
|
368
|
+
return _context.abrupt("break", 90);
|
|
369
|
+
case 80:
|
|
354
370
|
_int = num * 1000 * 60;
|
|
355
|
-
return _context.abrupt("break",
|
|
356
|
-
case
|
|
371
|
+
return _context.abrupt("break", 90);
|
|
372
|
+
case 82:
|
|
357
373
|
_int = num * 1000 * 60 * 60;
|
|
358
|
-
return _context.abrupt("break",
|
|
359
|
-
case
|
|
374
|
+
return _context.abrupt("break", 90);
|
|
375
|
+
case 84:
|
|
360
376
|
_int = num * 1000 * 60 * 60 * 24;
|
|
361
|
-
return _context.abrupt("break",
|
|
362
|
-
case
|
|
377
|
+
return _context.abrupt("break", 90);
|
|
378
|
+
case 86:
|
|
363
379
|
_int = num * 1000 * 60 * 60 * 24 * 30;
|
|
364
|
-
return _context.abrupt("break",
|
|
365
|
-
case
|
|
380
|
+
return _context.abrupt("break", 90);
|
|
381
|
+
case 88:
|
|
366
382
|
_int = num * 1000 * 60 * 60 * 24 * 365;
|
|
367
|
-
return _context.abrupt("break",
|
|
368
|
-
case
|
|
383
|
+
return _context.abrupt("break", 90);
|
|
384
|
+
case 90:
|
|
369
385
|
cronTags = [];
|
|
370
386
|
for (_k in _tags) {
|
|
371
387
|
if (/^Cron-Tag-/.test(_k)) {
|
|
@@ -377,13 +393,13 @@ var connect = exports.connect = function connect(mem, _ref) {
|
|
|
377
393
|
}
|
|
378
394
|
mem.env[id].cronTags = cronTags;
|
|
379
395
|
mem.env[id].span = _int;
|
|
380
|
-
case
|
|
396
|
+
case 94:
|
|
381
397
|
return _context.abrupt("return", id);
|
|
382
|
-
case
|
|
398
|
+
case 95:
|
|
383
399
|
case "end":
|
|
384
400
|
return _context.stop();
|
|
385
401
|
}
|
|
386
|
-
}, _callee);
|
|
402
|
+
}, _callee, null, [[37, 43]]);
|
|
387
403
|
}));
|
|
388
404
|
return function spawn() {
|
|
389
405
|
return _ref5.apply(this, arguments);
|
package/cjs/run.js
CHANGED
|
@@ -2,18 +2,22 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
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); }
|
|
5
|
+
var _yargs = _interopRequireDefault(require("yargs"));
|
|
5
6
|
var _server = _interopRequireDefault(require("./server.js"));
|
|
6
7
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
7
8
|
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; }
|
|
8
9
|
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); }
|
|
9
10
|
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); }); }; }
|
|
11
|
+
var _yargs$argv$port = (0, _yargs["default"])(process.argv.slice(2)).argv.port,
|
|
12
|
+
port = _yargs$argv$port === void 0 ? 4000 : _yargs$argv$port;
|
|
10
13
|
var main = /*#__PURE__*/function () {
|
|
11
14
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
12
15
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
13
16
|
while (1) switch (_context.prev = _context.next) {
|
|
14
17
|
case 0:
|
|
15
18
|
return _context.abrupt("return", new _server["default"]({
|
|
16
|
-
log: true
|
|
19
|
+
log: true,
|
|
20
|
+
port: port
|
|
17
21
|
}));
|
|
18
22
|
case 1:
|
|
19
23
|
case "end":
|
package/cjs/server.js
CHANGED
|
@@ -42,8 +42,16 @@ var Server = /*#__PURE__*/function () {
|
|
|
42
42
|
cu = _ref$cu === void 0 ? 4004 : _ref$cu,
|
|
43
43
|
aoconnect = _ref.aoconnect,
|
|
44
44
|
_ref$log = _ref.log,
|
|
45
|
-
log = _ref$log === void 0 ? false : _ref$log
|
|
45
|
+
log = _ref$log === void 0 ? false : _ref$log,
|
|
46
|
+
port = _ref.port;
|
|
46
47
|
_classCallCheck(this, Server);
|
|
48
|
+
if (port) {
|
|
49
|
+
ar = port;
|
|
50
|
+
mu = port + 2;
|
|
51
|
+
su = port + 3;
|
|
52
|
+
cu = port + 4;
|
|
53
|
+
aoconnect = (0, _utils.optAO)(5000);
|
|
54
|
+
}
|
|
47
55
|
var _connect = (0, _aoconnect.connect)(aoconnect, {
|
|
48
56
|
log: log
|
|
49
57
|
}),
|
|
@@ -89,6 +97,15 @@ var Server = /*#__PURE__*/function () {
|
|
|
89
97
|
app.use(_bodyParser["default"].json({
|
|
90
98
|
limit: "100mb"
|
|
91
99
|
}));
|
|
100
|
+
app.get("/", function (req, res) {
|
|
101
|
+
return res.json({
|
|
102
|
+
version: 1,
|
|
103
|
+
timestamp: Date.now(),
|
|
104
|
+
height: _this.mem.height,
|
|
105
|
+
network: "wao.LN.1",
|
|
106
|
+
current: _this.mem.getAnchor()
|
|
107
|
+
});
|
|
108
|
+
});
|
|
92
109
|
app.get("/wallet/:id/balance", function (req, res) {
|
|
93
110
|
return res.send("0");
|
|
94
111
|
});
|
|
@@ -293,7 +310,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
293
310
|
res.json({
|
|
294
311
|
id: req.body.id
|
|
295
312
|
});
|
|
296
|
-
_context7.next =
|
|
313
|
+
_context7.next = 22;
|
|
297
314
|
break;
|
|
298
315
|
case 14:
|
|
299
316
|
if (!(req.body.data_root && req.body.data === "")) {
|
|
@@ -301,16 +318,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
301
318
|
break;
|
|
302
319
|
}
|
|
303
320
|
data[req.body.data_root] = req.body;
|
|
304
|
-
_context7.next =
|
|
321
|
+
_context7.next = 21;
|
|
305
322
|
break;
|
|
306
323
|
case 18:
|
|
307
|
-
|
|
324
|
+
console.log("or here...", req.body);
|
|
325
|
+
_context7.next = 21;
|
|
308
326
|
return _this._ar.postTx(req.body);
|
|
309
|
-
case
|
|
327
|
+
case 21:
|
|
310
328
|
res.json({
|
|
311
329
|
id: req.body.id
|
|
312
330
|
});
|
|
313
|
-
case
|
|
331
|
+
case 22:
|
|
314
332
|
case "end":
|
|
315
333
|
return _context7.stop();
|
|
316
334
|
}
|
|
@@ -387,7 +405,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
387
405
|
}());
|
|
388
406
|
app.post("/", /*#__PURE__*/function () {
|
|
389
407
|
var _ref11 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(req, res) {
|
|
390
|
-
var binary, valid, type, item, _tags, err;
|
|
408
|
+
var binary, valid, type, item, _tags, err, _res;
|
|
391
409
|
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
392
410
|
while (1) switch (_context10.prev = _context10.next) {
|
|
393
411
|
case 0:
|
|
@@ -402,7 +420,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
402
420
|
_tags = (0, _utils.tags)(item.tags);
|
|
403
421
|
err = null;
|
|
404
422
|
if (!(_tags.Type === "Process")) {
|
|
405
|
-
_context10.next =
|
|
423
|
+
_context10.next = 16;
|
|
406
424
|
break;
|
|
407
425
|
}
|
|
408
426
|
_context10.next = 12;
|
|
@@ -412,24 +430,26 @@ var Server = /*#__PURE__*/function () {
|
|
|
412
430
|
scheduler: _tags.Scheduler
|
|
413
431
|
});
|
|
414
432
|
case 12:
|
|
415
|
-
|
|
433
|
+
_res = _context10.sent;
|
|
434
|
+
if (!_res) err = "bad requrest";
|
|
435
|
+
_context10.next = 22;
|
|
416
436
|
break;
|
|
417
|
-
case
|
|
437
|
+
case 16:
|
|
418
438
|
if (!(_tags.Type === "Message")) {
|
|
419
|
-
_context10.next =
|
|
439
|
+
_context10.next = 21;
|
|
420
440
|
break;
|
|
421
441
|
}
|
|
422
|
-
_context10.next =
|
|
442
|
+
_context10.next = 19;
|
|
423
443
|
return _this2.message({
|
|
424
444
|
item: item,
|
|
425
445
|
process: item.target
|
|
426
446
|
});
|
|
427
|
-
case 17:
|
|
428
|
-
_context10.next = 20;
|
|
429
|
-
break;
|
|
430
447
|
case 19:
|
|
448
|
+
_context10.next = 22;
|
|
449
|
+
break;
|
|
450
|
+
case 21:
|
|
431
451
|
err = true;
|
|
432
|
-
case
|
|
452
|
+
case 22:
|
|
433
453
|
if (err) {
|
|
434
454
|
res.status(400);
|
|
435
455
|
res.send({
|
|
@@ -440,7 +460,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
440
460
|
id: item.id
|
|
441
461
|
});
|
|
442
462
|
}
|
|
443
|
-
case
|
|
463
|
+
case 23:
|
|
444
464
|
case "end":
|
|
445
465
|
return _context10.stop();
|
|
446
466
|
}
|
package/cjs/tao.js
CHANGED
|
@@ -231,14 +231,10 @@ var AO = /*#__PURE__*/function (_MAO) {
|
|
|
231
231
|
_context5.next = 19;
|
|
232
232
|
return this.ar.postItems(item, jwk);
|
|
233
233
|
case 19:
|
|
234
|
-
this.mem.wasms[id] = {
|
|
235
|
-
data: data,
|
|
236
|
-
format: t["Module-Format"]
|
|
237
|
-
};
|
|
238
234
|
return _context5.abrupt("return", {
|
|
239
235
|
id: id
|
|
240
236
|
});
|
|
241
|
-
case
|
|
237
|
+
case 20:
|
|
242
238
|
case "end":
|
|
243
239
|
return _context5.stop();
|
|
244
240
|
}
|
package/cjs/tar.js
CHANGED
|
@@ -265,7 +265,7 @@ var AR = /*#__PURE__*/function (_MAR) {
|
|
|
265
265
|
};
|
|
266
266
|
data = di.data;
|
|
267
267
|
try {
|
|
268
|
-
data =
|
|
268
|
+
//data = base64url.decode(di.data)
|
|
269
269
|
} catch (e) {}
|
|
270
270
|
_context4.t0 = {
|
|
271
271
|
size: data_size,
|
|
@@ -364,6 +364,7 @@ var AR = /*#__PURE__*/function (_MAR) {
|
|
|
364
364
|
_iterator6,
|
|
365
365
|
_step6,
|
|
366
366
|
_v,
|
|
367
|
+
__tags,
|
|
367
368
|
owner,
|
|
368
369
|
_args5 = arguments;
|
|
369
370
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
@@ -462,12 +463,19 @@ var AR = /*#__PURE__*/function (_MAR) {
|
|
|
462
463
|
} finally {
|
|
463
464
|
_iterator6.f();
|
|
464
465
|
}
|
|
466
|
+
__tags = (0, _utils.tags)(_tags);
|
|
467
|
+
if (__tags.Type === "Module") {
|
|
468
|
+
this.mem.wasms[tx.id] = {
|
|
469
|
+
data: Buffer.from(tx.data, "base64"),
|
|
470
|
+
format: __tags["Module-Format"]
|
|
471
|
+
};
|
|
472
|
+
}
|
|
465
473
|
tx.tags = _tags;
|
|
466
|
-
_context5.next =
|
|
474
|
+
_context5.next = 25;
|
|
467
475
|
return this.arweave.wallets.jwkToAddress({
|
|
468
476
|
n: tx.owner
|
|
469
477
|
});
|
|
470
|
-
case
|
|
478
|
+
case 25:
|
|
471
479
|
tx.owner = _context5.sent;
|
|
472
480
|
this.mem.txs[tx.id] = tx;
|
|
473
481
|
block.txs.push(tx.id);
|
|
@@ -475,18 +483,18 @@ var AR = /*#__PURE__*/function (_MAR) {
|
|
|
475
483
|
this.mem.blocks.push(block.id);
|
|
476
484
|
this.mem.blockmap[block.id] = block;
|
|
477
485
|
if (!jwk) {
|
|
478
|
-
_context5.next =
|
|
486
|
+
_context5.next = 36;
|
|
479
487
|
break;
|
|
480
488
|
}
|
|
481
|
-
_context5.next =
|
|
489
|
+
_context5.next = 34;
|
|
482
490
|
return this.arweave.wallets.jwkToAddress(jwk);
|
|
483
|
-
case
|
|
491
|
+
case 34:
|
|
484
492
|
owner = _context5.sent;
|
|
485
493
|
this.mem.addrmap[owner] = {
|
|
486
494
|
address: owner,
|
|
487
495
|
key: jwk.n
|
|
488
496
|
};
|
|
489
|
-
case
|
|
497
|
+
case 36:
|
|
490
498
|
res = {
|
|
491
499
|
id: tx.id,
|
|
492
500
|
status: 200,
|
|
@@ -504,7 +512,7 @@ var AR = /*#__PURE__*/function (_MAR) {
|
|
|
504
512
|
err: err,
|
|
505
513
|
id: tx.id
|
|
506
514
|
});
|
|
507
|
-
case
|
|
515
|
+
case 39:
|
|
508
516
|
case "end":
|
|
509
517
|
return _context5.stop();
|
|
510
518
|
}
|
|
@@ -537,7 +545,7 @@ var AR = /*#__PURE__*/function (_MAR) {
|
|
|
537
545
|
}, {
|
|
538
546
|
key: "data",
|
|
539
547
|
value: function () {
|
|
540
|
-
var _data2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(id, _string) {
|
|
548
|
+
var _data2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(id, _string, log) {
|
|
541
549
|
var _tx$data;
|
|
542
550
|
var decode, string, tx, _data, isBuf, isStr;
|
|
543
551
|
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
@@ -551,35 +559,40 @@ var AR = /*#__PURE__*/function (_MAR) {
|
|
|
551
559
|
}
|
|
552
560
|
tx = this.mem.txs[id];
|
|
553
561
|
_data = (_tx$data = tx === null || tx === void 0 ? void 0 : tx.data) !== null && _tx$data !== void 0 ? _tx$data : null;
|
|
562
|
+
if ((tx === null || tx === void 0 ? void 0 : tx.format) === 2 && _data) {
|
|
563
|
+
_data = Buffer.from(_data, "base64");
|
|
564
|
+
} else {
|
|
565
|
+
_data = Buffer.from(_base64url["default"].decode(_data));
|
|
566
|
+
}
|
|
554
567
|
isBuf = (0, _ramda.is)(Uint8Array, _data) || (0, _ramda.is)(ArrayBuffer, _data);
|
|
555
568
|
isStr = (0, _ramda.is)(String, _data);
|
|
556
569
|
if (!(decode === false)) {
|
|
557
|
-
_context7.next =
|
|
570
|
+
_context7.next = 13;
|
|
558
571
|
break;
|
|
559
572
|
}
|
|
560
573
|
if (isStr) _data = new TextEncoder().encode(_data);
|
|
561
574
|
return _context7.abrupt("return", _base64url["default"].encode(_data));
|
|
562
|
-
case
|
|
575
|
+
case 13:
|
|
563
576
|
if (!(isBuf && string)) {
|
|
564
|
-
_context7.next =
|
|
577
|
+
_context7.next = 17;
|
|
565
578
|
break;
|
|
566
579
|
}
|
|
567
|
-
return _context7.abrupt("return",
|
|
568
|
-
case
|
|
580
|
+
return _context7.abrupt("return", _data.toString());
|
|
581
|
+
case 17:
|
|
569
582
|
if (!(isStr && string !== true)) {
|
|
570
|
-
_context7.next =
|
|
583
|
+
_context7.next = 19;
|
|
571
584
|
break;
|
|
572
585
|
}
|
|
573
586
|
return _context7.abrupt("return", new TextEncoder().encode(_data));
|
|
574
|
-
case 18:
|
|
575
|
-
return _context7.abrupt("return", _data);
|
|
576
587
|
case 19:
|
|
588
|
+
return _context7.abrupt("return", _data);
|
|
589
|
+
case 20:
|
|
577
590
|
case "end":
|
|
578
591
|
return _context7.stop();
|
|
579
592
|
}
|
|
580
593
|
}, _callee7, this);
|
|
581
594
|
}));
|
|
582
|
-
function data(_x9, _x10) {
|
|
595
|
+
function data(_x9, _x10, _x11) {
|
|
583
596
|
return _data2.apply(this, arguments);
|
|
584
597
|
}
|
|
585
598
|
return data;
|
package/cjs/weavedrive.js
CHANGED
|
@@ -317,9 +317,7 @@ var WeaveDrive = exports["default"] = /*#__PURE__*/_createClass(function WeaveDr
|
|
|
317
317
|
dst_ptr = Number(raw_dst_ptr);
|
|
318
318
|
stream = 0;
|
|
319
319
|
for (i = 0; i < FS.streams.length; i++) {
|
|
320
|
-
if (FS.streams[i].fd === fd)
|
|
321
|
-
stream = FS.streams[i];
|
|
322
|
-
}
|
|
320
|
+
if (FS.streams[i].fd === fd) stream = FS.streams[i];
|
|
323
321
|
}
|
|
324
322
|
// read block headers
|
|
325
323
|
if (!stream.path.includes("/block")) {
|
|
@@ -357,7 +355,7 @@ var WeaveDrive = exports["default"] = /*#__PURE__*/_createClass(function WeaveDr
|
|
|
357
355
|
to = Math.min(stream.node.total_size, stream.position + chunk_download_sz); //console.log("WeaveDrive: fd: ", fd, " Read length: ", to_read, " Reading ahead:", to - to_read - stream.position)
|
|
358
356
|
// fetch(`/${stream.node.name}`)
|
|
359
357
|
_context6.next = 21;
|
|
360
|
-
return ar.data(stream.node.name);
|
|
358
|
+
return ar.data(stream.node.name, null, log);
|
|
361
359
|
case 21:
|
|
362
360
|
data = _context6.sent;
|
|
363
361
|
// Extract the Range header to determine the start and end of the requested chunk
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"Bob","age":40}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"Bob","age":40}
|
package/esm/aoconnect.js
CHANGED
|
@@ -23,7 +23,7 @@ import { scheduler, mu, su, cu, acc } from "./test.js"
|
|
|
23
23
|
import { is, clone, fromPairs, map, mergeLeft, isNil } from "ramda"
|
|
24
24
|
import AR from "./tar.js"
|
|
25
25
|
|
|
26
|
-
export const connect = (mem, { log = false, extensions = {} }) => {
|
|
26
|
+
export const connect = (mem, { log = false, extensions = {} } = {}) => {
|
|
27
27
|
const isMem = mem?.__type__ === "mem"
|
|
28
28
|
if (!isMem) {
|
|
29
29
|
let args = {}
|
|
@@ -151,13 +151,17 @@ export const connect = (mem, { log = false, extensions = {} }) => {
|
|
|
151
151
|
await ar.postItems(item, su.jwk)
|
|
152
152
|
const now = Date.now
|
|
153
153
|
const t = tags(opt.tags)
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
154
|
+
const wdrive = extensions[t.Extension || "WeaveDrive"]
|
|
155
|
+
let handle = null
|
|
156
|
+
try {
|
|
157
|
+
handle = await AoLoader(wasm, {
|
|
158
|
+
format,
|
|
159
|
+
WeaveDrive: wdrive,
|
|
160
|
+
spawn: item,
|
|
161
|
+
module: mem.txs[mod],
|
|
162
|
+
})
|
|
163
|
+
} catch (e) {}
|
|
164
|
+
if (!handle) return null
|
|
161
165
|
_module = { handle, id: mod }
|
|
162
166
|
Date.now = now
|
|
163
167
|
|
|
@@ -189,7 +193,6 @@ export const connect = (mem, { log = false, extensions = {} }) => {
|
|
|
189
193
|
module: p.module,
|
|
190
194
|
auth: mu.addr,
|
|
191
195
|
})
|
|
192
|
-
|
|
193
196
|
const _t = tags(msg.Tags)
|
|
194
197
|
res = await _module.handle(null, msg, _env)
|
|
195
198
|
p.memory = res.Memory
|
package/esm/run.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env -S node --experimental-wasm-memory64
|
|
2
|
+
import yargs from "yargs"
|
|
3
|
+
let { port = 4000 } = yargs(process.argv.slice(2)).argv
|
|
2
4
|
|
|
3
5
|
import Server from "./server.js"
|
|
4
6
|
|
|
5
|
-
const main = async () => new Server({ log: true })
|
|
7
|
+
const main = async () => new Server({ log: true, port })
|
|
6
8
|
|
|
7
9
|
main()
|
package/esm/server.js
CHANGED
|
@@ -2,7 +2,7 @@ import express from "express"
|
|
|
2
2
|
import cors from "cors"
|
|
3
3
|
import base64url from "base64url"
|
|
4
4
|
import { DataItem } from "arbundles"
|
|
5
|
-
import { tags, toGraphObj } from "./utils.js"
|
|
5
|
+
import { tags, toGraphObj, optAO } from "./utils.js"
|
|
6
6
|
import { connect } from "./aoconnect.js"
|
|
7
7
|
import { GQL, cu, su, mu } from "./test.js"
|
|
8
8
|
import bodyParser from "body-parser"
|
|
@@ -16,7 +16,15 @@ class Server {
|
|
|
16
16
|
cu = 4004,
|
|
17
17
|
aoconnect,
|
|
18
18
|
log = false,
|
|
19
|
+
port,
|
|
19
20
|
} = {}) {
|
|
21
|
+
if (port) {
|
|
22
|
+
ar = port
|
|
23
|
+
mu = port + 2
|
|
24
|
+
su = port + 3
|
|
25
|
+
cu = port + 4
|
|
26
|
+
aoconnect = optAO(5000)
|
|
27
|
+
}
|
|
20
28
|
const {
|
|
21
29
|
ar: _ar,
|
|
22
30
|
message,
|
|
@@ -49,6 +57,15 @@ class Server {
|
|
|
49
57
|
const app = express()
|
|
50
58
|
app.use(cors())
|
|
51
59
|
app.use(bodyParser.json({ limit: "100mb" }))
|
|
60
|
+
app.get("/", (req, res) =>
|
|
61
|
+
res.json({
|
|
62
|
+
version: 1,
|
|
63
|
+
timestamp: Date.now(),
|
|
64
|
+
height: this.mem.height,
|
|
65
|
+
network: "wao.LN.1",
|
|
66
|
+
current: this.mem.getAnchor(),
|
|
67
|
+
}),
|
|
68
|
+
)
|
|
52
69
|
app.get("/wallet/:id/balance", (req, res) => res.send("0"))
|
|
53
70
|
app.get("/mint/:id/:amount", (req, res) => res.json({ id: "0" }))
|
|
54
71
|
app.get("/tx/:id/offset", async (req, res) => {
|
|
@@ -124,6 +141,7 @@ class Server {
|
|
|
124
141
|
if (req.body.data_root && req.body.data === "") {
|
|
125
142
|
data[req.body.data_root] = req.body
|
|
126
143
|
} else {
|
|
144
|
+
console.log("or here...", req.body)
|
|
127
145
|
await this._ar.postTx(req.body)
|
|
128
146
|
}
|
|
129
147
|
res.json({ id: req.body.id })
|
|
@@ -157,11 +175,12 @@ class Server {
|
|
|
157
175
|
const _tags = tags(item.tags)
|
|
158
176
|
let err = null
|
|
159
177
|
if (_tags.Type === "Process") {
|
|
160
|
-
await this.spawn({
|
|
178
|
+
const res = await this.spawn({
|
|
161
179
|
item,
|
|
162
180
|
module: _tags.Module,
|
|
163
181
|
scheduler: _tags.Scheduler,
|
|
164
182
|
})
|
|
183
|
+
if (!res) err = "bad requrest"
|
|
165
184
|
} else if (_tags.Type === "Message") {
|
|
166
185
|
await this.message({ item, process: item.target })
|
|
167
186
|
} else {
|
package/esm/tao.js
CHANGED
package/esm/tar.js
CHANGED
|
@@ -63,7 +63,7 @@ class AR extends MAR {
|
|
|
63
63
|
this.mem.addrmap[owner] = { key: di.owner, address: owner }
|
|
64
64
|
let data = di.data
|
|
65
65
|
try {
|
|
66
|
-
data = base64url.decode(di.data)
|
|
66
|
+
//data = base64url.decode(di.data)
|
|
67
67
|
} catch (e) {}
|
|
68
68
|
let _item = {
|
|
69
69
|
_data: { size: data_size, type: data_type },
|
|
@@ -134,7 +134,6 @@ class AR extends MAR {
|
|
|
134
134
|
this.mem.txs[item.id].block = block.id
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
|
-
|
|
138
137
|
let _tags = []
|
|
139
138
|
for (const v of tx.tags) {
|
|
140
139
|
_tags.push({
|
|
@@ -142,6 +141,13 @@ class AR extends MAR {
|
|
|
142
141
|
value: base64url.decode(v.value),
|
|
143
142
|
})
|
|
144
143
|
}
|
|
144
|
+
const __tags = t(_tags)
|
|
145
|
+
if (__tags.Type === "Module") {
|
|
146
|
+
this.mem.wasms[tx.id] = {
|
|
147
|
+
data: Buffer.from(tx.data, "base64"),
|
|
148
|
+
format: __tags["Module-Format"],
|
|
149
|
+
}
|
|
150
|
+
}
|
|
145
151
|
tx.tags = _tags
|
|
146
152
|
tx.owner = await this.arweave.wallets.jwkToAddress({ n: tx.owner })
|
|
147
153
|
this.mem.txs[tx.id] = tx
|
|
@@ -171,16 +177,20 @@ class AR extends MAR {
|
|
|
171
177
|
return this.mem.txs[id]
|
|
172
178
|
}
|
|
173
179
|
|
|
174
|
-
async data(id, _string) {
|
|
180
|
+
async data(id, _string, log) {
|
|
175
181
|
let decode = true
|
|
176
182
|
let string = _string
|
|
177
183
|
if (is(Object, _string)) {
|
|
178
184
|
if (!isNil(_string.decode)) decode = _string.decode
|
|
179
185
|
if (!isNil(_string.string)) string = _string.string
|
|
180
186
|
}
|
|
181
|
-
|
|
182
187
|
let tx = this.mem.txs[id]
|
|
183
188
|
let _data = tx?.data ?? null
|
|
189
|
+
if (tx?.format === 2 && _data) {
|
|
190
|
+
_data = Buffer.from(_data, "base64")
|
|
191
|
+
} else {
|
|
192
|
+
_data = Buffer.from(base64url.decode(_data))
|
|
193
|
+
}
|
|
184
194
|
let isBuf = is(Uint8Array, _data) || is(ArrayBuffer, _data)
|
|
185
195
|
let isStr = is(String, _data)
|
|
186
196
|
if (decode === false) {
|
|
@@ -188,7 +198,7 @@ class AR extends MAR {
|
|
|
188
198
|
return base64url.encode(_data)
|
|
189
199
|
} else {
|
|
190
200
|
if (isBuf && string) {
|
|
191
|
-
return
|
|
201
|
+
return _data.toString()
|
|
192
202
|
} else if (isStr && string !== true) {
|
|
193
203
|
return new TextEncoder().encode(_data)
|
|
194
204
|
}
|
package/esm/weavedrive.js
CHANGED
|
@@ -122,7 +122,6 @@ export default class WeaveDrive {
|
|
|
122
122
|
false,
|
|
123
123
|
)
|
|
124
124
|
var stream = FS.open("/tx2/" + id, "r")
|
|
125
|
-
|
|
126
125
|
return stream
|
|
127
126
|
},
|
|
128
127
|
async open(filename) {
|
|
@@ -190,9 +189,7 @@ export default class WeaveDrive {
|
|
|
190
189
|
|
|
191
190
|
var stream = 0
|
|
192
191
|
for (var i = 0; i < FS.streams.length; i++) {
|
|
193
|
-
if (FS.streams[i].fd === fd)
|
|
194
|
-
stream = FS.streams[i]
|
|
195
|
-
}
|
|
192
|
+
if (FS.streams[i].fd === fd) stream = FS.streams[i]
|
|
196
193
|
}
|
|
197
194
|
// read block headers
|
|
198
195
|
if (stream.path.includes("/block")) {
|
|
@@ -226,8 +223,7 @@ export default class WeaveDrive {
|
|
|
226
223
|
//console.log("WeaveDrive: fd: ", fd, " Read length: ", to_read, " Reading ahead:", to - to_read - stream.position)
|
|
227
224
|
|
|
228
225
|
// fetch(`/${stream.node.name}`)
|
|
229
|
-
const data = await ar.data(stream.node.name)
|
|
230
|
-
|
|
226
|
+
const data = await ar.data(stream.node.name, null, log)
|
|
231
227
|
// Extract the Range header to determine the start and end of the requested chunk
|
|
232
228
|
const start = 0
|
|
233
229
|
const end = data.length
|