wao 0.1.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.
Files changed (60) hide show
  1. package/cjs/accounts.js +96 -0
  2. package/cjs/ao.js +1543 -0
  3. package/cjs/aoconnect.js +758 -0
  4. package/cjs/ar.js +794 -0
  5. package/cjs/dirname.js +7 -0
  6. package/cjs/helpers.js +381 -0
  7. package/cjs/index.js +20 -0
  8. package/cjs/utils.js +438 -0
  9. package/esm/.cache/opt.json +1 -0
  10. package/esm/accounts.js +91 -0
  11. package/esm/ao.js +737 -0
  12. package/esm/aoconnect.js +318 -0
  13. package/esm/ar.js +243 -0
  14. package/esm/dirname.js +1 -0
  15. package/esm/helpers.js +161 -0
  16. package/esm/index.js +4 -0
  17. package/esm/lua/aos-sqlite.wasm +0 -0
  18. package/esm/lua/aos.wasm +0 -0
  19. package/esm/lua/aos2.lua +33 -0
  20. package/esm/lua/aos2_0_1.wasm +0 -0
  21. package/esm/lua/atomic-asset.lua +238 -0
  22. package/esm/lua/atomic-note-library.lua +2274 -0
  23. package/esm/lua/atomic-note.lua +11 -0
  24. package/esm/lua/collection-registry.lua +202 -0
  25. package/esm/lua/collection.lua +173 -0
  26. package/esm/lua/notebook.lua +173 -0
  27. package/esm/lua/profile.lua +858 -0
  28. package/esm/lua/profile000.lua +666 -0
  29. package/esm/lua/proxy.lua +24 -0
  30. package/esm/lua/registry.lua +858 -0
  31. package/esm/lua/registry000.lua +636 -0
  32. package/esm/test.js +94 -0
  33. package/esm/utils.js +342 -0
  34. package/package.json +21 -0
  35. package/test/.cache/opt.json +1 -0
  36. package/test/accounts.js +91 -0
  37. package/test/ao.js +737 -0
  38. package/test/aoconnect.js +318 -0
  39. package/test/ar.js +243 -0
  40. package/test/dirname.js +1 -0
  41. package/test/helpers.js +161 -0
  42. package/test/index.js +4 -0
  43. package/test/lua/aos-sqlite.wasm +0 -0
  44. package/test/lua/aos.wasm +0 -0
  45. package/test/lua/aos2.lua +33 -0
  46. package/test/lua/aos2_0_1.wasm +0 -0
  47. package/test/lua/atomic-asset.lua +238 -0
  48. package/test/lua/atomic-note-library.lua +2274 -0
  49. package/test/lua/atomic-note.lua +11 -0
  50. package/test/lua/collection-registry.lua +202 -0
  51. package/test/lua/collection.lua +173 -0
  52. package/test/lua/notebook.lua +173 -0
  53. package/test/lua/profile.lua +858 -0
  54. package/test/lua/profile000.lua +666 -0
  55. package/test/lua/proxy.lua +24 -0
  56. package/test/lua/registry.lua +858 -0
  57. package/test/lua/registry000.lua +636 -0
  58. package/test/package.json +21 -0
  59. package/test/test.js +94 -0
  60. package/test/utils.js +342 -0
@@ -0,0 +1,758 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.connect = void 0;
7
+ var _warpArbundles = require("warp-arbundles");
8
+ var _base64url = _interopRequireDefault(require("base64url"));
9
+ var _aoLoader = _interopRequireDefault(require("@permaweb/ao-loader"));
10
+ var _fs = require("fs");
11
+ var _path = require("path");
12
+ var _ramda = require("ramda");
13
+ var _accounts = _interopRequireDefault(require("./accounts.js"));
14
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
15
+ 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; }
16
+ 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; }
17
+ 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; }
18
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
19
+ 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); }
20
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
21
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
22
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
23
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
24
+ 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; } } }; }
25
+ 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; } }
26
+ 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; }
27
+ 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; }
28
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
29
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
30
+ 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); }
31
+ 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); }); }; }
32
+ 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); }
33
+ function isJSON(obj) {
34
+ if (obj === null || obj === undefined) return false;
35
+ if (_typeof(obj) !== "object" || obj instanceof Buffer || obj instanceof ArrayBuffer || Array.isArray(obj)) {
36
+ return false;
37
+ }
38
+ try {
39
+ var str = JSON.stringify(obj);
40
+ var parsed = JSON.parse(str);
41
+ var isjson = _typeof(parsed) === "object" && parsed !== null;
42
+ return isjson ? str : false;
43
+ } catch (e) {
44
+ return false;
45
+ }
46
+ }
47
+ var jsonToStr = function jsonToStr(obj) {
48
+ return isJSON(obj) || ((0, _ramda.is)(Number, obj) ? Number(obj).toString() : obj);
49
+ };
50
+ var dirname = /*#__PURE__*/function () {
51
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
52
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
53
+ while (1) switch (_context.prev = _context.next) {
54
+ case 0:
55
+ if (!(typeof __dirname != "undefined")) {
56
+ _context.next = 4;
57
+ break;
58
+ }
59
+ _context.t0 = __dirname;
60
+ _context.next = 7;
61
+ break;
62
+ case 4:
63
+ _context.next = 6;
64
+ return Promise.resolve().then(function () {
65
+ return _interopRequireWildcard(require("./dirname.js"));
66
+ });
67
+ case 6:
68
+ _context.t0 = _context.sent["default"];
69
+ case 7:
70
+ return _context.abrupt("return", _context.t0);
71
+ case 8:
72
+ case "end":
73
+ return _context.stop();
74
+ }
75
+ }, _callee);
76
+ }));
77
+ return function dirname() {
78
+ return _ref.apply(this, arguments);
79
+ };
80
+ }();
81
+ var tags = function tags(_tags2) {
82
+ return (0, _ramda.fromPairs)((0, _ramda.map)(function (v) {
83
+ return [v.name, v.value];
84
+ })(_tags2));
85
+ };
86
+ var action = function action(value) {
87
+ return tag("Action", value);
88
+ };
89
+ var tag = function tag(name, value) {
90
+ return {
91
+ name: name,
92
+ value: jsonToStr(value)
93
+ };
94
+ };
95
+ var buildTags = function buildTags(act, tags) {
96
+ var _tags = [];
97
+ if (act) _tags.push(action(act));
98
+ for (var k in tags) {
99
+ if ((0, _ramda.is)(Array)(tags[k])) {
100
+ var _iterator = _createForOfIteratorHelper(tags[k]),
101
+ _step;
102
+ try {
103
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
104
+ var v = _step.value;
105
+ _tags.push(tag(k, v));
106
+ }
107
+ } catch (err) {
108
+ _iterator.e(err);
109
+ } finally {
110
+ _iterator.f();
111
+ }
112
+ } else _tags.push(tag(k, tags[k]));
113
+ }
114
+ return _tags;
115
+ };
116
+ var connect = exports.connect = function connect() {
117
+ var wasms = {
118
+ T9W7AieZu7VZgv4NsjIGSPZSxGDWlTCixeLuFYo4WCM: {
119
+ file: "aos2_0_1",
120
+ format: "wasm64-unknown-emscripten-draft_2024_02_15"
121
+ }
122
+ };
123
+ var modules = {
124
+ aos_2_0_1: "T9W7AieZu7VZgv4NsjIGSPZSxGDWlTCixeLuFYo4WCM"
125
+ };
126
+ var modmap = {};
127
+ var env = {
128
+ msgs: {}
129
+ };
130
+ var mu = _accounts["default"].mu;
131
+ var transform = function transform(input) {
132
+ var _input$Tags;
133
+ var output = {
134
+ Tags: []
135
+ };
136
+ if (input.Data) output.Data = input.Data;
137
+ Object.entries(input).forEach(function (_ref2) {
138
+ var _ref3 = _slicedToArray(_ref2, 2),
139
+ key = _ref3[0],
140
+ value = _ref3[1];
141
+ if (key !== "Data" && key !== "Tags" && typeof value === "string") {
142
+ output.Tags.push({
143
+ name: key,
144
+ value: value
145
+ });
146
+ }
147
+ });
148
+ (_input$Tags = input.Tags) === null || _input$Tags === void 0 || _input$Tags.forEach(function (tag) {
149
+ var tagKey = Object.keys(tag)[0];
150
+ var tagValue = tag[tagKey];
151
+ if (typeof tagValue === "string") {
152
+ output.Tags.push({
153
+ name: tagKey,
154
+ value: tagValue
155
+ });
156
+ }
157
+ });
158
+ return output;
159
+ };
160
+ var genMsg = function genMsg(p, data, Tags, from, owner) {
161
+ var dry = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
162
+ if (!dry) p.height += 1;
163
+ return {
164
+ Id: p.height,
165
+ Target: p.id,
166
+ Owner: owner,
167
+ Data: data !== null && data !== void 0 && data.length ? data : "",
168
+ "Block-Height": p.height.toString(),
169
+ Timestamp: Date.now().toString(),
170
+ Module: p.module,
171
+ From: from,
172
+ Cron: false,
173
+ Tags: Tags !== null && Tags !== void 0 && Tags.length ? Tags : []
174
+ };
175
+ };
176
+ var genEnv = function genEnv(_ref4) {
177
+ var pid = _ref4.pid,
178
+ _ref4$owner = _ref4.owner,
179
+ owner = _ref4$owner === void 0 ? "" : _ref4$owner,
180
+ _ref4$module = _ref4.module,
181
+ module = _ref4$module === void 0 ? "" : _ref4$module,
182
+ _ref4$auth = _ref4.auth,
183
+ auth = _ref4$auth === void 0 ? "" : _ref4$auth;
184
+ return {
185
+ Process: {
186
+ Id: pid,
187
+ Tags: [{
188
+ name: "Data-Protocol",
189
+ value: "ao"
190
+ }, {
191
+ name: "Variant",
192
+ value: "ao.TN.1"
193
+ }, {
194
+ name: "Type",
195
+ value: "Process"
196
+ }, {
197
+ name: "Authority",
198
+ value: auth
199
+ }],
200
+ Owner: owner
201
+ },
202
+ Module: {
203
+ Id: module,
204
+ Tags: [{
205
+ name: "Data-Protocol",
206
+ value: "ao"
207
+ }, {
208
+ name: "Variant",
209
+ value: "ao.TN.1"
210
+ }, {
211
+ name: "Type",
212
+ value: "Module"
213
+ }]
214
+ }
215
+ };
216
+ };
217
+ var parse = /*#__PURE__*/function () {
218
+ var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(opt) {
219
+ var _opt$data;
220
+ var item, rowner, hashBuffer, owner;
221
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
222
+ while (1) switch (_context2.prev = _context2.next) {
223
+ case 0:
224
+ _context2.next = 2;
225
+ return opt.signer({
226
+ data: (_opt$data = opt.data) !== null && _opt$data !== void 0 ? _opt$data : "",
227
+ tags: opt.tags
228
+ });
229
+ case 2:
230
+ item = _context2.sent;
231
+ rowner = new _warpArbundles.DataItem(item.raw).rawOwner;
232
+ _context2.t0 = Buffer;
233
+ _context2.next = 7;
234
+ return crypto.subtle.digest("SHA-256", rowner);
235
+ case 7:
236
+ _context2.t1 = _context2.sent;
237
+ hashBuffer = _context2.t0.from.call(_context2.t0, _context2.t1);
238
+ owner = _base64url["default"].encode(hashBuffer);
239
+ return _context2.abrupt("return", {
240
+ id: item.id,
241
+ owner: owner
242
+ });
243
+ case 11:
244
+ case "end":
245
+ return _context2.stop();
246
+ }
247
+ }, _callee2);
248
+ }));
249
+ return function parse(_x) {
250
+ return _ref5.apply(this, arguments);
251
+ };
252
+ }();
253
+ var postModule = /*#__PURE__*/function () {
254
+ var _ref7 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref6) {
255
+ var data, _ref6$tags, tags, signer, t, _tags, _yield$parse, id, owner, handle;
256
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
257
+ while (1) switch (_context3.prev = _context3.next) {
258
+ case 0:
259
+ data = _ref6.data, _ref6$tags = _ref6.tags, tags = _ref6$tags === void 0 ? {} : _ref6$tags, signer = _ref6.signer;
260
+ t = (0, _ramda.mergeLeft)(tags, {
261
+ "Data-Protocol": "ao",
262
+ Variant: "ao.TN.1",
263
+ Type: "Module",
264
+ "Module-Format": "wasm64-unknown-emscripten-draft_2024_02_15",
265
+ "Input-Encoding": "JSON-V1",
266
+ "Output-Encoding": "JSON-V1",
267
+ "Memory-Limit": "1-gb",
268
+ "Compute-Limit": "9000000000000"
269
+ });
270
+ _tags = buildTags(t);
271
+ _context3.next = 5;
272
+ return parse({
273
+ tags: _tags,
274
+ data: data,
275
+ signer: signer
276
+ });
277
+ case 5:
278
+ _yield$parse = _context3.sent;
279
+ id = _yield$parse.id;
280
+ owner = _yield$parse.owner;
281
+ _context3.next = 10;
282
+ return (0, _aoLoader["default"])(data, {
283
+ format: t["Module-Format"]
284
+ });
285
+ case 10:
286
+ handle = _context3.sent;
287
+ modmap[id] = {
288
+ handle: handle,
289
+ id: id
290
+ };
291
+ return _context3.abrupt("return", id);
292
+ case 13:
293
+ case "end":
294
+ return _context3.stop();
295
+ }
296
+ }, _callee3);
297
+ }));
298
+ return function postModule(_x2) {
299
+ return _ref7.apply(this, arguments);
300
+ };
301
+ }();
302
+ var _message = /*#__PURE__*/function () {
303
+ var _ref8 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(opt) {
304
+ var p, ex, _iterator2, _step2, _v, _yield$parse2, id, owner, _opt$data2, _opt$from, _res$Messages, msg, _env, res, _iterator3, _step3, v;
305
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
306
+ while (1) switch (_context4.prev = _context4.next) {
307
+ case 0:
308
+ p = env[opt.process];
309
+ ex = false;
310
+ _iterator2 = _createForOfIteratorHelper(opt.tags);
311
+ try {
312
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
313
+ _v = _step2.value;
314
+ if (_v.name === "Type") ex = true;
315
+ }
316
+ } catch (err) {
317
+ _iterator2.e(err);
318
+ } finally {
319
+ _iterator2.f();
320
+ }
321
+ if (!ex) opt.tags.push({
322
+ name: "Type",
323
+ value: "Message"
324
+ });
325
+ _context4.next = 7;
326
+ return parse(opt);
327
+ case 7:
328
+ _yield$parse2 = _context4.sent;
329
+ id = _yield$parse2.id;
330
+ owner = _yield$parse2.owner;
331
+ _context4.prev = 10;
332
+ msg = genMsg(p, (_opt$data2 = opt.data) !== null && _opt$data2 !== void 0 ? _opt$data2 : "", opt.tags, (_opt$from = opt.from) !== null && _opt$from !== void 0 ? _opt$from : owner, mu.addr);
333
+ _env = genEnv({
334
+ pid: p.id,
335
+ owner: p.owner,
336
+ module: p.module,
337
+ auth: mu.addr
338
+ });
339
+ _context4.next = 15;
340
+ return p.handle(p.memory, msg, _env);
341
+ case 15:
342
+ res = _context4.sent;
343
+ p.memory = res.Memory;
344
+ delete res.Memory;
345
+ p.res[id] = res;
346
+ p.results.push(id);
347
+ p.txs.unshift(_objectSpread({
348
+ id: id
349
+ }, opt));
350
+ env.msgs[id] = opt;
351
+ _iterator3 = _createForOfIteratorHelper((_res$Messages = res.Messages) !== null && _res$Messages !== void 0 ? _res$Messages : []);
352
+ _context4.prev = 23;
353
+ _iterator3.s();
354
+ case 25:
355
+ if ((_step3 = _iterator3.n()).done) {
356
+ _context4.next = 32;
357
+ break;
358
+ }
359
+ v = _step3.value;
360
+ if (!env[v.Target]) {
361
+ _context4.next = 30;
362
+ break;
363
+ }
364
+ _context4.next = 30;
365
+ return _message({
366
+ process: v.Target,
367
+ tags: v.Tags,
368
+ data: v.Data,
369
+ signer: mu.signer,
370
+ from: opt.process
371
+ });
372
+ case 30:
373
+ _context4.next = 25;
374
+ break;
375
+ case 32:
376
+ _context4.next = 37;
377
+ break;
378
+ case 34:
379
+ _context4.prev = 34;
380
+ _context4.t0 = _context4["catch"](23);
381
+ _iterator3.e(_context4.t0);
382
+ case 37:
383
+ _context4.prev = 37;
384
+ _iterator3.f();
385
+ return _context4.finish(37);
386
+ case 40:
387
+ return _context4.abrupt("return", id);
388
+ case 43:
389
+ _context4.prev = 43;
390
+ _context4.t1 = _context4["catch"](10);
391
+ console.log(_context4.t1);
392
+ case 46:
393
+ return _context4.abrupt("return", null);
394
+ case 47:
395
+ case "end":
396
+ return _context4.stop();
397
+ }
398
+ }, _callee4, null, [[10, 43], [23, 34, 37, 40]]);
399
+ }));
400
+ return function message(_x3) {
401
+ return _ref8.apply(this, arguments);
402
+ };
403
+ }();
404
+ return {
405
+ modules: modules,
406
+ accounts: _accounts["default"].users,
407
+ message: _message,
408
+ txs: function () {
409
+ var _txs2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(pid) {
410
+ var _txs, _iterator4, _step4, v;
411
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
412
+ while (1) switch (_context5.prev = _context5.next) {
413
+ case 0:
414
+ _txs = [];
415
+ _iterator4 = _createForOfIteratorHelper(env[pid].txs);
416
+ try {
417
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
418
+ v = _step4.value;
419
+ _txs.push({
420
+ tags: v.tags,
421
+ id: v.id
422
+ });
423
+ }
424
+ } catch (err) {
425
+ _iterator4.e(err);
426
+ } finally {
427
+ _iterator4.f();
428
+ }
429
+ return _context5.abrupt("return", _txs);
430
+ case 4:
431
+ case "end":
432
+ return _context5.stop();
433
+ }
434
+ }, _callee5);
435
+ }));
436
+ function txs(_x4) {
437
+ return _txs2.apply(this, arguments);
438
+ }
439
+ return txs;
440
+ }(),
441
+ spawn: function () {
442
+ var _spawn = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
443
+ var _opt$module, _opt$tags;
444
+ var opt,
445
+ mod,
446
+ _dirname,
447
+ wasm,
448
+ handle,
449
+ _module,
450
+ ex,
451
+ _iterator5,
452
+ _step5,
453
+ v,
454
+ _yield$parse3,
455
+ id,
456
+ owner,
457
+ _args6 = arguments;
458
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
459
+ while (1) switch (_context6.prev = _context6.next) {
460
+ case 0:
461
+ opt = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : {};
462
+ mod = (_opt$module = opt.module) !== null && _opt$module !== void 0 ? _opt$module : modules["aos_2_0_1"];
463
+ if (!(!modmap[mod] && wasms[mod])) {
464
+ _context6.next = 11;
465
+ break;
466
+ }
467
+ _context6.next = 5;
468
+ return dirname();
469
+ case 5:
470
+ _dirname = _context6.sent;
471
+ wasm = (0, _fs.readFileSync)((0, _path.resolve)(_dirname, "lua/".concat(wasms[mod].file, ".wasm")));
472
+ _context6.next = 9;
473
+ return (0, _aoLoader["default"])(wasm, {
474
+ format: wasms[mod].format
475
+ });
476
+ case 9:
477
+ handle = _context6.sent;
478
+ modmap[mod] = {
479
+ handle: handle,
480
+ id: mod
481
+ };
482
+ case 11:
483
+ if (mod) {
484
+ _context6.next = 13;
485
+ break;
486
+ }
487
+ throw Error("module not found");
488
+ case 13:
489
+ _module = modmap[mod];
490
+ ex = false;
491
+ (_opt$tags = opt.tags) !== null && _opt$tags !== void 0 ? _opt$tags : opt.tags = [];
492
+ _iterator5 = _createForOfIteratorHelper(opt.tags);
493
+ try {
494
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
495
+ v = _step5.value;
496
+ if (v.name === "Type") ex = true;
497
+ }
498
+ } catch (err) {
499
+ _iterator5.e(err);
500
+ } finally {
501
+ _iterator5.f();
502
+ }
503
+ if (!ex) opt.tags.push({
504
+ name: "Type",
505
+ value: "Process"
506
+ });
507
+ _context6.next = 21;
508
+ return parse(opt);
509
+ case 21:
510
+ _yield$parse3 = _context6.sent;
511
+ id = _yield$parse3.id;
512
+ owner = _yield$parse3.owner;
513
+ env.msgs[id] = opt;
514
+ env[id] = {
515
+ id: id,
516
+ handle: _module.handle,
517
+ module: _module.id,
518
+ memory: null,
519
+ owner: owner,
520
+ height: 1,
521
+ res: {
522
+ id: null
523
+ },
524
+ results: [id],
525
+ txs: []
526
+ };
527
+ return _context6.abrupt("return", id);
528
+ case 27:
529
+ case "end":
530
+ return _context6.stop();
531
+ }
532
+ }, _callee6);
533
+ }));
534
+ function spawn() {
535
+ return _spawn.apply(this, arguments);
536
+ }
537
+ return spawn;
538
+ }(),
539
+ assign: function () {
540
+ var _assign = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(opt) {
541
+ var p, _opt, _yield$parse4, id, owner, _opt$data3, _opt$from2, _res$Messages2, msg, _env, res, _iterator6, _step6, v;
542
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
543
+ while (1) switch (_context7.prev = _context7.next) {
544
+ case 0:
545
+ p = env[opt.process];
546
+ _opt = (0, _ramda.clone)(env.msgs[opt.message]);
547
+ _context7.next = 4;
548
+ return parse(_opt);
549
+ case 4:
550
+ _yield$parse4 = _context7.sent;
551
+ id = _yield$parse4.id;
552
+ owner = _yield$parse4.owner;
553
+ _context7.prev = 7;
554
+ msg = genMsg(p, (_opt$data3 = _opt.data) !== null && _opt$data3 !== void 0 ? _opt$data3 : "", _opt.tags, (_opt$from2 = _opt.from) !== null && _opt$from2 !== void 0 ? _opt$from2 : owner, mu.addr);
555
+ _env = genEnv({
556
+ pid: p.id,
557
+ owner: p.owner,
558
+ module: p.module,
559
+ auth: mu.addr
560
+ });
561
+ _context7.next = 12;
562
+ return p.handle(p.memory, msg, _env);
563
+ case 12:
564
+ res = _context7.sent;
565
+ p.memory = res.Memory;
566
+ delete res.Memory;
567
+ p.res[id] = res;
568
+ p.results.push(id);
569
+ p.txs.unshift(_objectSpread({
570
+ id: id
571
+ }, _opt));
572
+ env.msgs[id] = _opt;
573
+ _iterator6 = _createForOfIteratorHelper((_res$Messages2 = res.Messages) !== null && _res$Messages2 !== void 0 ? _res$Messages2 : []);
574
+ _context7.prev = 20;
575
+ _iterator6.s();
576
+ case 22:
577
+ if ((_step6 = _iterator6.n()).done) {
578
+ _context7.next = 29;
579
+ break;
580
+ }
581
+ v = _step6.value;
582
+ if (!env[v.Target]) {
583
+ _context7.next = 27;
584
+ break;
585
+ }
586
+ _context7.next = 27;
587
+ return _message({
588
+ process: v.Target,
589
+ tags: v.Tags,
590
+ data: v.Data,
591
+ signer: mu.signer,
592
+ from: opt.process
593
+ });
594
+ case 27:
595
+ _context7.next = 22;
596
+ break;
597
+ case 29:
598
+ _context7.next = 34;
599
+ break;
600
+ case 31:
601
+ _context7.prev = 31;
602
+ _context7.t0 = _context7["catch"](20);
603
+ _iterator6.e(_context7.t0);
604
+ case 34:
605
+ _context7.prev = 34;
606
+ _iterator6.f();
607
+ return _context7.finish(34);
608
+ case 37:
609
+ return _context7.abrupt("return", id);
610
+ case 40:
611
+ _context7.prev = 40;
612
+ _context7.t1 = _context7["catch"](7);
613
+ console.log(_context7.t1);
614
+ case 43:
615
+ return _context7.abrupt("return", null);
616
+ case 44:
617
+ case "end":
618
+ return _context7.stop();
619
+ }
620
+ }, _callee7, null, [[7, 40], [20, 31, 34, 37]]);
621
+ }));
622
+ function assign(_x5) {
623
+ return _assign.apply(this, arguments);
624
+ }
625
+ return assign;
626
+ }(),
627
+ result: function () {
628
+ var _result = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(opt) {
629
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
630
+ while (1) switch (_context8.prev = _context8.next) {
631
+ case 0:
632
+ return _context8.abrupt("return", env[opt.process].res[opt.message]);
633
+ case 1:
634
+ case "end":
635
+ return _context8.stop();
636
+ }
637
+ }, _callee8);
638
+ }));
639
+ function result(_x6) {
640
+ return _result.apply(this, arguments);
641
+ }
642
+ return result;
643
+ }(),
644
+ results: function () {
645
+ var _results = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(opt) {
646
+ var _opt$limit;
647
+ var p, results, limit, i, _i;
648
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
649
+ while (1) switch (_context9.prev = _context9.next) {
650
+ case 0:
651
+ p = env[opt.process];
652
+ results = [];
653
+ limit = (_opt$limit = opt.limit) !== null && _opt$limit !== void 0 ? _opt$limit : 25;
654
+ if (!(opt.sort === "DESC")) {
655
+ _context9.next = 14;
656
+ break;
657
+ }
658
+ i = p.results.length - 1;
659
+ case 5:
660
+ if (!(0 < i)) {
661
+ _context9.next = 12;
662
+ break;
663
+ }
664
+ results.push({
665
+ cursor: p.results[i],
666
+ node: p.res[p.results[i]]
667
+ });
668
+ if (!(results.length >= limit)) {
669
+ _context9.next = 9;
670
+ break;
671
+ }
672
+ return _context9.abrupt("break", 12);
673
+ case 9:
674
+ i--;
675
+ _context9.next = 5;
676
+ break;
677
+ case 12:
678
+ _context9.next = 22;
679
+ break;
680
+ case 14:
681
+ _i = 0;
682
+ case 15:
683
+ if (!(_i < p.results.length)) {
684
+ _context9.next = 22;
685
+ break;
686
+ }
687
+ results.push({
688
+ node: p.res[p.results[_i]]
689
+ });
690
+ if (!(results.length >= limit)) {
691
+ _context9.next = 19;
692
+ break;
693
+ }
694
+ return _context9.abrupt("break", 22);
695
+ case 19:
696
+ _i++;
697
+ _context9.next = 15;
698
+ break;
699
+ case 22:
700
+ return _context9.abrupt("return", {
701
+ edges: results
702
+ });
703
+ case 23:
704
+ case "end":
705
+ return _context9.stop();
706
+ }
707
+ }, _callee9);
708
+ }));
709
+ function results(_x7) {
710
+ return _results.apply(this, arguments);
711
+ }
712
+ return results;
713
+ }(),
714
+ dryrun: function () {
715
+ var _dryrun = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(opt) {
716
+ var p, _yield$parse5, id, owner, _opt$data4, msg, _env, res;
717
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
718
+ while (1) switch (_context10.prev = _context10.next) {
719
+ case 0:
720
+ p = env[opt.process];
721
+ _context10.next = 3;
722
+ return parse(opt);
723
+ case 3:
724
+ _yield$parse5 = _context10.sent;
725
+ id = _yield$parse5.id;
726
+ owner = _yield$parse5.owner;
727
+ _context10.prev = 6;
728
+ msg = genMsg(p, (_opt$data4 = opt.data) !== null && _opt$data4 !== void 0 ? _opt$data4 : "", opt.tags, owner, mu.addr, true);
729
+ _env = genEnv({
730
+ pid: p.id,
731
+ owner: p.owner,
732
+ module: p.module,
733
+ auth: mu.addr
734
+ });
735
+ _context10.next = 11;
736
+ return p.handle(p.memory, msg, _env);
737
+ case 11:
738
+ res = _context10.sent;
739
+ return _context10.abrupt("return", res);
740
+ case 15:
741
+ _context10.prev = 15;
742
+ _context10.t0 = _context10["catch"](6);
743
+ console.log(_context10.t0);
744
+ case 18:
745
+ return _context10.abrupt("return", null);
746
+ case 19:
747
+ case "end":
748
+ return _context10.stop();
749
+ }
750
+ }, _callee10, null, [[6, 15]]);
751
+ }));
752
+ function dryrun(_x8) {
753
+ return _dryrun.apply(this, arguments);
754
+ }
755
+ return dryrun;
756
+ }()
757
+ };
758
+ };