wao 0.4.1 → 0.4.3

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/tar.js CHANGED
@@ -99,7 +99,7 @@ var AR = /*#__PURE__*/function (_MAR) {
99
99
  key: "post",
100
100
  value: function () {
101
101
  var _post = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref2) {
102
- var _ref2$data, data, _ref2$tags, tags, jwk, tx, _tags, _iterator, _step, v;
102
+ var _ref2$data, data, _ref2$tags, tags, jwk, tx, _tags, _iterator, _step, v, owner;
103
103
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
104
104
  while (1) switch (_context2.prev = _context2.next) {
105
105
  case 0:
@@ -122,26 +122,21 @@ var AR = /*#__PURE__*/function (_MAR) {
122
122
  } finally {
123
123
  _iterator.f();
124
124
  }
125
- _context2.t0 = this;
126
- _context2.t1 = tx;
127
- _context2.t2 = jwk;
128
- _context2.t3 = _tags;
129
- _context2.t4 = data;
130
- _context2.next = 14;
125
+ _context2.next = 9;
131
126
  return this.arweave.wallets.jwkToAddress(jwk);
132
- case 14:
133
- _context2.t5 = _context2.sent;
134
- _context2.t6 = {
127
+ case 9:
128
+ owner = _context2.sent;
129
+ this.mem.addrmap[owner] = jwk.n;
130
+ _context2.next = 13;
131
+ return this.postTx(tx, jwk, {
135
132
  recipient: "",
136
- tags: _context2.t3,
137
- data: _context2.t4,
138
- owner: _context2.t5
139
- };
140
- _context2.next = 18;
141
- return _context2.t0.postTx.call(_context2.t0, _context2.t1, _context2.t2, _context2.t6);
142
- case 18:
133
+ tags: _tags,
134
+ data: data,
135
+ owner: owner
136
+ });
137
+ case 13:
143
138
  return _context2.abrupt("return", _context2.sent);
144
- case 19:
139
+ case 14:
145
140
  case "end":
146
141
  return _context2.stop();
147
142
  }
@@ -156,7 +151,7 @@ var AR = /*#__PURE__*/function (_MAR) {
156
151
  key: "postItem",
157
152
  value: function () {
158
153
  var _postItem = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(item, jwk) {
159
- var tx, di, rowner, hashBuffer, owner, data, _item;
154
+ var tx, di, data_size, data_type, _iterator2, _step2, t, rowner, hashBuffer, owner, data, _item;
160
155
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
161
156
  while (1) switch (_context3.prev = _context3.next) {
162
157
  case 0:
@@ -169,19 +164,39 @@ var AR = /*#__PURE__*/function (_MAR) {
169
164
  tx.addTag("Bundle-Format", "binary");
170
165
  tx.addTag("Bundle-Version", "2.0.0");
171
166
  di = new _warpArbundles.DataItem(item.raw);
167
+ data_size = Buffer.byteLength(di.rawData).toString();
168
+ data_type = "";
169
+ _iterator2 = _createForOfIteratorHelper(di.tags);
170
+ try {
171
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
172
+ t = _step2.value;
173
+ if (t.name === "Content-Type") data_type = t.value;
174
+ }
175
+ } catch (err) {
176
+ _iterator2.e(err);
177
+ } finally {
178
+ _iterator2.f();
179
+ }
172
180
  rowner = di.rawOwner;
173
181
  _context3.t0 = Buffer;
174
- _context3.next = 10;
182
+ _context3.next = 14;
175
183
  return crypto.subtle.digest("SHA-256", rowner);
176
- case 10:
184
+ case 14:
177
185
  _context3.t1 = _context3.sent;
178
186
  hashBuffer = _context3.t0.from.call(_context3.t0, _context3.t1);
179
187
  owner = _base64url["default"].encode(hashBuffer);
188
+ this.mem.addrmap[owner] = di.owner;
180
189
  data = di.data;
181
190
  try {
182
191
  data = _base64url["default"].decode(di.data);
183
192
  } catch (e) {}
184
193
  _item = {
194
+ _data: {
195
+ size: data_size,
196
+ type: data_type
197
+ },
198
+ anchor: di.anchor,
199
+ signature: di.signature,
185
200
  recipient: di.target,
186
201
  id: item.id,
187
202
  item: di,
@@ -190,11 +205,11 @@ var AR = /*#__PURE__*/function (_MAR) {
190
205
  data: data
191
206
  };
192
207
  this.mem.txs[item.id] = _item;
193
- _context3.next = 19;
208
+ _context3.next = 24;
194
209
  return this.postTx(tx, jwk, _item);
195
- case 19:
210
+ case 24:
196
211
  return _context3.abrupt("return", _context3.sent);
197
- case 20:
212
+ case 25:
198
213
  case "end":
199
214
  return _context3.stop();
200
215
  }
@@ -209,7 +224,7 @@ var AR = /*#__PURE__*/function (_MAR) {
209
224
  key: "postTx",
210
225
  value: function () {
211
226
  var _postTx = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(tx, jwk, item) {
212
- var res, err, _last, block;
227
+ var res, err, _last, block, data_type, _iterator3, _step3, v, owner;
213
228
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
214
229
  while (1) switch (_context4.prev = _context4.next) {
215
230
  case 0:
@@ -228,19 +243,40 @@ var AR = /*#__PURE__*/function (_MAR) {
228
243
  if (!item.id) {
229
244
  item.id = tx.id;
230
245
  this.mem.txs[item.id] = item;
231
- this.mem.txs[item.id].parent = {
232
- id: block.id
246
+ this.mem.txs[item.id].parent = null;
247
+ this.mem.txs[item.id].signature = tx.signature;
248
+ this.mem.txs[item.id].anchor = tx.last_tx;
249
+ data_type = "";
250
+ _iterator3 = _createForOfIteratorHelper(tx.tags);
251
+ try {
252
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
253
+ v = _step3.value;
254
+ if (v.get("name", {
255
+ decode: true,
256
+ string: true
257
+ }) === "Content-Type") {
258
+ data_type = v.get("value", {
259
+ decode: true,
260
+ string: true
261
+ });
262
+ }
263
+ }
264
+ } catch (err) {
265
+ _iterator3.e(err);
266
+ } finally {
267
+ _iterator3.f();
268
+ }
269
+ this.mem.txs[item.id]._data = {
270
+ size: tx.data_size,
271
+ type: data_type
233
272
  };
234
273
  } else {
235
274
  this.mem.txs[item.id].parent = {
236
- id: ""
275
+ id: block.id
237
276
  };
238
277
  }
239
278
  block.txs = [item.id];
240
279
  this.mem.txs[item.id].block = block.id;
241
- this.mem.txs[item.id].parent = {
242
- id: block.id
243
- };
244
280
  this.mem.blocks.push(block.id);
245
281
  this.mem.blockmap[block.id] = block;
246
282
  }
@@ -249,12 +285,17 @@ var AR = /*#__PURE__*/function (_MAR) {
249
285
  status: 200,
250
286
  statusText: "200"
251
287
  };
288
+ _context4.next = 7;
289
+ return this.arweave.wallets.jwkToAddress(jwk);
290
+ case 7:
291
+ owner = _context4.sent;
292
+ this.mem.addrmap[owner] = jwk.n;
252
293
  return _context4.abrupt("return", {
253
294
  res: res,
254
295
  err: err,
255
296
  id: tx.id
256
297
  });
257
- case 6:
298
+ case 10:
258
299
  case "end":
259
300
  return _context4.stop();
260
301
  }
package/cjs/test.js CHANGED
@@ -16,6 +16,12 @@ Object.defineProperty(exports, "AR", {
16
16
  return _tar["default"];
17
17
  }
18
18
  });
19
+ Object.defineProperty(exports, "Src", {
20
+ enumerable: true,
21
+ get: function get() {
22
+ return _helpers.Src;
23
+ }
24
+ });
19
25
  Object.defineProperty(exports, "acc", {
20
26
  enumerable: true,
21
27
  get: function get() {
@@ -35,13 +41,31 @@ Object.defineProperty(exports, "cu", {
35
41
  return _accounts.cu;
36
42
  }
37
43
  });
44
+ Object.defineProperty(exports, "fail", {
45
+ enumerable: true,
46
+ get: function get() {
47
+ return _helpers.fail;
48
+ }
49
+ });
38
50
  Object.defineProperty(exports, "mu", {
39
51
  enumerable: true,
40
52
  get: function get() {
41
53
  return _accounts.mu;
42
54
  }
43
55
  });
56
+ Object.defineProperty(exports, "ok", {
57
+ enumerable: true,
58
+ get: function get() {
59
+ return _helpers.ok;
60
+ }
61
+ });
44
62
  exports.scheduler = void 0;
63
+ Object.defineProperty(exports, "setup", {
64
+ enumerable: true,
65
+ get: function get() {
66
+ return _helpers.setup;
67
+ }
68
+ });
45
69
  Object.defineProperty(exports, "su", {
46
70
  enumerable: true,
47
71
  get: function get() {
@@ -55,6 +79,7 @@ var _aoconnect = require("./aoconnect.js");
55
79
  var _tao = _interopRequireDefault(require("./tao.js"));
56
80
  var _tar = _interopRequireDefault(require("./tar.js"));
57
81
  var _utils = require("./utils.js");
82
+ var _helpers = require("./helpers.js");
58
83
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
59
84
  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; }
60
85
  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); }
package/cjs/tgql.js CHANGED
@@ -348,27 +348,27 @@ var GQL = exports["default"] = /*#__PURE__*/function () {
348
348
  case 91:
349
349
  _tx = _objectSpread(_objectSpread({
350
350
  cursor: tx.id
351
- }, tx), {}, {
351
+ }, tx), {}, _defineProperty({
352
+ data: tx._data,
352
353
  block: (0, _ramda.pick)(["id", "timestamp", "height", "previous"], block),
353
354
  anchor: (_tx$anchor = tx.anchor) !== null && _tx$anchor !== void 0 ? _tx$anchor : "",
354
355
  signature: (_tx$signature = tx.signature) !== null && _tx$signature !== void 0 ? _tx$signature : "",
355
356
  owner: {
356
357
  address: tx.owner,
357
- key: ""
358
+ key: this.mem.addrmap[tx.owner]
358
359
  },
359
360
  fee: {
360
- ar: 0,
361
- winston: 0
361
+ ar: "0",
362
+ winston: "0"
362
363
  },
363
364
  quantity: {
364
- ar: 0,
365
- winston: 0
366
- },
367
- data: {
368
- size: 0,
369
- type: ""
365
+ ar: "0",
366
+ winston: "0"
370
367
  }
371
- });
368
+ }, "data", {
369
+ size: "0",
370
+ type: ""
371
+ }));
372
372
  if (!(0, _ramda.isNil)(opt.fields)) {
373
373
  _tx2 = {
374
374
  cursor: tx.id
@@ -1 +1 @@
1
- {"ar":{"port":4000},"jwk":{"kty":"RSA","n":"vAiSYEBIogdeHhE1c-WoZOrrpsqing6sDQffTJYI7v2Hik7WkjhtxoXH3xlWk-dfUUXdntGEoaU9cBIdBz4EczxIkvBZ0e2bJQgDrZfbuQgy7RMdcvvCDQYXhQqF_DkmCbxDjpnP_W_Z3wL_7Sil5Ru5Jj_M_c6cyODuOiv8WZUZRi1KCoSuUVZr6dgiqGmzU_tBtZgoEtStKb29RHtT0PgpktWTYTk1nHWpOrA0mJMivrDdLmLfexFe_bPpZp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aN5FrEv3oCA_ApxFD62Gw_oyEmWdJD4Kh6ti4epi70f_FPv8MTSYzOnIHwo_J8SSH98CwJbuKpIZ9uUmeLMtelAECsMblLMTiUaRrXnTM9WezXwjwFqqqf7LTapzGPC0W4U7vRyV6ZpFzJ_VdLlWKMcsoByw6E-iUP3eE8qsvmfFdY4N1dBOU0FdRdf96BZUYA69pZ3pylykjUWK6rnATMl8dYN5yGecDdDCNleQjRv9n3kmIOpBGCt9qLvpi66HHzlCpt0AQTSQ41GqKvnN6hOJh7pNI_qfMvI9cBhsdUa3HEzaE7N3tzlVke37BQYMmSO88grsX5jIV_nc8BZ4EQ","qi":"8XcLLnE-6jPJURB3K-BNPBylUxXwQwEeMs4MX7tFXqxnnh2A23tVhOXESEb6PDkKe2Gql78B6_WrbtiTozV_-c6M0VjqGHRor62dBCvef9mUpiPUxkbflwlmcbqGTuiCNZyoZxR-8Pf0E2al2WxEkKeQjkplNHWt433A6hbx3rx8HsWAdM4RhY3LMsddGpFMc5gjm5PmTKo33uC15X16SmpC00SeVDnKaoiWWI3005RmMP2Wfago9XCTEwBsWeozQC7R2zI3CuW7jX3W6UeUYPoEeS3Qa0suCP4CqCbfNwstl-SQhWtm2IVBpbOZTDQ6e0cYUyyMGVh1AMCoehHMrw"},"module_sqlite":"I2E4Uu9bVmxCmXmfSfwQ3hOosbGRIKpF5qebATBylzs","ao":{"module":"I2E4Uu9bVmxCmXmfSfwQ3hOosbGRIKpF5qebATBylzs","scheduler":"9uDpdXg7JjC8xonD61nylkcjA2QYIti7jqSKgxOuLWs","aoconnect":{"MU_URL":"http://localhost:4002","CU_URL":"http://localhost:4004","GATEWAY_URL":"http://localhost:4000"},"ar":{"port":4000},"authority":"XztbUZU7D8lAcWlbg0avCD0s2lMBbFGgTC4YzLcOR90"},"ao2":{"module":"KCRP66Aq-4uQ7R556SgaNtzDNSnRJW4DA1m5sgxirDk","scheduler":"9uDpdXg7JjC8xonD61nylkcjA2QYIti7jqSKgxOuLWs","aoconnect":{"MU_URL":"http://localhost:4002","CU_URL":"http://localhost:4004","GATEWAY_URL":"http://localhost:4000"},"ar":{"port":4000},"authority":"XztbUZU7D8lAcWlbg0avCD0s2lMBbFGgTC4YzLcOR90"},"profile":{"module":"I2E4Uu9bVmxCmXmfSfwQ3hOosbGRIKpF5qebATBylzs","registry_src":"maJGJ2tAa6zVtW1rGhngNlhEZDUqbCwO3r5mYxDBCsQ","registry":"yRmn7BZDk_c916ZNy8JBY-H52vYMrP8SBp-npeOgAbU","profile_src":"LNTKw-wvmybqSrxvtMYtdplOADLAey1c8FpNXoMa638","ao":{"module":"I2E4Uu9bVmxCmXmfSfwQ3hOosbGRIKpF5qebATBylzs","scheduler":"9uDpdXg7JjC8xonD61nylkcjA2QYIti7jqSKgxOuLWs","aoconnect":{"MU_URL":"http://localhost:4002","CU_URL":"http://localhost:4004","GATEWAY_URL":"http://localhost:4000"},"ar":{"port":4000},"authority":"XztbUZU7D8lAcWlbg0avCD0s2lMBbFGgTC4YzLcOR90"}},"note":{"proxy":"0uUOLKRlt-4zume2JnSeIYFlSK6-5mH51kdj6o3Q4jw","note_src":"XmteOz1FGAFKGLRtVQo65-ggchiQJ1bJ7OrHueZDK8I","profile":{"module":"I2E4Uu9bVmxCmXmfSfwQ3hOosbGRIKpF5qebATBylzs","registry_src":"maJGJ2tAa6zVtW1rGhngNlhEZDUqbCwO3r5mYxDBCsQ","registry":"yRmn7BZDk_c916ZNy8JBY-H52vYMrP8SBp-npeOgAbU","profile_src":"LNTKw-wvmybqSrxvtMYtdplOADLAey1c8FpNXoMa638","ao":{"module":"I2E4Uu9bVmxCmXmfSfwQ3hOosbGRIKpF5qebATBylzs","scheduler":"9uDpdXg7JjC8xonD61nylkcjA2QYIti7jqSKgxOuLWs","aoconnect":{"MU_URL":"http://localhost:4002","CU_URL":"http://localhost:4004","GATEWAY_URL":"http://localhost:4000"},"ar":{"port":4000},"authority":"XztbUZU7D8lAcWlbg0avCD0s2lMBbFGgTC4YzLcOR90"}}},"notebook":{"notebook_src":"cAa0NBOgYfQPRH6DEcKxrLBm4QExws4FCKAyP-LHufg","registry":"EGVoxgKS9V4z6w21RJ9HiM3Q6TcwgwdwX8INSUTUuKE","registry_src":"6EX6wZ8RfUHbSfUvhU5Aby7q52czm0T-RckiOrIG4Wc","profile":{"module":"I2E4Uu9bVmxCmXmfSfwQ3hOosbGRIKpF5qebATBylzs","registry_src":"maJGJ2tAa6zVtW1rGhngNlhEZDUqbCwO3r5mYxDBCsQ","registry":"yRmn7BZDk_c916ZNy8JBY-H52vYMrP8SBp-npeOgAbU","profile_src":"LNTKw-wvmybqSrxvtMYtdplOADLAey1c8FpNXoMa638","ao":{"module":"I2E4Uu9bVmxCmXmfSfwQ3hOosbGRIKpF5qebATBylzs","scheduler":"9uDpdXg7JjC8xonD61nylkcjA2QYIti7jqSKgxOuLWs","aoconnect":{"MU_URL":"http://localhost:4002","CU_URL":"http://localhost:4004","GATEWAY_URL":"http://localhost:4000"},"ar":{"port":4000},"authority":"XztbUZU7D8lAcWlbg0avCD0s2lMBbFGgTC4YzLcOR90"}}},"asset":{"asset_src":"sZe0uqoLAlzFtFcATqERh_Jg3yvyJ-P1Fp7MstYUr8E","profile":{"module":"I2E4Uu9bVmxCmXmfSfwQ3hOosbGRIKpF5qebATBylzs","registry_src":"maJGJ2tAa6zVtW1rGhngNlhEZDUqbCwO3r5mYxDBCsQ","registry":"yRmn7BZDk_c916ZNy8JBY-H52vYMrP8SBp-npeOgAbU","profile_src":"LNTKw-wvmybqSrxvtMYtdplOADLAey1c8FpNXoMa638","ao":{"module":"I2E4Uu9bVmxCmXmfSfwQ3hOosbGRIKpF5qebATBylzs","scheduler":"9uDpdXg7JjC8xonD61nylkcjA2QYIti7jqSKgxOuLWs","aoconnect":{"MU_URL":"http://localhost:4002","CU_URL":"http://localhost:4004","GATEWAY_URL":"http://localhost:4000"},"ar":{"port":4000},"authority":"XztbUZU7D8lAcWlbg0avCD0s2lMBbFGgTC4YzLcOR90"}}},"collection":{"collection_src":"5MGgg1uHqI04MS7ZZNJSDYld2CqxyC9Aws08k4VZey0","registry":"EGVoxgKS9V4z6w21RJ9HiM3Q6TcwgwdwX8INSUTUuKE","registry_src":"6EX6wZ8RfUHbSfUvhU5Aby7q52czm0T-RckiOrIG4Wc","profile":{"module":"I2E4Uu9bVmxCmXmfSfwQ3hOosbGRIKpF5qebATBylzs","registry_src":"maJGJ2tAa6zVtW1rGhngNlhEZDUqbCwO3r5mYxDBCsQ","registry":"yRmn7BZDk_c916ZNy8JBY-H52vYMrP8SBp-npeOgAbU","profile_src":"LNTKw-wvmybqSrxvtMYtdplOADLAey1c8FpNXoMa638","ao":{"module":"I2E4Uu9bVmxCmXmfSfwQ3hOosbGRIKpF5qebATBylzs","scheduler":"9uDpdXg7JjC8xonD61nylkcjA2QYIti7jqSKgxOuLWs","aoconnect":{"MU_URL":"http://localhost:4002","CU_URL":"http://localhost:4004","GATEWAY_URL":"http://localhost:4000"},"ar":{"port":4000},"authority":"XztbUZU7D8lAcWlbg0avCD0s2lMBbFGgTC4YzLcOR90"}}},"modules":{"aos2":"KCRP66Aq-4uQ7R556SgaNtzDNSnRJW4DA1m5sgxirDk","aos1":"WpmAgOtIAWrtwyrMpWQv8bsINlFo9N8qu8lXng-Hjv0","sqlite":"I2E4Uu9bVmxCmXmfSfwQ3hOosbGRIKpF5qebATBylzs"}}
1
+ {"ar":{"port":4000},"jwk":{"kty":"RSA","n":"tBba3N1KKiDvu4TnAd_lhYDBXs0QrLH4Hgd6mHTeovFvZDLZHlNukT9SXeHx1_58hQWtcIPvS6F9tASdpMREKMVkG9hb6nMXtUCkTJE7PURvqeJf5VGJt9rUBtYaaJ_8eVJ3w98_RqUR0k0rYsYcJqiFFYaSFG2mIbyP7lBSUifF0dsOI1j1IRlvhZ02BOD7LJpwycX-fsXq7DAbpC6ywkuQ0EU830f3DefhfCQRRreZiKKNHRVvKhe9Z8LTjtMWHcAotg5-lLWLVUT1fO5tUnVwcJ_fGGFtLC1RGjry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IwVp49oAfETuidCxgAtV8fbnhSzDWa2ZqwR2SqGAIozanmgdff-S3z1-JkiXCLb7ArTyOiZ6HltprbZJYEpbZoLt64GZI8N8BXrIUusqL67FMsFZv7XcHIQuKmt_N_7RHr_btJ3PwIIjT-Nlbl6X2mf6WUBLXP1I9LaRqrM_6ooBtpspb-Hipzszmtd9cd-mBILONZIBmteEky3jrJzLmrZ397BkzaEd4AIfSkpNtlR9SlnK3uA-brCG50SDheK_zbfDXTVe5UbxmeonKIWe6sDL_GgPmV-a0WKkOQ","qi":"ri8WWvi1zib1qNyqXjFvsqi3AdgmH-QFt_cnx4F8vyeEd-4VPP9Ne6I-cr6-BtYJbfZSkpuBY9G7RLnRHnyY9nlbBPyP9mdJiBgs8f5-__2_pKhO5pvzRPCU-N-YLQH0NAKIYlSfWarObe84SW5Ds0OUb46WuoRGDqrLIokt2HxFi6uA_ZzuEvdmxZk9HWRRaPiKCif3uJfZtJ3_4WxpFvw-IYY3p8m3nt9qdU8EPhiZBEKdYdyAkHN6bIN9GbpUpUbEwYJXTCtqOgG4nuiWl8HWijk7QgcEO1gRG-pt4HzzFTa01BBIxdbelBii35uUoUVzco3dntUghotXOMGeCg"},"ao":{"module":"nrwqdbTzLYTALBkzLv9HwmF97b0eoGvlT3YwfJnyOjY","scheduler":"FKtGpY1kBbr8hBIocph3nMvadgBSQtQBTYnlAJetrDU","aoconnect":{"MU_URL":"http://localhost:4002","CU_URL":"http://localhost:4004","GATEWAY_URL":"http://localhost:4000"},"ar":{"port":4000},"authority":"7WspynohDWhx3_Q37pzHmDGStf2T_p8ghdk_XTSUm8s"},"ao2":{"module":"9Xx6YzV2-giIaD8b9HTewr0FxRjugwm5FCuaQU-kJvI","scheduler":"FKtGpY1kBbr8hBIocph3nMvadgBSQtQBTYnlAJetrDU","aoconnect":{"MU_URL":"http://localhost:4002","CU_URL":"http://localhost:4004","GATEWAY_URL":"http://localhost:4000"},"ar":{"port":4000},"authority":"7WspynohDWhx3_Q37pzHmDGStf2T_p8ghdk_XTSUm8s"},"authority":"7WspynohDWhx3_Q37pzHmDGStf2T_p8ghdk_XTSUm8s","targets":{"profile":false,"note":false,"asset":false},"modules":{"aos2":"9Xx6YzV2-giIaD8b9HTewr0FxRjugwm5FCuaQU-kJvI","aos1":"MSCReWoRQ3w3JmPvbsTvPFnJrdzPym0F61cdBGEsBgs","sqlite":"nrwqdbTzLYTALBkzLv9HwmF97b0eoGvlT3YwfJnyOjY"}}
package/esm/aoconnect.js CHANGED
@@ -1,5 +1,7 @@
1
1
  import { DataItem } from "warp-arbundles"
2
+ import crypto from "crypto"
2
3
  import base64url from "base64url"
4
+
3
5
  import {
4
6
  tags,
5
7
  action,
@@ -121,6 +123,18 @@ export const connect = mem => {
121
123
  mem.modmap[mod] = { handle, id: mod }
122
124
  }
123
125
  if (!mod) throw Error("module not found")
126
+ opt.tags = buildTags(
127
+ null,
128
+ mergeLeft(tags(opt.tags ?? []), {
129
+ "Data-Protocol": "ao",
130
+ Variant: "ao.TN.1",
131
+ Type: "Process",
132
+ SDK: "aoconnect",
133
+ Module: opt.module,
134
+ Scheduler: opt.scheduler,
135
+ "Content-Type": "text/plain",
136
+ }),
137
+ )
124
138
  const _module = mem.modmap[mod]
125
139
  let ex = false
126
140
  opt.tags ??= []
@@ -137,8 +151,10 @@ export const connect = mem => {
137
151
  let memory = null
138
152
  let p = {
139
153
  id: id,
154
+ epochs: [],
140
155
  handle: _module.handle,
141
156
  module: _module.id,
157
+ hash: id,
142
158
  memory,
143
159
  owner,
144
160
  height: 0,
@@ -207,62 +223,38 @@ export const connect = mem => {
207
223
  return id
208
224
  }
209
225
 
210
- const assign = async opt => {
211
- const p = mem.env[opt.process]
212
- let _opt = clone(mem.msgs[opt.message])
213
- const { id, owner, item } = await ar.dataitem({
214
- data: _opt.data,
215
- signer: _opt.signer,
216
- tags: tags(_opt.tags),
217
- target: opt.process,
218
- })
219
- await ar.postItem(item, su.jwk)
220
- try {
221
- const msg = genMsg(
222
- p,
223
- _opt.data ?? "",
224
- _opt.tags,
225
- _opt.from ?? owner,
226
- mu.addr,
227
- )
228
- const _env = genEnv({
229
- pid: p.id,
230
- owner: p.owner,
231
- module: p.module,
232
- auth: mu.addr,
233
- })
234
- const res = await p.handle(p.memory, msg, _env)
235
- p.memory = res.Memory
236
- delete res.Memory
237
- p.res[id] = res
238
- p.results.push(id)
239
- p.txs.unshift({ id: id, ..._opt })
240
- mem.msgs[id] = _opt
241
- for (const v of res.Messages ?? []) {
242
- if (mem.env[v.Target]) {
243
- await message({
244
- process: v.Target,
245
- tags: v.Tags,
246
- data: v.Data,
247
- signer: mu.signer,
248
- from: opt.process,
249
- })
250
- }
251
- }
252
- return id
253
- } catch (e) {
254
- console.log(e)
226
+ function genHashChain(previousHash, previousMessageId = null) {
227
+ const hasher = crypto.createHash("sha256")
228
+ hasher.update(Buffer.from(previousHash, "base64url"))
229
+ if (previousMessageId) {
230
+ hasher.update(Buffer.from(previousMessageId, "base64url"))
255
231
  }
256
- return null
232
+ return base64url(hasher.digest())
257
233
  }
258
234
 
259
- const message = async opt => {
235
+ const assign = async opt => {
260
236
  const p = mem.env[opt.process]
261
- let ex = false
262
- for (let v of opt.tags) if (v.name === "Type") ex = true
263
-
264
- if (!ex) opt.tags.push({ name: "Type", value: "Message" })
265
- const { item, id, owner } = await ar.dataitem({
237
+ let _opt = mem.msgs[opt.message]
238
+ let hash = genHashChain(p.hash, opt.message)
239
+ p.hash = hash
240
+ opt.tags = buildTags(
241
+ null,
242
+ mergeLeft(tags(opt.tags ?? []), {
243
+ Timestamp: Date.now(),
244
+ Epoch: p.epochs.length,
245
+ Nonce: "0",
246
+ "Data-Protocol": "ao",
247
+ Variant: "ao.TN.1",
248
+ SDK: "aoconnect",
249
+ Type: "Assignment",
250
+ "Block-Height": mem.height,
251
+ Process: opt.process,
252
+ Message: opt.message,
253
+ "Hash-Chain": hash,
254
+ }),
255
+ )
256
+ p.epochs.push([opt.id])
257
+ const { id, owner, item } = await ar.dataitem({
266
258
  data: opt.data,
267
259
  signer: opt.signer,
268
260
  tags: tags(opt.tags),
@@ -272,9 +264,9 @@ export const connect = mem => {
272
264
  try {
273
265
  const msg = genMsg(
274
266
  p,
275
- opt.data ?? "",
276
- opt.tags,
277
- opt.from ?? owner,
267
+ _opt.data ?? "",
268
+ _opt.tags,
269
+ _opt.from ?? opt.from ?? owner,
278
270
  mu.addr,
279
271
  )
280
272
  const _env = genEnv({
@@ -286,10 +278,10 @@ export const connect = mem => {
286
278
  const res = await p.handle(p.memory, msg, _env)
287
279
  p.memory = res.Memory
288
280
  delete res.Memory
289
- p.res[id] = res
290
- p.results.push(id)
291
- p.txs.unshift({ id: id, ...opt })
292
- mem.msgs[id] = opt
281
+ p.res[opt.message] = res
282
+ p.results.push(opt.message)
283
+ p.txs.unshift({ id: opt.message, ...opt })
284
+ mem.msgs[opt.message] = _opt
293
285
  for (const v of res.Messages ?? []) {
294
286
  if (mem.env[v.Target]) {
295
287
  await message({
@@ -322,6 +314,7 @@ export const connect = mem => {
322
314
  })
323
315
  }
324
316
  }
317
+
325
318
  return id
326
319
  } catch (e) {
327
320
  console.log(e)
@@ -329,6 +322,36 @@ export const connect = mem => {
329
322
  return null
330
323
  }
331
324
 
325
+ const message = async opt => {
326
+ const p = mem.env[opt.process]
327
+ let ex = false
328
+ for (let v of opt.tags) if (v.name === "Type") ex = true
329
+ opt.tags = buildTags(
330
+ null,
331
+ mergeLeft(tags(opt.tags ?? []), {
332
+ "Data-Protocol": "ao",
333
+ Variant: "ao.TN.1",
334
+ Type: "Message",
335
+ SDK: "aoconnect",
336
+ }),
337
+ )
338
+ const { item, id, owner } = await ar.dataitem({
339
+ data: opt.data,
340
+ signer: opt.signer,
341
+ tags: tags(opt.tags),
342
+ target: opt.process,
343
+ })
344
+ await ar.postItem(item, su.jwk)
345
+ mem.msgs[id] = opt
346
+ await assign({
347
+ message: id,
348
+ process: opt.process,
349
+ from: owner,
350
+ signer: mu.signer,
351
+ })
352
+ return id
353
+ }
354
+
332
355
  return {
333
356
  message,
334
357
  unmonitor: async opt => {
package/esm/armem.js CHANGED
@@ -11,6 +11,7 @@ export default class ArMem {
11
11
  : last(this.blockmap[last(this.blocks)].txs)
12
12
  }
13
13
  this.arweave.transactions.getPrice = () => 0
14
+ this.addrmap = {}
14
15
  this.txs = {}
15
16
  this.jwks = {}
16
17
  this.height = 0
package/esm/tar.js CHANGED
@@ -30,11 +30,13 @@ class AR extends MAR {
30
30
  let tx = await this.arweave.createTransaction({ data: data })
31
31
  let _tags = buildTags(null, tags)
32
32
  for (const v of _tags) tx.addTag(v.name, v.value)
33
+ const owner = await this.arweave.wallets.jwkToAddress(jwk)
34
+ this.mem.addrmap[owner] = jwk.n
33
35
  return await this.postTx(tx, jwk, {
34
36
  recipient: "",
35
37
  tags: _tags,
36
38
  data,
37
- owner: await this.arweave.wallets.jwkToAddress(jwk),
39
+ owner,
38
40
  })
39
41
  }
40
42
 
@@ -43,16 +45,23 @@ class AR extends MAR {
43
45
  tx.addTag("Bundle-Format", "binary")
44
46
  tx.addTag("Bundle-Version", "2.0.0")
45
47
  const di = new DataItem(item.raw)
48
+ const data_size = Buffer.byteLength(di.rawData).toString()
49
+ let data_type = ""
50
+ for (const t of di.tags) if (t.name === "Content-Type") data_type = t.value
46
51
  const rowner = di.rawOwner
47
52
  const hashBuffer = Buffer.from(
48
53
  await crypto.subtle.digest("SHA-256", rowner),
49
54
  )
50
55
  const owner = base64url.encode(hashBuffer)
56
+ this.mem.addrmap[owner] = di.owner
51
57
  let data = di.data
52
58
  try {
53
59
  data = base64url.decode(di.data)
54
60
  } catch (e) {}
55
61
  let _item = {
62
+ _data: { size: data_size, type: data_type },
63
+ anchor: di.anchor,
64
+ signature: di.signature,
56
65
  recipient: di.target,
57
66
  id: item.id,
58
67
  item: di,
@@ -69,28 +78,38 @@ class AR extends MAR {
69
78
  await this.mem.arweave.transactions.sign(tx, jwk)
70
79
  if (item) {
71
80
  this.mem.height += 1
72
-
73
81
  const block = {
74
82
  id: tx.id,
75
83
  timestamp: Date.now(),
76
84
  height: this.mem.height,
77
85
  previous: last(this.mem.blocks) ?? "",
78
86
  }
79
-
80
87
  if (!item.id) {
81
88
  item.id = tx.id
82
89
  this.mem.txs[item.id] = item
83
- this.mem.txs[item.id].parent = { id: block.id }
90
+ this.mem.txs[item.id].parent = null
91
+ this.mem.txs[item.id].signature = tx.signature
92
+ this.mem.txs[item.id].anchor = tx.last_tx
93
+ let data_type = ""
94
+ for (const v of tx.tags) {
95
+ if (
96
+ v.get("name", { decode: true, string: true }) === "Content-Type"
97
+ ) {
98
+ data_type = v.get("value", { decode: true, string: true })
99
+ }
100
+ }
101
+ this.mem.txs[item.id]._data = { size: tx.data_size, type: data_type }
84
102
  } else {
85
- this.mem.txs[item.id].parent = { id: "" }
103
+ this.mem.txs[item.id].parent = { id: block.id }
86
104
  }
87
105
  block.txs = [item.id]
88
106
  this.mem.txs[item.id].block = block.id
89
- this.mem.txs[item.id].parent = { id: block.id }
90
107
  this.mem.blocks.push(block.id)
91
108
  this.mem.blockmap[block.id] = block
92
109
  }
93
110
  res = { id: tx.id, status: 200, statusText: "200" }
111
+ const owner = await this.arweave.wallets.jwkToAddress(jwk)
112
+ this.mem.addrmap[owner] = jwk.n
94
113
  return { res, err, id: tx.id }
95
114
  }
96
115
 
package/esm/test.js CHANGED
@@ -5,10 +5,24 @@ import { connect } from "./aoconnect.js"
5
5
  import AO from "./tao.js"
6
6
  import AR from "./tar.js"
7
7
  import { dirname } from "./utils.js"
8
-
8
+ import { Src, setup, ok, fail } from "./helpers.js"
9
9
  const blueprint = async pkg => {
10
10
  return readFileSync(resolve(await dirname(), `lua/${pkg}.lua`), "utf8")
11
11
  }
12
12
  const scheduler = "GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA"
13
13
 
14
- export { AO, AR, connect, acc, mu, su, cu, blueprint, scheduler }
14
+ export {
15
+ AO,
16
+ AR,
17
+ connect,
18
+ acc,
19
+ mu,
20
+ su,
21
+ cu,
22
+ blueprint,
23
+ scheduler,
24
+ ok,
25
+ fail,
26
+ Src,
27
+ setup,
28
+ }
package/esm/tgql.js CHANGED
@@ -127,13 +127,14 @@ export default class GQL {
127
127
  let _tx = {
128
128
  cursor: tx.id,
129
129
  ...tx,
130
+ data: tx._data,
130
131
  block: pick(["id", "timestamp", "height", "previous"], block),
131
132
  anchor: tx.anchor ?? "",
132
133
  signature: tx.signature ?? "",
133
- owner: { address: tx.owner, key: "" },
134
- fee: { ar: 0, winston: 0 },
135
- quantity: { ar: 0, winston: 0 },
136
- data: { size: 0, type: "" },
134
+ owner: { address: tx.owner, key: this.mem.addrmap[tx.owner] },
135
+ fee: { ar: "0", winston: "0" },
136
+ quantity: { ar: "0", winston: "0" },
137
+ data: { size: "0", type: "" },
137
138
  }
138
139
  if (!isNil(opt.fields)) {
139
140
  let _tx2 = { cursor: tx.id }