wao 0.1.5 → 0.2.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 CHANGED
@@ -10,14 +10,14 @@ var _aoconnect = require("@permaweb/aoconnect");
10
10
  var _ramda = require("ramda");
11
11
  var _utils = require("./utils.js");
12
12
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
13
+ 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); }
14
+ 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; }
13
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; }
14
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; }
15
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; }
16
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; } } }; }
17
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; } }
18
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; }
19
- 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); }
20
- 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; }
21
21
  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); }
22
22
  function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
23
23
  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); } }
@@ -143,36 +143,14 @@ var AO = /*#__PURE__*/function () {
143
143
  key: "init",
144
144
  value: function () {
145
145
  var _init = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(jwk) {
146
- var _jwk, v, _v$connect, accounts, modules, _results2, _assign2, _result2, _message2, _spawn2, _dryrun2, txs;
147
146
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
148
147
  while (1) switch (_context3.prev = _context3.next) {
149
148
  case 0:
150
- if (!this.in_memory) {
151
- _context3.next = 14;
152
- break;
153
- }
154
- _context3.next = 3;
155
- return Promise.resolve().then(function () {
156
- return _interopRequireWildcard(require("./aoconnect.js"));
157
- });
158
- case 3:
159
- v = _context3.sent;
160
- _v$connect = v.connect(), accounts = _v$connect.accounts, modules = _v$connect.modules, _results2 = _v$connect.results, _assign2 = _v$connect.assign, _result2 = _v$connect.result, _message2 = _v$connect.message, _spawn2 = _v$connect.spawn, _dryrun2 = _v$connect.dryrun, txs = _v$connect.txs;
161
- this.module = modules.aos_2_0_1;
162
- this.assign = _assign2;
163
- this.result = _result2;
164
- this.results = _results2;
165
- this.message = _message2;
166
- this.spawn = _spawn2;
167
- this.dryrun = _dryrun2;
168
- this.ar.txs = txs;
169
- (_jwk = jwk) !== null && _jwk !== void 0 ? _jwk : jwk = accounts[0].jwk;
170
- case 14:
171
- _context3.next = 16;
149
+ _context3.next = 2;
172
150
  return this.ar.init(jwk);
173
- case 16:
151
+ case 2:
174
152
  return _context3.abrupt("return", this);
175
- case 17:
153
+ case 3:
176
154
  case "end":
177
155
  return _context3.stop();
178
156
  }
package/cjs/helpers.js CHANGED
@@ -4,10 +4,31 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.setup = exports.ok = exports.fail = exports.Src = void 0;
7
+ Object.defineProperty(exports, "AO", {
8
+ enumerable: true,
9
+ get: function get() {
10
+ return _tao["default"];
11
+ }
12
+ });
13
+ Object.defineProperty(exports, "AR", {
14
+ enumerable: true,
15
+ get: function get() {
16
+ return _index.AR;
17
+ }
18
+ });
19
+ exports.Src = void 0;
20
+ Object.defineProperty(exports, "connect", {
21
+ enumerable: true,
22
+ get: function get() {
23
+ return _aoconnect3.connect;
24
+ }
25
+ });
26
+ exports.setup = exports.ok = exports.fail = void 0;
27
+ var _aoconnect3 = require("./aoconnect.js");
8
28
  var _index = require("./index.js");
29
+ var _tao = _interopRequireDefault(require("./tao.js"));
9
30
  var _assert = _interopRequireDefault(require("assert"));
10
- var _aoconnect3 = require("@permaweb/aoconnect");
31
+ var _aoconnect4 = require("@permaweb/aoconnect");
11
32
  var _path = require("path");
12
33
  var _fs = require("fs");
13
34
  var _yargs = _interopRequireDefault(require("yargs"));
@@ -198,11 +219,11 @@ var setup = exports.setup = /*#__PURE__*/function () {
198
219
  dir: dir
199
220
  });
200
221
  _context3.next = 25;
201
- return new _index.AO(opt.ao).init(opt.jwk);
222
+ return new _tao["default"](opt.ao).init(opt.jwk);
202
223
  case 25:
203
224
  _ao = _context3.sent;
204
225
  _context3.next = 28;
205
- return new _index.AO(opt.ao2).init(opt.jwk);
226
+ return new _tao["default"](opt.ao2).init(opt.jwk);
206
227
  case 28:
207
228
  _ao2 = _context3.sent;
208
229
  console.log("cache:\t", optPath);
@@ -260,7 +281,7 @@ var setup = exports.setup = /*#__PURE__*/function () {
260
281
  return src.upload("aos2_0_1", "wasm");
261
282
  case 51:
262
283
  wasm_aos2 = _context3.sent;
263
- ao = new _index.AO({
284
+ ao = new _tao["default"]({
264
285
  aoconnect: aoconnect,
265
286
  ar: ar,
266
287
  authority: auth
@@ -324,7 +345,7 @@ var setup = exports.setup = /*#__PURE__*/function () {
324
345
 
325
346
  // ao2
326
347
  _context3.next = 87;
327
- return new _index.AO({
348
+ return new _tao["default"]({
328
349
  aoconnect: aoconnect,
329
350
  ar: ar,
330
351
  authority: auth,
package/cjs/tao.js ADDED
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+
3
+ 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); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports["default"] = void 0;
8
+ var _ao = _interopRequireDefault(require("./ao.js"));
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
10
+ 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; }
11
+ 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); }
12
+ 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; }
13
+ 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); }
14
+ 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); }); }; }
15
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
16
+ 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); } }
17
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), 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 _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
21
+ function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
22
+ function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
23
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
24
+ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
25
+ function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
26
+ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
27
+ var AO = /*#__PURE__*/function (_MAO) {
28
+ function AO() {
29
+ _classCallCheck(this, AO);
30
+ return _callSuper(this, AO, arguments);
31
+ }
32
+ _inherits(AO, _MAO);
33
+ return _createClass(AO, [{
34
+ key: "init",
35
+ value: function () {
36
+ var _init = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(jwk) {
37
+ var _jwk, v, _v$connect, accounts, modules, results, assign, result, message, spawn, dryrun, txs;
38
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
39
+ while (1) switch (_context.prev = _context.next) {
40
+ case 0:
41
+ if (!this.in_memory) {
42
+ _context.next = 14;
43
+ break;
44
+ }
45
+ _context.next = 3;
46
+ return Promise.resolve().then(function () {
47
+ return _interopRequireWildcard(require("./aoconnect.js"));
48
+ });
49
+ case 3:
50
+ v = _context.sent;
51
+ _v$connect = v.connect(), accounts = _v$connect.accounts, modules = _v$connect.modules, results = _v$connect.results, assign = _v$connect.assign, result = _v$connect.result, message = _v$connect.message, spawn = _v$connect.spawn, dryrun = _v$connect.dryrun, txs = _v$connect.txs;
52
+ this.module = modules.aos_2_0_1;
53
+ this.assign = assign;
54
+ this.result = result;
55
+ this.results = results;
56
+ this.message = message;
57
+ this.spawn = spawn;
58
+ this.dryrun = dryrun;
59
+ this.ar.txs = txs;
60
+ (_jwk = jwk) !== null && _jwk !== void 0 ? _jwk : jwk = accounts[0].jwk;
61
+ case 14:
62
+ _context.next = 16;
63
+ return this.ar.init(jwk);
64
+ case 16:
65
+ return _context.abrupt("return", this);
66
+ case 17:
67
+ case "end":
68
+ return _context.stop();
69
+ }
70
+ }, _callee, this);
71
+ }));
72
+ function init(_x) {
73
+ return _init.apply(this, arguments);
74
+ }
75
+ return init;
76
+ }()
77
+ }]);
78
+ }(_ao["default"]);
79
+ var _default = exports["default"] = AO;
package/esm/ao.js CHANGED
@@ -113,29 +113,6 @@ class AO {
113
113
  }
114
114
 
115
115
  async init(jwk) {
116
- if (this.in_memory) {
117
- const v = await import("./aoconnect.js")
118
- const {
119
- accounts,
120
- modules,
121
- results,
122
- assign,
123
- result,
124
- message,
125
- spawn,
126
- dryrun,
127
- txs,
128
- } = v.connect()
129
- this.module = modules.aos_2_0_1
130
- this.assign = assign
131
- this.result = result
132
- this.results = results
133
- this.message = message
134
- this.spawn = spawn
135
- this.dryrun = dryrun
136
- this.ar.txs = txs
137
- jwk ??= accounts[0].jwk
138
- }
139
116
  await this.ar.init(jwk)
140
117
  return this
141
118
  }
package/esm/helpers.js CHANGED
@@ -1,4 +1,6 @@
1
- import { AR, AO } from "./index.js"
1
+ import { connect as tconnect } from "./aoconnect.js"
2
+ import { AR } from "./index.js"
3
+ import AO from "./tao.js"
2
4
  import assert from "assert"
3
5
  import { createDataItemSigner, connect } from "@permaweb/aoconnect"
4
6
  import { dirname as _dirname, resolve } from "path"
@@ -159,3 +161,5 @@ export const fail = obj => {
159
161
  assert.notEqual(obj.err, null)
160
162
  return obj
161
163
  }
164
+
165
+ export { AO, AR, tconnect as connect }
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
package/esm/tao.js ADDED
@@ -0,0 +1,33 @@
1
+ import MAO from "./ao.js"
2
+
3
+ class AO extends MAO {
4
+ async init(jwk) {
5
+ if (this.in_memory) {
6
+ const v = await import("./aoconnect.js")
7
+ const {
8
+ accounts,
9
+ modules,
10
+ results,
11
+ assign,
12
+ result,
13
+ message,
14
+ spawn,
15
+ dryrun,
16
+ txs,
17
+ } = v.connect()
18
+ this.module = modules.aos_2_0_1
19
+ this.assign = assign
20
+ this.result = result
21
+ this.results = results
22
+ this.message = message
23
+ this.spawn = spawn
24
+ this.dryrun = dryrun
25
+ this.ar.txs = txs
26
+ jwk ??= accounts[0].jwk
27
+ }
28
+ await this.ar.init(jwk)
29
+ return this
30
+ }
31
+ }
32
+
33
+ export default AO
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wao",
3
- "version": "0.1.5",
3
+ "version": "0.2.0",
4
4
  "description": "",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",
@@ -13,10 +13,6 @@
13
13
  "require": "./cjs/utils.js",
14
14
  "import": "./esm/utils.js"
15
15
  },
16
- "./connect": {
17
- "require": "./cjs/aoconnect.js",
18
- "import": "./esm/aoconnect.js"
19
- },
20
16
  "./test": {
21
17
  "require": "./cjs/helpers.js",
22
18
  "import": "./esm/helpers.js"
package/esm/test.js DELETED
@@ -1,94 +0,0 @@
1
- import { Profile, AR, AO, Collection, Notebook } from "./index.js"
2
- import { expect } from "chai"
3
- import { createDataItemSigner, connect } from "@permaweb/aoconnect"
4
- import { resolve } from "path"
5
- import { readFileSync } from "fs"
6
- export class Src {
7
- constructor({ ar, base = "./lua", readFileSync, dir, resolve }) {
8
- this.ar = ar
9
- this.base = base
10
- this.dir = dir
11
- }
12
- async upload(file, ext = "lua") {
13
- const data = readFileSync(
14
- `${this.dir}/${this.base}/${file}.${ext}`,
15
- ext === "wasm" ? null : "utf8",
16
- )
17
- const res = await this.ar.post({ data })
18
- return res.err ? null : res.id
19
- }
20
- }
21
-
22
- export const setup = async ({ aoconnect, arweave } = {}) => {
23
- console.error = () => {}
24
- console.warn = () => {}
25
- arweave ??= { port: 4000 }
26
- aoconnect ??= {
27
- MU_URL: "http://localhost:4002",
28
- CU_URL: "http://localhost:4004",
29
- GATEWAY_URL: "http://localhost:4000",
30
- }
31
- const dir = resolve(import.meta.dirname)
32
- const thumbnail = readFileSync(`${dir}/assets/thumbnail.png`)
33
- const banner = readFileSync(resolve(`${dir}/assets/banner.png`))
34
- const ar = new AR(arweave)
35
- await ar.gen("10")
36
- const src = new Src({ ar, readFileSync, dir })
37
- const notelib_src = await src.upload("atomic-note-library")
38
- const registry_src = await src.upload("registry000")
39
- const profile_src = await src.upload("profile000")
40
- const collection_registry_src = await src.upload("collection-registry")
41
- const notebook_src = await src.upload("notebook")
42
- const note_src = await src.upload("atomic-note")
43
- const proxy = await src.upload("proxy")
44
- const wasm = await src.upload("aos-sqlite", "wasm")
45
- const wasm2 = await src.upload("aos", "wasm")
46
- const ao = new AO({ aoconnect, ar })
47
-
48
- const { id: module_sqlite } = await ao.postModule({
49
- data: await ar.data(wasm),
50
- overwrite: true,
51
- })
52
-
53
- const { scheduler } = await ao.postScheduler({
54
- url: "http://su",
55
- overwrite: true,
56
- })
57
-
58
- const profile = new Profile({ profile_src, registry_src, ao })
59
- await profile.createRegistry({})
60
- const notebook = new Notebook({
61
- notebook_src,
62
- registry_src: collection_registry_src,
63
- profile,
64
- })
65
-
66
- await notebook.createRegistry()
67
- const { id: module } = await ao.postModule({ data: await ar.data(wasm2) })
68
- const { pid: proxy_pid } = await ao.deploy({ src: proxy, module })
69
-
70
- let opt = {
71
- ar: { ...arweave },
72
- profile: { registry_src, registry: profile.registry, profile_src },
73
- ao: { module: module_sqlite, scheduler, aoconnect },
74
- note: { proxy: proxy_pid, note_src, notelib_src },
75
- notebook: {
76
- notebook_src,
77
- registry: notebook.registry,
78
- registry_src: collection_registry_src,
79
- },
80
- }
81
- return { opt, profile, ao, ar, thumbnail, banner }
82
- }
83
-
84
- export const ok = obj => {
85
- if (obj.err) console.log(obj.err)
86
- expect(obj.err).to.eql(null)
87
- return obj
88
- }
89
-
90
- export const fail = obj => {
91
- if (!obj.err) console.log(obj.res)
92
- expect(obj.err).to.not.eql(null)
93
- return obj
94
- }