wao 0.7.1 → 0.7.2

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
@@ -525,6 +525,7 @@ var AO = /*#__PURE__*/function () {
525
525
  module,
526
526
  _ref11$scheduler,
527
527
  scheduler,
528
+ memory,
528
529
  jwk,
529
530
  _ref11$tags,
530
531
  tags,
@@ -534,11 +535,12 @@ var AO = /*#__PURE__*/function () {
534
535
  _yield$this$ar$checkW,
535
536
  pid,
536
537
  _tags,
538
+ p,
537
539
  _args8 = arguments;
538
540
  return _regeneratorRuntime().wrap(function _callee8$(_context8) {
539
541
  while (1) switch (_context8.prev = _context8.next) {
540
542
  case 0:
541
- _ref11 = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : {}, boot = _ref11.boot, _ref11$module = _ref11.module, module = _ref11$module === void 0 ? this.module : _ref11$module, _ref11$scheduler = _ref11.scheduler, scheduler = _ref11$scheduler === void 0 ? this.scheduler : _ref11$scheduler, jwk = _ref11.jwk, _ref11$tags = _ref11.tags, tags = _ref11$tags === void 0 ? {} : _ref11$tags, data = _ref11.data, auth = _ref11.auth;
543
+ _ref11 = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : {}, boot = _ref11.boot, _ref11$module = _ref11.module, module = _ref11$module === void 0 ? this.module : _ref11$module, _ref11$scheduler = _ref11.scheduler, scheduler = _ref11$scheduler === void 0 ? this.scheduler : _ref11$scheduler, memory = _ref11.memory, jwk = _ref11.jwk, _ref11$tags = _ref11.tags, tags = _ref11$tags === void 0 ? {} : _ref11$tags, data = _ref11.data, auth = _ref11.auth;
542
544
  err = null;
543
545
  _context8.next = 4;
544
546
  return this.ar.checkWallet({
@@ -564,6 +566,7 @@ var AO = /*#__PURE__*/function () {
564
566
  _tags = (0, _utils.buildTags)(null, tags);
565
567
  _context8.next = 17;
566
568
  return this.spawn({
569
+ memory: memory,
567
570
  module: module,
568
571
  scheduler: scheduler,
569
572
  signer: this.toSigner(jwk),
@@ -580,11 +583,13 @@ var AO = /*#__PURE__*/function () {
580
583
  console.log(_context8.t0);
581
584
  err = _context8.t0;
582
585
  case 24:
586
+ p = pid ? this.p(pid) : null;
583
587
  return _context8.abrupt("return", {
584
588
  err: err,
585
- pid: pid
589
+ pid: pid,
590
+ p: p
586
591
  });
587
- case 25:
592
+ case 26:
588
593
  case "end":
589
594
  return _context8.stop();
590
595
  }
package/cjs/aoconnect.js CHANGED
@@ -149,7 +149,7 @@ var connect = exports.connect = function connect(mem) {
149
149
  };
150
150
  var spawn = /*#__PURE__*/function () {
151
151
  var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
152
- var _opt$module, _mem$wasms$mod, _format, _opt$tags, _opt$tags2;
152
+ var _opt$module, _mem$wasms$mod, _format, _opt$tags, _opt$tags2, _opt$memory;
153
153
  var opt,
154
154
  mod,
155
155
  _module,
@@ -180,7 +180,6 @@ var connect = exports.connect = function connect(mem) {
180
180
  data,
181
181
  msg,
182
182
  _env,
183
- _t,
184
183
  _tags$CronInterval$s,
185
184
  _tags$CronInterval$s2,
186
185
  num,
@@ -308,7 +307,7 @@ var connect = exports.connect = function connect(mem) {
308
307
  Date.now = now;
309
308
  _tags = (0, _utils.tags)(opt.tags);
310
309
  res = null;
311
- memory = null;
310
+ memory = (_opt$memory = opt.memory) !== null && _opt$memory !== void 0 ? _opt$memory : null;
312
311
  p = {
313
312
  id: id,
314
313
  epochs: [],
@@ -323,8 +322,15 @@ var connect = exports.connect = function connect(mem) {
323
322
  txs: [],
324
323
  opt: opt
325
324
  };
325
+ if (!memory) {
326
+ _context.next = 56;
327
+ break;
328
+ }
329
+ _context.next = 70;
330
+ break;
331
+ case 56:
326
332
  if (!(_tags["On-Boot"] || true)) {
327
- _context.next = 67;
333
+ _context.next = 69;
328
334
  break;
329
335
  }
330
336
  data = "";
@@ -336,52 +342,51 @@ var connect = exports.connect = function connect(mem) {
336
342
  module: p.module,
337
343
  auth: _test.mu.addr
338
344
  });
339
- _t = (0, _utils.tags)(msg.Tags);
340
- _context.next = 61;
345
+ _context.next = 63;
341
346
  return _module.handle(null, msg, _env);
342
- case 61:
347
+ case 63:
343
348
  res = _context.sent;
344
349
  p.memory = res.Memory;
345
350
  delete res.Memory;
346
351
  p.res[id] = res;
347
- _context.next = 68;
352
+ _context.next = 70;
348
353
  break;
349
- case 67:
354
+ case 69:
350
355
  p.height += 1;
351
- case 68:
356
+ case 70:
352
357
  mem.msgs[id] = opt;
353
358
  mem.env[id] = p;
354
359
  if (!_tags["Cron-Interval"]) {
355
- _context.next = 94;
360
+ _context.next = 96;
356
361
  break;
357
362
  }
358
363
  _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];
359
364
  _int = 0;
360
365
  _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;
366
+ _context.next = _context.t1 === "millisecond" ? 78 : _context.t1 === "second" ? 80 : _context.t1 === "minute" ? 82 : _context.t1 === "hour" ? 84 : _context.t1 === "day" ? 86 : _context.t1 === "month" ? 88 : _context.t1 === "year" ? 90 : 92;
362
367
  break;
363
- case 76:
364
- _int = num;
365
- return _context.abrupt("break", 90);
366
368
  case 78:
367
- _int = num * 1000;
368
- return _context.abrupt("break", 90);
369
+ _int = num;
370
+ return _context.abrupt("break", 92);
369
371
  case 80:
370
- _int = num * 1000 * 60;
371
- return _context.abrupt("break", 90);
372
+ _int = num * 1000;
373
+ return _context.abrupt("break", 92);
372
374
  case 82:
373
- _int = num * 1000 * 60 * 60;
374
- return _context.abrupt("break", 90);
375
+ _int = num * 1000 * 60;
376
+ return _context.abrupt("break", 92);
375
377
  case 84:
376
- _int = num * 1000 * 60 * 60 * 24;
377
- return _context.abrupt("break", 90);
378
+ _int = num * 1000 * 60 * 60;
379
+ return _context.abrupt("break", 92);
378
380
  case 86:
379
- _int = num * 1000 * 60 * 60 * 24 * 30;
380
- return _context.abrupt("break", 90);
381
+ _int = num * 1000 * 60 * 60 * 24;
382
+ return _context.abrupt("break", 92);
381
383
  case 88:
382
- _int = num * 1000 * 60 * 60 * 24 * 365;
383
- return _context.abrupt("break", 90);
384
+ _int = num * 1000 * 60 * 60 * 24 * 30;
385
+ return _context.abrupt("break", 92);
384
386
  case 90:
387
+ _int = num * 1000 * 60 * 60 * 24 * 365;
388
+ return _context.abrupt("break", 92);
389
+ case 92:
385
390
  cronTags = [];
386
391
  for (_k in _tags) {
387
392
  if (/^Cron-Tag-/.test(_k)) {
@@ -393,9 +398,9 @@ var connect = exports.connect = function connect(mem) {
393
398
  }
394
399
  mem.env[id].cronTags = cronTags;
395
400
  mem.env[id].span = _int;
396
- case 94:
401
+ case 96:
397
402
  return _context.abrupt("return", id);
398
- case 95:
403
+ case 97:
399
404
  case "end":
400
405
  return _context.stop();
401
406
  }
package/esm/ao.js CHANGED
@@ -333,6 +333,7 @@ class AO {
333
333
  boot,
334
334
  module = this.module,
335
335
  scheduler = this.scheduler,
336
+ memory,
336
337
  jwk,
337
338
  tags = {},
338
339
  data,
@@ -348,6 +349,7 @@ class AO {
348
349
  if (!tags.Authority && this.authority) tags.Authority = this.authority
349
350
  let _tags = buildTags(null, tags)
350
351
  pid = await this.spawn({
352
+ memory,
351
353
  module,
352
354
  scheduler,
353
355
  signer: this.toSigner(jwk),
@@ -358,7 +360,8 @@ class AO {
358
360
  console.log(e)
359
361
  err = e
360
362
  }
361
- return { err, pid }
363
+ const p = pid ? this.p(pid) : null
364
+ return { err, pid, p }
362
365
  }
363
366
 
364
367
  async msg({
package/esm/aoconnect.js CHANGED
@@ -167,7 +167,7 @@ export const connect = (mem, { log = false, extensions = {} } = {}) => {
167
167
 
168
168
  const _tags = tags(opt.tags)
169
169
  let res = null
170
- let memory = null
170
+ let memory = opt.memory ?? null
171
171
  let p = {
172
172
  id: id,
173
173
  epochs: [],
@@ -182,7 +182,9 @@ export const connect = (mem, { log = false, extensions = {} } = {}) => {
182
182
  txs: [],
183
183
  opt,
184
184
  }
185
- if (_tags["On-Boot"] || true) {
185
+ if (memory) {
186
+ // forking...
187
+ } else if (_tags["On-Boot"] || true) {
186
188
  let data = ""
187
189
  if (_tags["On-Boot"] === "Data") data = opt.data ?? ""
188
190
  else data = mem.msgs[_tags["On-Boot"]]?.data ?? ""
@@ -193,7 +195,6 @@ export const connect = (mem, { log = false, extensions = {} } = {}) => {
193
195
  module: p.module,
194
196
  auth: mu.addr,
195
197
  })
196
- const _t = tags(msg.Tags)
197
198
  res = await _module.handle(null, msg, _env)
198
199
  p.memory = res.Memory
199
200
  delete res.Memory
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wao",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "description": "",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",